aboutsummaryrefslogtreecommitdiff
path: root/lauxlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-05-12 18:44:17 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-05-12 18:44:17 -0300
commit45c430eac04b070a996437b79e40656942a4c7d4 (patch)
tree4816147bf5b2066fda992a131839c208b4ad391c /lauxlib.c
parent27d9219cf3649a195fdf7a2211efcb704cf3bffc (diff)
downloadlua-45c430eac04b070a996437b79e40656942a4c7d4.tar.gz
lua-45c430eac04b070a996437b79e40656942a4c7d4.tar.bz2
lua-45c430eac04b070a996437b79e40656942a4c7d4.zip
addition of '.0' to float representation done by the kernel
Diffstat (limited to 'lauxlib.c')
-rw-r--r--lauxlib.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/lauxlib.c b/lauxlib.c
index 843843ce..06a5882d 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.c,v 1.261 2014/04/01 18:55:06 roberto Exp roberto $ 2** $Id: lauxlib.c,v 1.262 2014/04/15 18:25:49 roberto Exp roberto $
3** Auxiliary functions for building Lua libraries 3** Auxiliary functions for building Lua libraries
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -757,13 +757,8 @@ LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) {
757 case LUA_TNUMBER: { 757 case LUA_TNUMBER: {
758 if (lua_isinteger(L, idx)) 758 if (lua_isinteger(L, idx))
759 lua_pushfstring(L, "%I", lua_tointeger(L, idx)); 759 lua_pushfstring(L, "%I", lua_tointeger(L, idx));
760 else { 760 else
761 const char *s = lua_pushfstring(L, "%f", lua_tonumber(L, idx)); 761 lua_pushfstring(L, "%f", lua_tonumber(L, idx));
762 if (s[strspn(s, "-0123456789")] == '\0') { /* looks like an int? */
763 lua_pushliteral(L, ".0"); /* add a '.0' to result */
764 lua_concat(L, 2);
765 }
766 }
767 break; 762 break;
768 } 763 }
769 case LUA_TSTRING: 764 case LUA_TSTRING: