Home | Info | Community | Development | myReactOS | Contact Us
Definition at line 356 of file locale.c.
Referenced by locale::global(), InitInstance(), process_COM(), TConfig::redir_init(), and wmain().
{ LCID lcid = 0; locale_search_t lc; int haveLang, haveCountry, haveCP; char* next; int lc_all = 0; TRACE("(%d %s)\n",category,locale); if (category < MSVCRT_LC_MIN || category > MSVCRT_LC_MAX) return NULL; if (locale == NULL) { /* Report the current Locale */ return MSVCRT_current_lc_all; } LOCK_LOCALE; if (locale[0] == 'L' && locale[1] == 'C' && locale[2] == '_') { WARN(":restore previous locale not implemented!\n"); /* FIXME: Easiest way to do this is parse the string and * call this function recursively with its elements, * Where they differ for each lc_ type. */ UNLOCK_LOCALE; return MSVCRT_current_lc_all; } /* Default Locale: Special case handling */ if (!strlen(locale) || ((toupper(locale[0]) == 'C') && !locale[1])) { MSVCRT_current_lc_all[0] = 'C'; MSVCRT_current_lc_all[1] = '\0'; MSVCRT___lc_codepage = GetACP(); MSVCRT___lc_collate_cp = GetACP(); switch (category) { case MSVCRT_LC_ALL: lc_all = 1; /* Fall through all cases ... */ case MSVCRT_LC_COLLATE: if (!lc_all) break; case MSVCRT_LC_CTYPE: /* Restore C locale ctype info */ __mb_cur_max = 1; memcpy(MSVCRT_current_ctype, MSVCRT__ctype, sizeof(MSVCRT__ctype)); if (!lc_all) break; case MSVCRT_LC_MONETARY: if (!lc_all) break; case MSVCRT_LC_NUMERIC: if (!lc_all) break; case MSVCRT_LC_TIME: break; } UNLOCK_LOCALE; return MSVCRT_current_lc_all; } /* Get locale elements */ haveLang = haveCountry = haveCP = 0; memset(&lc,0,sizeof(lc)); next = strchr(locale,'_'); if (next && next != locale) { haveLang = 1; memcpy(lc.search_language,locale,next-locale); locale += next-locale+1; } next = strchr(locale,'.'); if (next) { haveCP = 1; if (next == locale) { locale++; lstrcpynA(lc.search_codepage, locale, MAX_ELEM_LEN); } else { if (haveLang) { haveCountry = 1; memcpy(lc.search_country,locale,next-locale); locale += next-locale+1; } else { haveLang = 1; memcpy(lc.search_language,locale,next-locale); locale += next-locale+1; } lstrcpynA(lc.search_codepage, locale, MAX_ELEM_LEN); } } else { if (haveLang) { haveCountry = 1; lstrcpynA(lc.search_country, locale, MAX_ELEM_LEN); } else { haveLang = 1; lstrcpynA(lc.search_language, locale, MAX_ELEM_LEN); } } if (haveCountry) remap_synonym(lc.search_country); if (haveCP && !haveCountry && !haveLang) { ERR(":Codepage only locale not implemented\n"); /* FIXME: Use default lang/country and skip locale_to_LCID() * call below... */ UNLOCK_LOCALE; return NULL; } lcid = MSVCRT_locale_to_LCID(&lc); TRACE(":found LCID %d\n",lcid); if (lcid == 0) { UNLOCK_LOCALE; return NULL; } MSVCRT_current_lc_all_lcid = lcid; _snprintf(MSVCRT_current_lc_all,MAX_LOCALE_LENGTH,"%s_%s.%s", lc.found_language,lc.found_country,lc.found_codepage); switch (category) { case MSVCRT_LC_ALL: lc_all = 1; /* Fall through all cases ... */ case MSVCRT_LC_COLLATE: if (!lc_all) break; case MSVCRT_LC_CTYPE: msvcrt_set_ctype(atoi(lc.found_codepage),lcid); if (!lc_all) break; case MSVCRT_LC_MONETARY: if (!lc_all) break; case MSVCRT_LC_NUMERIC: if (!lc_all) break; case MSVCRT_LC_TIME: break; } UNLOCK_LOCALE; return MSVCRT_current_lc_all; }