fix ref
This commit is contained in:
5
pike.c
5
pike.c
@@ -516,6 +516,7 @@ int re_comp(rcode *prog, const char *re, int anchored)
|
||||
freedsub##nn: \
|
||||
for (j = 0; j < nsubp; j++) \
|
||||
s1->sub[j] = sub->sub[j]; \
|
||||
sub->ref--; \
|
||||
sub = s1; \
|
||||
sub->ref = 1; \
|
||||
} \
|
||||
@@ -583,11 +584,7 @@ int re_pikevm(rcode *prog, const char *s, const char **subp, int nsubp)
|
||||
npc += *(npc+1) * 2 + 2;
|
||||
goto addthread;
|
||||
case MATCH:
|
||||
if (matched)
|
||||
matched->ref = 0;
|
||||
matched = nsub;
|
||||
for(i++; i < clist->n; i++)
|
||||
clist->t[i].sub->ref = 0;
|
||||
goto BreakFor;
|
||||
}
|
||||
nsub->ref--;
|
||||
|
||||
3
test.sh
3
test.sh
@@ -147,6 +147,9 @@ echo "$regex" | tr '\n' | while read re; do
|
||||
inp=$(echo "$input" | awk -v c=$c 'BEGIN{ RS = "" ; FS = "\n" }{print $c}')
|
||||
exp=$(echo "$expect" | awk -v c=$c 'BEGIN{ RS = "" ; FS = "\n" }{print $c}')
|
||||
var=$(./a.out "$re" "$inp")
|
||||
if [ "$1" ]; then
|
||||
echo "$var"
|
||||
fi
|
||||
var1=$(echo "$var" | tail -1)
|
||||
if [ ! "$exp" = "$var1" ]; then
|
||||
echo "fail test$c regex:$re input:$inp expect:$exp output:$var1"
|
||||
|
||||
Reference in New Issue
Block a user