correct sdense

This commit is contained in:
Kyryl Melekhin
2022-01-06 21:37:47 +00:00
parent 915680e057
commit 281820d7c9

11
pike.c
View File

@@ -392,7 +392,7 @@ int re_comp(rcode *prog, const char *re, int nsubs)
if (res < 0) return res; if (res < 0) return res;
// If unparsed chars left // If unparsed chars left
if (*re) return RE_SYNTAX_ERROR; 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++) for (int i = 0; i < prog->unilen; i++)
switch (prog->insts[i]) { switch (prog->insts[i]) {
case CLASS: case CLASS:
@@ -440,11 +440,10 @@ if (--csub->ref == 0) { \
#define onclist(nn) #define onclist(nn)
#define onnlist(nn) \ #define onnlist(nn) \
if (sdense[spc] < sparsesz) \ if (sdense[spc] < sparsesz) \
if (sdense[sdense[spc]] == (unsigned int)spc) \ if (sdense[sdense[spc] * 2] == (unsigned int)spc) \
deccheck(nn) \ deccheck(nn) \
sdense[spc] = sparsesz; \ sdense[spc] = sparsesz; \
sdense[sparsesz] = spc; \ sdense[sparsesz++ * 2] = spc; \
sparsesz += 2; \
#define fastrec(nn, list, listidx) \ #define fastrec(nn, list, listidx) \
nsub->ref++; \ nsub->ref++; \
@@ -500,13 +499,13 @@ spc = *npc; \
if ((unsigned int)spc < WBEG) { \ if ((unsigned int)spc < WBEG) { \
list[listidx].sub = nsub; \ list[listidx].sub = nsub; \
list[listidx++].pc = npc; \ list[listidx++].pc = npc; \
list##match() \
rec_check##nn: \ rec_check##nn: \
if (si) { \ if (si) { \
npc = pcs[--si]; \ npc = pcs[--si]; \
nsub = subs[si]; \ nsub = subs[si]; \
goto rec##nn; \ goto rec##nn; \
} \ } \
list##match() \
continue; \ continue; \
} \ } \
next##nn: \ next##nn: \
@@ -574,7 +573,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; sparsesz = SPLIT; nlistidx = 0; sparsesz = 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;