ICU-8388 Fixed missing separator problem in uloc_minimizeSubtag/addLikelySubtag.

X-SVN-Rev: 29536
This commit is contained in:
Yoshito Umaoka 2011-03-04 00:32:02 +00:00
parent 29292b59e7
commit 5701f7add9
2 changed files with 33 additions and 3 deletions

View file

@ -1,7 +1,7 @@
/*
*******************************************************************************
*
* Copyright (C) 1997-2010, International Business Machines
* Copyright (C) 1997-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
@ -325,9 +325,14 @@ createTagStringWithAlternates(
}
if (trailingLength > 0) {
if (capacityRemaining > 0 && !regionAppended) {
if (*trailing != '@' && capacityRemaining > 0) {
tag[tagLength++] = '_';
--capacityRemaining;
if (capacityRemaining > 0 && !regionAppended) {
/* extra separator is required */
tag[tagLength++] = '_';
--capacityRemaining;
}
}
if (capacityRemaining > 0) {
@ -546,6 +551,9 @@ parseTagString(
**/
*regionLength = 0;
}
} else if (*position != 0 && *position != '@') {
/* back up over consumed trailing separator */
--position;
}
exit:
@ -883,6 +891,9 @@ _uloc_addLikelySubtags(const char* localeID,
}
/* Find the length of the trailing portion. */
while (_isIDSeparator(localeID[trailingIndex])) {
trailingIndex++;
}
trailing = &localeID[trailingIndex];
trailingLength = (int32_t)uprv_strlen(trailing);
@ -987,7 +998,10 @@ _uloc_minimizeSubtags(const char* localeID,
goto error;
}
/* Find the spot where the variants begin, if any. */
/* Find the spot where the variants or the keywords begin, if any. */
while (_isIDSeparator(localeID[trailingIndex])) {
trailingIndex++;
}
trailing = &localeID[trailingIndex];
trailingLength = (int32_t)uprv_strlen(trailing);

View file

@ -3015,6 +3015,15 @@ const char* const basic_maximize_data[][2] = {
}, {
"zzz",
""
}, {
"de_u_co_phonebk",
"de_Latn_DE_U_CO_PHONEBK"
}, {
"de_Latn_u_co_phonebk",
"de_Latn_DE_U_CO_PHONEBK"
}, {
"de_Latn_DE_u_co_phonebk",
"de_Latn_DE_U_CO_PHONEBK"
}
};
@ -3037,6 +3046,9 @@ const char* const basic_minimize_data[][2] = {
}, {
"und",
""
}, {
"en_Latn_US@calendar=gregorian",
"en@calendar=gregorian"
}
};
@ -5113,6 +5125,10 @@ const char* const full_data[][3] = {
"art_Moon_AQ",
"",
""
}, {
"de@collation=phonebook",
"de_Latn_DE@collation=phonebook",
"de@collation=phonebook"
}
};