diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-05-12 18:44:17 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-05-12 18:44:17 -0300 |
commit | 45c430eac04b070a996437b79e40656942a4c7d4 (patch) | |
tree | 4816147bf5b2066fda992a131839c208b4ad391c /lauxlib.c | |
parent | 27d9219cf3649a195fdf7a2211efcb704cf3bffc (diff) | |
download | lua-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.c | 11 |
1 files changed, 3 insertions, 8 deletions
@@ -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: |