From 22abc26aafa695318481640ce2ac0dd3d83a2bed Mon Sep 17 00:00:00 2001 From: Teodor Sigaev Date: Thu, 15 Jan 2009 17:44:47 +0000 Subject: [PATCH] Fix URL generation in headline. Only tag lexeme will be replaced by space. Per http://archives.postgresql.org/pgsql-bugs/2008-12/msg00013.php --- contrib/tsearch2/ts_cfg.c | 2 +- contrib/tsearch2/ts_cfg.h | 3 ++- contrib/tsearch2/wparser_def.c | 12 +++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/contrib/tsearch2/ts_cfg.c b/contrib/tsearch2/ts_cfg.c index 345e43f3986..5584878efca 100644 --- a/contrib/tsearch2/ts_cfg.c +++ b/contrib/tsearch2/ts_cfg.c @@ -533,7 +533,7 @@ genhl(HLPRSTEXT * prs) *ptr = ' '; ptr++; } - else + else if (!wrd->skip) { if (wrd->selected) { diff --git a/contrib/tsearch2/ts_cfg.h b/contrib/tsearch2/ts_cfg.h index 7bffdbcdd61..9b8a429a6a0 100644 --- a/contrib/tsearch2/ts_cfg.h +++ b/contrib/tsearch2/ts_cfg.h @@ -51,7 +51,8 @@ typedef struct in:1, replace:1, repeated:1, - unused:4, + skip:1, + unused:3, type:8, len:16; char *word; diff --git a/contrib/tsearch2/wparser_def.c b/contrib/tsearch2/wparser_def.c index 8bb4d3c7687..be189189da6 100644 --- a/contrib/tsearch2/wparser_def.c +++ b/contrib/tsearch2/wparser_def.c @@ -75,11 +75,11 @@ prsd_end(PG_FUNCTION_ARGS) #define COMPLEXTOKEN(x) ( (x)==5 || (x)==15 || (x)==16 || (x)==17 ) #define ENDPUNCTOKEN(x) ( (x)==12 ) - #define TS_IDIGNORE(x) ( (x)==13 || (x)==14 || (x)==12 || (x)==23 ) -#define HLIDIGNORE(x) ( (x)==5 || (x)==13 || (x)==15 || (x)==16 || (x)==17 ) +#define HLIDREPLACE(x) ( (x)==13 ) +#define HLIDSKIP(x) ( (x)==5 || (x)==15 || (x)==16 || (x)==17 ) #define HTMLHLIDIGNORE(x) ( (x)==5 || (x)==15 || (x)==16 || (x)==17 ) -#define NONWORDTOKEN(x) ( (x)==12 || HLIDIGNORE(x) ) +#define NONWORDTOKEN(x) ( (x)==12 || HLIDREPLACE(x) || HLIDSKIP(x) ) #define NOENDTOKEN(x) ( NONWORDTOKEN(x) || (x)==7 || (x)==8 || (x)==20 || (x)==21 || (x)==22 || TS_IDIGNORE(x) ) typedef struct @@ -369,13 +369,15 @@ prsd_headline(PG_FUNCTION_ARGS) prs->words[i].selected = 1; if (highlight == 0) { - if (HLIDIGNORE(prs->words[i].type)) + if (HLIDREPLACE(prs->words[i].type)) prs->words[i].replace = 1; + else if (HLIDSKIP(prs->words[i].type)) + prs->words[i].skip = 1; } else { if (HTMLHLIDIGNORE(prs->words[i].type)) - prs->words[i].replace = 1; + prs->words[i].skip = 1; } prs->words[i].in = (prs->words[i].repeated) ? 0 : 1;