aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-10-23 16:08:23 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-10-23 16:08:23 -0300
commit0fd91b1b087b478fffa36f96bc0f608d86627a4b (patch)
tree74e1e65dd7fb78b706c236ec2ba0f478245e4343
parenta2b353e0441f05c1c95793dd2ebdca0da3994e12 (diff)
downloadlua-0fd91b1b087b478fffa36f96bc0f608d86627a4b.tar.gz
lua-0fd91b1b087b478fffa36f96bc0f608d86627a4b.tar.bz2
lua-0fd91b1b087b478fffa36f96bc0f608d86627a4b.zip
optional limits for table.concat
-rw-r--r--ltablib.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/ltablib.c b/ltablib.c
index 15cad0e6..c95b621c 100644
--- a/ltablib.c
+++ b/ltablib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltablib.c,v 1.12 2002/08/06 18:01:50 roberto Exp roberto $ 2** $Id: ltablib.c,v 1.13 2002/10/04 14:30:31 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*/
@@ -149,12 +149,14 @@ static int luaB_tremove (lua_State *L) {
149 149
150static int str_concat (lua_State *L) { 150static int str_concat (lua_State *L) {
151 luaL_Buffer b; 151 luaL_Buffer b;
152 int n = aux_getn(L, 1);
153 size_t lsep; 152 size_t lsep;
154 const char *sep = luaL_opt_lstr(L, 2, "", &lsep); 153 const char *sep = luaL_opt_lstr(L, 2, "", &lsep);
155 int i; 154 int i = luaL_opt_int(L, 3, 1);
155 int n = luaL_opt_int(L, 4, 0);
156 luaL_check_type(L, 1, LUA_TTABLE);
157 if (n == 0) n = aux_getn(L, 1);
156 luaL_buffinit(L, &b); 158 luaL_buffinit(L, &b);
157 for (i=1; i<=n; i++) { 159 for (; i <= n; i++) {
158 lua_rawgeti(L, 1, i); 160 lua_rawgeti(L, 1, i);
159 luaL_arg_check(L, lua_isstring(L, -1), 1, "table contains non-strings"); 161 luaL_arg_check(L, lua_isstring(L, -1), 1, "table contains non-strings");
160 luaL_addvalue(&b); 162 luaL_addvalue(&b);