[PATCH 1/3] fc-lang: gracefully handle the case where the last language initial is < 'z'

Florent Rougon <[email protected]>
Newsgroups gmane.comp.fonts.fontconfig
Message-ID <a238c2b176b19d61be1a57ebd1e28498136352b2.1496823343.git.f.rougon@free.fr>
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.
---
 fc-lang/fc-lang.c | 3 +++
 1 file changed, 3 insertions(+)

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;
-- 
2.11.0

_______________________________________________
Fontconfig mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/fontconfig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.