ICU-1198 small fixes to ures_getInt() - check type and use RES_GET_INT()

X-SVN-Rev: 5857
This commit is contained in:
Markus Scherer 2001-09-21 00:02:24 +00:00
parent 1b9cd65c1c
commit 1ad7e7a434

View file

@ -595,9 +595,6 @@ U_CAPI const int32_t* U_EXPORT2 ures_getIntVector(const UResourceBundle* resB, i
/* this function returns a signed integer */
/* it performs sign extension */
U_CAPI int32_t U_EXPORT2 ures_getInt(const UResourceBundle* resB, UErrorCode *status) {
uint32_t uintValue = 0;
int32_t returnValue = 0;
if (status==NULL || U_FAILURE(*status)) {
return 0xffffffff;
}
@ -605,13 +602,14 @@ U_CAPI int32_t U_EXPORT2 ures_getInt(const UResourceBundle* resB, UErrorCode *st
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0xffffffff;
}
uintValue = RES_GET_UINT(resB->fRes);
returnValue = (int32_t)(uintValue<<4)>>4;
return returnValue;
if(RES_GET_TYPE(resB->fRes) != RES_INT) {
*status = U_RESOURCE_TYPE_MISMATCH;
return 0xffffffff;
}
return RES_GET_INT(resB->fRes);
}
U_CAPI uint32_t U_EXPORT2 ures_getUInt(const UResourceBundle* resB, UErrorCode *status) {
if (status==NULL || U_FAILURE(*status)) {
return 0xffffffff;
}
@ -619,6 +617,10 @@ U_CAPI uint32_t U_EXPORT2 ures_getUInt(const UResourceBundle* resB, UErrorCode *
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0xffffffff;
}
if(RES_GET_TYPE(resB->fRes) != RES_INT) {
*status = U_RESOURCE_TYPE_MISMATCH;
return 0xffffffff;
}
return RES_GET_UINT(resB->fRes);
}