Implementation errors in strtol()

Joerg Wunsch j at uriah.heep.sax.de
Sat Jan 22 09:50:05 PST 2005


As Andrey Chernov wrote:

> > even after checking that endptr moved can't check just

> I mean that another case still possible where errno check placed
> _before_ endptr checking, to detect, say, wrong user-entered "base"
> by EINVAL. It can't be detected by portable application in 100%
> cases, because EINVAL can be returned in other cases too.

But you'll probably agree that in 99.99 % of all cases, strtol() is
used using a fixed, developer-given value for base. ;-)

Btw., first checking for a valid conversion (using endptr), and then
checking errno would still work fine in that case, as after the
conversion was identified to be valid, the only source for errno ==
EINVAL remaining is a wrong value for `base'.  So there's still no
need to explicitly consider EINVAL in any other context...

But I guess we are really starting to bore anyone else, so if you
still disagree with the above, let's take that privately, poshalujsta.

-- 
cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)


More information about the freebsd-current mailing list