Re: Implementation errors in strtol()

From: Andrey Chernov <ache_at_nagual.pp.ru>
Date: Fri, 21 Jan 2005 01:40:18 +0300
On Thu, Jan 20, 2005 at 11:21:37PM +0100, Joerg Wunsch wrote:
> Nope.  "0" alone is a completely valid hexadecimal number,
> representing the value 0.  Conversion has to start at the 0 (as it is

I agree with you in this part, see my patch with POSIX quote.

> > +- may produce EINVAL, as POSIX says.
> 
> Where?

1) "If the subject sequence is empty or does not have the expected form, 
no conversion is performed;"
2) "If no conversion could be performed, 0 shall be returned and errno may 
be set to [EINVAL]."

All "expected forms" (integer, octal, hex, other bases constants) are 
perfectly described at the start and +- alone is not among them.

> Again, I'd value the C standard higher than Posix.  C says they form a
> valid subject sequence.  Thus, no error may be flagged.

But FreeBSD always tends to follow POSIX as final judge. At least in the 
past...

> I don't have Posix at hand, but SUSPv2 completely follows the C

You can download free PDF copy at their site, just register there.

> This is no excuse for violating standards.  If a user feels that a

This is just their intehtions explanation, not excuse. If several 
standards are in contradiction, POSIX vote is final. It may surprise you, 
but it covers and changes lots of cases comparing to minimalistic C 
standard. Such additions/changes are specially marked with different color 
(gray).

-- 
http://ache.pp.ru/
Received on Thu Jan 20 2005 - 21:40:40 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:26 UTC