ICU-1109 use more appropriate US::extract(), no need to NUL-terminate explicitly
X-SVN-Rev: 5800
This commit is contained in:
parent
6a8947faf3
commit
250e500aa3
@ -249,12 +249,10 @@ ResourceBundle::constructForLocale(const UnicodeString& path,
|
||||
const Locale& locale,
|
||||
UErrorCode& error)
|
||||
{
|
||||
char name[128];
|
||||
int32_t patlen = path.length();
|
||||
char name[300];
|
||||
|
||||
if(patlen > 0) {
|
||||
path.extract(0, patlen, name);
|
||||
name[patlen] = '\0';
|
||||
if(!path.empty()) {
|
||||
path.extract(name, sizeof(name), 0, error);
|
||||
resource = ures_open(name, locale.getName(), &error);
|
||||
} else {
|
||||
resource = ures_open(0, locale.getName(), &error);
|
||||
|
@ -763,10 +763,15 @@ umsg_vformat( UMessageFormat *fmt,
|
||||
UErrorCode *status)
|
||||
{
|
||||
|
||||
if(U_FAILURE(*status))
|
||||
if(status==0 || U_FAILURE(*status))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if(resultLength<0 || (resultLength>0 && result==0)) {
|
||||
*status=U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t count =0;
|
||||
const Formattable::Type* argTypes = ((MessageFormat*)fmt)->getFormatTypeList(count);
|
||||
Formattable args[MessageFormat::kMaxFormat];
|
||||
@ -820,16 +825,7 @@ umsg_vformat( UMessageFormat *fmt,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(result ==NULL || resultLength < resultStr.length()){
|
||||
*status = U_BUFFER_OVERFLOW_ERROR;
|
||||
}else{
|
||||
/* copy the resultStr to target buffer */
|
||||
//u_strcpy(result, resultStr.getUChars());
|
||||
int len = resultStr.length();
|
||||
resultStr.extract(0,len,result);
|
||||
result[len]=0;/* null terminate the string */
|
||||
}
|
||||
return resultStr.length();
|
||||
return resultStr.extract(result, resultStr.length(), *status);
|
||||
}
|
||||
|
||||
U_CAPI void
|
||||
@ -898,7 +894,6 @@ umsg_vparse(UMessageFormat *fmt,
|
||||
case Formattable::kString:
|
||||
aString = va_arg(ap, UChar*);
|
||||
args[i].getString(temp);
|
||||
//u_strcpy(aString, temp.getUChars());
|
||||
len = temp.length();
|
||||
temp.extract(0,len,aString);
|
||||
aString[len]=0;
|
||||
|
@ -687,12 +687,7 @@ unum_getSymbol(UNumberFormat *fmt,
|
||||
}
|
||||
|
||||
UnicodeString s=((DecimalFormat *)fmt)->getDecimalFormatSymbols()->getSymbol((DecimalFormatSymbols::ENumberFormatSymbol)symbol);
|
||||
int32_t length=s.length();
|
||||
if(buffer!=NULL && length<size-1) {
|
||||
s.extract(0, length, buffer);
|
||||
buffer[length]=0;
|
||||
}
|
||||
return length;
|
||||
return s.extract(buffer, size, *status);
|
||||
}
|
||||
|
||||
U_CAPI void U_EXPORT2
|
||||
|
Loading…
Reference in New Issue
Block a user