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: \
|
freedsub##nn: \
|
||||||
for (j = 0; j < nsubp; j++) \
|
for (j = 0; j < nsubp; j++) \
|
||||||
s1->sub[j] = sub->sub[j]; \
|
s1->sub[j] = sub->sub[j]; \
|
||||||
|
sub->ref--; \
|
||||||
sub = s1; \
|
sub = s1; \
|
||||||
sub->ref = 1; \
|
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;
|
npc += *(npc+1) * 2 + 2;
|
||||||
goto addthread;
|
goto addthread;
|
||||||
case MATCH:
|
case MATCH:
|
||||||
if (matched)
|
|
||||||
matched->ref = 0;
|
|
||||||
matched = nsub;
|
matched = nsub;
|
||||||
for(i++; i < clist->n; i++)
|
|
||||||
clist->t[i].sub->ref = 0;
|
|
||||||
goto BreakFor;
|
goto BreakFor;
|
||||||
}
|
}
|
||||||
nsub->ref--;
|
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}')
|
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}')
|
exp=$(echo "$expect" | awk -v c=$c 'BEGIN{ RS = "" ; FS = "\n" }{print $c}')
|
||||||
var=$(./a.out "$re" "$inp")
|
var=$(./a.out "$re" "$inp")
|
||||||
|
if [ "$1" ]; then
|
||||||
|
echo "$var"
|
||||||
|
fi
|
||||||
var1=$(echo "$var" | tail -1)
|
var1=$(echo "$var" | tail -1)
|
||||||
if [ ! "$exp" = "$var1" ]; then
|
if [ ! "$exp" = "$var1" ]; then
|
||||||
echo "fail test$c regex:$re input:$inp expect:$exp output:$var1"
|
echo "fail test$c regex:$re input:$inp expect:$exp output:$var1"
|
||||||
|
|||||||
Reference in New Issue
Block a user