string comparison which doesn't consider NULL pointers equal */
| 80 | |
| 81 | /* string comparison which doesn't consider NULL pointers equal */ |
| 82 | static int compare_strings(const unsigned char *string1, const unsigned char *string2, const cJSON_bool case_sensitive) |
| 83 | { |
| 84 | if ((string1 == NULL) || (string2 == NULL)) |
| 85 | { |
| 86 | return 1; |
| 87 | } |
| 88 | |
| 89 | if (string1 == string2) |
| 90 | { |
| 91 | return 0; |
| 92 | } |
| 93 | |
| 94 | if (case_sensitive) |
| 95 | { |
| 96 | return strcmp((const char *)string1, (const char *)string2); |
| 97 | } |
| 98 | |
| 99 | for (; tolower(*string1) == tolower(*string2); (void)string1++, string2++) |
| 100 | { |
| 101 | if (*string1 == '\0') |
| 102 | { |
| 103 | return 0; |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | return tolower(*string1) - tolower(*string2); |
| 108 | } |
| 109 | |
| 110 | /* securely comparison of floating-point variables */ |
| 111 | static cJSON_bool compare_double(double a, double b) |
no outgoing calls
no test coverage detected