Ralph Corderoy [Sun, 20 Aug 2017 13:16:09 +0000 (14:16 +0100)]
cppflags.m4: Don't trample CFLAGS and CPPFLAGS.
They were always being restored, but not necessarily saved first. There
might still be some odd behaviour in this area. I'm seeing -D...
preprocessor symbols disappear on subsequent runs causing compilation
problems, e.g. strcasecmp(3) not prototyped.
Ralph Corderoy [Sun, 20 Aug 2017 11:20:45 +0000 (12:20 +0100)]
sbr/mf.c: Simplify logic, ditching endless for-loops and switch.
Some of the control flow follows the pattern of the larger sections: an
endless for-loop with a switch, and then cases that continue or break,
and another break out of the for loop. For the simpler cases, it's much
easier to read a simple while-loop that achieves the same in fewer
lines. No functional change intended.
Ralph Corderoy [Sun, 20 Aug 2017 10:56:55 +0000 (11:56 +0100)]
sbr/mf.c: Remove QUOTE macro, use its '\\' definition instead.
The name suggests a quote character, not the backslash as an escape
character that quotes what comes after it. It's easier to read '\\' and
instantly know what's meant.
Ralph Corderoy [Sun, 20 Aug 2017 10:38:04 +0000 (11:38 +0100)]
contains8bit(): Don't fetch a byte when start >= end.
The test for a NUL byte was before the test for start being before end.
Whilst here, hoist the test of end out of the per-byte loop, alter the
function to return bool, and merge the two, different, comments
explaining the function's behaviour.
Ralph Corderoy [Sat, 19 Aug 2017 14:58:49 +0000 (15:58 +0100)]
test-sendfiles: Feed `lzma -cd' stdin rather than a filename.
HÃ¥kon Alstadheim reported that Debian's lzma-9.22-2 would complain at
`lzma -cd foo.tar' with `unknown suffix -- unchanged' even though it was
not being asked to alter the file, or produce a new one based on its
filename. This appears to be https://bugs.debian.org/700681. The lzma
from Arch Linux's xz 5.2.3-1 does no have this fault. Work around it by
feeding the file to decompress on standard input for all the compression
programs being tested; none of the others should mind.
David Levine [Thu, 17 Aug 2017 23:45:20 +0000 (19:45 -0400)]
Default CFLAGS to -std=c99 instead of -ansi.
gcc -ansi -pedantic issued a few warnings about C90 not supporting the
"ll" printf length modifier. Ralph pointed out that
http://www.unix.org/version4/overview.html says:
The following source code portability standards lie at the core of
the Single UNIX Specification:
POSIX.1-2008
(This is technically identical to the Base Specifications, Issue 7;
they are one and the same document.)
The ISO/IEC 9899:1999 standard
So perhaps we're wrong to expect modern POSIX code to compile as C90.
Leonardo Taccari [Thu, 17 Aug 2017 23:42:48 +0000 (19:42 -0400)]
mhical expected an ics file as input and after just pressing
^D I've found that mhical wasn't happy about an empty input.
A trivial patch that should fix this issue.
Ralph Corderoy [Thu, 17 Aug 2017 11:20:16 +0000 (12:20 +0100)]
fmtdump.c, fmttest.c: Remove tests for FT_LIT_FORCE.
It isn't defined, and git-grep(1) suggests it was a local Lawrence
Berkeley Laboratory modification that output a literal without consuming
any of the width budget.
Ralph Corderoy [Thu, 17 Aug 2017 10:59:38 +0000 (11:59 +0100)]
Makefile.am: Remove multiple `mkdir -p' for etc; use ./configure.
A `mkdir -p' was used in each rule that created a file in etc to ensure
the directory already existed. Ken pointed out existing ./configure
code to do that for the man directory, just once. Use that for etc too.
Remove the `test -d' because `mkdir -p' does that itself.
Ken Hornstein [Thu, 17 Aug 2017 05:24:08 +0000 (01:24 -0400)]
Fix bug in cpnumber().
The cpnumber() function (which handles the NUMF instruction, among others)
would hang if a 0 width was given to it. Make sure that (and negative
widths) are handled correctly. Note that normally NUMF did not handle
left padding which is indicated by a negative width; that may change
in the future.
Ralph Corderoy [Sun, 13 Aug 2017 23:52:57 +0000 (00:52 +0100)]
inc.c: Use closure for pop_retr()'s action callback.
Allows file-static variables to become local to a function. In fact,
two of them no longer need to exist: one of them becomes the closure's
struct's member, and the other is always 0 and probably just present due
to copy and paste.
Ralph Corderoy [Sun, 13 Aug 2017 16:54:59 +0000 (17:54 +0100)]
popsbr.c: Alter traverse() to check action callback's result.
The action callback returned zero, with a 1999 comment asking if it was
checked. traverse() didn't check it. Change it so it does, wanting
`OK' if all's well, else returning the non-OK value to traverse's
caller; though that only checks for NOTOK. No functional change
intended.
Ralph Corderoy [Sun, 13 Aug 2017 16:13:34 +0000 (17:13 +0100)]
pop_retr(): Add a `void *closure' to be passed to action callback.
Only caller passes in NULL for the moment, and doesn't use it in the
callback, but it will allow fewer scopes by name of the variables the
action callback uses.
Ralph Corderoy [Sun, 13 Aug 2017 15:58:14 +0000 (16:58 +0100)]
inc.c: Narrow scope of inc_type. Chain mutually-exclusive ifs.
Joining the separate if-statements with `else' tells the reader it's not
expected that more than one branch can be taken. Useful when each is
many lines long. No functional change intended.
Ralph Corderoy [Sun, 13 Aug 2017 15:33:06 +0000 (16:33 +0100)]
scan(): Don't ioctl(2) for TTY's width every call.
Saves a system call per message scanned. Does mean it won't adjust
should the terminal width change mid scan, but that seems fine; after
all, the retrieved width could be out of date by the time a message's
output is written anyway.
Ralph Corderoy [Sun, 13 Aug 2017 14:20:14 +0000 (15:20 +0100)]
m_getfld() et al: Replace with m_getfld2(), etc., in many places.
The difference is the FILE pointer isn't passed in on each call.
Instead, it's stored in the m_getfld_state_t once, on
m_getfld_state_init(). No functional change intended.
Ralph Corderoy [Fri, 11 Aug 2017 14:34:41 +0000 (15:34 +0100)]
mhparse.c: Cast ptrdiff_t from subtraction to long.
Cygwin's 32-bit doesn't like `%ld' for the `p - q' difference between
two pointers as the value is an int, not a long. printf(3)'s `t' length
modifier, for ptrdiff_t, can't be used as that's C99, and we're C90.
Cast the difference to a long explicitly instead.
Ralph Corderoy [Thu, 10 Aug 2017 14:44:20 +0000 (15:44 +0100)]
m_getfld() et al: Add wrapper without FILE *iob parameter.
m_getfld(), m_getfld_track_filepos(), and m_unknown() all take a FILE
*iob that's used to update *m_getfld_state_t, even though it's probably,
hopefully, the same as the previous calls. Create wrapper functions for
these with an arbitrary `2' suffix that don't have this parameter.
After checking the m_getfld_state_t is initialised, they pass in its
existing FILE *iob. This allows callers to transition to the wrappers
in the cases where it's obviously the same FILE *iob being passed in.
It isn't always obvious, in part because of the convention for calling
this variable `in', even when it's a file-level static, a word that also
occurs in comments.
Ralph Corderoy [Wed, 9 Aug 2017 22:56:27 +0000 (23:56 +0100)]
m_getfld.c: Alter Peek() to match Getc()'s structure.
Their logic was equivalent, but written differently, which didn't help
the reader easily see they were the same apart from whether the returned
character was consumed. Now they're visually similar too.
Ralph Corderoy [Wed, 9 Aug 2017 18:46:26 +0000 (19:46 +0100)]
m_getfld.c: Use intmax_t and PRIdMAX to printf off_t values.
Compiling for ISO C90 prohibits casting to long long and printing with
"%lld", and printing as "%ld" is wrong on Mac OS where David reports
off_t is long long.
Ralph Corderoy [Wed, 9 Aug 2017 16:03:24 +0000 (17:03 +0100)]
leave_getfld(): Don't follow fseeko(SEEK_SET) with ftello().
If fseeko(3) didn't error then we know the stream's position and the
ftello(3) is not needed. Set last_caller_pos to total_bytes_read
instead. This small change is a commit to help future bisecting.
Ralph Corderoy [Wed, 9 Aug 2017 15:00:17 +0000 (16:00 +0100)]
fmtdump.c: Add string for FT_LS_UNQUOTE case.
It was missing since e8635a8a1 and the default case that attempted to
format it as a number was faulty, fixed in 39ecf70bb. That fix broke
test/format/test-fmtdump as it expected the broken "blank line" to be
output instead.
Ralph Corderoy [Wed, 9 Aug 2017 14:42:48 +0000 (15:42 +0100)]
Silence more gcc format-string warnings.
By enabling more checks, gcc has found some real bugs, e.g. `printf(buf,
"%d", i)'. Other changes required duplicating the formatting call with
a constant format string; a local macro was used to avoid repeating all
the many arguments.
Ralph Corderoy [Wed, 9 Aug 2017 14:06:01 +0000 (15:06 +0100)]
mhparse.c: Use constant indent for second line of messages.
It was using knowledge of inform()'s workings to indent by the varying
width of global invo_name plus two for the following ": ". This also
cluttered every call's parameters with a strlen(), cast to an int for
printf's width specifier, and an empty string. All noise for little
gain.
Ralph Corderoy [Wed, 9 Aug 2017 13:49:53 +0000 (14:49 +0100)]
m_getfld.c: Alter Ungetc() to die if it can't rewind.
It used to return EOF to the caller in this case, but none of the three
callers bothered checking. And the other return value of a `peek' of
the character that would next be read was also unused.
Ralph Corderoy [Wed, 9 Aug 2017 13:32:29 +0000 (14:32 +0100)]
Teach gcc(1) that adios() and friends take printf formats.
It then checks their arguments. Correct the resulting warnings, e.g.
C89 doesn't have `%zu', but does say size_t shouldn't be wider than
long. Perhaps an autoconf test can detect if the `format' __attribute__
is supported.
Ralph Corderoy [Sun, 6 Aug 2017 17:15:41 +0000 (18:15 +0100)]
cpstripped(): Rewrite multi-byte version.
Removes the assert(3) failure reported on the list for 1.7-RC1 when a
non-space, non-cntrl, rune has a wcwidth(3) of -1; output L'?' in its
place. The old code also didn't reset mbtowc(3)'s state before trying
to parse "?"; that's handled differently now so isn't an issue. Pad
with the multi-byte encoding of L" ", having ensured the wcwidth(1) of
L' ' is one, rather than with a non-wchar_t ' '. Point out padding only
occurs in one particular case, and not the other two; quite odd.
Ralph Corderoy [Sat, 5 Aug 2017 16:16:39 +0000 (17:16 +0100)]
test/getcwidth: Add --ctype to dump locale's iswprint(), etc.
Didn't bother trying to `start - end' range the output.
Most of the time I want to slice and dice the output, or grep for a
particular value. If I want ranges then I can post-process.
Ken Hornstein [Tue, 1 Aug 2017 17:22:36 +0000 (13:22 -0400)]
Merge branch 'fix-post-bcc'
This branch fixes bug #51098; the lack of alias expansion on a From line
when doing a Bcc. Admittedly, this is rather an obscure bug, and AFAICT
it never worked in any version of MH or nmh, but it is fixed now.
David Levine [Sat, 17 Jun 2017 13:32:00 +0000 (09:32 -0400)]
Don't bypass scan_content() when expanding pseudoheaders.
expand_pseudoheader() would avoid the call to scan_content() in order
to inhibit use of quoted-printable for text content. Removed that;
the user still has control over the use of quoted-printable via
-maxunencoded. Though now, lines over 998 bytes long will always
be encoded.
Ralph Corderoy [Sat, 10 Jun 2017 17:32:08 +0000 (18:32 +0100)]
sbr/netsec.c: Report popped TLS error code, don't pop again.
ERR_get_error() pops an error code so having tested that value it should
also be the one that's reported in an error message, not another popped
error code by calling ERR_get_error() again as this misleads as to the
error's cause.
Ken Hornstein [Thu, 1 Jun 2017 16:26:23 +0000 (12:26 -0400)]
Remove ancient SENDMAILBUG code.
Old SMTP code used to treat a code 451 the same as code 250 (success). It's
not clear if this was ever a real bug in sendmail, but regardless this code
is long obsolete.
Ken Hornstein [Wed, 31 May 2017 18:39:48 +0000 (14:39 -0400)]
Normalize connection shutdown handling.
I originally tried to make things work so that the netsec client code gave
the client the option of closing the file descriptors if it wanted to, but
I was running into a problem where if TLS negotiation failed part of the
negotiation would be interpreted as connection data. The code has been
changed to have the sockets close when the SSL BIO is released and to
have netsec_shutdown unconditionally close the file descriptors.