| 1691 | |
| 1692 | |
| 1693 | static int capture_aux (lua_State *L, int kind, int labelidx) { |
| 1694 | int l1, n; |
| 1695 | Instruction *p1 = getpatt(L, 1, &l1); |
| 1696 | int lc = skipchecks(p1, 0, &n); |
| 1697 | if (lc == l1) { /* got whole pattern? */ |
| 1698 | /* may use a IFullCapture instruction at its end */ |
| 1699 | Instruction *p = newpatt(L, l1 + 1); |
| 1700 | int label = getlabel(L, labelidx); |
| 1701 | p += addpatt(L, p, 1); |
| 1702 | setinstcap(p, IFullCapture, label, kind, n); |
| 1703 | } |
| 1704 | else { /* must use open-close pair */ |
| 1705 | Instruction *op = newpatt(L, 1 + l1 + 1); |
| 1706 | Instruction *p = op; |
| 1707 | setinstcap(p++, IOpenCapture, getlabel(L, labelidx), kind, 0); |
| 1708 | p += addpatt(L, p, 1); |
| 1709 | setinstcap(p, ICloseCapture, 0, Cclose, 0); |
| 1710 | optimizecaptures(op); |
| 1711 | } |
| 1712 | return 1; |
| 1713 | } |
| 1714 | |
| 1715 | |
| 1716 | static int capture_l (lua_State *L) { return capture_aux(L, Csimple, 0); } |
no test coverage detected