diff options
| -rw-r--r-- | lstate.c | 7 |
1 files changed, 5 insertions, 2 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstate.c,v 2.59 2009/09/21 12:09:52 roberto Exp roberto $ | 2 | ** $Id: lstate.c,v 2.60 2009/09/28 13:50:19 roberto Exp roberto $ |
| 3 | ** Global State | 3 | ** Global State |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -98,7 +98,10 @@ static void freestack (lua_State *L) { | |||
| 98 | */ | 98 | */ |
| 99 | static int cpcall (lua_State *L) { | 99 | static int cpcall (lua_State *L) { |
| 100 | lua_CFunction f = *(lua_CFunction *)lua_touserdata(L, 1); | 100 | lua_CFunction f = *(lua_CFunction *)lua_touserdata(L, 1); |
| 101 | lua_remove(L, 1); | 101 | lua_remove(L, 1); /* remove f from stack */ |
| 102 | /* restore original environment for 'cpcall' */ | ||
| 103 | lua_pushvalue(L, LUA_GLOBALSINDEX); | ||
| 104 | lua_replace(L, LUA_ENVIRONINDEX); | ||
| 102 | return f(L); | 105 | return f(L); |
| 103 | } | 106 | } |
| 104 | 107 | ||
