diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-06-26 16:28:08 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-06-26 16:28:08 -0300 |
commit | cfcf2008069fc2d5574e10303dbe4f1ea3188636 (patch) | |
tree | fe9ce59f29e9faa92ace610c01ef6b2a797ee648 | |
parent | f32a8c04772bf9d78dbdc920cfad148deff08fab (diff) | |
download | lua-cfcf2008069fc2d5574e10303dbe4f1ea3188636.tar.gz lua-cfcf2008069fc2d5574e10303dbe4f1ea3188636.tar.bz2 lua-cfcf2008069fc2d5574e10303dbe4f1ea3188636.zip |
`concat' goes to `table' library
-rw-r--r-- | lstrlib.c | 22 |
1 files changed, 1 insertions, 21 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstrlib.c,v 1.85 2002/06/18 15:16:18 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.86 2002/06/25 19:16:44 roberto Exp roberto $ |
3 | ** Standard library for string operations and pattern-matching | 3 | ** Standard library for string operations and pattern-matching |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -92,25 +92,6 @@ static int str_rep (lua_State *L) { | |||
92 | } | 92 | } |
93 | 93 | ||
94 | 94 | ||
95 | static int str_concat (lua_State *L) { | ||
96 | luaL_Buffer b; | ||
97 | size_t lsep; | ||
98 | const char *sep = luaL_opt_lstr(L, 2, "", &lsep); | ||
99 | int n, i; | ||
100 | luaL_check_type(L, 1, LUA_TTABLE); | ||
101 | luaL_buffinit(L, &b); | ||
102 | n = lua_getn(L, 1); | ||
103 | for (i=1; i<=n; i++) { | ||
104 | lua_rawgeti(L, 1, i); | ||
105 | luaL_addvalue(&b); | ||
106 | if (i != n) | ||
107 | luaL_addlstring(&b, sep, lsep); | ||
108 | } | ||
109 | luaL_pushresult(&b); | ||
110 | return 1; | ||
111 | } | ||
112 | |||
113 | |||
114 | static int str_byte (lua_State *L) { | 95 | static int str_byte (lua_State *L) { |
115 | size_t l; | 96 | size_t l; |
116 | const char *s = luaL_check_lstr(L, 1, &l); | 97 | const char *s = luaL_check_lstr(L, 1, &l); |
@@ -713,7 +694,6 @@ static const luaL_reg strlib[] = { | |||
713 | {"char", str_char}, | 694 | {"char", str_char}, |
714 | {"rep", str_rep}, | 695 | {"rep", str_rep}, |
715 | {"byte", str_byte}, | 696 | {"byte", str_byte}, |
716 | {"concat", str_concat}, | ||
717 | {"format", str_format}, | 697 | {"format", str_format}, |
718 | {"find", str_find}, | 698 | {"find", str_find}, |
719 | {"gfind", gfind}, | 699 | {"gfind", gfind}, |