Ken Pizzini tz. at
Tue Jul 27 09:03:29 UTC 2004

On Tue, Jul 27, 2004 at 12:37:12AM -0700, Paul Eggert wrote:
> > snprintf's behavior is to return the number of characters that would have
> > been generated had the output buffer not been limited.
> Good catch.  Sorry, I misused snprintf.  (Wouldn't be the first time.  :-)

Ah; I didn't read the previous code carefully enough when I claimed
that Eggert did it right last time.  :-P

>  * If snprintf returns a negative value (this shouldn't happen --
>    perhaps if memory exhausted though?), asctime should probably leave
>    errno set to whatever snprintf set it to, rather than setting it to

There is a portability issue where some older snprintf() implementations
(e.g., glibc-2.0.6) returned -1 for the "buffer too small" conditon,
instead of the C99 specified behavior that Olson is mentioning.  I'm not
sure that errno is given a useful value in this situation (I don't have
old glibc documentation handy, and it may vary with other implementations
anyway), so it might still make sense to force errno=EOVERFLOW.

		--Ken Pizzini

More information about the tz mailing list