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 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


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