[tz] [PROPOSED 2/2] strftime: conform better to POSIX+

Clive D.W. Feather clive at davros.org
Sat Aug 8 21:25:47 UTC 2020


Robert Elz said:
>   | a reliable way
>   | to determine whether 0 represents failure or buffer exhaustion
> 
> This is not necessary.
> 
> The cases can be distinguished by setting errno to 0 before the call,
> and checking afterwards (if 0 is returned) - if errno is set there was
> an error, if it is still 0, it is something else.

C has no requirement to leave errno unchanged on success.


| The value of errno is zero at program startup, but is
| never set to zero by any library function. The value of
| errno may be set to nonzero by a library function call
| whether or not there is an error, provided the use of errno
| is not documented in the description of the function in this
| International Standard.

strftime is not documented as using errno, so that wording applies.

This is because the library function may have to make a system call to
check how to behave and that may fail.

-- 
Clive D.W. Feather          | If you lie to the compiler,
Email: clive at davros.org     | it will get its revenge.
Web: http://www.davros.org  |   - Henry Spencer
Mobile: +44 7973 377646



More information about the tz mailing list