]> diplodocus.org Git - nmh/log
nmh
8 years agofmt_compile.c: Alter FINDCOMP(): the caller must supply the semicolon.
Ralph Corderoy [Sun, 10 Sep 2017 13:53:32 +0000 (14:53 +0100)]
fmt_compile.c: Alter FINDCOMP(): the caller must supply the semicolon.

The macro expands to a for-loop, including the semicolon body.  The
caller typically supplies their own semicolon.  This results in two on
one line that looks odd.  Alter the macro to have the for-loop inside a
do-while loop that doesn't have a semicolon, ensuring the caller must
supply it.

8 years agoargsplit(): Incorrect type used in sizeof calculation for array.
Ralph Corderoy [Sun, 10 Sep 2017 13:44:15 +0000 (14:44 +0100)]
argsplit(): Incorrect type used in sizeof calculation for array.

Switched to referring to the variable being assigned the resulting
memory rather than duplicating its type information.  Fixes 78211e93.

8 years agoget_file_info(): Flip logic throughout, reducing nesting.
Ralph Corderoy [Sun, 10 Sep 2017 13:22:29 +0000 (14:22 +0100)]
get_file_info(): Flip logic throughout, reducing nesting.

Now a series of small paragraphs, each of which might return on error.
Also, the Cygwin oddity described in the comment needs no special
handling given the recent bug fixes so it can be deleted.

8 years agoget_file_info(): Don't return filename from quote onwards on error.
Ralph Corderoy [Sun, 10 Sep 2017 12:38:18 +0000 (13:38 +0100)]
get_file_info(): Don't return filename from quote onwards on error.

If `file_name' contained a quote then `cp' points to it, and remains
pointing to it if any of concat(), popen(3), or fgets(3) fail to give
the expected result.  On returning, cp is not NULL and so strdup(cp) is
returned.  Also, if fgets() fails on Cygwin in the way the comment
describes then cp is wrongly free(3)'d.  (One of the problems with
generic variable names is their overloaded semantics cause faulty
re-use.)  Fixes b4f2851d and 0c50c669.

8 years agoget_file_info(): Don't dereference out of scope char array.
Ralph Corderoy [Sun, 10 Sep 2017 12:29:46 +0000 (13:29 +0100)]
get_file_info(): Don't dereference out of scope char array.

A pointer to `char buf[...]' is taken, the array being declared in a
block scope inside the function.  The pointer is passed to strdup(3) as
the function returned, but the array is by then out of scope.  Move the
array to the function's scope.  Fixes 0c50c669.

8 years agoReplace parallel MIME-preference arrays with struct array.
Ralph Corderoy [Sun, 10 Sep 2017 11:28:51 +0000 (12:28 +0100)]
Replace parallel MIME-preference arrays with struct array.

New array of struct has `type' and `subtype' members, replacing the old
preferred_types[] and preferred_subtypes[] arrays.

8 years agopidstatus(): Rewrite to print stopped and continued statuses too.
Ralph Corderoy [Sun, 10 Sep 2017 11:14:20 +0000 (12:14 +0100)]
pidstatus(): Rewrite to print stopped and continued statuses too.

Delete own versions of WTERMSIG and WCOREDUMP macros now we're assuming
POSIX.

8 years agopidstatus(): Delete commented-out code testing for exit(255).
Ralph Corderoy [Sun, 10 Sep 2017 10:35:20 +0000 (11:35 +0100)]
pidstatus(): Delete commented-out code testing for exit(255).

Pre-dating git, a test of wait(2)'s status having its top eight bits all
set was commented out an "I've no idea what this does" explanation.  The
top eight bits hold either exit(3)'s parameter or the signal that caused
the child to stop.  Either way, there are macros for pulling apart that
value and they're being used.  Perhaps they were broken on a much older
system.  Delete the comment, including its code.

