Ignore 'und-' prefix for in FcLangCompare

See https://bugs.freedesktop.org/show_bug.cgi?id=94551#c54

For example, matching for :lang=und-zsye matches emoji font, but searching
for :lang=und-xyz wouldn't match an emoji font anymore.  Neither does :lang-und.
This commit is contained in:
Behdad Esfahbod 2017-08-03 11:02:32 +01:00
parent cc8442dec8
commit 064440d597
1 changed files with 20 additions and 3 deletions

View File

@ -351,6 +351,13 @@ FcLangCompare (const FcChar8 *s1, const FcChar8 *s2)
{
FcChar8 c1, c2;
FcLangResult result = FcLangDifferentLang;
FcChar8 *s1_orig = s1;
FcBool is_und;
is_und = FcToLower (s1[0]) == 'u' &&
FcToLower (s1[1]) == 'n' &&
FcToLower (s1[2]) == 'd' &&
FcLangEnd (s1[3]);
for (;;)
{
@ -361,14 +368,24 @@ FcLangCompare (const FcChar8 *s1, const FcChar8 *s2)
c2 = FcToLower (c2);
if (c1 != c2)
{
if (FcLangEnd (c1) && FcLangEnd (c2))
if (!is_und && FcLangEnd (c1) && FcLangEnd (c2))
result = FcLangDifferentTerritory;
return result;
}
else if (!c1)
return FcLangEqual;
{
return is_und ? result : FcLangEqual;
}
else if (c1 == '-')
result = FcLangDifferentTerritory;
{
if (!is_und)
result = FcLangDifferentTerritory;
}
/* If we parsed past "und-", then do not consider it undefined anymore,
* as there's *something* specified. */
if (is_und && s1 - s1_orig == 4)
is_und = FcFalse;
}
}