diff options
Diffstat (limited to 'lauxlib.c')
-rw-r--r-- | lauxlib.c | 10 |
1 files changed, 7 insertions, 3 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 */ |