Ralph Corderoy [Mon, 29 May 2017 11:23:38 +0000 (12:23 +0100)]
uip/scansbr.c: Add PUTC() macro, similar to FPUTS().
FPUTS() exists, but all the putc(3) checks for error were written
alongside in longhand. May as well have a PUTC() to match, though
perhaps just the existing check of the FILE's sticky error state with
ferror(3) is sufficient and neither macro is required.
Ralph Corderoy [Mon, 29 May 2017 10:49:29 +0000 (11:49 +0100)]
uip/scansbr.c: Stop `scan -file' copying mailbox to /dev/null.
scan() was copying the mailbox to /dev/null when called for `scan -file
foo.mbox' because it used outnum being non-zero as the test of whether
to write instead of FILE pointer scnout being non-NULL. By switching,
we can avoid the opening of /dev/null that was just to give scnout a
valid value for the needless fputs(3), etc.
Add comment explaining scan()'s outnum input parameter's three
functions: -1, 0, and positive.
Ralph Corderoy [Sun, 28 May 2017 11:32:28 +0000 (12:32 +0100)]
sbr/mts.c: Delete mmdlm2; use same-valued mmdlm1 instead.
mmdlm1 and mmdlm2 had the same compile-time value. Both could be
changed at run-time by mts.conf(5), but d205d39a stopped that. Use
mmdlm1 instead of mmdlm2 and delete mmdlm2.
Ralph Corderoy [Sun, 28 May 2017 11:21:12 +0000 (12:21 +0100)]
sbr/mts.c: Make MMDF's delimeters fixed at compile time.
mts.conf(5) allowed `mmdelim1' and `mmdelim2' to alter the default MMDF
begin and end markers of four ASCII SOHs and an LF. There doesn't seem
to be a modern use for this, and nmh wouldn't have handled longer
markers correctly so remove the capability.
The comment claims -file is "interface from msh", but msh(1) was removed
in e6917522. The options remain as discussion on the list prompted
David to say he uses them occasionally.
Ralph Corderoy [Fri, 26 May 2017 22:34:10 +0000 (23:34 +0100)]
uip/mhparse.c: Fix body starting a byte too soon when no blank line.
m_getfld() returns BODY when the headers run into a line without a colon
instead of being separated from the body by a blank line. The file's
position and the returned `bufsz' differ from the normal case of a blank
line and then the start of the body, causing confusion. get_content()
was aware of the difference, documented it, and attempted to correct for
it, but got it wrong and included the `\n' that terminates the last real
header at the start of the "body". This affected a struct Content's
c_begin.
Use the correct file position for c_begin, adding a comment that
explains the theory for both cases. Add a test-mhlist case that checks
mhlist(1) states the body size is the same whether it is separated from
the headers by a blank line or not. Correct existing
test/bad-input/test-header test that expected the extra blank line to be
counted and to appear in the output.
Ralph Corderoy [Thu, 25 May 2017 13:36:59 +0000 (14:36 +0100)]
uip/comp.c: Delete single-use NULLMP macro.
It just cast 0 to a pointer to struct msgs and was used once, as a
function's parameter. Replace that with NULL since a prototype for the
function is visible.
Ralph Corderoy [Thu, 25 May 2017 12:53:27 +0000 (13:53 +0100)]
Remove support for ./.foo.map index for ./foo mailbox.
An MH-only index of a mailbox, mbox or MMDF format, called a map file,
could be built and maintained by packf(1), rcvpack(1), and slocal(1),
but since msh(1) was removed in e6917522, there hasn't been a user of
the index file so stop producing it and delete all the supporting code
in uip/dropsbr.c.
mbx_copy() loses its `mapping' and `noisy' parameters; noisy was only
used when mapping. Delete mbx_read() and mbx_size() as they have no
callers without maps.
Ralph Corderoy [Thu, 25 May 2017 12:03:53 +0000 (13:03 +0100)]
test/runpty.c: Add more detail to "timed out" message.
test/install-mh/test-version-check was skipped due to timeout, but it
took a lot less than the thirty-second timeout to run. Add start time
and the time now to the diagnostic, and select(2)'s return value.
Ralph Corderoy [Wed, 24 May 2017 18:22:02 +0000 (19:22 +0100)]
uip/inc.c: Delete POP3's -pack option for msh users.
inc(1)'s -pack option, only available with POP3 access, stored the
emails in a spool file instead of a folder. The man page says this was
intended for msh(1) users, but msh was deleted in e6917522. The spool
file was always in packf(1)'s MMDF format, no option of -mbox, and was a
rare producer of `map' files that indexed the spool file, again intended
for msh. Removing -pack makes deletion of map files elsewhere in the
code easier.
Ralph Corderoy [Tue, 23 May 2017 11:56:00 +0000 (12:56 +0100)]
Replace some "FALLTHRU" comments with control flow.
Instead of a case statement falling through, with a "FALLTHRU" comment,
to the follow case that just does a break, continue, goto, etc.,
control-flow statement, duplicate the statement in place of the comment.
Fall-through should be the exception, and saving a break statement
doesn't offset the cognitive cost when reading the source.
Ralph Corderoy [Sat, 20 May 2017 11:38:22 +0000 (12:38 +0100)]
test/inc/test-eom-align: Fix tests; they've never worked.
Instead of cycling through lots of mbox sizes, $STDIO_BUFSZ was always
used as the desired size resulting in tests A and B being duplicated 221
times each. Slowly, if using valgrind. The tests fail now they're
fixed.
`$Test' was being interpolated into the output, but has never existed.
Rephrase the output given a /^SKIP: / line follows from the test harness
due to the `exit 77'.
Ken Hornstein [Thu, 18 May 2017 18:03:09 +0000 (14:03 -0400)]
Remove support for aliases based on Unix groups.
Remove support for expanding aliases based on group membership (=) and
all users who have a particular primary group (+). This was the result
of a discussion on nmh-workers; these features were of dubious value, likely
not used, and interfered with RFC-2047 encoded names in alias files.
Ralph Corderoy [Wed, 17 May 2017 16:56:00 +0000 (17:56 +0100)]
uip/mhshowsbr.c: Increase buffer size for showing-content command.
Experimenting with small BUFSIZ to try and trigger programs caused one
test to fail because the code detected BUFSIZ was too small a string to
hold the command to execute. Use NMH_BUFSIZ instead.
Ken Hornstein [Thu, 18 May 2017 03:28:02 +0000 (23:28 -0400)]
After further reflection, I decided I didn't like that previous
implementation. Instead, allocate two ptys and connect one to standard
input and the other to standard output and standard error of the child
process. After the first data is received from the slave, close the
master connected to standard input; that will generate an EOF on input
to the child process. This ends up being much cleaner than looping and
waiting to send the EOF character to the child process.
Ken Hornstein [Thu, 18 May 2017 01:40:57 +0000 (21:40 -0400)]
Apparently on Linux if a slave pty is closed, instead of the master
getting an EOF they get an EIO, which strikes me as unfriendly. So
make sure we exit the main read loop without complaint on an EOF or
error.
Ken Hornstein [Thu, 18 May 2017 01:00:47 +0000 (21:00 -0400)]
Switch from using script(1) to a new custom utility, runpty. It turns out
on some systems script(1) has a bug that results in hangs that is simply
too difficult to test for, and this custom utility is simpler.
Ralph Corderoy [Wed, 17 May 2017 14:15:18 +0000 (15:15 +0100)]
uip/mhbuildsbr.c: Fix long-line truncation when BUFSIZ is 1024.
a23477eb changed one char array from BUFSIZ to NMH_BUFSIZ elements, but
the long line read into it was passed to user_content() that
strncpy(3)'d it, silently truncating, to another char array, still
BUFSIZ long. This show up on platforms where BUFSIZ is 1024 versus
NMH_BUFSIZ's minimum of 8192.
Ralph Corderoy [Wed, 17 May 2017 11:58:15 +0000 (12:58 +0100)]
test/mhbuild/test-cte: Move run_prog() to just before check().
Prepare the input and output files, then run the program and check the
result. Makes it easier to see every run is being checked if a,
sometimes large, expected-output file isn't being produced in between.
Ralph Corderoy [Wed, 17 May 2017 11:45:26 +0000 (12:45 +0100)]
test/common.sh.in: Clarify test name in failure message.
Some test names don't stand out as that when suffixed with `failed'
amidst all the other output. Change `foo failed' to `first test
failure: foo' instead. Also makes clear there's possibly other tests
that failed later.
Ralph Corderoy [Tue, 16 May 2017 10:35:49 +0000 (11:35 +0100)]
Merge sbr/norm_charmap.c into sbr/check_charset.c.
Alter norm_charmap() to be static now its only caller is in the same
file. I've checked the upstream cam.ac.uk source and it's still the
same and hasn't changed in years, so I don't think there's much benefit
from having it standalone to ease checking.
Ralph Corderoy [Tue, 16 May 2017 10:29:17 +0000 (11:29 +0100)]
Part 1 of merging sbr/norm_charmap.c into sbr/check_charset.c.
This commit won't compile, but I'm attempting to get the rename into git
so the history after the next, merge, commit will continue through both
parents.
Ralph Corderoy [Mon, 15 May 2017 17:06:19 +0000 (18:06 +0100)]
uip/mhshowsbr.h: Move in declarations from h/mhparse.h.
Delete non-existent markerform parameter from show_all_messages()'s
comment. Alter show_all_messages()'s definition's concatsw parameter to
match comment and prototype.
Ralph Corderoy [Mon, 15 May 2017 16:14:01 +0000 (17:14 +0100)]
uip/mhshowsbr.c: Create header file with exports' declarations.
Create a single set of externs for mhshowsbr.c's global variables. Have
the other users of those use the new include file instead of their own
declarations.
Ralph Corderoy [Mon, 15 May 2017 15:09:28 +0000 (16:09 +0100)]
uip/mhcachesbr.c: Move exported symbols to existing h/mhcachesbr.h.
Remove the user's copies of the declarations.
A static struct swit caches[] was declared everywhere that included
h/mhcachesbr.h. The larger number of includers causes `variable not
used' for `caches'. Move that declaration to uip/mhcachesbr.c and have
an exported `cache_policy' symbol that points to it for the existing
users.
Ralph Corderoy [Mon, 15 May 2017 13:40:52 +0000 (14:40 +0100)]
sbr/m_mktemp.h: Create with missing prototypes.
Some of sbr/m_mktemp.c's functions didn't have prototypes in a header
file so callers were declaring prototypes themselves. Have them include
the new header file instead.
Ralph Corderoy [Mon, 15 May 2017 13:23:53 +0000 (14:23 +0100)]
uip/picksbr.c: Use function prototypes for `nexus' functions.
Prototypes for ORaction(), etc., now state the parameters they expect.
Removed the args() macro, instead explicitly listing the arguments being
passed to functions.
Ralph Corderoy [Mon, 15 May 2017 13:12:21 +0000 (14:12 +0100)]
Specify function parameters in prototypes, mainly void.
These prototypes are all in *.[cl] source compared with the *.h of the
earlier commit. All but one had void added, that one's parameter was a
char pointer.
Ralph Corderoy [Sun, 14 May 2017 18:35:13 +0000 (19:35 +0100)]
sbr/dtimep.l: Remove redundant wrapping parenthesis in definitions.
It's been decades since a lex(1) didn't follow POSIX and treat `{foo}'
as parenthesis surrounding foo's definition. Other nmh lex files work
without the extra wrapping.
If the profile component nmh-storage was a single character, e.g. the
relative directory `d', then it would be dropped from the output path so
instead of `d/foo' being written, `/foo' would probably fail. I think
this was due to a faulty check for nmh-storage being `/'. Add a test
for a non-/ single-character nmh-storage.
Ralph Corderoy [Sun, 14 May 2017 10:23:33 +0000 (11:23 +0100)]
Use new PLURALS(n) macro instead of variety of tests.
Whether to output a plural noun in a message was decided by ternary
operators that tested n==1, n!=1, n>1, etc. Make them all consistent by
using PLURALS(n).
Ralph Corderoy [Sat, 13 May 2017 17:39:06 +0000 (18:39 +0100)]
uip/folder.c: Rewrite plural test to common form.
The common form is a choice between "" and "s". This one occurrence was
using " " and "s" so either output was a fixed width. Alter the
printf(3) format string from `%s' to `%1s' to provide that instead.
Allows the new code to be altered by an upcoming `plural' change.
Ralph Corderoy [Sat, 13 May 2017 17:35:15 +0000 (18:35 +0100)]
Makefile.am: Alter long lists to be sorted, one entry per line.
It was hard to see what files were included in some variables when
searching for the best place for new content. Some variables had
definitions that were almost sorted, by weren't. Switch to a
one-entry-per-line list, in `LC_ALL=C sort' order, documented at the
start of the file. Makes it easy to run through the lists and see the
patterns.
The space padding was added at the start of the output buffer, not the
start of the component being formatted. Caused by 92128dac's move to
dynamic allocation for fmt_scan()'s output. Only shows if the component
isn't at the start of the buffer. Expand existing
test/format/test-rightjustify to cover this.
Ralph Corderoy [Tue, 9 May 2017 22:10:06 +0000 (23:10 +0100)]
config/version.sh: Rewrite. Use uname(1), git-describe(1), and UTC.
Not sure why it searched through PATH manually for uname(1) and
hostname(1). uname and its -n option are POSIX so just use those. It
was the preference over hostname anyway.
Use git-describe(1), not just git-branch(1), as it gives more detail,
including --dirty to show the built source differs from the commit.
Specify the format for the build date, and its timezone; +0000.