static char * loadlocale(int category) { char aliaspath[PATH_MAX], loccat[PATH_MAX], buf[PATH_MAX]; const char *alias; _DIAGASSERT(0 < category && category < __arysize(categories)); if (strcmp(new_categories[category], current_categories[category]) == 0) return(current_categories[category]); /* (1) non-aliased file */ if (!load_locale_sub(category, new_categories[category], 0)) goto success; /* (2) lookup locname/catname type alias */ snprintf(aliaspath, sizeof(aliaspath), "%s/" _LOCALE_ALIAS_NAME, _PathLocale); snprintf(loccat, sizeof(loccat), "%s/%s", new_categories[category], categories[category].name); alias = _lookup_alias(aliaspath, loccat, buf, sizeof(buf), _LOOKUP_CASE_SENSITIVE); if (!load_locale_sub(category, alias, 1)) goto success; /* (3) lookup locname type alias */ alias = _lookup_alias(aliaspath, new_categories[category], buf, sizeof(buf), _LOOKUP_CASE_SENSITIVE); if (!load_locale_sub(category, alias, 1)) goto success; return(NULL); success: strlcpy(current_categories[category], new_categories[category], sizeof(current_categories[category])); return(current_categories[category]); }
static char * loadlocale(int category) { if (strcmp(new_categories[category], current_categories[category]) == 0) return (current_categories[category]); if (!load_locale_sub(category, new_categories[category], 0)) { (void)strlcpy(current_categories[category], new_categories[category], sizeof(current_categories[category])); return current_categories[category]; } else { return NULL; } }
static char * loadlocale(int category) { //char aliaspath[PATH_MAX], loccat[PATH_MAX], buf[PATH_MAX]; //const char *alias; _DIAGASSERT(0 < category && category < _LC_LAST); if (strcmp(new_categories[category], current_categories[category]) == 0) return (current_categories[category]); /* (1) non-aliased file */ if (!load_locale_sub(category, new_categories[category], 0)) goto success; ///* (2) lookup locname/catname type alias */ //(void)snprintf(aliaspath, sizeof(aliaspath), // "%s/" _LOCALE_ALIAS_NAME, _PathLocale); //(void)snprintf(loccat, sizeof(loccat), "%s/%s", // new_categories[category], categories[category]); //alias = _lookup_alias(aliaspath, loccat, buf, sizeof(buf), // _LOOKUP_CASE_SENSITIVE); //if (!load_locale_sub(category, alias, 1)) // goto success; ///* (3) lookup locname type alias */ //alias = _lookup_alias(aliaspath, new_categories[category], // buf, sizeof(buf), _LOOKUP_CASE_SENSITIVE); //if (!load_locale_sub(category, alias, 1)) // goto success; return NULL; success: (void)strncpyX(current_categories[category], new_categories[category], sizeof(current_categories[category])); return current_categories[category]; }