summaryrefslogtreecommitdiff
path: root/fc-lang
diff options
context:
space:
mode:
authorFlorent Rougon <f.rougon@free.fr>2017-06-06 11:10:18 +0200
committerAkira TAGOH <akira@tagoh.org>2017-06-09 13:48:00 +0900
commit02161ef2d6eda4e9c0ad068058d51a67a09af92f (patch)
treeaa02c07094d850ce8b4931cbb2536da1ecb6f214 /fc-lang
parentc37eeb8f1ff2cb8655a27545ca32cc50ab70e8d6 (diff)
downloadfontconfig-02161ef2d6eda4e9c0ad068058d51a67a09af92f.tar.gz
fc-lang: gracefully handle the case where the last language initial is < 'z'
FcLangSetIndex() contains code like this: low = fcLangCharSetRanges[firstChar - 'a'].begin; high = fcLangCharSetRanges[firstChar - 'a'].end; /* no matches */ if (low > high) The assumption behind this test didn't hold before this commit, unless there is at least one language name that starts with 'z' (which is thankfully the case in our world :-). If the last language name in lexicographic order starts for instance with 'x', this change ensures that fcLangCharSetRanges['y' - 'a'].begin and fcLangCharSetRanges['z' - 'a'].begin are equal to NUM_LANG_CHAR_SET, in order to make the above assumption correct in all cases.
Diffstat (limited to 'fc-lang')
-rw-r--r--fc-lang/fc-lang.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fc-lang/fc-lang.c b/fc-lang/fc-lang.c
index 38fc697..3443f51 100644
--- a/fc-lang/fc-lang.c
+++ b/fc-lang/fc-lang.c
@@ -561,6 +561,9 @@ main (int argc FC_UNUSED, char **argv)
while (setRangeChar <= c && c <= 'z')
setRangeStart[setRangeChar++ - 'a'] = i;
}
+ while (setRangeChar <= 'z') /* no language code starts with these letters */
+ setRangeStart[setRangeChar++ - 'a'] = i;
+
for (setRangeChar = 'a'; setRangeChar < 'z'; setRangeChar++)
setRangeEnd[setRangeChar - 'a'] = setRangeStart[setRangeChar+1-'a'] - 1;
setRangeEnd[setRangeChar - 'a'] = i - 1;