File tree Expand file tree Collapse file tree 1 file changed +16
-14
lines changed Expand file tree Collapse file tree 1 file changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -257,18 +257,25 @@ struct Value {
257
257
while (*curr && is_json_space (*curr)) \
258
258
curr++; \
259
259
}
260
+ #define skip_escaped_characters (ptr )\
261
+ while (*ptr && *ptr != ' "' ) {\
262
+ if (*ptr == ' \\ ' && *(ptr + 1 )) {\
263
+ ptr++;\
264
+ }\
265
+ ptr++;\
266
+ }
267
+ #define RUNTIME_ASSERT (condition )\
268
+ if (!(condition)) {\
269
+ std::cerr << " Assertion failed: " #condition << " at " << __FILE__ << " :" << __LINE__ << " \n " ;\
270
+ std::terminate ();\
271
+ }
260
272
skip ();
261
273
if (*curr == ' "' ) {
262
274
// String
263
275
curr++;
264
276
char * close = curr;
265
- while (*close && *close != ' "' ) {
266
- if (*close == ' \\ ' && *(close + 1 )) {
267
- close++; // Skip escaped character
268
- }
269
- close++;
270
- }
271
- assert (*close == ' "' );
277
+ skip_escaped_characters (close);
278
+ RUNTIME_ASSERT (*close == ' "' );
272
279
*close = 0 ; // end this string, and reuse it straight from the input
273
280
setString (curr);
274
281
curr = close + 1 ;
@@ -314,13 +321,8 @@ struct Value {
314
321
if (*curr == ' "' ) {
315
322
curr++;
316
323
char * close = curr;
317
- while (*close && *close != ' "' ) {
318
- if (*close == ' \\ ' && *(close + 1 )) {
319
- close++; // Skip escaped character
320
- }
321
- close++;
322
- }
323
- assert (*close == ' "' );
324
+ skip_escaped_characters (close);
325
+ RUNTIME_ASSERT (*close == ' "' );
324
326
*close = 0 ; // end this string, and reuse it straight from the input
325
327
IString key (curr);
326
328
curr = close + 1 ;
You can’t perform that action at this time.
0 commit comments