Skip to content

Commit a13cefa

Browse files
committed
Fix synonym-dict breakage introduced in last patch :-(.
Minor other cleanups.
1 parent 93eab93 commit a13cefa

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/backend/tsearch/dict_synonym.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/tsearch/dict_synonym.c,v 1.3 2007/08/25 00:03:59 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/tsearch/dict_synonym.c,v 1.4 2007/08/25 02:29:45 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -120,30 +120,31 @@ dsynonym_init(PG_FUNCTION_ARGS)
120120
/* Empty line */
121121
goto skipline;
122122
}
123-
*end = '\0';
124-
if (end >= line + strlen(line))
123+
if (*end == '\0')
125124
{
126125
/* A line with only one word. Ignore silently. */
127126
goto skipline;
128127
}
128+
*end = '\0';
129129

130130
starto = findwrd(end + 1, &end);
131131
if (!starto)
132132
{
133-
/* A line with only one word. Ignore silently. */
133+
/* A line with only one word (+whitespace). Ignore silently. */
134134
goto skipline;
135135
}
136136
*end = '\0';
137137

138-
/* starti now points to the first word, and starto to the second
138+
/*
139+
* starti now points to the first word, and starto to the second
139140
* word on the line, with a \0 terminator at the end of both words.
140141
*/
141142

142-
if (cur == d->len)
143+
if (cur >= d->len)
143144
{
144145
if (d->len == 0)
145146
{
146-
d->len = 16;
147+
d->len = 64;
147148
d->syn = (Syn *) palloc(sizeof(Syn) * d->len);
148149
}
149150
else
@@ -180,7 +181,8 @@ dsynonym_lexize(PG_FUNCTION_ARGS)
180181
*found;
181182
TSLexeme *res;
182183

183-
if (len <= 0)
184+
/* note: d->len test protects against Solaris bsearch-of-no-items bug */
185+
if (len <= 0 || d->len <= 0)
184186
PG_RETURN_POINTER(NULL);
185187

186188
key.in = lowerstr_with_len(in, len);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy