Ralph Corderoy [Sat, 10 Dec 2016 14:19:43 +0000 (14:19 +0000)]
Document that adios() does not return. abort() ensures it won't.
Discussion with David confirmed that adios()'s de facto contract with
the caller is that it won't return. Document that, and add an abort(3)
to ensure it won't occur. Better that than return and blunder on until
a SEGV or corruption later.
Ralph Corderoy [Sat, 10 Dec 2016 14:11:13 +0000 (14:11 +0000)]
mhlsbr.c: Don't hide mhladios and mhldone behind macros.
Locally defined mhladios() and mhldone() were called as adios() and
done() thanks to #defines that hid the widely-used functions with those
names. Don't bother as it confuses the reader. Just call the local
variations directly to make clear it's not the standard implementation.
David Levine [Thu, 8 Dec 2016 21:27:40 +0000 (16:27 -0500)]
Replaced !iscntrl() with isprint().
To address Ralph's FIXME comment. One example where a byte would
have been printed with !iscntrl() is 0x24 is ISO 646 BASIC (Inv),
which is undefined. Also, added test cases to cover most of
get_param_value(). Also, replaced a couple of other FIXME's with
code comments.
David Levine [Sun, 20 Nov 2016 19:25:11 +0000 (14:25 -0500)]
Open infile before fixing each message.
Though the input file won't need to be opened if everything goes
well, do it early just in case there's a failure, and that failure
is running out of file descriptors.
It was several lines repeated each time, and it saves having to check
they're all identical. The original test pressed on if the MIME
parameter's value was an empty string; preserve that as it's spotted
later on.
David Levine [Sun, 13 Nov 2016 19:50:08 +0000 (14:50 -0500)]
Replaced docs/COMPLETION-BASH with etc/bash_completions_nmh.
It's generated from man/mh-chart.man, which in turn is generated.
Automake doesn't like generated files in docs, hence the move to
etc. And the new filename better fits usage, I think.
Did not provide support for completing message numbers. It can
be fooled by programs that take multiple switches with +
arguments.
COMPLETION-BASH was broken with current bash, anyway.
Ralph Corderoy [Sat, 12 Nov 2016 18:40:46 +0000 (18:40 +0000)]
m_getfld: Shuffle `delim' assignments slightly.
Document end state of the four pointers to parts of the delimiter.
fdelimlen can be, wrongly, one less without causing problems because a
second check uses edelimlen. The only side effect is an extra iteration
through m_getfld().
Ralph Corderoy [Sat, 12 Nov 2016 00:39:23 +0000 (00:39 +0000)]
m_getfld: Replace matchc() with memmem(3).
libc is more likely to find one lump of memory inside another quicker
than a home-grown quadratic emulation of the VAX's MATCHC instruction.
memmem() isn't POSIX, but exists on Linux and FreeBSD. This will see if
the buildbot is happy.
Ralph Corderoy [Sat, 12 Nov 2016 00:31:36 +0000 (00:31 +0000)]
m_getfld: Remove never-true test in matchc().
Now the fdelimlen doesn't include the NUL it is never true. I didn't
understand how it could ever be true but gcov on the test suite was
showing 22e6 tests had three positives; that's what put me on to
fdelimlen's overshoot.
Ralph Corderoy [Fri, 11 Nov 2016 23:23:11 +0000 (23:23 +0000)]
m_getfld: Shorten fdelimlen by one; it was too long.
The fdelimlen bytes starting at fdelim included a NUL at the end, e.g. 7
for "\nFrom \0". Other code seems not to expect this and has
conditional bits to work around it, perhaps without understanding why.
All the tests still pass, including with valgrind.
Ralph Corderoy [Fri, 11 Nov 2016 00:38:29 +0000 (00:38 +0000)]
dlocaltime(): Only call tzset(3) once.
This avoids the stat(2) of /etc/localtime per message scan if TZ isn't
set in the environment; that's the default case on this Linux system.
I can't see a way the TZ environment variable is likely to change
between messages, or that it's intended an invocation of scan(1), say,
copes with the timezone shifting underneath it by /etc/localtime being
changed.
Ralph Corderoy [Tue, 1 Nov 2016 11:11:11 +0000 (11:11 +0000)]
test: Remove the " # gcov" comment from check_exit calls.
Now the command is passed to check_exit, that is sufficient to indicate
it's for coverage uses only, and a candidate to be fleshed out into a
test that checks the output.
Ralph Corderoy [Tue, 1 Nov 2016 00:05:42 +0000 (00:05 +0000)]
anno: Stop segmentation violation on `-number 0'.
If atoi(3) returned zero, either because `0' was given or the number
could not be parsed, then the error message dereferenced an invalid
pointer. Found when trying to increase coverage with check_exit.
The tests aren't getting 100% coverage and the nested assignments make
it harder to see what's happening, and what needs to happen to gain
coverage. Hoist invariants so it's clear they're such to the reader and
not just the compiler.
Ralph Corderoy [Mon, 31 Oct 2016 17:18:11 +0000 (17:18 +0000)]
test/common.sh.in: Add test_exit() for $? checking.
The stdout and stderr of the command being tested are saved but ignored,
only regurgitated if the test fails. The test is stated as a fragment
of a test(1) condition, e.g. '-eq 1'. This is mainly intended for the
quick one-liners to increase gcov coverage and thus valgrind's scope.
Over time, better tests that check more of the command's behaviour can
replace these, keeping the coverage level.