aboutsummaryrefslogtreecommitdiff
path: root/loadlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-01-11 15:06:31 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-01-11 15:06:31 -0200
commit692209fa8d2f9cb05d5b21860df4fd4eeb9622c4 (patch)
treeb3a24fc874d8083a09f2682d794b9c14a4b97b8e /loadlib.c
parent953d499ea25b95560dc53e97bcbdc2dab40d1dbf (diff)
downloadlua-692209fa8d2f9cb05d5b21860df4fd4eeb9622c4.tar.gz
lua-692209fa8d2f9cb05d5b21860df4fd4eeb9622c4.tar.bz2
lua-692209fa8d2f9cb05d5b21860df4fd4eeb9622c4.zip
Dynamic C functions should be created with the global table as their
initial environments
Diffstat (limited to 'loadlib.c')
-rw-r--r--loadlib.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/loadlib.c b/loadlib.c
index d9af503a..7bf6b503 100644
--- a/loadlib.c
+++ b/loadlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: loadlib.c,v 1.73 2010/01/06 14:35:17 roberto Exp roberto $ 2** $Id: loadlib.c,v 1.74 2010/01/11 16:10:47 roberto Exp roberto $
3** Dynamic library loader for Lua 3** Dynamic library loader for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5** 5**
@@ -344,7 +344,9 @@ static int ll_loadfunc (lua_State *L, const char *path, const char *sym) {
344 lua_CFunction f = ll_sym(L, *reg, sym); 344 lua_CFunction f = ll_sym(L, *reg, sym);
345 if (f == NULL) 345 if (f == NULL)
346 return ERRFUNC; /* unable to find function */ 346 return ERRFUNC; /* unable to find function */
347 lua_pushcfunction(L, f); /* else return function */ 347 lua_pushcfunction(L, f); /* else create new function... */
348 lua_pushglobaltable(L); /* ... and set the standard global table... */
349 lua_setfenv(L, -2); /* ... as its environment */
348 return 0; /* no errors */ 350 return 0; /* no errors */
349 } 351 }
350} 352}