From 318575627f5a38328e38acf23733c53abfe65be1 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 7 Jun 2013 16:02:05 -0300 Subject: [PATCH] avoid adding '.0' to "numbers" like "nan" and "inf" --- lvm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lvm.c b/lvm.c index 26f65742..5e01944c 100644 --- a/lvm.c +++ b/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 ** 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';