diff options
-rw-r--r-- | ltests.c | 43 |
1 files changed, 8 insertions, 35 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 1.129 2002/07/09 14:58:28 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 1.130 2002/07/17 16:25:13 roberto Exp roberto $ |
3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -172,7 +172,7 @@ void luaI_printcode (Proto *pt, int size) { | |||
172 | char buff[100]; | 172 | char buff[100]; |
173 | printf("%s\n", buildop(pt, pc, buff)); | 173 | printf("%s\n", buildop(pt, pc, buff)); |
174 | } | 174 | } |
175 | printf("-------\n"); | 175 | printf("-------\n"); |
176 | } | 176 | } |
177 | #endif | 177 | #endif |
178 | 178 | ||
@@ -299,9 +299,9 @@ static int table_query (lua_State *L) { | |||
299 | lua_pushnil(L); | 299 | lua_pushnil(L); |
300 | } | 300 | } |
301 | else if ((i -= t->sizearray) < sizenode(t)) { | 301 | else if ((i -= t->sizearray) < sizenode(t)) { |
302 | if (ttype(val(node(t, i))) != LUA_TNIL || | 302 | if (!ttisnil(val(node(t, i))) || |
303 | ttype(key(node(t, i))) == LUA_TNIL || | 303 | ttisnil(key(node(t, i))) || |
304 | ttype(key(node(t, i))) == LUA_TNUMBER) { | 304 | ttisnumber(key(node(t, i)))) { |
305 | luaA_pushobject(L, key(node(t, i))); | 305 | luaA_pushobject(L, key(node(t, i))); |
306 | } | 306 | } |
307 | else | 307 | else |
@@ -338,34 +338,6 @@ static int string_query (lua_State *L) { | |||
338 | } | 338 | } |
339 | 339 | ||
340 | 340 | ||
341 | static int xpcall (lua_State *L) { | ||
342 | int status; | ||
343 | luaL_check_type(L, 1, LUA_TFUNCTION); | ||
344 | luaL_check_any(L, 2); | ||
345 | lua_pushliteral(L, LUA_TRACEBACK); | ||
346 | lua_gettable(L, LUA_REGISTRYINDEX); | ||
347 | lua_pushliteral(L, LUA_TRACEBACK); | ||
348 | lua_pushvalue(L, 1); | ||
349 | lua_settable(L, LUA_REGISTRYINDEX); | ||
350 | lua_replace(L, 1); | ||
351 | status = lua_pcall(L, lua_gettop(L) - 2, LUA_MULTRET); | ||
352 | lua_pushliteral(L, LUA_TRACEBACK); | ||
353 | lua_pushvalue(L, 1); | ||
354 | lua_settable(L, LUA_REGISTRYINDEX); | ||
355 | if (status != 0) { | ||
356 | int numres = (status == LUA_ERRRUN) ? 3 : 2; | ||
357 | lua_pushnil(L); | ||
358 | lua_insert(L, -numres); | ||
359 | return numres; | ||
360 | } | ||
361 | else { | ||
362 | lua_pushboolean(L, 1); | ||
363 | lua_insert(L, 2); | ||
364 | return lua_gettop(L) - 1; /* return `true' + all results */ | ||
365 | } | ||
366 | } | ||
367 | |||
368 | |||
369 | static int tref (lua_State *L) { | 341 | static int tref (lua_State *L) { |
370 | int level = lua_gettop(L); | 342 | int level = lua_gettop(L); |
371 | int lock = luaL_opt_int(L, 2, 1); | 343 | int lock = luaL_opt_int(L, 2, 1); |
@@ -484,8 +456,10 @@ static int doremote (lua_State *L) { | |||
484 | int status; | 456 | int status; |
485 | lua_settop(L1, 0); | 457 | lua_settop(L1, 0); |
486 | status = luaL_loadbuffer(L1, code, lcode, code); | 458 | status = luaL_loadbuffer(L1, code, lcode, code); |
487 | if (status == 0) | 459 | if (status == 0) { |
488 | status = lua_pcall(L1, 0, LUA_MULTRET); | 460 | status = lua_pcall(L1, 0, LUA_MULTRET); |
461 | if (status != 0) lua_pcallreset(L1); | ||
462 | } | ||
489 | if (status != 0) { | 463 | if (status != 0) { |
490 | lua_pushnil(L); | 464 | lua_pushnil(L); |
491 | lua_pushnumber(L, status); | 465 | lua_pushnumber(L, status); |
@@ -711,7 +685,6 @@ static const struct luaL_reg tests_funcs[] = { | |||
711 | {"loadlib", loadlib}, | 685 | {"loadlib", loadlib}, |
712 | {"stacklevel", stacklevel}, | 686 | {"stacklevel", stacklevel}, |
713 | {"querystr", string_query}, | 687 | {"querystr", string_query}, |
714 | {"xpcall", xpcall}, | ||
715 | {"querytab", table_query}, | 688 | {"querytab", table_query}, |
716 | {"testC", testC}, | 689 | {"testC", testC}, |
717 | {"ref", tref}, | 690 | {"ref", tref}, |