Enlightenment CVS committal Author : devilhorns Project : e17 Module : apps/e
Dir : e17/apps/e/src/bin Modified Files: e_intl.c Log Message: Lots of formatting fixes. There may still be more needed in this file. Do not print errs on C locale during shutdown. =================================================================== RCS file: /cvs/e/e17/apps/e/src/bin/e_intl.c,v retrieving revision 1.93 retrieving revision 1.94 diff -u -3 -r1.93 -r1.94 --- e_intl.c 25 Sep 2007 14:26:36 -0000 1.93 +++ e_intl.c 28 Sep 2007 16:36:13 -0000 1.94 @@ -107,7 +107,8 @@ if ((e_config->input_method) && (e_config->input_method[0] != 0)) e_intl_input_method_set(e_config->input_method); - _e_intl_exit_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _e_intl_cb_exit, NULL); + _e_intl_exit_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, + _e_intl_cb_exit, NULL); return 1; } @@ -171,7 +172,8 @@ else _e_intl_language = NULL; - if (!_e_intl_locale_validate(_e_intl_language_alias)) + if ((!_e_intl_locale_validate(_e_intl_language_alias)) || + (strcmp(_e_intl_language_alias, "C"))) { fprintf(stderr, "The locale '%s' cannot be found on your " "system. Please install this locale or try " @@ -201,7 +203,8 @@ locale_parts = e_intl_locale_parts_get(_e_intl_language_alias); /* If locale is C or some form of en don't report an error */ - if ( locale_parts == NULL && strcmp (_e_intl_language_alias, "C") ) + if ((locale_parts == NULL) && + (strcmp(_e_intl_language_alias, "C"))) { fprintf(stderr, "An error occurred setting your locale. \n\n" @@ -215,7 +218,8 @@ "Enlightenment will not be translated.\n", _e_intl_language_alias); } - else if ( locale_parts && locale_parts->lang && strcmp(locale_parts->lang, "en") ) + else if ((locale_parts) && (locale_parts->lang) && + (strcmp(locale_parts->lang, "en"))) { fprintf(stderr, "An error occurred setting your locale. \n\n" @@ -275,15 +279,13 @@ language = dir_languages->data; dir_languages = evas_list_remove_list(dir_languages, dir_languages); - if ( _e_intl_language_list_find(all_languages, language) || (strlen(language) > 2 && - !_e_intl_locale_validate(language))) + if ((_e_intl_language_list_find(all_languages, language)) || + (strlen(language) > 2) && (!_e_intl_locale_validate(language))) { free(language); } else - { - all_languages = evas_list_append(all_languages, language); - } + all_languages = evas_list_append(all_languages, language); } } @@ -383,9 +385,7 @@ } while (input_methods) - { - input_methods = evas_list_remove_list(input_methods, input_methods); - } + input_methods = evas_list_remove_list(input_methods, input_methods); /* System Path */ input_methods = _e_intl_imc_dir_scan(e_intl_imc_system_path_get()); @@ -396,9 +396,7 @@ } while (input_methods) - { - input_methods = evas_list_remove_list(input_methods, input_methods); - } + input_methods = evas_list_remove_list(input_methods, input_methods); return im_list; } @@ -427,7 +425,6 @@ _e_intl_imc_system_path = evas_stringshare_add(buf); } return _e_intl_imc_system_path; - } static int @@ -490,13 +487,13 @@ dir_list = e_path_dir_list_get(path_messages); /* For each directory in the path */ - for (next_dir = dir_list ; next_dir && !found ; next_dir = next_dir->next) + for (next_dir = dir_list; next_dir && !found; next_dir = next_dir->next) { E_Path_Dir *epd; epd = next_dir->data; /* Match canonicalized locale against each possible search */ - for (next_search = search_list ; next_search && !found ; next_search = next_search->next) + for (next_search = search_list; next_search && !found; next_search = next_search->next) { char *search_locale; char message_path[PATH_MAX]; @@ -504,7 +501,7 @@ search_locale = next_search->data; snprintf(message_path, sizeof(message_path), "%s/%s/LC_MESSAGES/%s.mo", epd->dir, search_locale, PACKAGE); - if (ecore_file_exists(message_path) && !ecore_file_is_dir(message_path)) + if ((ecore_file_exists(message_path)) && (!ecore_file_is_dir(message_path))) { directory = strdup(epd->dir); found = 1; @@ -548,7 +545,6 @@ dir, file, PACKAGE); if (ecore_file_exists(file_path) && !ecore_file_is_dir(file_path)) languages = evas_list_append(languages, strdup(file)); - } ecore_list_destroy(files); } @@ -566,37 +562,28 @@ { Evas_Hash *alias_hash; char *alias; + char *lower_language; + int i; - if (language == NULL || !strncmp(language, "POSIX", strlen("POSIX"))) + if ((language == NULL) || (!strncmp(language, "POSIX", strlen("POSIX")))) return strdup("C"); alias_hash = _e_intl_locale_alias_hash_get(); if (alias_hash == NULL) /* No alias file available */ - { - return strdup(language); - } + return strdup(language); - { - char *lower_language; - int i; - - lower_language = malloc(strlen(language) + 1); - for (i = 0; i < strlen(language); i++) - lower_language[i] = tolower(language[i]); - lower_language[i] = 0; + lower_language = malloc(strlen(language) + 1); + for (i = 0; i < strlen(language); i++) + lower_language[i] = tolower(language[i]); + lower_language[i] = 0; - alias = evas_hash_find(alias_hash, lower_language); - free(lower_language); - } + alias = evas_hash_find(alias_hash, lower_language); + free(lower_language); if (alias) - { - alias = strdup(alias); - } + alias = strdup(alias); else - { - alias = strdup(language); - } + alias = strdup(language); _e_intl_locale_hash_free(alias_hash); @@ -613,7 +600,7 @@ dir_list = e_path_dir_list_get(path_messages); alias_hash = NULL; - for (next = dir_list ; next ; next = next->next) + for (next = dir_list; next; next = next->next) { char buf[4096]; E_Path_Dir *epd; @@ -673,7 +660,7 @@ int tmp_idx = 0; /* Parse Loop - Seperators are _ . @ */ - for ( locale_idx = 0; locale_idx < strlen(locale); locale_idx++ ) + for (locale_idx = 0; locale_idx < strlen(locale); locale_idx++) { char locale_char; locale_char = locale[locale_idx]; @@ -686,69 +673,56 @@ switch (state) { case 0: /* Gathering Language */ - if (tmp_idx == 2 && locale_char == '_') - { - state++; - language[tmp_idx] = 0; - tmp_idx = 0; - } - else if (tmp_idx < 2 && islower(locale_char)) - { - language[tmp_idx++] = locale_char; - } - else - { - return NULL; - } - break; + if (tmp_idx == 2 && locale_char == '_') + { + state++; + language[tmp_idx] = 0; + tmp_idx = 0; + } + else if ((tmp_idx < 2) && (islower(locale_char))) + language[tmp_idx++] = locale_char; + else + return NULL; + break; case 1: /* Gathering Territory */ - if (tmp_idx == 2 && locale_char == '.') - { - state++; - territory[tmp_idx] = 0; - tmp_idx = 0; - } - else if ((tmp_idx == 2) && (locale_char == '@')) - { - state += 2; - territory[tmp_idx] = 0; - codeset[0] = 0; - tmp_idx = 0; - } - else if ((tmp_idx < 2) && isupper(locale_char)) - { - territory[tmp_idx++] = locale_char; - } - else - { - return NULL; - } - break; + if (tmp_idx == 2 && locale_char == '.') + { + state++; + territory[tmp_idx] = 0; + tmp_idx = 0; + } + else if ((tmp_idx == 2) && (locale_char == '@')) + { + state += 2; + territory[tmp_idx] = 0; + codeset[0] = 0; + tmp_idx = 0; + } + else if ((tmp_idx < 2) && isupper(locale_char)) + territory[tmp_idx++] = locale_char; + else + return NULL; + break; case 2: /* Gathering Codeset */ - if (locale_char == '@') - { - state++; - codeset[tmp_idx] = 0; - tmp_idx = 0; - } - else if (tmp_idx < 32) - { - codeset[tmp_idx++] = locale_char; - } - else - { - return NULL; - } - break; + if (locale_char == '@') + { + state++; + codeset[tmp_idx] = 0; + tmp_idx = 0; + } + else if (tmp_idx < 32) + codeset[tmp_idx++] = locale_char; + else + return NULL; + break; case 3: /* Gathering modifier */ - if (tmp_idx < 32) - { - modifier[tmp_idx++] = locale_char; - } - else - { - return NULL; - } + if (tmp_idx < 32) + modifier[tmp_idx++] = locale_char; + else + return NULL; + break; + default: + break; } } @@ -756,16 +730,22 @@ switch (state) { case 0: - language[tmp_idx] = 0; - tmp_idx = 0; + language[tmp_idx] = 0; + tmp_idx = 0; + break; case 1: - territory[tmp_idx] = 0; - tmp_idx = 0; + territory[tmp_idx] = 0; + tmp_idx = 0; + break; case 2: - codeset[tmp_idx] = 0; - tmp_idx = 0; + codeset[tmp_idx] = 0; + tmp_idx = 0; + break; case 3: - modifier[tmp_idx] = 0; + modifier[tmp_idx] = 0; + break; + default: + break; } locale_parts = E_NEW(E_Locale_Parts, 1); @@ -839,9 +819,7 @@ locale[0] = 0; if (mask & E_INTL_LOC_LANG) - { - strcat(locale, locale_parts->lang); - } + strcat(locale, locale_parts->lang); if (mask & E_INTL_LOC_REGION) { @@ -876,16 +854,12 @@ while ((c = charset[i++]) != 0) { if (isalnum(c)) - { - charset_canonic[i_tmp++] = tolower(c); - } + charset_canonic[i_tmp++] = tolower(c); } charset_canonic[i_tmp] = 0; if (!strcmp(charset, charset_canonic)) - { - return NULL; - } + return NULL; return strdup(charset_canonic); } @@ -898,13 +872,11 @@ locales = NULL; output = popen("locale -a", "r"); - if ( output ) + if (output) { char line[32]; - while ( fscanf(output, "%[^\n]\n", line) == 1) - { - locales = evas_list_append(locales, strdup(line)); - } + while (fscanf(output, "%[^\n]\n", line) == 1) + locales = evas_list_append(locales, strdup(line)); pclose(output); } @@ -928,9 +900,11 @@ 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); + locale_lr = + e_intl_locale_parts_combine(locale_parts, + E_INTL_LOC_LANG | E_INTL_LOC_REGION); - if ( locale_lr == NULL ) + if (locale_lr == NULL) { /* Not valid locale, maybe its an alias */ locale_lr = strdup(locale); @@ -938,7 +912,7 @@ } else { - if ( locale_parts && locale_parts->codeset ) + if (locale_parts && locale_parts->codeset) locale_cs_canonic = e_intl_locale_charset_canonic_get(locale_parts->codeset); else locale_cs_canonic = NULL; @@ -962,7 +936,8 @@ locale_lr_next = e_intl_locale_parts_combine(locale_parts_next, E_INTL_LOC_LANG | E_INTL_LOC_REGION); - if (locale_parts && locale_lr_next && !strcmp(locale_lr, locale_lr_next)) + if ((locale_parts) && (locale_lr_next) && + (!strcmp(locale_lr, locale_lr_next))) { /* Matched lang/region part, now if CS matches */ if ((locale_parts->codeset == NULL) && (locale_parts_next->codeset == NULL)) @@ -1050,7 +1025,7 @@ if (locale_parts == NULL) return NULL; search_list = NULL; - for ( mask = E_INTL_LOC_ALL; mask >= E_INTL_LOC_LANG; mask-- ) + for (mask = E_INTL_LOC_ALL; mask >= E_INTL_LOC_LANG; mask--) { if ((mask & locale_parts->mask) == mask) { @@ -1092,4 +1067,3 @@ } return imcs; } - ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs