MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / tconcat

Function tconcat

lib/lua/src/ltablib.c:156–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154
155
156static int tconcat (lua_State *L) {
157 luaL_Buffer b;
158 lua_Integer last = aux_getn(L, 1, TAB_R);
159 size_t lsep;
160 const char *sep = luaL_optlstring(L, 2, "", &lsep);
161 lua_Integer i = luaL_optinteger(L, 3, 1);
162 last = luaL_optinteger(L, 4, last);
163 luaL_buffinit(L, &b);
164 for (; i < last; i++) {
165 addfield(L, &b, i);
166 luaL_addlstring(&b, sep, lsep);
167 }
168 if (i == last) /* add last value (if interval was not empty) */
169 addfield(L, &b, i);
170 luaL_pushresult(&b);
171 return 1;
172}
173
174
175/*

Callers

nothing calls this directly

Calls 6

luaL_optlstringFunction · 0.85
luaL_optintegerFunction · 0.85
luaL_buffinitFunction · 0.85
addfieldFunction · 0.85
luaL_addlstringFunction · 0.85
luaL_pushresultFunction · 0.85

Tested by

no test coverage detected