ICU-13210 remove unreachable code, improve pattern pointer check
X-SVN-Rev: 40491
This commit is contained in:
parent
0d9ef38e4c
commit
45a6728cbe
@ -321,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 ;
|
||||
}
|
||||
@ -329,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);
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ static void MessageFormatTest( void )
|
||||
UMessageFormat formatter = umsg_open(testCasePatterns[0],patternLength,"en_US",NULL,&ec);
|
||||
|
||||
if(U_FAILURE(ec)){
|
||||
log_data_err("umsg_open() failed for testCasePattens[%d]. -> %s (Are you missing data?)\n",i, u_errorName(ec));
|
||||
log_data_err("umsg_open() failed for testCasePattens[0]. -> %s (Are you missing data?)\n", u_errorName(ec));
|
||||
return;
|
||||
}
|
||||
for(i = 0;i<cnt_testCases; i++){
|
||||
@ -199,8 +199,9 @@ static void MessageFormatTest( void )
|
||||
UDate d2=0;
|
||||
|
||||
result=NULL;
|
||||
patternLength = u_strlen(testCasePatterns[i]);
|
||||
|
||||
// Alternate between specifying the length and using NUL-termination.
|
||||
patternLength = ((i & 1) == 0) ? u_strlen(testCasePatterns[i]) : -1;
|
||||
|
||||
umsg_applyPattern(formatter,testCasePatterns[i],patternLength,&parseError,&ec);
|
||||
if(U_FAILURE(ec)){
|
||||
log_err("umsg_applyPattern() failed for testCasePattens[%d].\n",i);
|
||||
|
Loading…
Reference in New Issue
Block a user