From: Teodor Sigaev Date: Thu, 15 Jan 2009 16:33:28 +0000 (+0000) Subject: Fix generation too long headline with ShortWords. X-Git-Tag: recoveryinfrav9~35 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=f6ffaf8045664bc5b86b3d9cd9175b5f321d658e;p=users%2Fsimon%2Fpostgres.git Fix generation too long headline with ShortWords. Per http://archives.postgresql.org/pgsql-hackers/2008-09/msg01088.php --- diff --git a/src/backend/tsearch/wparser_def.c b/src/backend/tsearch/wparser_def.c index 55cc3a7e96..94ff4087ed 100644 --- a/src/backend/tsearch/wparser_def.c +++ b/src/backend/tsearch/wparser_def.c @@ -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)