lib/src/: a2i_strto[iu](): Support other errno values An implementation of strto[iu]max(3) may choose to fail with for example ENOMEM. Behave well with those. The reason for the weird indentation is to reduce the diff in the following patch. Reported-by: Bruno Haible <bruno@clisp.org> Signed-off-by: Alejandro Colomar <alx@kernel.org>
diff --git a/lib/src/a2i/strtoi/strtoi/strtoi.h b/lib/src/a2i/strtoi/strtoi/strtoi.h index 900b2eb..cc76700 100644 --- a/lib/src/a2i/strtoi/strtoi/strtoi.h +++ b/lib/src/a2i/strtoi/strtoi/strtoi.h
@@ -53,9 +53,12 @@ if (e == NULL) st = errno; + else + if (errno != 0 && errno != EINVAL) + st = errno; else if (e == s) st = ECANCELED; - else if (errno == ERANGE || n < min || n > max) + else if (n < min || n > max) st = ERANGE; else if (*e != '\0') st = ENOTSUP;
diff --git a/lib/src/a2i/strtoi/strtou/strtou.h b/lib/src/a2i/strtoi/strtou/strtou.h index cfb0e45..a7761ed 100644 --- a/lib/src/a2i/strtoi/strtou/strtou.h +++ b/lib/src/a2i/strtoi/strtou/strtou.h
@@ -53,9 +53,12 @@ if (e == NULL) st = errno; + else + if (errno != 0 && errno != EINVAL) + st = errno; else if (e == s) st = ECANCELED; - else if (errno == ERANGE || n < min || n > max) + else if (n < min || n > max) st = ERANGE; else if (*e != '\0') st = ENOTSUP;