Give it a chance of working under Lua 5.1

This commit is contained in:
philip 2020-09-22 20:45:05 -04:00 committed by Nathaniel Wesley Filardo
parent df9f3030e6
commit 96d8047f71
2 changed files with 3 additions and 3 deletions

View File

@ -401,7 +401,7 @@
@@ l_sprintf is equivalent to 'snprintf' or 'sprintf' in C89.
** (All uses in Lua have only one format item.)
*/
#if !defined(LUA_USE_C89) && !defined(LUA_USE_ESP8266)
#if !defined(LUA_USE_C89) || defined(LUA_USE_ESP8266)
#define l_sprintf(s,sz,f,i) snprintf(s,sz,f,i)
#else
#define l_sprintf(s,sz,f,i) ((void)(sz), sprintf(s,f,i))

View File

@ -725,9 +725,9 @@ static void encode_lua_object(lua_State *L, ENC_DATA *data, int argno, const cha
char value[50];
if (lua_isinteger(L, -1)) {
l_sprintf(value, sizeof(value), LUA_INTEGER_FMT, lua_tointeger(L, -1));
snprintf(value, sizeof(value), LUA_INTEGER_FMT, lua_tointeger(L, -1));
} else {
l_sprintf(value, sizeof(value), SJSON_FLOAT_FMT, lua_tonumber(L, -1));
snprintf(value, sizeof(value), SJSON_FLOAT_FMT, lua_tonumber(L, -1));
}
lua_pop(L, 1);
if (strcmp(value, "-Infinity") == 0 || strcmp(value, "NaN") == 0 || strcmp(value, "Infinity") == 0) {