diff options
author | Mark Pulford <mark@kyne.com.au> | 2011-12-29 23:03:58 +1030 |
---|---|---|
committer | Mark Pulford <mark@kyne.com.au> | 2012-03-04 18:54:34 +1030 |
commit | ca42b9a996f9046ba3876ad8a81cda1d935b39cf (patch) | |
tree | 229cc0e408e28abc882778c68496c87af0d781ba /fpconv.h | |
parent | 8eecc878e0560461ef42bd3cd8d6dfe33cf148e8 (diff) | |
download | lua-cjson-ca42b9a996f9046ba3876ad8a81cda1d935b39cf.tar.gz lua-cjson-ca42b9a996f9046ba3876ad8a81cda1d935b39cf.tar.bz2 lua-cjson-ca42b9a996f9046ba3876ad8a81cda1d935b39cf.zip |
Use internal dtoa/strtod for double conversion
The internal Lua CJSON dtoa/strtod routines have locale support
disabled. This avoids problems under locales with comma decimal
separators.
Build changes:
- CMake: Check for big endian architectures
- Makefile: Provide option to build with dtoa.c
Modifications to dtoa.c:
- Include locale dtoa_config.h configuration
- Rename Infinity/NaN to inf/nan to match common C libraries
- Rename strtod() -> internal_strtod() to prevent conflict with libc
function
Modifications to g_fmt.c:
- Return output string length (instead of original buffer pointer)
- Provide precision as an argument to g_fmt()
- Silence compilations warnings from vendor source
- while(a = b)
- Unused label "done:"
- Only swap to scientific notation when once the number of decimal
digits required exceeds the precision available. This matches
standard printf format %g.
- Display a "0" in front of numbers < 1.
Diffstat (limited to 'fpconv.h')
-rw-r--r-- | fpconv.h | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -6,7 +6,15 @@ | |||
6 | * -1.7976931348623e+308 */ | 6 | * -1.7976931348623e+308 */ |
7 | # define FPCONV_G_FMT_BUFSIZE 32 | 7 | # define FPCONV_G_FMT_BUFSIZE 32 |
8 | 8 | ||
9 | extern void fpconv_init(); | 9 | #ifdef USE_INTERNAL_DTOA |
10 | static inline void fpconv_init() | ||
11 | { | ||
12 | /* Do nothing - not required */ | ||
13 | } | ||
14 | #else | ||
15 | extern inline void fpconv_init(); | ||
16 | #endif | ||
17 | |||
10 | extern int fpconv_g_fmt(char*, double, int); | 18 | extern int fpconv_g_fmt(char*, double, int); |
11 | extern double fpconv_strtod(const char*, char**); | 19 | extern double fpconv_strtod(const char*, char**); |
12 | 20 | ||