diff options
Diffstat (limited to 'src/state.cpp')
-rw-r--r-- | src/state.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/state.cpp b/src/state.cpp index d6dfb89..e71865d 100644 --- a/src/state.cpp +++ b/src/state.cpp | |||
@@ -52,21 +52,21 @@ THE SOFTWARE. | |||
52 | [[nodiscard]] static int luaG_new_require(lua_State* L_) | 52 | [[nodiscard]] static int luaG_new_require(lua_State* L_) |
53 | { | 53 | { |
54 | int rc; | 54 | int rc; |
55 | int const args = lua_gettop( L_); // args | 55 | int const args = lua_gettop(L_); // args |
56 | Universe* U = universe_get( L_); | 56 | Universe* U = universe_get(L_); |
57 | //char const* modname = luaL_checkstring( L, 1); | 57 | //char const* modname = luaL_checkstring(L_, 1); |
58 | 58 | ||
59 | STACK_GROW( L_, 1); | 59 | STACK_GROW(L_, 1); |
60 | 60 | ||
61 | lua_pushvalue( L_, lua_upvalueindex( 1)); // args require | 61 | lua_pushvalue(L_, lua_upvalueindex( 1)); // args require |
62 | lua_insert( L_, 1); // require args | 62 | lua_insert(L_, 1); // require args |
63 | 63 | ||
64 | // Using 'lua_pcall()' to catch errors; otherwise a failing 'require' would | 64 | // Using 'lua_pcall()' to catch errors; otherwise a failing 'require' would |
65 | // leave us locked, blocking any future 'require' calls from other lanes. | 65 | // leave us locked, blocking any future 'require' calls from other lanes. |
66 | 66 | ||
67 | U->require_cs.lock(); | 67 | U->require_cs.lock(); |
68 | // starting with Lua 5.4, require may return a second optional value, so we need LUA_MULTRET | 68 | // starting with Lua 5.4, require may return a second optional value, so we need LUA_MULTRET |
69 | rc = lua_pcall( L_, args, LUA_MULTRET, 0 /*errfunc*/ ); // err|result(s) | 69 | rc = lua_pcall(L_, args, LUA_MULTRET, 0 /*errfunc*/ ); // err|result(s) |
70 | U->require_cs.unlock(); | 70 | U->require_cs.unlock(); |
71 | 71 | ||
72 | // the required module (or an error message) is left on the stack as returned value by original require function | 72 | // the required module (or an error message) is left on the stack as returned value by original require function |
@@ -76,7 +76,7 @@ THE SOFTWARE. | |||
76 | raise_lua_error(L_); | 76 | raise_lua_error(L_); |
77 | } | 77 | } |
78 | // should be 1 for Lua <= 5.3, 1 or 2 starting with Lua 5.4 | 78 | // should be 1 for Lua <= 5.3, 1 or 2 starting with Lua 5.4 |
79 | return lua_gettop(L_); // result(s) | 79 | return lua_gettop(L_); // result(s) |
80 | } | 80 | } |
81 | 81 | ||
82 | // ################################################################################################# | 82 | // ################################################################################################# |