From e34d3c06b069e36189c334d8bfbcf5c978e994c5 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 20 May 2010 09:57:59 -0300 Subject: it is better to call open functions with lua_call to not mess the caller stack --- linit.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'linit.c') diff --git a/linit.c b/linit.c index 79dec99f..2e9fb0b9 100644 --- a/linit.c +++ b/linit.c @@ -1,5 +1,5 @@ /* -** $Id: linit.c,v 1.23 2009/12/22 15:32:50 roberto Exp roberto $ +** $Id: linit.c,v 1.24 2010/03/26 20:58:11 roberto Exp roberto $ ** Initialization of libraries for lua.c and other clients ** See Copyright Notice in lua.h */ @@ -52,9 +52,9 @@ LUALIB_API void luaL_openlibs (lua_State *L) { const luaL_Reg *lib; /* call open functions from 'loadedlibs' */ for (lib = loadedlibs; lib->func; lib++) { - lua_settop(L, 0); + lua_pushcfunction(L, lib->func); lua_pushstring(L, lib->name); - (lib->func)(L); + lua_call(L, 1, 0); } /* add open functions from 'preloadedlibs' into 'package.preload' table */ lua_pushglobaltable(L); -- cgit v1.2.3-55-g6feb