8 years agoReplace printf("%s\n", foo) and similar with puts(foo).
Ralph Corderoy [Sun, 10 Sep 2017 10:21:42 +0000 (11:21 +0100)]
Replace printf("%s\n", foo) and similar with puts(foo).

8 years agodatetime.c: Flip if-conditions so returns move from else block.
Ralph Corderoy [Sat, 9 Sep 2017 22:27:00 +0000 (23:27 +0100)]
datetime.c: Flip if-conditions so returns move from else block.

Then there's no need for else-blocks after return.

8 years agoicalendar.l: Refer to base64.h relative to root of source.
Ralph Corderoy [Sat, 9 Sep 2017 21:56:45 +0000 (22:56 +0100)]
icalendar.l: Refer to base64.h relative to root of source.

Ken reported a missing-include-file problem when building so the product
ends up outside the source tree, e.g. running configure from elsewhere.
It must also depend on his environment, e.g. OS or compiler, because the
problem isn't reproducible with Arch Linux and gcc, and be specific to C
source built from other source files, e.g. lex(1).  However, given that
the existing sibling icalparse.h is referred to as sbr/..., duplicate
that so it builds for Ken too.

8 years agotest/getcanon.c: exit(3) with 0 or 1, not -1 or symbolic error code.
Ralph Corderoy [Sat, 9 Sep 2017 21:45:54 +0000 (22:45 +0100)]
test/getcanon.c: exit(3) with 0 or 1, not -1 or symbolic error code.

gethostname(3) returns -1 on failure and that was being returned from
main;  use 1 instead.  getaddrinfo(3) returns EAI_ADDRFAMILY et al on
failure, but here they're defined as small negative integers, unsuitable
for main()'s return value;  again, use 1 instead.  Along the way, flip
the logic so the end is nigh when possible, avoiding the cognitive
overhead of tracking state when continuing to read through the source.

8 years agotest/getfullname.c: Move return case first in if-else chain.
Ralph Corderoy [Sat, 9 Sep 2017 21:08:43 +0000 (22:08 +0100)]
test/getfullname.c: Move return case first in if-else chain.

8 years agoRefer to #include files from the root of nmh's source.
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.

8 years agoicalparse.y: Remove else-block that returns by merging if-conditions.
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.

8 years agoseq_setprev.c: Flip if-condition so return moves from else block.
Ralph Corderoy [Sat, 9 Sep 2017 17:29:58 +0000 (18:29 +0100)]
seq_setprev.c: Flip if-condition so return moves from else block.

Then no need for else block after return.

8 years agofolder_pack.c: Flip if-condition so return moves from else block.
Ralph Corderoy [Sat, 9 Sep 2017 17:28:31 +0000 (18:28 +0100)]
folder_pack.c: Flip if-condition so return moves from else block.

Then no need for else block after return.

8 years agoseq_setunseen.c: Flip if-condition so return moves from else block.
Ralph Corderoy [Sat, 9 Sep 2017 17:27:42 +0000 (18:27 +0100)]
seq_setunseen.c: Flip if-condition so return moves from else block.

Then no need for else block after return.

8 years agomhstoresbr.c: Flip if-condition so return moves from else block.
Ralph Corderoy [Sat, 9 Sep 2017 17:26:45 +0000 (18:26 +0100)]
mhstoresbr.c: Flip if-condition so return moves from else block.

Then no need for else block after return.

8 years agoread_switch_multiword.c: Flip if-condition so return moves from else block.
Ralph Corderoy [Sat, 9 Sep 2017 17:20:09 +0000 (18:20 +0100)]
read_switch_multiword.c: Flip if-condition so return moves from else block.

Then no need for else block after return.

8 years agodatetime.c: Don't atoi("0") if zone is NULL.
Ralph Corderoy [Sat, 9 Sep 2017 11:26:40 +0000 (12:26 +0100)]
datetime.c: Don't atoi("0") if zone is NULL.

8 years agodatetime.c: Fix parse-failure's error-message's daylight indication.
Ralph Corderoy [Sat, 9 Sep 2017 11:05:22 +0000 (12:05 +0100)]
datetime.c: Fix parse-failure's error-message's daylight indication.

