diff options
| -rw-r--r-- | lauxlib.c | 10 | ||||
| -rw-r--r-- | ldo.c | 2 | ||||
| -rw-r--r-- | liolib.c | 2 | ||||
| -rw-r--r-- | ltablib.c | 2 | ||||
| -rw-r--r-- | ltests.c | 8 |
5 files changed, 13 insertions, 11 deletions
| @@ -898,9 +898,13 @@ LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) { | |||
| 898 | luaL_checkstack(L, nup, "too many upvalues"); | 898 | luaL_checkstack(L, nup, "too many upvalues"); |
| 899 | for (; l->name != NULL; l++) { /* fill the table with given functions */ | 899 | for (; l->name != NULL; l++) { /* fill the table with given functions */ |
| 900 | int i; | 900 | int i; |
| 901 | for (i = 0; i < nup; i++) /* copy upvalues to the top */ | 901 | if (l->func == NULL) /* place holder? */ |
| 902 | lua_pushvalue(L, -nup); | 902 | lua_pushboolean(L, 0); |
| 903 | lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */ | 903 | else { |
| 904 | for (i = 0; i < nup; i++) /* copy upvalues to the top */ | ||
| 905 | lua_pushvalue(L, -nup); | ||
| 906 | lua_pushcclosure(L, l->func, nup); /* closure with those upvalues */ | ||
| 907 | } | ||
| 904 | lua_setfield(L, -(nup + 2), l->name); | 908 | lua_setfield(L, -(nup + 2), l->name); |
| 905 | } | 909 | } |
| 906 | lua_pop(L, nup); /* remove upvalues */ | 910 | lua_pop(L, nup); /* remove upvalues */ |
| @@ -669,7 +669,7 @@ LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs, | |||
| 669 | else if (L->top - (L->ci->func + 1) == nargs) /* no function? */ | 669 | else if (L->top - (L->ci->func + 1) == nargs) /* no function? */ |
| 670 | return resume_error(L, "cannot resume dead coroutine", nargs); | 670 | return resume_error(L, "cannot resume dead coroutine", nargs); |
| 671 | } | 671 | } |
| 672 | else if (L->status != LUA_YIELD) | 672 | else if (L->status != LUA_YIELD) /* ended with errors? */ |
| 673 | return resume_error(L, "cannot resume dead coroutine", nargs); | 673 | return resume_error(L, "cannot resume dead coroutine", nargs); |
| 674 | if (from == NULL) | 674 | if (from == NULL) |
| 675 | L->nCcalls = 1; | 675 | L->nCcalls = 1; |
| @@ -39,7 +39,7 @@ | |||
| 39 | /* Check whether 'mode' matches '[rwa]%+?[L_MODEEXT]*' */ | 39 | /* Check whether 'mode' matches '[rwa]%+?[L_MODEEXT]*' */ |
| 40 | static int l_checkmode (const char *mode) { | 40 | static int l_checkmode (const char *mode) { |
| 41 | return (*mode != '\0' && strchr("rwa", *(mode++)) != NULL && | 41 | return (*mode != '\0' && strchr("rwa", *(mode++)) != NULL && |
| 42 | (*mode != '+' || (++mode, 1)) && /* skip if char is '+' */ | 42 | (*mode != '+' || ((void)(++mode), 1)) && /* skip if char is '+' */ |
| 43 | (strspn(mode, L_MODEEXT) == strlen(mode))); /* check extensions */ | 43 | (strspn(mode, L_MODEEXT) == strlen(mode))); /* check extensions */ |
| 44 | } | 44 | } |
| 45 | 45 | ||
| @@ -299,7 +299,7 @@ static IdxT partition (lua_State *L, IdxT lo, IdxT up) { | |||
| 299 | /* loop invariant: a[lo .. i] <= P <= a[j .. up] */ | 299 | /* loop invariant: a[lo .. i] <= P <= a[j .. up] */ |
| 300 | for (;;) { | 300 | for (;;) { |
| 301 | /* next loop: repeat ++i while a[i] < P */ | 301 | /* next loop: repeat ++i while a[i] < P */ |
| 302 | while (lua_geti(L, 1, ++i), sort_comp(L, -1, -2)) { | 302 | while ((void)lua_geti(L, 1, ++i), sort_comp(L, -1, -2)) { |
| 303 | if (i == up - 1) /* a[i] < P but a[up - 1] == P ?? */ | 303 | if (i == up - 1) /* a[i] < P but a[up - 1] == P ?? */ |
| 304 | luaL_error(L, "invalid order function for sorting"); | 304 | luaL_error(L, "invalid order function for sorting"); |
| 305 | lua_pop(L, 1); /* remove a[i] */ | 305 | lua_pop(L, 1); /* remove a[i] */ |
| @@ -51,9 +51,8 @@ static int runC (lua_State *L, lua_State *L1, const char *pc); | |||
| 51 | 51 | ||
| 52 | 52 | ||
| 53 | static void setnameval (lua_State *L, const char *name, int val) { | 53 | static void setnameval (lua_State *L, const char *name, int val) { |
| 54 | lua_pushstring(L, name); | ||
| 55 | lua_pushinteger(L, val); | 54 | lua_pushinteger(L, val); |
| 56 | lua_settable(L, -3); | 55 | lua_setfield(L, -2, name); |
| 57 | } | 56 | } |
| 58 | 57 | ||
| 59 | 58 | ||
| @@ -710,12 +709,11 @@ static void printstack (lua_State *L) { | |||
| 710 | 709 | ||
| 711 | 710 | ||
| 712 | static int get_limits (lua_State *L) { | 711 | static int get_limits (lua_State *L) { |
| 713 | lua_createtable(L, 0, 5); | 712 | lua_createtable(L, 0, 6); |
| 714 | setnameval(L, "BITS_INT", LUAI_BITSINT); | 713 | setnameval(L, "IS32INT", LUAI_IS32INT); |
| 715 | setnameval(L, "MAXARG_Ax", MAXARG_Ax); | 714 | setnameval(L, "MAXARG_Ax", MAXARG_Ax); |
| 716 | setnameval(L, "MAXARG_Bx", MAXARG_Bx); | 715 | setnameval(L, "MAXARG_Bx", MAXARG_Bx); |
| 717 | setnameval(L, "OFFSET_sBx", OFFSET_sBx); | 716 | setnameval(L, "OFFSET_sBx", OFFSET_sBx); |
| 718 | setnameval(L, "BITS_INT", LUAI_BITSINT); | ||
| 719 | setnameval(L, "LFPF", LFIELDS_PER_FLUSH); | 717 | setnameval(L, "LFPF", LFIELDS_PER_FLUSH); |
| 720 | setnameval(L, "NUM_OPCODES", NUM_OPCODES); | 718 | setnameval(L, "NUM_OPCODES", NUM_OPCODES); |
| 721 | return 1; | 719 | return 1; |
