Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit debb3aa

Browse files
committed
Fix stopword and synonym files parsing bug in MSVC build, per report from
Magnus Hagander. Also, now it ignores space symbol after stopwords.
1 parent a6fbd2f commit debb3aa

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

contrib/tsearch2/dict_syn.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/contrib/tsearch2/dict_syn.c,v 1.12 2007/02/08 11:10:26 petere Exp $ */
1+
/* $PostgreSQL: pgsql/contrib/tsearch2/dict_syn.c,v 1.13 2007/03/26 12:25:35 teodor Exp $ */
22

33
/*
44
* ISpell interface
@@ -40,7 +40,7 @@ findwrd(char *in, char **end)
4040
while (*in && isspace((unsigned char) *in))
4141
in++;
4242

43-
if (!in)
43+
if (*in=='\0')
4444
return NULL;
4545
start = in;
4646

@@ -103,10 +103,7 @@ syn_init(PG_FUNCTION_ARGS)
103103

104104
while (fgets(buf, sizeof(buf), fin))
105105
{
106-
slen = strlen(buf) - 1;
107-
buf[slen] = '\0';
108-
if (*buf == '\0')
109-
continue;
106+
pg_verifymbstr(buf, strlen(buf), false);
110107
if (cur == d->len)
111108
{
112109
d->len = (d->len) ? 2 * d->len : 16;

contrib/tsearch2/stopword.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,13 @@ readstoplist(text *in, StopList * s)
4747

4848
while (fgets(buf, sizeof(buf), hin))
4949
{
50-
buf[strlen(buf) - 1] = '\0';
50+
pbuf = buf;
51+
while( !isspace( *pbuf ) )
52+
pbuf++;
53+
*pbuf = '\0';
54+
5155
pg_verifymbstr(buf, strlen(buf), false);
52-
if (*buf == '\0')
56+
if (*buf == '\0' || *buf=='\n' || *buf=='\r')
5357
continue;
5458

5559
if (s->len >= reallen)

0 commit comments

Comments
 (0)