`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.

8 years agodatetime.c: Replace some int with bool.
Ralph Corderoy [Sat, 9 Sep 2017 10:57:15 +0000 (11:57 +0100)]
datetime.c: Replace some int with bool.

8 years agoOnly call fork(2) once, not up to five times on failure.
Ralph Corderoy [Sat, 9 Sep 2017 10:32:01 +0000 (11:32 +0100)]
Only call fork(2) once, not up to five times on failure.

The existing loop that slept five seconds between each attempt was
copy-pasted widely.  Those days are gone.  Just call it once.

8 years agocontent_error(): Add missing va_end(3).
Ralph Corderoy [Sat, 9 Sep 2017 10:13:11 +0000 (11:13 +0100)]
content_error(): Add missing va_end(3).

A va_start(3) without a matching va_end() is undefined behaviour.

8 years agoSend a QUIT instead of RSET at session end when doing 'whom'.
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.

8 years agoAdd a -credentials argument when we call post.
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.

8 years agopopsbr.c: Remove impossible case from switch statement.
Ralph Corderoy [Fri, 8 Sep 2017 13:49:21 +0000 (14:49 +0100)]
popsbr.c: Remove impossible case from switch statement.

Actually, just convert the overkill switch statement into a couple of
if-statements as it's a lot less lines.

8 years agomhbuildsbr.c: Attempt fork(2) multiple times, as intended.
Ralph Corderoy [Fri, 8 Sep 2017 13:30:31 +0000 (14:30 +0100)]
mhbuildsbr.c: Attempt fork(2) multiple times, as intended.

The loop attempting fork() intends to try five times but the comparison
operator was wrong so would only try once.  Bug present since pre-git.

8 years agobase64.c: Don't out-of-bounds printf("%s", &encoded[-1]).
Ralph Corderoy [Fri, 8 Sep 2017 13:12:51 +0000 (14:12 +0100)]
base64.c: Don't out-of-bounds printf("%s", &encoded[-1]).

`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.

8 years agocontent_error(): Don't strlen(invo_name) that might be NULL.
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.

8 years agoreplsbr.c: In parent, free child's argv[] built before fork().
Ralph Corderoy [Thu, 7 Sep 2017 09:36:56 +0000 (10:36 +0100)]
replsbr.c: In parent, free child's argv[] built before fork().

Fixes ccafa1944.

8 years agogetpass.c: Don't fileno(NULL) when fopen("/dev/tty") fails.
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.

8 years agomhbuildsbr.c: Don't free(3) string then print it; do reverse.
Ralph Corderoy [Thu, 7 Sep 2017 09:03:25 +0000 (10:03 +0100)]
mhbuildsbr.c: Don't free(3) string then print it; do reverse.

Fixes c87ca5cca.

8 years agosmtp.c: Use read-end of pipe, not random integer.
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.

8 years agoRevised expected output with -prefer in test/mhlist/test-mhlist.
David Levine [Tue, 5 Sep 2017 14:51:00 +0000 (10:51 -0400)]
Revised expected output with -prefer in test/mhlist/test-mhlist.

Update to commit 5dce1b38ace6cf61398df3ee4ca5aee0e1dedb5d.

8 years agoman: Fix some of the font-changing macros' parameters.
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'.

8 years agoAdd -noprefer switch to mhshow, mhstore, and mhlist
Paul Fox [Sat, 2 Sep 2017 15:24:01 +0000 (11:24 -0400)]
Add -noprefer switch to mhshow, mhstore, and mhlist

Allow profile-specified -prefer switches to be cancelled from the
command line.

8 years agoChange the priority ordering for multiple -prefer switches
Paul Fox [Sat, 2 Sep 2017 13:13:44 +0000 (09:13 -0400)]
Change the priority ordering for multiple -prefer switches

