typedef struct _MimTable
{
- gchar *lang_in_locale;
+ int lang_in_locale;
+ gchar *encoded_lang;
gchar *lang;
gchar *name;
MSymbol symlang;
result = 0;
else
{
- if (t1->lang_in_locale)
- {
- if (t2->lang_in_locale)
- result = strcoll (t1->lang_in_locale, t2->lang_in_locale);
- else
- result = -1;
- }
- else if (t2->lang_in_locale)
- result = 1;
- else if (t1->lang)
- {
- if (t2->lang)
- result = strcmp (t1->lang, t2->lang);
- else
- result = -1;
- }
- else if (t2->lang)
- result = 1;
+ if (t1->lang_in_locale != t2->lang_in_locale)
+ return (t1->lang_in_locale ? -1 : 1);
+ if ((! t1->encoded_lang) != (! t2->encoded_lang))
+ return (t1->encoded_lang ? -1 : 1);
+ if (t1->encoded_lang)
+ result = strcoll (t1->encoded_lang, t2->encoded_lang);
else
- result = 0;
+ result = strcmp (t1->lang, t2->lang);
}
return (result ? result : strcmp (t1->name, t2->name));
imtable[i].symlang = tag[1];
imtable[i].symname = tag[2];
imtable[i].name = msymbol_name (tag[2]);
- imtable[i].lang = imtable[i].lang_in_locale = NULL;
+ imtable[i].lang = imtable[i].encoded_lang = NULL;
+ imtable[i].lang_in_locale = 0;
if (tag[1] != Mt)
{
- pl = mlanguage_name_list (tag[1], Mnil);
- if (! pl)
- pl = mlanguage_name_list (tag[1], Meng);
+ pl = mlanguage_name_list (tag[1], Mnil, Mnil, Mnil);
+ if (pl)
+ imtable[i].lang_in_locale = 1;
+ else
+ pl = mlanguage_name_list (tag[1], Meng, Mnil, Mnil);
if (pl)
{
MText *mt = mplist_value (pl);
nbytes = mconv_encode (converter, mt);
if (converter->result == MCONVERSION_RESULT_SUCCESS)
{
- conv_buf[nbytes] = '\0';
- imtable[i].lang_in_locale = alloca (nbytes + 1);
- if (imtable[i].lang_in_locale)
- memcpy (imtable[i].lang_in_locale, conv_buf,
- nbytes + 1);
+ imtable[i].encoded_lang = alloca (nbytes + 1);
+ if (imtable[i].encoded_lang)
+ {
+ memcpy (imtable[i].encoded_lang, conv_buf, nbytes);
+ imtable[i].encoded_lang[nbytes] = '\0';
+ }
}
}
else if (locale_is_utf8)
- imtable[i].lang_in_locale
+ imtable[i].encoded_lang
= mtext_data (mt, NULL, NULL, NULL, NULL);
imtable[i].lang = mtext_data (mt, NULL, NULL, NULL, NULL);
}