FcLangSetCompare(): fix bug when two charsets come from different "buckets"

In fcLangCountrySets, it may happen that two charsets for the same
language but different territories are found in different FcChar32
"buckets" (different "columns" on the same line). This is currently the
case for the following pairs:

  mn-cn  and mn-mn
  pap-an and pap-aw

The FcLangSetCompare() code so far used to return FcLangDifferentLang
instead of FcLangDifferentTerritory when comparing:

  an FcLangSet containing only mn-cn with one containing only mn-mn

or

  an FcLangSet containing only pap-an with one containing only pap-aw

This commit fixes this problem.
This commit is contained in:
Florent Rougon 2017-06-08 09:34:53 +02:00 committed by Akira TAGOH
parent 209619b1a6
commit b0a5b4b48e
1 changed files with 12 additions and 2 deletions

View File

@ -680,6 +680,7 @@ FcLangSetCompare (const FcLangSet *lsa, const FcLangSet *lsb)
{
int i, j, count;
FcLangResult best, r;
FcChar32 aInCountrySet, bInCountrySet;
count = FC_MIN (lsa->map_size, lsb->map_size);
count = FC_MIN (NUM_LANG_SET_MAP, count);
@ -688,13 +689,22 @@ FcLangSetCompare (const FcLangSet *lsa, const FcLangSet *lsb)
return FcLangEqual;
best = FcLangDifferentLang;
for (j = 0; j < NUM_COUNTRY_SET; j++)
{
aInCountrySet = 0;
bInCountrySet = 0;
for (i = 0; i < count; i++)
if ((lsa->map[i] & fcLangCountrySets[j][i]) &&
(lsb->map[i] & fcLangCountrySets[j][i]))
{
aInCountrySet |= lsa->map[i] & fcLangCountrySets[j][i];
bInCountrySet |= lsb->map[i] & fcLangCountrySets[j][i];
if (aInCountrySet && bInCountrySet)
{
best = FcLangDifferentTerritory;
break;
}
}
}
if (lsa->extra)
{
r = FcLangSetCompareStrSet (lsb, lsa->extra);