diff options
-rw-r--r-- | lua-cjson.spec | 2 | ||||
-rw-r--r-- | lua_cjson.c | 18 | ||||
-rw-r--r-- | strbuf.c | 6 | ||||
-rw-r--r-- | strbuf.h | 6 | ||||
-rw-r--r-- | tests/common.lua | 2 | ||||
-rwxr-xr-x | tests/test.lua | 6 |
6 files changed, 20 insertions, 20 deletions
diff --git a/lua-cjson.spec b/lua-cjson.spec index a86ee20..874a6bc 100644 --- a/lua-cjson.spec +++ b/lua-cjson.spec | |||
@@ -18,7 +18,7 @@ Requires: lua >= %{luaver} | |||
18 | %description | 18 | %description |
19 | CJSON provides fast JSON parsing and encoding functions for Lua. It | 19 | CJSON provides fast JSON parsing and encoding functions for Lua. It |
20 | allows a Lua application to quickly serialise a data structure to | 20 | allows a Lua application to quickly serialise a data structure to |
21 | JSON, or deserialise from JSON to Lua. | 21 | JSON, or deserialise from JSON to Lua. |
22 | 22 | ||
23 | %prep | 23 | %prep |
24 | %setup -q | 24 | %setup -q |
diff --git a/lua_cjson.c b/lua_cjson.c index 50f27c2..2228fee 100644 --- a/lua_cjson.c +++ b/lua_cjson.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* CJSON - JSON support for Lua | 1 | /* CJSON - JSON support for Lua |
2 | * | 2 | * |
3 | * Copyright (c) 2010-2011 Mark Pulford <mark@kyne.com.au> | 3 | * Copyright (c) 2010-2011 Mark Pulford <mark@kyne.com.au> |
4 | * | 4 | * |
5 | * Permission is hereby granted, free of charge, to any person obtaining | 5 | * Permission is hereby granted, free of charge, to any person obtaining |
6 | * a copy of this software and associated documentation files (the | 6 | * a copy of this software and associated documentation files (the |
7 | * "Software"), to deal in the Software without restriction, including | 7 | * "Software"), to deal in the Software without restriction, including |
@@ -9,10 +9,10 @@ | |||
9 | * distribute, sublicense, and/or sell copies of the Software, and to | 9 | * distribute, sublicense, and/or sell copies of the Software, and to |
10 | * permit persons to whom the Software is furnished to do so, subject to | 10 | * permit persons to whom the Software is furnished to do so, subject to |
11 | * the following conditions: | 11 | * the following conditions: |
12 | * | 12 | * |
13 | * The above copyright notice and this permission notice shall be | 13 | * The above copyright notice and this permission notice shall be |
14 | * included in all copies or substantial portions of the Software. | 14 | * included in all copies or substantial portions of the Software. |
15 | * | 15 | * |
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
@@ -105,7 +105,7 @@ typedef struct { | |||
105 | int encode_keep_buffer; | 105 | int encode_keep_buffer; |
106 | } json_config_t; | 106 | } json_config_t; |
107 | 107 | ||
108 | typedef struct { | 108 | typedef struct { |
109 | const char *data; | 109 | const char *data; |
110 | int index; | 110 | int index; |
111 | strbuf_t *tmp; /* Temporary storage for strings */ | 111 | strbuf_t *tmp; /* Temporary storage for strings */ |
@@ -306,7 +306,7 @@ static int json_cfg_refuse_invalid_numbers(lua_State *l) | |||
306 | static int json_destroy_config(lua_State *l) | 306 | static int json_destroy_config(lua_State *l) |
307 | { | 307 | { |
308 | json_config_t *cfg; | 308 | json_config_t *cfg; |
309 | 309 | ||
310 | cfg = lua_touserdata(l, 1); | 310 | cfg = lua_touserdata(l, 1); |
311 | if (cfg) | 311 | if (cfg) |
312 | strbuf_free(&cfg->encode_buf); | 312 | strbuf_free(&cfg->encode_buf); |
@@ -720,7 +720,7 @@ static int codepoint_to_utf8(char *utf8, int codepoint) | |||
720 | utf8[0] = codepoint; | 720 | utf8[0] = codepoint; |
721 | return 1; | 721 | return 1; |
722 | } | 722 | } |
723 | 723 | ||
724 | /* 110xxxxx 10xxxxxx */ | 724 | /* 110xxxxx 10xxxxxx */ |
725 | if (codepoint <= 0x7FF) { | 725 | if (codepoint <= 0x7FF) { |
726 | utf8[0] = (codepoint >> 6) | 0xC0; | 726 | utf8[0] = (codepoint >> 6) | 0xC0; |
@@ -843,7 +843,7 @@ static void json_next_string_token(json_parse_t *json, json_token_t *token) | |||
843 | json_set_token_error(token, json, "unexpected end of string"); | 843 | json_set_token_error(token, json, "unexpected end of string"); |
844 | return; | 844 | return; |
845 | } | 845 | } |
846 | 846 | ||
847 | /* Handle escapes */ | 847 | /* Handle escapes */ |
848 | if (ch == '\\') { | 848 | if (ch == '\\') { |
849 | /* Fetch escape character */ | 849 | /* Fetch escape character */ |
@@ -1102,7 +1102,7 @@ static void json_parse_object_context(lua_State *l, json_parse_t *json) | |||
1102 | json_throw_parse_error(l, json, "comma or object end", &token); | 1102 | json_throw_parse_error(l, json, "comma or object end", &token); |
1103 | 1103 | ||
1104 | json_next_token(json, &token); | 1104 | json_next_token(json, &token); |
1105 | } | 1105 | } |
1106 | } | 1106 | } |
1107 | 1107 | ||
1108 | /* Handle the array context */ | 1108 | /* Handle the array context */ |
@@ -1141,7 +1141,7 @@ static void json_parse_array_context(lua_State *l, json_parse_t *json) | |||
1141 | 1141 | ||
1142 | /* Handle the "value" context */ | 1142 | /* Handle the "value" context */ |
1143 | static void json_process_value(lua_State *l, json_parse_t *json, | 1143 | static void json_process_value(lua_State *l, json_parse_t *json, |
1144 | json_token_t *token) | 1144 | json_token_t *token) |
1145 | { | 1145 | { |
1146 | switch (token->type) { | 1146 | switch (token->type) { |
1147 | case T_STRING: | 1147 | case T_STRING: |
@@ -1,7 +1,7 @@ | |||
1 | /* strbuf - string buffer routines | 1 | /* strbuf - string buffer routines |
2 | * | 2 | * |
3 | * Copyright (c) 2010-2011 Mark Pulford <mark@kyne.com.au> | 3 | * Copyright (c) 2010-2011 Mark Pulford <mark@kyne.com.au> |
4 | * | 4 | * |
5 | * Permission is hereby granted, free of charge, to any person obtaining | 5 | * Permission is hereby granted, free of charge, to any person obtaining |
6 | * a copy of this software and associated documentation files (the | 6 | * a copy of this software and associated documentation files (the |
7 | * "Software"), to deal in the Software without restriction, including | 7 | * "Software"), to deal in the Software without restriction, including |
@@ -9,10 +9,10 @@ | |||
9 | * distribute, sublicense, and/or sell copies of the Software, and to | 9 | * distribute, sublicense, and/or sell copies of the Software, and to |
10 | * permit persons to whom the Software is furnished to do so, subject to | 10 | * permit persons to whom the Software is furnished to do so, subject to |
11 | * the following conditions: | 11 | * the following conditions: |
12 | * | 12 | * |
13 | * The above copyright notice and this permission notice shall be | 13 | * The above copyright notice and this permission notice shall be |
14 | * included in all copies or substantial portions of the Software. | 14 | * included in all copies or substantial portions of the Software. |
15 | * | 15 | * |
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
@@ -1,7 +1,7 @@ | |||
1 | /* strbuf - String buffer routines | 1 | /* strbuf - String buffer routines |
2 | * | 2 | * |
3 | * Copyright (c) 2010-2011 Mark Pulford <mark@kyne.com.au> | 3 | * Copyright (c) 2010-2011 Mark Pulford <mark@kyne.com.au> |
4 | * | 4 | * |
5 | * Permission is hereby granted, free of charge, to any person obtaining | 5 | * Permission is hereby granted, free of charge, to any person obtaining |
6 | * a copy of this software and associated documentation files (the | 6 | * a copy of this software and associated documentation files (the |
7 | * "Software"), to deal in the Software without restriction, including | 7 | * "Software"), to deal in the Software without restriction, including |
@@ -9,10 +9,10 @@ | |||
9 | * distribute, sublicense, and/or sell copies of the Software, and to | 9 | * distribute, sublicense, and/or sell copies of the Software, and to |
10 | * permit persons to whom the Software is furnished to do so, subject to | 10 | * permit persons to whom the Software is furnished to do so, subject to |
11 | * the following conditions: | 11 | * the following conditions: |
12 | * | 12 | * |
13 | * The above copyright notice and this permission notice shall be | 13 | * The above copyright notice and this permission notice shall be |
14 | * included in all copies or substantial portions of the Software. | 14 | * included in all copies or substantial portions of the Software. |
15 | * | 15 | * |
16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
diff --git a/tests/common.lua b/tests/common.lua index 48b4197..156f882 100644 --- a/tests/common.lua +++ b/tests/common.lua | |||
@@ -31,7 +31,7 @@ end | |||
31 | 31 | ||
32 | function serialise_table(value, indent, depth) | 32 | function serialise_table(value, indent, depth) |
33 | local spacing, spacing2, indent2 | 33 | local spacing, spacing2, indent2 |
34 | if indent then | 34 | if indent then |
35 | spacing = "\n" .. indent | 35 | spacing = "\n" .. indent |
36 | spacing2 = spacing .. " " | 36 | spacing2 = spacing .. " " |
37 | indent2 = indent .. " " | 37 | indent2 = indent .. " " |
diff --git a/tests/test.lua b/tests/test.lua index 4bb62be..bfa4f66 100755 --- a/tests/test.lua +++ b/tests/test.lua | |||
@@ -43,7 +43,7 @@ local function gen_utf16_escaped() | |||
43 | end | 43 | end |
44 | end | 44 | end |
45 | table.insert(utf16_escaped, '"') | 45 | table.insert(utf16_escaped, '"') |
46 | 46 | ||
47 | return table.concat(utf16_escaped) | 47 | return table.concat(utf16_escaped) |
48 | end | 48 | end |
49 | 49 | ||
@@ -120,10 +120,10 @@ local encode_table_tests = { | |||
120 | true, { '[null,null,"sparse test"]' } }, | 120 | true, { '[null,null,"sparse test"]' } }, |
121 | 121 | ||
122 | { json.encode, { { [1] = "one", [4] = "sparse test" } }, | 122 | { json.encode, { { [1] = "one", [4] = "sparse test" } }, |
123 | true, { '["one",null,null,"sparse test"]' } }, | 123 | true, { '["one",null,null,"sparse test"]' } }, |
124 | 124 | ||
125 | { json.encode, { { [1] = "one", [5] = "sparse test" } }, | 125 | { json.encode, { { [1] = "one", [5] = "sparse test" } }, |
126 | true, { '{"1":"one","5":"sparse test"}' } }, | 126 | true, { '{"1":"one","5":"sparse test"}' } }, |
127 | 127 | ||
128 | { json.encode, { nested5 }, true, { '[[[[["nested"]]]]]' } }, | 128 | { json.encode, { nested5 }, true, { '[[[[["nested"]]]]]' } }, |
129 | { json.encode, { { nested5 } }, | 129 | { json.encode, { { nested5 } }, |