From dd231d4cd0e277fedb6ca23d9685202787dc65b1 Mon Sep 17 00:00:00 2001 From: Mark Pulford Date: Thu, 19 Jan 2012 00:56:40 +1030 Subject: Remove deprecated "refuse_invalid_numbers" Remove deprecated "refuse_invalid_numbers" since the version number will be bumped to 1.1.0. Also remove "version" variable since it has been replaced by _VERSION. --- lua_cjson.c | 38 -------------------------------------- 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) return 1; } -/* When enabled, rejects: NaN, Infinity, hexadecimal numbers. - * - * This function has been deprecated and may be removed in future. */ -static int json_cfg_refuse_invalid_numbers(lua_State *l) -{ - static const char *options[] = { "none", "encode", "decode", "both", NULL }; - json_config_t *cfg = json_arg_init(l, 1); - int setting; - - /* Map config variables to options list index */ - setting = !cfg->encode_invalid_numbers + /* bit 0 */ - (!cfg->decode_invalid_numbers << 1); /* bit 1 */ - - json_enum_option(l, 1, &setting, options, 3); - - /* Map options list index to config variables - * - * Only update the config variables when an argument has been provided. - * Otherwise a "null" encoding setting may inadvertently be disabled. */ - if (!lua_isnil(l, 1)) { - cfg->encode_invalid_numbers = !(setting & 1); - cfg->decode_invalid_numbers = !(setting & 2); - -#if DISABLE_INVALID_NUMBERS - if (cfg->encode_invalid_numbers || cfg->decode_invalid_numbers) { - cfg->encode_invalid_numbers = cfg->decode_invalid_numbers = 0; - luaL_error(l, "Infinity, NaN, and/or hexadecimal numbers are not supported."); - } -#endif - - } - - return 1; -} - static int json_destroy_config(lua_State *l) { json_config_t *cfg; @@ -1348,7 +1313,6 @@ static int lua_cjson_new(lua_State *l) { "encode_keep_buffer", json_cfg_encode_keep_buffer }, { "encode_invalid_numbers", json_cfg_encode_invalid_numbers }, { "decode_invalid_numbers", json_cfg_decode_invalid_numbers }, - { "refuse_invalid_numbers", json_cfg_refuse_invalid_numbers }, { "new", lua_cjson_new }, { NULL, NULL } }; @@ -1372,8 +1336,6 @@ static int lua_cjson_new(lua_State *l) lua_setfield(l, -2, "_NAME"); lua_pushliteral(l, CJSON_VERSION); lua_setfield(l, -2, "_VERSION"); - lua_pushliteral(l, CJSON_VERSION); - lua_setfield(l, -2, "version"); return 1; } 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() local cjson_tests = { -- Test API variables { "Check module name, version", - function () return json._NAME, json._VERSION, json.version end, { }, - true, { "cjson", "1.1devel", "1.1devel" } }, + function () return json._NAME, json._VERSION end, { }, + true, { "cjson", "1.1devel" } }, -- Test decoding simple types { "Decode string", -- cgit v1.2.3-55-g6feb