+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
*
-* Copyright (C) 1999-2011, International Business Machines
+* Copyright (C) 1999-2012, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: umsg.cpp
-* encoding: US-ASCII
+* encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
if(status ==NULL||U_FAILURE(*status)){
return ;
}
- if(fmt==NULL||pattern==NULL||patternLength<-1){
+ if(fmt==NULL || (pattern==NULL && patternLength!=0) || patternLength<-1) {
*status=U_ILLEGAL_ARGUMENT_ERROR;
return ;
}
if(parseError==NULL){
parseError = &tErr;
}
- if(patternLength<-1){
- patternLength=u_strlen(pattern);
- }
+ // UnicodeString(pattern, -1) calls u_strlen().
((MessageFormat*)fmt)->applyPattern(UnicodeString(pattern,patternLength),*parseError,*status);
}
break;
case Formattable::kObject:
- default:
- // This will never happen because MessageFormat doesn't
- // support kObject. When MessageFormat is changed to
- // understand MeasureFormats, modify this code to do the
- // right thing. [alan]
- U_ASSERT(FALSE);
- *status=U_ILLEGAL_ARGUMENT_ERROR;
+ // Unused argument number. Read and ignore a pointer argument.
+ va_arg(ap, void*);
break;
+
+ default:
+ // Unknown/unsupported argument type.
+ UPRV_UNREACHABLE;
}
}
UnicodeString resultStr;
- FieldPosition fieldPosition(0);
+ FieldPosition fieldPosition(FieldPosition::DONT_CARE);
/* format the message */
((const MessageFormat*)fmt)->format(args,count,resultStr,fieldPosition,*status);
// support kObject. When MessageFormat is changed to
// understand MeasureFormats, modify this code to do the
// right thing. [alan]
- U_ASSERT(FALSE);
- break;
+ UPRV_UNREACHABLE;
// better not happen!
case Formattable::kArray:
- U_ASSERT(FALSE);
- break;
+ UPRV_UNREACHABLE;
}
}