Skip to main content

concat

Function concat 

Source
pub fn concat(state: &mut LuaState) -> Result<usize, LuaError>
Expand description
static int tconcat (lua_State *L) {
  luaL_Buffer b;
  lua_Integer last = aux_getn(L, 1, TAB_R);
  size_t lsep;
  const char *sep = luaL_optlstring(L, 2, "", &lsep);
  lua_Integer i = luaL_optinteger(L, 3, 1);
  last = luaL_optinteger(L, 4, last);
  luaL_buffinit(L, &b);
  for (; i < last; i++) { addfield(L, &b, i); luaL_addlstring(&b, sep, lsep); }
  if (i == last) addfield(L, &b, i);
  luaL_pushresult(&b);
  return 1;
}