Interpreting multiple -prefer switches in ascending priority
order allows the command line to override the user's profile.

8 years agoman: Use `.IR' for `foo(1)', not the few `.BR'.
Ralph Corderoy [Mon, 4 Sep 2017 11:01:35 +0000 (12:01 +0100)]
man: Use `.IR' for `foo(1)', not the few `.BR'.

8 years agoman: Change the tautological `the foo(1) man page' to `foo(1)'.
Ralph Corderoy [Mon, 4 Sep 2017 10:59:48 +0000 (11:59 +0100)]
man: Change the tautological `the foo(1) man page' to `foo(1)'.

8 years agooauth: Replace `if...return false; return true' with `return ...'.
Ralph Corderoy [Mon, 4 Sep 2017 09:42:17 +0000 (10:42 +0100)]
oauth: Replace `if...return false; return true' with `return ...'.

In functions returning bool, these are equivalent.

    Before:                 After:
        if (!foo())             return foo();
            return false;
        return true;

8 years agooauth.c: Remove unused assignments of function return value.
Ralph Corderoy [Mon, 4 Sep 2017 09:29:21 +0000 (10:29 +0100)]
oauth.c: Remove unused assignments of function return value.

`if ((status = foo()) != OK) return false;' doesn't need to set local
variable status.

8 years agoReplace FALSE and TRUE with C99's false and true.
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.

8 years agoprint_intro(): Change parameter brief from int to bool.
Ralph Corderoy [Mon, 4 Sep 2017 09:03:36 +0000 (10:03 +0100)]
print_intro(): Change parameter brief from int to bool.

8 years agoflist.c: Use bool instead of int for some of the flags.
Ralph Corderoy [Sun, 3 Sep 2017 22:37:52 +0000 (23:37 +0100)]
flist.c: Use bool instead of int for some of the flags.

8 years agoReplace boolean with bool everywhere.
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.

8 years agomh.h: Always define NMH_UNUSED as a cast to void.
Ralph Corderoy [Sun, 3 Sep 2017 14:41:04 +0000 (15:41 +0100)]
mh.h: Always define NMH_UNUSED as a cast to void.

The not-gcc-or-earlier-than-gcc-2 version was the identity function
seems unnecessary as what C99 compiler would complain about a cast to
void?

8 years agomh.h: Move the gcc-4.3-conditional macro definitions.
Ralph Corderoy [Sun, 3 Sep 2017 14:38:44 +0000 (15:38 +0100)]
mh.h: Move the gcc-4.3-conditional macro definitions.

Having them outside of the gcc-2 ones makes the logic easier to follow
as there's no nesting.

8 years agodropsbr.c: Remove unused ntohl() macro, and its NTOHLSWAP test.
Ralph Corderoy [Sun, 3 Sep 2017 12:35:34 +0000 (13:35 +0100)]
dropsbr.c: Remove unused ntohl() macro, and its NTOHLSWAP test.

Not used since e6c91771 removed support for ./.foo.map index for ./foo
mailbox.

8 years agofakehttp.c: Remove unused LINESIZE macro; never used.
Ralph Corderoy [Sun, 3 Sep 2017 12:32:24 +0000 (13:32 +0100)]
fakehttp.c: Remove unused LINESIZE macro; never used.

8 years agoconfig.c: Remove unused nmhdocdir() macro.
Ralph Corderoy [Sun, 3 Sep 2017 12:30:34 +0000 (13:30 +0100)]
config.c: Remove unused nmhdocdir() macro.

8 years agoap.c, dp.c: exit(3) with 0 or 1, not [0, MAX_EXIT].
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.

8 years agoDEFAULT_PAGER: Move from nmh.h to mh.h. Former is "config.h".
Ralph Corderoy [Sun, 3 Sep 2017 11:18:59 +0000 (12:18 +0100)]
DEFAULT_PAGER: Move from nmh.h to mh.h.  Former is "config.h".

The macro isn't related to platform independence, unlike the rest of
nmh.h, that starts by including config.h.

8 years agogeteditor.c: Hard-code the default, "vi".
Ralph Corderoy [Sat, 2 Sep 2017 23:22:18 +0000 (00:22 +0100)]
geteditor.c: Hard-code the default, "vi".

It was the only use of the DEFAULT_EDITOR macro, so that can be deleted.

8 years agoMove base64.c's prototypes from prototypes.h to new base64.h.
Ralph Corderoy [Sat, 2 Sep 2017 17:49:11 +0000 (18:49 +0100)]
Move base64.c's prototypes from prototypes.h to new base64.h.

8 years agomhbuild.man: Fix grammar indentation by expanding tabs.
Ralph Corderoy [Sat, 2 Sep 2017 16:38:33 +0000 (17:38 +0100)]
mhbuild.man: Fix grammar indentation by expanding tabs.

The grammar is pre-formatted using spaces for indentation.
A few lines had switched to tabs in 9b706433f.

8 years agodecodeBase64(): Limit length of error message on invalid input.
Ralph Corderoy [Sat, 2 Sep 2017 12:55:29 +0000 (13:55 +0100)]
decodeBase64(): Limit length of error message on invalid input.

Screenfuls of email were appearing on stderr.

8 years agoRestrict use of alloc_size function attribute to gcc >= 4.3.0.
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.

8 years agoMove read_line.c's prototypes from prototypes.h to new read_line.h.
Ralph Corderoy [Mon, 28 Aug 2017 18:57:16 +0000 (19:57 +0100)]
Move read_line.c's prototypes from prototypes.h to new read_line.h.

Add copyright comment to start of read_line.c whilst there.

8 years agoAdd ENDNULL macro for gcc's `sentinel' function attribute.
Ralph Corderoy [Mon, 28 Aug 2017 18:47:23 +0000 (19:47 +0100)]
Add ENDNULL macro for gcc's `sentinel' function attribute.

