MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / stringcap

Function stringcap

other_src/lua/src/lpeg.cpp:2093–2119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2091
2092
2093static void stringcap (luaL_Buffer *b, CapState *cs) {
2094 StrAux cps[MAXSTRCAPS];
2095 int n;
2096 size_t len, i;
2097 const char *c;
2098 updatecache(cs, cs->cap->idx);
2099 c = lua_tolstring(cs->L, subscache(cs), &len);
2100 n = getstrcaps(cs, cps, 0) - 1;
2101 for (i = 0; i < len; i++) {
2102 if (c[i] != '%' || c[++i] < '0' || c[i] > '9')
2103 luaL_addchar(b, c[i]);
2104 else {
2105 int l = c[i] - '0';
2106 if (l > n)
2107 luaL_error(cs->L, "invalid capture index (%d)", l);
2108 else if (cps[l].isstring)
2109 luaL_addlstring(b, cps[l].u.s.s, cps[l].u.s.e - cps[l].u.s.s);
2110 else {
2111 Capture *curr = cs->cap;
2112 cs->cap = cps[l].u.cp;
2113 if (addonestring(b, cs, "capture") == 0)
2114 luaL_error(cs->L, "no values in capture index %d", l);
2115 cs->cap = curr;
2116 }
2117 }
2118 }
2119}
2120
2121
2122static void substcap (luaL_Buffer *b, CapState *cs) {

Callers 2

addonestringFunction · 0.85
pushcaptureFunction · 0.85

Calls 5

getstrcapsFunction · 0.85
addonestringFunction · 0.85
lua_tolstringFunction · 0.70
luaL_errorFunction · 0.70
luaL_addlstringFunction · 0.70

Tested by

no test coverage detected