Odp: Re: [PATCH] fputs return the number of characters written
Paul Eggert
eggert@cs.ucla.edu
Mon Sep 20 20:34:19 GMT 2021
I'm not convinced it'd be useful to modify puts / fputs, due to the
INT_MAX and portability issues mentioned. That being said....
[putting my standards-nerd hat on; apologies in advance]
On 9/20/21 11:39 AM, Siddhesh Poyarekar wrote:
> AFAICT, the return value is considered implementation defined[1],
[1] doesn't say the return value of 'puts' is implementation-defined. It
says merely that 'puts' returns a non-negative number on success. This
is in contrast to the specs for functions like 'malloc'[2], where the
spec is careful to say that the behavior of 'malloc (0)' is
implementation-defined on success.
The current glibc manual doesn't say what 'puts' returns, which is
surely a defect in the manual. The manual should use return-value
wording similar to that of 'fputs'.
Although the current glibc manual does say that 'fputs' returns a
non-negative value on success, it doesn't say which value, and this
vagueness is OK as far as POSIX goes, as POSIX doesn't say the behavior
is implementation-defined. So from what I can see, changing a successful
'puts' to return some other non-negative value is merely of pragmatic
concern rather than being an API or ABI event (as I understand these
things, anyway).
> [1]
> https://pubs.opengroup.org/onlinepubs/9699919799/functions/puts.html#tag_16_468
[2] https://pubs.opengroup.org/onlinepubs/9699919799/functions/malloc.html
More information about the Libc-alpha
mailing list