Ralph Corderoy [Thu, 7 Sep 2017 09:16:36 +0000 (10:16 +0100)]
getpass.c: Don't fileno(NULL) when fopen("/dev/tty") fails.
If stdin is a TTY, but opening it for writing fails, then stdin and
stderr are used as defaults and the TTY doesn't have echo disabled. The
later test to restore echo just checks if stdin is a TTY and not that it
was opened successfully causing a NULL FILE pointer to be fileno(3)'d.
Fixes da6af9633. This function's logic remains a bit contorted; I went
for the minimal fix.
Ralph Corderoy [Thu, 7 Sep 2017 08:57:11 +0000 (09:57 +0100)]
smtp.c: Use read-end of pipe, not random integer.
Instead of `pdi[0]' the array of two elements was being indexed by `i'.
That is typically zero so everything works, but can be up to five
depending how many times fork(2) failed before succeeding. Fixes e65127948.
Ralph Corderoy [Tue, 5 Sep 2017 13:11:56 +0000 (14:11 +0100)]
man: Fix some of the font-changing macros' parameters.
Various recurring problems on two themes. `.BR foo,' lacks the space in
`.BR foo ,'. `.IR foo' doesn't need to alternate and can be just `.I
foo'. Other similar changes made, e.g. `.B foo' becoming `foo'.
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.