From e4e2ec390d364770d16a3a478796c1b949e8645f Mon Sep 17 00:00:00 2001 From: Alexander Tkachev Date: Wed, 11 May 2016 14:02:32 +0600 Subject: CLOUD: Remove wcsncasecmp() usage from SimpleJSON Replaced with scumm_strnicmp(). --- common/json.cpp | 8 ++++---- common/json.h | 43 ------------------------------------------- 2 files changed, 4 insertions(+), 47 deletions(-) diff --git a/common/json.cpp b/common/json.cpp index 878c67e1ae..83ce0db29d 100644 --- a/common/json.cpp +++ b/common/json.cpp @@ -281,15 +281,15 @@ JSONValue *JSONValue::parse(const char **data) { return new JSONValue(str); } - // Is it a boolean? - else if ((simplejson_wcsnlen(*data, 4) && wcsncasecmp(*data, "true", 4) == 0) || (simplejson_wcsnlen(*data, 5) && wcsncasecmp(*data, "false", 5) == 0)) { - bool value = wcsncasecmp(*data, "true", 4) == 0; + // Is it a boolean? + else if ((simplejson_wcsnlen(*data, 4) && scumm_strnicmp(*data, "true", 4) == 0) || (simplejson_wcsnlen(*data, 5) && scumm_strnicmp(*data, "false", 5) == 0)) { + bool value = scumm_strnicmp(*data, "true", 4) == 0; (*data) += value ? 4 : 5; return new JSONValue(value); } // Is it a null? - else if (simplejson_wcsnlen(*data, 4) && wcsncasecmp(*data, "null", 4) == 0) { + else if (simplejson_wcsnlen(*data, 4) && scumm_strnicmp(*data, "null", 4) == 0) { (*data) += 4; return new JSONValue(); } diff --git a/common/json.h b/common/json.h index 5114947966..c9debf05af 100644 --- a/common/json.h +++ b/common/json.h @@ -54,8 +54,6 @@ // Win32 incompatibilities #if defined(WIN32) && !defined(__GNUC__) -#define wcsncasecmp _strnicmp - static inline bool isnan(double x) { return x != x; } @@ -65,44 +63,7 @@ static inline bool isinf(double x) { } #endif -// Linux compile fix - from quaker66 -#ifdef __GNUC__ - #include - #include -#endif - -// Mac compile fixes - from quaker66, Lion fix by dabrahams -// Tkachov: I probably broke those -#if defined(__APPLE__) && __DARWIN_C_LEVEL < 200809L || (defined(WIN32) && defined(__GNUC__)) || defined(ANDROID) - #include - #include - - static inline int wcsncasecmp(const char *s1, const char *s2, size_t n) - { - int lc1 = 0; - int lc2 = 0; - - while (n--) - { - lc1 = towlower (*s1); - lc2 = towlower (*s2); - - if (lc1 != lc2) - return (lc1 - lc2); - - if (!lc1) - return 0; - - ++s1; - ++s2; - } - - return 0; - } -#endif - // Simple function to check a string 's' has at least 'n' characters -// Tkachov: that's not wchar_t anymore, though it should work for C-strings too static inline bool simplejson_wcsnlen(const char *s, size_t n) { if (s == 0) return false; @@ -122,8 +83,6 @@ class JSONValue; typedef Array JSONArray; typedef HashMap JSONObject; -//JSONValue.h: - class JSON; enum JSONType { JSONType_Null, JSONType_String, JSONType_Bool, JSONType_Number, JSONType_Array, JSONType_Object }; @@ -183,8 +142,6 @@ private: }; -//EOF JSONValue.h - class JSON { friend class JSONValue; -- cgit v1.2.3