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

Function add_value

third-party/lua-5.3.5/src/lstrlib.c:731–759  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

729
730
731static void add_value (MatchState *ms, luaL_Buffer *b, const char *s,
732 const char *e, int tr) {
733 lua_State *L = ms->L;
734 switch (tr) {
735 case LUA_TFUNCTION: {
736 int n;
737 lua_pushvalue(L, 3);
738 n = push_captures(ms, s, e);
739 lua_call(L, n, 1);
740 break;
741 }
742 case LUA_TTABLE: {
743 push_onecapture(ms, 0, s, e);
744 lua_gettable(L, 3);
745 break;
746 }
747 default: { /* LUA_TNUMBER or LUA_TSTRING */
748 add_s(ms, b, s, e);
749 return;
750 }
751 }
752 if (!lua_toboolean(L, -1)) { /* nil or false? */
753 lua_pop(L, 1);
754 lua_pushlstring(L, s, e - s); /* keep original text */
755 }
756 else if (!lua_isstring(L, -1))
757 luaL_error(L, "invalid replacement value (a %s)", luaL_typename(L, -1));
758 luaL_addvalue(b); /* add result to accumulator */
759}
760
761
762static 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