From 82aaa25bd10b8aa0f77c59ca1bfdd13f32c52b9f Mon Sep 17 00:00:00 2001 From: Kyryl Melekhin Date: Mon, 19 Jul 2021 10:38:02 +0000 Subject: [PATCH] fix ref --- pike.c | 5 +---- test.sh | 3 +++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pike.c b/pike.c index 816f29c..12b1b6c 100644 --- a/pike.c +++ b/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--; diff --git a/test.sh b/test.sh index a0465e3..8b43c9e 100755 --- a/test.sh +++ b/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"