This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH] Use C99-compliant scanf under _GNU_SOURCE.
- From: Zack Weinberg <zackw at panix dot com>
- To: GNU C Library <libc-alpha at sourceware dot org>
- Cc: Joseph Myers <joseph at codesourcery dot com>, Rical Jasan <ricaljasan at pacific dot net>, Andreas Schwab <schwab at suse dot de>
- Date: Wed, 21 Feb 2018 13:01:53 -0500
- Subject: Re: [PATCH] Use C99-compliant scanf under _GNU_SOURCE.
- Authentication-results: sourceware.org; auth=none
- References: <firstname.lastname@example.org>
On Sat, Feb 10, 2018 at 1:17 PM, Zack Weinberg <email@example.com> wrote:
> The only difference between noncompliant and C99-compliant scanf is
> that the former accepts the archaic GNU extension '%as' (also %aS and
> %a[...]) meaning to allocate space for the input string with malloc.
> This extension conflicts with C99's use of %a as a format _type_
> meaning to read a floating-point number; POSIX.1-2001 standardized
> equivalent functionality using the modifier letter 'm' instead (%ms,
> %mS, %m[...]).
Ping. The details of this patch have been reviewed (thanks, Rical)
but I would like to hear opinions from more people than just me and
Joseph on which feature-test macros should expose the old scanf
family. We want this to match GCC's diagnostic behavior as closely as
possible, and we also want the default mode to be C99-compliant. The
tricky cases are e.g. -std=c89 -D_GNU_SOURCE should probably get old
scanf, and should it also get old vscanf? vscanf is currently treated
as new in C99, but was a GNU extension before then, and programs that
are using it expecting GNU %as won't be caught by the compiler.
There also seems to be some confusion about which revision of POSIX
added %ms: comparing
leads me to believe that it was added in POSIX.1-2008, but it's (sort
of) gated on __USE_XOPEN2K right now, which corresponds to
POSIX.1-2001, not -2008. "SD5-XSH-ERN-132 is applied" in the change
history on the Issue 7 version of the page makes me think it might
have been added in a minor update to -2001, but then why doesn't it
show up on the online version of -2001?