|
@@ -322,20 +322,26 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, |
|
|
goto redo_char; |
|
|
goto redo_char; |
|
|
|
|
|
|
|
|
case json_tokener_state_null: |
|
|
case json_tokener_state_null: |
|
|
printbuf_memappend_fast(tok->pb, &c, 1); |
|
|
|
|
|
if(strncasecmp(json_null_str, tok->pb->buf, |
|
|
|
|
|
json_min(tok->st_pos+1, (int)strlen(json_null_str))) == 0) { |
|
|
|
|
|
if(tok->st_pos == (int)strlen(json_null_str)) { |
|
|
|
|
|
current = NULL; |
|
|
|
|
|
saved_state = json_tokener_state_finish; |
|
|
|
|
|
state = json_tokener_state_eatws; |
|
|
|
|
|
goto redo_char; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
int size; |
|
|
|
|
|
printbuf_memappend_fast(tok->pb, &c, 1); |
|
|
|
|
|
size = json_min(tok->st_pos+1, (int)strlen(json_null_str)); |
|
|
|
|
|
if((!(tok->flags & JSON_TOKENER_STRICT) && |
|
|
|
|
|
strncasecmp(json_null_str, tok->pb->buf, size) == 0) |
|
|
|
|
|
|| (strncmp(json_null_str, tok->pb->buf, size) == 0) |
|
|
|
|
|
) { |
|
|
|
|
|
if(tok->st_pos == (int)strlen(json_null_str)) { |
|
|
|
|
|
current = NULL; |
|
|
|
|
|
saved_state = json_tokener_state_finish; |
|
|
|
|
|
state = json_tokener_state_eatws; |
|
|
|
|
|
goto redo_char; |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
tok->err = json_tokener_error_parse_null; |
|
|
|
|
|
goto out; |
|
|
} |
|
|
} |
|
|
} else { |
|
|
|
|
|
tok->err = json_tokener_error_parse_null; |
|
|
|
|
|
goto out; |
|
|
|
|
|
|
|
|
tok->st_pos++; |
|
|
} |
|
|
} |
|
|
tok->st_pos++; |
|
|
|
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case json_tokener_state_comment_start: |
|
|
case json_tokener_state_comment_start: |
|
@@ -548,28 +554,36 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok, |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case json_tokener_state_boolean: |
|
|
case json_tokener_state_boolean: |
|
|
printbuf_memappend_fast(tok->pb, &c, 1); |
|
|
|
|
|
if(strncasecmp(json_true_str, tok->pb->buf, |
|
|
|
|
|
json_min(tok->st_pos+1, (int)strlen(json_true_str))) == 0) { |
|
|
|
|
|
if(tok->st_pos == (int)strlen(json_true_str)) { |
|
|
|
|
|
current = json_object_new_boolean(1); |
|
|
|
|
|
saved_state = json_tokener_state_finish; |
|
|
|
|
|
state = json_tokener_state_eatws; |
|
|
|
|
|
goto redo_char; |
|
|
|
|
|
} |
|
|
|
|
|
} else if(strncasecmp(json_false_str, tok->pb->buf, |
|
|
|
|
|
json_min(tok->st_pos+1, (int)strlen(json_false_str))) == 0) { |
|
|
|
|
|
if(tok->st_pos == (int)strlen(json_false_str)) { |
|
|
|
|
|
current = json_object_new_boolean(0); |
|
|
|
|
|
saved_state = json_tokener_state_finish; |
|
|
|
|
|
state = json_tokener_state_eatws; |
|
|
|
|
|
goto redo_char; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
int size1, size2; |
|
|
|
|
|
printbuf_memappend_fast(tok->pb, &c, 1); |
|
|
|
|
|
size1 = json_min(tok->st_pos+1, (int)strlen(json_true_str)); |
|
|
|
|
|
size2 = json_min(tok->st_pos+1, (int)strlen(json_false_str)); |
|
|
|
|
|
if((!(tok->flags & JSON_TOKENER_STRICT) && |
|
|
|
|
|
strncasecmp(json_true_str, tok->pb->buf, size1) == 0) |
|
|
|
|
|
|| (strncmp(json_true_str, tok->pb->buf, size1) == 0) |
|
|
|
|
|
) { |
|
|
|
|
|
if(tok->st_pos == (int)strlen(json_true_str)) { |
|
|
|
|
|
current = json_object_new_boolean(1); |
|
|
|
|
|
saved_state = json_tokener_state_finish; |
|
|
|
|
|
state = json_tokener_state_eatws; |
|
|
|
|
|
goto redo_char; |
|
|
|
|
|
} |
|
|
|
|
|
} else if((!(tok->flags & JSON_TOKENER_STRICT) && |
|
|
|
|
|
strncasecmp(json_false_str, tok->pb->buf, size2) == 0) |
|
|
|
|
|
|| (strncmp(json_false_str, tok->pb->buf, size2) == 0)) { |
|
|
|
|
|
if(tok->st_pos == (int)strlen(json_false_str)) { |
|
|
|
|
|
current = json_object_new_boolean(0); |
|
|
|
|
|
saved_state = json_tokener_state_finish; |
|
|
|
|
|
state = json_tokener_state_eatws; |
|
|
|
|
|
goto redo_char; |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
tok->err = json_tokener_error_parse_boolean; |
|
|
|
|
|
goto out; |
|
|
} |
|
|
} |
|
|
} else { |
|
|
|
|
|
tok->err = json_tokener_error_parse_boolean; |
|
|
|
|
|
goto out; |
|
|
|
|
|
|
|
|
tok->st_pos++; |
|
|
} |
|
|
} |
|
|
tok->st_pos++; |
|
|
|
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
case json_tokener_state_number: |
|
|
case json_tokener_state_number: |
|
|