]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix URL generation in headline. Only tag lexeme will be replaced by space.
authorTeodor Sigaev <teodor@sigaev.ru>
Thu, 15 Jan 2009 18:17:12 +0000 (18:17 +0000)
committerTeodor Sigaev <teodor@sigaev.ru>
Thu, 15 Jan 2009 18:17:12 +0000 (18:17 +0000)
Per http://archives.postgresql.org/pgsql-bugs/2008-12/msg00013.php

contrib/tsearch2/expected/tsearch2.out
contrib/tsearch2/ts_cfg.c
contrib/tsearch2/ts_cfg.h
contrib/tsearch2/wparser_def.c

index 78c12c52354f8de21d854ab436b79dfa33fdeb17..0fbb36e8b2b72ae313d6579549e5ba13f3f66cda 100644 (file)
@@ -2149,15 +2149,15 @@ ff-bg
 </body>
 </html>', 
 to_tsquery('sea&foo'), 'HighlightAll=true');
-                                                                                                              headline                                                                                                               
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+                                                                                                              headline                                                                                                              
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  
 <html>
 <!-- some comment -->
 <body>
 <b>Sea</b> view wow <u><b>foo</b> bar</u> <i>qq</i>
 <a href="http://www.google.com/foo.bar.html" target="_blank">YES &nbsp;</a>
- ff-bg
+ff-bg
 <script>
        document.write(15);
 </script>
index 1d5fef81370171489cec490a494651fe750ca917..ed1e3973fdbb2becb4d26220dc1a8922abfb06a9 100644 (file)
@@ -520,7 +520,7 @@ genhl(HLPRSTEXT * prs)
                                *ptr = ' ';
                                ptr++;
                        }
-                       else
+                       else if (!wrd->skip)
                        {
                                if (wrd->selected)
                                {
index e000233178d1e556029ba7f8a46e336644765124..325459ead617999eb08fd3f356558689118d7f86 100644 (file)
@@ -50,7 +50,8 @@ typedef struct
                                in:1,
                                replace:1,
                                repeated:1,
-                               unused:4,
+                               skip:1,
+                               unused:3,
                                type:8,
                                len:16;
        char       *word;
index 947c22fc5191b1d9e1e4609ea53c16b3fc955525..12318f02cead28f8775527e64cef242d5a31dbfe 100644 (file)
@@ -72,11 +72,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
@@ -366,13 +366,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;