From 40392b73e3f3048e10f1338f7ab9b5e47a8aa08e Mon Sep 17 00:00:00 2001 From: "Serge A. Zaitsev" Date: Mon, 27 Jan 2014 15:58:43 +0200 Subject: [PATCH] fixed indentation and comments style after merge --- jsmn.c | 26 ++++++++--------- jsmn_test.c | 84 ++++++++++++++++++++++++++--------------------------- 2 files changed, 55 insertions(+), 55 deletions(-) diff --git a/jsmn.c b/jsmn.c index 1091b95..4f70adb 100644 --- a/jsmn.c +++ b/jsmn.c @@ -116,19 +116,19 @@ static jsmnerr_t jsmn_parse_string(jsmn_parser *parser, const char *js, break; /* Allows escaped symbol \uXXXX */ case 'u': - parser->pos++; - int i=0; - for(;i<4&&js[parser->pos] != '\0';i++) { - // If it isn't a hex character we have an error - if(!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || // 0-9 - (js[parser->pos] >= 65 && js[parser->pos] <= 70) || // A-F - (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { // a-f - parser->pos = start; - return JSMN_ERROR_INVAL; - } - parser->pos++; - } - parser->pos--; + parser->pos++; + int i = 0; + for(; i < 4 && js[parser->pos] != '\0'; i++) { + /* If it isn't a hex character we have an error */ + if(!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */ + (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */ + (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */ + parser->pos = start; + return JSMN_ERROR_INVAL; + } + parser->pos++; + } + parser->pos--; break; /* Unexpected symbol */ default: diff --git a/jsmn_test.c b/jsmn_test.c index c381fcb..fe5f000 100644 --- a/jsmn_test.c +++ b/jsmn_test.c @@ -349,47 +349,47 @@ int test_objects_arrays() { } int test_unicode_characters() { - jsmn_parser p; - jsmntok_t tokens[10]; - const char *js; - - int r; - js = "{\"a\":\"\\uAbcD\"}"; - jsmn_init(&p); - r = jsmn_parse(&p, js, tokens, 10); - check(r == JSMN_SUCCESS); - - js = "{\"a\":\"str\\u0000\"}"; - jsmn_init(&p); - r = jsmn_parse(&p, js, tokens, 10); - check(r == JSMN_SUCCESS); - - js = "{\"a\":\"\\uFFFFstr\"}"; - jsmn_init(&p); - r = jsmn_parse(&p, js, tokens, 10); - check(r == JSMN_SUCCESS); - - js = "{\"a\":\"str\\uFFGFstr\"}"; - jsmn_init(&p); - r = jsmn_parse(&p, js, tokens, 10); - check(r == JSMN_ERROR_INVAL); - - js = "{\"a\":\"str\\u@FfF\"}"; - jsmn_init(&p); - r = jsmn_parse(&p, js, tokens, 10); - check(r == JSMN_ERROR_INVAL); - - js = "{\"a\":[\"\\u028\"]}"; - jsmn_init(&p); - r = jsmn_parse(&p, js, tokens, 10); - check(r == JSMN_ERROR_INVAL); - - js = "{\"a\":[\"\\u0280\"]}"; - jsmn_init(&p); - r = jsmn_parse(&p, js, tokens, 10); - check(r == JSMN_SUCCESS); - - return 0; + jsmn_parser p; + jsmntok_t tokens[10]; + const char *js; + + int r; + js = "{\"a\":\"\\uAbcD\"}"; + jsmn_init(&p); + r = jsmn_parse(&p, js, tokens, 10); + check(r == JSMN_SUCCESS); + + js = "{\"a\":\"str\\u0000\"}"; + jsmn_init(&p); + r = jsmn_parse(&p, js, tokens, 10); + check(r == JSMN_SUCCESS); + + js = "{\"a\":\"\\uFFFFstr\"}"; + jsmn_init(&p); + r = jsmn_parse(&p, js, tokens, 10); + check(r == JSMN_SUCCESS); + + js = "{\"a\":\"str\\uFFGFstr\"}"; + jsmn_init(&p); + r = jsmn_parse(&p, js, tokens, 10); + check(r == JSMN_ERROR_INVAL); + + js = "{\"a\":\"str\\u@FfF\"}"; + jsmn_init(&p); + r = jsmn_parse(&p, js, tokens, 10); + check(r == JSMN_ERROR_INVAL); + + js = "{\"a\":[\"\\u028\"]}"; + jsmn_init(&p); + r = jsmn_parse(&p, js, tokens, 10); + check(r == JSMN_ERROR_INVAL); + + js = "{\"a\":[\"\\u0280\"]}"; + jsmn_init(&p); + r = jsmn_parse(&p, js, tokens, 10); + check(r == JSMN_SUCCESS); + + return 0; } int main() { @@ -402,7 +402,7 @@ int main() { test(test_array_nomem, "test array reading with a smaller number of tokens"); test(test_unquoted_keys, "test unquoted keys (like in JavaScript)"); test(test_objects_arrays, "test objects and arrays"); - test(test_unicode_characters, "test unicode characters"); + test(test_unicode_characters, "test unicode characters"); printf("\nPASSED: %d\nFAILED: %d\n", test_passed, test_failed); return 0; }