bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gnulib portability issues


From: Eric Blake
Subject: Re: gnulib portability issues
Date: Tue, 12 Jun 2012 08:19:12 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1

On 06/12/2012 08:03 AM, Rich Felker wrote:
> On Tue, Jun 12, 2012 at 06:12:39AM -0600, Eric Blake wrote:
>> And this simple program proves that most libc know how to push back more
>> than one byte, whether or not they differ from the original contents,
>> and especially in the common case where the byte still fits in the
>> buffer.  It's the corner case where the bytes being pushed back differ
>> from the backing store, and where they don't fit in the normal buffer
>> (perhaps because you have used setvbuf or friends), and therefore libc
>> has to malloc() some pushback storage, and if the malloc fails then so
>> does the ungetc().
> 
> This is where we (musl vs glibc and perhaps you) have very different
> design philosophies. Using a single non-switchable buffer simplifies
> all the stdio code paths a lot, and reduces the cost of unget/get
> cycles. I wouldn't look fondly on changing this for the sake of
> supporting something that the standard says applications can't rely
> upon.

We're talking past each other.  I never said that ungetc() should
support more than one pushback byte, only that most libc implementations
already do support it as an extension.  I fully agree with the current
standards that say that at most one pushback byte is portable, and GNU
m4 goes to great lengths to comply with that.  Furthermore, I claim that
musl need not go out its way to provide an extension where ungetc can be
used for more than one byte.

-- 
Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]