summaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-12-04 15:29:32 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-12-04 15:29:32 -0200
commit0bb8eb51517ef63c65fb986d711c3163ad0be38f (patch)
tree88c0badaddb58e14a6c4e795ab106f787f81843a /ldo.c
parent38da8c0d7d69da5eed2e98a0871b86113869b858 (diff)
downloadlua-github-0bb8eb51517ef63c65fb986d711c3163ad0be38f.tar.gz
new function `lua_cpcall'
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c31
1 files changed, 7 insertions, 24 deletions
diff --git a/ldo.c b/ldo.c
index cf2948c6..15afc6f1 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
/*
-** $Id: ldo.c,v 1.208 2002/11/22 17:16:52 roberto Exp roberto $
+** $Id: ldo.c,v 1.209 2002/11/22 18:01:46 roberto Exp roberto $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
@@ -378,35 +378,17 @@ LUA_API int lua_yield (lua_State *L, int nresults) {
}
-/*
-** Execute a protected call.
-*/
-struct CallS { /* data to `f_call' */
- StkId func;
- int nresults;
-};
-
-
-static void f_call (lua_State *L, void *ud) {
- struct CallS *c = cast(struct CallS *, ud);
- luaD_call(L, c->func, c->nresults);
-}
-
-
-int luaD_pcall (lua_State *L, int nargs, int nresults, ptrdiff_t errfunc) {
- struct CallS c;
+int luaD_pcall (lua_State *L, Pfunc func, void *u,
+ ptrdiff_t old_top, ptrdiff_t ef) {
int status;
unsigned short oldnCcalls = L->nCcalls;
- ptrdiff_t old_top = savestack(L, L->top);
ptrdiff_t old_ci = saveci(L, L->ci);
lu_byte old_allowhooks = L->allowhook;
ptrdiff_t old_errfunc = L->errfunc;
- L->errfunc = errfunc;
- c.func = L->top - (nargs+1); /* function to be called */
- c.nresults = nresults;
- status = luaD_rawrunprotected(L, &f_call, &c);
+ L->errfunc = ef;
+ status = luaD_rawrunprotected(L, func, u);
if (status != 0) { /* an error occurred? */
- StkId oldtop = restorestack(L, old_top) - (nargs+1);
+ StkId oldtop = restorestack(L, old_top);
luaF_close(L, oldtop); /* close eventual pending closures */
seterrorobj(L, status, oldtop);
L->nCcalls = oldnCcalls;
@@ -420,6 +402,7 @@ int luaD_pcall (lua_State *L, int nargs, int nresults, ptrdiff_t errfunc) {
}
+
/*
** Execute a protected parser.
*/