David Levine [Fri, 1 Feb 2013 01:43:09 +0000 (19:43 -0600)]
Redirected stderr to /dev/null in the test for presence of
/dev/tty. Solaris warns that it can't create the device.
This may not fix it, but it should help isolate which part of
the test is causing the warning.
Lyndon Nerenberg [Thu, 31 Jan 2013 11:56:55 +0000 (03:56 -0800)]
Use cmp(1) to compare acheieved and expected test results.
'diff -c' on Solaris 11 generate a spurious 'No differences encountered'
message (on stdout, no less!) when the compared files are identical. This
changes the test logic to compare with 'cmp -s', and then perform a
'diff -c' if the results don't match expectations.
David Levine [Tue, 29 Jan 2013 03:38:39 +0000 (21:38 -0600)]
Changed m_getfld() buffer size to 4096 from 8192, to benefit
scan(1). We could consider using a larger buffer size when
readying message bodies. But I expect any benefit would be
overshadowed by the way parse_mime() currently reads MIME
messages: it reopens the file for each part.
David Levine [Tue, 29 Jan 2013 03:20:22 +0000 (21:20 -0600)]
Added m_getfld_track_filepos() for callers to indicate that they
may interleave fseek*/ftell* calls with m_getfld() calls. This
eliminates the need for m_getfld() to call fseek() when called
by inc(1) and scan(1).
David Levine [Sat, 26 Jan 2013 14:52:50 +0000 (08:52 -0600)]
Enabled colorized test output (PASS/FAIL/summary) by default
via "color-tests" automake option. To disable at runtime,
either set your AM_COLOR_TESTS environment variable to "no",
or provide that on the make check command line.
Ken Hornstein [Thu, 24 Jan 2013 21:05:36 +0000 (16:05 -0500)]
Fix the format engine so it properly keeps track of multibyte characters
and column positions when processing components and other functions.
When working on this code I realized we have nothing that checks to make
sure right justification of format function output works properly, so a
test for right justification is also included.
Ken Hornstein [Mon, 21 Jan 2013 15:32:37 +0000 (10:32 -0500)]
Fix a bug leading to message corruption with inc when incorporation more
than one message at a time.
When I reworked the scan() code to remove the use of stdio internals,
two code paths were created. The inc code path consumed another buffer
from the nxtbuf list for processing the message body. At the end of
scan() there was code to push back all of the consumed buffers to the
nxtbuf list. The extra buffer consumed in the inc code path wasn't
being pushed back, and as a result the nxtbuf list would end up with
duplicate pointers in it. This would result in two components sharing
the same text buffer, which caused the message corruption.
When I looked at this closer, I realized that there was no reason to
push those buffers back to the list; nxtbuf gets reset to compbuffers
at the start of every call to scan(), and nxtbuf isn't used after the
buffers are pushed back. Some researched revealed that this was the
same back in the original MH code. I decided it was simplest to simply
delete the buffer recycling code.
(cherry picked from commit 22d2acba60374851c291260ff6aa716e9bf44a6d)
Ken Hornstein [Mon, 21 Jan 2013 15:32:37 +0000 (10:32 -0500)]
Fix a bug leading to message corruption with inc when incorporation more
than one message at a time.
When I reworked the scan() code to remove the use of stdio internals,
two code paths were created. The inc code path consumed another buffer
from the nxtbuf list for processing the message body. At the end of
scan() there was code to push back all of the consumed buffers to the
nxtbuf list. The extra buffer consumed in the inc code path wasn't
being pushed back, and as a result the nxtbuf list would end up with
duplicate pointers in it. This would result in two components sharing
the same text buffer, which caused the message corruption.
When I looked at this closer, I realized that there was no reason to
push those buffers back to the list; nxtbuf gets reset to compbuffers
at the start of every call to scan(), and nxtbuf isn't used after the
buffers are pushed back. Some researched revealed that this was the
same back in the original MH code. I decided it was simplest to simply
delete the buffer recycling code.
David Levine [Mon, 21 Jan 2013 03:27:54 +0000 (21:27 -0600)]
Removed the static m_getfld() state instance and replaced
with functions for callers to create and destroy their own
instances. This also allows inc, msh, and pick to call
m_getfld() with an initial file stream position other than 0.
There is now a global state instance so that scan can call
m_unknown() on maildrop files. It'd be nice to get rid of
that.
David Levine [Sat, 19 Jan 2013 14:33:38 +0000 (08:33 -0600)]
Added a FILE * to the m_getfld_state struct so that most
functions don't need to pass it explicitly. Note that
m_getfld() must still be passed the FILE * because some
callers, e.g., those in mhparse.c, reopen their input file
and therefore pass different FILE *'s for the same input.
David Levine [Fri, 18 Jan 2013 03:58:50 +0000 (21:58 -0600)]
Removed all traces of m_getfld() FLDEOF and BODYEOF states.
They were never set by m_getfld(), so all caller code that
supported them was completely unexercised.
David Levine [Fri, 18 Jan 2013 03:46:54 +0000 (21:46 -0600)]
Minimized message files reads in m_getfld() when the caller
interleaves calls to fseek(). Added check of handling of
long header field name without a colon to test-header.
David Levine [Thu, 17 Jan 2013 03:48:11 +0000 (21:48 -0600)]
Added check of header field body with more than 511
characters to test-inc-scanout. Also changed a couple of
test message files to be generated on the fly.
David Levine [Thu, 17 Jan 2013 02:13:04 +0000 (20:13 -0600)]
Cleaned up m_getfld() code a bit. The most notable change
was to remove the check for mmdlm2 not being null. It's
global data so that shouldn't happen.
David Levine [Wed, 16 Jan 2013 02:11:41 +0000 (20:11 -0600)]
Removed the for-loop that was used to get a header field
name in m_getfld (). It was no longer necessary when not
drawing directly from the stdio buffer.
David Levine [Tue, 15 Jan 2013 03:05:22 +0000 (21:05 -0600)]
In m_getfld(), fixed the loop that handles the FLDPLUS case.
In Getc(), removed the increment of the byte count at EOF,
it didn't seem correct or necessary.
David Levine [Tue, 15 Jan 2013 02:58:56 +0000 (20:58 -0600)]
m_getfld() now supports interleaving calls with
fseek()/ftell(). Reverted the changes to uip/mhparse.c of
commit 484eb1003ae647e4b751e4d7829c7daf44fb99c9 because
they're no longer necessary.
David Levine [Sat, 12 Jan 2013 16:58:31 +0000 (10:58 -0600)]
Cleaned up FLDPLUS handling in m_getfld(). As part of this,
removed the backing up of the read pointer in the "something
went wrong" portion of the FLD handling. It had been moved
back two positions. The first is no longer necessary
because a Getc() was replace by a Peek(), and the second
caused the extra blank line noted in the old comments.
Updated the expected output in test/bad-input/test-header to
correspond.
David Levine [Thu, 10 Jan 2013 02:50:58 +0000 (20:50 -0600)]
When read_more() loads more bytes, save some from the end of the
current chunk and move them to the front of the buffer. This
allows backing up of the current position, which is necessary when
looking for the message delimiter in a maildrop file.
David Levine [Sun, 6 Jan 2013 21:04:24 +0000 (15:04 -0600)]
Removed support for #ifdef LBL. It was broken anyways,
sometime between MH 6.8.5 and the Apr 1999 entry into CVS.
Also removed the addtoseq format function that could only be
accessed with it.
David Levine [Sun, 6 Jan 2013 15:38:21 +0000 (09:38 -0600)]
Fixed test-utf8-body to actually contain the UTF-8 character
instead of the single byte, 8-bit character. This was caught
using Heirloom shell with a UTF-8 locale: when it wrote the
test draft from a here document, it converted the single byte
character to UTF-8. This verifies that behavior:
David Levine [Fri, 4 Jan 2013 04:32:28 +0000 (22:32 -0600)]
Removed discard() call in post(8). It was only used with -debug
and seemed to serve no useful purpose any more. Its comment
said that it was needed to help the loader.
David Levine [Fri, 4 Jan 2013 03:59:44 +0000 (21:59 -0600)]
In cpstripped() and cptrimmed(), if a multibyte character is
found, only count it as taking up one character in the
destination buffer (if it has enought room). This way,
scan(1)'s output won't be jagged if there are any subjects,
for example, that have multibyte characters.
Added a test for this to test-scan-multibyte, and moved the
test for an invalid multibyte sequence from test-scan to it.
David Levine [Thu, 3 Jan 2013 02:07:43 +0000 (20:07 -0600)]
Fixed decoding of header fields when they contain a character that
can't be converted. Added test case to test-scan. valgrind also
noticed that things went amiss.