diff options
Diffstat (limited to 'src/tools.c')
-rw-r--r-- | src/tools.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/tools.c b/src/tools.c index 65c70bf..c03433a 100644 --- a/src/tools.c +++ b/src/tools.c | |||
@@ -171,7 +171,7 @@ FuncSubType luaG_getfuncsubtype( lua_State *L, int _i) | |||
171 | } | 171 | } |
172 | { | 172 | { |
173 | int mustpush = 0, dumpres; | 173 | int mustpush = 0, dumpres; |
174 | if( STACK_ABS( L, _i) != lua_gettop( L)) | 174 | if( lua_absindex( L, _i) != lua_gettop( L)) |
175 | { | 175 | { |
176 | lua_pushvalue( L, _i); | 176 | lua_pushvalue( L, _i); |
177 | mustpush = 1; | 177 | mustpush = 1; |
@@ -376,7 +376,7 @@ static void populate_func_lookup_table_recur( lua_State *L, int _ctx_base, int _ | |||
376 | void populate_func_lookup_table( lua_State *L, int _i, char const *_name) | 376 | void populate_func_lookup_table( lua_State *L, int _i, char const *_name) |
377 | { | 377 | { |
378 | int const ctx_base = lua_gettop( L) + 1; | 378 | int const ctx_base = lua_gettop( L) + 1; |
379 | int const in_base = STACK_ABS( L, _i); | 379 | int const in_base = lua_absindex( L, _i); |
380 | int const start_depth = _name ? 1 : 0; | 380 | int const start_depth = _name ? 1 : 0; |
381 | //printf( "%p: populate_func_lookup_table('%s')\n", L, _name ? _name : "NULL"); | 381 | //printf( "%p: populate_func_lookup_table('%s')\n", L, _name ? _name : "NULL"); |
382 | STACK_GROW( L, 3); | 382 | STACK_GROW( L, 3); |
@@ -458,7 +458,9 @@ lua_State* luaG_newstate( char const* libs, lua_CFunction _on_state_create) | |||
458 | } | 458 | } |
459 | } | 459 | } |
460 | // after opening base, register the functions it exported in our name<->function database | 460 | // after opening base, register the functions it exported in our name<->function database |
461 | populate_func_lookup_table( L, LUA_GLOBALSINDEX, NULL); | 461 | lua_pushglobaltable( L); // Lua 5.2 no longer has LUA_GLOBALSINDEX: we must push globals table on the stack |
462 | populate_func_lookup_table( L, -1, NULL); | ||
463 | lua_pop( L, 1); | ||
462 | STACK_MID( L, 0); | 464 | STACK_MID( L, 0); |
463 | if( libs) | 465 | if( libs) |
464 | { | 466 | { |
@@ -594,7 +596,7 @@ luaG_IdFunction get_idfunc( lua_State *L, int index ) | |||
594 | { | 596 | { |
595 | luaG_IdFunction ret; | 597 | luaG_IdFunction ret; |
596 | 598 | ||
597 | index = STACK_ABS( L, index); | 599 | index = lua_absindex( L, index); |
598 | 600 | ||
599 | STACK_GROW(L,1); | 601 | STACK_GROW(L,1); |
600 | 602 | ||
@@ -1006,7 +1008,7 @@ uint_t get_mt_id( lua_State *L, int i ) { | |||
1006 | static uint_t last_id= 0; | 1008 | static uint_t last_id= 0; |
1007 | uint_t id; | 1009 | uint_t id; |
1008 | 1010 | ||
1009 | i = STACK_ABS( L, i); | 1011 | i = lua_absindex( L, i); |
1010 | 1012 | ||
1011 | STACK_GROW(L,3); | 1013 | STACK_GROW(L,3); |
1012 | 1014 | ||
@@ -1296,7 +1298,7 @@ int luaG_nameof( lua_State* L) | |||
1296 | // push a table whose contents are strings that, when concatenated, produce unique name | 1298 | // push a table whose contents are strings that, when concatenated, produce unique name |
1297 | lua_newtable( L); // o nil {c} {fqn} | 1299 | lua_newtable( L); // o nil {c} {fqn} |
1298 | // this is where we start the search | 1300 | // this is where we start the search |
1299 | lua_pushvalue( L, LUA_GLOBALSINDEX); // o nil {c} {fqn} _G | 1301 | lua_pushglobaltable( L); // o nil {c} {fqn} _G |
1300 | (void) discover_object_name_recur( L, 6666, 0); | 1302 | (void) discover_object_name_recur( L, 6666, 0); |
1301 | lua_pop( L, 3); // o "result" | 1303 | lua_pop( L, 3); // o "result" |
1302 | lua_pushstring( L, luaL_typename( L, 1)); // o "result" "type" | 1304 | lua_pushstring( L, luaL_typename( L, 1)); // o "result" "type" |