diff options
Diffstat (limited to 'lib/BLua.cc')
-rw-r--r-- | lib/BLua.cc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/BLua.cc b/lib/BLua.cc index 76a0c6d..1db9dda 100644 --- a/lib/BLua.cc +++ b/lib/BLua.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: BLua.cc,v 1.57 2008-01-23 17:53:12 pixel Exp $ */ +/* $Id: BLua.cc,v 1.58 2008-01-25 10:09:19 pixel Exp $ */ #include <stdlib.h> #include "BLua.h" @@ -789,14 +789,17 @@ lua_Number Lua::tonumber(int i) { String Lua::tostring(int i) { const char * r = 0; + size_t l = -1; if (isnil(i)) { - r = ""; + r = "(nil)"; } else if (isboolean(i)) { r = toboolean(i) ? "true" : "false"; + } else if (isnumber(i)) { + return String(tonumber(i)); } else { - r = lua_tostring(L, i); + r = lua_tolstring(L, i, &l); } - return String(r ? r : "<lua-NULL>"); + return String(r ? r : "<lua-NULL>", l); } lua_CFunction Lua::tocfunction(int i) { |