pikevm return how much it consumes

This commit is contained in:
2026-01-24 07:37:23 -06:00
parent 1cc16538a4
commit 728b72bc91

View File

@@ -582,7 +582,7 @@ static int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
rthread *clist = _clist, *nlist = _nlist, *tmp; rthread *clist = _clist, *nlist = _nlist, *tmp;
int rsubsize = prog->presub, suboff = 0; int rsubsize = prog->presub, suboff = 0;
int cnt, spc, i, c, osubp = nsubp * sizeof(char*); int cnt, spc, i, c, osubp = nsubp * sizeof(char*);
int si = 0, clistidx = 0, nlistidx, mcont = MATCH; int si = 0, clistidx = 0, nlistidx, mcont = MATCH, len = -1;
unsigned int sdense[prog->sparsesz], sparsesz = 0; unsigned int sdense[prog->sparsesz], sparsesz = 0;
char nsubs[prog->sub]; char nsubs[prog->sub];
goto jmp_start; goto jmp_start;
@@ -613,6 +613,7 @@ static int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
matched: matched:
nlist[nlistidx++].pc = &mcont; nlist[nlistidx++].pc = &mcont;
if (npc != &mcont) { if (npc != &mcont) {
len = sp-s;
if (matched) if (matched)
decref(matched) decref(matched)
matched = nsub; matched = nsub;
@@ -622,7 +623,7 @@ static int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
subp[i] = matched->sub[i >> 1]; subp[i] = matched->sub[i >> 1];
subp[i+1] = matched->sub[(nsubp >> 1) + (i >> 1)]; subp[i+1] = matched->sub[(nsubp >> 1) + (i >> 1)];
} }
return 1; return len;
} }
swaplist() swaplist()
goto _continue; goto _continue;