| 2230 | |
| 2231 | |
| 2232 | static int getcaptures (lua_State *L, const char *s, const char *r, int ptop) { |
| 2233 | Capture *capture = (Capture *)lua_touserdata(L, caplistidx(ptop)); |
| 2234 | int n = 0; |
| 2235 | if (!isclosecap(capture)) { /* is there any capture? */ |
| 2236 | CapState cs; |
| 2237 | cs.ocap = cs.cap = capture; cs.L = L; |
| 2238 | cs.s = s; cs.valuecached = 0; cs.ptop = ptop; |
| 2239 | do { /* collect their values */ |
| 2240 | n += pushcapture(&cs); |
| 2241 | } while (!isclosecap(cs.cap)); |
| 2242 | } |
| 2243 | if (n == 0) { /* no capture values? */ |
| 2244 | lua_pushinteger(L, r - s + 1); /* return only end position */ |
| 2245 | n = 1; |
| 2246 | } |
| 2247 | return n; |
| 2248 | } |
| 2249 | |
| 2250 | /* }====================================================== */ |
| 2251 |
no test coverage detected