diff options
author | Teodor Sigaev <teodor@sigaev.ru> | 2016-03-11 19:47:50 +0300 |
---|---|---|
committer | Teodor Sigaev <teodor@sigaev.ru> | 2016-03-11 19:47:50 +0300 |
commit | 8829af47ef63d3c484f2e1f97a85a7a76b1baba6 (patch) | |
tree | ca8768811198451f63d4bf2307db710a2792d442 /src | |
parent | a9eb6c83efd258bb7a658fefa0074e0e65efd673 (diff) | |
download | postgresql-8829af47ef63d3c484f2e1f97a85a7a76b1baba6.tar.gz postgresql-8829af47ef63d3c484f2e1f97a85a7a76b1baba6.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/tsearch/spell.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/backend/tsearch/spell.c b/src/backend/tsearch/spell.c index 20097275d0f..304504e7d0c 100644 --- a/src/backend/tsearch/spell.c +++ b/src/backend/tsearch/spell.c @@ -1465,6 +1465,12 @@ MergeAffix(IspellDict *Conf, int a1, int a2) { char **ptr; + /* Do not merge affix flags if one of affix flags is empty */ + if (*Conf->AffixData[a1] == '\0') + return a2; + else if (*Conf->AffixData[a2] == '\0') + return a1; + while (Conf->nAffixData + 1 >= Conf->lenAffixData) { Conf->lenAffixData *= 2; @@ -1473,10 +1479,20 @@ MergeAffix(IspellDict *Conf, int a1, int a2) } ptr = Conf->AffixData + Conf->nAffixData; - *ptr = cpalloc(strlen(Conf->AffixData[a1]) + - strlen(Conf->AffixData[a2]) + - 1 /* space */ + 1 /* \0 */ ); - sprintf(*ptr, "%s %s", Conf->AffixData[a1], Conf->AffixData[a2]); + if (Conf->flagMode == FM_NUM) + { + *ptr = cpalloc(strlen(Conf->AffixData[a1]) + + strlen(Conf->AffixData[a2]) + + 1 /* comma */ + 1 /* \0 */ ); + sprintf(*ptr, "%s,%s", Conf->AffixData[a1], Conf->AffixData[a2]); + } + else + { + *ptr = cpalloc(strlen(Conf->AffixData[a1]) + + strlen(Conf->AffixData[a2]) + + 1 /* \0 */ ); + sprintf(*ptr, "%s%s", Conf->AffixData[a1], Conf->AffixData[a2]); + } ptr++; *ptr = NULL; Conf->nAffixData++; |