/*
******************************************************************************
*
-* Copyright (C) 2001-2004, International Business Machines
+* Copyright (C) 2001-2008, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
{
u_localized_print_string *output = (u_localized_print_string *)context;
int32_t written = 0;
+ int32_t lengthOfResult = resultLen;
resultLen = ufmt_min(resultLen, output->available);
else {
written = u_sprintf_write(output, result, resultLen);
}
+
+ if (written >= 0 && lengthOfResult > written) {
+ return lengthOfResult;
+ }
return written;
}
va_list ap)
{
int32_t written = 0; /* haven't written anything yet */
+ int32_t result = 0; /* test the return value of u_printf_parse */
u_localized_print_string outStr;
}
/* parse and print the whole format string */
- u_printf_parse(&g_sprintf_stream_handler, patternSpecification, &outStr, &outStr, &outStr.fBundle, &written, ap);
-
+ result = u_printf_parse(&g_sprintf_stream_handler, patternSpecification, &outStr, &outStr, &outStr.fBundle, &written, ap);
+
/* Terminate the buffer, if there's room. */
if (outStr.available > 0) {
buffer[outStr.len - outStr.available] = 0x0000;
/* Release the cloned bundle, if we cloned it. */
u_locbund_close(&outStr.fBundle);
+ /* parsing error */
+ if (result < 0) {
+ return result;
+ }
/* return # of UChars written */
return written;
}