diff mbox

fix "Illegal number" on FreeBSD & macOS for x=; echo $((x))

Message ID 622da1b5-7459-375d-e810-c270c776ebb5@inlv.org (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show

Commit Message

Martijn Dekker March 7, 2018, 1:03 p.m. UTC
Op 07-03-18 om 06:26 schreef Herbert Xu:
> Martijn Dekker <martijn@inlv.org> wrote:
>>
>>> Since base is always a constant 0 or a constant 10, never a
>>> user-provided value, the only error that strtoimax will ever report on
>>> glibc systems is ERANGE. Checking only ERANGE therefore preserves the
>>> glibc behaviour, and allows the exact same set of errors to be detected
>>> on non-glibc systems.
>>
>> That makes sense, thanks.
> 
> Could you resend your patch with this change please?

OK, see below.

- M.


--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Herbert Xu March 10, 2018, 8:04 a.m. UTC | #1
On Wed, Mar 07, 2018 at 01:03:26PM +0000, Martijn Dekker wrote:
> Op 07-03-18 om 06:26 schreef Herbert Xu:
> > Martijn Dekker <martijn@inlv.org> wrote:
> >>
> >>> Since base is always a constant 0 or a constant 10, never a
> >>> user-provided value, the only error that strtoimax will ever report on
> >>> glibc systems is ERANGE. Checking only ERANGE therefore preserves the
> >>> glibc behaviour, and allows the exact same set of errors to be detected
> >>> on non-glibc systems.
> >>
> >> That makes sense, thanks.
> > 
> > Could you resend your patch with this change please?
> 
> OK, see below.

Patch applied.  Thanks.
diff mbox

Patch

diff --git a/src/mystring.c b/src/mystring.c
index 0106bd2..de624b8 100644
--- a/src/mystring.c
+++ b/src/mystring.c
@@ -125,7 +125,7 @@  intmax_t atomax(const char *s, int base)
 	errno = 0;
 	r = strtoimax(s, &p, base);

-	if (errno != 0)
+	if (errno == ERANGE)
 		badnum(s);

 	/*