aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2004-06-08 11:31:00 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2004-06-08 11:31:00 -0300
commit75057dfcedf9fb99660eed490c399ab3143e62c1 (patch)
tree025379c1fdd51f6c556657f9e7b7535a5e4a19e9
parent345379b5ff7ce6f5a732a6954bfb5e83bce12036 (diff)
downloadlua-75057dfcedf9fb99660eed490c399ab3143e62c1.tar.gz
lua-75057dfcedf9fb99660eed490c399ab3143e62c1.tar.bz2
lua-75057dfcedf9fb99660eed490c399ab3143e62c1.zip
-rw-r--r--lapi.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/lapi.c b/lapi.c
index f5b080fa..a7b3678d 100644
--- a/lapi.c
+++ b/lapi.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lapi.c,v 2.10 2004/05/31 19:41:52 roberto Exp roberto $ 2** $Id: lapi.c,v 2.11 2004/06/04 15:30:53 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*/
@@ -697,10 +697,15 @@ LUA_API int lua_setfenv (lua_State *L, int idx) {
697 { if (nres == LUA_MULTRET && L->top >= L->ci->top) L->ci->top = L->top; } 697 { if (nres == LUA_MULTRET && L->top >= L->ci->top) L->ci->top = L->top; }
698 698
699 699
700#define checkresults(L,na,nr) \
701 api_check(L, (nr) == LUA_MULTRET || (L->ci->top - L->top >= (nr) - (na)))
702
703
700LUA_API void lua_call (lua_State *L, int nargs, int nresults) { 704LUA_API void lua_call (lua_State *L, int nargs, int nresults) {
701 StkId func; 705 StkId func;
702 lua_lock(L); 706 lua_lock(L);
703 api_checknelems(L, nargs+1); 707 api_checknelems(L, nargs+1);
708 checkresults(L, nargs, nresults);
704 func = L->top - (nargs+1); 709 func = L->top - (nargs+1);
705 luaD_call(L, func, nresults); 710 luaD_call(L, func, nresults);
706 adjustresults(L, nresults); 711 adjustresults(L, nresults);
@@ -730,6 +735,8 @@ LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfunc) {
730 int status; 735 int status;
731 ptrdiff_t func; 736 ptrdiff_t func;
732 lua_lock(L); 737 lua_lock(L);
738 api_checknelems(L, nargs+1);
739 checkresults(L, nargs, nresults);
733 if (errfunc == 0) 740 if (errfunc == 0)
734 func = 0; 741 func = 0;
735 else { 742 else {