diff options
author | Mark Pulford <mark@kyne.com.au> | 2011-05-01 18:46:51 +0930 |
---|---|---|
committer | Mark Pulford <mark@kyne.com.au> | 2011-05-01 18:46:51 +0930 |
commit | 6fb4dd5283870100dd2e877327c923953d8639eb (patch) | |
tree | 824d0f0a8e470e0d1ef4f4c27e87dde357e52e7e | |
parent | 024dd94968e60fa3177c869a0c200d116f78f924 (diff) | |
download | lua-cjson-6fb4dd5283870100dd2e877327c923953d8639eb.tar.gz lua-cjson-6fb4dd5283870100dd2e877327c923953d8639eb.tar.bz2 lua-cjson-6fb4dd5283870100dd2e877327c923953d8639eb.zip |
Update lua_cjson.c with minor fixes
- Fix typo and comment
- Change "while" to "for" loop
-rw-r--r-- | lua_cjson.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/lua_cjson.c b/lua_cjson.c index abf2bfc..aaf476d 100644 --- a/lua_cjson.c +++ b/lua_cjson.c | |||
@@ -405,7 +405,7 @@ static void json_append_number(lua_State *l, strbuf_t *json, int index, | |||
405 | double num = lua_tonumber(l, index); | 405 | double num = lua_tonumber(l, index); |
406 | 406 | ||
407 | if (strict && (isinf(num) || isnan(num))) | 407 | if (strict && (isinf(num) || isnan(num))) |
408 | json_encode_exception(l, json, index, "must not be NaN of Inf"); | 408 | json_encode_exception(l, json, index, "must not be NaN or Inf"); |
409 | 409 | ||
410 | strbuf_append_fmt(json, LUA_NUMBER_FMT, num); | 410 | strbuf_append_fmt(json, LUA_NUMBER_FMT, num); |
411 | } | 411 | } |
@@ -433,8 +433,7 @@ static void json_append_object(lua_State *l, json_config_t *cfg, | |||
433 | keytype = lua_type(l, -2); | 433 | keytype = lua_type(l, -2); |
434 | if (keytype == LUA_TNUMBER) { | 434 | if (keytype == LUA_TNUMBER) { |
435 | /* Can't just use json_append_string() below since it would | 435 | /* Can't just use json_append_string() below since it would |
436 | * convert the value in the callers data structure, and it | 436 | * convert the value in the callers data structure. */ |
437 | * does not support strict numbers */ | ||
438 | strbuf_append_char(json, '"'); | 437 | strbuf_append_char(json, '"'); |
439 | json_append_number(l, json, -2, cfg->strict_numbers); | 438 | json_append_number(l, json, -2, cfg->strict_numbers); |
440 | strbuf_append_string(json, "\": "); | 439 | strbuf_append_string(json, "\": "); |
@@ -903,8 +902,7 @@ static void json_parse_array_context(lua_State *l, json_parse_t *json) | |||
903 | if (token.type == T_ARR_END) | 902 | if (token.type == T_ARR_END) |
904 | return; | 903 | return; |
905 | 904 | ||
906 | i = 1; | 905 | for (i = 1; ; i++) { |
907 | while (1) { | ||
908 | json_process_value(l, json, &token); | 906 | json_process_value(l, json, &token); |
909 | lua_rawseti(l, -2, i); /* arr[i] = value */ | 907 | lua_rawseti(l, -2, i); /* arr[i] = value */ |
910 | 908 | ||
@@ -917,7 +915,6 @@ static void json_parse_array_context(lua_State *l, json_parse_t *json) | |||
917 | json_throw_parse_error(l, json, "comma or array end", &token); | 915 | json_throw_parse_error(l, json, "comma or array end", &token); |
918 | 916 | ||
919 | json_next_token(json, &token); | 917 | json_next_token(json, &token); |
920 | i++; | ||
921 | } | 918 | } |
922 | } | 919 | } |
923 | 920 | ||