MCPcopy Create free account
hub / github.com/F-Stack/f-stack / add_value

Function add_value

freebsd/contrib/openzfs/module/lua/lstrlib.c:715–743  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

str_gsubFunction · 0.70

Calls 11

lua_callFunction · 0.85
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

Tested by

no test coverage detected