get rid of misleading recursion
This commit is contained in:
42
pike.c
42
pike.c
@@ -498,10 +498,17 @@ int re_comp(rcode *prog, const char *re, int anchored)
|
|||||||
static void addthread(const int *pbeg, int *plist, int gen, rthreadlist *l,
|
static void addthread(const int *pbeg, int *plist, int gen, rthreadlist *l,
|
||||||
int *pc, rsub *sub, const char *beg, const char *sp)
|
int *pc, rsub *sub, const char *beg, const char *sp)
|
||||||
{
|
{
|
||||||
int off;
|
int i = 0, *pcs[10];
|
||||||
|
rsub *subs[10];
|
||||||
rec:
|
rec:
|
||||||
if(plist[pc - pbeg] == gen) {
|
if(plist[pc - pbeg] == gen) {
|
||||||
decref(sub);
|
decref(sub);
|
||||||
|
rec_check:
|
||||||
|
if (i) {
|
||||||
|
pc = pcs[--i];
|
||||||
|
sub = subs[i];
|
||||||
|
goto rec;
|
||||||
|
}
|
||||||
return; // already on list
|
return; // already on list
|
||||||
}
|
}
|
||||||
plist[pc - pbeg] = gen;
|
plist[pc - pbeg] = gen;
|
||||||
@@ -510,36 +517,35 @@ static void addthread(const int *pbeg, int *plist, int gen, rthreadlist *l,
|
|||||||
default:
|
default:
|
||||||
l->t[l->n].sub = sub;
|
l->t[l->n].sub = sub;
|
||||||
l->t[l->n++].pc = pc;
|
l->t[l->n++].pc = pc;
|
||||||
break;
|
goto rec_check;
|
||||||
case JMP:
|
case JMP:
|
||||||
off = pc[1];
|
pc += 2 + pc[1];
|
||||||
pc += 2 + off;
|
|
||||||
goto rec;
|
goto rec;
|
||||||
case SPLIT:
|
case SPLIT:
|
||||||
off = pc[1];
|
subs[i] = sub;
|
||||||
sub->ref++;
|
sub->ref++;
|
||||||
addthread(pbeg, plist, gen, l, pc+2, sub, beg, sp);
|
pc += 2;
|
||||||
pc += 2 + off;
|
pcs[i++] = pc + pc[-1];
|
||||||
goto rec;
|
goto rec;
|
||||||
case RSPLIT:
|
case RSPLIT:
|
||||||
off = pc[1];
|
subs[i] = sub;
|
||||||
pc += 2;
|
|
||||||
sub->ref++;
|
sub->ref++;
|
||||||
addthread(pbeg, plist, gen, l, pc + off, sub, beg, sp);
|
pc += 2;
|
||||||
|
pcs[i++] = pc;
|
||||||
|
pc += pc[-1];
|
||||||
goto rec;
|
goto rec;
|
||||||
case SAVE:
|
case SAVE:
|
||||||
off = pc[1];
|
sub = update(sub, pc[1], sp);
|
||||||
pc += 2;
|
pc += 2;
|
||||||
sub = update(sub, off, sp);
|
|
||||||
goto rec;
|
goto rec;
|
||||||
case BOL:
|
case BOL:
|
||||||
if(sp == beg)
|
if(sp != beg)
|
||||||
{ pc++; goto rec; }
|
goto rec_check;
|
||||||
break;
|
pc++; goto rec;
|
||||||
case EOL:
|
case EOL:
|
||||||
if(!*sp)
|
if(*sp)
|
||||||
{ pc++; goto rec; }
|
goto rec_check;
|
||||||
break;
|
pc++; goto rec;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user