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

Function findback

other_src/lua/src/lpeg.cpp:1915–1937  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1913
1914
1915static Capture *findback (CapState *cs, Capture *cap) {
1916 lua_State *L = cs->L;
1917 for (;;) {
1918 if (cap == cs->ocap) { /* not found */
1919 const char *s = lua_tostring(L, -1);
1920 if (s == NULL) s = lua_pushfstring(L, "(a %s)", luaL_typename(L, -1));
1921 luaL_error(L, "back reference '%s' not found", s);
1922 }
1923 cap--;
1924 if (isclosecap(cap))
1925 cap = findopen(cap);
1926 else if (!isfullcap(cap))
1927 continue; /* opening an enclosing capture: skip and get previous */
1928 if (captype(cap) == Cgroup) {
1929 getfromenv(cs, cap->idx); /* get group name */
1930 if (lua_equal(L, -2, -1)) { /* right group? */
1931 lua_pop(L, 2); /* remove reference name and group name */
1932 return cap;
1933 }
1934 else lua_pop(L, 1); /* remove group name */
1935 }
1936 }
1937}
1938
1939
1940static int backrefcap (CapState *cs) {

Callers 1

backrefcapFunction · 0.85

Calls 4

findopenFunction · 0.85
lua_pushfstringFunction · 0.70
luaL_errorFunction · 0.70
lua_equalFunction · 0.70

Tested by

no test coverage detected