aboutsummaryrefslogtreecommitdiff
path: root/lauxlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2013-04-25 10:53:13 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2013-04-25 10:53:13 -0300
commit9c43d6a24e2612504686f9efbade264e2246bbfb (patch)
treed0a8adf92fb28c64e2c4d5500d819939be3ac9fa /lauxlib.c
parent01b6fe0cbfe59fe74b255ede51806a574f5cf447 (diff)
downloadlua-9c43d6a24e2612504686f9efbade264e2246bbfb.tar.gz
lua-9c43d6a24e2612504686f9efbade264e2246bbfb.tar.bz2
lua-9c43d6a24e2612504686f9efbade264e2246bbfb.zip
new format "%I" in 'lua_pushfstring' for lua_Integer
Diffstat (limited to 'lauxlib.c')
-rw-r--r--lauxlib.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/lauxlib.c b/lauxlib.c
index 286e0430..c2620357 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lauxlib.c,v 1.247 2012/10/19 15:55:01 roberto Exp roberto $ 2** $Id: lauxlib.c,v 1.248 2013/03/21 13:54:57 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*/
@@ -737,7 +737,17 @@ LUALIB_API int luaL_len (lua_State *L, int idx) {
737LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) { 737LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) {
738 if (!luaL_callmeta(L, idx, "__tostring")) { /* no metafield? */ 738 if (!luaL_callmeta(L, idx, "__tostring")) { /* no metafield? */
739 switch (lua_type(L, idx)) { 739 switch (lua_type(L, idx)) {
740 case LUA_TNUMBER: 740 case LUA_TNUMBER: {
741 if (lua_isinteger(L, idx)) {
742 lua_Integer n = lua_tointeger(L, idx);
743 lua_pushfstring(L, "%I", n);
744 }
745 else {
746 lua_Number n = lua_tonumber(L, idx);
747 lua_pushfstring(L, "%f", n);
748 }
749 break;
750 }
741 case LUA_TSTRING: 751 case LUA_TSTRING:
742 lua_pushvalue(L, idx); 752 lua_pushvalue(L, idx);
743 break; 753 break;