diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-02-18 13:02:13 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-02-18 13:02:13 -0300 |
| commit | 07948c3181702c55b7b36069ca519b54371a4ab7 (patch) | |
| tree | dd7ac524bfb0a8e3a1f9ae7c98fce86ef9b2c8ad | |
| parent | dce9a49a086189c8fe1a3a1098dcde4871a7036d (diff) | |
| download | lua-07948c3181702c55b7b36069ca519b54371a4ab7.tar.gz lua-07948c3181702c55b7b36069ca519b54371a4ab7.tar.bz2 lua-07948c3181702c55b7b36069ca519b54371a4ab7.zip | |
restore _REQUIREDNAME after requiring a file
| -rw-r--r-- | lbaselib.c | 9 |
1 files changed, 5 insertions, 4 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lbaselib.c,v 1.118 2003/02/12 09:11:01 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.119 2003/02/13 16:07:37 roberto Exp roberto $ |
| 3 | ** Basic library | 3 | ** Basic library |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -466,11 +466,12 @@ static int luaB_require (lua_State *L) { | |||
| 466 | } | 466 | } |
| 467 | switch (status) { | 467 | switch (status) { |
| 468 | case 0: { | 468 | case 0: { |
| 469 | lua_getglobal(L, "_REQUIREDNAME"); /* save previous name */ | ||
| 470 | lua_insert(L, -2); /* put it below function */ | ||
| 469 | lua_pushvalue(L, 1); | 471 | lua_pushvalue(L, 1); |
| 470 | lua_setglobal(L, "_REQUIREDNAME"); | 472 | lua_setglobal(L, "_REQUIREDNAME"); /* set new name */ |
| 471 | lua_call(L, 0, 0); /* run loaded module */ | 473 | lua_call(L, 0, 0); /* run loaded module */ |
| 472 | lua_pushnil(L); | 474 | lua_setglobal(L, "_REQUIREDNAME"); /* reset to previous name */ |
| 473 | lua_setglobal(L, "_REQUIREDNAME"); /* reset */ | ||
| 474 | lua_pushvalue(L, 1); | 475 | lua_pushvalue(L, 1); |
| 475 | lua_pushboolean(L, 1); | 476 | lua_pushboolean(L, 1); |
| 476 | lua_rawset(L, 2); /* mark it as loaded */ | 477 | lua_rawset(L, 2); /* mark it as loaded */ |
