Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6698567

Browse files
committed
Fix minor bug in regexp makesearch() function.
The list-wrangling here was done wrong, allowing the same state to getput into the list twice. The following loop then would clone it twice.The second clone would wind up with no inarcs, so that there was noobservable misbehavior AFAICT, but a useless state in the finished NFAisn't an especially good thing.
1 parentcc28f77 commit6698567

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

‎src/backend/regex/regcomp.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -560,21 +560,26 @@ makesearch(struct vars * v,
560560
* splitting each such state into progress and no-progress states.
561561
*/
562562

563-
/* first, make a list of the states */
563+
/* first, make a list of the statesreachable from pre and elsewhere*/
564564
slist=NULL;
565565
for (a=pre->outs;a!=NULL;a=a->outchain)
566566
{
567567
s=a->to;
568568
for (b=s->ins;b!=NULL;b=b->inchain)
569+
{
569570
if (b->from!=pre)
570571
break;
572+
}
573+
574+
/*
575+
* We want to mark states as being in the list already by having non
576+
* NULL tmp fields, but we can't just store the old slist value in tmp
577+
* because that doesn't work for the first such state. Instead, the
578+
* first list entry gets its own address in tmp.
579+
*/
571580
if (b!=NULL&&s->tmp==NULL)
572581
{
573-
/*
574-
* Must be split if not already in the list (fixes bugs 505048,
575-
* 230589, 840258, 504785).
576-
*/
577-
s->tmp=slist;
582+
s->tmp= (slist!=NULL) ?slist :s;
578583
slist=s;
579584
}
580585
}
@@ -593,7 +598,7 @@ makesearch(struct vars * v,
593598
freearc(nfa,a);
594599
}
595600
}
596-
s2=s->tmp;
601+
s2=(s->tmp!=s) ?s->tmp :NULL;
597602
s->tmp=NULL;/* clean up while we're at it */
598603
}
599604
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp