]> granicus.if.org Git - postgresql/commitdiff
Fix stopword and synonym files parsing bug in MSVC build, per report from
authorTeodor Sigaev <teodor@sigaev.ru>
Mon, 26 Mar 2007 12:25:35 +0000 (12:25 +0000)
committerTeodor Sigaev <teodor@sigaev.ru>
Mon, 26 Mar 2007 12:25:35 +0000 (12:25 +0000)
Magnus Hagander. Also, now it ignores space symbol after stopwords.

contrib/tsearch2/dict_syn.c
contrib/tsearch2/stopword.c

index 1e3a71cee12b21632fca64035cc9d69d30f92a3a..cf730ed88d59d24d4855170e69e938af5453dcf1 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/contrib/tsearch2/dict_syn.c,v 1.12 2007/02/08 11:10:26 petere Exp $ */
+/* $PostgreSQL: pgsql/contrib/tsearch2/dict_syn.c,v 1.13 2007/03/26 12:25:35 teodor Exp $ */
 
 /*
  * ISpell interface
@@ -40,7 +40,7 @@ findwrd(char *in, char **end)
        while (*in && isspace((unsigned char) *in))
                in++;
 
-       if (!in)
+       if (*in=='\0')
                return NULL;
        start = in;
 
@@ -103,10 +103,7 @@ syn_init(PG_FUNCTION_ARGS)
 
        while (fgets(buf, sizeof(buf), fin))
        {
-               slen = strlen(buf) - 1;
-               buf[slen] = '\0';
-               if (*buf == '\0')
-                       continue;
+               pg_verifymbstr(buf, strlen(buf), false);
                if (cur == d->len)
                {
                        d->len = (d->len) ? 2 * d->len : 16;
index d8bb54aca31e036f146291acd5f0dc892f6b2ee5..582932e84be669235147e6790d98f9e1929a01a2 100644 (file)
@@ -47,9 +47,13 @@ readstoplist(text *in, StopList * s)
 
                while (fgets(buf, sizeof(buf), hin))
                {
-                       buf[strlen(buf) - 1] = '\0';
+                       pbuf = buf;
+                       while( !isspace( *pbuf ) )
+                               pbuf++;
+                       *pbuf = '\0';
+
                        pg_verifymbstr(buf, strlen(buf), false);
-                       if (*buf == '\0')
+                       if (*buf == '\0' || *buf=='\n' || *buf=='\r')
                                continue;
 
                        if (s->len >= reallen)