Ralph Corderoy [Sun, 16 Oct 2016 22:16:26 +0000 (23:16 +0100)]
Rename local enum to avoid clashing with NEW() macro.
Even if it doesn't in practice due to the lack of parenthesis, it makes
things more clean if all the enumerates have a common abbreviation
prefix.
Ralph Corderoy [Sun, 16 Oct 2016 18:38:36 +0000 (19:38 +0100)]
Add NEW(p) that sets p to mh_xmalloc'd memory sized by *p.
Use it for the simple cases. Again, saves having to check the same
identifier is given, possibly far apart after a superfluous cast.
Ralph Corderoy [Sun, 16 Oct 2016 17:49:32 +0000 (18:49 +0100)]
Add macro NEW0(p) that callocs, and use it in simple calls.
p is a pointer, the size of the contents of the pointer is allocated
with calloc via mh_xcalloc. It saves having to check every calloc to
ensure the space requested matches the pointer to which it is assigned.
Ralph Corderoy [Sun, 16 Oct 2016 17:24:51 +0000 (18:24 +0100)]
Put parameter names in h/utils.h memory function prototypes.
It can be a problem if there is a system creeps in a clashing macro,
e.g. `size', but that's unlikely and I think the documentation benefits.
Ralph Corderoy [Sun, 16 Oct 2016 17:21:15 +0000 (18:21 +0100)]
Add mh_xfree(), guarding free(3) from NULLs.
Perhaps all nmh's platforms cope with free(3) these days, but it gives
symmetry with the other mh_x* memory functions and if there is code
testing the pointer before calling free then it can use this instead.
Ralph Corderoy [Sun, 16 Oct 2016 17:17:31 +0000 (18:17 +0100)]
Tweak mh_xcalloc(); print size on error, follow POSIX.
Using `%zu' for the size_t value. That might be a problem on older
platforms, but we'll see. If asked for zero bytes then allocate one to
get a unique pointer.
Ralph Corderoy [Sun, 16 Oct 2016 17:08:29 +0000 (18:08 +0100)]
Tweak mh_xrealloc(); print size on error, follow POSIX.
Using `%zu' for the size_t value. That might be a problem on older
platforms, but we'll see. If asked for zero bytes then free an existing
pointer, only passing it to free(3) if it's non-NULL, and then allocate
a byte so a unique pointer is returned.
Ralph Corderoy [Sun, 16 Oct 2016 16:43:56 +0000 (17:43 +0100)]
Tweak mh_xmalloc(); print size in error, allocate zero bytes.
Using `%zu' for the size_t value. That might be a problem on older
platforms, but we'll see. If asked for zero bytes then allocate one
rather than exit; it's sometimes useful to allocate zero, but some
older platforms might not like it.
Ralph Corderoy [Sun, 16 Oct 2016 14:50:12 +0000 (15:50 +0100)]
Expand the test of scan's -forma; fails on first attempt.
For an email that's just `a:\nb:\nc:\n', a scan with `%{a}\n%{b}\n%{c}'
is one blank line short. If the `%{c}' has anything added then its line
prints. Break out of the loop so all the other tests are skipped.
Ralph Corderoy [Sun, 16 Oct 2016 14:25:37 +0000 (15:25 +0100)]
Don't test -reverse's boolean on every message number.
Test just once before the loop and define start, end, and increment.
Keep going whilst start is not end. Happy for underflow or overflow in
calculating end because msgnum will make the same transition. It can't
affect whether the loop runs at all since 0 is not a valid message
number.
Ralph Corderoy [Sun, 16 Oct 2016 13:19:56 +0000 (14:19 +0100)]
Fix bug where single-character headers were sometimes missed.
The hash function used to check if a header was of interest always used
its first three characters. For a single-character header that third
byte wasn't particularly set and so it was pot luck if the two hashes
matched, swayed by what was previously in the format string and in the
email's headers. Alter it to cope, including with an empty string.
Comment that it never gives 127 so leaves the last element of the
hash-table array unused. Alter test-header-parsing to stop declaring it
expects to fail.
Ralph Corderoy [Sun, 16 Oct 2016 11:44:32 +0000 (12:44 +0100)]
Change all Getc() callers to use EOF, not comparisons with 0.
Makes the logic that bit easier when you don't have to convert to EOF
mentally. No functional change intended.
Ralph Corderoy [Sun, 16 Oct 2016 11:23:57 +0000 (12:23 +0100)]
Don't increment bytes_read if returning EOF.
Don't know if this was actually causing a problem, or if it was wrong,
but bytes_read was always being incremented even if the later test
showed readpos was to be left unincremented and EOF returned instead.
All tests still pass so any breakage must be subtle!
Ralph Corderoy [Sun, 16 Oct 2016 11:13:59 +0000 (12:13 +0100)]
Fix spelling in comment. Alter case to match identifier.
vim will search matching case on `*', for example, so if searching for
`\<fdelim\>' the comment shouldn't use `Fdelim'.
Ralph Corderoy [Sun, 16 Oct 2016 10:43:45 +0000 (11:43 +0100)]
Add failing test case for single-character header parsing.
`scan -format '%{x}'' fails to find single-character header `x' in some
cases, depending on the position of the header in the file. Add a
simple test case, scan/test-header-parsing, for this that fails. Alter
the test harness to allow a test to indicate it expects to fail. When
it does, that's ignored. If it passes, that's then an error instead.
Did this because I don't know if or when it will be fixed and didn't
want it to be forgotten in the meantime. When it is fixed, the test can
be enhanced to cover many more possibilities. First noticed it with ad
hoc testing of my fewer-lseek change, but it is present in the released
1.6.
Ralph Corderoy [Sun, 16 Oct 2016 08:17:51 +0000 (09:17 +0100)]
Move -help and -version to the front of the man page options.
The man pages had -verbose and -help listed at the end of the synopsis.
This put them after mandatory arguments in some cases, e.g. post(8).
Put then at the front, swapping the order so -help is first, as novices
will want to know -help exists early on, and others can simply skip over
them rather than encounter them at the end when they're trying to track
the combinations of what they've read so far.
Ralph Corderoy [Sun, 16 Oct 2016 07:52:10 +0000 (08:52 +0100)]
Fix end of sentence spacing in man pages, and related problems.
troff(1) input that ends a sentence at the end of the line gets the
proper inter-sentence spacing when formatted. If the sentence ends
midline then two spaces must follow to get the same result, otherwise
the spacing looks odd. Similarly, if a full stop is not the end of a
sentence then it should have the zero-width escape appended so if
re-formatting the source happens to place it at the end of the line then
no large gap follows it: e.g. `e.g.\&'.
Replace `et. al.' with `et al'.
Ralph Corderoy [Sun, 16 Oct 2016 07:23:51 +0000 (08:23 +0100)]
Stop one lseek(2) per header fetched by m_getfld.c in common case.
Only call ftello(3) in enter_getfld() when track_filepos has been
requested; not often.
David Levine [Fri, 14 Oct 2016 17:27:32 +0000 (13:27 -0400)]
Instead of feeding stdin to script(1) in test-version-check,
create a simple shell script with the command to be run and feed
it to script via the SHELL environment variable or -S option.
Thanks to Ralph for suggesting this approach. We'll see if it
works on all of the buildbot hosts.
David Levine [Tue, 11 Oct 2016 12:53:32 +0000 (08:53 -0400)]
Moved gcc warning options from AM_CFLAGS back to CFLAGS, to
make it easier for packagers to override. This is a partial
rollback of commit f7eb978bd395752d3d9037ea4436b8e2db41f135.
David Levine [Mon, 10 Oct 2016 13:54:51 +0000 (09:54 -0400)]
Changed test suite's require_locale() to set the locale that it
finds, and added upper case versions of locale names to each test.
This should allow the tests to succeed on old Solaris.
David Levine [Thu, 6 Oct 2016 22:01:50 +0000 (18:01 -0400)]
A better fix than e87f37c27828723317a71291e31b34f39ec09098, because
c_reqencoding should be set for text content in replies if we don't
want it to be encoded. Scan the text content to see if it is 7- or
8-bit, and set c_reqencoding accordingly.
David Levine [Thu, 6 Oct 2016 13:11:45 +0000 (09:11 -0400)]
Enable SMTP 8BITMIME for messages with 8-bit content:
1) In post, look for a Content-Transfer-Encoding header. It has to
be the header for the message, not any MIME parts. If found,
post trusts that it's correct. If there isn't one, post scans
the entire message body for any 8-bit bytes.
2) If the message body is 8-bit:
If the server supports 8BITMIME, enable it.
If the server doesn't support 8BITMIME, fail with a message to
user that they need to encode the message for 7-bit transport.
David Levine [Wed, 5 Oct 2016 01:24:10 +0000 (21:24 -0400)]
Enabled check for 8-bit content in all text parts, not just those
with no specified character set, so that a Content-Transfer-Encoding
header will be added if needed.
Ken Hornstein [Sun, 2 Oct 2016 05:47:15 +0000 (01:47 -0400)]
Move the read buffer shuffling to BEFORE where we call the network
read routines; otherwise we can end up calling the lower layers with
a length of zero, which messes everything up.
Also make sure we reshuffle our pointers around if that happens.
David Levine [Sat, 1 Oct 2016 18:37:27 +0000 (14:37 -0400)]
mhfixmsg now replaces RFC 2047 encoding with RFC 2231 encoding of
name and filename parameters in Content-Type and Content-Disposition
headers, respectively.
David Levine [Thu, 29 Sep 2016 19:13:05 +0000 (15:13 -0400)]
Welcome message enhancements:
1) Disable if Welcome: disable component is in profile.
2) If MHCONTEXT is set, only print the message if the context file
already has a Version: reference where the version is old.
Oliver Kiddle [Wed, 28 Sep 2016 07:58:54 +0000 (09:58 +0200)]
back out use of RFC 2047 decoding on the filename
The RFCs clearly state that an encoded word should not be used in
the MIME parameters and the scheme from RFC2231 should be used
instead. nmh supports that. Unfortunately, other mail clients,
in particular gmail and IBM/Lotus Notes, produce messages with
the invalid encoding.
David Levine [Tue, 27 Sep 2016 12:28:47 +0000 (08:28 -0400)]
Updated start_test() and finish_test() to not update the test name
if there was a test failure. run_test disables exit on non-zero
status, but does increment failed.