diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-08-06 12:32:22 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-08-06 12:32:22 -0300 |
commit | a2fa48a570b01b2a2cd37f01799f08f693fc5892 (patch) | |
tree | b41fc7e88f7f941ae1589921f8d7c0ff57146f4d /lapi.c | |
parent | 8b2b8790b5c419282f4fa0c7faa168379647b3b9 (diff) | |
download | lua-a2fa48a570b01b2a2cd37f01799f08f693fc5892.tar.gz lua-a2fa48a570b01b2a2cd37f01799f08f693fc5892.tar.bz2 lua-a2fa48a570b01b2a2cd37f01799f08f693fc5892.zip |
new (old?) error handling scheme
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 15 |
1 files changed, 5 insertions, 10 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 1.205 2002/07/17 16:25:13 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.206 2002/08/05 14:43:38 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -610,22 +610,17 @@ LUA_API void lua_call (lua_State *L, int nargs, int nresults) { | |||
610 | } | 610 | } |
611 | 611 | ||
612 | 612 | ||
613 | LUA_API int lua_pcall (lua_State *L, int nargs, int nresults) { | 613 | LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) { |
614 | int status; | 614 | int status; |
615 | ptrdiff_t func; | ||
615 | lua_lock(L); | 616 | lua_lock(L); |
616 | status = luaD_pcall(L, nargs, nresults); | 617 | func = (errfunc == 0) ? 0 : savestack(L, luaA_index(L, errfunc)); |
618 | status = luaD_pcall(L, nargs, nresults, func); | ||
617 | lua_unlock(L); | 619 | lua_unlock(L); |
618 | return status; | 620 | return status; |
619 | } | 621 | } |
620 | 622 | ||
621 | 623 | ||
622 | LUA_API void lua_pcallreset (lua_State *L) { | ||
623 | lua_lock(L); | ||
624 | luaD_resetprotection(L); /* reset error handler */ | ||
625 | lua_unlock(L); | ||
626 | } | ||
627 | |||
628 | |||
629 | LUA_API int lua_load (lua_State *L, lua_Chunkreader reader, void *data, | 624 | LUA_API int lua_load (lua_State *L, lua_Chunkreader reader, void *data, |
630 | const char *chunkname) { | 625 | const char *chunkname) { |
631 | ZIO z; | 626 | ZIO z; |