@@ -144,34 +144,44 @@ jsonsl_feed(jsonsl_t jsn, const jsonsl_char_t *bytes, size_t nbytes)
144
144
{
145
145
146
146
#define INVOKE_ERROR (eb ) \
147
- if (jsn->error_callback(jsn, JSONSL_ERROR_##eb, state, (char*)c)) { \
148
- goto GT_AGAIN; \
149
- } \
150
- return;
147
+ if (1) { \
148
+ if (jsn->error_callback(jsn, JSONSL_ERROR_##eb, state, (char*)c)) { \
149
+ goto GT_AGAIN; \
150
+ } \
151
+ return; \
152
+ } else ((void)0)
151
153
152
154
#define STACK_PUSH \
153
- if (jsn->level >= (levels_max-1)) { \
154
- jsn->error_callback(jsn, JSONSL_ERROR_LEVELS_EXCEEDED, state, (char*)c); \
155
- return; \
156
- } \
157
- state = jsn->stack + (++jsn->level); \
158
- state->ignore_callback = jsn->stack[jsn->level-1].ignore_callback; \
159
- state->pos_begin = jsn->pos;
155
+ if (1) { \
156
+ if (jsn->level >= (levels_max-1)) { \
157
+ jsn->error_callback(jsn, JSONSL_ERROR_LEVELS_EXCEEDED, state, (char*)c); \
158
+ return; \
159
+ } \
160
+ state = jsn->stack + (++jsn->level); \
161
+ state->ignore_callback = jsn->stack[jsn->level-1].ignore_callback; \
162
+ state->pos_begin = jsn->pos; \
163
+ } else ((void)0)
160
164
161
165
#define CALLBACK_AND_POP_NOPOS (T ) \
166
+ if (1) { \
162
167
state->pos_cur = jsn->pos; \
163
168
DO_CALLBACK(T, POP); \
164
169
state->nescapes = 0; \
165
- state = jsn->stack + (--jsn->level);
170
+ state = jsn->stack + (--jsn->level); \
171
+ } else ((void)0)
166
172
167
173
#define CALLBACK_AND_POP (T ) \
174
+ if (1) { \
168
175
CALLBACK_AND_POP_NOPOS(T); \
169
- state->pos_cur = jsn->pos;
176
+ state->pos_cur = jsn->pos; \
177
+ } else ((void)0)
170
178
171
179
#define SPECIAL_POP \
172
- CALLBACK_AND_POP(SPECIAL); \
173
- jsn->expecting = 0; \
174
- jsn->tok_last = 0; \
180
+ if (1) { \
181
+ CALLBACK_AND_POP(SPECIAL); \
182
+ jsn->expecting = 0; \
183
+ jsn->tok_last = 0; \
184
+ } else ((void)0)
175
185
176
186
#define CUR_CHAR (*(jsonsl_uchar_t*)c)
177
187
@@ -186,27 +196,27 @@ jsonsl_feed(jsonsl_t jsn, const jsonsl_char_t *bytes, size_t nbytes)
186
196
jsn->action_callback(jsn, JSONSL_ACTION_##action, state, (jsonsl_char_t*)c); \
187
197
} \
188
198
if (jsn->stopfl) { return; } \
189
- }
199
+ } else ((void)0)
190
200
191
201
/**
192
202
* Verifies that we are able to insert the (non-string) item into a hash.
193
203
*/
194
204
#define ENSURE_HVAL \
195
205
if (state->nelem % 2 == 0 && state->type == JSONSL_T_OBJECT) { \
196
206
INVOKE_ERROR(HKEY_EXPECTED); \
197
- }
207
+ } else ((void)0)
198
208
199
209
#define VERIFY_SPECIAL (lit , lit_len ) \
200
- if ((jsn->pos - state->pos_begin) > lit_len \
201
- || CUR_CHAR != (lit)[jsn->pos - state->pos_begin]) { \
202
- INVOKE_ERROR(SPECIAL_EXPECTED); \
203
- }
210
+ if ((jsn->pos - state->pos_begin) > lit_len \
211
+ || CUR_CHAR != (lit)[jsn->pos - state->pos_begin]) { \
212
+ INVOKE_ERROR(SPECIAL_EXPECTED); \
213
+ } else ((void)0)
204
214
205
215
#define VERIFY_SPECIAL_CI (lit , lit_len ) \
206
- if ((jsn->pos - state->pos_begin) > lit_len \
207
- || tolower(CUR_CHAR) != (lit)[jsn->pos - state->pos_begin]) { \
208
- INVOKE_ERROR(SPECIAL_EXPECTED); \
209
- }
216
+ if ((jsn->pos - state->pos_begin) > lit_len \
217
+ || tolower(CUR_CHAR) != (lit)[jsn->pos - state->pos_begin]) { \
218
+ INVOKE_ERROR(SPECIAL_EXPECTED); \
219
+ } else ((void)0)
210
220
211
221
#define STATE_SPECIAL_LENGTH \
212
222
(state)->nescapes
@@ -663,7 +673,7 @@ const char* jsonsl_strerror(jsonsl_error_t err)
663
673
#define X (t ) \
664
674
if (err == JSONSL_ERROR_##t) \
665
675
return #t;
666
- JSONSL_XERR ;
676
+ JSONSL_XERR
667
677
#undef X
668
678
return "<UNKNOWN_ERROR>" ;
669
679
}
@@ -787,7 +797,7 @@ jsonsl_jpr_new(const char *path, jsonsl_error_t *errp)
787
797
size_t origlen ;
788
798
jsonsl_error_t errstacked ;
789
799
790
- #define JPR_BAIL (err ) *errp = err; goto GT_ERROR;
800
+ #define JPR_BAIL (err ) if (1) { *errp = err; goto GT_ERROR; } else ((void)0)
791
801
792
802
if (errp == NULL ) {
793
803
errp = & errstacked ;
@@ -1157,7 +1167,7 @@ const char *jsonsl_strmatchtype(jsonsl_jpr_match_t match)
1157
1167
static char *
1158
1168
jsonsl__writeutf8 (uint32_t pt , char * out )
1159
1169
{
1160
- #define ADD_OUTPUT (c ) *out = (char)(c); out++;
1170
+ #define ADD_OUTPUT (c ) if (1) { *out = (char)(c); out++; } else ((void)0)
1161
1171
1162
1172
if (pt < 0x80 ) {
1163
1173
ADD_OUTPUT (pt );
@@ -1204,9 +1214,11 @@ jsonsl__get_uescape_16(const char *s)
1204
1214
int cur ;
1205
1215
1206
1216
#define GET_DIGIT (off ) \
1207
- cur = jsonsl__digit2int(s[off]); \
1208
- if (cur == -1) { return -1; } \
1209
- ret |= (cur << (12 - (off * 4)));
1217
+ if (1) { \
1218
+ cur = jsonsl__digit2int(s[off]); \
1219
+ if (cur == -1) { return -1; } \
1220
+ ret |= (cur << (12 - (off * 4))); \
1221
+ } else ((void)0)
1210
1222
1211
1223
GET_DIGIT (0 );
1212
1224
GET_DIGIT (1 );
@@ -1238,11 +1250,13 @@ size_t jsonsl_util_unescape_ex(const char *in,
1238
1250
* oflags = 0 ;
1239
1251
1240
1252
#define UNESCAPE_BAIL (e ,offset ) \
1241
- *err = JSONSL_ERROR_##e; \
1242
- if (errat) { \
1243
- *errat = (const char*)(c+ (ptrdiff_t)(offset)); \
1244
- } \
1245
- return 0;
1253
+ if (1) { \
1254
+ *err = JSONSL_ERROR_##e; \
1255
+ if (errat) { \
1256
+ *errat = (const char*)(c+ (ptrdiff_t)(offset)); \
1257
+ } \
1258
+ return 0; \
1259
+ } else ((void)0)
1246
1260
1247
1261
for (; len ; len -- , c ++ , out ++ ) {
1248
1262
int uescval ;
@@ -1255,7 +1269,7 @@ size_t jsonsl_util_unescape_ex(const char *in,
1255
1269
UNESCAPE_BAIL (ESCAPE_INVALID , 0 );
1256
1270
}
1257
1271
if (!is_allowed_escape (c [1 ])) {
1258
- UNESCAPE_BAIL (ESCAPE_INVALID , 1 )
1272
+ UNESCAPE_BAIL (ESCAPE_INVALID , 1 );
1259
1273
}
1260
1274
if ((toEscape && toEscape [(unsigned char )c [1 ] & 0x7f ] == 0 &&
1261
1275
c [1 ] != '\\' && c [1 ] != '"' )) {
0 commit comments