mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-06 22:15:31 +00:00
ICU-6441 bug fix in ucnv_bld.c: don't ucnv_close() if onlyTestIsLoadable; and simplify code by dropping isLoadable result and using UErrorCode instead
X-SVN-Rev: 25741
This commit is contained in:
parent
0d7a759dd8
commit
8ee4058f62
11 changed files with 22 additions and 52 deletions
|
@ -518,8 +518,7 @@ _ISO2022Open(UConverter *cnv, UConverterLoadArgs *pArgs, UErrorCode *errorCode){
|
|||
myConverterData->version=version=0;
|
||||
}
|
||||
if(pArgs->onlyTestIsLoadable) {
|
||||
UErrorCode localStatus=U_ZERO_ERROR;
|
||||
pArgs->isLoadable=ucnv_canCreateConverter(cnvName, &localStatus);
|
||||
ucnv_canCreateConverter(cnvName, errorCode); /* errorCode carries result */
|
||||
uprv_free(cnv->extraInfo);
|
||||
cnv->extraInfo=NULL;
|
||||
return;
|
||||
|
@ -594,13 +593,9 @@ _ISO2022Open(UConverter *cnv, UConverterLoadArgs *pArgs, UErrorCode *errorCode){
|
|||
|
||||
cnv->maxBytesPerUChar=cnv->sharedData->staticData->maxBytesPerChar;
|
||||
|
||||
if(U_FAILURE(*errorCode)) {
|
||||
if(U_FAILURE(*errorCode) || pArgs->onlyTestIsLoadable) {
|
||||
_ISO2022Close(cnv);
|
||||
}
|
||||
if(pArgs->onlyTestIsLoadable) {
|
||||
_ISO2022Close(cnv);
|
||||
pArgs->isLoadable=TRUE;
|
||||
}
|
||||
} else {
|
||||
*errorCode = U_MEMORY_ALLOCATION_ERROR;
|
||||
}
|
||||
|
|
|
@ -874,7 +874,7 @@ ucnv_canCreateConverter(const char *converterName, UErrorCode *err) {
|
|||
}
|
||||
|
||||
UTRACE_EXIT_STATUS(*err);
|
||||
return U_SUCCESS(*err) && stackArgs.isLoadable;
|
||||
return U_SUCCESS(*err);
|
||||
}
|
||||
|
||||
UConverter *
|
||||
|
@ -1016,11 +1016,10 @@ ucnv_createConverterFromSharedData(UConverter *myUConverter,
|
|||
myUConverter->toUCallbackReason = UCNV_ILLEGAL; /* default reason to invoke (*fromCharErrorBehaviour) */
|
||||
}
|
||||
|
||||
if(mySharedConverterData->impl->open == NULL) {
|
||||
pArgs->isLoadable = pArgs->onlyTestIsLoadable;
|
||||
} else {
|
||||
if(mySharedConverterData->impl->open != NULL) {
|
||||
mySharedConverterData->impl->open(myUConverter, pArgs, err);
|
||||
if(U_FAILURE(*err)) {
|
||||
if(U_FAILURE(*err) && !pArgs->onlyTestIsLoadable) {
|
||||
/* don't ucnv_close() if onlyTestIsLoadable because not fully initialized */
|
||||
ucnv_close(myUConverter);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ typedef struct {
|
|||
int32_t size; /* sizeof(UConverterLoadArgs) */
|
||||
int32_t nestedLoads; /* count nested ucnv_load() calls */
|
||||
UBool onlyTestIsLoadable; /* input: don't actually load */
|
||||
UBool isLoadable; /* output, if onlyTestIsLoadable is set */
|
||||
UBool reserved0; /* reserved - for good alignment of the pointers */
|
||||
int16_t reserved; /* reserved - for good alignment of the pointers */
|
||||
uint32_t options;
|
||||
const char *pkg, *name, *locale;
|
||||
|
|
|
@ -588,15 +588,10 @@ _LMBCSOpenWorker(UConverter* _this,
|
|||
}
|
||||
}
|
||||
|
||||
if(U_FAILURE(*err)) {
|
||||
if(U_FAILURE(*err) || pArgs->onlyTestIsLoadable) {
|
||||
_LMBCSClose(_this);
|
||||
return;
|
||||
}
|
||||
if(pArgs->onlyTestIsLoadable) {
|
||||
_LMBCSClose(_this);
|
||||
pArgs->isLoadable=TRUE;
|
||||
return;
|
||||
}
|
||||
extraInfo->OptGroup = OptGroup;
|
||||
extraInfo->localeConverterIndex = FindLMBCSLocale(pArgs->locale);
|
||||
}
|
||||
|
|
|
@ -585,13 +585,10 @@ static void
|
|||
_UTF16BEOpen(UConverter *cnv,
|
||||
UConverterLoadArgs *pArgs,
|
||||
UErrorCode *pErrorCode) {
|
||||
if(pArgs->onlyTestIsLoadable) {
|
||||
pArgs->isLoadable=TRUE;
|
||||
} else {
|
||||
if(UCNV_GET_VERSION(cnv)>1) {
|
||||
cnv->options=0;
|
||||
}
|
||||
if(UCNV_GET_VERSION(cnv)<=1) {
|
||||
_UTF16BEReset(cnv, UCNV_RESET_BOTH);
|
||||
} else {
|
||||
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1187,13 +1184,10 @@ static void
|
|||
_UTF16LEOpen(UConverter *cnv,
|
||||
UConverterLoadArgs *pArgs,
|
||||
UErrorCode *pErrorCode) {
|
||||
if(pArgs->onlyTestIsLoadable) {
|
||||
pArgs->isLoadable=TRUE;
|
||||
} else {
|
||||
if(UCNV_GET_VERSION(cnv)>1) {
|
||||
cnv->options=0;
|
||||
}
|
||||
if(UCNV_GET_VERSION(cnv)<=1) {
|
||||
_UTF16LEReset(cnv, UCNV_RESET_BOTH);
|
||||
} else {
|
||||
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1289,13 +1283,10 @@ static void
|
|||
_UTF16Open(UConverter *cnv,
|
||||
UConverterLoadArgs *pArgs,
|
||||
UErrorCode *pErrorCode) {
|
||||
if(pArgs->onlyTestIsLoadable) {
|
||||
pArgs->isLoadable=TRUE;
|
||||
} else {
|
||||
if(UCNV_GET_VERSION(cnv)>1) {
|
||||
cnv->options=0;
|
||||
}
|
||||
if(UCNV_GET_VERSION(cnv)<=1) {
|
||||
_UTF16Reset(cnv, UCNV_RESET_BOTH);
|
||||
} else {
|
||||
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1035,11 +1035,7 @@ static void
|
|||
_UTF32Open(UConverter *cnv,
|
||||
UConverterLoadArgs *pArgs,
|
||||
UErrorCode *pErrorCode) {
|
||||
if(pArgs->onlyTestIsLoadable) {
|
||||
pArgs->isLoadable=TRUE;
|
||||
} else {
|
||||
_UTF32Reset(cnv, UCNV_RESET_BOTH);
|
||||
}
|
||||
_UTF32Reset(cnv, UCNV_RESET_BOTH);
|
||||
}
|
||||
|
||||
static const char utf32BOM[8]={ 0, 0, (char)0xfe, (char)0xff, (char)0xff, (char)0xfe, 0, 0 };
|
||||
|
|
|
@ -192,10 +192,9 @@ static void
|
|||
_UTF7Open(UConverter *cnv,
|
||||
UConverterLoadArgs *pArgs,
|
||||
UErrorCode *pErrorCode) {
|
||||
if(pArgs->onlyTestIsLoadable) {
|
||||
pArgs->isLoadable=TRUE;
|
||||
} else if((pArgs->options&0xf)<=1) {
|
||||
cnv->fromUnicodeStatus=(pArgs->options&0xf)<<28;
|
||||
if(UCNV_GET_VERSION(cnv)<=1) {
|
||||
/* TODO(markus): Should just use cnv->options rather than copying the version number. */
|
||||
cnv->fromUnicodeStatus=UCNV_GET_VERSION(cnv)<<28;
|
||||
_UTF7Reset(cnv, UCNV_RESET_BOTH);
|
||||
} else {
|
||||
*pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
|
|
|
@ -69,8 +69,7 @@ static void
|
|||
_HZOpen(UConverter *cnv, UConverterLoadArgs *pArgs, UErrorCode *errorCode){
|
||||
UConverter *gbConverter;
|
||||
if(pArgs->onlyTestIsLoadable) {
|
||||
UErrorCode localStatus = U_ZERO_ERROR;
|
||||
pArgs->isLoadable = ucnv_canCreateConverter("GBK", &localStatus);
|
||||
ucnv_canCreateConverter("GBK", errorCode); /* errorCode carries result */
|
||||
return;
|
||||
}
|
||||
gbConverter = ucnv_open("GBK", errorCode);
|
||||
|
|
|
@ -173,7 +173,6 @@ static void initializeSets() {
|
|||
|
||||
static void _ISCIIOpen(UConverter *cnv, UConverterLoadArgs *pArgs, UErrorCode *errorCode) {
|
||||
if(pArgs->onlyTestIsLoadable) {
|
||||
pArgs->isLoadable=TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1401,7 +1401,6 @@ ucnv_MBCSLoad(UConverterSharedData *sharedData,
|
|||
args.size=sizeof(UConverterLoadArgs);
|
||||
args.nestedLoads=2;
|
||||
args.onlyTestIsLoadable=pArgs->onlyTestIsLoadable;
|
||||
args.isLoadable=pArgs->isLoadable;
|
||||
args.reserved=pArgs->reserved;
|
||||
args.options=pArgs->options;
|
||||
args.pkg=pArgs->pkg;
|
||||
|
@ -1688,7 +1687,6 @@ ucnv_MBCSOpen(UConverter *cnv,
|
|||
int8_t maxBytesPerUChar;
|
||||
|
||||
if(pArgs->onlyTestIsLoadable) {
|
||||
pArgs->isLoadable=TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -194,7 +194,6 @@ _SCSUOpen(UConverter *cnv,
|
|||
UErrorCode *pErrorCode) {
|
||||
const char *locale=pArgs->locale;
|
||||
if(pArgs->onlyTestIsLoadable) {
|
||||
pArgs->isLoadable=TRUE;
|
||||
return;
|
||||
}
|
||||
cnv->extraInfo=uprv_malloc(sizeof(SCSUData));
|
||||
|
|
Loading…
Add table
Reference in a new issue