printf: Don't die on incomplete conversions

POSIX dictates here that incomplete conversions, like in

    printf %d\n 15.2

or

    printf %d 14g

are still printed along with any error.

This seems alright, as it allows users to silence stderr to accept incomplete conversions.

This commit implements it, but what's a bit weird is the ordering between stdout and stderr,
causing the error to be printed _after_, like

    15
    14
    15.1: value not completely converted
    14,2: value not completely converted

but that seems like a general issue with how we buffer the streams.

(I know that nonfatal_error is a copy of most of fatal_error - I tried
differently, and va_* is weird)

Fixes #5532.
This commit is contained in:
Fabian Homborg
2019-03-17 16:33:58 +01:00
parent aea4062906
commit 0bde698f81
5 changed files with 32 additions and 4 deletions

View File

@@ -72,3 +72,7 @@ printf 'long hex4 %X\n' 0xABCDEF12345678901
printf 'long decimal %d\n' 498216206594
printf 'long signed %d\n' -498216206595
printf 'long signed to unsigned %u\n' -498216206596
# Verify numeric conversion still happens even if it couldn't be fully converted
printf '%d\n' 15.1
echo $status