Assaf Gordon wrote, On 02/11/2013 12:35 PM: > > Assaf Gordon wrote, On 02/11/2013 12:27 PM: >> Strange failure with numfmt on an eccentric system (Mac OS X 10.6.8): some >> errors are not reported correctly. >> >> [ ... ] >> >> >> And 'strtol' returns errno=EINVAL (22) instead of 0 - causing the incorrect >> error message. >>
The attached patch fixes the problem (tested on Mac OS 10.6.8 and Debian/Linux 3.2). -gordon
>From 68ff89d497fcaffe054f0ca619fd747db8fb4574 Mon Sep 17 00:00:00 2001 From: Assaf Gordon <[email protected]> Date: Mon, 11 Feb 2013 15:39:42 -0500 Subject: [PATCH] numfmt: fix strtol() bug src/numfmt.c: on some system, strtol() returns EINVAL if no conversion was performed. Ignore and continue if so. --- src/numfmt.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/src/numfmt.c b/src/numfmt.c index d87d8ef..6e7cf2f 100644 --- a/src/numfmt.c +++ b/src/numfmt.c @@ -970,7 +970,10 @@ parse_format_string (char const *fmt) i += strspn (fmt + i, " "); errno = 0; pad = strtol (fmt + i, &endptr, 10); - if (errno != 0) + /* EINVAL can happen if 'base' is invalid (hardcoded as 10, so can't happen), + or if no conversion was performed (on some platforms). Ignore & continue + if no conversion was performed */ + if (errno != 0 && (errno != EINVAL)) error (EXIT_FAILURE, 0, _("invalid format %s (width overflow)"), quote (fmt)); -- 1.7.7.4
