This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Use C99-compliant scanf under _GNU_SOURCE.


On Sat, Feb 10, 2018 at 1:17 PM, Zack Weinberg <zackw@panix.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
http://pubs.opengroup.org/onlinepubs/9699919799/functions/fscanf.html
to http://pubs.opengroup.org/onlinepubs/009695399/functions/fscanf.html
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?

zw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]