Fix recently introduced bugs about parsing ispell/hunspell files.

In most cases it cause because of unneeded lowercasing of flags.

Per experiment with regression checks with ispell dictionary.
This commit is contained in:
Teodor Sigaev 2007-09-10 20:27:12 +00:00
parent 21c27af65f
commit 53ef36cb4a
1 changed files with 9 additions and 10 deletions

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/tsearch/spell.c,v 1.3 2007/09/10 10:39:56 teodor Exp $ * $PostgreSQL: pgsql/src/backend/tsearch/spell.c,v 1.4 2007/09/10 20:27:12 teodor Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -647,12 +647,10 @@ NIImportOOAffixes(IspellDict * Conf, const char *filename)
goto nextline; goto nextline;
flag = *sflag; flag = *sflag;
isSuffix = (STRNCMP(ptype, "sfx") == 0) ? true : false; isSuffix = (STRNCMP(ptype, "sfx") == 0) ? true : false;
pfind = lowerstr_ctx(find); if (t_iseq(find, 'y') || t_iseq(find, 'Y'))
if (t_iseq(find, 'y'))
flagflags = FF_CROSSPRODUCT; flagflags = FF_CROSSPRODUCT;
else else
flagflags = 0; flagflags = 0;
pfree(pfind);
} }
else else
{ {
@ -666,7 +664,7 @@ NIImportOOAffixes(IspellDict * Conf, const char *filename)
if ((ptr = strchr(prepl, '/')) != NULL) if ((ptr = strchr(prepl, '/')) != NULL)
{ {
*ptr = '\0'; *ptr = '\0';
ptr++; ptr = repl + (ptr-prepl) + 1;
while (*ptr) while (*ptr)
{ {
aflg |= Conf->flagval[(unsigned int) *ptr]; aflg |= Conf->flagval[(unsigned int) *ptr];
@ -704,8 +702,7 @@ NIImportOOAffixes(IspellDict * Conf, const char *filename)
void void
NIImportAffixes(IspellDict * Conf, const char *filename) NIImportAffixes(IspellDict * Conf, const char *filename)
{ {
char str[BUFSIZ], char *pstr = NULL;
*pstr = NULL;
char mask[BUFSIZ]; char mask[BUFSIZ];
char find[BUFSIZ]; char find[BUFSIZ];
char repl[BUFSIZ]; char repl[BUFSIZ];
@ -742,13 +739,15 @@ NIImportAffixes(IspellDict * Conf, const char *filename)
if (STRNCMP(pstr, "compoundwords") == 0) if (STRNCMP(pstr, "compoundwords") == 0)
{ {
s = findchar(str, 'l'); s = findchar(pstr, 'l');
if (s) if (s)
{ {
s = recoded + ( s-pstr ); /* we need non-lowercased string */
while (*s && !t_isspace(s)) while (*s && !t_isspace(s))
s++; s++;
while (*s && t_isspace(s)) while (*s && t_isspace(s))
s++; s++;
if (*s && pg_mblen(s) == 1) if (*s && pg_mblen(s) == 1)
{ {
Conf->flagval[(unsigned int) *s] = FF_COMPOUNDFLAG; Conf->flagval[(unsigned int) *s] = FF_COMPOUNDFLAG;
@ -774,7 +773,7 @@ NIImportAffixes(IspellDict * Conf, const char *filename)
} }
if (STRNCMP(pstr, "flag") == 0) if (STRNCMP(pstr, "flag") == 0)
{ {
s = str + 4; s = recoded + 4; /* we need non-lowercased string */
flagflags = 0; flagflags = 0;
while (*s && t_isspace(s)) while (*s && t_isspace(s))
@ -1333,7 +1332,7 @@ addToResult(char **forms, char **cur, char *word)
} }
static char ** static char **
NormalizeSubWord(IspellDict * Conf, char *word, char flag) NormalizeSubWord(IspellDict * Conf, char *word, int flag)
{ {
AffixNodeData *suffix = NULL, AffixNodeData *suffix = NULL,
*prefix = NULL; *prefix = NULL;