This commit is contained in:
Kyryl Melekhin
2021-07-18 23:12:00 +00:00
parent 3837d0364b
commit 001ae2393b

17
pike.c
View File

@@ -464,9 +464,10 @@ int re_comp(rcode *prog, const char *re, int anchored)
return RE_SUCCESS; return RE_SUCCESS;
} }
#define addthread(nn, list, _pc, _sub, _sp, cont) \ #define addthread(nn, list, _pc, _sub, cont) \
{ \ { \
int i = 0, j, *pc = _pc; \ int i = 0, j, *pc = _pc; \
const char *_sp = sp+l; \
rsub *s1, *sub = _sub; \ rsub *s1, *sub = _sub; \
rec##nn: \ rec##nn: \
if(plist[pc - prog->insts] == gen) { \ if(plist[pc - prog->insts] == gen) { \
@@ -524,7 +525,7 @@ int re_comp(rcode *prog, const char *re, int anchored)
goto rec_check##nn; \ goto rec_check##nn; \
pc++; goto rec##nn; \ pc++; goto rec##nn; \
case EOL: \ case EOL: \
if(*(_sp)) \ if(*_sp) \
goto rec_check##nn; \ goto rec_check##nn; \
pc++; goto rec##nn; \ pc++; goto rec##nn; \
} \ } \
@@ -532,8 +533,8 @@ int re_comp(rcode *prog, const char *re, int anchored)
int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp) int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
{ {
int i, c, l, *npc, gen = 1, subidx = 1; int i, c, l = 0, *npc, gen = 1, subidx = 1;
const char *sp; const char *sp = s;
rsub nsubs[256]; rsub nsubs[256];
int plist[prog->unilen]; int plist[prog->unilen];
int *pcs[prog->splits]; int *pcs[prog->splits];
@@ -554,10 +555,8 @@ int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
gen = 1; gen = 1;
while (1) while (1)
addthread(1, clist, prog->insts, nsub, s, break) addthread(1, clist, prog->insts, nsub, break)
for(sp=s;; sp += l) { for(; clist->n; sp += l) {
if(clist->n == 0)
break;
gen++; uc_len(l, sp) gen++; uc_len(l, sp)
for(i=0; i<clist->n; i++) { for(i=0; i<clist->n; i++) {
npc = clist->t[i].pc; npc = clist->t[i].pc;
@@ -575,7 +574,7 @@ int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
break; break;
case ANY: case ANY:
addthread: addthread:
addthread(2, nlist, npc, nsub, sp+l, continue) addthread(2, nlist, npc, nsub, continue)
case CLASS: case CLASS:
if (!re_classmatch(npc, sp)) if (!re_classmatch(npc, sp))
break; break;