Commit 064440d5 authored by Behdad Esfahbod's avatar Behdad Esfahbod

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.
parent cc8442de
......@@ -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;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment