diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-01-11 15:06:31 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-01-11 15:06:31 -0200 |
commit | 692209fa8d2f9cb05d5b21860df4fd4eeb9622c4 (patch) | |
tree | b3a24fc874d8083a09f2682d794b9c14a4b97b8e /loadlib.c | |
parent | 953d499ea25b95560dc53e97bcbdc2dab40d1dbf (diff) | |
download | lua-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.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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 | } |