Annotate a few prototypes with it.

8 years agoMove terminal.c's prototypes from prototypes.h to new terminal.h.
Ralph Corderoy [Mon, 28 Aug 2017 18:33:53 +0000 (19:33 +0100)]
Move terminal.c's prototypes from prototypes.h to new terminal.h.

8 years agoFix spelling in comment.
Ralph Corderoy [Mon, 28 Aug 2017 17:13:17 +0000 (18:13 +0100)]
Fix spelling in comment.

8 years agoread_switch_multiword.c: siglongjmp(3) removes need for `else'.
Ralph Corderoy [Mon, 28 Aug 2017 17:09:59 +0000 (18:09 +0100)]
read_switch_multiword.c: siglongjmp(3) removes need for `else'.

8 years agomhlsbr.c: Don't need to `else' after longjmp() at end of then-block.
Ralph Corderoy [Mon, 28 Aug 2017 17:08:31 +0000 (18:08 +0100)]
mhlsbr.c: Don't need to `else' after longjmp() at end of then-block.

8 years agoRemove comment asking if siglongjmp(3) should be used; it is.
Ralph Corderoy [Mon, 28 Aug 2017 17:05:41 +0000 (18:05 +0100)]
Remove comment asking if siglongjmp(3) should be used;  it is.

77a8a873b switched from longjmp(3).

8 years agoDon't need to `else' after mhladios() at end of then-block.
Ralph Corderoy [Mon, 28 Aug 2017 17:00:11 +0000 (18:00 +0100)]
Don't need to `else' after mhladios() at end of then-block.

8 years agoGive mhldone() and mhladios() the NORETURN function attribute.
Ralph Corderoy [Mon, 28 Aug 2017 16:57:04 +0000 (17:57 +0100)]
Give mhldone() and mhladios() the NORETURN function attribute.

