David Levine [Tue, 29 Aug 2017 01:03:21 +0000 (21:03 -0400)]
Restrict use of alloc_size function attribute to gcc >= 4.3.0.
It's not supported by gcc 4.2.4. CHECK_PRINTF doesn't work
perfectly with gcc 4.2.1, so disable that with gcc < 4.3.0 as
well. Fix to commit c066b395274021182a5f0530ccfeb1bcd167d860.
Ralph Corderoy [Sun, 27 Aug 2017 19:04:42 +0000 (20:04 +0100)]
mhparam: exit(3) zero if all components found, else one.
The exit status used to be a count of the number missing, clipped to
120. That doesn't seem useful, and is overhead to document, read, and
test. Use the normal Unix 0 or 1 instead.
Ralph Corderoy [Sun, 27 Aug 2017 11:13:39 +0000 (12:13 +0100)]
Replace add(foo, NULL) with mh_xstrdup(foo).
add()'s arguments are back to front so add(foo, bar) produces bar+foo in
the normal case. Thus add(foo, NULL) is read as the jarring NULL+foo.
Removing the NULL with mh_xstrdup() avoids this. FENDNULL is used when
it isn't obvious foo can't be NULL as add() treats it as "" in that
case.
Ralph Corderoy [Sun, 27 Aug 2017 10:34:50 +0000 (11:34 +0100)]
Add die(fmt, ...). Equivalent to adios(NULL, fmt, ...).
Avoids the noise of the `NULL' first parameter that's used in over 70%
of adios() calls. Removes the possibility of it being omitted and `fmt'
being used instead. `die' is already in use in nmh's shell scripts.
Had to rename post.c's existing die() to avoid it clashing.
Ralph Corderoy [Fri, 25 Aug 2017 21:36:01 +0000 (22:36 +0100)]
Print pointers in debug with C99's `%p' rather than `0x%x'.
The `%x' needed a double cast, the `%p' needs just a single to void
pointer. The output can differ, e.g. `0x0' v. perhaps
implementation-defined `(nil)'.
Ralph Corderoy [Fri, 25 Aug 2017 21:20:17 +0000 (22:20 +0100)]
picksbr.c: fprintf function pointer with unsigned-long-long cast.
It was previously a double cast, to unsigned long, and then to unsigned
int, and formatted with `0x%x'. Now we're C99, at least, we can use
unsigned long long and `%#llx'. Though the fprintf() in question should
be a BUG() that abort(3)s.
Ralph Corderoy [Fri, 25 Aug 2017 08:45:00 +0000 (09:45 +0100)]
build_nmh: Stop -d enabling assert(3)s.
c347c3bb enabled asserts by default so alter -d's description to not say
it enables them as this may make users thing that have to disable
optimisation, -d's other action, to get them. Don't add
`--enable-assert' to configure's options.
Ralph Corderoy [Wed, 23 Aug 2017 20:20:25 +0000 (21:20 +0100)]
mhlistsbr.c: Replace list_application() with body at call site.
list_application()'s comment said the function didn't need to exist.
It's correct, so delete it. The sole caller now calls list_content(),
as list_application() used to do. That's actually the same as other
cases in the switch so merge them. There is a slight difference:
list_application() used to call list_content() and then return OK
regardless, now it returns list_content()'s value, but that's always OK
too.
Ralph Corderoy [Mon, 21 Aug 2017 10:09:02 +0000 (11:09 +0100)]
Add ZERO(p) for the typical memset(p, 0, sizeof *p) dance.
Also seen as memset(&foo->bar_xyzzy, 0, sizeof foo->bar_xyzzy). I find
it tedious to keep checking the parameters are in agreement when reading
the code.
Ralph Corderoy [Sun, 20 Aug 2017 13:16:09 +0000 (14:16 +0100)]
cppflags.m4: Don't trample CFLAGS and CPPFLAGS.
They were always being restored, but not necessarily saved first. There
might still be some odd behaviour in this area. I'm seeing -D...
preprocessor symbols disappear on subsequent runs causing compilation
problems, e.g. strcasecmp(3) not prototyped.
Ralph Corderoy [Sun, 20 Aug 2017 11:20:45 +0000 (12:20 +0100)]
sbr/mf.c: Simplify logic, ditching endless for-loops and switch.
Some of the control flow follows the pattern of the larger sections: an
endless for-loop with a switch, and then cases that continue or break,
and another break out of the for loop. For the simpler cases, it's much
easier to read a simple while-loop that achieves the same in fewer
lines. No functional change intended.
Ralph Corderoy [Sun, 20 Aug 2017 10:56:55 +0000 (11:56 +0100)]
sbr/mf.c: Remove QUOTE macro, use its '\\' definition instead.
The name suggests a quote character, not the backslash as an escape
character that quotes what comes after it. It's easier to read '\\' and
instantly know what's meant.
Ralph Corderoy [Sun, 20 Aug 2017 10:38:04 +0000 (11:38 +0100)]
contains8bit(): Don't fetch a byte when start >= end.
The test for a NUL byte was before the test for start being before end.
Whilst here, hoist the test of end out of the per-byte loop, alter the
function to return bool, and merge the two, different, comments
explaining the function's behaviour.
Ralph Corderoy [Sat, 19 Aug 2017 14:58:49 +0000 (15:58 +0100)]
test-sendfiles: Feed `lzma -cd' stdin rather than a filename.
HÃ¥kon Alstadheim reported that Debian's lzma-9.22-2 would complain at
`lzma -cd foo.tar' with `unknown suffix -- unchanged' even though it was
not being asked to alter the file, or produce a new one based on its
filename. This appears to be https://bugs.debian.org/700681. The lzma
from Arch Linux's xz 5.2.3-1 does no have this fault. Work around it by
feeding the file to decompress on standard input for all the compression
programs being tested; none of the others should mind.
David Levine [Thu, 17 Aug 2017 23:45:20 +0000 (19:45 -0400)]
Default CFLAGS to -std=c99 instead of -ansi.
gcc -ansi -pedantic issued a few warnings about C90 not supporting the
"ll" printf length modifier. Ralph pointed out that
http://www.unix.org/version4/overview.html says:
The following source code portability standards lie at the core of
the Single UNIX Specification:
POSIX.1-2008
(This is technically identical to the Base Specifications, Issue 7;
they are one and the same document.)
The ISO/IEC 9899:1999 standard
So perhaps we're wrong to expect modern POSIX code to compile as C90.
Leonardo Taccari [Thu, 17 Aug 2017 23:42:48 +0000 (19:42 -0400)]
mhical expected an ics file as input and after just pressing
^D I've found that mhical wasn't happy about an empty input.
A trivial patch that should fix this issue.
Ralph Corderoy [Thu, 17 Aug 2017 11:20:16 +0000 (12:20 +0100)]
fmtdump.c, fmttest.c: Remove tests for FT_LIT_FORCE.
It isn't defined, and git-grep(1) suggests it was a local Lawrence
Berkeley Laboratory modification that output a literal without consuming
any of the width budget.
Ralph Corderoy [Thu, 17 Aug 2017 10:59:38 +0000 (11:59 +0100)]
Makefile.am: Remove multiple `mkdir -p' for etc; use ./configure.
A `mkdir -p' was used in each rule that created a file in etc to ensure
the directory already existed. Ken pointed out existing ./configure
code to do that for the man directory, just once. Use that for etc too.
Remove the `test -d' because `mkdir -p' does that itself.