leftadjust flag strip off leading whitespace on each
line of text
noleftadjust flag don't leftadjust
+rtrim flag trim whitespace at end of text lines
+nortrim flag retain whitespace at end of text lines (default)
compress flag change newlines in text to spaces
nocompress flag don't compress
wrap flag Wrap lines that exceed width (default)
EOF
-# check that blank lines don't end with whitepace
+# check nortrim (default), and that trailing whitespace in a
+# component is trimmed when filtering blank lines
cat >"$expected" <<EOF
> There are two blank lines below. And there is a trailing space:
> And another trailing space:
check "$expected" "$actual"
+# check rtrim
+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,rtrim
+EOF
+
+"$mhl" -nomoreproc -form "$MH_TEST_DIR/test.format" `mhpath last` >"$actual"
+check "$expected" "$actual"
+
+
rm -f "$MH_TEST_DIR/test.format"
exit $failed
#define DATEFMT 0x000800 /* contains dates */
#define FORMAT 0x001000 /* parse address/date/RFC-2047 field */
#define INIT 0x002000 /* initialize component */
+#define RTRIM 0x004000 /* trim trailing whitespace */
#define SPLIT 0x010000 /* split headers (don't concatenate) */
#define NONEWLINE 0x020000 /* don't write trailing newline */
#define NOWRAP 0x040000 /* Don't wrap lines ever */
#define FMTFILTER 0x080000 /* Filter through format filter */
-#define LBITS "\020\01NOCOMPONENT\02UPPERCASE\03CENTER\04CLEARTEXT\05EXTRA\06HDROUTPUT\07CLEARSCR\010LEFTADJUST\011COMPRESS\012ADDRFMT\013BELL\014DATEFMT\015FORMAT\016INIT\021SPLIT\022NONEWLINE\023NOWRAP\024FMTFILTER"
+#define LBITS "\020\01NOCOMPONENT\02UPPERCASE\03CENTER\04CLEARTEXT\05EXTRA\06HDROUTPUT\07CLEARSCR\010LEFTADJUST\011COMPRESS\012ADDRFMT\013BELL\014DATEFMT\015FORMAT\016INIT\017RTRIM\021SPLIT\022NONEWLINE\023NOWRAP\024FMTFILTER"
#define GFLAGS (NOCOMPONENT | UPPERCASE | CENTER | LEFTADJUST | COMPRESS | SPLIT | NOWRAP)
/*
{ "nocompress", 0, COMPRESS },
{ "split", SPLIT, 0 },
{ "nosplit", 0, SPLIT },
+ { "rtrim", RTRIM, 0 },
+ { "nortrim", 0, RTRIM },
{ "addrfield", ADDRFMT, DATEFMT },
{ "bell", BELL, 0 },
{ "nobell", 0, BELL },
onelp = NULL;
if (c1->c_flags & CLEARTEXT) {
- putstr (c1->c_text, c1->c_flags);
+ putstr (c1->c_flags & RTRIM ? rtrim (c1->c_text) : c1->c_text,
+ c1->c_flags);
putstr ("\n", c1->c_flags);
return;
}
count += c1->c_offset;
if ((cp = oneline (c2->c_text, c1->c_flags)))
- putstr(cp, c1->c_flags);
+ /* Output line, trimming trailing whitespace if requested. */
+ putstr (c1->c_flags & RTRIM ? rtrim (cp) : cp, c1->c_flags);
if (term == '\n')
putstr ("\n", c1->c_flags);
while ((cp = oneline (c2->c_text, c1->c_flags))) {
}
}
if (*cp) {
- putstr (cp, c1->c_flags);
+ /* Output line, trimming trailing whitespace if requested. */
+ putstr (c1->c_flags & RTRIM ? rtrim (cp) : cp, c1->c_flags);
}
if (term == '\n')
putstr ("\n", c1->c_flags);