mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-05 05:25:34 +00:00
ICU-22901 Move calls to uloc_getDefault() out of ulocimp_getSubtags().
This commit is contained in:
parent
cd9fada30c
commit
1dccc10085
4 changed files with 27 additions and 6 deletions
|
@ -377,6 +377,10 @@ _getDisplayNameForComponent(const char *locale,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (locale == nullptr) {
|
||||
locale = uloc_getDefault();
|
||||
}
|
||||
|
||||
localStatus = U_ZERO_ERROR;
|
||||
icu::CharString localeBuffer = (*getter)(locale, localStatus);
|
||||
if (U_FAILURE(localStatus)) {
|
||||
|
|
|
@ -349,7 +349,9 @@ uloc_isRightToLeft(const char *locale) {
|
|||
UErrorCode errorCode = U_ZERO_ERROR;
|
||||
icu::CharString lang;
|
||||
icu::CharString script;
|
||||
ulocimp_getSubtags(locale, &lang, &script, nullptr, nullptr, nullptr, errorCode);
|
||||
ulocimp_getSubtags(
|
||||
locale == nullptr ? uloc_getDefault() : locale,
|
||||
&lang, &script, nullptr, nullptr, nullptr, errorCode);
|
||||
if (U_FAILURE(errorCode) || script.isEmpty()) {
|
||||
// Fastpath: We know the likely scripts and their writing direction
|
||||
// for some common languages.
|
||||
|
@ -430,7 +432,7 @@ ulocimp_getRegionForSupplementalData(const char *localeID, bool inferRegion,
|
|||
icu::CharString rgBuf = GetRegionFromKey(localeID, "rg", status);
|
||||
if (U_SUCCESS(status) && rgBuf.isEmpty()) {
|
||||
// No valid rg keyword value, try for unicode_region_subtag
|
||||
rgBuf = ulocimp_getRegion(localeID, status);
|
||||
rgBuf = ulocimp_getRegion(localeID == nullptr ? uloc_getDefault() : localeID, status);
|
||||
if (U_SUCCESS(status) && rgBuf.isEmpty() && inferRegion) {
|
||||
// Second check for sd keyword value
|
||||
rgBuf = GetRegionFromKey(localeID, "sd", status);
|
||||
|
|
|
@ -1541,10 +1541,6 @@ ulocimp_getSubtags(
|
|||
|
||||
bool hasRegion = false;
|
||||
|
||||
if (localeID == nullptr) {
|
||||
localeID = uloc_getDefault();
|
||||
}
|
||||
|
||||
_getLanguage(localeID, language, &localeID, status);
|
||||
if (U_FAILURE(status)) { return; }
|
||||
U_ASSERT(localeID != nullptr);
|
||||
|
@ -1989,6 +1985,10 @@ uloc_getLanguage(const char* localeID,
|
|||
int32_t languageCapacity,
|
||||
UErrorCode* err)
|
||||
{
|
||||
if (localeID == nullptr) {
|
||||
localeID = uloc_getDefault();
|
||||
}
|
||||
|
||||
/* uloc_getLanguage will return a 2 character iso-639 code if one exists. *CWB*/
|
||||
return ByteSinkUtil::viaByteSinkToTerminatedChars(
|
||||
language, languageCapacity,
|
||||
|
@ -2011,6 +2011,10 @@ uloc_getScript(const char* localeID,
|
|||
int32_t scriptCapacity,
|
||||
UErrorCode* err)
|
||||
{
|
||||
if (localeID == nullptr) {
|
||||
localeID = uloc_getDefault();
|
||||
}
|
||||
|
||||
return ByteSinkUtil::viaByteSinkToTerminatedChars(
|
||||
script, scriptCapacity,
|
||||
[&](ByteSink& sink, UErrorCode& status) {
|
||||
|
@ -2032,6 +2036,10 @@ uloc_getCountry(const char* localeID,
|
|||
int32_t countryCapacity,
|
||||
UErrorCode* err)
|
||||
{
|
||||
if (localeID == nullptr) {
|
||||
localeID = uloc_getDefault();
|
||||
}
|
||||
|
||||
return ByteSinkUtil::viaByteSinkToTerminatedChars(
|
||||
country, countryCapacity,
|
||||
[&](ByteSink& sink, UErrorCode& status) {
|
||||
|
@ -2053,6 +2061,10 @@ uloc_getVariant(const char* localeID,
|
|||
int32_t variantCapacity,
|
||||
UErrorCode* err)
|
||||
{
|
||||
if (localeID == nullptr) {
|
||||
localeID = uloc_getDefault();
|
||||
}
|
||||
|
||||
return ByteSinkUtil::viaByteSinkToTerminatedChars(
|
||||
variant, variantCapacity,
|
||||
[&](ByteSink& sink, UErrorCode& status) {
|
||||
|
|
|
@ -59,6 +59,9 @@ getCodesFromLocale(const char *locale,
|
|||
if (U_FAILURE(*err)) { return 0; }
|
||||
icu::CharString lang;
|
||||
icu::CharString script;
|
||||
if (locale == nullptr) {
|
||||
locale = uloc_getDefault();
|
||||
}
|
||||
ulocimp_getSubtags(locale, &lang, &script, nullptr, nullptr, nullptr, *err);
|
||||
if (U_FAILURE(*err)) { return 0; }
|
||||
// Multi-script languages, equivalent to the LocaleScript data
|
||||
|
|
Loading…
Add table
Reference in a new issue