And remove `FALLTHRU' comments after their calls.

8 years agoDon't cast zero to pid_t for setpgid(2)'s first argument.
Ralph Corderoy [Mon, 28 Aug 2017 16:53:15 +0000 (17:53 +0100)]
Don't cast zero to pid_t for setpgid(2)'s first argument.

8 years agoDon't cast zero to char for storing at pointer to char.
Ralph Corderoy [Mon, 28 Aug 2017 16:52:12 +0000 (17:52 +0100)]
Don't cast zero to char for storing at pointer to char.

8 years agoDon't cast zero to a non-function pointer; use NULL instead.
Ralph Corderoy [Mon, 28 Aug 2017 16:49:29 +0000 (17:49 +0100)]
Don't cast zero to a non-function pointer;  use NULL instead.

Better still, omit it when BSS does the job, or C's treatment of
non-zero as true is sufficient.

8 years agomhparse: Change mhfixmsg flags from int to bool.
Ralph Corderoy [Mon, 28 Aug 2017 13:45:16 +0000 (14:45 +0100)]
mhparse: Change mhfixmsg flags from int to bool.

8 years agomhparse.h: Add externs for skip_mp_cte_check, etc.
Ralph Corderoy [Mon, 28 Aug 2017 13:35:15 +0000 (14:35 +0100)]
mhparse.h: Add externs for skip_mp_cte_check, etc.

Delete the local copies from the other user.

8 years agoDelete declaration already available from included header file.
Ralph Corderoy [Mon, 28 Aug 2017 13:34:44 +0000 (14:34 +0100)]
Delete declaration already available from included header file.

8 years agomhparse.h: Add externs for preferred_types[], etc.
Ralph Corderoy [Mon, 28 Aug 2017 13:25:11 +0000 (14:25 +0100)]
mhparse.h: Add externs for preferred_types[], etc.

Delete the local copies from other users.

8 years agoDelete declarations already available from included header files.
Ralph Corderoy [Mon, 28 Aug 2017 13:16:51 +0000 (14:16 +0100)]
Delete declarations already available from included header files.

8 years agomhbuildsbr.c: Include mhcachesbr.h. Delete copy of prototype.
Ralph Corderoy [Mon, 28 Aug 2017 12:52:48 +0000 (13:52 +0100)]
mhbuildsbr.c: Include mhcachesbr.h.  Delete copy of prototype.

8 years agomhfixmsg.c: Make mhfixmsgsbr() static.
Ralph Corderoy [Mon, 28 Aug 2017 12:50:41 +0000 (13:50 +0100)]
mhfixmsg.c: Make mhfixmsgsbr() static.

8 years agoMove NPARTS and NTYPES from mhparse.h to mhmisc.h.
Ralph Corderoy [Mon, 28 Aug 2017 12:37:24 +0000 (13:37 +0100)]
Move NPARTS and NTYPES from mhparse.h to mhmisc.h.

It's mhmisc.c that has the global arrays that use them.

8 years agomhmisc.h: Add mhmisc.c's global variables as externs.
Ralph Corderoy [Mon, 28 Aug 2017 12:32:38 +0000 (13:32 +0100)]
mhmisc.h: Add mhmisc.c's global variables as externs.

Delete the local copies from other users.

8 years agoCreate mhmisc.h with mhmisc.c's global-function prototypes.
Ralph Corderoy [Mon, 28 Aug 2017 12:25:53 +0000 (13:25 +0100)]
Create mhmisc.h with mhmisc.c's global-function prototypes.

Delete the many local copies from each caller.

8 years agoMake functions with no external callers by name static.
Ralph Corderoy [Mon, 28 Aug 2017 12:08:34 +0000 (13:08 +0100)]
Make functions with no external callers by name static.

8 years agorcvtty.c: Remove duplicate prototype. Other in mts.h.
Ralph Corderoy [Mon, 28 Aug 2017 11:47:38 +0000 (12:47 +0100)]
rcvtty.c: Remove duplicate prototype.  Other in mts.h.

8 years agoaliasbr.c: Remove duplicate prototypes. Others in aliasbr.h.
Ralph Corderoy [Mon, 28 Aug 2017 11:45:32 +0000 (12:45 +0100)]
aliasbr.c: Remove duplicate prototypes.  Others in aliasbr.h.

8 years agomhparam: exit(3) zero if all components found, else one.
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.

8 years agoEnsure that mhfixmsg exit status is either 0 or 1.
David Levine [Sun, 27 Aug 2017 13:25:21 +0000 (09:25 -0400)]
Ensure that mhfixmsg exit status is either 0 or 1.

Ralph noticed where exit status values were being accumulated, and those
values could include -1.

8 years agoAdd gcc's pure function attribute.
Ralph Corderoy [Sun, 27 Aug 2017 13:08:22 +0000 (14:08 +0100)]
Add gcc's pure function attribute.

Mark quite a few function prototypes with it.

8 years agoinc.c: Make maildir_srt() static.
Ralph Corderoy [Sun, 27 Aug 2017 12:52:46 +0000 (13:52 +0100)]
inc.c: Make maildir_srt() static.

8 years agoReplace add(foo, NULL) with mh_xstrdup(foo).
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.

8 years agoReplace strlen("foo") with LEN("foo").
Ralph Corderoy [Sun, 27 Aug 2017 10:53:26 +0000 (11:53 +0100)]
Replace strlen("foo") with LEN("foo").

The existing LEN() uses sizeof.

8 years agocontext_find.c: Hoist strlen(3) out of search loop.
Ralph Corderoy [Sun, 27 Aug 2017 10:47:02 +0000 (11:47 +0100)]
context_find.c: Hoist strlen(3) out of search loop.

8 years agoAdd die(fmt, ...). Equivalent to adios(NULL, fmt, ...).
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.

8 years agomhparam: Remove `libdir', deprecated in 1.7.
Ralph Corderoy [Sun, 27 Aug 2017 09:49:10 +0000 (10:49 +0100)]
mhparam: Remove `libdir', deprecated in 1.7.

Use existing `libexecdir' instead.

