aboutsummaryrefslogtreecommitdiff
path: root/ltablib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2004-12-07 16:31:16 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2004-12-07 16:31:16 -0200
commit70751dd27c4225955fe018d6829ea45e3e66a51c (patch)
treef190cfa201bcb793247463e948e8ed0de8b9994b /ltablib.c
parent39a8082f50c7321d75425f08a551a1d331dcea2d (diff)
downloadlua-70751dd27c4225955fe018d6829ea45e3e66a51c.tar.gz
lua-70751dd27c4225955fe018d6829ea45e3e66a51c.tar.bz2
lua-70751dd27c4225955fe018d6829ea45e3e66a51c.zip
details
Diffstat (limited to 'ltablib.c')
-rw-r--r--ltablib.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/ltablib.c b/ltablib.c
index d5c3e37c..572730aa 100644
--- a/ltablib.c
+++ b/ltablib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltablib.c,v 1.25 2004/05/10 18:06:14 roberto Exp roberto $ 2** $Id: ltablib.c,v 1.26 2004/06/15 13:37:21 roberto Exp roberto $
3** Library for Table Manipulation 3** Library for Table Manipulation
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -19,7 +19,7 @@
19#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n)) 19#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n))
20 20
21 21
22static int luaB_foreachi (lua_State *L) { 22static int foreachi (lua_State *L) {
23 int i; 23 int i;
24 int n = aux_getn(L, 1); 24 int n = aux_getn(L, 1);
25 luaL_checktype(L, 2, LUA_TFUNCTION); 25 luaL_checktype(L, 2, LUA_TFUNCTION);
@@ -36,7 +36,7 @@ static int luaB_foreachi (lua_State *L) {
36} 36}
37 37
38 38
39static int luaB_foreach (lua_State *L) { 39static int foreach (lua_State *L) {
40 luaL_checktype(L, 1, LUA_TTABLE); 40 luaL_checktype(L, 1, LUA_TTABLE);
41 luaL_checktype(L, 2, LUA_TFUNCTION); 41 luaL_checktype(L, 2, LUA_TFUNCTION);
42 lua_pushnil(L); /* first key */ 42 lua_pushnil(L); /* first key */
@@ -54,13 +54,13 @@ static int luaB_foreach (lua_State *L) {
54} 54}
55 55
56 56
57static int luaB_getn (lua_State *L) { 57static int getn (lua_State *L) {
58 lua_pushinteger(L, aux_getn(L, 1)); 58 lua_pushinteger(L, aux_getn(L, 1));
59 return 1; 59 return 1;
60} 60}
61 61
62 62
63static int luaB_setn (lua_State *L) { 63static int setn (lua_State *L) {
64 luaL_checktype(L, 1, LUA_TTABLE); 64 luaL_checktype(L, 1, LUA_TTABLE);
65 luaL_setn(L, 1, luaL_checkint(L, 2)); 65 luaL_setn(L, 1, luaL_checkint(L, 2));
66 lua_pushvalue(L, 1); 66 lua_pushvalue(L, 1);
@@ -68,7 +68,7 @@ static int luaB_setn (lua_State *L) {
68} 68}
69 69
70 70
71static int luaB_tinsert (lua_State *L) { 71static int tinsert (lua_State *L) {
72 int v = lua_gettop(L); /* number of arguments */ 72 int v = lua_gettop(L); /* number of arguments */
73 int e = aux_getn(L, 1) + LUA_FIRSTINDEX; /* first empty element */ 73 int e = aux_getn(L, 1) + LUA_FIRSTINDEX; /* first empty element */
74 int pos; /* where to insert new element */ 74 int pos; /* where to insert new element */
@@ -90,7 +90,7 @@ static int luaB_tinsert (lua_State *L) {
90} 90}
91 91
92 92
93static int luaB_tremove (lua_State *L) { 93static int tremove (lua_State *L) {
94 int e = aux_getn(L, 1) + LUA_FIRSTINDEX - 1; 94 int e = aux_getn(L, 1) + LUA_FIRSTINDEX - 1;
95 int pos = luaL_optint(L, 2, e); 95 int pos = luaL_optint(L, 2, e);
96 if (e < LUA_FIRSTINDEX) return 0; /* table is `empty' */ 96 if (e < LUA_FIRSTINDEX) return 0; /* table is `empty' */
@@ -220,7 +220,7 @@ static void auxsort (lua_State *L, int l, int u) {
220 } /* repeat the routine for the larger one */ 220 } /* repeat the routine for the larger one */
221} 221}
222 222
223static int luaB_sort (lua_State *L) { 223static int sort (lua_State *L) {
224 int n = aux_getn(L, 1); 224 int n = aux_getn(L, 1);
225 luaL_checkstack(L, 40, ""); /* assume array is smaller than 2^40 */ 225 luaL_checkstack(L, 40, ""); /* assume array is smaller than 2^40 */
226 if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */ 226 if (!lua_isnoneornil(L, 2)) /* is there a 2nd argument? */
@@ -235,13 +235,13 @@ static int luaB_sort (lua_State *L) {
235 235
236static const luaL_reg tab_funcs[] = { 236static const luaL_reg tab_funcs[] = {
237 {"concat", str_concat}, 237 {"concat", str_concat},
238 {"foreach", luaB_foreach}, 238 {"foreach", foreach},
239 {"foreachi", luaB_foreachi}, 239 {"foreachi", foreachi},
240 {"getn", luaB_getn}, 240 {"getn", getn},
241 {"setn", luaB_setn}, 241 {"setn", setn},
242 {"sort", luaB_sort}, 242 {"sort", sort},
243 {"insert", luaB_tinsert}, 243 {"insert", tinsert},
244 {"remove", luaB_tremove}, 244 {"remove", tremove},
245 {NULL, NULL} 245 {NULL, NULL}
246}; 246};
247 247