Fixed incorrect string comparison on some platforms (fixes #1198)

This commit is contained in:
Benoit Blanchon
2020-02-27 11:44:09 +01:00
parent 2996503b27
commit 2641697e0b
10 changed files with 110 additions and 57 deletions

View File

@ -0,0 +1,23 @@
#include <ArduinoJson/Namespace.hpp>
// Issue #1198: strcmp() implementation that returns a value larger than 8-bit
namespace ARDUINOJSON_NAMESPACE {
int strcmp(const char* a, const char* b) {
int result = ::strcmp(a, b);
if (result > 0)
return 2147483647;
if (result < 0)
return -214748364;
return 0;
}
int strncmp(const char* a, const char* b, size_t n) {
int result = ::strncmp(a, b, n);
if (result > 0)
return 2147483647;
if (result < 0)
return -214748364;
return 0;
}
} // namespace ARDUINOJSON_NAMESPACE