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

Function add_s

third-party/lua-5.5.0/src/lstrlib.c:874–901  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

872
873
874static void add_s (MatchState *ms, luaL_Buffer *b, const char *s,
875 const char *e) {
876 size_t l;
877 lua_State *L = ms->L;
878 const char *news = lua_tolstring(L, 3, &l);
879 const char *p;
880 while ((p = (char *)memchr(news, L_ESC, l)) != NULL) {
881 luaL_addlstring(b, news, ct_diff2sz(p - news));
882 p++; /* skip ESC */
883 if (*p == L_ESC) /* '%%' */
884 luaL_addchar(b, *p);
885 else if (*p == '0') /* '%0' */
886 luaL_addlstring(b, s, ct_diff2sz(e - s));
887 else if (isdigit(cast_uchar(*p))) { /* '%n' */
888 const char *cap;
889 ptrdiff_t resl = get_onecapture(ms, *p - '1', s, e, &cap);
890 if (resl == CAP_POSITION)
891 luaL_addvalue(b); /* add position to accumulated result */
892 else
893 luaL_addlstring(b, cap, cast_sizet(resl));
894 }
895 else
896 luaL_error(L, "invalid use of '%c' in replacement string", L_ESC);
897 l -= ct_diff2sz(p + 1 - news);
898 news = p + 1;
899 }
900 luaL_addlstring(b, news, l);
901}
902
903
904/*

Callers 1

add_valueFunction · 0.70

Calls 5

lua_tolstringFunction · 0.70
luaL_addlstringFunction · 0.70
get_onecaptureFunction · 0.70
luaL_addvalueFunction · 0.70
luaL_errorFunction · 0.70

Tested by

no test coverage detected