-avoided a warning when a c++ compiler refers char to unsigned.

This commit is contained in:
Wang Renxin 2018-04-20 13:04:30 +08:00
parent f74dc06e6c
commit fd9e34b9d1
2 changed files with 22 additions and 6 deletions

View File

@ -1,3 +1,6 @@
Apr. 20 2018
Avoided a warning when a C++ compiler refers char to unsigned
Mar. 11 2018 Mar. 11 2018
Fixed a string assignment issue with class member Fixed a string assignment issue with class member
@ -1050,7 +1053,7 @@ Improved compatibility with GCC
Aug. 3 2012 Aug. 3 2012
Implemented memory occupation statistics Implemented memory occupation statistics
Improved compatibility on 64bit systems Improved compatibility on 64bit systems
Fixed some warnings under a stricter mode Avoided some warnings under a stricter mode
Jul. 21 2012 Jul. 21 2012
Added a compatibility macro for PRINT a newline Added a compatibility macro for PRINT a newline

View File

@ -3345,15 +3345,21 @@ static int mb_wchar_to_bytes(const wchar_t* sz, char** out, size_t size) {
/* Determine whether a string begins with a BOM, and ignore it */ /* Determine whether a string begins with a BOM, and ignore it */
static int mb_uu_getbom(const char** ch) { static int mb_uu_getbom(const char** ch) {
if(!ch && !(*ch)) #ifdef __cplusplus
signed char** ptr = (signed char**)ch;
#else /* __cplusplus */
char** ptr = (char**)ch;
#endif /* __cplusplus */
if(!ptr && !(*ptr))
return 0; return 0;
if((*ch)[0] == -17 && (*ch)[1] == -69 && (*ch)[2] == -65) { if((*ptr)[0] == -17 && (*ptr)[1] == -69 && (*ptr)[2] == -65) {
*ch += 3; *ptr += 3;
return 3; return 3;
} else if((*ch)[0] == -2 && (*ch)[1] == -1) { } else if((*ptr)[0] == -2 && (*ptr)[1] == -1) {
*ch += 2; *ptr += 2;
return 2; return 2;
} }
@ -4962,7 +4968,14 @@ static bool_t _is_blank_char(char c) {
/* Determine whether a character is end of file */ /* Determine whether a character is end of file */
static bool_t _is_eof_char(char c) { static bool_t _is_eof_char(char c) {
#ifdef __cplusplus
union { signed char s; char c; } u;
u.c = c;
return u.s == EOF;
#else /* __cplusplus */
return (c == EOF); return (c == EOF);
#endif /* __cplusplus */
} }
/* Determine whether a character is newline */ /* Determine whether a character is newline */