Skip to content

Commit 8829af4

Browse files
committed
Fix merge affixes for numeric ones
Some dictionaries have duplicated base words with different affix set, we just merge that sets into one set. But previously merging of sets of affixes was actually a concatenation of strings but it's wrong for numeric representation of affixes because such representation uses comma to separate affixes. Author: Artur Zakirov
1 parent a9eb6c8 commit 8829af4

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/backend/tsearch/spell.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,6 +1465,12 @@ MergeAffix(IspellDict *Conf, int a1, int a2)
14651465
{
14661466
char **ptr;
14671467

1468+
/* Do not merge affix flags if one of affix flags is empty */
1469+
if (*Conf->AffixData[a1] == '\0')
1470+
return a2;
1471+
else if (*Conf->AffixData[a2] == '\0')
1472+
return a1;
1473+
14681474
while (Conf->nAffixData + 1 >= Conf->lenAffixData)
14691475
{
14701476
Conf->lenAffixData *= 2;
@@ -1473,10 +1479,20 @@ MergeAffix(IspellDict *Conf, int a1, int a2)
14731479
}
14741480

14751481
ptr = Conf->AffixData + Conf->nAffixData;
1476-
*ptr = cpalloc(strlen(Conf->AffixData[a1]) +
1477-
strlen(Conf->AffixData[a2]) +
1478-
1 /* space */ + 1 /* \0 */ );
1479-
sprintf(*ptr, "%s %s", Conf->AffixData[a1], Conf->AffixData[a2]);
1482+
if (Conf->flagMode == FM_NUM)
1483+
{
1484+
*ptr = cpalloc(strlen(Conf->AffixData[a1]) +
1485+
strlen(Conf->AffixData[a2]) +
1486+
1 /* comma */ + 1 /* \0 */ );
1487+
sprintf(*ptr, "%s,%s", Conf->AffixData[a1], Conf->AffixData[a2]);
1488+
}
1489+
else
1490+
{
1491+
*ptr = cpalloc(strlen(Conf->AffixData[a1]) +
1492+
strlen(Conf->AffixData[a2]) +
1493+
1 /* \0 */ );
1494+
sprintf(*ptr, "%s%s", Conf->AffixData[a1], Conf->AffixData[a2]);
1495+
}
14801496
ptr++;
14811497
*ptr = NULL;
14821498
Conf->nAffixData++;

0 commit comments

Comments
 (0)