Re: Implementation errors in strtol()

From: Andrey Chernov <ache_at_nagual.pp.ru>
Date: Thu, 20 Jan 2005 23:55:01 +0300
On Thu, Jan 20, 2005 at 08:23:24PM +0100, Joerg Wunsch wrote:
> While the standard explicitly states that empty (or whitespace-only)
> input strings cause an empty subject sequence, which will in turn
> cause no conversion to be performed, single signs ("+" or "-") would
> contain a non-empty subject sequence, so a conversion has to take
> place.  FreeBSD erroneously returns EINVAL in that case.  As EINVAL is

Just what is eye-catching:

+- can't be compared to whitespace at all. Whitespace is not subject 
sequence (2) but initial sequence (1) according to POSIX.

Moreover, POSIX clearly allows EINVAL for strtol():
"If no conversion could be performed, 0 shall be returned and errno may 
be set to [EINVAL]"

Reading POSIX will really help you with this issue.

-- 
http://ache.pp.ru/
Received on Thu Jan 20 2005 - 19:55:04 UTC

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