ICU-890 use improved fillOuput function from cpputils
X-SVN-Rev: 4173
This commit is contained in:
parent
f7da078199
commit
499a3e2ac3
@ -132,8 +132,6 @@ ucal_getTimeZoneDisplayName(const UCalendar* cal,
|
||||
{
|
||||
if(U_FAILURE(*status)) return -1;
|
||||
|
||||
int32_t actLen;
|
||||
|
||||
const TimeZone& tz = ((Calendar*)cal)->getTimeZone();
|
||||
UnicodeString id(result, 0, resultLength);
|
||||
|
||||
@ -155,8 +153,7 @@ ucal_getTimeZoneDisplayName(const UCalendar* cal,
|
||||
break;
|
||||
}
|
||||
|
||||
T_fillOutputParams(&id, result, resultLength, &actLen, status);
|
||||
return actLen;
|
||||
return uprv_fillOutputString(id, result, resultLength, status);
|
||||
}
|
||||
|
||||
U_CAPI UBool
|
||||
|
@ -2567,9 +2567,7 @@ ucol_getDisplayName( const char *objLoc,
|
||||
if(U_FAILURE(*status)) return -1;
|
||||
UnicodeString dst(result, resultLength, resultLength);
|
||||
Collator::getDisplayName(Locale(objLoc), Locale(dispLoc), dst);
|
||||
int32_t actLen;
|
||||
T_fillOutputParams(&dst, result, resultLength, &actLen, status);
|
||||
return actLen;
|
||||
return uprv_fillOutputString(dst, result, resultLength, status);
|
||||
}
|
||||
|
||||
U_CAPI const char*
|
||||
|
@ -620,7 +620,7 @@ int32_t uprv_ucol_decompose (UChar curChar, UChar *result) {
|
||||
/*hangul ? Normalizer::IGNORE_HANGUL : 0,*/
|
||||
Normalizer::IGNORE_HANGUL,
|
||||
res, status);
|
||||
T_fillOutputParams(&res, result, 356, &resSize, &status);
|
||||
resSize = uprv_fillOutputString(res, result, 356, &status);
|
||||
|
||||
} else {
|
||||
const UChar *source = (const UChar*)&(DecompData::contents);
|
||||
|
@ -119,8 +119,6 @@ udat_format( const UDateFormat* format,
|
||||
{
|
||||
if(U_FAILURE(*status)) return -1;
|
||||
|
||||
int32_t actLen;
|
||||
|
||||
UnicodeString res(result, 0, resultLength);
|
||||
FieldPosition fp;
|
||||
|
||||
@ -128,14 +126,13 @@ udat_format( const UDateFormat* format,
|
||||
fp.setField(position->field);
|
||||
|
||||
((DateFormat*)format)->format(dateToFormat, res, fp);
|
||||
T_fillOutputParams(&res, result, resultLength, &actLen, status);
|
||||
|
||||
if(position != 0) {
|
||||
position->beginIndex = fp.getBeginIndex();
|
||||
position->endIndex = fp.getEndIndex();
|
||||
}
|
||||
|
||||
return actLen;
|
||||
return uprv_fillOutputString(res, result, resultLength, status);
|
||||
}
|
||||
|
||||
U_CAPI UDate
|
||||
@ -246,8 +243,6 @@ udat_toPattern( const UDateFormat *fmt,
|
||||
{
|
||||
if(U_FAILURE(*status)) return -1;
|
||||
|
||||
int32_t actLen;
|
||||
|
||||
UnicodeString res(result, 0, resultLength);
|
||||
|
||||
if(localized)
|
||||
@ -255,8 +250,7 @@ udat_toPattern( const UDateFormat *fmt,
|
||||
else
|
||||
((SimpleDateFormat*)fmt)->toPattern(res);
|
||||
|
||||
T_fillOutputParams(&res, result, resultLength, &actLen, status);
|
||||
return actLen;
|
||||
return uprv_fillOutputString(res, result, resultLength, status);
|
||||
}
|
||||
|
||||
// TBD: should this take an UErrorCode?
|
||||
@ -286,71 +280,63 @@ udat_getSymbols(const UDateFormat *fmt,
|
||||
{
|
||||
if(U_FAILURE(*status)) return -1;
|
||||
|
||||
int32_t actLen = 0;
|
||||
|
||||
const DateFormatSymbols *syms =
|
||||
((SimpleDateFormat*)fmt)->getDateFormatSymbols();
|
||||
int32_t count;
|
||||
const UnicodeString *res;
|
||||
UnicodeString res1(result, 0, resultLength);
|
||||
|
||||
|
||||
switch(type) {
|
||||
case UDAT_ERAS:
|
||||
res = syms->getEras(count);
|
||||
if(index < count) {
|
||||
T_fillOutputParams(&res[index], result, resultLength,
|
||||
&actLen, status);
|
||||
return uprv_fillOutputString(res[index], result, resultLength, status);
|
||||
}
|
||||
break;
|
||||
|
||||
case UDAT_MONTHS:
|
||||
res = syms->getMonths(count);
|
||||
if(index < count) {
|
||||
T_fillOutputParams(&res[index], result, resultLength,
|
||||
&actLen, status);
|
||||
return uprv_fillOutputString(res[index], result, resultLength, status);
|
||||
}
|
||||
break;
|
||||
|
||||
case UDAT_SHORT_MONTHS:
|
||||
res = syms->getShortMonths(count);
|
||||
if(index < count) {
|
||||
T_fillOutputParams(&res[index], result, resultLength,
|
||||
&actLen, status);
|
||||
return uprv_fillOutputString(res[index], result, resultLength, status);
|
||||
}
|
||||
break;
|
||||
|
||||
case UDAT_WEEKDAYS:
|
||||
res = syms->getWeekdays(count);
|
||||
if(index < count) {
|
||||
T_fillOutputParams(&res[index], result, resultLength,
|
||||
&actLen, status);
|
||||
return uprv_fillOutputString(res[index], result, resultLength, status);
|
||||
}
|
||||
break;
|
||||
|
||||
case UDAT_SHORT_WEEKDAYS:
|
||||
res = syms->getShortWeekdays(count);
|
||||
if(index < count) {
|
||||
T_fillOutputParams(&res[index], result, resultLength,
|
||||
&actLen, status);
|
||||
return uprv_fillOutputString(res[index], result, resultLength, status);
|
||||
}
|
||||
break;
|
||||
|
||||
case UDAT_AM_PMS:
|
||||
res = syms->getAmPmStrings(count);
|
||||
if(index < count) {
|
||||
T_fillOutputParams(&res[index], result, resultLength,
|
||||
&actLen, status);
|
||||
return uprv_fillOutputString(res[index], result, resultLength, status);
|
||||
}
|
||||
break;
|
||||
|
||||
case UDAT_LOCALIZED_CHARS:
|
||||
syms->getLocalPatternChars(res1);
|
||||
T_fillOutputParams(&res1, result, resultLength, &actLen, status);
|
||||
break;
|
||||
{
|
||||
UnicodeString res1(result, 0, resultLength);
|
||||
syms->getLocalPatternChars(res1);
|
||||
return uprv_fillOutputString(res1, result, resultLength, status);
|
||||
}
|
||||
}
|
||||
|
||||
return actLen;
|
||||
return 0;
|
||||
}
|
||||
|
||||
U_CAPI int32_t
|
||||
|
@ -273,7 +273,6 @@ u_vformatMessage( const char *locale,
|
||||
if(U_FAILURE(*status)) return -1;
|
||||
|
||||
int32_t patLen = (patternLength == -1 ? u_strlen(pattern) : patternLength);
|
||||
int32_t actLen;
|
||||
|
||||
// ========================================
|
||||
// Begin pseudo-parser
|
||||
@ -416,8 +415,7 @@ u_vformatMessage( const char *locale,
|
||||
FieldPosition fp;
|
||||
fmt.format(args, count, res, fp, *status);
|
||||
|
||||
T_fillOutputParams(&res, result, resultLength, &actLen, status);
|
||||
return actLen;
|
||||
return uprv_fillOutputString(res, result, resultLength, status);
|
||||
}
|
||||
|
||||
// For parse, do the reverse of format:
|
||||
|
@ -141,8 +141,6 @@ unum_format( const UNumberFormat* fmt,
|
||||
{
|
||||
if(U_FAILURE(*status)) return -1;
|
||||
|
||||
int32_t actSize;
|
||||
|
||||
UnicodeString res(result, 0, resultLength);
|
||||
FieldPosition fp;
|
||||
|
||||
@ -150,14 +148,13 @@ unum_format( const UNumberFormat* fmt,
|
||||
fp.setField(pos->field);
|
||||
|
||||
((NumberFormat*)fmt)->format(number, res, fp);
|
||||
T_fillOutputParams(&res, result, resultLength, &actSize, status);
|
||||
|
||||
if(pos != 0) {
|
||||
pos->beginIndex = fp.getBeginIndex();
|
||||
pos->endIndex = fp.getEndIndex();
|
||||
}
|
||||
|
||||
return actSize;
|
||||
return uprv_fillOutputString(res, result, resultLength, status);
|
||||
}
|
||||
|
||||
U_CAPI int32_t
|
||||
@ -170,8 +167,6 @@ unum_formatDouble( const UNumberFormat* fmt,
|
||||
{
|
||||
if(U_FAILURE(*status)) return -1;
|
||||
|
||||
int32_t actSize;
|
||||
|
||||
UnicodeString res(result, 0, resultLength);
|
||||
FieldPosition fp;
|
||||
|
||||
@ -179,14 +174,13 @@ unum_formatDouble( const UNumberFormat* fmt,
|
||||
fp.setField(pos->field);
|
||||
|
||||
((NumberFormat*)fmt)->format(number, res, fp);
|
||||
T_fillOutputParams(&res, result, resultLength, &actSize, status);
|
||||
|
||||
if(pos != 0) {
|
||||
pos->beginIndex = fp.getBeginIndex();
|
||||
pos->endIndex = fp.getEndIndex();
|
||||
}
|
||||
|
||||
return actSize;
|
||||
return uprv_fillOutputString(res, result, resultLength, status);
|
||||
}
|
||||
|
||||
U_CAPI int32_t
|
||||
@ -432,8 +426,6 @@ unum_getTextAttribute( const UNumberFormat* fmt,
|
||||
if(U_FAILURE(*status))
|
||||
return -1;
|
||||
|
||||
int32_t actSize = 0;
|
||||
|
||||
UnicodeString res(result, 0, resultLength);
|
||||
|
||||
switch(tag) {
|
||||
@ -455,7 +447,7 @@ unum_getTextAttribute( const UNumberFormat* fmt,
|
||||
|
||||
case UNUM_PADDING_CHARACTER:
|
||||
*result = ((DecimalFormat*)fmt)->getPadCharacter();
|
||||
actSize = 1;
|
||||
return 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -463,9 +455,7 @@ unum_getTextAttribute( const UNumberFormat* fmt,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (actSize != 1)
|
||||
T_fillOutputParams(&res, result, resultLength, &actSize, status);
|
||||
return actSize;
|
||||
return uprv_fillOutputString(res, result, resultLength, status);
|
||||
}
|
||||
|
||||
U_CAPI void
|
||||
@ -516,8 +506,6 @@ unum_toPattern( const UNumberFormat* fmt,
|
||||
{
|
||||
if(U_FAILURE(*status)) return -1;
|
||||
|
||||
int32_t actSize;
|
||||
|
||||
UnicodeString pat(result, 0, resultLength);
|
||||
|
||||
if(isPatternLocalized)
|
||||
@ -525,8 +513,7 @@ unum_toPattern( const UNumberFormat* fmt,
|
||||
else
|
||||
((DecimalFormat*)fmt)->toPattern(pat);
|
||||
|
||||
T_fillOutputParams(&pat, result, resultLength, &actSize, status);
|
||||
return actSize;
|
||||
return uprv_fillOutputString(pat, result, resultLength, status);
|
||||
}
|
||||
|
||||
U_CAPI void
|
||||
|
@ -351,7 +351,10 @@ utrans_transUChars(const UTransliterator* trans,
|
||||
|
||||
// Copy the string buffer back to text (only if necessary)
|
||||
// and fill in *neededCapacity (if neededCapacity != NULL).
|
||||
T_fillOutputParams(&str, text, textCapacity, textLength, status);
|
||||
textLen = uprv_fillOutputString(str, text, textCapacity, status);
|
||||
if(textLength != NULL) {
|
||||
*textLength = textLen;
|
||||
}
|
||||
}
|
||||
|
||||
U_CAPI void
|
||||
@ -378,5 +381,8 @@ utrans_transIncrementalUChars(const UTransliterator* trans,
|
||||
|
||||
// Copy the string buffer back to text (only if necessary)
|
||||
// and fill in *neededCapacity (if neededCapacity != NULL).
|
||||
T_fillOutputParams(&str, text, textCapacity, textLength, status);
|
||||
textLen = uprv_fillOutputString(str, text, textCapacity, status);
|
||||
if(textLength != NULL) {
|
||||
*textLength = textLen;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user