mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-10 07:39:16 +00:00
ICU-3984 updates from code review
X-SVN-Rev: 29004
This commit is contained in:
parent
6a5f83ff80
commit
4a9aeda18c
3 changed files with 23 additions and 12 deletions
|
@ -7129,16 +7129,17 @@ ucol_getReorderCodes(const UCollator *coll,
|
|||
if (U_FAILURE(*pErrorCode)) {
|
||||
return 0;
|
||||
}
|
||||
if (coll->reorderCodes == NULL) {
|
||||
if (destCapacity != 0) {
|
||||
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
}
|
||||
|
||||
if (destCapacity < 0 || (destCapacity > 0 && dest == NULL)) {
|
||||
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (coll->reorderCodesLength > destCapacity) {
|
||||
*pErrorCode = U_BUFFER_OVERFLOW_ERROR;
|
||||
return coll->reorderCodesLength;
|
||||
}
|
||||
for (int32_t i = 0; (i < coll->reorderCodesLength) && (i < destCapacity); i++) {
|
||||
for (int32_t i = 0; i < coll->reorderCodesLength; i++) {
|
||||
dest[i] = coll->reorderCodes[i];
|
||||
}
|
||||
return coll->reorderCodesLength;
|
||||
|
@ -7152,13 +7153,19 @@ ucol_setReorderCodes(UCollator *coll,
|
|||
if (U_FAILURE(*pErrorCode)) {
|
||||
return;
|
||||
}
|
||||
if (reorderCodes == NULL) {
|
||||
if (reorderCodesLength != 0) {
|
||||
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
}
|
||||
|
||||
if (reorderCodesLength < 0 || (reorderCodesLength > 0 && reorderCodes == NULL)) {
|
||||
*pErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return;
|
||||
}
|
||||
|
||||
uprv_free(coll->reorderCodes);
|
||||
coll->reorderCodesLength = 0;
|
||||
if (reorderCodesLength == 0) {
|
||||
uprv_free(coll->leadBytePermutationTable);
|
||||
coll->leadBytePermutationTable = NULL;
|
||||
return;
|
||||
}
|
||||
coll->reorderCodes = (int32_t*) uprv_malloc(reorderCodesLength * sizeof(int32_t));
|
||||
if (coll->reorderCodes == NULL) {
|
||||
*pErrorCode = U_MEMORY_ALLOCATION_ERROR;
|
||||
|
@ -7169,6 +7176,11 @@ ucol_setReorderCodes(UCollator *coll,
|
|||
}
|
||||
coll->reorderCodesLength = reorderCodesLength;
|
||||
ucol_buildPermutationTable(coll, pErrorCode);
|
||||
if (U_FAILURE(*pErrorCode)) {
|
||||
uprv_free(coll->reorderCodes);
|
||||
coll->reorderCodes = NULL;
|
||||
coll->reorderCodesLength = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1095,7 +1095,7 @@ U_CAPI const UChar* U_EXPORT2 ucol_tok_getRulesFromBundle(
|
|||
int32_t* pLength,
|
||||
UErrorCode* status);
|
||||
|
||||
U_CAPI void ucol_buildPermutationTable(UCollator *coll, UErrorCode *status);
|
||||
U_CAPI void U_EXPORT2 ucol_buildPermutationTable(UCollator *coll, UErrorCode *status);
|
||||
|
||||
|
||||
#ifdef XP_CPLUSPLUS
|
||||
|
|
|
@ -5905,8 +5905,7 @@ static void TestBeforeRuleWithScriptReordering(void)
|
|||
}
|
||||
|
||||
/*
|
||||
* This test ensures that characters placed before a character in a different script have the same lead byte
|
||||
* in their collation key before and after script reordering.
|
||||
* Test that in a primary-compressed sort key all bytes except the first one are unchanged under script reordering.
|
||||
*/
|
||||
static void TestNonLeadBytesDuringCollationReordering(void)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue