--- parser3/src/lib/json/pa_json.C 2015/09/29 12:25:15 1.14 +++ parser3/src/lib/json/pa_json.C 2026/09/20 00:27:40 1.17 @@ -121,6 +121,11 @@ enum actions { STATE_UC, /* Unicode character read */ }; +/* some compilers have the following names defined */ +#undef _C2 +#undef ST_ +#undef PT_ + /* error state */ #define STATE___ 0xff @@ -180,9 +185,6 @@ static const uint8_t state_transition_ta /*D1*/ PT_(___,___,___,___,___,___,___,___,___,___,_D2,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___), /*D2*/ PT_(___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,___,_U1,___,___,___,___,___), }; -#undef ST_ -#undef PT_ - /* map from (previous state+new character class) to the buffer policy. ignore=0/append=1/escape=2 */ static const uint8_t buffer_policy_table[NR_STATES][NR_CLASSES] = { /* white ABCDF other */ @@ -356,8 +358,8 @@ static const uint8_t hextable[] = { /* high surrogate range from d800 to dbff */ /* low surrogate range dc00 to dfff */ -#define IS_HIGH_SURROGATE(uc) (((uc) & 0xfc00) == 0xd800) -#define IS_LOW_SURROGATE(uc) (((uc) & 0xfc00) == 0xdc00) +#define PA_IS_HIGH_SURROGATE(uc) (((uc) & 0xfc00) == 0xd800) +#define PA_IS_LOW_SURROGATE(uc) (((uc) & 0xfc00) == 0xdc00) /* transform an unicode [0-9A-Fa-f]{4} sequence into a proper value */ static int decode_unicode_char(json_parser *parser) @@ -378,7 +380,7 @@ static int decode_unicode_char(json_pars } if (parser->unicode_multi) { - if (!IS_LOW_SURROGATE(uval)) + if (!PA_IS_LOW_SURROGATE(uval)) return JSON_ERROR_UNICODE_MISSING_LOW_SURROGATE; uval = 0x10000 + ((parser->unicode_multi & 0x3ff) << 10) + (uval & 0x3ff); @@ -390,9 +392,9 @@ static int decode_unicode_char(json_pars return 0; } - if (IS_LOW_SURROGATE(uval)) + if (PA_IS_LOW_SURROGATE(uval)) return JSON_ERROR_UNICODE_UNEXPECTED_LOW_SURROGATE; - if (IS_HIGH_SURROGATE(uval)) { + if (PA_IS_HIGH_SURROGATE(uval)) { parser->unicode_multi = (uint16_t)uval; return 0; } @@ -454,7 +456,7 @@ static int act_cb(json_parser *parser) static int act_ce(json_parser *parser) { - parser->state = (uint8_t)((parser->save_state > STATE_AA) ? STATE_OK : parser->save_state); + parser->state = (parser->save_state > STATE_AA) ? (uint8_t)(STATE_OK) : (uint8_t)(parser->save_state); return 0; } @@ -638,7 +640,7 @@ int json_parser_string(json_parser *pars unsigned char ch = s[i]; ret = 0; - next_class = (uint8_t)((ch >= 128) ? C_OTHER : character_class[ch]); + next_class = (ch >= 128) ? (uint8_t)(C_OTHER) : (uint8_t)(character_class[ch]); if (next_class == C_ERROR) { ret = JSON_ERROR_BAD_CHAR; break;