|
|
@ -1,5 +1,5 @@ |
|
|
|
/*
|
|
|
|
** $Id: ltablib.c,v 1.4 2002/06/05 16:59:21 roberto Exp roberto $ |
|
|
|
** $Id: ltablib.c,v 1.5 2002/06/05 17:24:04 roberto Exp roberto $ |
|
|
|
** Library for Table Manipulation |
|
|
|
** See Copyright Notice in lua.h |
|
|
|
*/ |
|
|
@ -25,7 +25,7 @@ static int luaB_foreachi (lua_State *L) { |
|
|
|
lua_pushvalue(L, 2); /* function */ |
|
|
|
lua_pushnumber(L, i); /* 1st argument */ |
|
|
|
lua_rawgeti(L, 1, i); /* 2nd argument */ |
|
|
|
lua_rawcall(L, 2, 1); |
|
|
|
lua_upcall(L, 2, 1); |
|
|
|
if (!lua_isnil(L, -1)) |
|
|
|
return 1; |
|
|
|
lua_pop(L, 1); /* remove nil result */ |
|
|
@ -44,7 +44,7 @@ static int luaB_foreach (lua_State *L) { |
|
|
|
lua_pushvalue(L, 2); /* function */ |
|
|
|
lua_pushvalue(L, -3); /* key */ |
|
|
|
lua_pushvalue(L, -3); /* value */ |
|
|
|
lua_rawcall(L, 2, 1); |
|
|
|
lua_upcall(L, 2, 1); |
|
|
|
if (!lua_isnil(L, -1)) |
|
|
|
return 1; |
|
|
|
lua_pop(L, 2); /* remove value and result */ |
|
|
@ -128,7 +128,7 @@ static int sort_comp (lua_State *L, int a, int b) { |
|
|
|
lua_pushvalue(L, 2); |
|
|
|
lua_pushvalue(L, a-1); /* -1 to compensate function */ |
|
|
|
lua_pushvalue(L, b-2); /* -2 to compensate function and `a' */ |
|
|
|
lua_rawcall(L, 2, 1); |
|
|
|
lua_upcall(L, 2, 1); |
|
|
|
res = lua_toboolean(L, -1); |
|
|
|
lua_pop(L, 1); |
|
|
|
return res; |
|
|
|