Browse Source

fix cjson.encode() when in integer version

funshine 9 years ago
parent
commit
3d14530b80
2 changed files with 3 additions and 2 deletions
  1. 2 1
      app/cjson/fpconv.c
  2. 1 1
      app/modules/cjson.c

+ 2 - 1
app/cjson/fpconv.c

@@ -35,6 +35,7 @@
 
 #include "fpconv.h"
 
+#if 0
 /* Lua CJSON assumes the locale is the same for all threads within a
  * process and doesn't change after initialisation.
  *
@@ -203,6 +204,6 @@ void fpconv_init()
 {
     fpconv_update_locale();
 }
-
+#endif
 /* vi:ai et sw=4 ts=4:
  */

+ 1 - 1
app/modules/cjson.c

@@ -772,7 +772,7 @@ static void json_append_number(lua_State *l, json_config_t *cfg,
 
     strbuf_ensure_empty_length(json, FPCONV_G_FMT_BUFSIZE);
     // len = fpconv_g_fmt(strbuf_empty_ptr(json), num, cfg->encode_number_precision);
-    c_sprintf(strbuf_empty_ptr(json), LUA_NUMBER_FMT, num);
+    c_sprintf(strbuf_empty_ptr(json), LUA_NUMBER_FMT, (LUA_NUMBER)num);
     len = c_strlen(strbuf_empty_ptr(json));
 
     strbuf_extend_length(json, len);