]> granicus.if.org Git - postgresql/commitdiff
Fix generation too long headline with ShortWords.
authorTeodor Sigaev <teodor@sigaev.ru>
Thu, 15 Jan 2009 16:33:28 +0000 (16:33 +0000)
committerTeodor Sigaev <teodor@sigaev.ru>
Thu, 15 Jan 2009 16:33:28 +0000 (16:33 +0000)
Per http://archives.postgresql.org/pgsql-hackers/2008-09/msg01088.php

src/backend/tsearch/wparser_def.c

index da644c3c2ec28bf60dfb0913edd4eed947d54329..1943c1143ceed6bd6c3992c7140b726236a42271 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/tsearch/wparser_def.c,v 1.18 2009/01/01 17:23:48 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/tsearch/wparser_def.c,v 1.19 2009/01/15 16:33:28 teodor Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1921,6 +1921,7 @@ mark_hl_fragments(HeadlineParsedText *prs, TSQuery query, int highlight,
        }
        pfree(covers);
 }
+
 static void
 mark_hl_words(HeadlineParsedText *prs, TSQuery query, int highlight, 
                int shortword, int min_words, int max_words)
@@ -1981,12 +1982,14 @@ mark_hl_words(HeadlineParsedText *prs, TSQuery query, int highlight,
                                if (curlen < min_words && i >= prs->curwords)
                                {                               /* got end of text and our cover is shoter
                                                                 * than min_words */
-                                       for (i = p; i >= 0; i--)
+                                       for (i = p - 1; i >= 0; i--)
                                        {
                                                if (!NONWORDTOKEN(prs->words[i].type))
                                                        curlen++;
                                                if (prs->words[i].item && !prs->words[i].repeated)
                                                        poslen++;
+                                               if ( curlen >= max_words )
+                                                       break;
                                                if (NOENDTOKEN(prs->words[i].type) || prs->words[i].len <= shortword)
                                                        continue;
                                                if (curlen >= min_words)