aboutsummaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
Diffstat (limited to 'ldo.c')
-rw-r--r--ldo.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/ldo.c b/ldo.c
index bd8d965f..e9f91384 100644
--- a/ldo.c
+++ b/ldo.c
@@ -391,7 +391,7 @@ static void rethook (lua_State *L, CallInfo *ci, int nres) {
391 int ftransfer; 391 int ftransfer;
392 if (isLua(ci)) { 392 if (isLua(ci)) {
393 Proto *p = ci_func(ci)->p; 393 Proto *p = ci_func(ci)->p;
394 if (p->is_vararg) 394 if (p->flag & PF_ISVARARG)
395 delta = ci->u.l.nextraargs + p->numparams + 1; 395 delta = ci->u.l.nextraargs + p->numparams + 1;
396 } 396 }
397 ci->func.p += delta; /* if vararg, back to virtual 'func' */ 397 ci->func.p += delta; /* if vararg, back to virtual 'func' */
@@ -412,7 +412,7 @@ static void rethook (lua_State *L, CallInfo *ci, int nres) {
412static StkId tryfuncTM (lua_State *L, StkId func) { 412static StkId tryfuncTM (lua_State *L, StkId func) {
413 const TValue *tm; 413 const TValue *tm;
414 StkId p; 414 StkId p;
415 checkstackGCp(L, 1, func); /* space for metamethod */ 415 checkstackp(L, 1, func); /* space for metamethod */
416 tm = luaT_gettmbyobj(L, s2v(func), TM_CALL); /* (after previous GC) */ 416 tm = luaT_gettmbyobj(L, s2v(func), TM_CALL); /* (after previous GC) */
417 if (l_unlikely(ttisnil(tm))) 417 if (l_unlikely(ttisnil(tm)))
418 luaG_callerror(L, s2v(func)); /* nothing to call */ 418 luaG_callerror(L, s2v(func)); /* nothing to call */
@@ -517,7 +517,7 @@ l_sinline int precallC (lua_State *L, StkId func, int nresults,
517 lua_CFunction f) { 517 lua_CFunction f) {
518 int n; /* number of returns */ 518 int n; /* number of returns */
519 CallInfo *ci; 519 CallInfo *ci;
520 checkstackGCp(L, LUA_MINSTACK, func); /* ensure minimum stack size */ 520 checkstackp(L, LUA_MINSTACK, func); /* ensure minimum stack size */
521 L->ci = ci = prepCallInfo(L, func, nresults, CIST_C, 521 L->ci = ci = prepCallInfo(L, func, nresults, CIST_C,
522 L->top.p + LUA_MINSTACK); 522 L->top.p + LUA_MINSTACK);
523 lua_assert(ci->top.p <= L->stack_last.p); 523 lua_assert(ci->top.p <= L->stack_last.p);
@@ -553,7 +553,7 @@ int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func,
553 int fsize = p->maxstacksize; /* frame size */ 553 int fsize = p->maxstacksize; /* frame size */
554 int nfixparams = p->numparams; 554 int nfixparams = p->numparams;
555 int i; 555 int i;
556 checkstackGCp(L, fsize - delta, func); 556 checkstackp(L, fsize - delta, func);
557 ci->func.p -= delta; /* restore 'func' (if vararg) */ 557 ci->func.p -= delta; /* restore 'func' (if vararg) */
558 for (i = 0; i < narg1; i++) /* move down function and arguments */ 558 for (i = 0; i < narg1; i++) /* move down function and arguments */
559 setobjs2s(L, ci->func.p + i, func + i); 559 setobjs2s(L, ci->func.p + i, func + i);
@@ -600,7 +600,7 @@ CallInfo *luaD_precall (lua_State *L, StkId func, int nresults) {
600 int narg = cast_int(L->top.p - func) - 1; /* number of real arguments */ 600 int narg = cast_int(L->top.p - func) - 1; /* number of real arguments */
601 int nfixparams = p->numparams; 601 int nfixparams = p->numparams;
602 int fsize = p->maxstacksize; /* frame size */ 602 int fsize = p->maxstacksize; /* frame size */
603 checkstackGCp(L, fsize, func); 603 checkstackp(L, fsize, func);
604 L->ci = ci = prepCallInfo(L, func, nresults, 0, func + 1 + fsize); 604 L->ci = ci = prepCallInfo(L, func, nresults, 0, func + 1 + fsize);
605 ci->u.l.savedpc = p->code; /* starting point */ 605 ci->u.l.savedpc = p->code; /* starting point */
606 for (; narg < nfixparams; narg++) 606 for (; narg < nfixparams; narg++)
@@ -977,7 +977,7 @@ struct SParser { /* data to 'f_parser' */
977 977
978 978
979static void checkmode (lua_State *L, const char *mode, const char *x) { 979static void checkmode (lua_State *L, const char *mode, const char *x) {
980 if (mode && strchr(mode, x[0]) == NULL) { 980 if (strchr(mode, x[0]) == NULL) {
981 luaO_pushfstring(L, 981 luaO_pushfstring(L,
982 "attempt to load a %s chunk (mode is '%s')", x, mode); 982 "attempt to load a %s chunk (mode is '%s')", x, mode);
983 luaD_throw(L, LUA_ERRSYNTAX); 983 luaD_throw(L, LUA_ERRSYNTAX);
@@ -988,13 +988,18 @@ static void checkmode (lua_State *L, const char *mode, const char *x) {
988static void f_parser (lua_State *L, void *ud) { 988static void f_parser (lua_State *L, void *ud) {
989 LClosure *cl; 989 LClosure *cl;
990 struct SParser *p = cast(struct SParser *, ud); 990 struct SParser *p = cast(struct SParser *, ud);
991 const char *mode = p->mode ? p->mode : "bt";
991 int c = zgetc(p->z); /* read first character */ 992 int c = zgetc(p->z); /* read first character */
992 if (c == LUA_SIGNATURE[0]) { 993 if (c == LUA_SIGNATURE[0]) {
993 checkmode(L, p->mode, "binary"); 994 int fixed = 0;
994 cl = luaU_undump(L, p->z, p->name); 995 if (strchr(mode, 'B') != NULL)
996 fixed = 1;
997 else
998 checkmode(L, mode, "binary");
999 cl = luaU_undump(L, p->z, p->name, fixed);
995 } 1000 }
996 else { 1001 else {
997 checkmode(L, p->mode, "text"); 1002 checkmode(L, mode, "text");
998 cl = luaY_parser(L, p->z, &p->buff, &p->dyd, p->name, c); 1003 cl = luaY_parser(L, p->z, &p->buff, &p->dyd, p->name, c);
999 } 1004 }
1000 lua_assert(cl->nupvalues == cl->p->sizeupvalues); 1005 lua_assert(cl->nupvalues == cl->p->sizeupvalues);