From: David Levine Date: Mon, 23 Feb 2015 03:21:40 +0000 (-0600) Subject: Merge remote-tracking branch 'origin/convertargs' X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/aad5d20016b28bb8c28592c1ebe4213aafaa43c3?hp=3f609815e33ab5474e631eac097d515d982ff0f5 Merge remote-tracking branch 'origin/convertargs' --- diff --git a/Makefile.am b/Makefile.am index 90dee631..ec523ec4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -97,6 +97,7 @@ TESTS = test/ali/test-ali test/anno/test-anno \ test/scan/test-scan test/scan/test-scan-multibyte \ test/sequences/test-flist test/sequences/test-mark \ test/sequences/test-out-of-range \ + test/show/test-show \ test/slocal/test-slocal \ test/whatnow/test-attach-detach test/whatnow/test-cd \ test/whatnow/test-ls test/whom/test-whom \ diff --git a/config/config.c b/config/config.c index 5c0591ca..919c1eec 100644 --- a/config/config.c +++ b/config/config.c @@ -242,13 +242,6 @@ char *moreproc = NULL; char *mhlproc = nmhlibexecdir (/mhl); -/* - * This is the super handy BBoard reading program, which is - * really just the nmh shell program. - */ - -char *mshproc = nmhbindir (/msh); - /* * This program is called to pack a folder. */ @@ -299,13 +292,6 @@ char *showmimeproc = nmhbindir (/mhshow); char *showproc = nmhlibexecdir (/mhl); -/* - * This program is called by vmh as the back-end to the window management - * protocol - */ - -char *vmhproc = nmhbindir (/msh); - /* * This program is called after comp, et. al., have built a draft */ diff --git a/configure.ac b/configure.ac index 754ccb6a..09365563 100644 --- a/configure.ac +++ b/configure.ac @@ -307,7 +307,7 @@ AS_IF([test x"$DISABLE_SETGID_MAIL" != x -a x"$DISABLE_SETGID_MAIL" != x0], dnl If mailspool is not world-writable and dotlockfile is not setgid, dnl we need to #define MAILGROUP to 1 and make inc setgid. -if test x"$LOCKTYPE" = x"dot" -a x"$nmh_cv_mailspool_world_writable" = x"no" -a x"$nmh_cv_dotlockfile_setgid" != x"yes" ; then +if test x"$with_locking" = x"dot" -a x"$nmh_cv_mailspool_world_writable" = x"no" -a x"$nmh_cv_dotlockfile_setgid" != x"yes" ; then dnl do we really need both of these? AC_DEFINE([MAILGROUP],[1], [Define to 1 if you need to make `inc' set-group-id because your mail spool is not world writable. There are no guarantees as to the safety of doing this, but this #define will add some extra security checks.])dnl diff --git a/etc/mhn.defaults.sh b/etc/mhn.defaults.sh index bfc7924f..e2821db8 100755 --- a/etc/mhn.defaults.sh +++ b/etc/mhn.defaults.sh @@ -306,7 +306,7 @@ $PGM "'-child -dump -force_html ${charset:+--assume_charset "$charset"} '"\ else PGM=`$SEARCHPROG "$SEARCHPATH" elinks` if [ ! -z "$PGM" ]; then - echo "mhshow-show-text/html: $PGM -dump -force-html \ + echo "mhshow-show-text/html: %l$PGM -dump -force-html \ -eval 'set document.browse.margin_width = 0' %F" >> $TMP echo "mhfixmsg-format-text/html: $PGM -dump -force-html \ -no-numbering -eval 'set document.browse.margin_width = 0' %F" >> $TMP diff --git a/etc/mhshow.header b/etc/mhshow.header new file mode 100644 index 00000000..2f9bafee --- /dev/null +++ b/etc/mhshow.header @@ -0,0 +1,5 @@ +%; +%; This is provided as reference only; it shows the default content marker +%; used by mhshow when it decides to not display content. +%; +[ Message %{folder}%<{folder}:%>%(msg) ] diff --git a/h/mh.h b/h/mh.h index b8c60ca8..4b3818c0 100644 --- a/h/mh.h +++ b/h/mh.h @@ -377,7 +377,6 @@ typedef struct m_getfld_state *m_getfld_state_t; #define MS_UNKNOWN 1 /* type not known yet */ #define MS_MBOX 2 /* Unix-style "from" lines */ #define MS_MMDF 3 /* string mmdlm2 */ -#define MS_MSH 4 /* whacko msh */ #define NOUSE 0 /* draft being re-used */ diff --git a/h/mhparse.h b/h/mhparse.h index d1c94420..3efec9cb 100644 --- a/h/mhparse.h +++ b/h/mhparse.h @@ -502,8 +502,7 @@ char *get_param_value(PM pm, char replace); * markerform - The name of a file containg mh-format(5) code used to * display markers about non-displayed MIME parts. */ -void show_all_messages(CT *cts, int concat, int textonly, int inlineonly, - char *markerform); +void show_all_messages(CT *cts, int concat, int textonly, int inlineonly); /* * Display (or store) a single MIME part using the specified command diff --git a/h/nmh.h b/h/nmh.h index ca32f58b..24689192 100644 --- a/h/nmh.h +++ b/h/nmh.h @@ -74,5 +74,3 @@ #define DEFAULT_PAGER "more" #define DEFAULT_EDITOR "vi" - -#include diff --git a/man/mh-format.man b/man/mh-format.man index 4b58b3ff..baad0708 100644 --- a/man/mh-format.man +++ b/man/mh-format.man @@ -137,7 +137,7 @@ For string valued functions or components, the condition is true if the function return or component value is a non-empty string, and false for an empty string. .PP -The `%?' control escape is optional, and may there may be more +The `%?' control escape is optional, and there may be more than one `%?' control escape in a conditional block. The `%|' control escape is also optional, but may be included at most once. diff --git a/man/mhlist.man b/man/mhlist.man index 093b7a8c..ee70811d 100644 --- a/man/mhlist.man +++ b/man/mhlist.man @@ -1,4 +1,4 @@ -.TH MHLIST %manext1% "August 20, 2014" "%nmhversion%" +.TH MHLIST %manext1% "February 6, 2015" "%nmhversion%" .\" .\" %nmhwarning% .\" @@ -98,24 +98,46 @@ By default, .B mhlist will list information about the entire message (all of its parts). By using the -.B \-part +.BR \-part , +.BR \-type , and -.B \-type -switches, you may limit the scope of this command to particular -subparts (of a multipart content) and/or particular content types. -.PP -A part specification consists of a series of numbers separated by dots. -For example, in a multipart content containing three parts, these -would be named as 1, 2, and 3, respectively. If part 2 was also a -multipart content containing two parts, these would be named as 2.1 and -2.2, respectively. Note that the +.B \-prefer +switches, you may limit and reorder the set of parts to be listed, +based on part number and/or content type. +.PP +A part specification consists of a series of numbers separated by +dots. For example, in a multipart content containing three parts, +these would be named as 1, 2, and 3, respectively. If part 2 was also +a multipart content containing two parts, these would be named as 2.1 +and 2.2, respectively. Note that the .B \-part -switch is effective for only -messages containing a multipart content. If a message has some other -kind of content, or if the part is itself another multipart content, the +switch is effective for only messages containing a multipart content. +If a message has some other kind of content, or if the part is itself +another multipart content, the .B \-part switch will not prevent the content from being acted upon. .PP +The +.B \-type +switch can also be used to restrict (or, when used in conjunction with +.BR \-part , +to further restrict) the selection of parts according to content type. +One or more +.B \-type +switches part will only select the first match +from a multipart/alternative, even if there is more than one +subpart that matches (one of) the given content type(s). +.PP +Using either +.B \-part +or +.B -type +switches alone will cause either to select +the part(s) they match. Using them together will select only +the part(s) matched by both (sets of) switches. In other +words, the result is the intersection, and not the union, of their +separate match results. +.PP A content specification consists of a content type and a subtype. The initial list of \*(lqstandard\*(rq content types and subtypes can be found in RFC 2046. @@ -177,7 +199,7 @@ but is also implemented in .B mhlist and .B mhstore -to make common part number ordering possible across all three programs. +to make common part numbering possible across all three programs. .SS "Checking the Contents" The .B \-check diff --git a/man/mhshow.man b/man/mhshow.man index 67516be5..c2bba35c 100644 --- a/man/mhshow.man +++ b/man/mhshow.man @@ -1,4 +1,4 @@ -.TH MHSHOW %manext1% "April 9, 2014" "%nmhversion%" +.TH MHSHOW %manext1% "February 8, 2015" "%nmhversion%" .\" .\" %nmhwarning% .\" @@ -24,6 +24,7 @@ mhshow \- display MIME messages .RB [ \-concat " | " \-noconcat ] .RB [ \-textonly " | " \-notextonly ] .RB [ \-inlineonly " | " \-noinlineonly ] +.RB [ \-header " | " \-noheader ] .RB [ \-form .IR formfile ] .RB [ \-markform @@ -59,14 +60,13 @@ and .B \-noinlineonly switches. In addition, by using the -.B \-part +.BR \-part , +.BR \-type , and -.B \-type -switches, you may -further limit the scope of -.B mhshow -to particular subparts (of a -multipart content) and/or particular content types. The inclusion of any +.B \-prefer +switches, you may limit and reorder the set of parts to be displayed, +based on part number and/or content type. +The inclusion of any .B \-part or .B \-type @@ -75,6 +75,22 @@ switches will override the default settings of and .BR \-inlineonly. .PP +The +.B \-header +switch control whether +.B mhshow +will print a message separator header before each message that it +displays. The header format can be controlled using +.B \-headerform +to specify a file containing +.IR mh\-format (5) +instructions. A copy of the built-in default +headerform can be found in %nmhetcdir%/mhshow.header, for reference. +In addition to the normal set of +.IR mh\-format (5) +instructions, a "%{folder}" escape provides a +string representing the current folder. +.PP By default .B mhshow will concatenate all content under one pager. If you which each part to @@ -140,6 +156,16 @@ switches part will only select the first match from a multipart/alternative, even if there is more than one subpart that matches (one of) the given content type(s). .PP +Using either +.B \-part +or +.B -type +switches alone will cause either to select +the part(s) they match. Using them together will select only +the part(s) matched by both (sets of) switches. In other +words, the result is the intersection, and not the union, of their +separate match results. +.PP A content specification consists of a content type and a subtype. The initial list of \*(lqstandard\*(rq content types and subtypes can be found in RFC 2046. @@ -671,8 +697,9 @@ next. The default marker can be changed using the .B \-markform switch to specify a file containing .IR mh\-format (5) -instructions to use when displaying the content marker. In addition to -the normal set of +instructions to use when displaying the content marker. A copy of the +default markform can be found in %nmhetcdir%/mhshow.marker, for +reference. In addition to the normal set of .IR mh\-format (5) instructions, the following .I component @@ -722,6 +749,7 @@ is checked. ^%nmhetcdir%/mhn.defaults~^System default MIME profile entries ^%nmhetcdir%/mhl.headers~^The headers template ^%nmhetcdir%/mhshow.marker~^Example content marker +^%nmhetcdir%/mhshow.header~^Example message separator header .fi .SH "PROFILE COMPONENTS" .fc ^ ~ diff --git a/man/mhstore.man b/man/mhstore.man index 2484d69e..fb0f57dd 100644 --- a/man/mhstore.man +++ b/man/mhstore.man @@ -1,4 +1,4 @@ -.TH MHSTORE %manext1% "March 2, 2014" "%nmhversion%" +.TH MHSTORE %manext1% "February 6, 2015" "%nmhversion%" .\" .\" %nmhwarning% .\" @@ -51,13 +51,12 @@ By default, will store all the parts of each message. Each part will be store in a separate file. The header fields of the message are not stored. By using the -.B \-part +.BR \-part , +.BR \-type , and -.B \-type -switches, you may limit the scope of -.B mhstore -to particular -subparts (of a multipart content) and/or particular content types. +.B \-prefer +switches, you may limit and reorder the set of parts to be stored, +based on part number and/or content type. .PP The .B \-file @@ -83,21 +82,40 @@ messages, see .PP A part specification consists of a series of numbers separated by dots. For example, in a multipart content containing three parts, -these would be named as 1, 2, and 3, respectively. If part 2 was -also a multipart content containing two parts, these would be named -as 2.1 and 2.2, respectively. Note that the +these would be named as 1, 2, and 3, respectively. If part 2 was also +a multipart content containing two parts, these would be named as 2.1 +and 2.2, respectively. Note that the .B \-part -switch is -effective for only messages containing a multipart content. If a -message has some other kind of content, or if the part is itself +switch is effective for only messages containing a multipart content. +If a message has some other kind of content, or if the part is itself another multipart content, the .B \-part -switch will not prevent -the content from being acted upon. +switch will not prevent the content from being acted upon. +.PP +The +.B \-type +switch can also be used to restrict (or, when used in conjunction with +.BR \-part , +to further restrict) the selection of parts according to content type. +One or more +.B \-type +switches part will only select the first match +from a multipart/alternative, even if there is more than one +subpart that matches (one of) the given content type(s). +.PP +Using either +.B \-part +or +.B -type +switches alone will cause either to select +the part(s) they match. Using them together will select only +the part(s) matched by both (sets of) switches. In other +words, the result is the intersection, and not the union, of their +separate match results. .PP A content specification consists of a content type and a subtype. -The initial list of \*(lqstandard\*(rq content types and subtypes -can be found in RFC 2046. +The initial list of \*(lqstandard\*(rq content types and subtypes can +be found in RFC 2046. .PP A list of commonly used contents is briefly reproduced here: .PP @@ -145,7 +163,7 @@ but is also implemented in .B mhlist and .B mhstore -to make common part number ordering possible across all three programs. +to make common part numbering possible across all three programs. See .IR mhlist (1) and diff --git a/man/show.man b/man/show.man index a248e6ac..57832c3f 100644 --- a/man/show.man +++ b/man/show.man @@ -1,4 +1,4 @@ -.TH SHOW %manext1% "June 6, 2012" "%nmhversion%" +.TH SHOW %manext1% "February 8, 2015" "%nmhversion%" .\" .\" %nmhwarning% .\" @@ -43,7 +43,11 @@ manual page for the details about this command. This default can be changed by defining the .I showproc profile component. Any switches not recognized by -.B show +.BR show , +as well as +.B \-header +and +.BR \-noheader , are passed along to that program. To override the default and the .I showproc diff --git a/sbr/context_save.c b/sbr/context_save.c index 70809595..27d55e9e 100644 --- a/sbr/context_save.c +++ b/sbr/context_save.c @@ -7,19 +7,18 @@ * complete copyright information. */ -#include -#include - /* - * static prototypes + * This function used to support setuid/setgid programs by writing + * the file as the user. But that code, m_chkids(), was removed + * because there no longer are setuid/setgid programs in nmh. */ -static int m_chkids(void); +#include +#include void context_save (void) { - int action; register struct node *np; FILE *out; sigset_t set, oset; @@ -33,9 +32,6 @@ context_save (void) return; ctxflags &= ~CTXMOD; - if ((action = m_chkids ()) > 0) - return; /* child did it for us */ - /* block a few signals */ sigemptyset (&set); sigaddset (&set, SIGHUP); @@ -57,48 +53,4 @@ context_save (void) lkfclosedata (out, ctxpath); sigprocmask (SIG_SETMASK, &oset, &set); /* reset the signal mask */ - - if (action == 0) - /* This must be _exit(), not exit(), because the child didn't - call unregister_for_removal() in m_chkids(). */ - _exit (0); /* we are child, time to die */ -} - -/* - * This hack brought to you so we can handle set[ug]id MH programs. - * If we return -1, then no fork is made, we update .mh_profile - * normally, and return to the caller normally. If we return 0, - * then the child is executing, .mh_profile is modified after - * we set our [ug]ids to the norm. If we return > 0, then the - * parent is executed and .mh_profile has already be modified. - * We can just return to the caller immediately. - */ - -static int -m_chkids (void) -{ - int i; - pid_t pid; - - if (getuid () == geteuid ()) - return (-1); - - for (i = 0; (pid = fork ()) == -1 && i < 5; i++) - sleep (5); - - switch (pid) { - case -1: - break; - - case 0: - /* It's not necessary to call unregister_for_removal(0) - because the child calls _exit() in context_save(). */ - break; - - default: - pidwait (pid, -1); - break; - } - - return pid; } diff --git a/sbr/getansreadline.c b/sbr/getansreadline.c index e68cba89..5d80dd97 100644 --- a/sbr/getansreadline.c +++ b/sbr/getansreadline.c @@ -8,7 +8,6 @@ */ #include -#include #ifdef READLINE_SUPPORT #include diff --git a/sbr/lock_file.c b/sbr/lock_file.c index f4d3902b..a8a98118 100644 --- a/sbr/lock_file.c +++ b/sbr/lock_file.c @@ -561,7 +561,7 @@ lockit (struct lockinfo *li) curlock = li->curlock; if ((tmpfile = m_mktemp(li->tmplock, &fd, NULL)) == NULL) { - advise(NULL, "unable to create temporary file in %s", get_temp_dir()); + advise(NULL, "unable to create temporary file in %s", li->tmplock); return -1; } diff --git a/test/bad-input/test-header b/test/bad-input/test-header index 1716ff1f..eeacc831 100755 --- a/test/bad-input/test-header +++ b/test/bad-input/test-header @@ -38,7 +38,7 @@ cat >"$expected" < "$actual" 2>&1 -check "$expected" "$actual" +check "$expected" "$actual" : scan with bogus header field # check show (mhl) cat >"$expected" < "$actual" 2>&1 -check "$expected" "$actual" +check "$expected" "$actual" : "show (mhl) with bogus header field" # check mhshow cat >"$expected" < "$actual" 2>&1 -check "$expected" "$actual" +check "$expected" "$actual" : mhshow with bogus header field # check m_getfld() handling of empty header field msgfile="$MH_TEST_DIR/Mail/inbox/12" @@ -86,8 +87,8 @@ scan: eof encountered in field "Received" EOF run_prog scan -width 13 last >"$actual" 2>"$actual_err" -check "$expected" "$actual" -check "$expected_err" "$actual_err" +check "$expected" "$actual" : m_getfld, empty header output +check "$expected_err" "$actual_err" : m_getfld, empty header error # check m_getfld() handling of excessively long header field name msgfile="$MH_TEST_DIR/Mail/inbox/13" @@ -100,7 +101,7 @@ cat >"$expected" <"$actual" 2>"$actual_err" -check "$expected" "$actual" +check "$expected" "$actual" : m_getfld with excessively long header field name # Cygwin has a BUFSIZ of 1024 so the error message gets truncated. # Deal with that by grepping to verify that scan showed the proper error. verify_string_in_file() { @@ -135,8 +136,8 @@ scan: eol encountered in field "If a header field name has at least 512 characte EOF run_prog scan -width 13 last >"$actual" 2>"$actual_err" -check "$expected" "$actual" -check "$expected_err" "$actual_err" +check "$expected" "$actual" : m_getfld with long header, no colon output +check "$expected_err" "$actual_err" : m_getfld with long header, no colon error exit $failed diff --git a/test/common.sh.in b/test/common.sh.in index e84d8e62..aa1e8455 100644 --- a/test/common.sh.in +++ b/test/common.sh.in @@ -155,23 +155,26 @@ prepare_space() { #### check() requires two arguments, each the name of a file to be #### diff'ed. -#### If the contents are same, the second file is removed. And the -#### first file is removed unless there's an optional argument with -#### a value of 'keep first'. -#### If different, global variable "failed" is incremented. -#### If there's an optional 'ignore space' argument, spacing differences -#### will not be considered signficant, emulating GNU diff -w. It -#### is assumed that the first file has already been run through -#### prepare_space. +#### If the contents are same, the second file is removed. If different, +#### global variable "failed" is incremented. +#### Optional arguments: +#### 'keep first' -- first file is removed unless this is present. +#### 'ignore space' -- spacing differences will not be considered +#### signficant, emulating GNU diff -w. It is assumed that the +#### first file has already been run through prepare_space. +#### ':' -- will print '' in the failure message, +#### to make it easier to tell which of multiple tests has failed. check() { first=$1; shift second=$1; shift keepfirst= ignorespace= + label=test while [ $# -gt 0 ]; do case $1 in 'keep first') keepfirst=1 ;; 'ignore space') ignorespace=1 ;; + ':') shift; label=\'"$*"\'; break ;; *) echo "$0: invalid check() argument \"$1\" in test suite" >&2 ;; esac shift @@ -193,7 +196,7 @@ check() { #### POSIX diff should support -c. diff -c "$first" "$second" || true echo - echo "$0: test failed, outputs are in $first and $second." + echo "$0: $label failed, outputs are in $first and $second." failed=`expr ${failed:-0} + 1` #### Set return status of the function. [ $failed -eq 0 ] @@ -289,7 +292,16 @@ mhbuild: -nocontentid mhlproc: ${MH_LIBEXEC_DIR}/mhl moreproc: cat postproc: ${MH_LIBEXEC_DIR}/post +showmimeproc: ${MH_INST_DIR}${bindir}/mhshow showproc: ${MH_LIBEXEC_DIR}/mhl +#: The following aren't currently used by the test suite, but are +#: defined here in case they are in the future: +mailproc: ${MH_INST_DIR}${bindir}/mhmail +rcvstoreproc: ${MH_LIBEXEC_DIR}/rcvstore +sendproc: ${MH_INST_DIR}${bindir}/send +whatnowproc: ${MH_INST_DIR}${bindir}/whatnow +whomproc: ${MH_INST_DIR}${bindir}/whom +#: incproc and packproc are defined in config.c but not used by any code. EOF if test -z '@nmhetcdirinst@'; then diff --git a/test/mhparam/test-mhparam b/test/mhparam/test-mhparam index 8a48b8de..29dd11f3 100755 --- a/test/mhparam/test-mhparam +++ b/test/mhparam/test-mhparam @@ -84,18 +84,18 @@ $MH_INST_DIR$bindir/refile 700 $bindir/inc more -$bindir/mhmail +$MH_INST_DIR$bindir/mhmail $MH_INST_DIR$nmhlibexecdir/mhl cat 600 $bindir/packf $MH_INST_DIR$nmhlibexecdir/post -$bindir/send -$bindir/mhshow +$MH_INST_DIR$bindir/send +$MH_INST_DIR$bindir/mhshow $MH_INST_DIR$nmhlibexecdir/mhl nmh-`cat ${srcdir}/VERSION` -$bindir/whatnow -$bindir/whom +$MH_INST_DIR$bindir/whatnow +$MH_INST_DIR$bindir/whom $nmhetcdirinst $MH_LIBEXEC_DIR fcntl diff --git a/test/mhshow/test-charset b/test/mhshow/test-charset index e0a0b6e8..6c3c763a 100755 --- a/test/mhshow/test-charset +++ b/test/mhshow/test-charset @@ -43,6 +43,7 @@ Date: Sun, 18 Dec 2005 00:52:39 +0100 EOF cat > $expected < $actual 2>&1 -check "$expected" "$actual" +check "$expected" "$actual" : bogus quoted-printable data exit $failed diff --git a/test/mhshow/test-cte-binary b/test/mhshow/test-cte-binary index fdf1ca78..f872e3b0 100755 --- a/test/mhshow/test-cte-binary +++ b/test/mhshow/test-cte-binary @@ -35,6 +35,7 @@ EOF # check it cat > $expected < $actual 2>&1 -check "$expected" "$actual" +check "$expected" "$actual" : C-T-E binary text exit $failed diff --git a/test/mhshow/test-msg-buffer-boundaries b/test/mhshow/test-msg-buffer-boundaries index 47005cc9..ca1e7cd6 100755 --- a/test/mhshow/test-msg-buffer-boundaries +++ b/test/mhshow/test-msg-buffer-boundaries @@ -153,12 +153,13 @@ EOF # Write the expected output. cat >"$expected" <"$actual" 2>&1 -check "$expected" "$actual" +check "$expected" "$actual" : check number 1 # check a boundary condition in m_getfld(): its internal message # buffer holds exactly up to the end of a header field name in a @@ -293,12 +294,13 @@ EOF # Write the expected output. cat >"$expected" <"$actual" 2>&1 -check "$expected" "$actual" +check "$expected" "$actual" : check number 2 # check a boundary condition in m_getfld(): its internal message # buffer holds exactly up to the end of a message part boundary @@ -434,12 +436,13 @@ EOF # Write the expected output. cat >"$expected" <"$actual" 2>&1 -check "$expected" "$actual" +check "$expected" "$actual" : check number 3 exit $failed diff --git a/test/mhshow/test-qp b/test/mhshow/test-qp index dae70a5a..1b78c8ea 100755 --- a/test/mhshow/test-qp +++ b/test/mhshow/test-qp @@ -47,6 +47,7 @@ EOF # check it cat > $expected < $actual 2>&1 -check "$expected" "$actual" +check "$expected" "$actual" : bogus quoted-printable data exit $failed diff --git a/test/mhshow/test-subpart b/test/mhshow/test-subpart index 161dceab..27fb9077 100755 --- a/test/mhshow/test-subpart +++ b/test/mhshow/test-subpart @@ -51,18 +51,22 @@ EOF # Write the expected output. cat > $expected < $actual 2>&1 -check "$expected" "$actual" +check "$expected" "$actual" : part 1.1 + + +# tests of -part/-type/-prefer cat > $msgfile < -Subject: mhshow -part/-type/prefer test +Subject: mhshow -part/-type/-prefer test Date: Thu, 29 Jan 2015 18:12:21 +0000 (GMT) Content-Type: multipart/mixed; boundary="BoundaryMixed" @@ -71,7 +75,7 @@ Content-type: multipart/alternative; boundary="BoundaryAlternative1" --BoundaryAlternative1 -Content-type: text/plain; charset=ISO-8859-1; format=flowed +Content-type: text/plain; charset=US-ASCII; format=flowed Content-transfer-encoding: 8bit This is the body text/plain part. @@ -105,36 +109,42 @@ EOF # Write the expected output. cat > $expected < $actual 2>&1 -check "$expected" "$actual" +# The sed command removes blank lines and leading space that lynx inserts. +run_prog mhshow -part 1.1.1 -form mhl.null $msgnum | + sed '/^$/D; s/^ *//;' > $actual 2>&1 +check "$expected" "$actual" : part 1.1.1 # Write the expected output. cat > $expected < $actual 2>&1 -check "$expected" "$actual" +check "$expected" "$actual" : part 1.2 # Write the expected output. cat > $expected < $actual 2>&1 -check "$expected" "$actual" +check "$expected" "$actual" : part conflicting text/plain, part 1 switches # Write the expected output. cat > $expected < $actual 2>&1 -check "$expected" "$actual" +check "$expected" "$actual" : part 2 # Write the expected output. cat > $expected < $actual 2>&1 -check "$expected" "$actual" +check "$expected" "$actual" : type text/plain # Write the expected output. cat > $expected < $actual 2>&1 -check "$expected" "$actual" +check "$expected" "$actual" : prefer text/plain exit $failed diff --git a/test/mhshow/test-textcharset b/test/mhshow/test-textcharset index d4d7ef07..f8d854fc 100755 --- a/test/mhshow/test-textcharset +++ b/test/mhshow/test-textcharset @@ -28,6 +28,7 @@ actual="$MH_TEST_DIR"/$$.actual # check charset conversion msgfile=`mhpath new` +msgnum=`basename $msgfile` cat >"$msgfile" <<'EOF' From: foo@example.edu To: bar@example.edu @@ -40,7 +41,8 @@ Date: Sun, 18 Dec 2005 00:52:39 +0100 4 =F7 2 =3D 2 EOF -cat >"$expected" <<'EOF' +cat >"$expected" <"$actual" 2>&1 -check "$expected" "$actual" +check "$expected" "$actual" : check charset conversion cat >>"$MH" <<'EOF' mhshow-show-text/plain: echo %{charset} @@ -62,6 +64,7 @@ EOF # check expansion of %{charset} by itself msgfile=`mhpath new` +msgnum=`basename $msgfile` cat >"$msgfile" <<'EOF' From: foo@example.edu To: bar@example.edu @@ -74,7 +77,8 @@ Date: Sun, 18 Dec 2005 00:52:39 +0100 4 =F7 2 =3D 2 EOF -cat >"$expected" <<'EOF' +cat >"$expected" <"$actual" 2>&1 -check "$expected" "$actual" +check "$expected" "$actual" : check %{charset} by itself # check expansion of empty %{charset} by itself msgfile=`mhpath new` +omsgnum=$msgnum +msgnum=`basename $msgfile` cat >"$msgfile" <<'EOF' From: foo@example.edu To: bar@example.edu @@ -103,7 +109,8 @@ Date: Sun, 18 Dec 2005 00:52:39 +0100 4 =F7 2 =3D 2 EOF -cat >"$expected" <<'EOF' +cat >"$expected" <"$actual" 2>&1 -check "$expected" "$actual" +check "$expected" "$actual" : check empty %{charset} by itself grep -v 'mhshow-show-text/plain:' "$MH" >"$MH.new" @@ -125,7 +132,8 @@ mhshow-show-text/plain: charset=%{charset}; echo ${charset:+-I $charset} EOF # check expansion of embedded %{charset} with no text following -cat >"$expected" <<'EOF' +cat >"$expected" <"$actual" 2>&1 -check "$expected" "$actual" +run_prog mhshow prev >"$actual" 2>&1 # NB: "mhshow prev" !!! +check "$expected" "$actual" : check embedded %{charset} with no text # check expansion of empty embedded %{charset} with no text following -cat >"$expected" <<'EOF' +cat >"$expected" <"$actual" 2>&1 -check "$expected" "$actual" +check "$expected" "$actual" : check empty embedded %{charset} with no text following sed -e 's%\(mhshow-show-text/plain:.*\)%\1 file%' "$MH" >"$MH.new" mv -f "$MH.new" "$MH" # check expansion of embedded %{charset} with text following -cat >"$expected" <<'EOF' +cat >"$expected" <"$actual" 2>&1 -check "$expected" "$actual" +run_prog mhshow prev >"$actual" 2>&1 # NB: "mhshow prev" !!! +check "$expected" "$actual" : check embedded %{charset} with text following # check expansion of empty embedded %{charset} with text following -cat >"$expected" <<'EOF' +cat >"$expected" <"$actual" 2>&1 -check "$expected" "$actual" +check "$expected" "$actual" : check empty embedded %{charset} with text following sed -e 's/charset/method/g' "$MH" >"$MH.new" @@ -196,6 +207,7 @@ mv -f "$MH.new" "$MH" # check parameter value quoting msgfile=`mhpath new` +msgnum=`basename $msgfile` cat >"$msgfile" <<'EOF' From: foo@example.edu To: bar@example.edu @@ -208,7 +220,10 @@ Date: Sun, 18 Dec 2005 00:52:39 +0100 4 =F7 2 =3D 2 EOF -cat >"$expected" <<'EOF' +cat >"$expected" <>"$expected" <<'EOF' Date: Sun, 18 Dec 2005 00:52:39 +0100 To: bar@example.edu From: foo@example.edu @@ -220,7 +235,7 @@ MIME-Version: 1.0 EOF run_prog mhshow last >"$actual" 2>&1 -check "$expected" "$actual" +check "$expected" "$actual" : check parameter value quoting sed -e 's/method/unknown/g' "$MH" >"$MH.new" @@ -228,6 +243,7 @@ mv -f "$MH.new" "$MH" # check that unknown parameter is not expanded msgfile=`mhpath new` +msgnum=`basename $msgfile` cat >"$msgfile" <<'EOF' From: foo@example.edu To: bar@example.edu @@ -240,7 +256,8 @@ Date: Sun, 18 Dec 2005 00:52:39 +0100 4 =F7 2 =3D 2 EOF -cat >"$expected" <<'EOF' +cat >"$expected" <"$actual" 2>&1 -check "$expected" "$actual" +check "$expected" "$actual" : check unknown parameter is not expanded grep -v '^mhshow-show-text/plain: ' "$MH" >>"$MH.new" @@ -263,6 +280,7 @@ EOF # check parameter value quoting with text following msgfile=`mhpath new` +msgnum=`basename $msgfile` cat >"$msgfile" <<'EOF' From: foo@example.edu To: bar@example.edu @@ -274,7 +292,8 @@ Date: Sun, 18 Dec 2005 00:52:39 +0100 This is a test. EOF -cat >"$expected" <<'EOF' +cat >"$expected" <"$actual" 2>&1 -check "$expected" "$actual" +check "$expected" "$actual" : parameter value quoting with text following # # test a large file that needs to be converted to UTF-8 @@ -294,6 +313,7 @@ check "$expected" "$actual" grep -v '^mhshow-show-text/plain: ' "$MH" >>"$MH.new" mv -f "$MH.new" "$MH" msgfile=`mhpath new` +msgnum=`basename $msgfile` cat >"$msgfile" <<'EOF' From: foo@example.edu To: bar@example.edu @@ -728,7 +748,8 @@ one of the glass buildings. =93How strange!=94 she exclaimed, drawing a long breath. EOF -cat >"$expected" <<'EOF' +cat >"$expected" <"$actual" 2>&1 -check "$expected" "$actual" +check "$expected" "$actual" : large file conversion to UTF-8 exit $failed diff --git a/test/show/test-show b/test/show/test-show new file mode 100755 index 00000000..15540945 --- /dev/null +++ b/test/show/test-show @@ -0,0 +1,125 @@ +#!/bin/sh + +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 + +# Write message with a text/plain subpart. +msgfile=`mhpath new` +msgnum=`basename $msgfile` +cat > $msgfile < $expected <>> inbox:1 + + +Date: Fri, 29 Sep 2006 00:00:00 +To: Some User +From: Test1 +Subject: Testing message 1 + + +This is message number 1 + + + +>>> inbox:2 + + +Date: Fri, 29 Sep 2006 00:00:00 +To: Some User +From: Test2 +Subject: Testing message 2 + + +This is message number 2 +EOF + +show +inbox 1 2 > $actual || exit 1 + +check "$expected" "$actual" : show two non-mime + +# Test showing one MIME message shows message number. +# Format is different; why? + +cat > $expected < $actual || exit 1 + +check "$expected" "$actual" : show one MIME + +# Test showing multiple MIME messages shows message numbers. +# Currently fails. + +cat > $expected < +From: Test1 +Subject: Testing message 1 + + +[ part - text/plain - 25B ] +This is message number 1 +[ Message inbox:11 ] +Date: Thu, 19 May 2011 00:00:00 +To: recipient@example.com +From: sender@example.com + +MIME-Version: 1.0 +Content-class: urn:content-classes:message + +[ part 1.1 - text/plain - 29B ] +This is the text/plain part. +EOF + +show +inbox 1 $msgnum > $actual || exit 1 + +check "$expected" "$actual" : show multiple mime + +exit $failed diff --git a/uip/inc.c b/uip/inc.c index 8b9fe7ae..7d128420 100644 --- a/uip/inc.c +++ b/uip/inc.c @@ -8,7 +8,13 @@ */ #ifdef MAILGROUP -/* Revised: Sat Apr 14 17:08:17 PDT 1990 (marvit@hplabs) +/* + * Thu Feb 12 21:00 CST 2015 Marcin Cieslak + * Replaced setgid() calls with setegid() so that it works with dot + * locking on FreeBSD. setegid() should be supported on modern POSIX + * systems. + * + * Revised: Sat Apr 14 17:08:17 PDT 1990 (marvit@hplabs) * Added hpux hacks to set and reset gid to be "mail" as needed. The reset * is necessary so inc'ed mail is the group of the inc'er, rather than * "mail". We setgid to egid only when [un]locking the mail file. This @@ -127,10 +133,16 @@ static FILE *pf = NULL; * For setting and returning to "mail" gid */ #ifdef MAILGROUP -static int return_gid; +static gid_t return_gid; #define TRYDROPGROUPPRIVS() DROPGROUPPRIVS() -#define DROPGROUPPRIVS() setgid(getgid()) -#define GETGROUPPRIVS() setgid(return_gid) +#define DROPGROUPPRIVS() \ + if (setegid(getgid()) != 0) { \ + adios ("setegid", "unable to restore group to %ld", (long) getgid()); \ + } +#define GETGROUPPRIVS() \ + if (setegid(return_gid) != 0) { \ + adios ("setegid", "unable to set group to %ld", (long) return_gid); \ + } #define SAVEGROUPPRIVS() return_gid = getegid() #else /* define *GROUPPRIVS() as null; this avoids having lots of "#ifdef MAILGROUP"s */ @@ -947,6 +959,7 @@ skip: static void inc_done (int status) { + done = exit; if (packfile && pd != NOTOK) mbx_close (packfile, pd); if (locked) diff --git a/uip/mhbuild.c b/uip/mhbuild.c index de0fdaae..58b37c4e 100644 --- a/uip/mhbuild.c +++ b/uip/mhbuild.c @@ -9,7 +9,6 @@ #include #include -#include #include #include #include diff --git a/uip/mhbuildsbr.c b/uip/mhbuildsbr.c index 2e177c47..b9989934 100644 --- a/uip/mhbuildsbr.c +++ b/uip/mhbuildsbr.c @@ -17,7 +17,6 @@ #include #include -#include #include #include #include diff --git a/uip/mhcachesbr.c b/uip/mhcachesbr.c index 201b78e1..ae563c2f 100644 --- a/uip/mhcachesbr.c +++ b/uip/mhcachesbr.c @@ -9,7 +9,6 @@ #include #include -#include #include #include #include diff --git a/uip/mhlistsbr.c b/uip/mhlistsbr.c index 0110d9e0..5a45d036 100644 --- a/uip/mhlistsbr.c +++ b/uip/mhlistsbr.c @@ -10,7 +10,6 @@ #include #include -#include #include #include #include diff --git a/uip/mhn.c b/uip/mhn.c index be433d69..ea563791 100644 --- a/uip/mhn.c +++ b/uip/mhn.c @@ -554,7 +554,7 @@ do_cache: * Show the message content */ if (showsw) - show_all_messages (cts, 0, 0, 0, NULL); + show_all_messages (cts, 0, 0, 0); /* Now free all the structures for the content */ for (ctp = cts; *ctp; ctp++) diff --git a/uip/mhoutsbr.c b/uip/mhoutsbr.c index 0c0a2975..066a4b9a 100644 --- a/uip/mhoutsbr.c +++ b/uip/mhoutsbr.c @@ -10,7 +10,6 @@ #include #include -#include #include #include #include diff --git a/uip/mhparse.c b/uip/mhparse.c index f021b07f..dd4c5e9a 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -9,7 +9,6 @@ #include #include -#include #include #include #include diff --git a/uip/mhshow.c b/uip/mhshow.c index c8343763..b2a4c0da 100644 --- a/uip/mhshow.c +++ b/uip/mhshow.c @@ -31,6 +31,9 @@ X("noinlineonly", 0, NINLINESW) \ X("file file", 0, FILESW) \ X("form formfile", 0, FORMSW) \ + X("header", 0, HEADSW) \ + X("noheader", 0, NHEADSW) \ + X("headerform formfile", 0, HEADFORMSW) \ X("markform formfile", 0, MARKFORMSW) \ X("part number", 0, PARTSW) \ X("type content", 0, TYPESW) \ @@ -70,6 +73,10 @@ extern char *cache_private; extern char *progsw; extern int nomore; /* flags for moreproc/header display */ extern char *formsw; +extern char *folder; +extern char *headerform; +extern char *markerform; +extern int headersw; /* mhmisc.c */ extern int npart; @@ -110,7 +117,7 @@ int main (int argc, char **argv) { int msgnum, *icachesw, concatsw = -1, textonly = -1, inlineonly = -1; - char *cp, *file = NULL, *folder = NULL, *markform = NULL; + char *cp, *file = NULL; char *maildir, buf[100], **argp; char **arguments; struct msgs_array msgs = { 0, 0, NULL }; @@ -131,13 +138,13 @@ main (int argc, char **argv) while ((cp = *argp++)) { if (*cp == '-') { switch (smatch (++cp, switches)) { - case AMBIGSW: + case AMBIGSW: ambigsw (cp, switches); done (1); - case UNKWNSW: + case UNKWNSW: adios (NULL, "-%s unknown", cp); - case HELPSW: + case HELPSW: snprintf (buf, sizeof(buf), "%s [+folder] [msgs] [switches]", invo_name); print_help (buf, switches, 1); @@ -235,8 +242,20 @@ do_cache: formsw = getcpy (etcpath (cp)); continue; + case HEADSW: + headersw = 1; + continue; + case NHEADSW: + headersw = 0; + continue; + + case HEADFORMSW: + if (!(headerform = *argp++) || *headerform == '-') + adios (NULL, "missing argument to %s", argp[-2]); + continue; + case MARKFORMSW: - if (!(markform = *argp++) || *markform == '-') + if (!(markerform = *argp++) || *markerform == '-') adios (NULL, "missing argument to %s", argp[-2]); continue; @@ -257,10 +276,10 @@ do_cache: adios (NULL, "missing argument to %s", argp[-2]); continue; - case VERBSW: + case VERBSW: verbosw = 1; continue; - case NVERBSW: + case NVERBSW: verbosw = 0; continue; case DEBUGSW: @@ -338,6 +357,8 @@ do_cache: if ((ct = parse_mime (file))) *ctp++ = ct; + + headersw = 0; } else { /* * message(s) are coming from a folder @@ -430,7 +451,7 @@ do_cache: /* * Show the message content */ - show_all_messages (cts, concatsw, textonly, inlineonly, markform); + show_all_messages (cts, concatsw, textonly, inlineonly); /* Now free all the structures for the content */ for (ctp = cts; *ctp; ctp++) diff --git a/uip/mhshowsbr.c b/uip/mhshowsbr.c index 31d25eb1..056c2f45 100644 --- a/uip/mhshowsbr.c +++ b/uip/mhshowsbr.c @@ -33,6 +33,12 @@ char *progsw = NULL; int nomore = 0; char *formsw = NULL; +/* for output markerss and headers */ +char *folder = NULL; +char *markerform; +char *headerform; +int headersw = -1; + /* mhmisc.c */ int part_ok (CT); @@ -59,7 +65,9 @@ static int show_external (CT, int, int, int, int, struct format *); static int parse_display_string (CT, char *, int *, int *, char *, char *, size_t, int multipart); static int convert_content_charset (CT, char **); +static struct format *compile_header(char *); static struct format *compile_marker(char *); +static void output_header (CT, struct format *); static void output_marker (CT, struct format *, int); static void free_markercomps (void); static int pidcheck(int); @@ -69,6 +77,7 @@ static int pidcheck(int); * content marker display. */ +static struct comp *folder_comp = NULL; static struct comp *part_comp = NULL; static struct comp *ctype_comp = NULL; static struct comp *description_comp = NULL; @@ -89,11 +98,10 @@ static struct param_comp_list *dispo_pc_list = NULL; */ void -show_all_messages (CT *cts, int concatsw, int textonly, int inlineonly, - char *markerform) +show_all_messages (CT *cts, int concatsw, int textonly, int inlineonly) { CT ct, *ctp; - struct format *fmt; + struct format *hfmt, *mfmt; /* * If form is not specified, then get default form @@ -103,9 +111,10 @@ show_all_messages (CT *cts, int concatsw, int textonly, int inlineonly, formsw = getcpy (etcpath ("mhl.headers")); /* - * Compile the content marker format line + * Compile the content marker and header format lines */ - fmt = compile_marker(markerform); + mfmt = compile_marker(markerform); + hfmt = compile_header(headerform); /* * If form is "mhl.null", suppress display of header. @@ -118,12 +127,15 @@ show_all_messages (CT *cts, int concatsw, int textonly, int inlineonly, /* if top-level type is ok, then display message */ if (type_ok (ct, 1)) + if (headersw) output_header(ct, hfmt); + show_single_message (ct, formsw, concatsw, textonly, inlineonly, - fmt); + mfmt); } free_markercomps(); - fmt_free(fmt, 1); + fmt_free(hfmt, 1); + fmt_free(mfmt, 1); } @@ -1252,6 +1264,7 @@ convert_content_charset (CT ct, char **file) { * Compile our format string and save any parameters we care about. */ +#define DEFAULT_HEADER "[ Message %{folder}%<{folder}:%>%(msg) ]" #define DEFAULT_MARKER "[ part %{part} - %{content-type} - " \ "%<{description}%{description}" \ "%?{cdispo-filename}%{cdispo-filename}" \ @@ -1259,7 +1272,29 @@ convert_content_charset (CT ct, char **file) { "%(kilo(size))B %<(unseen)\\(suppressed\\)%> ]" static struct format * -compile_marker(char *markerform) +compile_header(char *form) +{ + struct format *fmt; + char *fmtstring; + struct comp *comp = NULL; + unsigned int bucket; + + fmtstring = new_fs(form, NULL, DEFAULT_HEADER); + + (void) fmt_compile(fmtstring, &fmt, 1); + free_fs(); + + while ((comp = fmt_nextcomp(comp, &bucket)) != NULL) { + if (strcasecmp(comp->c_name, "folder") == 0) { + folder_comp = comp; + } + } + + return fmt; +} + +static struct format * +compile_marker(char *form) { struct format *fmt; char *fmtstring; @@ -1267,10 +1302,10 @@ compile_marker(char *markerform) unsigned int bucket; struct param_comp_list *pc_entry; - fmtstring = new_fs(markerform, NULL, DEFAULT_MARKER); + fmtstring = new_fs(form, NULL, DEFAULT_MARKER); (void) fmt_compile(fmtstring, &fmt, 1); - free(fmtstring); + free_fs(); /* * Things we care about: @@ -1316,13 +1351,46 @@ compile_marker(char *markerform) * Output on stdout an appropriate marker for this content, using mh-format */ +static void +output_header(CT ct, struct format *fmt) +{ + charstring_t outbuf = charstring_create (BUFSIZ); + int dat[5] = { 0 }; + char *endp; + int message = 0; + + if (folder_comp) + folder_comp->c_text = getcpy(folder); + + if (ct->c_file && *ct->c_file) { + message = strtol(ct->c_file, &endp, 10); + if (*endp) message = 0; + dat[0] = message; + } + + /* it would be nice to populate dat[2], for %(size) here, + * but it's not available. it might also be nice to know + * if the message originally had any mime parts or not -- but + * there's also no record of that. (except for MIME-version:) + */ + + fmt_scan(fmt, outbuf, BUFSIZ, dat, NULL); + + fputs(charstring_buffer (outbuf), stdout); + charstring_free (outbuf); + + fmt_freecomptext(); +} + static void output_marker(CT ct, struct format *fmt, int hidden) { charstring_t outbuf = charstring_create (BUFSIZ); struct param_comp_list *pcentry; int partsize; - int dat[5]; + int message = 0; + char *endp; + int dat[5] = { 0 }; /* * Grab any items we care about. @@ -1360,13 +1428,18 @@ output_marker(CT ct, struct format *fmt, int hidden) else partsize = ct->c_end - ct->c_begin; + if (ct->c_file && *ct->c_file) { + message = strtol(ct->c_file, &endp, 10); + if (*endp) message = 0; + dat[0] = message; + } + dat[2] = partsize; + /* make the part's hidden aspect available by overloading the * %(unseen) function. make the part's size available via %(size). * see comments in h/fmt_scan.h. */ - dat[2] = partsize; dat[4] = hidden; - dat[0] = dat[1] = dat[3] = 0; fmt_scan(fmt, outbuf, BUFSIZ, dat, NULL); @@ -1385,6 +1458,7 @@ free_markercomps(void) { struct param_comp_list *pc_entry, *pc2; + folder_comp = NULL; part_comp = NULL; ctype_comp = NULL; description_comp = NULL; diff --git a/uip/mhstoresbr.c b/uip/mhstoresbr.c index c53f7ad3..62b2f4af 100644 --- a/uip/mhstoresbr.c +++ b/uip/mhstoresbr.c @@ -9,7 +9,6 @@ #include #include -#include #include #include #include diff --git a/uip/show.c b/uip/show.c index e5b71eff..f8910785 100644 --- a/uip/show.c +++ b/uip/show.c @@ -1,4 +1,3 @@ - /* * show.c -- show/list messages * @@ -79,23 +78,29 @@ main (int argc, char **argv) while ((cp = *argp++)) { if (*cp == '-') { switch (smatch (++cp, switches)) { - case AMBIGSW: + case AMBIGSW: ambigsw (cp, switches); done (1); + case HEADSW: + headersw = 1; + goto non_mhl_switches; + case NHEADSW: + headersw = 0; case CONCATSW: case NCONCATSW: +non_mhl_switches: /* mhl can't handle these, so keep them separate. */ app_msgarg(&non_mhl_vec, --cp); continue; - case UNKWNSW: + case UNKWNSW: case NPROGSW: case NFMTPROCSW: app_msgarg(&vec, --cp); continue; - case HELPSW: + case HELPSW: snprintf (buf, sizeof(buf), "%s [+folder] %s[switches] [switches for showproc]", invo_name, mode == SHOW ? "[msgs] ": ""); @@ -105,7 +110,7 @@ main (int argc, char **argv) print_version(invo_name); done (0); - case DRFTSW: + case DRFTSW: if (file) adios (NULL, "only one file at a time!"); draftsw++; @@ -115,7 +120,7 @@ usage: adios (NULL, "usage: %s [+folder] [switches] [switches for showproc]", invo_name); - case FILESW: + case FILESW: if (mode != SHOW) goto usage; if (draftsw || file) @@ -125,13 +130,6 @@ usage: file = path (cp, TFILE); continue; - case HEADSW: - headersw++; - continue; - case NHEADSW: - headersw = 0; - continue; - case FORMSW: app_msgarg(&vec, --cp); if (!(cp = *argp++) || *cp == '-') @@ -149,12 +147,12 @@ usage: app_msgarg(&vec, cp); continue; - case SHOWSW: + case SHOWSW: if (!(showproc = *argp++) || *showproc == '-') adios (NULL, "missing argument to %s", argp[-2]); nshow = 0; continue; - case NSHOWSW: + case NSHOWSW: nshow++; continue; @@ -194,6 +192,7 @@ usage: app_msgarg(&vec, getcpy (m_draft (folder, NULL, 1, &isdf))); else app_msgarg(&vec, file); + headersw = 0; goto go_to_it; } @@ -252,11 +251,7 @@ usage: context_replace (pfolder, folder); /* update current folder */ context_save (); /* save the context file */ - if (headersw && vec.size == 1) - printf ("(Message %s:%s)\n", folder, vec.msgs[0]); - go_to_it: ; - fflush (stdout); /* * Decide which "proc" to use @@ -290,12 +285,22 @@ go_to_it: ; if (folder && !draftsw && !file) m_putenv ("mhfolder", folder); - if (strcmp (r1bindex (proc, '/'), "mhl") == 0) { + if (strcmp (r1bindex (proc, '/'), "cat") == 0) { + + if (headersw && vec.size == 1) + printf ("(Message %s:%s)\n", folder, vec.msgs[0]); + + } else if (strcmp (r1bindex (proc, '/'), "mhl") == 0) { + + if (headersw && vec.size == 1) + printf ("(Message %s:%s)\n", folder, vec.msgs[0]); + /* If "mhl", then run it internally */ argsplit_insert(&vec, "mhl", &program); app_msgarg(&vec, NULL); mhl (vec.size, vec.msgs); done (0); + } else { int i; char **mp; @@ -324,9 +329,14 @@ go_to_it: ; app_msgarg(&vec, vec.msgs[vec.size - 1]); vec.msgs[vec.size - 2] = "-file"; } + } else { + if (headersw && vec.size == 1) + printf ("(Message %s:%s)\n", folder, vec.msgs[0]); } } + fflush (stdout); + argsplit_insert(&vec, proc, &program); app_msgarg(&vec, NULL); execvp (program, vec.msgs); diff --git a/uip/viamail.c b/uip/viamail.c index 0ff765c4..050ca0f6 100644 --- a/uip/viamail.c +++ b/uip/viamail.c @@ -9,7 +9,6 @@ #include #include -#include #include #include #include