Skip to content

Commit

Permalink
Enable partial array test for non-strict mode
Browse files Browse the repository at this point in the history
  • Loading branch information
dominickpastore committed May 25, 2020
1 parent 3391c19 commit 82f378a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 6 additions & 1 deletion jsmn.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ typedef struct jsmn_parser {
unsigned int toknext; /* next token to allocate */
int toksuper; /* superior token node, e.g. parent object or array */
int state; /* parser state, from jsmnstate_t */
unsigned int depth; /* Nesting depth of arrays and objects (used only when
unsigned int depth; /* nesting depth of arrays and objects (used only when
* tokens is NULL) */
int tokbefore; /* token immediately preceding the first token in the
current JSON object */
} jsmn_parser;

/**
Expand Down Expand Up @@ -406,6 +408,7 @@ JSMN_API int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len,
}
#endif
if (parser->toksuper == -1) {
parser->tokbefore = parser->toknext - 1;
return count;
} else {
parser->state = (tokens[parser->toksuper].type == JSMN_ARRAY) ?
Expand All @@ -426,6 +429,7 @@ JSMN_API int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len,
}
}
if (parser->toksuper == -1) {
parser->tokbefore = parser->toknext - 1;
return count;
} else if (parser->state & 0x1) {
return JSMN_ERROR_INVAL;
Expand Down Expand Up @@ -503,6 +507,7 @@ JSMN_API int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len,
}
}
if (parser->toksuper == -1) {
parser->tokbefore = parser->toknext - 1;
return count;
#ifdef JSMN_STRICT
} else if (parser->state & 0x3) {
Expand Down
2 changes: 0 additions & 2 deletions test/tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ int test_partial_string(void) {
}

int test_partial_array(void) {
#ifdef JSMN_STRICT
int r;
unsigned long i;
jsmn_parser p;
Expand All @@ -144,7 +143,6 @@ int test_partial_array(void) {
check(r == JSMN_ERROR_PART);
}
}
#endif
return 0;
}

Expand Down

0 comments on commit 82f378a

Please sign in to comment.