mirror of
https://github.com/eledio-devices/thirdparty-ArduinoJson.git
synced 2025-11-01 16:14:05 +01:00
Merge branch 'master' into 6.x
This commit is contained in:
@@ -10,7 +10,9 @@ namespace Internals {
|
||||
template <typename TChar>
|
||||
struct CharPointerTraits {
|
||||
static bool equals(const TChar* str, const char* expected) {
|
||||
return strcmp(reinterpret_cast<const char*>(str), expected) == 0;
|
||||
const char* actual = reinterpret_cast<const char*>(str);
|
||||
if (!actual || !expected) return actual == expected;
|
||||
return strcmp(actual, expected) == 0;
|
||||
}
|
||||
|
||||
static bool is_null(const TChar* str) {
|
||||
|
||||
@@ -11,7 +11,9 @@ namespace Internals {
|
||||
template <>
|
||||
struct StringTraits<const __FlashStringHelper*, void> {
|
||||
static bool equals(const __FlashStringHelper* str, const char* expected) {
|
||||
return strcmp_P(expected, (const char*)str) == 0;
|
||||
const char* actual = reinterpret_cast<const char*>(str);
|
||||
if (!actual || !expected) return actual == expected;
|
||||
return strcmp_P(expected, actual) == 0;
|
||||
}
|
||||
|
||||
static bool is_null(const __FlashStringHelper* str) {
|
||||
@@ -33,7 +35,7 @@ struct StringTraits<const __FlashStringHelper*, void> {
|
||||
static const bool has_equals = true;
|
||||
static const bool should_duplicate = true;
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace Internals
|
||||
} // namespace ArduinoJson
|
||||
|
||||
#endif
|
||||
|
||||
@@ -36,7 +36,10 @@ struct StdStringTraits {
|
||||
}
|
||||
|
||||
static bool equals(const TString& str, const char* expected) {
|
||||
return 0 == strcmp(str.c_str(), expected);
|
||||
// Arduino's String::c_str() can return NULL
|
||||
const char* actual = str.c_str();
|
||||
if (!actual || !expected) return actual == expected;
|
||||
return 0 == strcmp(actual, expected);
|
||||
}
|
||||
|
||||
static void append(TString& str, char c) {
|
||||
@@ -64,7 +67,7 @@ struct StringTraits<StringSumHelper, void> : StdStringTraits<StringSumHelper> {
|
||||
template <>
|
||||
struct StringTraits<std::string, void> : StdStringTraits<std::string> {};
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace Internals
|
||||
} // namespace ArduinoJson
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user