|
7 | 7 | *
|
8 | 8 | *
|
9 | 9 | * IDENTIFICATION
|
10 |
| - * $PostgreSQL: pgsql/src/backend/tsearch/dict_synonym.c,v 1.3 2007/08/2500:03:59 tgl Exp $ |
| 10 | + * $PostgreSQL: pgsql/src/backend/tsearch/dict_synonym.c,v 1.4 2007/08/2502:29:45 tgl Exp $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -120,30 +120,31 @@ dsynonym_init(PG_FUNCTION_ARGS)
|
120 | 120 | /* Empty line */
|
121 | 121 | gotoskipline;
|
122 | 122 | }
|
123 |
| -*end='\0'; |
124 |
| -if (end >=line+strlen(line)) |
| 123 | +if (*end=='\0') |
125 | 124 | {
|
126 | 125 | /* A line with only one word. Ignore silently. */
|
127 | 126 | gotoskipline;
|
128 | 127 | }
|
| 128 | +*end='\0'; |
129 | 129 |
|
130 | 130 | starto=findwrd(end+1,&end);
|
131 | 131 | if (!starto)
|
132 | 132 | {
|
133 |
| -/* A line with only one word. Ignore silently. */ |
| 133 | +/* A line with only one word (+whitespace). Ignore silently. */ |
134 | 134 | gotoskipline;
|
135 | 135 | }
|
136 | 136 | *end='\0';
|
137 | 137 |
|
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 |
139 | 140 | * word on the line, with a \0 terminator at the end of both words.
|
140 | 141 | */
|
141 | 142 |
|
142 |
| -if (cur==d->len) |
| 143 | +if (cur>=d->len) |
143 | 144 | {
|
144 | 145 | if (d->len==0)
|
145 | 146 | {
|
146 |
| -d->len=16; |
| 147 | +d->len=64; |
147 | 148 | d->syn= (Syn*)palloc(sizeof(Syn)*d->len);
|
148 | 149 | }
|
149 | 150 | else
|
@@ -180,7 +181,8 @@ dsynonym_lexize(PG_FUNCTION_ARGS)
|
180 | 181 | *found;
|
181 | 182 | TSLexeme*res;
|
182 | 183 |
|
183 |
| -if (len <=0) |
| 184 | +/* note: d->len test protects against Solaris bsearch-of-no-items bug */ |
| 185 | +if (len <=0||d->len <=0) |
184 | 186 | PG_RETURN_POINTER(NULL);
|
185 | 187 |
|
186 | 188 | key.in=lowerstr_with_len(in,len);
|
|