diff options
| -rw-r--r-- | lbaselib.c | 13 |
1 files changed, 8 insertions, 5 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lbaselib.c,v 1.193 2006/10/10 17:40:17 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.194 2006/10/20 19:30:53 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 | */ |
| @@ -381,10 +381,13 @@ static int luaB_pcall (lua_State *L) { | |||
| 381 | 381 | ||
| 382 | static int luaB_xpcall (lua_State *L) { | 382 | static int luaB_xpcall (lua_State *L) { |
| 383 | int status; | 383 | int status; |
| 384 | luaL_checkany(L, 2); | 384 | int n = lua_gettop(L); |
| 385 | lua_settop(L, 2); | 385 | luaL_argcheck(L, n >= 2, 2, "value expected"); |
| 386 | lua_insert(L, 1); /* put error function under function to be called */ | 386 | lua_pushvalue(L, 1); /* exchange function... */ |
| 387 | status = lua_pcall(L, 0, LUA_MULTRET, 1); | 387 | lua_pushvalue(L, 2); /* ...and error handler */ |
| 388 | lua_replace(L, 1); | ||
| 389 | lua_replace(L, 2); | ||
| 390 | status = lua_pcall(L, n - 2, LUA_MULTRET, 1); | ||
| 388 | lua_pushboolean(L, (status == LUA_OK)); | 391 | lua_pushboolean(L, (status == LUA_OK)); |
| 389 | lua_replace(L, 1); | 392 | lua_replace(L, 1); |
| 390 | return lua_gettop(L); /* return status + all results */ | 393 | return lua_gettop(L); /* return status + all results */ |
