** changes the environment variable of calling function */
| 544 | ** changes the environment variable of calling function |
| 545 | */ |
| 546 | static void set_env (lua_State *L) { |
| 547 | lua_Debug ar; |
| 548 | if (lua_getstack(L, 1, &ar) == 0 || |
| 549 | lua_getinfo(L, "f", &ar) == 0 || /* get calling function */ |
| 550 | lua_iscfunction(L, -1)) |
| 551 | luaL_error(L, LUA_QL("module") " not called from a Lua function"); |
| 552 | lua_pushvalue(L, -2); /* copy new environment table to top */ |
| 553 | lua_setupvalue(L, -2, 1); |
| 554 | lua_pop(L, 1); /* remove function */ |
| 555 | } |
| 556 | |
| 557 | |
| 558 | static void dooptions (lua_State *L, int n) { |
no test coverage detected