removed trailing spaces

master
Serge A. Zaitsev 10 years ago
parent 8a22e0a149
commit 838061aa96

@ -5,7 +5,7 @@
/** /**
* Allocates a fresh unused token from the token pull. * Allocates a fresh unused token from the token pull.
*/ */
static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser, static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser,
jsmntok_t *tokens, size_t num_tokens) { jsmntok_t *tokens, size_t num_tokens) {
jsmntok_t *tok; jsmntok_t *tok;
if (parser->toknext >= num_tokens) { if (parser->toknext >= num_tokens) {
@ -23,7 +23,7 @@ static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser,
/** /**
* Fills token type and boundaries. * Fills token type and boundaries.
*/ */
static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type, static void jsmn_fill_token(jsmntok_t *token, jsmntype_t type,
int start, int end) { int start, int end) {
token->type = type; token->type = type;
token->start = start; token->start = start;
@ -234,7 +234,7 @@ jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
if (parser->toksuper != -1 && tokens != NULL) if (parser->toksuper != -1 && tokens != NULL)
tokens[parser->toksuper].size++; tokens[parser->toksuper].size++;
break; break;
case '\t' : case '\r' : case '\n' : case ' ': case '\t' : case '\r' : case '\n' : case ' ':
break; break;
case ':': case ':':
parser->toksuper = parser->toknext - 1; parser->toksuper = parser->toknext - 1;
@ -292,7 +292,7 @@ jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js, size_t len,
} }
/** /**
* Creates a new parser based over a given buffer with an array of tokens * Creates a new parser based over a given buffer with an array of tokens
* available. * available.
*/ */
void jsmn_init(jsmn_parser *parser) { void jsmn_init(jsmn_parser *parser) {

@ -120,7 +120,7 @@ int test_primitive() {
js = "\"boolVar\" : true"; js = "\"boolVar\" : true";
jsmn_init(&p); jsmn_init(&p);
r = jsmn_parse(&p, js, strlen(js), tok, 10); r = jsmn_parse(&p, js, strlen(js), tok, 10);
check(r >= 0 && tok[0].type == JSMN_STRING check(r >= 0 && tok[0].type == JSMN_STRING
&& tok[1].type == JSMN_PRIMITIVE); && tok[1].type == JSMN_PRIMITIVE);
check(TOKEN_STRING(js, tok[0], "boolVar")); check(TOKEN_STRING(js, tok[0], "boolVar"));
check(TOKEN_STRING(js, tok[1], "true")); check(TOKEN_STRING(js, tok[1], "true"));
@ -128,7 +128,7 @@ int test_primitive() {
js = "\"boolVar\" : false"; js = "\"boolVar\" : false";
jsmn_init(&p); jsmn_init(&p);
r = jsmn_parse(&p, js, strlen(js), tok, 10); r = jsmn_parse(&p, js, strlen(js), tok, 10);
check(r >= 0 && tok[0].type == JSMN_STRING check(r >= 0 && tok[0].type == JSMN_STRING
&& tok[1].type == JSMN_PRIMITIVE); && tok[1].type == JSMN_PRIMITIVE);
check(TOKEN_STRING(js, tok[0], "boolVar")); check(TOKEN_STRING(js, tok[0], "boolVar"));
check(TOKEN_STRING(js, tok[1], "false")); check(TOKEN_STRING(js, tok[1], "false"));
@ -136,7 +136,7 @@ int test_primitive() {
js = "\"intVar\" : 12345"; js = "\"intVar\" : 12345";
jsmn_init(&p); jsmn_init(&p);
r = jsmn_parse(&p, js, strlen(js), tok, 10); r = jsmn_parse(&p, js, strlen(js), tok, 10);
check(r >= 0 && tok[0].type == JSMN_STRING check(r >= 0 && tok[0].type == JSMN_STRING
&& tok[1].type == JSMN_PRIMITIVE); && tok[1].type == JSMN_PRIMITIVE);
check(TOKEN_STRING(js, tok[0], "intVar")); check(TOKEN_STRING(js, tok[0], "intVar"));
check(TOKEN_STRING(js, tok[1], "12345")); check(TOKEN_STRING(js, tok[1], "12345"));
@ -144,7 +144,7 @@ int test_primitive() {
js = "\"floatVar\" : 12.345"; js = "\"floatVar\" : 12.345";
jsmn_init(&p); jsmn_init(&p);
r = jsmn_parse(&p, js, strlen(js), tok, 10); r = jsmn_parse(&p, js, strlen(js), tok, 10);
check(r >= 0 && tok[0].type == JSMN_STRING check(r >= 0 && tok[0].type == JSMN_STRING
&& tok[1].type == JSMN_PRIMITIVE); && tok[1].type == JSMN_PRIMITIVE);
check(TOKEN_STRING(js, tok[0], "floatVar")); check(TOKEN_STRING(js, tok[0], "floatVar"));
check(TOKEN_STRING(js, tok[1], "12.345")); check(TOKEN_STRING(js, tok[1], "12.345"));
@ -152,7 +152,7 @@ int test_primitive() {
js = "\"nullVar\" : null"; js = "\"nullVar\" : null";
jsmn_init(&p); jsmn_init(&p);
r = jsmn_parse(&p, js, strlen(js), tok, 10); r = jsmn_parse(&p, js, strlen(js), tok, 10);
check(r >= 0 && tok[0].type == JSMN_STRING check(r >= 0 && tok[0].type == JSMN_STRING
&& tok[1].type == JSMN_PRIMITIVE); && tok[1].type == JSMN_PRIMITIVE);
check(TOKEN_STRING(js, tok[0], "nullVar")); check(TOKEN_STRING(js, tok[0], "nullVar"));
check(TOKEN_STRING(js, tok[1], "null")); check(TOKEN_STRING(js, tok[1], "null"));
@ -169,7 +169,7 @@ int test_string() {
js = "\"strVar\" : \"hello world\""; js = "\"strVar\" : \"hello world\"";
jsmn_init(&p); jsmn_init(&p);
r = jsmn_parse(&p, js, strlen(js), tok, 10); r = jsmn_parse(&p, js, strlen(js), tok, 10);
check(r >= 0 && tok[0].type == JSMN_STRING check(r >= 0 && tok[0].type == JSMN_STRING
&& tok[1].type == JSMN_STRING); && tok[1].type == JSMN_STRING);
check(TOKEN_STRING(js, tok[0], "strVar")); check(TOKEN_STRING(js, tok[0], "strVar"));
check(TOKEN_STRING(js, tok[1], "hello world")); check(TOKEN_STRING(js, tok[1], "hello world"));
@ -177,7 +177,7 @@ int test_string() {
js = "\"strVar\" : \"escapes: \\/\\r\\n\\t\\b\\f\\\"\\\\\""; js = "\"strVar\" : \"escapes: \\/\\r\\n\\t\\b\\f\\\"\\\\\"";
jsmn_init(&p); jsmn_init(&p);
r = jsmn_parse(&p, js, strlen(js), tok, 10); r = jsmn_parse(&p, js, strlen(js), tok, 10);
check(r >= 0 && tok[0].type == JSMN_STRING check(r >= 0 && tok[0].type == JSMN_STRING
&& tok[1].type == JSMN_STRING); && tok[1].type == JSMN_STRING);
check(TOKEN_STRING(js, tok[0], "strVar")); check(TOKEN_STRING(js, tok[0], "strVar"));
check(TOKEN_STRING(js, tok[1], "escapes: \\/\\r\\n\\t\\b\\f\\\"\\\\")); check(TOKEN_STRING(js, tok[1], "escapes: \\/\\r\\n\\t\\b\\f\\\"\\\\"));
@ -185,7 +185,7 @@ int test_string() {
js = "\"strVar\" : \"\""; js = "\"strVar\" : \"\"";
jsmn_init(&p); jsmn_init(&p);
r = jsmn_parse(&p, js, strlen(js), tok, 10); r = jsmn_parse(&p, js, strlen(js), tok, 10);
check(r >= 0 && tok[0].type == JSMN_STRING check(r >= 0 && tok[0].type == JSMN_STRING
&& tok[1].type == JSMN_STRING); && tok[1].type == JSMN_STRING);
check(TOKEN_STRING(js, tok[0], "strVar")); check(TOKEN_STRING(js, tok[0], "strVar"));
check(TOKEN_STRING(js, tok[1], "")); check(TOKEN_STRING(js, tok[1], ""));
@ -263,18 +263,18 @@ int test_partial_array() {
jsmn_init(&p); jsmn_init(&p);
js = " [ 1, true, "; js = " [ 1, true, ";
r = jsmn_parse(&p, js, strlen(js), tok, 10); r = jsmn_parse(&p, js, strlen(js), tok, 10);
check(r == JSMN_ERROR_PART && tok[0].type == JSMN_ARRAY check(r == JSMN_ERROR_PART && tok[0].type == JSMN_ARRAY
&& tok[1].type == JSMN_PRIMITIVE && tok[2].type == JSMN_PRIMITIVE); && tok[1].type == JSMN_PRIMITIVE && tok[2].type == JSMN_PRIMITIVE);
js = " [ 1, true, [123, \"hello"; js = " [ 1, true, [123, \"hello";
r = jsmn_parse(&p, js, strlen(js), tok, 10); r = jsmn_parse(&p, js, strlen(js), tok, 10);
check(r == JSMN_ERROR_PART && tok[0].type == JSMN_ARRAY check(r == JSMN_ERROR_PART && tok[0].type == JSMN_ARRAY
&& tok[1].type == JSMN_PRIMITIVE && tok[2].type == JSMN_PRIMITIVE && tok[1].type == JSMN_PRIMITIVE && tok[2].type == JSMN_PRIMITIVE
&& tok[3].type == JSMN_ARRAY && tok[4].type == JSMN_PRIMITIVE); && tok[3].type == JSMN_ARRAY && tok[4].type == JSMN_PRIMITIVE);
js = " [ 1, true, [123, \"hello\"]"; js = " [ 1, true, [123, \"hello\"]";
r = jsmn_parse(&p, js, strlen(js), tok, 10); r = jsmn_parse(&p, js, strlen(js), tok, 10);
check(r == JSMN_ERROR_PART && tok[0].type == JSMN_ARRAY check(r == JSMN_ERROR_PART && tok[0].type == JSMN_ARRAY
&& tok[1].type == JSMN_PRIMITIVE && tok[2].type == JSMN_PRIMITIVE && tok[1].type == JSMN_PRIMITIVE && tok[2].type == JSMN_PRIMITIVE
&& tok[3].type == JSMN_ARRAY && tok[4].type == JSMN_PRIMITIVE && tok[3].type == JSMN_ARRAY && tok[4].type == JSMN_PRIMITIVE
&& tok[5].type == JSMN_STRING); && tok[5].type == JSMN_STRING);
@ -283,7 +283,7 @@ int test_partial_array() {
js = " [ 1, true, [123, \"hello\"]]"; js = " [ 1, true, [123, \"hello\"]]";
r = jsmn_parse(&p, js, strlen(js), tok, 10); r = jsmn_parse(&p, js, strlen(js), tok, 10);
check(r >= 0 && tok[0].type == JSMN_ARRAY check(r >= 0 && tok[0].type == JSMN_ARRAY
&& tok[1].type == JSMN_PRIMITIVE && tok[2].type == JSMN_PRIMITIVE && tok[1].type == JSMN_PRIMITIVE && tok[2].type == JSMN_PRIMITIVE
&& tok[3].type == JSMN_ARRAY && tok[4].type == JSMN_PRIMITIVE && tok[3].type == JSMN_ARRAY && tok[4].type == JSMN_PRIMITIVE
&& tok[5].type == JSMN_STRING); && tok[5].type == JSMN_STRING);
@ -470,7 +470,7 @@ int test_count() {
js = "[[], [[]], [[], []]]"; js = "[[], [[]], [[], []]]";
jsmn_init(&p); jsmn_init(&p);
check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 7); check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 7);
js = "[\"a\", [[], []]]"; js = "[\"a\", [[], []]]";
jsmn_init(&p); jsmn_init(&p);
check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 5); check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 5);
@ -486,7 +486,7 @@ int test_count() {
js = "[1, 2, [3, \"a\"], null]"; js = "[1, 2, [3, \"a\"], null]";
jsmn_init(&p); jsmn_init(&p);
check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 7); check(jsmn_parse(&p, js, strlen(js), NULL, 0) == 7);
return 0; return 0;
} }

Loading…
Cancel
Save