[PATCH v3] ungetc: Guarantee single char pushback

Andreas Schwab schwab@suse.de
Mon Dec 9 13:14:00 GMT 2024


On Dez 09 2024, Siddhesh Poyarekar wrote:

> On 2024-12-08 20:40, Maciej W. Rozycki wrote:
>> On Fri, 6 Dec 2024, Siddhesh Poyarekar wrote:
>> 
>>> The C standard requires that ungetc guarantees at least one pushback, so
>>> put a single byte pushback buffer in the FILE struct to enable that.
>>   So what would the problem be if we instead replaced:
>>    int _flags2;
>> with
>>    short int _flags2;
>>    char _short_backupbuf[1];
>>    char _unused;
>
> I don't see an actual problem other than that of an application maybe
> using the upper bits of _flags2 for their own logic.  One could make the
> same argument for unused2, but the defence there is that there's precedent
> of struct expansion into unused2; the same can't be said about _flags2.

There is also the question of the probability that we eventually need
more than 16 flags here.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


More information about the Libc-alpha mailing list