|
10 | 10 | #defineMAX_NORM 1024
|
11 | 11 | #defineMAXNORMLEN 256
|
12 | 12 |
|
| 13 | +#defineERRSTRSIZE1024 |
| 14 | + |
13 | 15 | #defineSTRNCASECMP(x,y)pg_strncasecmp(x, y, strlen(y))
|
14 | 16 | #defineGETWCHAR(W,L,N,T) ( ((uint8*)(W))[ ((T)==FF_PREFIX) ? (N) : ( (L) - 1 - (N) ) ] )
|
15 | 17 | #defineGETCHAR(A,N,T) GETWCHAR( (A)->repl, (A)->replen, N, T )
|
@@ -250,30 +252,35 @@ NIAddAffix(IspellDict * Conf, int flag, char flagflags, const char *mask, const
|
250 | 252 | {
|
251 | 253 | Conf->Affix[Conf->naffixes].issimple=1;
|
252 | 254 | Conf->Affix[Conf->naffixes].isregis=0;
|
253 |
| -*(Conf->Affix[Conf->naffixes].mask)='\0'; |
| 255 | +Conf->Affix[Conf->naffixes].mask=strdup(""); |
254 | 256 | }
|
255 | 257 | elseif (RS_isRegis(mask))
|
256 | 258 | {
|
257 | 259 | Conf->Affix[Conf->naffixes].issimple=0;
|
258 | 260 | Conf->Affix[Conf->naffixes].isregis=1;
|
259 |
| -strcpy(Conf->Affix[Conf->naffixes].mask,mask); |
| 261 | +Conf->Affix[Conf->naffixes].mask=strdup(mask); |
260 | 262 | }
|
261 | 263 | else
|
262 | 264 | {
|
263 | 265 | Conf->Affix[Conf->naffixes].issimple=0;
|
264 | 266 | Conf->Affix[Conf->naffixes].isregis=0;
|
| 267 | +Conf->Affix[Conf->naffixes].mask= (char*)malloc(strlen(mask)+2 ); |
265 | 268 | if (type==FF_SUFFIX)
|
266 | 269 | sprintf(Conf->Affix[Conf->naffixes].mask,"%s$",mask);
|
267 | 270 | else
|
268 | 271 | sprintf(Conf->Affix[Conf->naffixes].mask,"^%s",mask);
|
269 | 272 | }
|
| 273 | +MEMOUT(Conf->Affix[Conf->naffixes].mask); |
| 274 | + |
270 | 275 | Conf->Affix[Conf->naffixes].compile=1;
|
271 | 276 | Conf->Affix[Conf->naffixes].flagflags=flagflags;
|
272 | 277 | Conf->Affix[Conf->naffixes].flag=flag;
|
273 | 278 | Conf->Affix[Conf->naffixes].type=type;
|
274 | 279 |
|
275 |
| -strcpy(Conf->Affix[Conf->naffixes].find,find); |
276 |
| -strcpy(Conf->Affix[Conf->naffixes].repl,repl); |
| 280 | +Conf->Affix[Conf->naffixes].find=strdup(find); |
| 281 | +MEMOUT(Conf->Affix[Conf->naffixes].find); |
| 282 | +Conf->Affix[Conf->naffixes].repl=strdup(repl); |
| 283 | +MEMOUT(Conf->Affix[Conf->naffixes].repl); |
277 | 284 | Conf->Affix[Conf->naffixes].replen=strlen(repl);
|
278 | 285 | Conf->naffixes++;
|
279 | 286 | return (0);
|
@@ -794,12 +801,9 @@ CheckAffix(const char *word, size_t len, AFFIX * Affix, char flagflags, char *ne
|
794 | 801 | pfree(mask);
|
795 | 802 | if (err)
|
796 | 803 | {
|
797 |
| -/* |
798 |
| - * regerror(err, &(Affix->reg.regex), regerrstr, |
799 |
| - * ERRSTRSIZE); |
800 |
| - */ |
801 |
| -pg_regfree(&(Affix->reg.regex)); |
802 |
| -return (NULL); |
| 804 | +charregerrstr[ERRSTRSIZE]; |
| 805 | +pg_regerror(err,&(Affix->reg.regex),regerrstr,ERRSTRSIZE); |
| 806 | +elog(ERROR,"Regex error in '%s': %s",Affix->mask,regerrstr); |
803 | 807 | }
|
804 | 808 | Affix->compile=0;
|
805 | 809 | }
|
@@ -1239,6 +1243,9 @@ NIFree(IspellDict * Conf)
|
1239 | 1243 | else
|
1240 | 1244 | pg_regfree(&(Affix[i].reg.regex));
|
1241 | 1245 | }
|
| 1246 | +free(Affix[i].mask); |
| 1247 | +free(Affix[i].find); |
| 1248 | +free(Affix[i].repl); |
1242 | 1249 | }
|
1243 | 1250 | if (Conf->Spell)
|
1244 | 1251 | {
|
|