test/mhfixmsg/test-mhfixmsg \
test/mhlist/test-mhlist test/mhmail/test-mhmail \
test/mhparam/test-mhparam test/mhpath/test-mhpath \
+ test/mhshow/test-charset \
test/mhshow/test-cte-binary test/mhshow/test-qp \
test/mhshow/test-subpart test/mhshow/test-msg-buffer-boundaries \
test/mhstore/test-mhstore test/new/test-basic \
@echo 's,%nmhwarning%,THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT.,g' > $@
@echo 's,%nmhversion%,nmh-$(VERSION),g' >> $@
@echo 's,%bindir%,$(bindir),g' >> $@
+ @echo 's,%docdir%,$(docdir),g' >> $@
@echo 's,%etcdir%,$(sysconfdir),g' >> $@
@echo 's,%libdir%,$(libdir),g' >> $@
@echo 's,%mandir%,$(mandir),g' >> $@
dnl Cygwin FAT filesystems do not support hard links. So default to
dnl cp instead, even if running on an NTFS or other filesystem.
AS_CASE(["$host_os"],
- [cygwin*],[LN=cp],
+ [cygwin*], [LN=cp],
[LN=ln])
AC_SUBST([LN])
dnl starting checking the termcap library.
LIBS="$nmh_save_LIBS"
+dnl ----------------
+dnl CHECK FLEX FIXUP
+dnl ----------------
+dnl Use LFLAGS make variable setting to work around bugs in flex
+dnl 2.5.35-37 that cause signed/unsigned mismatch,
+dnl http://sourceforge.net/p/flex/bugs/140/
+AS_IF([test "$LEX" = flex],
+ [AS_CASE([`$LEX -V`],
+ [flex\ 2.5.35], [[LFLAGS=\
+'; printf "%s\n" '\''1,$$s/(size_t) \(num_to_read\)/\1/'\'' w q | ed -s $@']],
+ [flex\ 2.5.3@<:@67@:>@], [[LFLAGS=\
+'; printf "%s\n" '\''1,$$s/\( \)int i;/\1yy_size_t i;/'\'' w q | ed -s $@']])
+ AC_SUBST([LFLAGS])])
+
dnl --------------
dnl CHECK TYPEDEFS
dnl --------------
fi
fi
-grep 'Error' "$logfile"
-#### Ignore the warning when sbr/dtimep.c is built with flex 2.5.36
-#### or 2.5.37.
-grep 'warn' "$logfile" | \
- grep -v 'sbr/dtimep.c:.*comparison between signed and unsigned'
-if [ $status -ne 0 ]; then
+grep Error "$logfile"
+grep warn "$logfile"
+
+if [ $status -eq 0 ]; then
+ [ $verbose -ge 1 ] && echo build completed successfully
+else
echo build failed!
echo build log is in "$logfile"
fi
-[ $status -eq 0 -a $verbose -ge 1 ] && echo build completed successfully
exit $status
connection with the -initialtls switch.
- Messages can now be selected using a relative offset from some other
message, or from the start or end of a sequence. See mh-sequences(5).
+- The -changecur and -nochangecur switches have been added to mhlist(1).
-----------------
OBSOLETE FEATURES
#define CT_ADDR (1<<0) /* referenced as address */
#define CT_DATE (1<<1) /* referenced as date */
+#define CT_BITS "\020\01ADDR\02DATE"
+
/*
* c_flags bits
*/
#define CF_DATEFAB (1<<2) /* datefield fabricated */
#define CF_TRIMMED (1<<3) /* Component has been trimmed */
+#define CF_BITS "\020\01TRUE\02PARSED\03CF_DATEFAB\04TRIMMED"
+
extern int fmt_norm;
/*
void seq_setunseen (struct msgs *, int);
int showfile (char **, char *);
int smatch(char *, struct swit *);
-char *snprintb (char *, size_t, unsigned, char *);
+
+/*
+ * Convert a set of bit flags to printable format.
+ *
+ * Arguments:
+ *
+ * buffer - Buffer to output string to.
+ * size - Size of buffer in bytes. Buffer is always NUL terminated.
+ * flags - Binary flags to output
+ * bitfield - Textual representation of bits to output. This string
+ * is in the following format:
+ *
+ * Option byte 0x01 STRING1 0x02 STRING2 ....
+ *
+ * The first byte is an option byte to snprintb(). Currently the only option
+ * supported is 0x08, which indicates that the flags should be output in
+ * octal format; if the option byte is any other value, the flags will be
+ * output in hexadecimal.
+ *
+ * After the option bytes are series of text strings, prefixed by the number
+ * of the bit they correspond to. For example, the bitfield string:
+ *
+ * "\020\01FLAG1\02FLAG2\03FLAG3\04FLAG4"
+ *
+ * will output the following string if "flags" is set to 0x09:
+ *
+ * 0x2<FLAG1,FLAG4>
+ *
+ * You don't have to use octal in the bitfield string, that's just the
+ * convention currently used by the nmh code. The order of flags in the
+ * bitfield string is not significant, but again, general convention is
+ * from least significant bit to most significant.
+ */
+char *snprintb (char *buffer, size_t size, unsigned flags, char *bitfield);
int ssequal (char *, char *);
int stringdex (char *, char *);
char *trimcpy (char *);
-.TH MHFIXMSG %manext1% "May 4, 2013" "%nmhversion%"
+.TH MHFIXMSG %manext1% "October 27, 2013" "%nmhversion%"
.\"
.\" %nmhwarning%
.\"
.na
.B mhfixmsg
.RI [ +folder ]
-.RI [ msgs ]
+.RI [ msgs " | "
+.IR "absolute pathname" " | "
+.RB \-file
+.IR file ]
.RB [ \-decodetext
8bit/7bit |
.BR \-nodecodetext ]
.RB [ \-replacetextplain " | " \-noreplacetextplain ]
.RB [ \-fixboundary " | " \-nofixboundary ]
.RB [ \-fixcte " | " \-nofixcte ]
-.RB [ \-file
-.IR file ]
.RB [ \-outfile
.IR outfile ]
.RB [ \-rmmproc
.B mhfixmsg
to use the specified
file as the source message, rather than a message from a folder.
-If this file is \*(lq-\*(rq, then
+Only one file argument may be provided. The
+.B \-file
+switch is implied if
+.I file
+is an absolute pathname.
+If the file is \*(lq-\*(rq, then
.B mhfixmsg
accepts the source message on the standard input stream. If
the
.B \-rmmproc
switches.
.PP
+.SS "Integration with inc"
+.B mhfixmsg
+can be used as an add-hook, as described in %docdir%/README-HOOKS.
+Note that add-hooks are called from all
+.B nmh
+programs that add a message to a folder, not just
+.BR inc .
+Alternatively, a simple shell alias or function can be used to
+call
+.B mhfixmsg
+immediately after a successful invocation of
+.BR inc .
+For example, with bash:
+.PP
+.RS 5
+alias inc='inc && mhfixmsg'
+.RE
+.PP
.SS "Integration with procmail"
By way of example, here is an excerpt from a procmailrc file
that filters messages through
^rmmproc:~^Program to delete original messages or files
.fi
.SH "SEE ALSO"
+.IR inc (1),
.IR mh-profile (5),
.IR mhbuild (1),
.IR mhlist (1),
message selected from a folder will become the current message. If
the
.B \-file
-switch is used, the context will not be modified.
+switch or an absolute pathname is used, the context will not be
+modified.
.RB [ \-wcache
.IR policy ]
.RB [ \-check " | " \-nocheck ]
+.RB [ \-changecur " | " \-nochangecur ]
.RB [ \-verbose " | " \-noverbose ]
.RB [ \-version ]
.RB [ \-help ]
.RB ` \-realsize '
.RB ` \-rcache\ ask '
.RB ` \-wcache\ ask '
+.RB ` \-changecur '
.RB ` \-noverbose '
.fi
.SH CONTEXT
If a folder is given, it will become the current folder. The last
-message selected will become the current message.
+message selected will become the current message, unless the
+.B \-nochangecur
+option is specified.
.B rcvpack
will correctly lock and unlock the file to serialize
access to the file, when running multiple copies of
-.B rcvpack .
+.BR rcvpack .
.PP
In general, its use is obsoleted by the
.B file
strncpy (addr, mp->m_mbox ? mp->m_mbox : "", sizeof(addr));
else
- if (mp->m_type != UUCPHOST)
- snprintf (addr, sizeof(addr), mp->m_host ? "%s%s@%s" : "%s%s",
- empty(mp->m_path), empty(mp->m_mbox), mp->m_host);
- else
+ if (mp->m_type != UUCPHOST) {
+ if (mp->m_host)
+ snprintf (addr, sizeof(addr), "%s%s@%s", empty(mp->m_path),
+ empty(mp->m_mbox), mp->m_host);
+ else snprintf (addr, sizeof(addr), "%s%s", empty(mp->m_path),
+ empty(mp->m_mbox));
+ } else
snprintf (addr, sizeof(addr), "%s!%s", mp->m_host, mp->m_mbox);
if (!extras)
snprintf (buffer, n, bits && *bits == 010 ? "0%o" : "0x%x", v);
bp = buffer + strlen(buffer);
+ n -= strlen(buffer);
if (bits && *++bits) {
j = 0;
*bp++ = '<';
- while ((i = *bits++))
+ while ((i = *bits++) && n > 1)
if (v & (1 << (i - 1))) {
- if (j++)
+ if (j++ && n > 1) {
*bp++ = ',';
- for (; (c = *bits) > 32; bits++)
+ n--;
+ }
+ for (; (c = *bits) > 32 && n > 1; bits++) {
*bp++ = c;
+ n--;
+ }
}
else
for (; *bits > 32; bits++)
continue;
- *bp++ = '>';
+ if (n > 1)
+ *bp++ = '>';
+
*bp = 0;
}
# check -inplace
# Hard link the message and verify that the new one does get annotated.
- ln "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
+ ln "${MH_TEST_DIR}/Mail/inbox/9" "${MH_TEST_DIR}/Mail/inbox/9.link"
cat >"$expected" <<EOF
-From: Test8 <test8@example.com>
+From: Test9 <test9@example.com>
To: Some User <user@example.com>
Date: Fri, 29 Sep 2006 00:00:00
-Message-Id: 8@test.nmh
-Subject: Testing message 8
+Message-Id: 9@test.nmh
+Subject: Testing message 9
Resent-From: ${localmbox}
Resent-To: somebody@example.com
Resent-Date:
-This is message number 8
+This is message number 9
EOF
- test_dist 8 -noedit -to somebody@example.com -annotate -noinplace -inplace
- check "${MH_TEST_DIR}/Mail/inbox/8" "${MH_TEST_DIR}/Mail/inbox/8.link"
+ test_dist 9 -noedit -to somebody@example.com -annotate -noinplace -inplace
+ check "${MH_TEST_DIR}/Mail/inbox/9" "${MH_TEST_DIR}/Mail/inbox/9.link"
fi
# check -draftfolder
fi
+# check implicit -file with absolute pathname
+run_test "mhfixmsg `mhpath last` -outfile /dev/null" ''
+
+
# check handling of boundary string that appears in message body
#
cat >"$expected" <<EOF
1 multipart/related 180
2 text/plain 36'
+#
+# Set the cur sequence to 1 to test default behavior of changecur after
+# this test.
+#
+
+mark 1 -sequence cur -add -zero
+
# check -verbose
run_test 'mhlist 11 -verbose -noheader' \
' 11 multipart/mixed 936
4 text/plain 36
charset="iso-8859-1"'
+#
+# Check default changecur behavior
+#
+
+run_test 'mark -sequence cur -list' 'cur: 11'
+
+#
+# Now test -nochangecur
+#
+
+mhlist -nochangecur 1 >/dev/null
+
+run_test 'mark -sequence cur -list' 'cur: 11'
exit $failed
--- /dev/null
+#!/bin/sh
+######################################################
+#
+# Test charset conversion functionality
+#
+######################################################
+
+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
+
+expected=$MH_TEST_DIR/$$.expected
+actual=$MH_TEST_DIR/$$.actual
+
+echo 'mhshow-charset-windows-1252: echo "This is a test"' >> $MH_TEST_DIR/Mail/.mh_profile
+
+# Write message with bogus quoted-printable data.
+msgfile=`mhpath new`
+msgnum=`basename $msgfile`
+cat > $msgfile <<EOF
+From: foo@example.edu
+To: bar@example.edu
+Subject: test
+MIME-Version: 1.0
+Content-Type: text/plain; charset=windows-1252
+Content-Transfer-Encoding: quoted-printable
+Date: Sun, 18 Dec 2005 00:52:39 +0100
+
+4 =F7 2 =3D 2
+EOF
+
+cat > $expected <<EOF
+Date: Sun, 18 Dec 2005 00:52:39 +0100
+To: bar@example.edu
+From: foo@example.edu
+Subject: test
+
+MIME-Version: 1.0
+
+part text/plain 10
+This is a test
+EOF
+
+mhshow -nopause $msgnum > $actual 2>&1
+check "$expected" "$actual"
+
+exit $failed
int
mbx_open (char *file, int mbx_style, uid_t uid, gid_t gid, mode_t mode)
{
- int j, count, fd;
+ int j, count, fd = NOTOK;
struct stat st;
j = 0;
static int lused = 0;
static int lallocated = 0;
-enum mode_t { MESSAGE, ADDRESS, RAW };
+enum mode_t { MESSAGE, ADDRESS, DATE, RAW };
#define DEFADDRFORMAT "%<{error}%{error}: %{text}%|%(putstr(proper{text}))%>"
#define DEFDATEFORMAT "%<(nodate{text})error: %{text}%|%(putstr(pretty{text}))%>"
dupaddrs = 0;
continue;
case DATESW:
- mode = RAW;
+ mode = DATE;
defformat = DEFDATEFORMAT;
continue;
fmt_norm = normalize;
process_addresses(fmt, &msgs, buffer, bufsize, outputsize,
dat, normalize, cbp);
- } else
+ } else /* Fall-through for RAW or DATE */
process_raw(fmt, &msgs, buffer, bufsize, outputsize, dat, cbp);
}
}
}
-#define FNORD(v, s) if (t & (v)) { \
- if (i++ > 0) \
- strcat(buf, "|"); \
- strcat(buf, s); }
-
static char *
c_typestr(int t)
{
- register int i;
static char buf[64];
- buf[0] = '\0';
- if (t & ~(CT_ADDR|CT_DATE))
- printf(buf, "0x%x ", t);
- strcat(buf, "<");
- i = 0;
- FNORD(CT_ADDR, "ADDR");
- FNORD(CT_DATE, "DATE");
- strcat(buf, ">");
+ snprintb(buf, sizeof(buf), t, CT_BITS);
return(buf);
}
static char *
c_flagsstr(int t)
{
- register int i;
static char buf[64];
- buf[0] = '\0';
- if (t & ~(CF_TRUE|CF_PARSED|CF_DATEFAB|CF_TRIMMED))
- printf(buf, "0x%x ", t);
- strcat(buf, "<");
- i = 0;
- FNORD(CF_TRUE, "TRUE");
- FNORD(CF_PARSED, "PARSED");
- FNORD(CF_DATEFAB, "DATEFAB");
- FNORD(CF_TRIMMED, "TRIMMED");
- strcat(buf, ">");
+ snprintb(buf, sizeof(buf), t, CF_BITS);
return(buf);
}
-#undef FNORD
static void
litputs(char *s)
else if (i == NOTOK)
chmod (audfile, m_gmprot ());
- fprintf (aud, from ? "<<inc>> %s -ms %s\n"
- : host ? "<<inc>> %s -host %s -user %s\n"
- : "<<inc>> %s\n",
- dtimenow (0), from ? from : host, user);
+ if (from)
+ fprintf (aud, "<<inc>> %s -ms %s\n", dtimenow(0), from);
+ else {
+ if (host)
+ fprintf (aud, "<<inc>> %s -host %s -user %s\n", dtimenow(0),
+ host, user);
+ else
+ fprintf (aud, "<<inc>> %s\n", dtimenow (0));
+ }
}
/* Get new format string */
case NREPLACETEXTPLAINSW:
fx.replacetextplain = 0;
continue;
-
case FILESW:
if (! (cp = *argp++) || (*cp == '-' && cp[1]))
adios (NULL, "missing argument to %s", argp[-2]);
file = *cp == '-' ? add (cp, NULL) : path (cp, TFILE);
continue;
-
case OUTFILESW:
if (! (cp = *argp++) || (*cp == '-' && cp[1]))
adios (NULL, "missing argument to %s", argp[-2]);
outfile = *cp == '-' ? add (cp, NULL) : path (cp, TFILE);
continue;
-
case RPROCSW:
if (!(rmmproc = *argp++) || *rmmproc == '-')
adios (NULL, "missing argument to %s", argp[-2]);
case NRPRCSW:
rmmproc = NULL;
continue;
-
case VERBSW:
verbosw = 1;
continue;
adios (NULL, "only one folder at a time!");
else
folder = pluspath (cp);
- } else
- app_msgarg(&msgs, cp);
+ } else {
+ if (*cp == '/') {
+ /* Interpret a full path as a filename, not a message. */
+ file = add (cp, NULL);
+ } else {
+ app_msgarg (&msgs, cp);
+ }
+ }
}
SIGNAL (SIGQUIT, quitser);
++*message_mods;
if (verbosw) {
- report (NULL,
- begin == 0 && end == 0 ? "(tmpfile)" : *file,
+ report (ct->c_partno,
+ begin == 0 && end == 0 ? "" : *file,
"stripped CRs");
}
}
X("type content", 0, TYPESW) \
X("rcache policy", 0, RCACHESW) \
X("wcache policy", 0, WCACHESW) \
+ X("changecur", 0, CHGSW) \
+ X("nochangecur", 0, NCHGSW) \
X("version", 0, VERSIONSW) \
X("help", 0, HELPSW) \
X("debug", -5, DEBUGSW) \
int
main (int argc, char **argv)
{
- int sizesw = 1, headsw = 1;
+ int sizesw = 1, headsw = 1, chgflag = 1;
int msgnum, *icachesw;
char *cp, *file = NULL, *folder = NULL;
char *maildir, buf[100], **argp;
file = *cp == '-' ? cp : path (cp, TFILE);
continue;
+ case CHGSW:
+ chgflag++;
+ continue;
+ case NCHGSW:
+ chgflag = 0;
+ continue;
+
case VERBSW:
verbosw = 1;
continue;
/* If reading from a folder, do some updating */
if (mp) {
context_replace (pfolder, folder);/* update current folder */
- seq_setcur (mp, mp->hghsel); /* update current message */
+ if (chgflag)
+ seq_setcur (mp, mp->hghsel); /* update current message */
seq_save (mp); /* synchronize sequences */
context_save (); /* save the context file */
}
char *cp, buffer[BUFSIZ];
CI ci = &ct->c_ctinfo;
- printf (toplevel > 0 ? LSTFMT2a : toplevel < 0 ? "part " : " ",
- atoi (r1bindex (empty (ct->c_file), '/')));
+ if (toplevel > 0)
+ printf (LSTFMT2a, atoi (r1bindex (empty (ct->c_file), '/')));
+ else
+ printf(toplevel < 0 ? "part " : " ");
+
snprintf (buffer, sizeof(buffer), "%s/%s", empty (ci->ci_type),
empty (ci->ci_subtype));
printf (LSTFMT2b, empty (ct->c_partno), buffer);
if ((mf & UUCPOK) || (mf & MMDFOK)) {
if (notifysw & NT_MAIL) {
- printf (personal ? "You have " : "%s has ", user);
+ if (personal)
+ printf ("You have ");
+ else
+ printf ("%s has ", user);
if (mf & UUCPOK)
printf ("%s old-style bell", mf & UUCPOLD ? "old" : "new");
if ((mf & UUCPOK) && (mf & MMDFOK))
if (nmsgs) {
if (notifysw & NT_MAIL) {
- printf (personal ? "You have " : "%s has ", user);
+ if (personal)
+ printf ("You have ");
+ else
+ printf ("%s has ", user);
+
printf ("%d message%s (%d bytes)",
nmsgs, nmsgs != 1 ? "s" : "", nbytes);
}
p_refile (tmpfil);
unlink (tmpfil);
- if (verbose)
- printf (partno ? "Partial Message #%s Processed\n" : "Message Processed\n",
- partno);
+ if (verbose) {
+ if (partno)
+ printf ("Partial Message #%s Processed\n", partno);
+ else
+ printf ("Message Processed\n");
+ }
+
done (0);
return 1;
}
rewind (in);
lseek (fileno(in), (off_t) 0, SEEK_SET);
+ arglist = argsplit(mhlproc, &mhl, &argnum);
+
switch (pid = fork()) {
case NOTOK:
adios ("fork", "unable to");
* because we never call arglist_free(). But if we ever change
* that be sure to use getcpy() for the extra arguments.
*/
- arglist = argsplit(mhlproc, &mhl, &argnum);
arglist[argnum++] = "-form";
arglist[argnum++] = filter;
arglist[argnum++] = "-noclear";
case LENERR:
case FMTERR:
- fprintf (stderr,
- innum ? "??Format error (message %d) in "
- : "??Format error in ",
- outnum ? outnum : innum);
+ if (innum)
+ fprintf (stderr, "??Format error (message %d) in ",
+ outnum ? outnum : innum);
+ else
+ fprintf (stderr, "??Format error in ");
+
fprintf (stderr, "component %d\n", compnum);
if (outnum) {