From 281820d7c96da4478ad26b014e428364f0aa59d6 Mon Sep 17 00:00:00 2001 From: Kyryl Melekhin Date: Thu, 6 Jan 2022 21:37:47 +0000 Subject: [PATCH] correct sdense --- pike.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pike.c b/pike.c index 9e7122f..08951da 100644 --- a/pike.c +++ b/pike.c @@ -392,7 +392,7 @@ int re_comp(rcode *prog, const char *re, int nsubs) if (res < 0) return res; // If unparsed chars left if (*re) return RE_SYNTAX_ERROR; - int icnt = 0, scnt = SPLIT + 1; + int icnt = 0, scnt = SPLIT; for (int i = 0; i < prog->unilen; i++) switch (prog->insts[i]) { case CLASS: @@ -440,11 +440,10 @@ if (--csub->ref == 0) { \ #define onclist(nn) #define onnlist(nn) \ if (sdense[spc] < sparsesz) \ - if (sdense[sdense[spc]] == (unsigned int)spc) \ + if (sdense[sdense[spc] * 2] == (unsigned int)spc) \ deccheck(nn) \ sdense[spc] = sparsesz; \ -sdense[sparsesz] = spc; \ -sparsesz += 2; \ +sdense[sparsesz++ * 2] = spc; \ #define fastrec(nn, list, listidx) \ nsub->ref++; \ @@ -500,13 +499,13 @@ spc = *npc; \ if ((unsigned int)spc < WBEG) { \ list[listidx].sub = nsub; \ list[listidx++].pc = npc; \ + list##match() \ rec_check##nn: \ if (si) { \ npc = pcs[--si]; \ nsub = subs[si]; \ goto rec##nn; \ } \ - list##match() \ continue; \ } \ next##nn: \ @@ -574,7 +573,7 @@ int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp) for (;; sp = _sp) { uc_len(i, sp) uc_code(c, sp) _sp = sp+i; - nlistidx = 0; sparsesz = SPLIT; + nlistidx = 0; sparsesz = 0; for (i = 0; i < clistidx; i++) { npc = clist[i].pc; nsub = clist[i].sub;