weird_strcmp.hpp 546 B

123456789101112131415161718192021222324
  1. #include <ArduinoJson/Namespace.hpp>
  2. // Issue #1198: strcmp() implementation that returns a value larger than 8-bit
  3. namespace ARDUINOJSON_NAMESPACE {
  4. int strcmp(const char* a, const char* b) {
  5. int result = ::strcmp(a, b);
  6. if (result > 0)
  7. return 2147483647;
  8. if (result < 0)
  9. return -214748364;
  10. return 0;
  11. }
  12. int strncmp(const char* a, const char* b, size_t n) {
  13. int result = ::strncmp(a, b, n);
  14. if (result > 0)
  15. return 2147483647;
  16. if (result < 0)
  17. return -214748364;
  18. return 0;
  19. }
  20. } // namespace ARDUINOJSON_NAMESPACE