diff options
Diffstat (limited to '')
| -rw-r--r-- | lapi.c | 18 |
1 files changed, 11 insertions, 7 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lapi.c,v 1.128 2001/02/12 15:42:44 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 1.129 2001/02/13 16:17:53 roberto Exp roberto $ |
| 3 | ** Lua API | 3 | ** Lua API |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -707,14 +707,18 @@ LUA_API int lua_getn (lua_State *L, int index) { | |||
| 707 | 707 | ||
| 708 | 708 | ||
| 709 | LUA_API void lua_concat (lua_State *L, int n) { | 709 | LUA_API void lua_concat (lua_State *L, int n) { |
| 710 | StkId top; | ||
| 711 | LUA_LOCK(L); | 710 | LUA_LOCK(L); |
| 712 | api_check(L, n >= 2); | ||
| 713 | api_checknelems(L, n); | 711 | api_checknelems(L, n); |
| 714 | top = L->top; | 712 | if (n >= 2) { |
| 715 | luaV_strconc(L, n, top); | 713 | luaV_strconc(L, n, L->top); |
| 716 | L->top = top-(n-1); | 714 | L->top -= (n-1); |
| 717 | luaC_checkGC(L); | 715 | luaC_checkGC(L); |
| 716 | } | ||
| 717 | else if (n == 0) { /* push null string */ | ||
| 718 | setsvalue(L->top, luaS_newlstr(L, NULL, 0)); | ||
| 719 | api_incr_top(L); | ||
| 720 | } | ||
| 721 | /* else n == 1; nothing to do */ | ||
| 718 | LUA_UNLOCK(L); | 722 | LUA_UNLOCK(L); |
| 719 | } | 723 | } |
| 720 | 724 | ||
