summaryrefslogtreecommitdiff
path: root/src/fclang.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2017-08-03 11:02:32 +0100
committerBehdad Esfahbod <behdad@behdad.org>2017-08-03 11:17:35 +0100
commit064440d59797b1158badfb9144f3188cda11a791 (patch)
treef8de81442aec60619ad2f3d9dde44bc9ddbd8991 /src/fclang.c
parentcc8442dec85e9d416436d19eeae1783f2d3008f0 (diff)
downloadfontconfig-064440d59797b1158badfb9144f3188cda11a791.tar.gz
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.
Diffstat (limited to 'src/fclang.c')
-rw-r--r--src/fclang.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/fclang.c b/src/fclang.c
index 8418b46..1eee8ef 100644
--- a/src/fclang.c
+++ b/src/fclang.c
@@ -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;
}
}