[PATCH] stdio: make scanf(%f) eat the same number of characters as strtod() would
Joseph Myers
josmyers@redhat.com
Thu Jan 2 17:08:55 GMT 2025
On Wed, 1 Jan 2025, Miklós Máté wrote:
> According to the spec the %f conversion specifier (and its synonyms) must
> behave exactly as strtod(). This behavior matches FreeBSD libc. On MSVC
No, scanf should read a string that is *or is a prefix of* a matching
string. (Footnote 330 in C23 says "fscanf pushes back at most one input
character onto the input stream. Therefore, some sequences that are
acceptable to strtod, strtol, etc., are unacceptable to fscanf.".) If
it's a prefix but not a matching sequence, that is a matching failure.
See bug 12701 and duplicates (18246 is probably a duplicate though not
currently marked as such).
If you're interested in working in this area, talk to Maciej first since
he's working on scanf testing.
--
Joseph S. Myers
josmyers@redhat.com
More information about the Libc-alpha
mailing list