POSIX strto*() functions MAY return EINVAL, so don't assume that only one

errno from them allowed and it is always ERANGE
This commit is contained in:
ache 2001-12-14 23:20:54 +00:00
parent 588c679809
commit 7c495473b7

View File

@ -470,7 +470,8 @@ getn(s)
r = strtol(s, &p, 10);
if (errno != 0)
error("%s: out of range", s);
error((errno == EINVAL) ? "%s: bad number" :
"%s: out of range", s);
while (isspace((unsigned char)*p))
p++;
@ -493,7 +494,8 @@ getq(s)
r = strtoq(s, &p, 10);
if (errno != 0)
error("%s: out of range", s);
error((errno == EINVAL) ? "%s: bad number" :
"%s: out of range", s);
while (isspace((unsigned char)*p))
p++;