From 88c9bf99de50df5575cce13e8e6c278b9f1dc0d0 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 20 Mar 2002 09:54:08 -0300 Subject: standard libraries in packages --- lauxlib.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'lauxlib.c') diff --git a/lauxlib.c b/lauxlib.c index ceef7026..db7ab9b3 100644 --- a/lauxlib.c +++ b/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.60 2002/02/14 21:41:53 roberto Exp roberto $ +** $Id: lauxlib.c,v 1.61 2002/03/07 18:15:10 roberto Exp roberto $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -116,10 +116,21 @@ LUALIB_API lua_Number luaL_opt_number (lua_State *L, int narg, lua_Number def) { } -LUALIB_API void luaL_openlib (lua_State *L, const luaL_reg *l, int n) { - int i; - for (i=0; iname; l++) { + lua_pushstring(L, l->name); + lua_pushcfunction(L, l->func); + lua_settable(L, -3); + } +} + + +LUALIB_API void luaL_opennamedlib (lua_State *L, const char *libname, + const luaL_reg *l) { + lua_pushstring(L, libname); + lua_newtable(L); + luaL_openlib(L, l); + lua_settable(L, LUA_GLOBALSINDEX); } -- cgit v1.2.3-55-g6feb