MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / add_value

Function add_value

third-party/lua-5.2.4/src/lstrlib.c:704–732  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

702
703
704static void add_value (MatchState *ms, luaL_Buffer *b, const char *s,
705 const char *e, int tr) {
706 lua_State *L = ms->L;
707 switch (tr) {
708 case LUA_TFUNCTION: {
709 int n;
710 lua_pushvalue(L, 3);
711 n = push_captures(ms, s, e);
712 lua_call(L, n, 1);
713 break;
714 }
715 case LUA_TTABLE: {
716 push_onecapture(ms, 0, s, e);
717 lua_gettable(L, 3);
718 break;
719 }
720 default: { /* LUA_TNUMBER or LUA_TSTRING */
721 add_s(ms, b, s, e);
722 return;
723 }
724 }
725 if (!lua_toboolean(L, -1)) { /* nil or false? */
726 lua_pop(L, 1);
727 lua_pushlstring(L, s, e - s); /* keep original text */
728 }
729 else if (!lua_isstring(L, -1))
730 luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1));
731 luaL_addvalue(b); /* add result to accumulator */
732}
733
734
735static int str_gsub (lua_State *L) {

Callers 1

str_gsubFunction · 0.70

Calls 11

lua_pushvalueFunction · 0.70
push_capturesFunction · 0.70
push_onecaptureFunction · 0.70
lua_gettableFunction · 0.70
add_sFunction · 0.70
lua_tobooleanFunction · 0.70
lua_pushlstringFunction · 0.70
lua_isstringFunction · 0.70
luaL_errorFunction · 0.70
luaL_addvalueFunction · 0.70
lua_callFunction · 0.50

Tested by

no test coverage detected