+2016-07-22 Keith Marshall <keithmarshall@users.sourceforge.net>
+
+ Fix printf() field width parsing regression issue [#2309].
+
+ * mingwex/stdio/pformat.c (__imul10plus): Coerce any accumulated
+ negative total to zero; the only negative value to be handled is...
+ (PFORMAT_IGNORE): ...this; it ceases to be applicable, on first call
+ to __imul10plus(), to accumulate field width or precision.
+
2016-07-17 Keith Marshall <keithmarshall@users.sourceforge.net>
Correct source package omission of msvcrt-xref subdirectory.
static __pformat_inline__
/* Inline helper to accumulate a running total of successive
* decimal digits, optimized to use bitwise shifts to multiply
- * the total of more significant digits by ten.
+ * the total of more significant digits by ten; (note that we
+ * coerce negative totals to zero, since this implementation
+ * never needs to accumulate negative values, but it must be
+ * able to override an initial PFORMAT_IGNORE (-1) setting).
*/
int __pformat_imul10plus( int total, int units )
-{ return units + ((total == 0) ? 0 : ((total + (total << 2)) << 1)); }
+{ return units + ((total >= 0) ? ((total + (total << 2)) << 1) : 0); }
static
int __pformat_read_arg_index( const char **fmt )
if( (state < PFORMAT_END) && isdigit( c ) )
{
if( state == PFORMAT_INIT )
- /*
- * Initial digits explicitly relate to field width...
+ /* Initial digits explicitly relate to field width...
*/
state = PFORMAT_SET_WIDTH;
else if( state == PFORMAT_GET_PRECISION )
- /*
- * while those following a precision indicator
+ /* while those following a precision indicator
* explicitly relate to precision.
*/
state = PFORMAT_SET_PRECISION;
if( width_spec )
- {
- /* We are accepting a width or precision specification;
+ { /* We are accepting a width or precision specification;
* add the units value represented by the current digit,
* to ten times the value accumulated so far.
*/
*/
__pformat_putc( c, &stream );
}
-
/* Clean up the resource pool, which was allocated for local processing of
* the passed-in argument vector in either sequential or random order.
*/