diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-10-23 16:08:23 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-10-23 16:08:23 -0300 |
commit | 0fd91b1b087b478fffa36f96bc0f608d86627a4b (patch) | |
tree | 74e1e65dd7fb78b706c236ec2ba0f478245e4343 | |
parent | a2b353e0441f05c1c95793dd2ebdca0da3994e12 (diff) | |
download | lua-0fd91b1b087b478fffa36f96bc0f608d86627a4b.tar.gz lua-0fd91b1b087b478fffa36f96bc0f608d86627a4b.tar.bz2 lua-0fd91b1b087b478fffa36f96bc0f608d86627a4b.zip |
optional limits for table.concat
-rw-r--r-- | ltablib.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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 | ||
150 | static int str_concat (lua_State *L) { | 150 | static 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); |