diff options
author | Benoit Germain <bnt.germain@gmail.com> | 2015-04-12 13:49:04 +0200 |
---|---|---|
committer | Benoit Germain <bnt.germain@gmail.com> | 2015-04-12 13:49:04 +0200 |
commit | 3e3605dde3dd304fdce50171963c5363b31e1115 (patch) | |
tree | c35655212e0491729f8e0de7066e4ac1b1dea1dd | |
parent | ed24db228a7b4f949fb2c648f55a022ba5fcaa04 (diff) | |
parent | 20f0aed5462bd2dff3dde6abd52ae70728ae9d7a (diff) | |
download | lanes-3e3605dde3dd304fdce50171963c5363b31e1115.tar.gz lanes-3e3605dde3dd304fdce50171963c5363b31e1115.tar.bz2 lanes-3e3605dde3dd304fdce50171963c5363b31e1115.zip |
Merge pull request #113 from mpeterv/fix-lua53-configure-crash
Fix crash on lanes.configure() on Lua 5.3
-rw-r--r-- | src/tools.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/tools.c b/src/tools.c index bd1ea85..77f6abe 100644 --- a/src/tools.c +++ b/src/tools.c | |||
@@ -1256,13 +1256,13 @@ static void inter_copy_func( struct s_Universe* U, lua_State* L2, uint_t L2_cach | |||
1256 | 1256 | ||
1257 | /* push over any upvalues; references to this function will come from | 1257 | /* push over any upvalues; references to this function will come from |
1258 | * cache so we don't end up in eternal loop. | 1258 | * cache so we don't end up in eternal loop. |
1259 | * Lua5.2: one of the upvalues is _ENV, which we don't want to copy! | 1259 | * Lua5.2 and Lua5.3: one of the upvalues is _ENV, which we don't want to copy! |
1260 | * instead, the function shall have LUA_RIDX_GLOBALS taken in the destination state! | 1260 | * instead, the function shall have LUA_RIDX_GLOBALS taken in the destination state! |
1261 | */ | 1261 | */ |
1262 | { | 1262 | { |
1263 | char const* upname; | 1263 | char const* upname; |
1264 | #if LUA_VERSION_NUM == 502 | 1264 | #if LUA_VERSION_NUM >= 502 |
1265 | // With Lua 5.2, each Lua function gets its environment as one of its upvalues (named LUA_ENV, aka "_ENV" by default) | 1265 | // Starting with Lua 5.2, each Lua function gets its environment as one of its upvalues (named LUA_ENV, aka "_ENV" by default) |
1266 | // Generally this is LUA_RIDX_GLOBALS, which we don't want to copy from the source to the destination state... | 1266 | // Generally this is LUA_RIDX_GLOBALS, which we don't want to copy from the source to the destination state... |
1267 | // -> if we encounter an upvalue equal to the global table in the source, bind it to the destination's global table | 1267 | // -> if we encounter an upvalue equal to the global table in the source, bind it to the destination's global table |
1268 | lua_pushglobaltable( L); // ... _G | 1268 | lua_pushglobaltable( L); // ... _G |
@@ -1270,7 +1270,7 @@ static void inter_copy_func( struct s_Universe* U, lua_State* L2, uint_t L2_cach | |||
1270 | for( n = 0; (upname = lua_getupvalue( L, i, 1 + n)) != NULL; ++ n) | 1270 | for( n = 0; (upname = lua_getupvalue( L, i, 1 + n)) != NULL; ++ n) |
1271 | { // ... _G up[n] | 1271 | { // ... _G up[n] |
1272 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "UPNAME[%d]: %s -> " INDENT_END, n, upname)); | 1272 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "UPNAME[%d]: %s -> " INDENT_END, n, upname)); |
1273 | #if LUA_VERSION_NUM == 502 | 1273 | #if LUA_VERSION_NUM >= 502 |
1274 | if( lua_rawequal( L, -1, -2)) // is the upvalue equal to the global table? | 1274 | if( lua_rawequal( L, -1, -2)) // is the upvalue equal to the global table? |
1275 | { | 1275 | { |
1276 | DEBUGSPEW_CODE( fprintf( stderr, "pushing destination global scope\n")); | 1276 | DEBUGSPEW_CODE( fprintf( stderr, "pushing destination global scope\n")); |
@@ -1287,7 +1287,7 @@ static void inter_copy_func( struct s_Universe* U, lua_State* L2, uint_t L2_cach | |||
1287 | } | 1287 | } |
1288 | lua_pop( L, 1); // ... _G | 1288 | lua_pop( L, 1); // ... _G |
1289 | } | 1289 | } |
1290 | #if LUA_VERSION_NUM == 502 | 1290 | #if LUA_VERSION_NUM >= 502 |
1291 | lua_pop( L, 1); // ... | 1291 | lua_pop( L, 1); // ... |
1292 | #endif // LUA_VERSION_NUM | 1292 | #endif // LUA_VERSION_NUM |
1293 | } | 1293 | } |