aboutsummaryrefslogtreecommitdiff
path: root/linit.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-05-20 09:57:59 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-05-20 09:57:59 -0300
commite34d3c06b069e36189c334d8bfbcf5c978e994c5 (patch)
tree3a7ffdaf27346ec30acc985c6cc839832a08c7d9 /linit.c
parente8a2c3690940016f0c7050f441b1e78b1bc6d78a (diff)
downloadlua-e34d3c06b069e36189c334d8bfbcf5c978e994c5.tar.gz
lua-e34d3c06b069e36189c334d8bfbcf5c978e994c5.tar.bz2
lua-e34d3c06b069e36189c334d8bfbcf5c978e994c5.zip
it is better to call open functions with lua_call to not mess
the caller stack
Diffstat (limited to 'linit.c')
-rw-r--r--linit.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/linit.c b/linit.c
index 79dec99f..2e9fb0b9 100644
--- a/linit.c
+++ b/linit.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: linit.c,v 1.23 2009/12/22 15:32:50 roberto Exp roberto $ 2** $Id: linit.c,v 1.24 2010/03/26 20:58:11 roberto Exp roberto $
3** Initialization of libraries for lua.c and other clients 3** Initialization of libraries for lua.c and other clients
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -52,9 +52,9 @@ LUALIB_API void luaL_openlibs (lua_State *L) {
52 const luaL_Reg *lib; 52 const luaL_Reg *lib;
53 /* call open functions from 'loadedlibs' */ 53 /* call open functions from 'loadedlibs' */
54 for (lib = loadedlibs; lib->func; lib++) { 54 for (lib = loadedlibs; lib->func; lib++) {
55 lua_settop(L, 0); 55 lua_pushcfunction(L, lib->func);
56 lua_pushstring(L, lib->name); 56 lua_pushstring(L, lib->name);
57 (lib->func)(L); 57 lua_call(L, 1, 0);
58 } 58 }
59 /* add open functions from 'preloadedlibs' into 'package.preload' table */ 59 /* add open functions from 'preloadedlibs' into 'package.preload' table */
60 lua_pushglobaltable(L); 60 lua_pushglobaltable(L);