Ralph Corderoy [Fri, 28 Apr 2017 21:08:26 +0000 (22:08 +0100)]
sbr/oauth.c: Remove const to avoid curl's debug_callback warning.
The curl_debug_callback typedef doesn't use const for any of the
function's parameters. On one of the compilation platforms here,
oauth.c's debug_callback having const specifiers for some parameters
causes compilation warnings, and -Werror stops the compilation. Remove
them.
Ralph Corderoy [Fri, 28 Apr 2017 16:12:31 +0000 (17:12 +0100)]
sbr/folder_read.c: Don't malloc() once per message.
Instead of struct msgs having a pointer to a malloc'd array of pointers,
each to a malloc'd struct bvector, 1+N, it now has a pointer to a
malloc'd array of struct bvector; one malloc for all of them. This
avoids the large number of calls to malloc() and free() that's linear
with the size of the folder.
But there are some downsides. In order to step through an array of
struct bvector, code outside of sbr/vector.c needs to know the struct's
size. The simplest way to do this is to make the struct's definition
public, with a comment that access should be through vector.c.
New functions are needed to initialise the content of an already
allocated bvector, and to finish with its content prior to deallocation.
bvector_create() and bvector_free() now also use these new functions.
Before, it was the array of pointers to bvector that would be realloc'd.
That doesn't work for the array of bvectors as they may contain pointers
to within themselves. The solution is to malloc a new array and
bvector_copy() the ones to keep across, as folder_realloc() now does.
The other half of its logic that coped with growth at the end of the
array, has been deleted. Also deleted, is the code to clear the
bvectors before and after the old ones as they start in that state.
Ralph Corderoy [Fri, 28 Apr 2017 11:45:26 +0000 (12:45 +0100)]
sbr/vector.c: Only allocate bvector storage for set bits.
Now that a pointer to all the bit storage doesn't escape vector.c,
there's no need to allocate storage, that's initialised to 0, just to
then clear a bit in it. Only extend the bits's storage for set bits.
Remove the unused initial size parameter from bvector_create() as it
simplifies the implementation.
Ralph Corderoy [Wed, 26 Apr 2017 23:14:28 +0000 (00:14 +0100)]
sbr/vector.c: Zero the growth with memset(3), not loop.
When the resize functions grow the vectors, as they always do, zero the
new slots with memset(3) rather than a for loop. Particularly of note
for the bit vector where it was bvector_clear()ing one bit at a time.
Although a NULL pointer needn't have a representation of all-zero bits,
the code was already assuming that, e.g. on the initial allocation, so
we're no worse off.
Ralph Corderoy [Wed, 26 Apr 2017 12:41:27 +0000 (13:41 +0100)]
sbr/vector.c: Change bvector_bits() to return first word.
Rename it to bvector_first_bits() to represent its new behaviour. It
has only one caller that uses it to produce debug. Tighten the API so
other callers don't get access to the location of the bvector's bits.
Ralph Corderoy [Tue, 25 Apr 2017 22:21:21 +0000 (23:21 +0100)]
sbr/vector.c: Embed initial vector storage in header struct.
Instead of a malloc(3)'d struct bvector having a pointer to a separately
malloc'd area for the bits in the normal case of the default initial
size, have non-malloc'd storage in the struct itself, and set the
pointer to that. It's two unsigned longs, which is less than the
previous default of 256 bits for struct bvector, but still double the
pre-bvector norm of one word on 32 and 64-bit architectures.
This halves the mallocs needed to create a struct bvector in the common
case, but does mean that embedded memory is wasted should it not be
enough. That's probably an unusual case. It also means derefencing the
pointer to the bits probably hits the same cache line.
Have separate initial sizes for string and int vectors.
Ralph Corderoy [Mon, 24 Apr 2017 23:20:08 +0000 (00:20 +0100)]
sbr/vector.c: Remove `vec' argument from BVEC_OFFSET(), etc.
A few macros took a struct bvector pointer as their first argument just
to get the sizeof one of its fields. This can be done with a NULL
pointer so remove that argument from all of them.
Ralph Corderoy [Mon, 24 Apr 2017 22:47:46 +0000 (23:47 +0100)]
sbr/vector.c: Delete unused bvector_maxsize() and ivector_size().
May as well keep the proffered interface as small as possible so the
implementation can make greater assumptions knowing some internal
details aren't available.
Ralph Corderoy [Mon, 24 Apr 2017 21:58:56 +0000 (22:58 +0100)]
sbr/vector.c: Move assert(3)s into bvector_create().
Rather than asserting on every bit-related operation, assert just when
creating the vector. Whether the assertion is true is decided at
compile time, so it only needs checking once; once for every vector is
an easy compromise.
Ralph Corderoy [Mon, 24 Apr 2017 20:19:56 +0000 (21:19 +0100)]
sbr/vector.c: calloc(3) rather than malloc(3) and memset(3).
calloc(3) tells libc upfront that the memory needs to be zeroed rather
than giving it the news later with memset. Perhaps this allows it to
allocate from a CoW page of zero bytes, or it benefits from some other
way in memset not having to clear each bit, but it knocks about 15% off
the wall-clock time and the number of library calls under ltrace(1).
Ralph Corderoy [Tue, 25 Apr 2017 23:14:26 +0000 (00:14 +0100)]
sbr/fmt_scan.c: Only wcwidth(3) a valid mbtowc(3) result.
The assert(3) added by 80a9e99f7078199500d2d53c8d77d1b92af06fbc is
failing, but not reproducibly. It's probable that mbtowc() is returning
a negative, and not altering wide_char, leaving it as random stack
content. Taking its wcwidth() then sometimes also returns negative,
causing the assert() failure. Initialising wide_char before the call
isn't a solution as it isn't documented if it's modified to an invalid
value on an error return.
Instead, delay calculating the wcwidth() until after the possible
substitution of "?". Leave the assert() in place.
Code that's conditional on its definition has been kept; just the tests
removed. The comment explaining its purpose has been kept, just without
the "If defined...".
Ralph Corderoy [Sun, 23 Apr 2017 13:36:57 +0000 (14:36 +0100)]
mh.h: Remove unused MODIFIED and DELETED macros.
MODIFIED was a folder attribute used by msh(1), and DELETED a message
attribute that may have last been used in the 1980s.
Adjust corresponding FBITS and MBITS definitions.
Ralph Corderoy [Sun, 23 Apr 2017 12:33:57 +0000 (13:33 +0100)]
tws.h: Remove zero-valued TW_SNIL macro, used once.
Macro TW_SNIL was the zero value for a two-bit field. It was only used
once, and that is better ordered to check for bits set with none set
being the last, else, case, rather than in the middle. Kept the
behaviour of undefined value 3 being treated as TW_SIMP, 2.
Ralph Corderoy [Sun, 23 Apr 2017 12:18:20 +0000 (13:18 +0100)]
tws.h: Remove redundant TW_SZONE and TW_SZNIL bit-masks.
TW_SZONE is a mask of one bit that can either be 0, TW_SZNIL, or set,
TW_SZEXP. Rather than three macros for the single bit, have one,
TW_SZEXP. Simplifies the test too when the mask is known to be one-bit
wide.
Two of the column headings were separated by spaces rather than a tab.
The other two similar tables used `Return' instead of `Result', so
switch to that at the same time.
Ralph Corderoy [Sun, 23 Apr 2017 08:48:13 +0000 (09:48 +0100)]
sbr/dtime.c: Remove struct-assigning twscopy().
Historically, twscopy() assigned all the struct's members individually,
but that was `#if 0'd as far back as the repository goes. The one
caller now uses assignment, making clear the direction of data flow.
Ralph Corderoy [Sun, 23 Apr 2017 08:28:24 +0000 (09:28 +0100)]
uip/sortm.c: Remove unused variable and dlocaltimenow() call.
read_hdrs() has a auto `struct tws tb'. It's only use is as the
destination for dlocaltimenow()'s result. Remove the variable. Also
remove the dlocaltimenow() call; this I'm unsure about as it has a side
effect of calling tzset(3). However, tests pass. Repository history
sheds no light.
Ralph Corderoy [Sat, 22 Apr 2017 22:36:19 +0000 (23:36 +0100)]
Correct first-line comments where filename is wrong.
Having jiggled the start-of-file comment about, it's apparent that a few
files either don't know their own name, or the format the rest of the
gang follow. To wit, "basename(filename) -- ...".
Ralph Corderoy [Sat, 22 Apr 2017 22:19:39 +0000 (23:19 +0100)]
Replace "/*\n * " with "/* " at the start of a file.
Pulls the meat of the comment onto the file's first line, now that the
blank line at the start of the file has been deleted. Allows `sed -ns
1p ...' or similar to give a summary of lots of files.
Ralph Corderoy [Sat, 22 Apr 2017 18:05:32 +0000 (19:05 +0100)]
Remove leading and trailing blank lines from code.
Many of the main source file start with a blank line, and many end with
one or more too. They seem to serve little purpose so delete them.
This makes all the files consistent in not having them and ideally the
first line of a C source file will say something about its content in
time instead of just "/*". Avoided editing format files, etc,. where
the line could be significant, and historical files.
Ralph Corderoy [Sat, 22 Apr 2017 17:32:55 +0000 (18:32 +0100)]
mts/smtp/smtp.h: Remove unused `MMDF' macros.
The header file has a specification of a historical interface and
removing the unused parts leaves it incomplete, but it's unlikely those
parts will be needed and what remains seems more understandable; partly
due to it being less to grok, and also because it relates more to modern
use.
isfrom(s) checked for /^>?From /.
lequal(a, b) was another case-insensitive strcmp(3).
mfgets(fp, line) fetched a header at a time from fp, indicating when the
end of headers was reached.
Investigating their historical usage was, ironically, made too tedious
to complete by the pollution of mass commits of historical MH.
Ralph Corderoy [Sat, 22 Apr 2017 15:41:00 +0000 (16:41 +0100)]
h/mts.h: Remove unused isdlm{1,2}() macros.
They just do a strcmp(3) of their argument against mmdlm{1,2} and test
it's "equal". That's more clearly written longhand than have yet
another small-scope, specialised, macro to recall; as practice bears
out.
Ralph Corderoy [Sat, 22 Apr 2017 13:31:10 +0000 (14:31 +0100)]
h/tws.h: Remove TW_YES and TW_NO; TW_SUCC good enough.
TW_SUCC is a macro for the bit-mask 0x0040. TW_YES, a vague name, was
the same value. TW_NO was 0, and unused by the code. Ditch both those
as TW_SUCC is sufficient for setting and testing. Alter its comment to
make clear it means parsing was successful.
Ralph Corderoy [Fri, 21 Apr 2017 23:48:47 +0000 (00:48 +0100)]
sbr/lock_file.c: Move static variables into their functions.
A couple of file-scoped statc ints were the typical "if this function is
being called for the first time" flags. Move each into their respective
functions. Make them bools. Name them so the initial value is zero,
thus placing them in BSS.
Ralph Corderoy [Fri, 21 Apr 2017 13:01:21 +0000 (14:01 +0100)]
send and whatnow: Remove deprecated -attach... switches.
They were changed to do nothing but warn on stderr that they were
deprecated in 521674623 and 035c5db34, both before 1.6's release, and so
can be removed ready for 1.7's release.
Ralph Corderoy [Thu, 20 Apr 2017 13:27:46 +0000 (14:27 +0100)]
uip/dropsbr.c: Fix buffer overrun in mbx_copy().
The overrun occurs frequently, but typically zeroes a byte of a
character pointer on the stack that's not yet been used.
Caused by 28610ff9a604a75ae0c383be03aa19415ddb1965 appending a NUL after
the bytes stored by read(2).
Ralph Corderoy [Tue, 18 Apr 2017 11:54:28 +0000 (12:54 +0100)]
man/*.man: Fix some multi-word .B invocations.
Some needed to be .B for the first word, but .I for the second, or just
plain text for the rest of the words that should be on their own line.
Others were just plain wrong and became .IR for a man-page reference.
Then the .TP macro uses an input trap so only a single following line of
source is used and this prevents a two-line `.B .I', so use embedded
font escapes instead.
Ralph Corderoy [Tue, 18 Apr 2017 00:14:57 +0000 (01:14 +0100)]
man/*.man: Use italic for emphasis, not bold or SHOUTING.
When reading a body of text, italic is sufficient to add emphasis to
what's already being read. Bold draws the eye to the word on the page
and is more useful for keywords, concepts, etc. Some `.B' remain that
should probably be `.I', but they looked to have other problems so I
left them out of this pass.
Ralph Corderoy [Mon, 17 Apr 2017 23:24:07 +0000 (00:24 +0100)]
man/*.man: Replace minus sign with hyphen: `\-' with `-'.
Conservatively changed many of the troff minus-signs, `\-', with a troff
hyphen, `-'. Where it wasn't quickly obviously, I left it unchanged.
There were also cases that shouldn't be either minus sign or hyphen.
Those were changed to hyphen and still need to be fixed properly.
Ralph Corderoy [Mon, 17 Apr 2017 13:53:28 +0000 (14:53 +0100)]
Don't ignore bit 5 of a char when comparing alias names.
It's a crude method of ignoring case, but makes `^' equal to `~'.
Use tolower(3) instead.
http://lists.nongnu.org/archive/html/nmh-workers/2017-03/msg00050.html
Ralph Corderoy [Mon, 17 Apr 2017 10:42:39 +0000 (11:42 +0100)]
Change admonish(NULL, "foo") to inform("foo, continuing...").
Removes more uses of the ad... functions with unneeded parameters.
Puts the "continuing" at the call site rather than the reader having to
remember it's being magically appended. (Some calls were passing
"foo\n" that would result in "foo\n, continuing...\n" appearing.)
Ralph Corderoy [Mon, 17 Apr 2017 09:57:54 +0000 (10:57 +0100)]
Fix bug in advertise("", "", "foo", ap).
A non-NULL but empty `what' would result in "fooerrno\n" without
separation. Improve the function's comment to try and make it obvious
how its out of order parameters appear.
Ralph Corderoy [Sun, 16 Apr 2017 22:25:32 +0000 (23:25 +0100)]
man/*.man: Replace \(ru with an underscore, e.g. .mh_profile.
The character is an underscore, and that's what's wanted.
\(ru gives a "rule", which draws as a thick baseline in PDFs;
not a character at all.
Other devices map \(ru onto underscore, e.g. ASCII,
but an underscore should be used in the first place.
Ralph Corderoy [Sun, 16 Apr 2017 13:01:42 +0000 (14:01 +0100)]
Replace some strdup() with mh_xstrdup().
(This is an old patch I had stashed.)
Some surrounding `if...adios()' are removed too, but most of the
strdup() calls weren't being checked for success, thus their
replacement.
Ralph Corderoy [Sat, 15 Apr 2017 23:35:11 +0000 (00:35 +0100)]
Remove unneeded `\&' from man pages.
The zero-width character is used before a command character that is
intended to be literal but may end up at the start of a line.
Similarly, it's used after an end-of-sentence character when it may end
up at the end of the line but isn't the end of a sentence.
Remove the other cases because they're noise that confuses the issue of
when `\&' should be used.
Ralph Corderoy [Sat, 15 Apr 2017 18:17:31 +0000 (19:17 +0100)]
Fix errors in man-page NAME sections.
man/fmttest.man didn't have a NAME section, but a FMTTEST one.
And it broke lexgrog(1) by splitting the section over multiple lines and
using `.IR'. Re-write to use inline escapes.
man/rcvtty.man had two spaces before the `\-'.
Ralph Corderoy [Sat, 15 Apr 2017 13:25:12 +0000 (14:25 +0100)]
Fix forward-reference and `news.*' in mh-alias(5)'s example.
Spotted by Bob Carragher.
The example's forward reference was made a backward one, and `news.*'
explanation removed, in ff3060cefb460cce2174058eefff38b6e11ee2f1.
Larry Hynes [Fri, 24 Mar 2017 23:02:00 +0000 (23:02 +0000)]
Editing of man/repl.com.
- unashamedly add nmh to .SH NAME
- replace the delightfully baroque 'may be used to produce a reply
to an existing message' with 'may be used to reply to a message'.
- remove some \- objects
- deflower 'repl uses a reply template to guide its actions'
- remove multiple instances of 'replied\-to', with 'replied to'
- change 'tab\-stop' to 'tab stop'
- some formatting
- replace .B mhbuild with .IR mhbuild (1)
- replace whatnow with .B whatnow