Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
85298b34
Commit
85298b34
authored
Sep 22, 2020
by
philip
Committed by
Nathaniel Wesley Filardo
Sep 27, 2020
Browse files
Now round trips in float firmware, and gets it roughly right in double (in lua 51)
parent
96d8047f
Changes
1
Hide whitespace changes
Inline
Side-by-side
app/modules/sjson.c
View file @
85298b34
...
...
@@ -724,13 +724,21 @@ static void encode_lua_object(lua_State *L, ENC_DATA *data, int argno, const cha
lua_pushvalue
(
L
,
argno
);
char
value
[
50
];
#if LUA_VERSION_NUM == 501
#ifdef LUA_NUMBER_INTEGRAL
snprintf
(
value
,
sizeof
(
value
),
LUA_INTEGER_FMT
,
lua_tointeger
(
L
,
-
1
));
#else
snprintf
(
value
,
sizeof
(
value
),
SJSON_FLOAT_FMT
,
lua_tonumber
(
L
,
-
1
));
#endif
#else
if
(
lua_isinteger
(
L
,
-
1
))
{
snprintf
(
value
,
sizeof
(
value
),
LUA_INTEGER_FMT
,
lua_tointeger
(
L
,
-
1
));
}
else
{
snprintf
(
value
,
sizeof
(
value
),
SJSON_FLOAT_FMT
,
lua_tonumber
(
L
,
-
1
));
}
#endif
lua_pop
(
L
,
1
);
if
(
strcmp
(
value
,
"-
Infinity
"
)
==
0
||
strcmp
(
value
,
"
NaN
"
)
==
0
||
strcmp
(
value
,
"
Infinity
"
)
==
0
)
{
if
(
strcmp
(
value
,
"-
inf
"
)
==
0
||
strcmp
(
value
,
"
nan
"
)
==
0
||
strcmp
(
value
,
"
inf
"
)
==
0
)
{
luaL_addstring
(
&
b
,
"null"
);
// According to ECMA-262 section 24.5.2 Note 4
}
else
{
luaL_addstring
(
&
b
,
value
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment