MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / add_s

Function add_s

src/Chain/libraries/glua/lstrlib.cpp:786–811  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

784
785
786static void add_s(MatchState *ms, luaL_Buffer *b, const char *s,
787 const char *e) {
788 size_t l, i;
789 lua_State *L = ms->L;
790 const char *news = lua_tolstring(L, 3, &l);
791 for (i = 0; i < l; i++) {
792 if (news[i] != L_ESC)
793 luaL_addchar(b, news[i]);
794 else {
795 i++; /* skip ESC */
796 if (!isdigit(uchar(news[i]))) {
797 if (news[i] != L_ESC)
798 luaL_error(L, "invalid use of '%c' in replacement string", L_ESC);
799 luaL_addchar(b, news[i]);
800 }
801 else if (news[i] == '0')
802 luaL_addlstring(b, s, e - s);
803 else {
804 push_onecapture(ms, news[i] - '1', s, e);
805 luaL_tolstring(L, -1, nullptr); /* if number, convert it to string */
806 lua_remove(L, -2); /* remove original value */
807 luaL_addvalue(b); /* add capture to accumulated result */
808 }
809 }
810 }
811}
812
813
814static void add_value(MatchState *ms, luaL_Buffer *b, const char *s,

Callers 1

add_valueFunction · 0.85

Calls 6

lua_tolstringFunction · 0.85
luaL_errorFunction · 0.85
luaL_addlstringFunction · 0.85
push_onecaptureFunction · 0.85
luaL_tolstringFunction · 0.85
luaL_addvalueFunction · 0.85

Tested by

no test coverage detected