diff options
-rw-r--r-- | lua_cjson.c | 38 | ||||
-rwxr-xr-x | tests/test.lua | 4 |
2 files changed, 2 insertions, 40 deletions
diff --git a/lua_cjson.c b/lua_cjson.c index 7f0bbb1..fea3ed5 100644 --- a/lua_cjson.c +++ b/lua_cjson.c | |||
@@ -354,41 +354,6 @@ static int json_cfg_decode_invalid_numbers(lua_State *l) | |||
354 | return 1; | 354 | return 1; |
355 | } | 355 | } |
356 | 356 | ||
357 | /* When enabled, rejects: NaN, Infinity, hexadecimal numbers. | ||
358 | * | ||
359 | * This function has been deprecated and may be removed in future. */ | ||
360 | static int json_cfg_refuse_invalid_numbers(lua_State *l) | ||
361 | { | ||
362 | static const char *options[] = { "none", "encode", "decode", "both", NULL }; | ||
363 | json_config_t *cfg = json_arg_init(l, 1); | ||
364 | int setting; | ||
365 | |||
366 | /* Map config variables to options list index */ | ||
367 | setting = !cfg->encode_invalid_numbers + /* bit 0 */ | ||
368 | (!cfg->decode_invalid_numbers << 1); /* bit 1 */ | ||
369 | |||
370 | json_enum_option(l, 1, &setting, options, 3); | ||
371 | |||
372 | /* Map options list index to config variables | ||
373 | * | ||
374 | * Only update the config variables when an argument has been provided. | ||
375 | * Otherwise a "null" encoding setting may inadvertently be disabled. */ | ||
376 | if (!lua_isnil(l, 1)) { | ||
377 | cfg->encode_invalid_numbers = !(setting & 1); | ||
378 | cfg->decode_invalid_numbers = !(setting & 2); | ||
379 | |||
380 | #if DISABLE_INVALID_NUMBERS | ||
381 | if (cfg->encode_invalid_numbers || cfg->decode_invalid_numbers) { | ||
382 | cfg->encode_invalid_numbers = cfg->decode_invalid_numbers = 0; | ||
383 | luaL_error(l, "Infinity, NaN, and/or hexadecimal numbers are not supported."); | ||
384 | } | ||
385 | #endif | ||
386 | |||
387 | } | ||
388 | |||
389 | return 1; | ||
390 | } | ||
391 | |||
392 | static int json_destroy_config(lua_State *l) | 357 | static int json_destroy_config(lua_State *l) |
393 | { | 358 | { |
394 | json_config_t *cfg; | 359 | json_config_t *cfg; |
@@ -1348,7 +1313,6 @@ static int lua_cjson_new(lua_State *l) | |||
1348 | { "encode_keep_buffer", json_cfg_encode_keep_buffer }, | 1313 | { "encode_keep_buffer", json_cfg_encode_keep_buffer }, |
1349 | { "encode_invalid_numbers", json_cfg_encode_invalid_numbers }, | 1314 | { "encode_invalid_numbers", json_cfg_encode_invalid_numbers }, |
1350 | { "decode_invalid_numbers", json_cfg_decode_invalid_numbers }, | 1315 | { "decode_invalid_numbers", json_cfg_decode_invalid_numbers }, |
1351 | { "refuse_invalid_numbers", json_cfg_refuse_invalid_numbers }, | ||
1352 | { "new", lua_cjson_new }, | 1316 | { "new", lua_cjson_new }, |
1353 | { NULL, NULL } | 1317 | { NULL, NULL } |
1354 | }; | 1318 | }; |
@@ -1372,8 +1336,6 @@ static int lua_cjson_new(lua_State *l) | |||
1372 | lua_setfield(l, -2, "_NAME"); | 1336 | lua_setfield(l, -2, "_NAME"); |
1373 | lua_pushliteral(l, CJSON_VERSION); | 1337 | lua_pushliteral(l, CJSON_VERSION); |
1374 | lua_setfield(l, -2, "_VERSION"); | 1338 | lua_setfield(l, -2, "_VERSION"); |
1375 | lua_pushliteral(l, CJSON_VERSION); | ||
1376 | lua_setfield(l, -2, "version"); | ||
1377 | 1339 | ||
1378 | return 1; | 1340 | return 1; |
1379 | } | 1341 | } |
diff --git a/tests/test.lua b/tests/test.lua index 2941a91..1bf8d2b 100755 --- a/tests/test.lua +++ b/tests/test.lua | |||
@@ -91,8 +91,8 @@ local testdata = load_testdata() | |||
91 | local cjson_tests = { | 91 | local cjson_tests = { |
92 | -- Test API variables | 92 | -- Test API variables |
93 | { "Check module name, version", | 93 | { "Check module name, version", |
94 | function () return json._NAME, json._VERSION, json.version end, { }, | 94 | function () return json._NAME, json._VERSION end, { }, |
95 | true, { "cjson", "1.1devel", "1.1devel" } }, | 95 | true, { "cjson", "1.1devel" } }, |
96 | 96 | ||
97 | -- Test decoding simple types | 97 | -- Test decoding simple types |
98 | { "Decode string", | 98 | { "Decode string", |