diff options
Diffstat (limited to 'lbaselib.c')
-rw-r--r-- | lbaselib.c | 19 |
1 files changed, 1 insertions, 18 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.233 2009/12/17 16:20:01 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.234 2009/12/22 15:32:50 roberto Exp roberto $ |
3 | ** Basic library | 3 | ** Basic library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -412,22 +412,6 @@ static int luaB_assert (lua_State *L) { | |||
412 | } | 412 | } |
413 | 413 | ||
414 | 414 | ||
415 | static int luaB_unpack (lua_State *L) { | ||
416 | int i, e, n; | ||
417 | luaL_checktype(L, 1, LUA_TTABLE); | ||
418 | i = luaL_optint(L, 2, 1); | ||
419 | e = luaL_opt(L, luaL_checkint, 3, (int)lua_rawlen(L, 1)); | ||
420 | if (i > e) return 0; /* empty range */ | ||
421 | n = e - i + 1; /* number of elements */ | ||
422 | if (n <= 0 || !lua_checkstack(L, n)) /* n <= 0 means arith. overflow */ | ||
423 | return luaL_error(L, "too many results to unpack"); | ||
424 | lua_rawgeti(L, 1, i); /* push arg[i] (avoiding overflow problems) */ | ||
425 | while (i++ < e) /* push arg[i + 1...e] */ | ||
426 | lua_rawgeti(L, 1, i); | ||
427 | return n; | ||
428 | } | ||
429 | |||
430 | |||
431 | static int luaB_select (lua_State *L) { | 415 | static int luaB_select (lua_State *L) { |
432 | int n = lua_gettop(L); | 416 | int n = lua_gettop(L); |
433 | if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') { | 417 | if (lua_type(L, 1) == LUA_TSTRING && *lua_tostring(L, 1) == '#') { |
@@ -542,7 +526,6 @@ static const luaL_Reg base_funcs[] = { | |||
542 | {"tonumber", luaB_tonumber}, | 526 | {"tonumber", luaB_tonumber}, |
543 | {"tostring", luaB_tostring}, | 527 | {"tostring", luaB_tostring}, |
544 | {"type", luaB_type}, | 528 | {"type", luaB_type}, |
545 | {"unpack", luaB_unpack}, | ||
546 | {"xpcall", luaB_xpcall}, | 529 | {"xpcall", luaB_xpcall}, |
547 | {NULL, NULL} | 530 | {NULL, NULL} |
548 | }; | 531 | }; |