ICU-10585 Review fixes: Improve arg check, then don't skip res.setTo for preflight case

X-SVN-Rev: 34906
This commit is contained in:
Peter Edberg 2014-01-15 23:44:01 +00:00
parent c64fb93a29
commit 93ac2bd3b5

View file

@ -498,14 +498,14 @@ utrans_toRules( const UTransliterator* trans,
UBool escapeUnprintable,
UChar* result, int32_t resultLength,
UErrorCode* status) {
utrans_ENTRY(status) -1;
utrans_ENTRY(status) 0;
if ( (result==NULL)? resultLength!=0: resultLength<0 ) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;
}
UnicodeString res;
if (!(result==NULL && resultLength==0)) {
// NULL destination for pure preflighting: empty dummy string
// otherwise, alias the destination buffer
res.setTo(result, 0, resultLength);
}
res.setTo(result, 0, resultLength);
((Transliterator*) trans)->toRules(res, escapeUnprintable);
return res.extract(result, resultLength, *status);
}