diff --git a/lapi.c b/lapi.c index e2c9f45a..47635e56 100644 --- a/lapi.c +++ b/lapi.c @@ -1,5 +1,5 @@ /* -** $Id: lapi.c,v 1.128 2001/02/12 15:42:44 roberto Exp roberto $ +** $Id: lapi.c,v 1.129 2001/02/13 16:17:53 roberto Exp roberto $ ** Lua API ** See Copyright Notice in lua.h */ @@ -707,14 +707,18 @@ LUA_API int lua_getn (lua_State *L, int index) { LUA_API void lua_concat (lua_State *L, int n) { - StkId top; LUA_LOCK(L); - api_check(L, n >= 2); api_checknelems(L, n); - top = L->top; - luaV_strconc(L, n, top); - L->top = top-(n-1); - luaC_checkGC(L); + if (n >= 2) { + luaV_strconc(L, n, L->top); + L->top -= (n-1); + luaC_checkGC(L); + } + else if (n == 0) { /* push null string */ + setsvalue(L->top, luaS_newlstr(L, NULL, 0)); + api_incr_top(L); + } + /* else n == 1; nothing to do */ LUA_UNLOCK(L); } diff --git a/lauxlib.c b/lauxlib.c index 8920ac9c..d36424d2 100644 --- a/lauxlib.c +++ b/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.45 2001/01/25 16:45:36 roberto Exp roberto $ +** $Id: lauxlib.c,v 1.46 2001/02/02 19:02:40 roberto Exp roberto $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -166,10 +166,8 @@ static void adjuststack (luaL_Buffer *B) { } else break; } while (toget < B->level); - if (toget >= 2) { - lua_concat(L, toget); - B->level = B->level - toget + 1; - } + lua_concat(L, toget); + B->level = B->level - toget + 1; } } @@ -194,10 +192,7 @@ LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) { LUALIB_API void luaL_pushresult (luaL_Buffer *B) { emptybuffer(B); - if (B->level == 0) - lua_pushlstring(B->L, NULL, 0); - else if (B->level > 1) - lua_concat(B->L, B->level); + lua_concat(B->L, B->level); B->level = 1; }