Ralph Corderoy [Sat, 9 Sep 2017 20:56:42 +0000 (21:56 +0100)]
Refer to #include files from the root of nmh's source.
One of the -I options given to the C compiler is the root of the nmh
source. This means uip/foo.c's #include of the relative ../sbr/bar.h
can also be written more tidily as sbr/bar.h.
Ralph Corderoy [Sat, 9 Sep 2017 20:30:39 +0000 (21:30 +0100)]
icalparse.y: Remove else-block that returns by merging if-conditions.
The code tested two values to see if they were present, and if they
were, and were equal, then it returned this node. If either were
missing then this node was still returned because it matched the more
limited criteria that had already been tested. So the test for
returning this node can more simply be if either value to compare is
missing, or they're (both present and) equal.
`in_standard' was being used to decide between `standard' and `daylight'
in the error message, but it would always be false by that point.
`in_daylight' is what's passed to the parsing function so use that to
determine the string instead. Bug present since the initial
implementation.
Ken Hornstein [Fri, 8 Sep 2017 17:46:08 +0000 (13:46 -0400)]
Send a QUIT instead of RSET at session end when doing 'whom'.
When running 'whom -check' (which really invokes post(8)), at the
end of the SMTP session we would send a RSET instead of a QUIT. This was
technically a RFC violation (RFC 5321 says a QUIT has to be the last
thing you send), and this would cause some SMTP servers to complain.
So make sure if we're being invoked by whom to send a QUIT at the end
of the session. Reported by Ralph Corderoy.
Ken Hornstein [Fri, 8 Sep 2017 16:08:41 +0000 (12:08 -0400)]
Add a -credentials argument when we call post.
If we are using -check, post(8) will need to talk to a remote SMTP server,
and it might need to perform authentication when doing so. So include a
-credentials option if there is the appropriate line in the user's profile.
`cp' is walking through encoded[] when an error occurs and is stepped
back up to 20 elements to provide some lead-in context for the error
message. If might be stepped back to encoded-1, but it attempts to cope
with that by `cp ? cp : encoded'. cp is always non-NULL so true and cp
is printed. Presumably, `cp > encoded' was meant. But it's all a bit
of a rigmarole so just use min() instead to ensure cp stays within
encoded and print cp. Fixes bfc6b93af.
Ralph Corderoy [Fri, 8 Sep 2017 12:48:29 +0000 (13:48 +0100)]
content_error(): Don't strlen(invo_name) that might be NULL.
Earlier in content_error(), it checks invo_name isn't NULL before using
it. Later, it passes it to strlen(3) without the check. Either the
former is redundant or the latter wrong. Rather than work out which,
delete the strlen(invo_name) because it was only used for a
variable-width indent on a second diagnostic line. Instead, indent by a
fixed four spaces, which will look better when invo_name is stupidly
long anyway. Bug present since pre-git.
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.