diff options
author | Teodor Sigaev | 2007-03-26 12:25:35 +0000 |
---|---|---|
committer | Teodor Sigaev | 2007-03-26 12:25:35 +0000 |
commit | debb3aa8e9d4a4ae78894566af85679edd9232ba (patch) | |
tree | 67e11817c7437b63d5b21b640b25e07eb211d422 | |
parent | a6fbd2f12aac3c649320dff2dd336732c60495fa (diff) |
Fix stopword and synonym files parsing bug in MSVC build, per report from
Magnus Hagander. Also, now it ignores space symbol after stopwords.
-rw-r--r-- | contrib/tsearch2/dict_syn.c | 9 | ||||
-rw-r--r-- | contrib/tsearch2/stopword.c | 8 |
2 files changed, 9 insertions, 8 deletions
diff --git a/contrib/tsearch2/dict_syn.c b/contrib/tsearch2/dict_syn.c index 1e3a71cee1..cf730ed88d 100644 --- a/contrib/tsearch2/dict_syn.c +++ b/contrib/tsearch2/dict_syn.c @@ -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; diff --git a/contrib/tsearch2/stopword.c b/contrib/tsearch2/stopword.c index d8bb54aca3..582932e84b 100644 --- a/contrib/tsearch2/stopword.c +++ b/contrib/tsearch2/stopword.c @@ -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) |