From 3577ddfff213b02a04e8e159e232de4e99408f87 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 18 Dec 2012 12:10:33 +0000 Subject: [PATCH] fix e_intl_locale_parts_combine() usage to handle locales without regions SVN revision: 81241 --- src/bin/e_intl.c | 25 +++++++++++++++-------- src/modules/conf_intl/e_int_config_intl.c | 7 +++++-- src/modules/wizard/page_010.c | 10 +++++---- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/bin/e_intl.c b/src/bin/e_intl.c index 88e3424ed..29f96aca1 100644 --- a/src/bin/e_intl.c +++ b/src/bin/e_intl.c @@ -880,7 +880,7 @@ _e_intl_locale_validate(const char *locale) Eina_List *all_locales; E_Locale_Parts *locale_parts; char *locale_next; - char *locale_lr; + char *locale_lr = NULL; char *locale_cs_canonic; int found; @@ -889,9 +889,13 @@ _e_intl_locale_validate(const char *locale) locale_parts = e_intl_locale_parts_get(locale); /* Gather the search information */ - locale_lr = - e_intl_locale_parts_combine(locale_parts, - E_INTL_LOC_LANG | E_INTL_LOC_REGION); + if (locale_parts) + { + if (locale_parts->mask & E_INTL_LOC_REGION) + locale_lr = e_intl_locale_parts_combine(locale_parts, E_INTL_LOC_LANG | E_INTL_LOC_REGION); + else if (locale_parts->lang) + locale_lr = strdup(locale_parts->lang); + } if (!locale_lr) { /* Not valid locale, maybe its an alias */ @@ -915,12 +919,17 @@ _e_intl_locale_validate(const char *locale) if (found == 0) { E_Locale_Parts *locale_parts_next; - char *locale_lr_next; + char *locale_lr_next = NULL; locale_parts_next = e_intl_locale_parts_get(locale_next); - locale_lr_next = e_intl_locale_parts_combine(locale_parts_next, - E_INTL_LOC_LANG | E_INTL_LOC_REGION); - + if (locale_parts_next) + { + if (locale_parts_next->mask & E_INTL_LOC_REGION) + locale_lr_next = e_intl_locale_parts_combine(locale_parts_next, + E_INTL_LOC_LANG | E_INTL_LOC_REGION); + else if (locale_parts_next->lang) + locale_lr_next = strdup(locale_parts_next->lang); + } if ((locale_parts) && (locale_lr_next) && (!strcmp(locale_lr, locale_lr_next))) { diff --git a/src/modules/conf_intl/e_int_config_intl.c b/src/modules/conf_intl/e_int_config_intl.c index 838d0f34d..b597be4f9 100644 --- a/src/modules/conf_intl/e_int_config_intl.c +++ b/src/modules/conf_intl/e_int_config_intl.c @@ -1047,8 +1047,11 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf locale_parts = e_intl_locale_parts_get(cfdata->cur_language); if (locale_parts) { - cur_sig_loc = e_intl_locale_parts_combine(locale_parts, - E_INTL_LOC_LANG | E_INTL_LOC_REGION); + if (locale_parts->mask & E_INTL_LOC_REGION) + cur_sig_loc = e_intl_locale_parts_combine(locale_parts, + E_INTL_LOC_LANG | E_INTL_LOC_REGION); + else if (locale_parts->lang) + cur_sig_loc = strdup(locale_parts->lang); e_intl_locale_parts_free(locale_parts); } diff --git a/src/modules/wizard/page_010.c b/src/modules/wizard/page_010.c index 07cb754d0..51a8fd7a8 100644 --- a/src/modules/wizard/page_010.c +++ b/src/modules/wizard/page_010.c @@ -101,11 +101,13 @@ wizard_page_init(E_Wizard_Page *pg __UNUSED__, Eina_Bool *need_xdg_desktops __UN locale_parts = e_intl_locale_parts_get(line); if (locale_parts) { - char *basic_language; + char *basic_language = NULL; - basic_language = - e_intl_locale_parts_combine - (locale_parts, E_INTL_LOC_LANG | E_INTL_LOC_REGION); + if (locale_parts->mask & E_INTL_LOC_REGION) + basic_language = e_intl_locale_parts_combine(locale_parts, + E_INTL_LOC_LANG | E_INTL_LOC_REGION); + else if (locale_parts->lang) + basic_language = strdup(locale_parts->lang); if (basic_language) { int i = 0;