mhl now trims that whitespace off when filtering blank text lines.
test/mhbuild/test-forw test/mhbuild/test-header-encode \
test/mhbuild/test-utf8-body \
test/mhfixmsg/test-mhfixmsg \
+ test/mhl/test-mhl-flags \
test/mhlist/test-mhlist test/mhlist/test-ext-params \
test/mhmail/test-mhmail \
test/mhparam/test-mhparam test/mhpath/test-mhpath \
fmttest(1), and mhl(1) now means as many characters as the format
engine can produce [Bug #15274]. That amount is limited by internal
buffers.
+- If a component has trailing whitespace, e.g., body:component="> ",
+ mhl now trims that whitespace off when filtering blank text lines.
-----------------
OBSOLETE FEATURES
void cpydata (int, int, char *, char *);
void cpydgst (int, int, char *, char *);
char *cpytrim (const char *);
+char *rtrim (char *);
int decode_rfc2047 (char *, char *, size_t);
void discard (FILE *);
char *upcase (const char *);
return dp;
}
+
+
+/*
+ * rtrim() -- modify the argument to:
+ * -- strip trailing whitespace
+ *
+ * This code is Copyright (c) 2014, by the authors of nmh. See the
+ * COPYRIGHT file in the root directory of the nmh distribution for
+ * complete copyright information.
+ */
+char *
+rtrim (char *sp) {
+ char *cp;
+
+ /* start at the end and zap trailing whitespace */
+ for (cp = sp + strlen (sp) - 1;
+ cp >= sp && isspace ((unsigned char) *cp);
+ --cp) { continue; }
+ *++cp = '\0';
+
+ return sp;
+}
--- /dev/null
+#!/bin/sh
+#
+# Test of various (well, start with one) function escapes.
+
+set -e
+
+if test -z "${MH_OBJ_DIR}"; then
+ srcdir=`dirname "$0"`/../..
+ MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
+fi
+
+. "$MH_OBJ_DIR/test/common.sh"
+
+setup_test
+mhl="${MH_LIB_DIR}/mhl"
+expected="$MH_TEST_DIR/$$.expected"
+actual="$MH_TEST_DIR/$$.actual"
+
+cat >`mhpath new` <<EOF
+MIME-Version: 1.0
+From: sender@example.com
+To: recipient@example.com
+Subject: message with blank lines
+Date: Mon, 29 Apr 2013 11:51:45 -0400
+
+There are two blank lines below. And there is a trailing space:
+And another trailing space:
+
+
+EOF
+
+
+# check that blank lines don't end with whitepace
+cat >"$expected" <<EOF
+> There are two blank lines below. And there is a trailing space:
+> And another trailing space:
+>
+>
+EOF
+
+cat >"$MH_TEST_DIR/test.format" <<EOF
+body:component="> ",overflowtext=,overflowoffset=0
+EOF
+
+"$mhl" -nomoreproc -form "$MH_TEST_DIR/test.format" `mhpath last` >"$actual"
+check "$expected" "$actual"
+
+
+rm -f "$MH_TEST_DIR/test.format"
+exit $failed
{
int count, cchdr;
char *cp;
+ /*
+ * Create a copy of c1->c_text with trailing whitespace
+ * trimmed, for use with blank lines.
+ */
+ char *trimmed_prefix =
+ rtrim (add (c1->c_text ? c1->c_text : c1->c_name, NULL));
cchdr = 0;
lm = 0;
while ((cp = oneline (c2->c_text, c1->c_flags))) {
lm = count;
if (flag == BODYCOMP
- && !(c1->c_flags & NOCOMPONENT))
- putstr (c1->c_text ? c1->c_text : c1->c_name, c1->c_flags);
- if (*cp)
+ && !(c1->c_flags & NOCOMPONENT)) {
+ /* Output component, trimming trailing whitespace if there
+ is no text on the line. */
+ if (*cp) {
+ putstr (c1->c_text ? c1->c_text : c1->c_name, c1->c_flags);
+ } else {
+ putstr (trimmed_prefix, c1->c_flags);
+ }
+ }
+ if (*cp) {
putstr (cp, c1->c_flags);
+ }
if (term == '\n')
putstr ("\n", c1->c_flags);
}
if (flag == BODYCOMP && term == '\n')
c1->c_flags &= ~HDROUTPUT; /* Buffer ended on a newline */
+
+ free (trimmed_prefix);
}