mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 22:02:27 +00:00
This reverts commit 55a15c204e
.
This commit is contained in:
parent
6bbb44c165
commit
2bc0901ce3
16 changed files with 20 additions and 557 deletions
15
third_party/lua/lbaselib.c
vendored
15
third_party/lua/lbaselib.c
vendored
|
@ -254,12 +254,9 @@ static int luaB_next (lua_State *L) {
|
|||
}
|
||||
}
|
||||
|
||||
static int luaB_ipairs (lua_State *L);
|
||||
|
||||
static int luaB_pairs (lua_State *L) {
|
||||
luaL_checkany(L, 1);
|
||||
if (lua_isarray(L, 1))
|
||||
return luaB_ipairs(L);
|
||||
if (luaL_getmetafield(L, 1, "__pairs") == LUA_TNIL) { /* no metamethod? */
|
||||
lua_pushcfunction(L, luaB_next); /* will return generator, */
|
||||
lua_pushvalue(L, 1); /* state, */
|
||||
|
@ -282,16 +279,6 @@ static int ipairsaux (lua_State *L) {
|
|||
return (lua_geti(L, 1, i) == LUA_TNIL) ? 1 : 2;
|
||||
}
|
||||
|
||||
/*
|
||||
** Traversal function for 'ipairs' specialized for arrays.
|
||||
*/
|
||||
static int ipairsauxarray (lua_State *L) {
|
||||
lua_Integer i = luaL_checkinteger(L, 2) + 1;
|
||||
lua_pushinteger(L, i);
|
||||
lua_geti(L, 1, i);
|
||||
return (lua_rawlen(L, 1) == i-1) ? 1 : 2;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** 'ipairs' function. Returns 'ipairsaux', given "table", 0.
|
||||
|
@ -299,7 +286,7 @@ static int ipairsauxarray (lua_State *L) {
|
|||
*/
|
||||
static int luaB_ipairs (lua_State *L) {
|
||||
luaL_checkany(L, 1);
|
||||
lua_pushcfunction(L, lua_isarray(L, 1) ? ipairsauxarray : ipairsaux); /* iteration function */
|
||||
lua_pushcfunction(L, ipairsaux); /* iteration function */
|
||||
lua_pushvalue(L, 1); /* state */
|
||||
lua_pushinteger(L, 0); /* initial value */
|
||||
return 3;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue