diff options
author | George Hazan <george.hazan@gmail.com> | 2012-06-23 17:32:07 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-06-23 17:32:07 +0000 |
commit | 8c33681f317706acf4cd319927a2e37fc78c2256 (patch) | |
tree | 9b60033e353e050a7eaf534dfc2cff594f76d2ea | |
parent | d11afafa9a4ffcf5c33f64d55d1ce22e452d6120 (diff) |
- warning fixes
- code formatting
git-svn-id: http://svn.miranda-ng.org/main/trunk@577 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | include/m_json.h | 192 | ||||
-rw-r--r-- | src/miranda32_10.vcxproj | 7 | ||||
-rw-r--r-- | src/miranda32_10.vcxproj.filters | 3 | ||||
-rw-r--r-- | src/modules/json/JSONDefs.h | 2 | ||||
-rw-r--r-- | src/modules/json/JSONWorker.cpp | 106 | ||||
-rw-r--r-- | src/modules/json/JSONWorker.h | 6 |
6 files changed, 162 insertions, 154 deletions
diff --git a/include/m_json.h b/include/m_json.h index 76c9d966f6..2326728302 100644 --- a/include/m_json.h +++ b/include/m_json.h @@ -28,8 +28,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define json_getJSI(a) CallService(MS_JSON_GETINTERFACE,(WPARAM)a,0)
#ifndef LIBJSON_H
- #define JSONNODE void //so that JSONNODE* is void* - typedef JSONNODE** JSONNODE_ITERATOR; +#define JSONNODE void //so that JSONNODE* is void* +typedef JSONNODE** JSONNODE_ITERATOR; #endif
// This function get the service interface for direct calling
@@ -38,107 +38,107 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Return value ALWAYS 0
typedef struct {
- /* - stuff that's in namespace libJSON - */ - void (*free)(void * str); - void (*delete_)(JSONNODE * node); - // #ifdef JSON_MEMORY_MANAGE - void (*free_all)(void); - void (*delete_all)(void); - // #endif - JSONNODE * (*parse)(const char * json); - char * (*strip_white_space)(const char * json); - // #ifdef JSON_VALIDATE - JSONNODE * (*validate)(const char * json); - // #endif + /* + stuff that's in namespace libJSON + */ + void (*free)(void * str); + void (*delete_)(JSONNODE * node); + // #ifdef JSON_MEMORY_MANAGE + void (*free_all)(void); + void (*delete_all)(void); + // #endif + JSONNODE * (*parse)(const char * json); + char * (*strip_white_space)(const char * json); + // #ifdef JSON_VALIDATE + JSONNODE * (*validate)(const char * json); + // #endif - /* - stuff that's in class JSONNode - */ - //ctors - JSONNODE * (*new_a)(const char * name, const char * value); - JSONNODE * (*new_i)(const char * name, long value); - JSONNODE * (*new_f)(const char * name, double value); - JSONNODE * (*new_b)(const char * name, int value); //because C bools are ints and C++ will implicitly cast it - JSONNODE * (*new_)(char type); - JSONNODE * (*copy)(const JSONNODE * orig); - JSONNODE * (*duplicate)(const JSONNODE * orig); + /* + stuff that's in class JSONNode + */ + //ctors + JSONNODE * (*new_a)(const char * name, const char * value); + JSONNODE * (*new_i)(const char * name, long value); + JSONNODE * (*new_f)(const char * name, double value); + JSONNODE * (*new_b)(const char * name, int value); //because C bools are ints and C++ will implicitly cast it + JSONNODE * (*new_)(char type); + JSONNODE * (*copy)(const JSONNODE * orig); + JSONNODE * (*duplicate)(const JSONNODE * orig); - //assignment - void (*set_a)(JSONNODE * node, const char * value); - void (*set_i)(JSONNODE * node, long value); - void (*set_f)(JSONNODE * node, double value); - void (*set_b)(JSONNODE * node, int value); //because C bools are ints ane C++ will implicit - void (*set_n)(JSONNODE * node, const JSONNODE * orig); + //assignment + void (*set_a)(JSONNODE * node, const char * value); + void (*set_i)(JSONNODE * node, long value); + void (*set_f)(JSONNODE * node, double value); + void (*set_b)(JSONNODE * node, int value); //because C bools are ints ane C++ will implicit + void (*set_n)(JSONNODE * node, const JSONNODE * orig); - //inspectors - char (*type)(const JSONNODE * node); - unsigned int (*size)(const JSONNODE * node); - int (*empty)(const JSONNODE * node); - char * (*name)(const JSONNODE * node); - // #ifdef JSON_COMMENTS - char * (*get_comment)(const JSONNODE * node); - // #endif - char * (*as_string)(const JSONNODE * node); - long (*as_int)(const JSONNODE * node); - double (*as_float)(const JSONNODE * node); - int (*as_bool)(const JSONNODE * node); - JSONNODE * (*as_node)(const JSONNODE * node); - JSONNODE * (*as_array)(const JSONNODE * node); - // #ifdef JSON_BINARY - void * (*as_binary)(const JSONNODE * node, unsigned long * size); - // #endif - // #ifdef JSON_WRITER - char * (*write)(const JSONNODE * node); - char * (*write_formatted)(const JSONNODE * node); - // #endif + //inspectors + char (*type)(const JSONNODE * node); + unsigned int (*size)(const JSONNODE * node); + int (*empty)(const JSONNODE * node); + char * (*name)(const JSONNODE * node); + // #ifdef JSON_COMMENTS + char * (*get_comment)(const JSONNODE * node); + // #endif + char * (*as_string)(const JSONNODE * node); + long (*as_int)(const JSONNODE * node); + double (*as_float)(const JSONNODE * node); + int (*as_bool)(const JSONNODE * node); + JSONNODE * (*as_node)(const JSONNODE * node); + JSONNODE * (*as_array)(const JSONNODE * node); + // #ifdef JSON_BINARY + void * (*as_binary)(const JSONNODE * node, unsigned long * size); + // #endif + // #ifdef JSON_WRITER + char * (*write)(const JSONNODE * node); + char * (*write_formatted)(const JSONNODE * node); + // #endif - //modifiers - void (*set_name)(JSONNODE * node, const char * name); - // #ifdef JSON_COMMENTS - void (*set_comment)(JSONNODE * node, const char * comment); - // #endif - void (*clear)(JSONNODE * node); - void (*nullify)(JSONNODE * node); - void (*swap)(JSONNODE * node, JSONNODE * node2); - void (*merge)(JSONNODE * node, JSONNODE * node2); - // #ifndef JSON_PREPARSE - void (*preparse)(JSONNODE * node); - // #endif - // #ifdef JSON_BINARY - void (*set_binary)(JSONNODE * node, const void * data, unsigned long length); - // #endif - void (*cast)(JSONNODE * node, char type); + //modifiers + void (*set_name)(JSONNODE * node, const char * name); + // #ifdef JSON_COMMENTS + void (*set_comment)(JSONNODE * node, const char * comment); + // #endif + void (*clear)(JSONNODE * node); + void (*nullify)(JSONNODE * node); + void (*swap)(JSONNODE * node, JSONNODE * node2); + void (*merge)(JSONNODE * node, JSONNODE * node2); + // #ifndef JSON_PREPARSE + void (*preparse)(JSONNODE * node); + // #endif + // #ifdef JSON_BINARY + void (*set_binary)(JSONNODE * node, const void * data, unsigned long length); + // #endif + void (*cast)(JSONNODE * node, char type); - //children access - void (*reserve)(JSONNODE * node, unsigned int siz); - JSONNODE * (*at)(JSONNODE * node, unsigned int pos); - JSONNODE * (*get)(JSONNODE * node, const char * name); - // #ifdef JSON_CASE_INSENSITIVE_FUNCTIONS - JSONNODE * (*get_nocase)(JSONNODE * node, const char * name); - JSONNODE * (*pop_back_nocase)(JSONNODE * node, const char * name); - // #endif - void (*push_back)(JSONNODE * node, JSONNODE * node2); - JSONNODE * (*pop_back_at)(JSONNODE * node, unsigned int pos); - JSONNODE * (*pop_back)(JSONNODE * node, const char * name); - // #ifdef JSON_ITERATORS - JSONNODE_ITERATOR (*find)(JSONNODE * node, const char * name); - // #ifdef JSON_CASE_INSENSITIVE_FUNCTIONS - JSONNODE_ITERATOR (*find_nocase)(JSONNODE * node, const char * name); - // #endif - JSONNODE_ITERATOR (*erase)(JSONNODE * node, JSONNODE_ITERATOR it); - JSONNODE_ITERATOR (*erase_multi)(JSONNODE * node, JSONNODE_ITERATOR start, JSONNODE_ITERATOR end); - JSONNODE_ITERATOR (*insert)(JSONNODE * node, JSONNODE_ITERATOR it, JSONNODE * node2); - JSONNODE_ITERATOR (*insert_multi)(JSONNODE * node, JSONNODE_ITERATOR it, JSONNODE_ITERATOR start, JSONNODE_ITERATOR end); + //children access + void (*reserve)(JSONNODE * node, unsigned int siz); + JSONNODE * (*at)(JSONNODE * node, unsigned int pos); + JSONNODE * (*get)(JSONNODE * node, const char * name); + // #ifdef JSON_CASE_INSENSITIVE_FUNCTIONS + JSONNODE * (*get_nocase)(JSONNODE * node, const char * name); + JSONNODE * (*pop_back_nocase)(JSONNODE * node, const char * name); + // #endif + void (*push_back)(JSONNODE * node, JSONNODE * node2); + JSONNODE * (*pop_back_at)(JSONNODE * node, unsigned int pos); + JSONNODE * (*pop_back)(JSONNODE * node, const char * name); + // #ifdef JSON_ITERATORS + JSONNODE_ITERATOR (*find)(JSONNODE * node, const char * name); + // #ifdef JSON_CASE_INSENSITIVE_FUNCTIONS + JSONNODE_ITERATOR (*find_nocase)(JSONNODE * node, const char * name); + // #endif + JSONNODE_ITERATOR (*erase)(JSONNODE * node, JSONNODE_ITERATOR it); + JSONNODE_ITERATOR (*erase_multi)(JSONNODE * node, JSONNODE_ITERATOR start, JSONNODE_ITERATOR end); + JSONNODE_ITERATOR (*insert)(JSONNODE * node, JSONNODE_ITERATOR it, JSONNODE * node2); + JSONNODE_ITERATOR (*insert_multi)(JSONNODE * node, JSONNODE_ITERATOR it, JSONNODE_ITERATOR start, JSONNODE_ITERATOR end); - //iterator functions - JSONNODE_ITERATOR (*begin)(JSONNODE * node); - JSONNODE_ITERATOR (*end)(JSONNODE * node); - // #endif + //iterator functions + JSONNODE_ITERATOR (*begin)(JSONNODE * node); + JSONNODE_ITERATOR (*end)(JSONNODE * node); + // #endif - //comparison - int (*equal)(JSONNODE * node, JSONNODE * node2); + //comparison + int (*equal)(JSONNODE * node, JSONNODE * node2); } JSONSERVICEINTERFACE, *PJSONSERVICEINTERFACE, *LPJSONSERVICEINTERFACE;
diff --git a/src/miranda32_10.vcxproj b/src/miranda32_10.vcxproj index a549b914dd..db486957c2 100644 --- a/src/miranda32_10.vcxproj +++ b/src/miranda32_10.vcxproj @@ -77,7 +77,7 @@ <AdditionalIncludeDirectories>..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;WIN32;_WINDOWS;_NOSDK;_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
- <ExceptionHandling>false</ExceptionHandling>
+ <ExceptionHandling>Sync</ExceptionHandling>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>commonheaders.h</PrecompiledHeaderFile>
@@ -113,7 +113,7 @@ <AdditionalIncludeDirectories>..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;WIN64;_WINDOWS;_NOSDK;_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
- <ExceptionHandling>false</ExceptionHandling>
+ <ExceptionHandling>Sync</ExceptionHandling>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>commonheaders.h</PrecompiledHeaderFile>
@@ -153,6 +153,7 @@ <PrecompiledHeaderFile>commonheaders.h</PrecompiledHeaderFile>
<WarningLevel>Level3</WarningLevel>
<DisableSpecificWarnings>4996;4530;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ <ExceptionHandling>Sync</ExceptionHandling>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -182,6 +183,7 @@ <PrecompiledHeaderFile>commonheaders.h</PrecompiledHeaderFile>
<WarningLevel>Level3</WarningLevel>
<DisableSpecificWarnings>4996;4530;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ <ExceptionHandling>Sync</ExceptionHandling>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -218,6 +220,7 @@ <ClInclude Include="..\include\m_icq.h" />
<ClInclude Include="..\include\m_idle.h" />
<ClInclude Include="..\include\m_ignore.h" />
+ <ClInclude Include="..\include\m_json.h" />
<ClInclude Include="..\include\m_langpack.h" />
<ClInclude Include="..\include\m_message.h" />
<ClInclude Include="..\include\m_netlib.h" />
diff --git a/src/miranda32_10.vcxproj.filters b/src/miranda32_10.vcxproj.filters index c9c2782aa4..a0ba3df139 100644 --- a/src/miranda32_10.vcxproj.filters +++ b/src/miranda32_10.vcxproj.filters @@ -315,6 +315,9 @@ <ClInclude Include="modules\json\NumberToString.h">
<Filter>Modules\json</Filter>
</ClInclude>
+ <ClInclude Include="..\include\m_json.h">
+ <Filter>SDK</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="core\commonheaders.cpp">
diff --git a/src/modules/json/JSONDefs.h b/src/modules/json/JSONDefs.h index 678d059400..e354a0b9fa 100644 --- a/src/modules/json/JSONDefs.h +++ b/src/modules/json/JSONDefs.h @@ -25,6 +25,7 @@ #error, You can not use unicode under ISO Strict C++ #endif #define json_char wchar_t + #define json_uchar wchar_t #ifdef __cplusplus #include <cwchar> //need wide characters typedef std::wstring json_string; @@ -36,6 +37,7 @@ #define json_strcmp wcscmp #else #define json_char char + #define json_uchar BYTE #ifdef __cplusplus typedef std::string json_string; #endif diff --git a/src/modules/json/JSONWorker.cpp b/src/modules/json/JSONWorker.cpp index c99cd38ee2..25589a8d2f 100644 --- a/src/modules/json/JSONWorker.cpp +++ b/src/modules/json/JSONWorker.cpp @@ -1,28 +1,28 @@ -/*
-
-Miranda IM: the free IM client for Microsoft* Windows*
-
-Copyright 2000-2009 Miranda ICQ/IM project,
-all portions of this codebase are copyrighted to the people
-listed in contributors.txt.
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "..\..\core\commonheaders.h"
-
+/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2009 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "..\..\core\commonheaders.h" + #include "JSONWorker.h" #ifdef JSON_VALIDATE @@ -210,8 +210,8 @@ inline void SingleLineComment(const json_char * & p){ } //no break, let it fall through so that the trailing quote gets added default: - JSON_ASSERT_SAFE((unsigned json_char)*p >= 32, JSON_TEXT("Invalid JSON character detected (lo)"), goto endofloop;); - JSON_ASSERT_SAFE((unsigned json_char)*p <= 126, JSON_TEXT("Invalid JSON character detected (hi)"), goto endofloop;); + JSON_ASSERT_SAFE((json_uchar)*p >= 32, JSON_TEXT("Invalid JSON character detected (lo)"), goto endofloop;); + JSON_ASSERT_SAFE((json_uchar)*p <= 126, JSON_TEXT("Invalid JSON character detected (hi)"), goto endofloop;); *runner++ = *p; break; } @@ -267,8 +267,8 @@ json_string JSONWorker::RemoveWhiteSpaceAndComments(const json_string & value_t) } //no break, let it fall through so that the trailing quote gets added default: - JSON_ASSERT_SAFE((unsigned json_char)*p >= 32, JSON_TEXT("Invalid JSON character detected (lo)"), goto endofloop;); - JSON_ASSERT_SAFE((unsigned json_char)*p <= 126, JSON_TEXT("Invalid JSON character detected (hi)"), goto endofloop;); + JSON_ASSERT_SAFE((json_uchar)*p >= 32, JSON_TEXT("Invalid JSON character detected (lo)"), goto endofloop;); + JSON_ASSERT_SAFE((json_uchar)*p <= 126, JSON_TEXT("Invalid JSON character detected (hi)"), goto endofloop;); result += *p; break; } @@ -285,18 +285,18 @@ json_string JSONWorker::RemoveWhiteSpaceAndComments(const json_string & value_t) This includes dealing with special characters and utf characters */ #ifdef JSON_UNICODE - inline unsigned json_char SurrogatePair(const unsigned json_char hi, const unsigned json_char lo){ + inline json_uchar SurrogatePair(const json_uchar hi, const json_uchar lo){ JSON_ASSERT(sizeof(unsigned int) == 4, JSON_TEXT("size of unsigned int is not 32-bit")); - JSON_ASSERT(sizeof(unsigned json_char) == 4, JSON_TEXT("size of json_char is not 32-bit")); + JSON_ASSERT(sizeof(json_uchar) == 4, JSON_TEXT("size of json_char is not 32-bit")); return (((hi << 10) & 0x1FFC00) + 0x10000) | lo & 0x3FF; } json_string JSONWorker::UTF(const json_char * & pos){ json_string result; - unsigned json_char first = UTF8(pos); + json_uchar first = UTF8(pos); if ((*(pos + 1) == '\\') && (*(pos + 2) == 'u')) { pos += 2; - unsigned json_char second = UTF8(pos); + json_uchar second = UTF8(pos); //surrogate pair, not two characters if ((first > 0xD800) && (first < 0xDBFF) && (second > 0xDC00) && (second < 0xDFFF)) { result += SurrogatePair(first, second); @@ -312,10 +312,10 @@ json_string JSONWorker::RemoveWhiteSpaceAndComments(const json_string & value_t) } #endif -unsigned json_char JSONWorker::UTF8(const json_char * & pos){ +json_uchar JSONWorker::UTF8(const json_char * & pos){ #ifdef JSON_UNICODE ++pos; - unsigned json_char temp = Hex(pos) << 8; + json_uchar temp = Hex(pos) << 8; ++pos; return temp | Hex(pos); #else @@ -326,12 +326,12 @@ unsigned json_char JSONWorker::UTF8(const json_char * & pos){ #endif } -static char szU8Buffer[10]; +static json_char szU8Buffer[10]; json_char* JSONWorker::UTF8_2(const json_char * & pos){ #ifdef JSON_UNICODE ++pos; - unsigned json_char temp = Hex(pos) << 8; + json_uchar temp = Hex(pos) << 8; ++pos; *szU8Buffer= temp | Hex(pos); szU8Buffer[1]=0; @@ -357,7 +357,7 @@ json_char* JSONWorker::UTF8_2(const json_char * & pos){ szU8Buffer[1]=0x80+((uByte[1]&0x0f)<<2)+(uByte[0]>>6); szU8Buffer[2]=0x80+(uByte[0]&0x3f); szU8Buffer[3]=0; - }
+ } pos += 3; return szU8Buffer; @@ -374,14 +374,14 @@ json_char JSONWorker::Hex(const json_char * & pos){ as this method is also used for \x */ //First character - unsigned json_char hi = *pos++ - 48; + json_uchar hi = *pos++ - 48; if (hi > 48){ //A-F don't immediately follow 0-9, so have to pull them down a little hi -= 39; } else if (hi > 9){ //neither do a-f hi -= 7; } //second character - unsigned json_char lo = *pos - 48; + json_uchar lo = *pos - 48; if (lo > 48){ //A-F don't immediately follow 0-9, so have to pull them down a little lo -= 39; } else if (lo > 9){ //neither do a-f @@ -393,9 +393,9 @@ json_char JSONWorker::Hex(const json_char * & pos){ inline json_char FromOctal(const json_char * & str){ JSON_ASSERT(json_strlen(str) > 3, JSON_TEXT("Octal will go out of bounds")); - const unsigned json_char top = ((unsigned json_char)(*(str++) - 48)); - const unsigned json_char middle = (unsigned json_char)(*(str++) - 48); - const unsigned json_char bottom = (unsigned json_char)(*str - 48); + const json_uchar top = ((json_uchar)(*(str++) - 48)); + const json_uchar middle = (json_uchar)(*(str++) - 48); + const json_uchar bottom = (json_uchar)(*str - 48); return (json_char)((top << 6) | (middle << 3) | bottom); } @@ -504,10 +504,10 @@ void JSONWorker::SpecialChar(const json_char * & pos, json_string & res){ } #ifdef JSON_UNICODE - json_string JSONWorker::toSurrogatePair(unsigned json_char C){ + json_string JSONWorker::toSurrogatePair(json_uchar C){ JSON_ASSERT(sizeof(unsigned int) == 4, JSON_TEXT("size of unsigned int is not 32-bit")); JSON_ASSERT(sizeof(unsigned short) == 2, JSON_TEXT("size of unsigned short is not 16-bit")); - JSON_ASSERT(sizeof(unsigned json_char) == 4, JSON_TEXT("json_char is not 32-bit")); + JSON_ASSERT(sizeof(json_uchar) == 4, JSON_TEXT("json_char is not 32-bit")); //Compute the high surrogate const unsigned int U = (C >> 16) & 31; unsigned short HiSurrogate = 0xD800 | (((unsigned short)U - 1) << 6) | ((unsigned short)C) >> 10; @@ -522,26 +522,26 @@ void JSONWorker::SpecialChar(const json_char * & pos, json_string & res){ } #endif -json_string JSONWorker::toUTF8(unsigned json_char p){ +json_string JSONWorker::toUTF8(json_uchar p){ #ifdef JSON_UNICODE if (p > 0xFFFF) return toSurrogatePair(p); #endif json_string res(JSON_TEXT("\\u")); #ifdef JSON_UNICODE - unsigned json_char hihi = ((p & 0xF000) >> 12) + 48; + json_uchar hihi = ((p & 0xF000) >> 12) + 48; if (hihi > 57) hihi += 7; //A-F don't immediately follow 0-9, so have to further adjust those - unsigned json_char hilo = ((p & 0x0F00) >> 8) + 48; + json_uchar hilo = ((p & 0x0F00) >> 8) + 48; if (hilo > 57) hilo += 7; //A-F don't immediately follow 0-9, so have to further adjust those res += hihi; res += hilo; - unsigned json_char hi = ((p & 0x00F0) >> 4) + 48; + json_uchar hi = ((p & 0x00F0) >> 4) + 48; #else res += JSON_TEXT("00"); - unsigned json_char hi = (p >> 4) + 48; + json_uchar hi = (p >> 4) + 48; #endif //convert the character to be escaped into two digits between 0 and 15 if (hi > 57) hi += 7; //A-F don't immediately follow 0-9, so have to further adjust those - unsigned json_char lo = (p & 0x000F) + 48; + json_uchar lo = (p & 0x000F) + 48; if (lo > 57) lo += 7; //A-F don't immediately follow 0-9, so have to further adjust those res += hi; res += lo; @@ -589,8 +589,8 @@ json_string JSONWorker::UnfixString(const json_string & value_t, bool flag){ res += JSON_TEXT("\\\'"); break; default: - /*if (((unsigned json_char)(*p) < 32) || ((unsigned json_char)(*p) > 126)) { - //res += toUTF8((unsigned json_char)(*p)); + /*if (((json_uchar)(*p) < 32) || ((json_uchar)(*p) > 126)) { + //res += toUTF8((json_uchar)(*p)); } else*/ { res += *p; } diff --git a/src/modules/json/JSONWorker.h b/src/modules/json/JSONWorker.h index 373660743c..91a4f6d8c4 100644 --- a/src/modules/json/JSONWorker.h +++ b/src/modules/json/JSONWorker.h @@ -31,12 +31,12 @@ public: static json_string UnfixString(const json_string & value_t, bool flag); JSON_PRIVATE static json_char Hex(const json_char * & pos); - static unsigned json_char UTF8(const json_char * & pos); + static json_uchar UTF8(const json_char * & pos); static json_char* UTF8_2(const json_char * & pos); - static json_string toUTF8(unsigned json_char p); + static json_string toUTF8(json_uchar p); #ifdef JSON_UNICODE static json_string UTF(const json_char * & pos); - static json_string toSurrogatePair(unsigned json_char pos); + static json_string toSurrogatePair(json_uchar pos); #endif static void SpecialChar(const json_char * & pos, json_string & res); static size_t FindNextRelevant(json_char ch, const json_string & value_t, const size_t pos); |