X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/51004dcb01e06fef634b61be77ed73dd61cb6db9..a01113dcd0f39d5da295ef82785beff9ed86fe38:/icuSources/i18n/umsg.cpp diff --git a/icuSources/i18n/umsg.cpp b/icuSources/i18n/umsg.cpp index 8143932e..9a5344e0 100644 --- a/icuSources/i18n/umsg.cpp +++ b/icuSources/i18n/umsg.cpp @@ -1,3 +1,5 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /* ******************************************************************************* * @@ -6,7 +8,7 @@ * ******************************************************************************* * file name: umsg.cpp -* encoding: US-ASCII +* encoding: UTF-8 * tab size: 8 (not used) * indentation:4 * @@ -319,7 +321,7 @@ umsg_applyPattern(UMessageFormat *fmt, 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 ; } @@ -327,10 +329,8 @@ umsg_applyPattern(UMessageFormat *fmt, 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); } @@ -463,13 +463,11 @@ umsg_vformat( const UMessageFormat *fmt, default: // Unknown/unsupported argument type. - U_ASSERT(FALSE); - *status=U_ILLEGAL_ARGUMENT_ERROR; - break; + UPRV_UNREACHABLE; } } UnicodeString resultStr; - FieldPosition fieldPosition(0); + FieldPosition fieldPosition(FieldPosition::DONT_CARE); /* format the message */ ((const MessageFormat*)fmt)->format(args,count,resultStr,fieldPosition,*status); @@ -592,13 +590,11 @@ umsg_vparse(const UMessageFormat *fmt, // 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; } }