Implementation errors in strtol()

Andrey Chernov ache at nagual.pp.ru
Thu Jan 20 12:55:04 PST 2005


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/


More information about the freebsd-current mailing list