Skip to content

Commit c7faf45

Browse files
committed
Add more strict check of stop and non-recognized words,
allow only recognized words in thezaurus configuration file.
1 parent d77df81 commit c7faf45

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

contrib/tsearch2/dict_thesaurus.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/contrib/tsearch2/dict_thesaurus.c,v 1.1 2006/05/31 14:05:31 teodor Exp $ */
1+
/* $PostgreSQL: pgsql/contrib/tsearch2/dict_thesaurus.c,v 1.2 2006/06/02 15:35:42 teodor Exp $ */
22

33
/*
44
* thesaurus
@@ -330,8 +330,12 @@ compileTheLexeme(DictThesaurus *d) {
330330
);
331331

332332
if ( !(ptr && ptr->lexeme) ) {
333+
if ( !ptr )
334+
elog(NOTICE,"Thesaurus: word '%s' isn't recognized by subdictionary", d->wrds[i].lexeme);
335+
else
336+
elog(ERROR,"Thesaurus: word '%s' is recognized as stop-word, assign any stop-word", d->wrds[i].lexeme);
337+
333338
newwrds = addCompiledLexeme( newwrds, &nnw, &tnm, NULL, d->wrds[i].entries, 0);
334-
elog(NOTICE,"Thesaurus: word '%s' isn't recognized by subdictionary or it's a stop-word, assign any non-recognized word", d->wrds[i].lexeme);
335339
} else {
336340
while( ptr->lexeme ) {
337341
TSLexeme *remptr = ptr+1;
@@ -420,7 +424,7 @@ compileTheSubstitute(DictThesaurus *d) {
420424
);
421425

422426
reml = lexized;
423-
if ( lexized ) {
427+
if ( lexized && lexized->lexeme ) {
424428
int toset = (lexized->lexeme && outptr != d->subst[i].res ) ? (outptr - d->subst[i].res) : -1;
425429

426430
while( lexized->lexeme ) {
@@ -443,13 +447,18 @@ compileTheSubstitute(DictThesaurus *d) {
443447

444448
if ( toset > 0)
445449
d->subst[i].res[toset].flags |= TSL_ADDPOS;
450+
} else {
451+
elog(NOTICE,"Thesaurus: word '%s' isn't recognized by subdictionary or it's a stop-word, ignored", inptr->lexeme);
446452
}
447453

448454
if ( inptr->lexeme )
449455
free( inptr->lexeme );
450456
inptr++;
451457
}
452458

459+
if ( outptr == d->subst[i].res )
460+
elog(ERROR,"Thesaurus: all words in subsitution aren't recognized by subdictionary");
461+
453462
d->subst[i].reslen = outptr - d->subst[i].res;
454463

455464
free(rem);

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