static int load_locale_sub(int category, const char *locname, int isspecial) { char name[PATH_MAX]; /* check for the default locales */ if (!strcmp(new_categories[category], "C") || !strcmp(new_categories[category], "POSIX")) { revert_to_default(category); return(0); } /* check whether special symbol */ if (isspecial && _bcs_strcasecmp(locname, _LOCALE_SYM_FORCE) == 0) return(force_locale_enable(category)); /* sanity check */ if (strchr(locname, '/') != NULL) return(-1); snprintf(name, sizeof(name), "%s/%s/%s", _PathLocale, locname, categories[category].name); if (category > 0 && category < (int)__arysize(categories) && categories[category].load_function != NULL) return(categories[category].load_function(locname)); return(0); }
static int load_locale_sub( int category, const char *locname, int isspecial ) { char name[PATH_MAX]; /* check for the default locales */ if (!strcmp(new_categories[category], "C") || !strcmp(new_categories[category], "POSIX")) { revert_to_default(category); return 0; } /* check whether special symbol */ if (isspecial && _bcs_strcasecmp(locname, _LOCALE_SYM_FORCE) == 0) return force_locale_enable(category); /* sanity check */ if (strchr(locname, '/') != NULL) return -1; (void)snprintf(name, sizeof(name), "%s/%s/%s", _PathLocale, locname, categories[category]); switch (category) { case LC_CTYPE: #ifdef WITH_RUNE if (_xpg4_setrunelocale(__UNCONST(locname))) return -1; if (__runetable_to_netbsd_ctype(locname)) { /* very unfortunate, but need to go to "C" locale */ revert_to_default(category); return -1; } #else if (!__loadctype(name)) return -1; #endif break; case LC_MESSAGES: /* * XXX we don't have LC_MESSAGES support yet, * but catopen may use the value of LC_MESSAGES category. * so return successfully if locale directory is present. */ (void)snprintf(name, sizeof(name), "%s/%s", _PathLocale, locname); /* local */ { struct stat st; if (stat(name, &st) < 0) return -1; if (!S_ISDIR(st.st_mode)) return -1; } break; case LC_COLLATE: case LC_MONETARY: case LC_NUMERIC: case LC_TIME: return -1; } return 0; }