aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lbaselib.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/lbaselib.c b/lbaselib.c
index 0599d08b..93ddc2ac 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.21 2001/02/02 19:02:40 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.22 2001/02/06 13:59:29 roberto Exp roberto $
3** Basic library 3** Basic library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -345,14 +345,19 @@ static int luaB_tostring (lua_State *L) {
345 lua_pushvalue(L, 1); 345 lua_pushvalue(L, 1);
346 return 1; 346 return 1;
347 case LUA_TTABLE: 347 case LUA_TTABLE:
348 sprintf(buff, "table: %p", lua_topointer(L, 1)); 348 sprintf(buff, "%.40s: %p", lua_xtype(L, 1), lua_topointer(L, 1));
349 break; 349 break;
350 case LUA_TFUNCTION: 350 case LUA_TFUNCTION:
351 sprintf(buff, "function: %p", lua_topointer(L, 1)); 351 sprintf(buff, "function: %p", lua_topointer(L, 1));
352 break; 352 break;
353 case LUA_TUSERDATA: 353 case LUA_TUSERDATA: {
354 sprintf(buff, "userdata(%d): %p", lua_tag(L, 1), lua_touserdata(L, 1)); 354 const char *t = lua_xtype(L, 1);
355 if (strcmp(t, "userdata") == 0)
356 sprintf(buff, "userdata(%d): %p", lua_tag(L, 1), lua_touserdata(L, 1));
357 else
358 sprintf(buff, "%.40s: %p", t, lua_touserdata(L, 1));
355 break; 359 break;
360 }
356 case LUA_TNIL: 361 case LUA_TNIL:
357 lua_pushliteral(L, "nil"); 362 lua_pushliteral(L, "nil");
358 return 1; 363 return 1;