track nmatch with sp

This commit is contained in:
Kyryl Melekhin
2021-10-22 14:16:56 +00:00
parent 2d96c352cc
commit abaaa8fe7a

10
pike.c
View File

@@ -473,7 +473,7 @@ plist[plistidx++] = npc; \
#define onclist(nn) \ #define onclist(nn) \
#define endnlist() if (*npc == MATCH) nmatch = 1; \ #define endnlist() if (*npc == MATCH) nmatch = sp; \
#define endclist() \ #define endclist() \
@@ -571,8 +571,8 @@ int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
{ {
int rsubsize = sizeof(rsub)+(sizeof(char*)*nsubp); int rsubsize = sizeof(rsub)+(sizeof(char*)*nsubp);
int i, j, c, suboff = rsubsize, *npc, osubp = nsubp * sizeof(char*); int i, j, c, suboff = rsubsize, *npc, osubp = nsubp * sizeof(char*);
int clistidx = 0, nlistidx, plistidx, nmatch; int clistidx = 0, nlistidx, plistidx;
const char *sp = s, *_sp = s; const char *sp = s, *_sp = s, *nmatch = NULL;
int *insts = prog->insts; int *insts = prog->insts;
int *pcs[prog->splits], *plist[prog->splits]; int *pcs[prog->splits], *plist[prog->splits];
rsub *subs[prog->splits]; rsub *subs[prog->splits];
@@ -584,7 +584,7 @@ int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
for (;; sp = _sp) { for (;; sp = _sp) {
uc_len(i, sp) uc_code(c, sp) uc_len(i, sp) uc_code(c, sp)
_sp = sp+i; _sp = sp+i;
nlistidx = 0; plistidx = 0; nmatch = 0; nlistidx = 0; plistidx = 0;
for (i = 0; i < clistidx; i++) { for (i = 0; i < clistidx; i++) {
npc = clist[i].pc; npc = clist[i].pc;
nsub = clist[i].sub; nsub = clist[i].sub;
@@ -594,7 +594,7 @@ int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
break; break;
case ANY: case ANY:
addthread: addthread:
if (nmatch) if (nmatch == sp)
break; break;
addthread(2, nlist, nlistidx) addthread(2, nlist, nlistidx)
case CLASS: case CLASS: