summaryrefslogtreecommitdiff
path: root/lib/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lib/lua')
-rw-r--r--lib/lua/src/lvm.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/lua/src/lvm.c b/lib/lua/src/lvm.c
index 7334edc..5c6620a 100644
--- a/lib/lua/src/lvm.c
+++ b/lib/lua/src/lvm.c
@@ -1,5 +1,5 @@
/*
-** $Id: lvm.c,v 1.8 2005-02-12 22:57:53 pixel Exp $
+** $Id: lvm.c,v 1.9 2006-02-09 16:57:30 pixel Exp $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -53,6 +53,7 @@ const TObject *luaV_tonumber (const TObject *obj, TObject *n) {
int luaV_tostring (lua_State *L, StkId obj) {
+#if 0
if (!ttisnumber(obj))
return 0;
else {
@@ -61,6 +62,25 @@ int luaV_tostring (lua_State *L, StkId obj) {
setsvalue2s(obj, luaS_new(L, s));
return 1;
}
+#else
+ if (ttisnumber(obj)) {
+ char s[32]; /* 16 digits, sign, point and \0 (+ some extra...) */
+ lua_number2str(s, nvalue(obj));
+ setsvalue2s(obj, luaS_new(L, s));
+ return 1;
+ } else if (ttisboolean(obj)) {
+ if (bvalue(obj))
+ setsvalue2s(obj, luaS_new(L, "(true)"))
+ else
+ setsvalue2s(obj, luaS_new(L, "(false)"));
+ return 1;
+ } else if (ttisnil(obj)) {
+ setsvalue(obj, luaS_new(L, "(nil)"));
+ return 1;
+ } else {
+ return 0;
+ }
+#endif
}