Skip to content

Commit 53ef36c

Browse files
committed
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.
1 parent 21c27af commit 53ef36c

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/backend/tsearch/spell.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/tsearch/spell.c,v 1.3 2007/09/10 10:39:56 teodor Exp $
10+
* $PostgreSQL: pgsql/src/backend/tsearch/spell.c,v 1.4 2007/09/10 20:27:12 teodor Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -647,12 +647,10 @@ NIImportOOAffixes(IspellDict * Conf, const char *filename)
647647
goto nextline;
648648
flag = *sflag;
649649
isSuffix = (STRNCMP(ptype, "sfx") == 0) ? true : false;
650-
pfind = lowerstr_ctx(find);
651-
if (t_iseq(find, 'y'))
650+
if (t_iseq(find, 'y') || t_iseq(find, 'Y'))
652651
flagflags = FF_CROSSPRODUCT;
653652
else
654653
flagflags = 0;
655-
pfree(pfind);
656654
}
657655
else
658656
{
@@ -666,7 +664,7 @@ NIImportOOAffixes(IspellDict * Conf, const char *filename)
666664
if ((ptr = strchr(prepl, '/')) != NULL)
667665
{
668666
*ptr = '\0';
669-
ptr++;
667+
ptr = repl + (ptr-prepl) + 1;
670668
while (*ptr)
671669
{
672670
aflg |= Conf->flagval[(unsigned int) *ptr];
@@ -704,8 +702,7 @@ NIImportOOAffixes(IspellDict * Conf, const char *filename)
704702
void
705703
NIImportAffixes(IspellDict * Conf, const char *filename)
706704
{
707-
char str[BUFSIZ],
708-
*pstr = NULL;
705+
char *pstr = NULL;
709706
char mask[BUFSIZ];
710707
char find[BUFSIZ];
711708
char repl[BUFSIZ];
@@ -742,13 +739,15 @@ NIImportAffixes(IspellDict * Conf, const char *filename)
742739

743740
if (STRNCMP(pstr, "compoundwords") == 0)
744741
{
745-
s = findchar(str, 'l');
742+
s = findchar(pstr, 'l');
746743
if (s)
747744
{
745+
s = recoded + ( s-pstr ); /* we need non-lowercased string */
748746
while (*s && !t_isspace(s))
749747
s++;
750748
while (*s && t_isspace(s))
751749
s++;
750+
752751
if (*s && pg_mblen(s) == 1)
753752
{
754753
Conf->flagval[(unsigned int) *s] = FF_COMPOUNDFLAG;
@@ -774,7 +773,7 @@ NIImportAffixes(IspellDict * Conf, const char *filename)
774773
}
775774
if (STRNCMP(pstr, "flag") == 0)
776775
{
777-
s = str + 4;
776+
s = recoded + 4; /* we need non-lowercased string */
778777
flagflags = 0;
779778

780779
while (*s && t_isspace(s))
@@ -1333,7 +1332,7 @@ addToResult(char **forms, char **cur, char *word)
13331332
}
13341333

13351334
static char **
1336-
NormalizeSubWord(IspellDict * Conf, char *word, char flag)
1335+
NormalizeSubWord(IspellDict * Conf, char *word, int flag)
13371336
{
13381337
AffixNodeData *suffix = NULL,
13391338
*prefix = NULL;

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