Source release v3.2.0
This commit is contained in:
2
third_party/jsmn/example/jsondump.c
vendored
2
third_party/jsmn/example/jsondump.c
vendored
@@ -122,5 +122,5 @@ again:
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
4
third_party/jsmn/example/simple.c
vendored
4
third_party/jsmn/example/simple.c
vendored
@@ -8,7 +8,7 @@
|
||||
* tokens is predictable.
|
||||
*/
|
||||
|
||||
const char *JSON_STRING =
|
||||
static const char *JSON_STRING =
|
||||
"{\"user\": \"johndoe\", \"admin\": false, \"uid\": 1000,\n "
|
||||
"\"groups\": [\"users\", \"wheel\", \"audio\", \"video\"]}";
|
||||
|
||||
@@ -72,5 +72,5 @@ int main() {
|
||||
JSON_STRING + t[i].start);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
3
third_party/jsmn/jsmn.c
vendored
3
third_party/jsmn/jsmn.c
vendored
@@ -198,6 +198,9 @@ int jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
|
||||
break;
|
||||
}
|
||||
if (token->parent == -1) {
|
||||
if(token->type != type || parser->toksuper == -1) {
|
||||
return JSMN_ERROR_INVAL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
token = &tokens[token->parent];
|
||||
|
||||
6
third_party/jsmn/jsmn.h
vendored
6
third_party/jsmn/jsmn.h
vendored
@@ -33,9 +33,9 @@ enum jsmnerr {
|
||||
|
||||
/**
|
||||
* JSON token description.
|
||||
* @param type type (object, array, string etc.)
|
||||
* @param start start position in JSON data string
|
||||
* @param end end position in JSON data string
|
||||
* type type (object, array, string etc.)
|
||||
* start start position in JSON data string
|
||||
* end end position in JSON data string
|
||||
*/
|
||||
typedef struct {
|
||||
jsmntype_t type;
|
||||
|
||||
20
third_party/jsmn/test/tests.c
vendored
20
third_party/jsmn/test/tests.c
vendored
@@ -357,6 +357,25 @@ int test_nonstrict(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_unmatched_brackets(void) {
|
||||
const char *js;
|
||||
js = "\"key 1\": 1234}";
|
||||
check(parse(js, JSMN_ERROR_INVAL, 2));
|
||||
js = "{\"key 1\": 1234";
|
||||
check(parse(js, JSMN_ERROR_PART, 3));
|
||||
js = "{\"key 1\": 1234}}";
|
||||
check(parse(js, JSMN_ERROR_INVAL, 3));
|
||||
js = "\"key 1\"}: 1234";
|
||||
check(parse(js, JSMN_ERROR_INVAL, 3));
|
||||
js = "\"key {1\": 1234";
|
||||
check(parse(js, 2, 2,
|
||||
JSMN_STRING, "key {1", 1,
|
||||
JSMN_PRIMITIVE, "1234"));
|
||||
js = "{{\"key 1\": 1234}";
|
||||
check(parse(js, JSMN_ERROR_PART, 4));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
test(test_empty, "test for a empty JSON objects/arrays");
|
||||
test(test_object, "test for a JSON objects");
|
||||
@@ -373,6 +392,7 @@ int main(void) {
|
||||
test(test_issue_27, "test issue #27");
|
||||
test(test_count, "test tokens count estimation");
|
||||
test(test_nonstrict, "test for non-strict mode");
|
||||
test(test_unmatched_brackets, "test for unmatched brackets");
|
||||
printf("\nPASSED: %d\nFAILED: %d\n", test_passed, test_failed);
|
||||
return (test_failed > 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user