summaryrefslogtreecommitdiff
path: root/pango/pango-script.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2004-07-14 21:47:36 +0000
committerOwen Taylor <otaylor@src.gnome.org>2004-07-14 21:47:36 +0000
commit731bd56653de86e2298cd8b04c320fca82bb2f9f (patch)
tree1cfeead4942555339a2dfa14042b22991f3e5584 /pango/pango-script.c
parent2d0ca3423d011d36507d652ca71445a3daad1055 (diff)
downloadpango-731bd56653de86e2298cd8b04c320fca82bb2f9f.tar.gz
Fix problem when we only figured out latin script for 'en' not for
Wed Jul 14 17:42:49 2004 Owen Taylor <otaylor@redhat.com> * pango/pango-script.c (pango_language_includes_script): Fix problem when we only figured out latin script for 'en' not for 'en-us'. Fix reversed arguments to bsearch.
Diffstat (limited to 'pango/pango-script.c')
-rw-r--r--pango/pango-script.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/pango/pango-script.c b/pango/pango-script.c
index b5045c42..68814984 100644
--- a/pango/pango-script.c
+++ b/pango/pango-script.c
@@ -351,15 +351,38 @@ pango_script_iter_next (PangoScriptIter *iter)
#include "pango-script-lang-table.h"
+/* The fact that this comparison function works is dependent
+ * on a property of the pango_script_lang_table which accidental rather
+ * than inherent.
+ *
+ * The property is if we take any element in the table and suffix it
+ * <elem>-<suffix> then that must strcmp() between any elements
+ * preceding the element in the table and any element following in the
+ * table. So, if we had something like:
+ *
+ * 'zh'
+ *' zh-cn'
+ *
+ * in the table we would have a problem since 'zh-tw' follows 'zh-cn'.
+ * On the other hand:
+ *
+ * 'zh'
+ * 'zha'
+ *
+ * Works because 'zh-tw' precedes 'zha'.
+ */
static int
script_for_lang_compare (gconstpointer key,
gconstpointer member)
{
- const char *lang = key;
+ PangoLanguage *lang = (PangoLanguage *)key;
const PangoScriptForLang *script_for_lang = member;
-
- return strcmp (lang,
- pango_language_to_string (script_for_lang->lang));
+
+ if (pango_language_matches (lang, script_for_lang->lang))
+ return 0;
+ else
+ return strcmp (pango_language_to_string (lang),
+ script_for_lang->lang);
}
/**
@@ -398,8 +421,8 @@ pango_language_includes_script (PangoLanguage *language,
*/
script_for_lang = bsearch (pango_language_to_string (language),
pango_script_for_lang,
- sizeof (PangoScriptForLang),
G_N_ELEMENTS (pango_script_for_lang),
+ sizeof (PangoScriptForLang),
script_for_lang_compare);
if (!script_for_lang)
return TRUE;