Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8fd07a3

Browse files
committed
Fix generation too long headline with ShortWords.
Per http://archives.postgresql.org/pgsql-hackers/2008-09/msg01088.php
1 parent f8c8386 commit 8fd07a3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/backend/tsearch/wparser_def.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/tsearch/wparser_def.c,v 1.18 2009/01/01 17:23:48 momjian Exp $
10+
* $PostgreSQL: pgsql/src/backend/tsearch/wparser_def.c,v 1.19 2009/01/15 16:33:28 teodor Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1921,6 +1921,7 @@ mark_hl_fragments(HeadlineParsedText *prs, TSQuery query, int highlight,
19211921
}
19221922
pfree(covers);
19231923
}
1924+
19241925
static void
19251926
mark_hl_words(HeadlineParsedText *prs, TSQuery query, int highlight,
19261927
int shortword, int min_words, int max_words)
@@ -1981,12 +1982,14 @@ mark_hl_words(HeadlineParsedText *prs, TSQuery query, int highlight,
19811982
if (curlen < min_words && i >= prs->curwords)
19821983
{ /* got end of text and our cover is shoter
19831984
* than min_words */
1984-
for (i = p; i >= 0; i--)
1985+
for (i = p - 1; i >= 0; i--)
19851986
{
19861987
if (!NONWORDTOKEN(prs->words[i].type))
19871988
curlen++;
19881989
if (prs->words[i].item && !prs->words[i].repeated)
19891990
poslen++;
1991+
if ( curlen >= max_words )
1992+
break;
19901993
if (NOENDTOKEN(prs->words[i].type) || prs->words[i].len <= shortword)
19911994
continue;
19921995
if (curlen >= min_words)

0 commit comments

Comments
 (0)