8 years agopick: Remove support for MHPDEBUG environment variable.
Ralph Corderoy [Sun, 27 Aug 2017 09:39:11 +0000 (10:39 +0100)]
pick: Remove support for MHPDEBUG environment variable.

It was deprecated in 1.7, and the -debug option gives the same
behaviour.

8 years agoAdd MAX_EXIT, value 120, to limit some more exit(3) values.
Ralph Corderoy [Sun, 27 Aug 2017 09:16:11 +0000 (10:16 +0100)]
Add MAX_EXIT, value 120, to limit some more exit(3) values.

mhparam(1) altered to use new macro.  ap(1) and dp(1) now limit.

8 years agomh_xmalloc() et al: Use C99's `%zu' to print size_t.
Ralph Corderoy [Sat, 26 Aug 2017 21:40:40 +0000 (22:40 +0100)]
mh_xmalloc() et al: Use C99's `%zu' to print size_t.

8 years agoTreat %(myhost) failure to match canonical hostname as information.
David Levine [Sat, 26 Aug 2017 20:06:52 +0000 (16:06 -0400)]
Treat %(myhost) failure to match canonical hostname as information.

Not an error from test-myhost.

8 years agoReplace printf("foo\n") with puts("foo").
Ralph Corderoy [Sat, 26 Aug 2017 18:24:05 +0000 (19:24 +0100)]
Replace printf("foo\n") with puts("foo").

8 years agoAdd gcc's nonnull function attribute.
Ralph Corderoy [Sat, 26 Aug 2017 18:19:16 +0000 (19:19 +0100)]
Add gcc's nonnull function attribute.

Apply it to some prototypes to get started.

8 years agoUse C99's variable-argument preprocessor macros for ALLOC_SIZE.
Ralph Corderoy [Sat, 26 Aug 2017 17:41:42 +0000 (18:41 +0100)]
Use C99's variable-argument preprocessor macros for ALLOC_SIZE.

ALLOC_SIZE2() can be deleted.