diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-04-19 15:29:41 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2011-04-19 15:29:41 -0300 |
commit | 2f128c5130b962bc691aa1f7eaf5882b3e826c23 (patch) | |
tree | 7fc1a5f46ed35b761ed5be40ba0791b6aab42b94 /lauxlib.c | |
parent | 4758113043b6c362a0fdce77715c711332d909dc (diff) | |
download | lua-2f128c5130b962bc691aa1f7eaf5882b3e826c23.tar.gz lua-2f128c5130b962bc691aa1f7eaf5882b3e826c23.tar.bz2 lua-2f128c5130b962bc691aa1f7eaf5882b3e826c23.zip |
'luaL_setfuncs' does not need to accept a NULL list. (If there is
no list, there is no reason to call this function.)
Diffstat (limited to 'lauxlib.c')
-rw-r--r-- | lauxlib.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.229 2011/03/03 16:34:46 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.230 2011/04/08 19:17:36 roberto Exp roberto $ |
3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -825,7 +825,10 @@ LUALIB_API void luaL_openlib (lua_State *L, const char *libname, | |||
825 | luaL_pushmodule(L, libname, libsize(l)); /* get/create library table */ | 825 | luaL_pushmodule(L, libname, libsize(l)); /* get/create library table */ |
826 | lua_insert(L, -(nup + 1)); /* move library table to below upvalues */ | 826 | lua_insert(L, -(nup + 1)); /* move library table to below upvalues */ |
827 | } | 827 | } |
828 | luaL_setfuncs(L, l, nup); | 828 | if (l) |
829 | luaL_setfuncs(L, l, nup); | ||
830 | else | ||
831 | lua_pop(L, nup); /* remove upvalues */ | ||
829 | } | 832 | } |
830 | 833 | ||
831 | #endif | 834 | #endif |
@@ -838,7 +841,7 @@ LUALIB_API void luaL_openlib (lua_State *L, const char *libname, | |||
838 | */ | 841 | */ |
839 | LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) { | 842 | LUALIB_API void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup) { |
840 | luaL_checkstack(L, nup, "too many upvalues"); | 843 | luaL_checkstack(L, nup, "too many upvalues"); |
841 | for (; l && l->name; l++) { /* fill the table with given functions */ | 844 | for (; l->name != NULL; l++) { /* fill the table with given functions */ |
842 | int i; | 845 | int i; |
843 | for (i = 0; i < nup; i++) /* copy upvalues to the top */ | 846 | for (i = 0; i < nup; i++) /* copy upvalues to the top */ |
844 | lua_pushvalue(L, -nup); | 847 | lua_pushvalue(L, -nup); |