1
0
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:
Roberto Ierusalimschy 2013-06-07 16:02:05 -03:00
parent a14992992a
commit 318575627f

6
lvm.c
View File

@ -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
** See Copyright Notice in lua.h
*/
@ -52,12 +52,12 @@ int luaV_tostring (lua_State *L, StkId obj) {
return 0;
else {
char buff[MAXNUMBER2STR];
int len;
size_t len;
if (ttisinteger(obj))
len = lua_integer2str(buff, ivalue(obj));
else {
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++] = '0';
buff[len] = '\0';