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

Function tablecap

other_src/lua/src/lpeg.cpp:1951–1980  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1949
1950
1951static int tablecap (CapState *cs) {
1952 lua_State *L = cs->L;
1953 int n = 0;
1954 lua_newtable(L);
1955 if (isfullcap(cs->cap++))
1956 return 1; /* table is empty */
1957 while (!isclosecap(cs->cap)) {
1958 if (captype(cs->cap) == Cgroup && cs->cap->idx != 0) { /* named group? */
1959 int k;
1960 pushluaval(cs); /* push group name */
1961 k = pushallvalues(cs, 0);
1962 if (k == 0) { /* no value? */
1963 lua_pop(L, 1); /* remove group name */
1964 continue; /* and go on */
1965 }
1966 else if (k > 1)
1967 lua_pop(L, k - 1); /* keep just one value */
1968 lua_settable(L, -3);
1969 }
1970 else {
1971 int i;
1972 int k = pushcapture(cs);
1973 for (i = k; i > 0; i--)
1974 lua_rawseti(L, -(i + 1), n + i);
1975 n += k;
1976 }
1977 }
1978 cs->cap++; /* skip close entry */
1979 return 1;
1980}
1981
1982
1983static int querycap (CapState *cs) {

Callers 1

pushcaptureFunction · 0.85

Calls 4

pushallvaluesFunction · 0.85
pushcaptureFunction · 0.85
lua_settableFunction · 0.70
lua_rawsetiFunction · 0.70

Tested by

no test coverage detected