Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpx/lua-cjson.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Pulford <mark@kyne.com.au>2012-01-21 06:14:41 +0400
committerMark Pulford <mark@kyne.com.au>2012-03-04 12:24:35 +0400
commit6264bb40e0e9d87f24bc38ad1496b153262b5331 (patch)
tree08c6388e598cdb15df1d117d249c4467eaca7645
parenta05c5153ad6b4082de209ed1154034ccd3b68326 (diff)
Ignore DISABLE_INVALID_NUMBERS with builtin fpconv
-rw-r--r--lua_cjson.c26
-rw-r--r--manual.txt3
2 files changed, 16 insertions, 13 deletions
diff --git a/lua_cjson.c b/lua_cjson.c
index b14c242..498c686 100644
--- a/lua_cjson.c
+++ b/lua_cjson.c
@@ -321,6 +321,18 @@ static int json_cfg_encode_keep_buffer(lua_State *l)
return 1;
}
+#if defined(DISABLE_INVALID_NUMBERS) && !defined(USE_INTERNAL_FPCONV)
+void json_verify_invalid_number_setting(lua_State *l, int *setting)
+{
+ if (*setting == 1) {
+ *setting = 0;
+ luaL_error(l, "Infinity, NaN, and/or hexadecimal numbers are not supported.");
+ }
+}
+#else
+#define json_verify_invalid_number_setting(l, s) do { } while(0)
+#endif
+
static int json_cfg_encode_invalid_numbers(lua_State *l)
{
static const char *options[] = { "off", "on", "null", NULL };
@@ -328,12 +340,7 @@ static int json_cfg_encode_invalid_numbers(lua_State *l)
json_enum_option(l, 1, &cfg->encode_invalid_numbers, options, 1);
-#if DISABLE_INVALID_NUMBERS
- if (cfg->encode_invalid_numbers == 1) {
- cfg->encode_invalid_numbers = 0;
- luaL_error(l, "Infinity, NaN, and/or hexadecimal numbers are not supported.");
- }
-#endif
+ json_verify_invalid_number_setting(l, &cfg->encode_invalid_numbers);
return 1;
}
@@ -344,12 +351,7 @@ static int json_cfg_decode_invalid_numbers(lua_State *l)
json_enum_option(l, 1, &cfg->decode_invalid_numbers, NULL, 1);
-#if DISABLE_INVALID_NUMBERS
- if (cfg->decode_invalid_numbers) {
- cfg->decode_invalid_numbers = 0;
- luaL_error(l, "Infinity, NaN, and/or hexadecimal numbers are not supported.");
- }
-#endif
+ json_verify_invalid_number_setting(l, &cfg->encode_invalid_numbers);
return 1;
}
diff --git a/manual.txt b/manual.txt
index eacd2c7..d7c916a 100644
--- a/manual.txt
+++ b/manual.txt
@@ -120,7 +120,8 @@ DISABLE_INVALID_NUMBERS:: Recommended on platforms where ++strtod++(3) /
++sprintf++(3) are not POSIX compliant (Eg, Windows MinGW). Prevents
+cjson.encode_invalid_numbers+ and +cjson.decode_invalid_numbers+
from being enabled. However, +cjson.encode_invalid_numbers+ may be
- set to +"null"+.
+ set to +"null"+. This option is unnecessary and is ignored when
+ using built-in floating point conversion.
Built-in dtoa() support