summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-06-23 17:32:07 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-06-23 17:32:07 +0000
commit8c33681f317706acf4cd319927a2e37fc78c2256 (patch)
tree9b60033e353e050a7eaf534dfc2cff594f76d2ea /src
parentd11afafa9a4ffcf5c33f64d55d1ce22e452d6120 (diff)
- warning fixes
- code formatting git-svn-id: http://svn.miranda-ng.org/main/trunk@577 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r--src/miranda32_10.vcxproj7
-rw-r--r--src/miranda32_10.vcxproj.filters3
-rw-r--r--src/modules/json/JSONDefs.h2
-rw-r--r--src/modules/json/JSONWorker.cpp106
-rw-r--r--src/modules/json/JSONWorker.h6
5 files changed, 66 insertions, 58 deletions
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);