Merge pull request #71 from WillDignazio/master
Fix Broken Build, Check ADVANCE_CHAR
This commit is contained in:
@@ -207,16 +207,16 @@ char* strndup(const char* str, size_t n)
|
|||||||
* printbuf_memappend() in a single call, rather than calling
|
* printbuf_memappend() in a single call, rather than calling
|
||||||
* printbuf_memappend() one char at a time.
|
* printbuf_memappend() one char at a time.
|
||||||
*
|
*
|
||||||
* POP_CHAR() and ADVANCE_CHAR() macros are used for code that is
|
* PEEK_CHAR() and ADVANCE_CHAR() macros are used for code that is
|
||||||
* common to both the main loop and the tighter loops.
|
* common to both the main loop and the tighter loops.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* POP_CHAR(dest, tok) macro:
|
/* PEEK_CHAR(dest, tok) macro:
|
||||||
* Not really a pop()...peeks at the current char and stores it in dest.
|
* Peeks at the current char and stores it in dest.
|
||||||
* Returns 1 on success, sets tok->err and returns 0 if no more chars.
|
* Returns 1 on success, sets tok->err and returns 0 if no more chars.
|
||||||
* Implicit inputs: str, len vars
|
* Implicit inputs: str, len vars
|
||||||
*/
|
*/
|
||||||
#define POP_CHAR(dest, tok) \
|
#define PEEK_CHAR(dest, tok) \
|
||||||
(((tok)->char_offset == len) ? \
|
(((tok)->char_offset == len) ? \
|
||||||
(((tok)->depth == 0 && state == json_tokener_state_eatws && saved_state == json_tokener_state_finish) ? \
|
(((tok)->depth == 0 && state == json_tokener_state_eatws && saved_state == json_tokener_state_finish) ? \
|
||||||
(((tok)->err = json_tokener_success), 0) \
|
(((tok)->err = json_tokener_success), 0) \
|
||||||
@@ -254,7 +254,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
|
|||||||
tok->char_offset = 0;
|
tok->char_offset = 0;
|
||||||
tok->err = json_tokener_success;
|
tok->err = json_tokener_success;
|
||||||
|
|
||||||
while (POP_CHAR(c, tok)) {
|
while (PEEK_CHAR(c, tok)) {
|
||||||
|
|
||||||
redo_char:
|
redo_char:
|
||||||
switch(state) {
|
switch(state) {
|
||||||
@@ -262,7 +262,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
|
|||||||
case json_tokener_state_eatws:
|
case json_tokener_state_eatws:
|
||||||
/* Advance until we change state */
|
/* Advance until we change state */
|
||||||
while (isspace((int)c)) {
|
while (isspace((int)c)) {
|
||||||
if ((!ADVANCE_CHAR(str, tok)) || (!POP_CHAR(c, tok)))
|
if ((!ADVANCE_CHAR(str, tok)) || (!PEEK_CHAR(c, tok)))
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if(c == '/') {
|
if(c == '/') {
|
||||||
@@ -373,7 +373,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
|
|||||||
/* Advance until we change state */
|
/* Advance until we change state */
|
||||||
const char *case_start = str;
|
const char *case_start = str;
|
||||||
while(c != '*') {
|
while(c != '*') {
|
||||||
if (!ADVANCE_CHAR(str, tok) || !POP_CHAR(c, tok)) {
|
if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) {
|
||||||
printbuf_memappend_fast(tok->pb, case_start, str-case_start);
|
printbuf_memappend_fast(tok->pb, case_start, str-case_start);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@@ -388,7 +388,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
|
|||||||
/* Advance until we change state */
|
/* Advance until we change state */
|
||||||
const char *case_start = str;
|
const char *case_start = str;
|
||||||
while(c != '\n') {
|
while(c != '\n') {
|
||||||
if (!ADVANCE_CHAR(str, tok) || !POP_CHAR(c, tok)) {
|
if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) {
|
||||||
printbuf_memappend_fast(tok->pb, case_start, str-case_start);
|
printbuf_memappend_fast(tok->pb, case_start, str-case_start);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@@ -426,7 +426,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
|
|||||||
state = json_tokener_state_string_escape;
|
state = json_tokener_state_string_escape;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!ADVANCE_CHAR(str, tok) || !POP_CHAR(c, tok)) {
|
if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) {
|
||||||
printbuf_memappend_fast(tok->pb, case_start, str-case_start);
|
printbuf_memappend_fast(tok->pb, case_start, str-case_start);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@@ -507,13 +507,17 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
|
|||||||
(str[1] == '\\') &&
|
(str[1] == '\\') &&
|
||||||
(str[2] == 'u'))
|
(str[2] == 'u'))
|
||||||
{
|
{
|
||||||
ADVANCE_CHAR(str, tok);
|
/* Advance through the 16 bit surrogate, and move on to the
|
||||||
ADVANCE_CHAR(str, tok);
|
* next sequence. The next step is to process the following
|
||||||
|
* characters.
|
||||||
|
*/
|
||||||
|
if( !ADVANCE_CHAR(str, tok) || !ADVANCE_CHAR(str, tok) ) {
|
||||||
|
printbuf_memappend_fast(tok->pb, (char*)utf8_replacement_char, 3);
|
||||||
|
}
|
||||||
/* Advance to the first char of the next sequence and
|
/* Advance to the first char of the next sequence and
|
||||||
* continue processing with the next sequence.
|
* continue processing with the next sequence.
|
||||||
*/
|
*/
|
||||||
if (!ADVANCE_CHAR(str, tok) || !POP_CHAR(c, tok)) {
|
if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) {
|
||||||
printbuf_memappend_fast(tok->pb, (char*)utf8_replacement_char, 3);
|
printbuf_memappend_fast(tok->pb, (char*)utf8_replacement_char, 3);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@@ -552,7 +556,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
|
|||||||
tok->err = json_tokener_error_parse_string;
|
tok->err = json_tokener_error_parse_string;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (!ADVANCE_CHAR(str, tok) || !POP_CHAR(c, tok)) {
|
if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) {
|
||||||
if (got_hi_surrogate) /* Clean up any pending chars */
|
if (got_hi_surrogate) /* Clean up any pending chars */
|
||||||
printbuf_memappend_fast(tok->pb, (char*)utf8_replacement_char, 3);
|
printbuf_memappend_fast(tok->pb, (char*)utf8_replacement_char, 3);
|
||||||
goto out;
|
goto out;
|
||||||
@@ -595,7 +599,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
|
|||||||
++case_len;
|
++case_len;
|
||||||
if(c == '.' || c == 'e' || c == 'E')
|
if(c == '.' || c == 'e' || c == 'E')
|
||||||
tok->is_double = 1;
|
tok->is_double = 1;
|
||||||
if (!ADVANCE_CHAR(str, tok) || !POP_CHAR(c, tok)) {
|
if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) {
|
||||||
printbuf_memappend_fast(tok->pb, case_start, case_len);
|
printbuf_memappend_fast(tok->pb, case_start, case_len);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@@ -686,7 +690,7 @@ struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
|
|||||||
state = json_tokener_state_string_escape;
|
state = json_tokener_state_string_escape;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!ADVANCE_CHAR(str, tok) || !POP_CHAR(c, tok)) {
|
if (!ADVANCE_CHAR(str, tok) || !PEEK_CHAR(c, tok)) {
|
||||||
printbuf_memappend_fast(tok->pb, case_start, str-case_start);
|
printbuf_memappend_fast(tok->pb, case_start, str-case_start);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user