ICU-1616 Pay more attention to UErrorCode

X-SVN-Rev: 7533
This commit is contained in:
George Rhoten 2002-01-30 06:18:26 +00:00
parent d80f01ccbf
commit 30f7f026e1
2 changed files with 30 additions and 35 deletions

View File

@ -1232,19 +1232,15 @@ MessageFormat::makeFormat(/*int32_t position, */
break;
default:
newFormat = DateFormat::createDateInstance(DateFormat::kDefault, fLocale);
if(newFormat->getDynamicClassID() == SimpleDateFormat::getStaticClassID()){
if(newFormat && newFormat->getDynamicClassID() == SimpleDateFormat::getStaticClassID()){
((SimpleDateFormat*)newFormat)->applyPattern(segments[3]);
}
/* Ram: 'success' is not passed to above methods
and is not set so we donot have to check for failure.
if(U_FAILURE(success)) {
fMaxOffset = oldMaxOffset;
success = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
*/
break;
}
if (!newFormat) {
/* TODO: get the real error from createDateInstance */
success = U_MEMORY_ALLOCATION_ERROR;
}
break;
case 5: case 6:// time
@ -1268,24 +1264,20 @@ MessageFormat::makeFormat(/*int32_t position, */
break;
default:
newFormat = DateFormat::createTimeInstance(DateFormat::kDefault, fLocale);
if(newFormat->getDynamicClassID() == SimpleDateFormat::getStaticClassID()){
if(newFormat && newFormat->getDynamicClassID() == SimpleDateFormat::getStaticClassID()){
((SimpleDateFormat*)newFormat)->applyPattern(segments[3]);
}
/* Ram: 'success' is not passed to above methods
and is not set so we donot have to check for failure.
if(U_FAILURE(success)) {
fMaxOffset = oldMaxOffset;
success = U_ILLEGAL_ARGUMENT_ERROR;
return;
}
*/
break;
}
if (!newFormat) {
/* TODO: get the real error from createTimeInstance */
success = U_MEMORY_ALLOCATION_ERROR;
}
break;
case 7: case 8:// choice
fFormatTypeList[argumentNumber] = Formattable::kDouble;
newFormat = new ChoiceFormat(segments[3],parseError,success);
newFormat = new ChoiceFormat(segments[3], parseError, success);
if(U_FAILURE(success)) {
fMaxOffset = oldMaxOffset;
return argumentNumber;

View File

@ -124,18 +124,17 @@ u_parseMessage( const char *locale,
UErrorCode *status,
...)
{
va_list ap;
va_list ap;
if(U_FAILURE(*status)) return;
if(U_FAILURE(*status)) return;
// start vararg processing
va_start(ap, status);
// start vararg processing
va_start(ap, status);
u_vparseMessage(locale,pattern,patternLength,source,sourceLength,ap,status);
// end vararg processing
va_end(ap);
u_vparseMessage(locale,pattern,patternLength,source,sourceLength,ap,status);
// end vararg processing
va_end(ap);
}
U_CAPI void U_EXPORT2
@ -149,7 +148,11 @@ u_vparseMessage(const char *locale,
{
UMessageFormat *fmt = umsg_open(pattern,patternLength,locale,NULL,status);
int32_t count = 0;
umsg_vparse(fmt,source,sourceLength,&count,ap,status);
if (U_SUCCESS(*status)) {
umsg_vparse(fmt,source,sourceLength,&count,ap,status);
}
umsg_close(fmt);
}
@ -163,17 +166,17 @@ u_parseMessageWithError(const char *locale,
UErrorCode *status,
...)
{
va_list ap;
va_list ap;
if(U_FAILURE(*status)) return;
if(U_FAILURE(*status)) return;
// start vararg processing
va_start(ap, status);
// start vararg processing
va_start(ap, status);
u_vparseMessageWithError(locale,pattern,patternLength,source,sourceLength,ap,error,status);
u_vparseMessageWithError(locale,pattern,patternLength,source,sourceLength,ap,error,status);
// end vararg processing
va_end(ap);
// end vararg processing
va_end(ap);
}
U_CAPI void U_EXPORT2
u_vparseMessageWithError(const char *locale,