Ralph Corderoy [Mon, 4 Sep 2017 09:07:35 +0000 (10:07 +0100)]
Replace FALSE and TRUE with C99's false and true.
Remove the duplicate definitions of FALSE and TRUE. Change a few
variables from int to bool at the same time. The semantics of bool are
different to int because `bool b = 42' maps 42 to 1, but if the code was
relying on that then it needs shaking out anyway.
Ralph Corderoy [Sun, 3 Sep 2017 22:29:36 +0000 (23:29 +0100)]
Replace boolean with bool everywhere.
boolean's comment said it existed to ensure storage was a char and not
an int so it could be packed in a struct, but the only struct using it
doesn't care about the space taken.
Ralph Corderoy [Sun, 3 Sep 2017 11:23:14 +0000 (12:23 +0100)]
ap.c, dp.c: exit(3) with 0 or 1, not [0, MAX_EXIT].
Don't attempt to indicate the number of failures through the exit status
as that's too constrained. Just stick to zero for none, and 1 for some.
Delete, the now unused, MAX_EXIT.
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.