This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Use C99-compliant scanf under _GNU_SOURCE.
- From: Zack Weinberg <zackw at panix dot com>
- To: Rical Jasan <ricaljasan at pacific dot net>
- Cc: GNU C Library <libc-alpha at sourceware dot org>, Joseph Myers <joseph at codesourcery dot com>, Andreas Schwab <schwab at suse dot de>
- Date: Wed, 21 Feb 2018 20:04:52 -0500
- Subject: Re: [PATCH] Use C99-compliant scanf under _GNU_SOURCE.
- Authentication-results: sourceware.org; auth=none
- References: <20180210181736.11570-1-zackw@panix.com> <a185b849-9f90-12df-362b-e1c7ec0cdd8f@pacific.net>
On Mon, Feb 12, 2018 at 7:53 AM, Rical Jasan <ricaljasan@pacific.net> wrote:
> On 02/10/2018 10:17 AM, Zack Weinberg 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
>
> POSIX.1-2008, from what I could tell (Issue 7 of IEEE 1003.1, if I'm
> saying that right). This happens a few times throughout.
Fixed, thanks.
>> +#undef __GLIBC_USE_DEPRECATED_SCANF
>
> Should be a tab.
Fixed.
>> #ifdef __USE_ISOC99
>> -# if !defined __USE_GNU && !defined __REDIRECT \
>> - && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
>> +#if !__GLIBC_USE (DEPRECATED_SCANF) && defined __REDIRECT
>
> This #if should still be indented one space, I believe.
Yup, fixed.
> You might be
> able to get rid of the outer "#ifdef __USE_ISOC99" though, since it only
> wraps this this one block.
I don't think I can. Neither the inner if block nor the inner else
block should be exposed when __USE_ISOC99 is false.
>> -# else
>> +# elif !defined __REDIRECT
>
> Should this still include the "!defined __LDBL_COMPAT"? Or maybe put
> that on the line with DEPRECATED_SCANF, so it also wraps the __REDIRECT
> if-else?
I can simplify it a little, but ... this gets messy, because
ldbl-compat.h isn't participating in the fiction that our headers work
with a compiler that doesn't provide __asm__() redirections. I am
tempted to put an #error in sys/cdefs.h and see if anything comes out
of the woodwork (tinycc, maybe?)
zw