Strange failure with numfmt on an eccentric system (Mac OS X 10.6.8): some
errors are not reported correctly.
===
FAIL: tests/misc/numfmt
=======================
< ... snip ...>
numfmt.pl: test fmt-err-3: stderr mismatch, comparing fmt-err-3.1 (expected)
and fmt-err-3.E (actual)
*** fmt-err-3.1 Mon Feb 11 11:55:16 2013
--- fmt-err-3.E Mon Feb 11 11:55:16 2013
***************
*** 1 ****
! numfmt: format 'hello%' ends in %
--- 1 ----
! numfmt: invalid format 'hello%' (width overflow)
fmt-err-4...
numfmt.pl: test fmt-err-4: stderr mismatch, comparing fmt-err-4.1 (expected)
and fmt-err-4.E (actual)
*** fmt-err-4.1 Mon Feb 11 11:55:16 2013
--- fmt-err-4.E Mon Feb 11 11:55:16 2013
***************
*** 1 ****
! numfmt: invalid format '%d', directive must be %['][-][N]f
--- 1 ----
! numfmt: invalid format '%d' (width overflow)
fmt-err-5...
fmt-err-6...
numfmt.pl: test fmt-err-6: stderr mismatch, comparing fmt-err-6.1 (expected)
and fmt-err-6.E (actual)
*** fmt-err-6.1 Mon Feb 11 11:55:16 2013
--- fmt-err-6.E Mon Feb 11 11:55:16 2013
***************
*** 1 ****
! numfmt: format '%f %f' has too many % directives
--- 1 ----
! numfmt: invalid format '%f %f' (width overflow)
fmt-err-7...
fmt-err-8...
fmt-err-9...
fmt-err-10...
numfmt.pl: test fmt-err-10: stderr mismatch, comparing fmt-err-10.1 (expected)
and fmt-err-10.E (actual)
*** fmt-err-10.1 Mon Feb 11 11:55:16 2013
--- fmt-err-10.E Mon Feb 11 11:55:16 2013
***************
*** 1 ****
! numfmt: grouping cannot be combined with --to
--- 1 ----
! numfmt: invalid format '%\'f' (width overflow)
fmt-err-11...
numfmt.pl: test fmt-err-11 failed: exit status mismatch: expected 0, got 1
fmt-1...
numfmt.pl: test fmt-1 failed: exit status mismatch: expected 0, got 1
fmt-2...
numfmt.pl: test fmt-2 failed: exit status mismatch: expected 0, got 1
fmt-3...
numfmt.pl: test fmt-3 failed: exit status mismatch: expected 0, got 1
fmt-4...
numfmt.pl: test fmt-4 failed: exit status mismatch: expected 0, got 1
===
It looks like all the errors are related to the "--format" option, and even
more strangely, most do produce errors but the wrong error messages.
One example is:
# On a 'normal' system:
$ ./src/numfmt --format "hello%"
./src/numfmt: format 'hello%' ends in %
# On this broken system
$ ./src/numfmt --format "hello%"
./src/numfmt: invalid format 'hello%' (width overflow)
In the source code, it seems to be related to this part, in
parse_format_string(), line 972:
970 i += strspn (fmt + i, " ");
971 errno = 0;
972 pad = strtol (fmt + i, &endptr, 10);
973 if (errno != 0)
974 error (EXIT_FAILURE, 0,
975 _("invalid format %s (width overflow)"), quote (fmt));
976
On this system (Mac OS X):
fmt = 'hello%'
i = 6
fmt+i = ''
And 'strtol' returns errno=EINVAL (22) instead of 0 - causing the incorrect
error message.
Investigating further...
-gordon
P.S.
This is a strange system, already has two other bugs associated with it (#13516
#13495).
Perhaps it's not worth supporting it?