mirror of
https://github.com/lua/lua.git
synced 2025-01-14 05:43:00 +08:00
avoid adding '.0' to "numbers" like "nan" and "inf"
This commit is contained in:
parent
a14992992a
commit
318575627f
6
lvm.c
6
lvm.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lvm.c,v 2.171 2013/05/27 12:43:37 roberto Exp roberto $
|
** $Id: lvm.c,v 2.172 2013/06/04 19:36:42 roberto Exp roberto $
|
||||||
** Lua virtual machine
|
** Lua virtual machine
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@ -52,12 +52,12 @@ int luaV_tostring (lua_State *L, StkId obj) {
|
|||||||
return 0;
|
return 0;
|
||||||
else {
|
else {
|
||||||
char buff[MAXNUMBER2STR];
|
char buff[MAXNUMBER2STR];
|
||||||
int len;
|
size_t len;
|
||||||
if (ttisinteger(obj))
|
if (ttisinteger(obj))
|
||||||
len = lua_integer2str(buff, ivalue(obj));
|
len = lua_integer2str(buff, ivalue(obj));
|
||||||
else {
|
else {
|
||||||
len = lua_number2str(buff, fltvalue(obj));
|
len = lua_number2str(buff, fltvalue(obj));
|
||||||
if (strpbrk(buff, ".eE") == NULL) { /* no marks that it is a float? */
|
if (strspn(buff, "-0123456789") == len) { /* look like an integer? */
|
||||||
buff[len++] = '.'; /* add a '.0' */
|
buff[len++] = '.'; /* add a '.0' */
|
||||||
buff[len++] = '0';
|
buff[len++] = '0';
|
||||||
buff[len] = '\0';
|
buff[len] = '\0';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user