aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-05-14 16:47:11 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-05-14 16:47:11 -0300
commitf8daddba506112cafdc980a4935e46cf358e37c1 (patch)
tree704bc9c5eb5c4841b2b3cea4c2a52afd32618273
parente58ef8d0bbd2f4fc873cd40218922f9a25de4c2e (diff)
downloadlua-f8daddba506112cafdc980a4935e46cf358e37c1.tar.gz
lua-f8daddba506112cafdc980a4935e46cf358e37c1.tar.bz2
lua-f8daddba506112cafdc980a4935e46cf358e37c1.zip
added a compat option (although it will be off by default) to
the addition of '.0' to float->string conversions
-rw-r--r--lvm.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lvm.c b/lvm.c
index 4f5d8fe1..64829962 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.208 2014/05/12 21:22:05 roberto Exp roberto $ 2** $Id: lvm.c,v 2.209 2014/05/12 21:44:17 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -140,10 +140,12 @@ int luaV_tostring (lua_State *L, StkId obj) {
140 len = lua_integer2str(buff, ivalue(obj)); 140 len = lua_integer2str(buff, ivalue(obj));
141 else { 141 else {
142 len = lua_number2str(buff, fltvalue(obj)); 142 len = lua_number2str(buff, fltvalue(obj));
143#if !defined(LUA_COMPAT_FLOATSTRING)
143 if (buff[strspn(buff, "-0123456789")] == '\0') { /* looks like an int? */ 144 if (buff[strspn(buff, "-0123456789")] == '\0') { /* looks like an int? */
144 buff[len++] = '.'; 145 buff[len++] = '.';
145 buff[len++] = '0'; /* adds '.0' to result */ 146 buff[len++] = '0'; /* adds '.0' to result */
146 } 147 }
148#endif
147 } 149 }
148 setsvalue2s(L, obj, luaS_newlstr(L, buff, len)); 150 setsvalue2s(L, obj, luaS_newlstr(L, buff, len));
149 return 1; 151 return 1;