diff options
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | lua_cjson.c | 9 | ||||
-rw-r--r-- | manual.txt | 4 | ||||
-rwxr-xr-x | tests/test.lua | 2 |
5 files changed, 9 insertions, 14 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3768fc4..c18381f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -6,7 +6,7 @@ | |||
6 | project(lua-cjson C) | 6 | project(lua-cjson C) |
7 | cmake_minimum_required(VERSION 2.6) | 7 | cmake_minimum_required(VERSION 2.6) |
8 | 8 | ||
9 | option(DISABLE_CJSON_GLOBAL "Disable global registration of the 'cjson' module table") | 9 | option(ENABLE_CJSON_GLOBAL "Register cjson module table as a global variable - not recommended") |
10 | option(USE_INTERNAL_DTOA "Use internal strtod() / dtoa code for performance") | 10 | option(USE_INTERNAL_DTOA "Use internal strtod() / dtoa code for performance") |
11 | option(MULTIPLE_THREADS | 11 | option(MULTIPLE_THREADS |
12 | "Build internal dtoa with support for multi-threaded applications - recommended" ON) | 12 | "Build internal dtoa with support for multi-threaded applications - recommended" ON) |
@@ -20,8 +20,8 @@ endif() | |||
20 | find_package(Lua51 REQUIRED) | 20 | find_package(Lua51 REQUIRED) |
21 | include_directories(${LUA_INCLUDE_DIR}) | 21 | include_directories(${LUA_INCLUDE_DIR}) |
22 | 22 | ||
23 | if(DISABLE_CJSON_GLOBAL) | 23 | if(ENABLE_CJSON_GLOBAL) |
24 | add_definitions(-DDISABLE_CJSON_GLOBAL) | 24 | add_definitions(-DENABLE_CJSON_GLOBAL) |
25 | endif() | 25 | endif() |
26 | 26 | ||
27 | if(NOT USE_INTERNAL_DTOA) | 27 | if(NOT USE_INTERNAL_DTOA) |
@@ -1,7 +1,7 @@ | |||
1 | ##### Available defines for CJSON_CFLAGS ##### | 1 | ##### Available defines for CJSON_CFLAGS ##### |
2 | ## | 2 | ## |
3 | ## USE_INTERNAL_ISINF: Workaround for Solaris platforms missing isinf(). | 3 | ## USE_INTERNAL_ISINF: Workaround for Solaris platforms missing isinf(). |
4 | ## DISABLE_CJSON_GLOBAL: Do not store module is "cjson" global. | 4 | ## ENABLE_CJSON_GLOBAL: Register "cjson" module table as a global variable. |
5 | ## DISABLE_INVALID_NUMBERS: Permanently disable invalid JSON numbers: | 5 | ## DISABLE_INVALID_NUMBERS: Permanently disable invalid JSON numbers: |
6 | ## NaN, Infinity, hex. | 6 | ## NaN, Infinity, hex. |
7 | ## | 7 | ## |
diff --git a/lua_cjson.c b/lua_cjson.c index 0662414..118ca27 100644 --- a/lua_cjson.c +++ b/lua_cjson.c | |||
@@ -1382,13 +1382,8 @@ int luaopen_cjson(lua_State *l) | |||
1382 | { | 1382 | { |
1383 | lua_cjson_new(l); | 1383 | lua_cjson_new(l); |
1384 | 1384 | ||
1385 | #if !defined(DISABLE_CJSON_GLOBAL) && (!defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 502) | 1385 | #ifdef ENABLE_CJSON_GLOBAL |
1386 | /* Register a global "cjson" table to maintain compatibility with earlier | 1386 | /* Register a global "cjson" table. */ |
1387 | * versions of Lua CJSON which used luaL_register() under Lua 5.1. | ||
1388 | * | ||
1389 | * From Lua 5.2 onwards, Lua CJSON does not automatically register a global | ||
1390 | * table. | ||
1391 | */ | ||
1392 | lua_pushvalue(l, -1); | 1387 | lua_pushvalue(l, -1); |
1393 | lua_setglobal(l, CJSON_MODNAME); | 1388 | lua_setglobal(l, CJSON_MODNAME); |
1394 | #endif | 1389 | #endif |
@@ -113,9 +113,9 @@ Build Options (#define) | |||
113 | ~~~~~~~~~~~~~~~~~~~~~~~ | 113 | ~~~~~~~~~~~~~~~~~~~~~~~ |
114 | 114 | ||
115 | [horizontal] | 115 | [horizontal] |
116 | ENABLE_CJSON_GLOBAL:: Register +cjson+ module table as a global | ||
117 | variable (not recommended). | ||
116 | USE_INTERNAL_ISINF:: Workaround for Solaris platforms missing ++isinf++(3). | 118 | USE_INTERNAL_ISINF:: Workaround for Solaris platforms missing ++isinf++(3). |
117 | DISABLE_CJSON_GLOBAL:: Do not store module table in global "cjson" | ||
118 | variable. Redundant from Lua 5.2 onwards. | ||
119 | DISABLE_INVALID_NUMBERS:: Recommended on platforms where ++strtod++(3) / | 119 | DISABLE_INVALID_NUMBERS:: Recommended on platforms where ++strtod++(3) / |
120 | ++sprintf++(3) are not POSIX compliant (Eg, Windows MinGW). Prevents | 120 | ++sprintf++(3) are not POSIX compliant (Eg, Windows MinGW). Prevents |
121 | +cjson.encode_invalid_numbers+ and +cjson.decode_invalid_numbers+ | 121 | +cjson.encode_invalid_numbers+ and +cjson.decode_invalid_numbers+ |
diff --git a/tests/test.lua b/tests/test.lua index 19fc1af..152579e 100755 --- a/tests/test.lua +++ b/tests/test.lua | |||
@@ -69,7 +69,7 @@ function load_testdata() | |||
69 | 69 | ||
70 | local big = {} | 70 | local big = {} |
71 | for i = 1, 1100 do | 71 | for i = 1, 1100 do |
72 | big = { { 10, false, true, cjson.null }, "string", a = big } | 72 | big = { { 10, false, true, json.null }, "string", a = big } |
73 | end | 73 | end |
74 | data.deeply_nested_data = big | 74 | data.deeply_nested_data = big |
75 | 75 | ||