From 0c5ac77c9949ecfe83537ebe2de355a5286ce6ae Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 11 Nov 1994 12:00:08 -0200 Subject: small corrections to avoid 'warings' with acc. do_call was moving results in the wrong order. --- opcode.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/opcode.c b/opcode.c index d967c2cc..6625f51e 100644 --- a/opcode.c +++ b/opcode.c @@ -3,7 +3,7 @@ ** TecCGraf - PUC-Rio */ -char *rcs_opcode="$Id: opcode.c,v 3.8 1994/11/10 17:11:52 roberto Exp roberto $"; +char *rcs_opcode="$Id: opcode.c,v 3.9 1994/11/10 17:36:54 roberto Exp roberto $"; #include #include @@ -101,7 +101,7 @@ static void lua_initstack (void) */ static void lua_checkstack (Word n) { - if (n > maxstack) + if ((Long)n > maxstack) { int t; if (stack == NULL) @@ -186,16 +186,17 @@ static int lua_tostring (Object *obj) /* ** Adjust stack. Set top to the given value, pushing NILs if needed. */ -static void adjust_top (Object *newtop) +static void adjust_top (int newtop) { - while (top < newtop) tag(top++) = LUA_T_NIL; - top = newtop; /* top could be bigger than newtop */ + Object *nt = stack+newtop; + while (top < nt) tag(top++) = LUA_T_NIL; + top = nt; /* top could be bigger than newtop */ } static void adjustC (int nParams) { - adjust_top(stack+CBase+nParams); + adjust_top(CBase+nParams); } @@ -240,14 +241,15 @@ static void do_call (Object *func, int base, int nResults, int whereRes) } /* adjust the number of results */ if (nResults != MULT_RET && top - (stack+firstResult) != nResults) - adjust_top(stack+firstResult+nResults); + adjust_top(firstResult+nResults); /* move results to the given position */ if (firstResult != whereRes) { - int i = top - (stack+firstResult); /* number of results */ - top -= firstResult-whereRes; - while (i--) + int i; + nResults = top - (stack+firstResult); /* actual number of results */ + for (i=0; i