MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / add_value

Function add_value

Source/Misc/lua/src/lua.c:14289–14318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14287
14288
14289static void add_value (MatchState *ms, luaL_Buffer *b, const char *s,
14290const char *e) {
14291lua_State *L = ms->L;
14292switch (lua_type(L, 3)) {
14293case LUA_TNUMBER:
14294case LUA_TSTRING: {
14295add_s(ms, b, s, e);
14296return;
14297}
14298case LUA_TFUNCTION: {
14299int n;
14300lua_pushvalue(L, 3);
14301n = push_captures(ms, s, e);
14302lua_call(L, n, 1);
14303break;
14304}
14305case LUA_TTABLE: {
14306push_onecapture(ms, 0, s, e);
14307lua_gettable(L, 3);
14308break;
14309}
14310}
14311if (!lua_toboolean(L, -1)) { /* nil or false? */
14312lua_pop(L, 1);
14313lua_pushlstring(L, s, e - s); /* keep original text */
14314}
14315else if (!lua_isstring(L, -1))
14316luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1));
14317luaL_addvalue(b); /* add result to accumulator */
14318}
14319
14320
14321static int str_gsub (lua_State *L) {

Callers 1

str_gsubFunction · 0.85

Calls 12

lua_typeFunction · 0.85
add_sFunction · 0.85
lua_pushvalueFunction · 0.85
push_capturesFunction · 0.85
lua_callFunction · 0.85
push_onecaptureFunction · 0.85
lua_gettableFunction · 0.85
lua_tobooleanFunction · 0.85
lua_pushlstringFunction · 0.85
lua_isstringFunction · 0.85
luaL_errorFunction · 0.85
luaL_addvalueFunction · 0.85

Tested by

no test coverage detected