aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorspacewander <spacewanderlzx@gmail.com>2017-01-31 13:09:55 +0800
committerYichun Zhang (agentzh) <agentzh@gmail.com>2017-01-31 12:17:37 -0800
commitfd35fd98035735bc91c55d14832461e41dd0e193 (patch)
tree364d8e04b07fdb7390e76629afd2e7ccaff2cacd
parenta61d7840ba2d79df8cb73d8c864a99d0eb06d580 (diff)
downloadlua-cjson-fd35fd98035735bc91c55d14832461e41dd0e193.tar.gz
lua-cjson-fd35fd98035735bc91c55d14832461e41dd0e193.tar.bz2
lua-cjson-fd35fd98035735bc91c55d14832461e41dd0e193.zip
feature: supports MS C compiler older than VC2012.
Signed-off-by: Yichun Zhang (agentzh) <agentzh@gmail.com>
-rw-r--r--fpconv.c6
-rw-r--r--lua-cjson-2.1devel-1.rockspec2
-rw-r--r--lua_cjson.c10
-rw-r--r--strbuf.h5
4 files changed, 22 insertions, 1 deletions
diff --git a/fpconv.c b/fpconv.c
index 854662c..3e480ec 100644
--- a/fpconv.c
+++ b/fpconv.c
@@ -35,6 +35,12 @@
35 35
36#include "fpconv.h" 36#include "fpconv.h"
37 37
38/* Workaround for MSVC */
39#ifdef _MSC_VER
40#define inline __inline
41#define snprintf sprintf_s
42#endif
43
38/* Lua CJSON assumes the locale is the same for all threads within a 44/* Lua CJSON assumes the locale is the same for all threads within a
39 * process and doesn't change after initialisation. 45 * process and doesn't change after initialisation.
40 * 46 *
diff --git a/lua-cjson-2.1devel-1.rockspec b/lua-cjson-2.1devel-1.rockspec
index 154e333..d614d05 100644
--- a/lua-cjson-2.1devel-1.rockspec
+++ b/lua-cjson-2.1devel-1.rockspec
@@ -47,7 +47,7 @@ build = {
47 -- Override default build options (per platform) 47 -- Override default build options (per platform)
48 platforms = { 48 platforms = {
49 win32 = { modules = { cjson = { defines = { 49 win32 = { modules = { cjson = { defines = {
50 "DISABLE_INVALID_NUMBERS" 50 "DISABLE_INVALID_NUMBERS", "USE_INTERNAL_ISINF"
51 } } } } 51 } } } }
52 }, 52 },
53 copy_directories = { "tests" } 53 copy_directories = { "tests" }
diff --git a/lua_cjson.c b/lua_cjson.c
index 1695979..89cba6d 100644
--- a/lua_cjson.c
+++ b/lua_cjson.c
@@ -54,6 +54,16 @@
54#define CJSON_VERSION "2.1devel" 54#define CJSON_VERSION "2.1devel"
55#endif 55#endif
56 56
57#ifdef _MSC_VER
58#define snprintf sprintf_s
59
60#ifndef isnan
61#include <float.h>
62#define isnan(x) _isnan(x)
63#endif
64
65#endif
66
57/* Workaround for Solaris platforms missing isinf() */ 67/* Workaround for Solaris platforms missing isinf() */
58#if !defined(isinf) && (defined(USE_INTERNAL_ISINF) || defined(MISSING_ISINF)) 68#if !defined(isinf) && (defined(USE_INTERNAL_ISINF) || defined(MISSING_ISINF))
59#define isinf(x) (!isnan(x) && isnan((x) - (x))) 69#define isinf(x) (!isnan(x) && isnan((x) - (x)))
diff --git a/strbuf.h b/strbuf.h
index d861108..5df0b7b 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -25,6 +25,11 @@
25#include <stdlib.h> 25#include <stdlib.h>
26#include <stdarg.h> 26#include <stdarg.h>
27 27
28/* Workaround for MSVC */
29#ifdef _MSC_VER
30#define inline __inline
31#endif
32
28/* Size: Total bytes allocated to *buf 33/* Size: Total bytes allocated to *buf
29 * Length: String length, excluding optional NULL terminator. 34 * Length: String length, excluding optional NULL terminator.
30 * Increment: Allocation increments when resizing the string buffer. 35 * Increment: Allocation increments when resizing the string buffer.