** changes the environment variable of calling function */
| 632 | ** changes the environment variable of calling function |
| 633 | */ |
| 634 | static void set_env (lua_State *L) { |
| 635 | lua_Debug ar; |
| 636 | if (lua_getstack(L, 1, &ar) == 0 || |
| 637 | lua_getinfo(L, "f", &ar) == 0 || /* get calling function */ |
| 638 | lua_iscfunction(L, -1)) |
| 639 | luaL_error(L, "'module' not called from a Lua function"); |
| 640 | lua_pushvalue(L, -2); /* copy new environment table to top */ |
| 641 | lua_setupvalue(L, -2, 1); |
| 642 | lua_pop(L, 1); /* remove function */ |
| 643 | } |
| 644 | |
| 645 | |
| 646 | static void dooptions (lua_State *L, int n) { |
no test coverage detected