]> git.marmaro.de Git - mmh/commitdiff
Merge branch 'm_getfld2-meillo' into master
authorPhilipp Takacs <philipp@bureaucracy.de>
Fri, 22 Apr 2016 22:56:56 +0000 (00:56 +0200)
committerPhilipp Takacs <philipp@bureaucracy.de>
Fri, 22 Apr 2016 22:56:56 +0000 (00:56 +0200)
127 files changed:
config/config.c
configure.ac
docs/TODO
etc/Makefile.in
etc/mhl.headers
etc/rcvdistcomps
etc/replcomps
etc/replgroupcomps
etc/scan.default [new file with mode: 0644]
etc/scan.meillo
h/mh.h
h/prototypes.h
h/scansbr.h
h/utils.h
man/ap.man8
man/dp.man8
man/fmtdump.man8
man/folder.man1
man/forw.man1
man/inc.man1
man/mark.man1
man/mh-alias.man5
man/mh-draft.man7
man/mh-format.man5
man/mh-mail.man5
man/mh-profile.man5
man/mh-sequence.man7
man/mhbuild.man1
man/mhl.man1
man/mhlist.man1
man/mhmail.man1
man/mhparam.man1
man/mhpath.man1
man/mhstore.man1
man/packf.man1
man/pick.man1
man/prompter.man1
man/rcvstore.man1
man/refile.man1
man/repl.man1
man/rmf.man1
man/scan.man1
man/show.man1
man/slocal.man1
man/sortm.man1
man/whatnow.man1
sbr/Makefile.in
sbr/addrsbr.c
sbr/brkstring.c
sbr/concat.c
sbr/context_del.c
sbr/context_read.c
sbr/context_replace.c
sbr/crawl_folders.c
sbr/encode_rfc2047.c
sbr/fmt_addr.c
sbr/fmt_compile.c
sbr/fmt_new.c
sbr/fmt_rfc2047.c
sbr/folder_free.c
sbr/folder_read.c
sbr/folder_realloc.c
sbr/getarguments.c
sbr/getcpy.c [deleted file]
sbr/lock_file.c
sbr/m_draft.c
sbr/mf.c
sbr/putenv.c
sbr/readconfig.c
sbr/seq_list.c
sbr/seq_read.c
sbr/seq_setprev.c
sbr/seq_setunseen.c
sbr/trimcpy.c
sbr/utils.c
sbr/vfgets.c
test/tests/mhsign/test-mhsign [new file with mode: 0755]
test/tests/refile/test-refile [new file with mode: 0755]
test/tests/repl/test-decode-addr [new file with mode: 0644]
test/tests/repl/test-if-str
test/tests/scan/test-mh-format [new file with mode: 0644]
uip/Makefile.in
uip/ali.c
uip/aliasbr.c
uip/anno.c
uip/ap.c
uip/burst.c
uip/comp.c
uip/dist.c
uip/flist.c
uip/fmtdump.c
uip/folder.c
uip/forw.c
uip/inc.c
uip/mark.c
uip/mhbuild.c
uip/mhfree.c
uip/mhl.c
uip/mhlist.c
uip/mhlistsbr.c
uip/mhmail.c
uip/mhmisc.c
uip/mhparam.c
uip/mhparse.c
uip/mhpath.c
uip/mhshow.c
uip/mhshowsbr.c
uip/mhsign.sh
uip/mhstore.c
uip/mhtest.c
uip/new.c
uip/packf.c
uip/pick.c
uip/rcvdist.c
uip/rcvstore.c
uip/refile.c
uip/repl.c
uip/rmf.c
uip/rmm.c
uip/scan.c
uip/scansbr.c
uip/send.c
uip/slocal.c
uip/sortm.c
uip/spost.c
uip/whatnow.c
uip/whom.c

index 2bf7325bb42e4579de76906f36bb7cc4e44c7aca..5e250414946e3686b97a1a1253c1558109566c0a 100644 (file)
@@ -62,6 +62,7 @@ char *digestcomps    = "digestcomps";      /* forw -digest */
 /* standard format (filter) files */
 char *mhlformat      = "mhl.format";       /* show         */
 char *mhlreply       = "mhl.reply";        /* repl         */
+char *scanformat     = "scan.default";     /* scan/inc     */
 
 
 /*
index 653acf0ad0760d5d01268c0288831cd8f025b253..ad45c152ca8acaa95013be5653af0254425ed9d3 100644 (file)
@@ -377,7 +377,7 @@ dnl -------------------
 dnl Check location of modf
 AC_CHECK_FUNC(modf, , AC_CHECK_LIB(m, modf))
 
-termcap_curses_order="termcap curses ncurses"
+termcap_curses_order="termcap curses ncurses tinfo"
 for lib in $termcap_curses_order; do
   AC_CHECK_LIB(${lib}, tgetent, [TERMLIB="-l$lib"; break])
 done
index a439680d39fe234c196bd14876d8a38f8ce3553e..308f755c864e55be57530a41c98ee6e849173ad9 100644 (file)
--- a/docs/TODO
+++ b/docs/TODO
@@ -4,7 +4,6 @@ TODO
 * Write different function to read configuration files, instead
   of using m_getfld.c
 * convert calls from sprintf/vsprintf to snprintf/vsnprintf
-* convert calls from getcpy to strdup
 * modularize access to context/profile list.
 * add command printm to print messages
 * finish changing to macros for msgstats and msgflags
index da3bb51aa08b96145f45007cec5df7afddb9dba4..fd00e0de39376ba381358b819fc00300809b5f31 100644 (file)
@@ -31,7 +31,8 @@ STATIC_FILES = components digestcomps distcomps forwcomps \
                mhl.reply rcvdistcomps rcvdistcomps.outbox \
                replcomps replgroupcomps scan.MMDDYY scan.YYYYMMDD \
                scan.nmh scan.mailx scan.nomime scan.size scan.time \
-               scan.timely scan.unseen scan.meillo mhn.defaults
+               scan.timely scan.unseen scan.meillo scan.default \
+               mhn.defaults
 
 # ========= DEPENDENCIES FOR BUILDING ==========
 
index a39883791a01b4178a01d9c7fb2d9fceca24ff22..87a7752f6f99a04444228008893a0713687ec986 100644 (file)
@@ -7,8 +7,8 @@
 overflowtext="***",overflowoffset=5
 leftadjust,compwidth=9
 Date:formatfield="%<(nodate{text})%{text}%|%(pretty{text})%>"
-From:decode
-To:decode
-Cc:decode
-Subject:decode
+From:formatfield="%(putstr(trim(decode{text})))"
+To:formatfield="%(putstr(trim(decode{text})))"
+Cc:formatfield="%(putstr(trim(decode{text})))"
+Subject:formatfield="%(putstr(trim(decode{text})))"
 :
index f5cc117ef956e1fef46bc926be9106913761d8ad..3d1fd717a822c1a8a536b0976a7ba263aa2e6167 100644 (file)
@@ -1,2 +1,2 @@
 %(lit)%(formataddr{addresses})\
-%<(nonnull)%(void(width))%(putaddr Resent-To: )\n%>
+%<(nonnull)%(void(width))%(void(decode))%(putaddr Resent-To: )\n%>
index 87532bac56d7fa80ed5d8ecaf5d04f3dc7c5c15e..523070078752b3ce44b27c383c965871be39c01e 100644 (file)
 %(formataddr{prev-resent-to})\
 %(formataddr{x-to})\
 %(formataddr{apparently-to})\
-%(void(width))%(putaddr To: )
+%(void(width))%(void(decode))%(putaddr To: )
 %(lit)%(formataddr{to})\
 %(formataddr{cc})\
 %(formataddr{x-cc})\
 %(formataddr{resent-cc})\
 %(formataddr{prev-resent-cc})\
 %(formataddr(me))\
-%(void(width))%(putaddr Cc: )
+%(void(width))%(void(decode))%(putaddr Cc: )
 Fcc: +sent
-Subject: %<{subject}Re: %(void{subject})%(trim)%(decode)%>
+Subject: %<{subject}Re: %(putstr(trim(decode{subject})))%>
 %;
 %; Make References: and In-reply-to: fields for threading.
-%; Use (void), (trim) and (putstr) to eat trailing whitespace.
+%; Use (trim) to eat trailing whitespace.
 %;
 %<{message-id}In-reply-to: %{message-id}\n%>\
 %<{message-id}References: \
-%<{references}%(void{references})%(trim)%(putstr) %>\
-%(void{message-id})%(trim)%(putstr)\n%>\
+%<{references}%(trim{references})%(putstr) %>\
+%(trim{message-id})%(putstr)\n%>\
 Comments: In-reply-to \
 %<{from}%(void{from})%?(void{apparently-from})%|%(void{sender})%>\
-%(trim)%(decode)\n\
+%(putstr(trim(decode)))\n\
    message dated "%<(nodate{date})%{date}%|%(tws{date})%>."
 --------
 [%4(year{date})-%02(mon{date})-%02(mday{date}) \
index ae55a7b884d216aeedb68caf02f5b4c3616ec4b3..09d6360627a922cfdc05aa9cfdc906101f0f0225 100644 (file)
 %;     personal address
 %;
 %(lit)%(formataddr{mail-followup-to})\
-%<(nonnull)%(void(width))%(putaddr To: )\n\
+%<(nonnull)%(void(width))%(void(decode))%(putaddr To: )\n\
 %|\
 %(lit)%(formataddr %<{mail-reply-to}%?{reply-to}%?{from}%?{sender}%?{return-path}%>)\
-%<(nonnull)%(void(width))%(putaddr To: )\n%>\
+%<(nonnull)%(void(width))%(void(decode))%(putaddr To: )\n%>\
 %(lit)%(formataddr{to})%(formataddr{cc})%(formataddr(me))\
-%<(nonnull)%(void(width))%(putaddr Cc: )\n%>%>\
+%<(nonnull)%(void(width))%(void(decode))%(putaddr Cc: )\n%>%>\
 %;
 Fcc: +sent
-Subject: %<{subject}Re: %(void{subject})%(trim)%(decode)%>
+Subject: %<{subject}Re: %(putstr(trim(decode{subject})))%>
 %;
 %; Make References: and In-reply-to: fields for threading.
-%; Use (void), (trim) and (putstr) to eat trailing whitespace.
+%; Use (trim) to eat trailing whitespace.
 %;
 %<{message-id}In-reply-to: %{message-id}\n%>\
 %<{message-id}References: \
-%<{references}%(void{references})%(trim)%(putstr) %>\
-%(void{message-id})%(trim)%(putstr)\n%>\
+%<{references}%(trim{references})%(putstr) %>\
+%(trim{message-id})%(putstr)\n%>\
 Comments: In-reply-to \
 %<{from}%(void{from})%?(void{apparently-from})%|%(void{sender})%>\
-%(trim)%(decode)\n\
+%(putstr(trim(decode)))\n\
    message dated "%<(nodate{date})%{date}%|%(tws{date})%>."
 --------
 [%4(year{date})-%02(mon{date})-%02(mday{date}) \
diff --git a/etc/scan.default b/etc/scan.default
new file mode 100644 (file)
index 0000000..40a0554
--- /dev/null
@@ -0,0 +1,9 @@
+%;
+%; default scan/inc listing format
+%;
+%4(msg)%<(cur)+%| %>%<{replied}-%| %>\
+%4(year{date})-%02(mon{date})-%02(mday{date}) \
+%02(hour{date}):%02(min{date})  \
+%<(mymbox{from})%<{to}To:%14(decode(friendly{to}))%>%>\
+%<(zero)%17(decode(friendly{from}))%>  \
+%(putstr(trim(decode{subject})))
index c809e3b2d4c6c4eb9b970758715e5b10d629a76d..9001148142c1049798c4439e4d1df5da553d9248 100644 (file)
@@ -19,4 +19,4 @@
 %(void(size))%4(divide 1024)\
 %<{mime-version} %|~%>\
  \
-%(decode{subject})
+%(putstr(trim(decode{subject})))
diff --git a/h/mh.h b/h/mh.h
index 8f6fad1d78ec61172ca555f68e283b3727f70769..e1795caa1b681466ada5b4f6af22ee41d6c2a0ae 100644 (file)
--- a/h/mh.h
+++ b/h/mh.h
@@ -291,6 +291,7 @@ extern char *psequence;
 extern char *rcvdistcomps;
 extern char *replcomps;
 extern char *replgroupcomps;
+extern char *scanformat;
 extern char *sendmail;
 extern char *seq_all;
 extern char *seq_beyond;
index 32ec0b5b0f411d7e3c6d2ba46b4b1b48837037f8..69556f94d64bc5ba94808c339c13a7feaa065eeb 100644 (file)
@@ -55,7 +55,6 @@ char **getans(char *, struct swit *);
 int getanswer(char *);
 char **getarguments(char *, int, char **, int);
 char *get_charset();
-char *getcpy(char *);
 char *getcurfol(void);
 char *getdeffol(void);
 int lkclose(int, char*);
index 91b2ff676749aa45e763abe39eb286fa9d5e260f..5e5816d94351b47c552eb42fd8deee443c3c2273 100644 (file)
@@ -10,15 +10,6 @@ extern char *scanl;
 #define SCNNUM  (-2)  /* number out of range                  */
 #define SCNFAT  (-3)  /* fatal error                          */
 
-/*
-** default format for `scan' and `inc'
-*/
-# define FORMAT \
-"=%4(msg)%<(cur)+%| %>%<{replied}-%| %>\
-%4(year{date})-%02(mon{date})-%02(mday{date}) %02(hour{date}):%02(min{date})  \
-%<(mymbox{from})%<{to}To:%14(decode(friendly{to}))%>%>\
-%<(zero)%17(decode(friendly{from}))%>  %(decode{subject})\n"
-
 #define WIDTH  78
 
 #define SCN_MBOX (-1)
index 6f74c325d036010b6e8a72c24e901ce22d0b20e5..c0d283515a5e866512609a0a258406e5a0a87c70 100644 (file)
--- a/h/utils.h
+++ b/h/utils.h
@@ -2,13 +2,14 @@
 ** utils.h -- utility prototypes
 */
 
-void *mh_xmalloc(size_t);
 void *mh_xrealloc(void *, size_t);
 void *mh_xcalloc(size_t, size_t);
+void mh_free0(void *);
 char *pwd(void);
 char *add(char *, char *);
 void create_folder(char *, int, void (*)(int));
 int num_digits(int);
+char *mh_xstrdup(char *);
 
 struct msgs_array {
        int max, size;
index c96770ce620c6a9dd5fad39e480f9a02f096710d..ad41a9220e6e3ff6a1885b7ea9f8265eb74228b6 100644 (file)
@@ -21,7 +21,7 @@ ap \- parse addresses 822-style
 is a program that parses addresses according to the ARPA
 Internet standard.  It also understands many non\-standard formats.
 It is useful for seeing how
-.B nmh
+.B mmh
 will interpret an address.
 .PP
 The
index b19c50b951c2006bc11df8c53db458d73360f451..caf695ea5668936a3b20d05c74086715969c1ee8 100644 (file)
@@ -22,7 +22,7 @@ It also understands many non\-standard formats,
 such as those produced by TOPS\-20 sites and some UNIX sites using
 .BR ctime (3).
 It is useful for seeing how
-.B nmh
+.B mmh
 will interpret a date.
 .PP
 The
index 6156c395fb0c55ac7eea447c3a4ffa59a64b2333..046c2de88cc620e6796887696b8bc26c2a431c67 100644 (file)
@@ -3,7 +3,7 @@
 .\"
 .TH FMTDUMP %manext8% "%nmhdate%" MH.6.8 [%nmhversion%]
 .SH NAME
-fmtdump \- decode nmh format files
+fmtdump \- decode mh format files
 .SH SYNOPSIS
 .HP 5
 .na
@@ -16,9 +16,9 @@ fmtdump \- decode nmh format files
 .SH DESCRIPTION
 .B Fmtdump
 is a program that parses an
-.B nmh
+.B mh
 format file and produces a pseudo-language listing of the how
-.B nmh
+.B mmh
 interprets the file.  This is useful when debugging a complicated format file.
 .PP
 The
index 704809d8cb461c9a3a75b220b87c5c3b4de2858f..be903be0475ae6003b4dca0cdb4c9b5690b42291 100644 (file)
@@ -31,7 +31,7 @@ is equivalent to
 .ad
 .SH DESCRIPTION
 Since the
-.B nmh
+.B mmh
 environment is the shell, it is easy to lose track
 of the current folder from day to day.  When
 .B folder
@@ -133,7 +133,7 @@ The `(others)' indicates that the folder
 .I ucom
 has files which
 aren't messages.  These files may either be sub\-folders, or files that
-don't belong under the nmh file naming scheme.
+don't belong under the mh file naming scheme.
 .PP
 The folder and message totals are output if either a
 .B \-all
index 8091c4234fde43c3f20aa092b39031184db7991b..220a7f023b867fecdc396b85b34d6e3649b39fb6 100644 (file)
@@ -138,7 +138,7 @@ and
 .B \-volume
 .I number
 switches implement a digest facility for
-.BR nmh .
+.BR mmh .
 Specifying these switches enables and/or overloads the following escapes:
 .PP
 .RS 5
index 73c0346c1cf1b4fadb9e981d58d1ad482fed1802..817c1bd8d0b9569132472fae10ca824990a11943 100644 (file)
@@ -28,7 +28,7 @@ inc \- incorporate new mail
 .B Inc
 incorporates mail from the user's incoming mail drop into
 an
-.B nmh
+.B mh
 folder.
 .PP
 You may specify which folder to use with
@@ -55,7 +55,7 @@ If the user's profile contains a
 entry, it
 will be used as the protection on the newly created messages, otherwise
 the
-.B nmh
+.B mmh
 default of 0644 will be used.  For all subsequent operations
 on these messages, this initially assigned protection will be preserved.
 .PP
@@ -93,7 +93,7 @@ will be in the current directory unless a full path is specified.
 .PP
 .B Inc
 will incorporate even improperly formatted messages into the
-user's nmh folder, inserting a blank line prior to the offending component
+user's mh folder, inserting a blank line prior to the offending component
 and printing a comment identifying the bad message.
 .PP
 In all cases, the user's mail drop will be zeroed, unless the
@@ -143,7 +143,7 @@ will consult the profile entry
 .RI ` MailDrop '
 for this information.  If the value found is
 not absolute, then it is interpreted relative to the user's
-.B nmh
+.B mh
 directory.  If the value is not found, then
 .B inc
 will look in the standard system location for the user's maildrop.
index dacf4ce27e82809146a5ac2ef6395ed0f194cde7..ba19506a495da073fb8cd30f58d240bd8099ce7a 100644 (file)
@@ -110,7 +110,7 @@ to force the new or modified sequences to be
 indicates
 that the sequences should be made `public'.  These sequences
 will then be readable by all
-.B nmh
+.B mmh
 users with permission to read the relevant folders.  In contrast, the
 .B \-nopublic
 switch indicates that the
index e05358a18a08320507783e653dad518c70945e83..610117b94ca1a0fd0cf39fa98823538b3be3d561 100644 (file)
@@ -3,10 +3,10 @@
 .\"
 .TH MH-ALIAS %manext5% "%nmhdate%" MH.6.8 [%nmhversion%]
 .SH NAME
-mh-alias \- alias file for nmh message system
+mh-alias \- alias file for mh message system
 .SH DESCRIPTION
 This describes
-.B nmh
+.B mh
 personal alias files.
 It does
 .B not
@@ -122,7 +122,7 @@ not usually output, rather the address\-group that the alias maps to is
 output instead.  If `alias' is terminated with a `;' instead of
 a `:', then both the `alias' and the address are output in the
 correct format.  (This makes replies possible since personal
-.B nmh
+.B mh
 aliases are unknown to the mail transport system.)
 .RE
 .PP
@@ -175,9 +175,9 @@ Finally, all aliases of the form
 `news.<anything>' are defined to be `news'.
 .PP
 The key thing to understand about aliasing in
-.B nmh
+.B mh
 is that aliases in
-.B nmh
+.B mh
 alias files are expanded into the headers of messages posted.
 This aliasing occurs first, at posting time, without the knowledge of the
 message transport system.  In contrast, once the message transport system
@@ -189,7 +189,7 @@ expanded into the headers of messages delivered.
 
 .SH "HELPFUL HINTS"
 To use aliasing in
-.B nmh
+.B mmh
 quickly, do the following:
 .PP
 .RS 2
index b721aa6abbc46797155626139dd6027f2fd05a22..65ae938850cc0b3e5a1783b2d7e18530371ac15a 100644 (file)
@@ -3,7 +3,7 @@
 .\"
 .TH MH-DRAFT %manext7% "%nmhdate%" MH.6.8 [%nmhversion%]
 .SH NAME
-mh-draft \- draft folder facility for nmh message system
+mh-draft \- draft folder facility for mh message system
 .SH DESCRIPTION
 There are a number of interesting advanced facilities for the composition of
 outgoing mail.
@@ -33,7 +33,7 @@ the user was composing is the current message in the draft folder.
 .PP
 The user can send off whatever drafts desired from the shell using the
 standard
-.B nmh
+.B mmh
 `msgs' convention to the
 .B send
 command..
@@ -76,7 +76,7 @@ Or, if more editing was required, the draft could be edited with
 .PP
 .RS 5
 .nf
-comp -use
+comp \-use
 .fi
 .RE
 .PP
@@ -92,7 +92,7 @@ to do the work:
 .PP
 .RS 5
 .nf
-comp -use `pick +drafts -to nmh-workers`
+comp \-use `pick +drafts \-to nmh-workers`
 .fi
 .RE
 .PP
@@ -100,7 +100,7 @@ or
 .PP
 .RS 5
 .nf
-send `pick +drafts -to nmh-workers`
+send `pick +drafts \-to nmh-workers`
 .fi
 .RE
 .PP
@@ -118,9 +118,9 @@ example, as many message drafts as desired can appear, since
 doesn't mind sending more than one draft at a time.
 .PP
 It is important to realize that
-.B nmh
+.B mmh
 treats the draft folder like a standard
-.B nmh
+.B mh
 folder in nearly all respects.  There is one exception:
 Although conceptually
 .B send
index e86e9ce61b3e8c17b738d298b062bd58b92861a4..ed0a2dc67bc5b4c874d718a408a0881f84001ebb 100644 (file)
@@ -3,10 +3,10 @@
 .\"
 .TH MH-FORMAT %manext5% "%nmhdate%" MH.6.8 [%nmhversion%]
 .SH NAME
-mh-format \- format file for nmh message system
+mh-format \- format file for mh message system
 .SH DESCRIPTION
 Several
-.B nmh
+.B mmh
 commands utilize either a
 .I format
 string or a
@@ -19,25 +19,21 @@ for each message;
 uses a format file which directs it
 how to generate the reply to a message, and so on.
 .PP
-There are a few alternate scan listing formats available
-in
-.IR nmh/etc/scan.time ,
-.IR nmh/etc/scan.size ,
+There are a few alternate scan listing formats available, e.g.
+.IR scan.nmh ,
+.IR scan.mailx ,
 and
-.IR nmh/etc/scan.timely .
+.IR scan.timely .
 Look in
-.I nmh/etc
+.I %etcdir%
 for other
 .B scan
 and
 .B repl
-format files which may have been written at your site.
+format files.
 .PP
-It suffices to have your local
-.B nmh
-expert actually write new format
-commands or modify existing ones.  This manual section explains how to
-do that.  Note: familiarity with the C
+This manual section explains how to write and modify format commands.
+Note: familiarity with the C
 .B printf
 routine is assumed.
 .PP
@@ -51,14 +47,20 @@ string, the usual C backslash characters are honored: `\\b', `\\f',
 .SS SYNTAX
 Format strings are built around
 .IR "escape sequences" .
-There are three types of escape sequences: header
-.IR components ,
-built-in
-.IR functions ,
-and flow
-.IR control .
-Comments may be inserted in most places where a function argument is
-not expected.  A comment begins with `%;' and ends with a (non-escaped)
+There are four types of escape sequences:
+.PP
+.RS 5
+.nf
+.ta +\w'name of escape class xxxxxxx'u
+.RI "1)  header components     %{" component }
+.RI "2)  built-in functions    %(" "function arg" )
+.RI "3)  flow control  %< ... %? ... %| ... %>
+.RI "4)  comments      %; ...
+.fi
+.RE
+.PP
+Comments may be inserted in most places where no function argument is
+expected.  A comment begins with `%;' and ends with a (non-escaped)
 newline.
 .PP
 A
@@ -91,7 +93,7 @@ the argument to a function escape can be another function, a component,
 or a control escape.  When the argument is a function or a
 component, they are listed without a leading `%'.  When control escapes
 are used as function arguments, they written as normally, with
-a leading `%';
+a leading `%'.
 
 .SS "Control escapes"
 .PP
@@ -110,7 +112,7 @@ These are combined into the conditional execution construct:
 .fi
 .RE
 .PP
-Extra white space is shown here only for clarity.  These
+(Extra white space is shown here only for clarity.)  These
 constructs may be nested without ambiguity.  They form a general
 .B if\-elseif\-else\-endif
 block where only one of the
@@ -131,7 +133,7 @@ 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.
@@ -213,6 +215,13 @@ or
 .I str
 is used as the argument: which register is
 used depends on the function, as listed below.
+.\"  What is the difference between these two lines:
+.\"      %(void{comp})%(trim)%(putstr)
+.\"      %(putstr(trim{comp}))
+.\"  The latter can be used as a single expression for %<.
+.\"  It does make a difference for (decode) because in the former
+.\"  way, wrapping (decode) with (void) can be necessary.
+.\"  What is the prefered way?
 .PP
 Component escapes write the value of their message header in
 .IR str .
@@ -280,7 +289,7 @@ compval     comp    integer Set \fInum\fR to `\fBatoi\fR(\fIcomp\fR\^)'
 .\" compflag   comp    integer Set \fInum\fR to component flags bits (internal)
 .\" decodecomp comp    string  Set \fIstr\fR to RFC-2047 decoded component text
 decode expr    string  decode \fIstr\fR as RFC-2047 (MIME-encoded)
-                       component
+                       component and print it
 unquote        expr    string  remove RFC-2822 quotes from \fIstr\fR
 trim   expr            trim trailing white-space from \fIstr\fR
 putstr expr            print \fIstr\fR
@@ -325,7 +334,7 @@ date2gmt    date            coerce date to GMT
 dst    date    integer daylight savings in effect? (0 or 1)
 clock  date    integer seconds since the UNIX epoch
 rclock date    integer seconds prior to current time
-tws    date    string  official 822 rendering
+tws    date    string  official RFC-822 rendering
 pretty date    string  user-friendly rendering
 .fi
 .RE
@@ -338,7 +347,7 @@ the first address present in the header component.
 .nf
 .ta \w'Fformataddr 'u +\w'Aboolean 'u +\w'Rboolean 'u
 .I "Function   Argument        Return  Description
-proper addr    string  official 822 rendering
+proper addr    string  official RFC-822 rendering
 friendly       addr    string  user-friendly rendering
 addr   addr    string  mbox@host or host!mbox rendering*
 pers   addr    string  the personal name*
@@ -383,16 +392,15 @@ size in a field six characters wide filled with leading zeros;
 component in fourteen characters with trailing spaces added as needed.
 For \fIputstrf\fR, using a negative value for the field width causes
 right-justification of the string within the field, with padding on
-the left up to the field width.
-The functions (\fIputnum\fR\^) and
-(\fIputstr\fR\^) are somewhat special: they print their result in the minimum number of characters
-required, and ignore any leading field width argument.
+the left up to the field width. The functions (\fIputnum\fR\^) and
+(\fIputstr\fR\^) are somewhat special: they print their result in
+the minimum number of characters required, and ignore any leading
+field width argument.
 .PP
 The available output width is kept in an internal register; any output
 past this width will be truncated.
 .SS Examples
-With all this in mind,
-here's the default format string for
+With all this in mind, here's a format string for
 .BR scan .
 It's been divided into several pieces for readability.
 The first part is:
@@ -481,7 +489,7 @@ if present.  If not present, the else-if clause is executed.
 .RE
 .PP
 This formats the
-`From:', `Sender:' and `Return-Path:'
+`From:', `Sender:' or `Return-Path:'
 headers, stopping as soon as one of them is present.  Next:
 .PP
 .RS 5
@@ -516,7 +524,7 @@ leading label of `Cc:'.
 .PP
 .RS 5
 .nf
-%<{subject}Subject: Re: %{subject}\\n%>\\
+%<{subject}Subject: Re: %(decode{subject})\\n%>\\
 .fi
 .RE
 .PP
@@ -545,17 +553,17 @@ Here's that part again in pseudo-code:
 .nf
 .ta .5i 1i 1.5i 2i
 if (comp_exists(message-id))  then
-       print (`In-reply-to: ')
-       print (message-id.value)
-       print (`\\n')
+       print("In-reply-to: ")
+       print(message-id.value)
+       print("\\n")
 endif
 if (comp_exists(message-id)) then
-       print (`References: ')
+       print("References: ")
        if (comp_exists(references)) then
              print(references.value);
        endif
-       print (message-id.value)
-       print (`\\n')
+       print(message-id.value)
+       print("\\n")
 endif
 .fi
 .RE
@@ -563,8 +571,8 @@ endif
 .\" (Note that this pseudocode begs the question ``why not just
 .\" support this syntax?''  MH has been hacked on for a long time...)
 .\".PP
-One more example: Currently,
-.B nmh
+One more example:
+.B Mmh
 supports very
 large message numbers, and it is not uncommon for a folder
 to have far more than 10000 messages.
@@ -573,12 +581,11 @@ to have far more than 10000 messages.
 .\" process 200 messages a day and still get some real work
 .\" done."  The authors apparently only planned to get
 .\" real work done for about 50 days per folder.)
-Nontheless (as noted above)
-the various scan format strings are inherited
+Nonetheless several scan format strings are inherited
 from older MH versions, and are generally hard-coded to 4
 digits of message number before formatting problems
 start to occur.
-The nmh format strings can be modified to behave more sensibly with larger
+The mh format strings can be modified to behave more sensibly with larger
 message numbers:
 .PP
 .RS
index 9b3334dab8cdc7c20735a760a54ec4446dc17059..9d06dfcd08670c853ccaebd651f77a5d3b6b4672 100644 (file)
@@ -3,15 +3,15 @@
 .\"
 .TH MH-MAIL %manext5% "%nmhdate%" MH.6.8 [%nmhversion%]
 .SH NAME
-mh-mail \- message format for nmh message system
+mh-mail \- message format for mh message system
 .SH DESCRIPTION
-.B nmh
+.B mmh
 processes messages in a particular format.  It should be noted
 that although neither Bell nor Berkeley mailers produce message files
 in the format that
-.B nmh
+.B mmh
 prefers,
-.B nmh
+.B mmh
 can read message files in that antiquated format.
 .PP
 Each user possesses a system maildrop box which initially receives all
@@ -33,7 +33,7 @@ part of a message is called the header, and the free-format portion is
 called the body.  The header must always exist, but the body is optional.
 These parts are separated by an empty line, i.e., two consecutive newline
 characters.  Within
-.B nmh ,
+.B mmh ,
 the header and body may be separated by a line consisting of dashes:
 .PP
 .RS 5
index dd051b78d194a65e67db2d930640583221614e59..cd8e2401215d7ef0a90eba67dea2a45efd63ef75 100644 (file)
@@ -391,7 +391,7 @@ signature text.  (profile, no default)
 
 .SS "Process Profile Entries"
 The following profile elements are used whenever an
-.B nmh
+.B mmh
 program invokes some other program such as
 .BR more .
 The profile can be used to select alternate programs if the
index 4e4b4438d843e42f6d577b1d71d71c85e01fa046..0ad2c4a4e73ba4e0c4326035d53720b00d95a4d0 100644 (file)
@@ -3,18 +3,18 @@
 .\"
 .TH MH-SEQUENCE %manext7% "%nmhdate%" MH.6.8 [%nmhversion%]
 .SH NAME
-mh-sequence \- sequence specification for nmh message system
+mh-sequence \- sequence specification for mh message system
 .SH DESCRIPTION
 A sequence (or sequence set) is a symbolic name representing a
 message or collection of messages.
-.B nmh
+.B mmh
 has several internally
 defined sequences, as well as allowing users to define their own
 sequences.
 
 .SS "Message Specification and Pre\-Defined Message Sequences"
 Most
-.B nmh
+.B mmh
 commands accept a `msg' or `msgs' specification, where
 `msg' indicates one message and `msgs' indicates one or more messages.
 To designate a message, you may use either its number (e.g., 1, 10, 234)
@@ -93,10 +93,10 @@ b   the next message number beyond `l'
 .SS "User\-Defined Message Sequences"
 In addition to the `reserved' (pre-defined) message names given
 above,
-.B nmh
+.B mmh
 supports user-defined sequence names.  User-defined
 sequences allow the
-.B nmh
+.B mmh
 user a tremendous amount of power in dealing
 with groups of messages in the same folder by allowing the user to bind
 a group of messages to a meaningful symbolic name.
@@ -105,7 +105,7 @@ The name used to denote a message sequence must consist of an alphabetic
 character followed by zero or more alphanumeric characters, and can not
 be one of the `reserved' message names above.  After defining a
 sequence, it can be used wherever an
-.B nmh
+.B mmh
 command expects a `msg' or
 `msgs' argument.
 .PP
@@ -133,17 +133,17 @@ commands.
 .SS "Public and Private User-Defined Sequences"
 There are two varieties of user-defined sequences:
 public and private.  Public sequences of a folder are accessible to any
-.B nmh
+.B mmh
 user that can read that folder.  They are kept in each folder
 in the file determined by the `Mh\-Sequences' profile entry
 (default is
 .IR \&.mh_sequences ).
 Private sequences are accessible
 only to the
-.B nmh
+.B mmh
 user that defined those sequences and are kept in
 the user's
-.B nmh
+.B mh
 context file.
 .PP
 In general, the commands that create sequences (such as
@@ -152,7 +152,7 @@ and
 .BR mark )
 will create public sequences if the folder for which
 the sequences are being defined is writable by the
-.B nmh
+.B mmh
 user.
 For most commands, this can be overridden by using the switches
 .B \-public
@@ -163,7 +163,7 @@ the `Mh\-Sequences' profile entry is defined but empty, then
 \fIprivate\fR sequences will be created instead.
 
 .SS "Sequence Negation"
-.B Nmh
+.B Mmh
 provides the ability to select all messages
 .B not
 elements of a user-defined sequence.
@@ -173,7 +173,7 @@ messages not elements of the specified sequence name.
 The default negation prefix is the exlamation mark `!',
 but it may be change to any string, by defining the entry
 `Sequence\-Negation' in the
-.B nmh
+.B mmh
 profile file.
 For example, if the profile entry is:
 .PP
@@ -182,7 +182,7 @@ Sequence\-Negation: not
 .RE
 .PP
 then anytime an
-.B nmh
+.B mmh
 command is given `notfoo' as a `msg' or
 `msgs' argument, it would substitute all messages that are not elements
 of the sequence `foo'.
@@ -198,17 +198,17 @@ To deactivate the negation mechanism, define Sequence\-Negation in your
 profile to an empty value.
 
 .SS "The Previous Sequence"
-.B Nmh
+.B Mmh
 provides the ability to remember the `msgs' or `msg' argument
 last given to an
-.B nmh
+.B mmh
 command.  The entry `Previous\-Sequence'
 should be defined in the
-.B nmh
+.B mmh
 profile; its value should be a sequence
 name or multiple sequence names separated by spaces.  If this entry
 is defined, when an
-.B nmh
+.B mmh
 command finishes, it will define the
 sequence(s) named in the value of this entry to be those messages that
 were specified to the command.  Hence, a profile entry of
@@ -218,7 +218,7 @@ Previous\-Sequence: pseq
 .RE
 .PP
 directs any
-.B nmh
+.B mmh
 command that accepts a `msg' or `msgs' argument to
 define the sequence `pseq' as those messages when it finishes.
 .PP
@@ -226,7 +226,7 @@ define the sequence `pseq' as those messages when it finishes.
 there can be a performance penalty in using the
 `Previous\-Sequence' facility.  If it is used,
 .B all
-.B nmh
+.B mmh
 programs have to write the sequence information to the
 .I \&.mh_sequences
 file for the folder each time they run.  If the
index 98fb39daa7e6dbb080b0d53ef272e60e7a1208de..304cbf29db9e4dfcda52c67a729d6feed3c11966 100644 (file)
@@ -104,7 +104,7 @@ For example,
 .PP
 .RS 5
 .nf
-#audio/basic |raw2audio -F < /usr/lib/sound/giggle.au
+#audio/basic |raw2audio \-F < /usr/lib/sound/giggle.au
 .fi
 .RE
 .PP
@@ -159,7 +159,7 @@ will complain.
 An example entry might be:
 .PP
 .RS 5
-mhbuild-compose-audio/basic: record | raw2audio -F
+mhbuild-compose-audio/basic: record | raw2audio \-F
 .RE
 .PP
 Because commands like these will vary, depending on the display
@@ -341,7 +341,7 @@ The second part will be text/enriched
 #
 This third part will be text/plain
 #audio/basic [silly giggle]  \\
-    |raw2audio -F < /usr/lib/sounds/giggle.au
+    |raw2audio \-F < /usr/lib/sounds/giggle.au
 #image/gif   [photo of foobar] \\
                     /home/foobar/lib/picture.gif
 .fi
index 37577f8c134c7bb34e16f9ec671748e32a30520e..a80d6bf02afa12cd72ea8e076b3788d723949d9f 100644 (file)
@@ -3,7 +3,7 @@
 .\"
 .TH MHL %manext1% "%nmhdate%" MH.6.8 [%nmhversion%]
 .SH NAME
-mhl \- produce formatted listings of nmh messages
+mhl \- produce formatted listings of mh messages
 .SH SYNOPSIS
 .HP 5
 .na
@@ -20,10 +20,10 @@ mhl \- produce formatted listings of nmh messages
 .SH DESCRIPTION
 .B Mhl
 is an
-.B nmh
+.B mmh
 command for filtering and/or displaying text
 messages.  It is the default method of displaying text messages for
-.B nmh
+.B mmh
 (it is the default
 .IR showproc ).
 .PP
@@ -218,7 +218,7 @@ appropriate formatfield variable string.
 .ta \w'%etcdir%/ExtraBigFileName  'u
 ^%etcdir%/mhl.format~^The message template
 ^or $HOME/.mmh/mhl.format~^Rather than the standard template
-^$HOME/.mh/profile~^The user profile
+^$HOME/.mmh/profile~^The user profile
 .fi
 
 .SH "PROFILE COMPONENTS"
index 80bdccad0d2602b14bad8b78e9f66e1da40d07ba..90f46cc82b17fb2cb46c31b5d7a1376b29f42b0e 100644 (file)
@@ -57,12 +57,12 @@ will
 accept the source message on the standard input.  Note that the
 file, or input from standard input should be a validly formatted
 message, just like any other
-.B nmh
+.B mh
 message.  It should
 .B NOT
 be in mail drop format (to convert a file in mail drop format to
 a folder of
-.B nmh
+.B mh
 messages, see
 .BR inc (1)).
 .PP
index acecbbc85568fccb195e57e3117a8469a58b1e18..423ddd642f3d0dd28abfa0d94e1d0e3febf63c0b 100644 (file)
@@ -118,12 +118,12 @@ mail program
 or
 .BR mailx ),
 which is compatible with
-.BR nmh .
+.BR mmh .
 This program was intended for the use of programs such as
 .BR cron ,
 which expect to send mail automatically to various
 addresses.  It was also used by various
-.B nmh
+.B mmh
 commands to mail various error notifications.
 .PP
 When invoked without arguments, it had once simply invoked
index 11a1346f799968bef90f8d228b810bdc39b9b4e4..9cd39fbb87fb37a794d534732ab9bcdadc450756 100644 (file)
@@ -3,7 +3,7 @@
 .\"
 .TH MHPARAM %manext1% "%nmhdate%" MH.6.8 [%nmhversion%]
 .SH NAME
-mhparam \- print nmh profile and context components
+mhparam \- print mmh profile and context components
 .SH SYNOPSIS
 .HP 5
 .na
index d5d3327d8aa814a5d1049ba150368f550c78205c..17295650c24cbeb05a778399cc504dd13b6b9523 100644 (file)
@@ -3,7 +3,7 @@
 .\"
 .TH MHPATH %manext1% "%nmhdate%" MH.6.8 [%nmhversion%]
 .SH NAME
-mhpath \- print full pathnames of nmh messages and folders
+mhpath \- print full pathnames of mh messages and folders
 .SH SYNOPSIS
 .HP 5
 .na
@@ -24,7 +24,7 @@ instead.  If the only argument is `+', your mail storage location
 (`Path') is output; this can be useful in shell scripts.
 .PP
 Contrasted with other
-.B nmh
+.B mmh
 commands, a message argument to
 .B mhpath
 may often be intended for writing.  Because of this:
@@ -141,7 +141,7 @@ None
 
 .SH BUGS
 Like all
-.B nmh
+.B mmh
 commands,
 .B mhpath
 expands and sorts
index e4fdfdce64d5411d98bb3553f69ebb60fcb1d616..4a821bf97432710bbe6cc4a960ebdbb57662b70d 100644 (file)
@@ -59,12 +59,12 @@ will
 accept the source message on the standard input.  Note that the
 file, or input from standard input should be a validly formatted
 message, just like any other
-.B nmh
+.B mh
 message.  It should
 .B NOT
 be in mail drop format (to convert a file in mail drop format to
 a folder of
-.B nmh
+.B mh
 messages, see
 .BR inc (1)).
 .PP
@@ -232,7 +232,7 @@ Example profile entries might be:
 mhstore-store-text: %m%P.txt
 mhstore-store-text: +inbox
 mhstore-store-message/partial: +
-mhstore-store-audio/basic: | raw2audio -e ulaw -s 8000 -c 1 > %m%P.au
+mhstore-store-audio/basic: | raw2audio \-e ulaw \-s 8000 \-c 1 > %m%P.au
 mhstore-store-image/jpeg: %m%P.jpg
 mhstore-store-application/PostScript: %m%P.ps
 .fi
@@ -311,7 +311,7 @@ user profile, e.g.,
 .RE
 .PP
 which is created automatically during
-.B nmh
+.B mmh
 installation.
 
 .SH FILES
index c07204a5e0c2244a9d51bb396772e65bfe80d154..337c9a90508c84ff54e3bcc83c80a3b17621bcfc 100644 (file)
@@ -3,7 +3,7 @@
 .\"
 .TH PACKF %manext1% "%nmhdate%" MH.6.8 [%nmhversion%]
 .SH NAME
-packf \- pack messages in nmh folder into a single mbox file
+packf \- pack messages in mh folder into a single mbox file
 .SH SYNOPSIS
 .HP 5
 .na
index 42971fec485af8d515fd47295f89c0998a095429..6f5a0ce15a8b4ddc52527808b272df00749f67f4 100644 (file)
@@ -231,7 +231,7 @@ output separated by newlines.  This is
 .B extremely
 useful for
 quickly generating arguments for other
-.B nmh
+.B mmh
 programs by using the
 `backquoting' syntax of the shell.  For example, the command
 .PP
@@ -402,7 +402,7 @@ no output, and the argument given to the outer command as a result of
 backquoting
 .B pick
 is empty.  In the case of
-.B nmh
+.B mmh
 programs,
 the outer command now acts as if the default `msg' or `msgs' should be
 used (e.g., `all' in the case of
index 4d701c6ede7fd011ae3ad7180ec120397d9cbbb5..e4738dbe6e623cc5689009e6fd1d7a19cd6b68d6 100644 (file)
@@ -184,11 +184,11 @@ The user may wish to link
 .B prompter
 under several names (e.g.,
 `rapid') and give appropriate switches in the profile entries
-under these names (e.g., `rapid: -rapid').  This facilitates
+under these names (e.g., `rapid: \-rapid').  This facilitates
 invoking prompter differently for different
 .B mmh
 commands (e.g.,
-`forw: -editor rapid').
+`forw: \-editor rapid').
 .PP
 Former
 .B mutt
index c9c64b9971b476ddef20bfc8875456dec3156dff..5cae3e392666515a2564d5fe8653c0ad4451562f 100644 (file)
@@ -22,7 +22,7 @@ rcvstore \- asynchronously incorporate mail into a folder
 .SH DESCRIPTION
 .B Rcvstore
 incorporates a message from the standard input into an
-.B nmh
+.B mh
 folder.  This command is typically used in conjunction with
 mail filtering programs such as
 .B slocal
@@ -54,14 +54,14 @@ the next highest number for that folder.
 .B Rcvstore
 will incorporate anything except zero length messages
 into the user's
-.B nmh
+.B mh
 folder.  It will not change the message in any
 way.
 .PP
 If the user's profile contains a `Msg\-Protect: nnn' entry, it
 will be used as the protection on the newly created message, otherwise
 the
-.B nmh
+.B mmh
 default of 0644 will be used.  For all subsequent operations
 on this message, this initially assigned protection will be preserved.
 .PP
@@ -135,7 +135,7 @@ sequence manipulation.
 If you use the `Unseen\-Sequence' profile entry,
 .B rcvstore
 could try to update the context while another
-.B nmh
+.B mmh
 process
 is also trying to do so.  This can cause the context to become
 corrupted.  To avoid this, do not use
index 47f825bebf35d3c0bb3b6e95bf7ad346a2b8394a..b19b1c0e2db72b0540ff9d4313c812c4712743ad 100644 (file)
@@ -60,12 +60,12 @@ to use the specified file
 as the source message to be filed, rather than a message from a folder.
 Note that the file should be a validly formatted message, just like
 any other
-.B nmh
+.B mh
 message.  It should
 .B NOT
 be in mail drop format
 (to convert a file in mail drop format to a folder of
-.B nmh
+.B mh
 messages,
 see
 .BR inc (1)).
@@ -119,17 +119,13 @@ folder(1), rmf(1), rmm(1)
 
 .SH DEFAULTS
 .nf
-.RB ` "\-src\ +folder" "' defaults to the current folder"
+.RB ` "\-src\ \fI+folder\fP" "' defaults to the current folder"
 .RB ` msgs "' defaults to the current message"
 .RB ` \-nolink '
 .fi
 
 .SH CONTEXT
 If
-.B \-src
-.I +folder
-is given, it will become the current folder.
-If
 .B \-link
 is specified, the current message in the
 source folder will be set to the last message specified; otherwise, the
@@ -142,3 +138,11 @@ will also define
 those sequences for the destination folders.  See
 .B mh\-sequence (7)
 for information concerning the previous sequence.
+
+.SH HISTORY
+Since mmh-0.3,
+.B refile
+does never change the current folder.
+(It used to change it when
+.BI \-src\  +folder
+was given, but this behavior had usability disadvantages.)
index 698d9c824f8f76bad5f1db0f0cc54d39e717e2af..7cc41106a055af2e47a6ccc9fe71e0a59a2461a6 100644 (file)
@@ -256,7 +256,7 @@ the `>' character.
 If the switch
 .B \-nofilter
 is given, then the message
-to which you are replying will not be formated and thus not included in
+to which you are replying will not be formatted and thus not included in
 the body of the draft.
 (It may be added as MIME attachment with
 .B \-mime
@@ -329,7 +329,7 @@ to be created, containing the draft message that would normally be presented
 to the user for editing.
 No
 .B whatnow
-programm is invoked.
+program is invoked.
 No mail is actually sent.
 .PP
 The
@@ -337,7 +337,7 @@ The
 .I msgfile
 switch specifies the message to be replied to as an
 exact filename rather than as an
-.B nmh
+.B mh
 folder and message number. It is
 intended to be used by the
 .B msh
@@ -353,7 +353,7 @@ switch.
 .ta \w'%etcdir%/ExtraBigFileName  'u
 ^%etcdir%/replcomps~^The standard reply template
 ^or $HOME/.mmh/replcomps~^Rather than the standard template
-^%etcdir%/replgroupcomps~^The standard `reply -group' template
+^%etcdir%/replgroupcomps~^The standard `reply \-group' template
 ^or $HOME/.mmh/replgroupcomps~^Rather than the standard template
 ^%etcdir%/mhl.reply~^The standard message filter
 ^or $HOME/.mmh/mhl.reply~^Rather than the standard filter
index 7dccb69f4a3105c780dd1d7dd33993dc4d40c620..d2f50f761a3d21cbdde0662b0d02900be4be2bb1 100644 (file)
@@ -3,7 +3,7 @@
 .\"
 .TH RMF %manext1% "%nmhdate%" MH.6.8 [%nmhversion%]
 .SH NAME
-rmf \- remove an nmh folder
+rmf \- remove an mh folder
 .SH SYNOPSIS
 .HP 5
 .na
@@ -19,7 +19,7 @@ removes all of the messages (files) within the specified
 (or default) folder, and then removes the folder (directory) itself.
 .PP
 If there are any files within the folder which are not a part of
-.BR nmh ,
+.BR mmh ,
 they will
 .B not
 be removed, and an error will be produced.
index 997ade202b3f65eced4ec37619acc7276d439462..2a25d18c1e2c85c4d077a29e4972899350244a0d 100644 (file)
@@ -34,7 +34,7 @@ For example:
 15+    10/\|05 crocker nned
 16\-   10/\|05 crocker message id format
 18     10/\|06 brien   Re: Exit status from mkdir
-19     10/\|07*brien   `scan' listing format in nmh
+19     10/\|07*brien   `scan' listing format in mmh
 .fi
 .RE
 .PP
index d4f90d1675c784cd5af9ea7ce580299175dc2c74..94bd33c0fdaba21715bd78fc034992ae6667b4cd 100644 (file)
@@ -94,12 +94,12 @@ this file as `-', then
 will accept the source message
 on the standard input.  Note that the file, or input from standard input
 should be a validly formatted message, just like any other
-.B nmh
+.B mh
 message.  It should
 .B NOT
 be in mail drop format (to convert a file in
 mail drop format to a folder of
-.B nmh
+.B mh
 messages, see
 .BR inc (1)).
 .PP
@@ -187,7 +187,7 @@ the file end in a specific suffix.  For example, the
 command (part of the StarOffice package) can be used to display
 Microsoft Word content, but it uses the suffix to determine how to display
 the file.  If no suffix is present, the file is not correctly loaded.
-Similarily, older versions of the
+Similarly, older versions of the
 .B gs
 command append a `.ps' suffix to
 the filename if one was missing.  As a result, these cannot be used to read
@@ -279,7 +279,7 @@ has the following default values:
 .PP
 .RS 5
 .nf
-mhshow-show-text/plain: %liconv -f <source-charset>
+mhshow-show-text/plain: %liconv \-f <source-charset>
 mhshow-show-message/rfc822: %lshow \-file %F
 .fi
 .RE
@@ -302,7 +302,7 @@ Example entries might be:
 .nf
 mhshow-show-audio/basic: raw2audio 2>/dev/null | play
 mhshow-show-image: xv %f
-mhshow-show-application/PostScript: lpr -Pps
+mhshow-show-application/PostScript: lpr \-Pps
 .fi
 .RE
 .PP
@@ -335,7 +335,7 @@ the default display method converts the content automatically by
 piping it through:
 .PP
 .RS 5
-iconv -f '<source-charset>'
+iconv \-f '<source-charset>'
 .RE
 .PP
 Note that if you have a custom `mhshow-show-*' display string, you
@@ -392,7 +392,7 @@ e.g.,
 .RE
 .PP
 which is created automatically during
-.B nmh
+.B mmh
 installation.
 
 .SH FILES
@@ -451,7 +451,7 @@ your link will act like
 .B show
 instead.  To circumvent this, add a
 profile\-entry for the link to your
-.B nmh
+.B mmh
 profile and add the argument
 .I n
 or
index f6c78d451962b949c229a15f320bcb5775ebf823..8779c0c077112c2762220778e8c46a6f3b9c8edf 100644 (file)
@@ -187,7 +187,7 @@ This action always succeeds.
 Append the message to the mbox file named by
 .IR string .
 This is handled by piping the message to the
-.B nmh
+.B mmh
 program
 .BR rcvpack .
 If
@@ -230,11 +230,11 @@ which your shell might interpret.
 .TP 4
 .IR folder " or " +
 Store the message in the
-.B nmh
+.B mh
 folder named by
 .IR string .
 This is handled by piping the message to the
-.B nmh
+.B mmh
 program
 .BR rcvstore .
 If
@@ -294,7 +294,7 @@ To summarize, here's an example delivery file:
 .nf
 .ta \w'default  'u +\w'mh-workersxx 'uC +\w'destroy 'uC +\w'result 'u
 #
-# .maildelivery file for nmh's slocal
+# .maildelivery file for mmh's slocal
 #
 # Blank lines and lines beginning with a '#' are ignored
 #
index 72ee22d0745105dae30f94c6b5bd91ae258227f6..29a067d630f40bb4a5187580f388343ea4a5a411 100644 (file)
@@ -78,7 +78,7 @@ the sort is instead made textfield\-major, date\-minor.
 For example, to order a folder by date-major, subject-minor, use:
 .PP
 .RS 5
-sortm -textfield subject +folder
+sortm \-textfield subject +folder
 .RE
 
 .SH FILES
index e13fbfd3aabad97d36cfe4d97606216f8ecb26a0..d0fea84e63591d45ca524ec7d5bca2f95ede3ce6 100644 (file)
@@ -21,7 +21,7 @@ whatnow \- prompting front-end for sending messages
 is the default program that queries the user about
 the disposition of a composed draft.  It is normally automatically
 invoked by one of the
-.B nmh
+.B mmh
 commands
 .BR comp ,
 .BR dist ,
@@ -111,7 +111,7 @@ See
 .BR mh\-profile (5)
 for further information about how editors
 are used by
-.BR nmh .
+.BR mmh .
 It also discusses how environment variables can be
 used to direct
 .BR whatnow 's
index 4064d4e3fea7d0b8b83ecafc55c4d9b5d5ffb289..f60bd9aa4245113c31ff8479cc1ccf85c911f577 100644 (file)
@@ -54,7 +54,7 @@ SRCS = addrsbr.c ambigsw.c brkstring.c  \
        error.c execprog.c ext_hook.c folder_addmsg.c folder_delmsgs.c  \
        folder_free.c folder_read.c  \
        folder_realloc.c gans.c getans.c getanswer.c  \
-       getarguments.c getcpy.c \
+       getarguments.c \
        fmt_addr.c fmt_compile.c fmt_new.c fmt_rfc2047.c  \
        fmt_scan.c lock_file.c m_atoi.c \
        m_convert.c m_draft.c m_getfld2.c m_gmprot.c  \
index 96fa72f02a53ab74dbd612877300c2cfb55714c0..db5b42e67d33d35f2618c4c571e79f28bfc8410a 100644 (file)
@@ -104,7 +104,7 @@ getm(char *str, char *dfhost, int dftype, int wanthost, char *eresult)
                dftype = LOCALHOST;
        }
 
-       mp = (struct mailname *) mh_xcalloc((size_t) 1, sizeof(*mp));
+       mp = mh_xcalloc(1, sizeof(*mp));
        if (mp == NULL) {
                if (eresult)
                        strcpy(eresult, "insufficient memory to represent address");
@@ -114,31 +114,31 @@ getm(char *str, char *dfhost, int dftype, int wanthost, char *eresult)
        }
 
        mp->m_next = NULL;
-       mp->m_text = getcpy(str);
+       mp->m_text = mh_xstrdup(str);
        if (pers)
-               mp->m_pers = getcpy(pers);
+               mp->m_pers = mh_xstrdup(pers);
 
        if (mbox == NULL) {
                mp->m_type = BADHOST;
                mp->m_nohost = 1;
                mp->m_ingrp = ingrp;
-               mp->m_gname = getcpy(grp);
+               mp->m_gname = mh_xstrdup(grp);
                if (note)
-                       mp->m_note = getcpy(note);
+                       mp->m_note = mh_xstrdup(note);
                return mp;
        }
 
        if (host) {
-               mp->m_mbox = getcpy(mbox);
-               mp->m_host = getcpy(host);
+               mp->m_mbox = mh_xstrdup(mbox);
+               mp->m_host = mh_xstrdup(host);
        } else {
                mp->m_nohost = 1;
-               mp->m_mbox = getcpy(mbox);
+               mp->m_mbox = mh_xstrdup(mbox);
                if (route == NULL && dftype == LOCALHOST) {
                        mp->m_host = NULL;
                        mp->m_type = dftype;
                } else {
-                       mp->m_host = route ? NULL : getcpy(dfhost);
+                       mp->m_host = route ? NULL : mh_xstrdup(dfhost);
                        mp->m_type = route ? NETHOST : dftype;
                }
                goto got_host;
@@ -152,12 +152,12 @@ getm(char *str, char *dfhost, int dftype, int wanthost, char *eresult)
 
 got_host: ;
        if (route)
-               mp->m_path = getcpy(route);
+               mp->m_path = mh_xstrdup(route);
        mp->m_ingrp = ingrp;
        if (grp)
-               mp->m_gname = getcpy(grp);
+               mp->m_gname = mh_xstrdup(grp);
        if (note)
-               mp->m_note = getcpy(note);
+               mp->m_note = mh_xstrdup(note);
 
        return mp;
 }
@@ -170,21 +170,21 @@ mnfree(struct mailname *mp)
                return;
 
        if (mp->m_text)
-               free(mp->m_text);
+               mh_free0(&(mp->m_text));
        if (mp->m_pers)
-               free(mp->m_pers);
+               mh_free0(&(mp->m_pers));
        if (mp->m_mbox)
-               free(mp->m_mbox);
+               mh_free0(&(mp->m_mbox));
        if (mp->m_host)
-               free(mp->m_host);
+               mh_free0(&(mp->m_host));
        if (mp->m_path)
-               free(mp->m_path);
+               mh_free0(&(mp->m_path));
        if (mp->m_gname)
-               free(mp->m_gname);
+               mh_free0(&(mp->m_gname));
        if (mp->m_note)
-               free(mp->m_note);
+               mh_free0(&(mp->m_note));
 
-       free((char *) mp);
+       mh_free0(&mp);
 }
 
 
@@ -436,7 +436,7 @@ error:
        while (first->m_next != NULL && first->m_next != next) {
                mp = first->m_next;
                first->m_next = mp->m_next;
-               free(mp);
+               mh_free0(&mp);
        }
        first->m_next = next;
        return -1;
index 205c8c9e9df7b247cdc38608b79ed4b90cf605aa..a9446fef299512d5409b596b09a7ae1540bb3c19 100644 (file)
@@ -30,7 +30,7 @@ brkstring(char *str, char *brksep, char *brkterm)
        /* allocate initial space for pointers on first call */
        if (!broken) {
                len = NUMBROKEN;
-               broken = (char **)mh_xmalloc((size_t)(len * sizeof(*broken)));
+               broken = mh_xcalloc(len, sizeof(*broken));
        }
 
        /*
@@ -42,8 +42,7 @@ brkstring(char *str, char *brksep, char *brkterm)
                /* enlarge pointer array, if necessary */
                if (i >= len) {
                        len += NUMBROKEN;
-                       broken = mh_xrealloc(broken,
-                                       (size_t)(len * sizeof(*broken)));
+                       broken = mh_xrealloc(broken, len * sizeof(*broken));
                }
 
                /* handle separators */
index 4a57656f149afb583324c978d09e942f31c9ace0..9efe73180d894870b7e14e606b1950a0f7da0c39 100644 (file)
@@ -36,7 +36,7 @@ concat(char *s1, ...)
                len += strlen(cp);
        va_end(list);
 
-       dp = sp = mh_xmalloc(len);
+       dp = sp = mh_xcalloc(len, sizeof(char));
 
        sp = copy(s1, sp);
 
index 7d068b5c0331ec16caf4da53b612fb924b729db1..96610506167041cdc2fd11d1ecf8bf75545df3c3 100644 (file)
@@ -7,6 +7,7 @@
 */
 
 #include <h/mh.h>
+#include <h/utils.h>
 
 /*
 ** Delete a key/value pair from the context/profile list.
@@ -26,10 +27,10 @@ context_del(char *key)
                                pp->n_next = np->n_next;
                        else
                                m_defs = np->n_next;
-                       free(np->n_name);
+                       mh_free0(&(np->n_name));
                        if (np->n_field)
-                               free(np->n_field);
-                       free((char *) np);
+                               mh_free0(&(np->n_field));
+                       mh_free0(&np);
                        ctxflags |= CTXMOD;
                        return 0;
                }
index 5b7c7775ef3b41e36ef0f19653937527a7c45c33..cfdcff275c11192a2c753a68084452557d9fb8a9 100644 (file)
@@ -25,6 +25,7 @@
 */
 
 #include <h/mh.h>    /* mh internals */
+#include <h/utils.h>
 #include <errno.h>   /* system call errors */
 #include <pwd.h>     /* structure for getpwuid() results */
 #include <unistd.h>
@@ -64,7 +65,7 @@ context_read(void)
        ** set mmhpath
        */
        if ((cp = getenv("MMH")) && *cp) {
-               mmhpath = getcpy(expanddir(cp));  /* rel to cwd */
+               mmhpath = mh_xstrdup(expanddir(cp));  /* rel to cwd */
                if (stat(mmhpath, &st) != -1 && (st.st_mode & S_IFDIR) == 0) {
                        adios(EX_CONFIG, NULL, "`%s' specified by your MMH environment variable is not a directory", cp);
                }
@@ -82,7 +83,7 @@ context_read(void)
        */
        if ((cp = getenv("MMHP")) && *cp) {
                if (*cp == '/') {
-                       defpath = getcpy(cp);
+                       defpath = mh_xstrdup(cp);
                } else {
                        defpath = concat(mmhpath, "/", cp, NULL);
                }
@@ -126,7 +127,7 @@ context_read(void)
                if (!getanswer(cp)) {
                        adios(EX_NOPERM, NULL, "Unable to access the mail storage directory `%s'", nd);
                }
-               free(cp);
+               mh_free0(&cp);
                if (!makedir(nd)) {
                        adios(EX_CANTCREAT, nd, "unable to create");
                }
@@ -168,7 +169,7 @@ context_read(void)
        }
 
        if (*cp == '/') {
-               ctxpath = getcpy(cp);
+               ctxpath = mh_xstrdup(cp);
        } else {
                ctxpath = concat(mmhpath, "/", cp, NULL);
        }
index dd6e63149d4d647b63a2e5734853a34b178c55ba..bfa3daf8b4160baecdf7dcdf3105603a26dd2aef 100644 (file)
@@ -19,11 +19,11 @@ context_replace(char *key, char *value)
        ** If list is emtpy, allocate head of profile/context list.
        */
        if (!m_defs) {
-               m_defs = (struct node *) mh_xmalloc(sizeof(*np));
+               m_defs = mh_xcalloc(1, sizeof(*np));
 
                np = m_defs;
-               np->n_name = getcpy(key);
-               np->n_field = getcpy(value);
+               np->n_name = mh_xstrdup(key);
+               np->n_field = mh_xstrdup(value);
                np->n_context = 1;
                np->n_next = NULL;
                ctxflags |= CTXMOD;
@@ -40,8 +40,8 @@ context_replace(char *key, char *value)
                                if (!np->n_context)
                                        admonish(NULL, "bug: context_replace(key=\"%s\",value=\"%s\")", key, value);
                                if (np->n_field)
-                                       free(np->n_field);
-                               np->n_field = getcpy(value);
+                                       mh_free0(&(np->n_field));
+                               np->n_field = mh_xstrdup(value);
                                ctxflags |= CTXMOD;
                        }
                        return;
@@ -53,11 +53,11 @@ context_replace(char *key, char *value)
        /*
        ** Else add this new entry at the end
        */
-       np->n_next = (struct node *) mh_xmalloc(sizeof(*np));
+       np->n_next = mh_xcalloc(1, sizeof(*np));
 
        np = np->n_next;
-       np->n_name = getcpy(key);
-       np->n_field = getcpy(value);
+       np->n_name = mh_xstrdup(key);
+       np->n_field = mh_xstrdup(value);
        np->n_context = 1;
        np->n_next = NULL;
        ctxflags |= CTXMOD;
index 47327edd83ff8d0cf0ba5a48789670b17c5f7d87..71646162b0f2934bc856ab2ddc78a5f16440d30c 100644 (file)
@@ -68,7 +68,7 @@ add_children(char *name, struct crawl_context *crawl)
        }
 
        if (strcmp(name, ".") == 0) {
-               prefix = getcpy("");
+               prefix = mh_xstrdup("");
        } else {
                prefix = concat(name, "/", (void *)NULL);
        }
@@ -102,12 +102,12 @@ add_children(char *name, struct crawl_context *crawl)
                        /* add_folder saves child in the list, don't free it */
                        add_folder(child, crawl);
                } else {
-                       free(child);
+                       mh_free0(&child);
                }
        }
 
        closedir(dd);
-       free(prefix);
+       mh_free0(&prefix);
 }
 
 static void
@@ -142,10 +142,10 @@ crawl_folders_body(struct crawl_context *crawl, char *dir,
 void
 crawl_folders(char *dir, crawl_callback_t *callback, void *baton)
 {
-       struct crawl_context *crawl = mh_xmalloc(sizeof(*crawl));
+       struct crawl_context *crawl = mh_xcalloc(1, sizeof(*crawl));
        crawl->max = CRAWL_NUMFOLDERS;
        crawl->total = crawl->start = crawl->foldp = 0;
-       crawl->folders = mh_xmalloc(crawl->max * sizeof(*crawl->folders));
+       crawl->folders = mh_xcalloc(crawl->max, sizeof(*crawl->folders));
 
        crawl_folders_body(crawl, dir, callback, baton);
 
@@ -153,6 +153,6 @@ crawl_folders(char *dir, crawl_callback_t *callback, void *baton)
        ** Note that we "leak" the folder names, on the assumption that the
        ** caller is using them.
        */
-       free(crawl->folders);
-       free(crawl);
+       mh_free0(&(crawl->folders));
+       mh_free0(&crawl);
 }
index 852c26135ad275d24748e4179d5234fd30994d53..4e4cbefbf3ada215daef01e242dc64e175aefdee 100644 (file)
@@ -204,7 +204,7 @@ field_encode_quoted(const char *name, char **value, const char *charset,
                                ** least one) until we get to the actual
                                ** text. Copy until we get to a non-space.
                                */
-                               output = mh_xmalloc(outlen);
+                               output = mh_xcalloc(outlen, sizeof(char));
                                q = output;
                                while (is_fws(*p)) {
                                        *q++ = *p++;
@@ -299,7 +299,7 @@ field_encode_quoted(const char *name, char **value, const char *charset,
        }
        *q = '\0';
 
-       free(*value);
+       mh_free0(value);
        *value = output;
 
        return 0;
@@ -340,7 +340,7 @@ utf8len(const char *p)
 static void
 unfold_header(char **value, int len)
 {
-       char *str = mh_xmalloc(len + 1);
+       char *str = mh_xcalloc(len + 1, sizeof(char));
        char *p = str, *q = *value;
 
        while (*q != '\0') {
@@ -367,7 +367,7 @@ unfold_header(char **value, int len)
        }
        *p = '\0';
 
-       free(*value);
+       mh_free0(value);
        *value = str;
 }
 
@@ -574,8 +574,7 @@ do_reformat:
 
                output = add(cp, output);
                column += len;
-               free(cp);
-               cp = NULL;
+               mh_free0(&cp);
        }
 
        /*
@@ -588,17 +587,17 @@ do_reformat:
 
        output = add("\n", output);
 
-       free(*value);
+       mh_free0(value);
        *value = output;
        output = NULL;
 
 out:
 
        if (tmpbuf) {
-               free(tmpbuf);
+               mh_free0(&tmpbuf);
        }
        if (output) {
-               free(output);
+               mh_free0(&output);
        }
 
        return errflag > 0;
index c7379b10f056ce11751e0303bd7bb9db2766543d..25c0e168ae8580e5c03b9024846d660e3c8962dd 100644 (file)
@@ -41,7 +41,7 @@ static unsigned int bufsiz;  /* current size of buf         */
 ** returns a pointer to the concatenated address string.
 **
 ** We try to not do a lot of malloc/copy/free's (which is why we
-** don't call "getcpy") but still place no upper limit on the
+** don't call "mh_xstrdup") but still place no upper limit on the
 ** length of the result string.
 **
 ** This routine is placed in a separate library so it can be
@@ -60,7 +60,7 @@ formataddr(char *orig, char *str)
 
        /* if we don't have a buffer yet, get one */
        if (bufsiz == 0) {
-               buf = mh_xmalloc(BUFINCR);
+               buf = mh_xcalloc(BUFINCR, sizeof(char));
                last_dst = buf;  /* XXX */
                bufsiz = BUFINCR - 6;  /* leave some slop */
                bufend = buf + bufsiz;
index 096f7dd62a46d1b31b696b0888ae14c8143a14ae..566f620939018eac7824fe2ae80e49a6ae5d920c 100644 (file)
@@ -209,7 +209,7 @@ static struct ftable functable[] = {
 
 /* Add new component to the hash table */
 #define NEWCOMP(cm,name) do { \
-               cm = ((struct comp *) mh_xcalloc(1, sizeof (struct comp)));\
+               cm = (mh_xcalloc(1, sizeof (struct comp)));\
                cm->c_name = name;\
                ncomp++;\
                i = CHASH(name);\
@@ -308,8 +308,8 @@ fmt_compile(char *fstring, struct format **fmt)
        size_t i;
 
        if (format_string)
-               free(format_string);
-       format_string = getcpy(fstring);
+               mh_free0(&format_string);
+       format_string = mh_xstrdup(fstring);
        usr_fstring = fstring;
 
        /* init the component hash table. */
@@ -328,8 +328,7 @@ fmt_compile(char *fstring, struct format **fmt)
        i = strlen(fstring)/2 + 1;
        if (i == 1)
                i++;
-       next_fp = formatvec = (struct format *)mh_xcalloc((size_t) i,
-               sizeof(struct format));
+       next_fp = formatvec = mh_xcalloc(i, sizeof(struct format));
        if (next_fp == NULL)
                adios(EX_OSERR, NULL, "unable to allocate format storage");
 
@@ -480,8 +479,7 @@ do_name(char *sp, int preprocess)
                if (cm->c_type & CT_ADDR) {
                        CERROR("component used as both date and address");
                }
-               cm->c_tws = (struct tws *)
-                       mh_xcalloc((size_t) 1, sizeof(*cm->c_tws));
+               cm->c_tws = mh_xcalloc(1, sizeof(*cm->c_tws));
                fp->f_type = preprocess;
                PUTCOMP(sp);
                cm->c_type |= CT_DATE;
index 9a7988ebb07993aa2c3a1a027dcfca4adf49a12f..c1386d4c710bb4de354bbbbc9d219b6753ccc5eb 100644 (file)
@@ -30,12 +30,12 @@ new_fs(char *form, char *def_form)
        FILE *fp;
 
        if (formats) {
-               free(formats);
+               mh_free0(&formats);
        }
 
        if (form) {
                if (*form == '=') {
-                       formats = getcpy(form+1);
+                       formats = mh_xstrdup(form+1);
                } else {
                        if ((fp = fopen(etcpath(form), "r")) == NULL) {
                                adios(EX_IOERR, form, "unable to open format file");
@@ -43,7 +43,7 @@ new_fs(char *form, char *def_form)
                        if (fstat(fileno(fp), &st) == -1) {
                                adios(EX_IOERR, form, "unable to stat format file");
                        }
-                       formats = mh_xmalloc((size_t) st.st_size + 1);
+                       formats = mh_xcalloc(st.st_size + 1, sizeof(char));
                        if (read(fileno(fp), formats, (int)st.st_size) != st.st_size) {
                                adios(EX_IOERR, form, "error reading format file");
                        }
@@ -52,7 +52,7 @@ new_fs(char *form, char *def_form)
                }
        } else if (def_form) {
                if (*def_form == '=') {
-                       formats = getcpy(def_form+1);
+                       formats = mh_xstrdup(def_form+1);
                } else {
                        if ((fp = fopen(etcpath(def_form), "r")) == NULL) {
                                adios(EX_IOERR, def_form, "unable to open format file");
@@ -60,7 +60,7 @@ new_fs(char *form, char *def_form)
                        if (fstat(fileno(fp), &st) == -1) {
                                adios(EX_IOERR, def_form, "unable to stat format file");
                        }
-                       formats = mh_xmalloc((size_t) st.st_size + 1);
+                       formats = mh_xcalloc(st.st_size + 1, sizeof(char));
                        if (read(fileno(fp), formats, (int)st.st_size) != st.st_size) {
                                adios(EX_IOERR, def_form, "error reading format file");
                        }
index faa3cc2c0d3cc798550bea94c267c0e90c40500d..414513985a1a3d7a8d2ac7de4454bbee62dd9ef2 100644 (file)
@@ -209,7 +209,7 @@ decode_rfc2047(char *str, char *dst, size_t dstlen)
                        if (use_iconv) {
                                saveq = q;
                                savedstlen = dstlen;
-                               q = convbuf = (char *) mh_xmalloc(endofmime - startofmime);
+                               q = convbuf = mh_xcalloc(endofmime - startofmime, sizeof(char));
                        }
 /*
 ** ADDCHR2 is for adding characters when q is or might be convbuf:
@@ -337,7 +337,7 @@ decode_rfc2047(char *str, char *dst, size_t dstlen)
                                if (!dstlen || !savedstlen)
                                        goto buffull;
                                dstlen = savedstlen;
-                               free(convbuf);
+                               mh_free0(&convbuf);
                        }
 #endif
 
index 2930254effa3207ee279077f9689fac2c7387952..8da713ef7bb8b560fea6047fbbe6f6af3ee1099c 100644 (file)
@@ -7,7 +7,7 @@
 */
 
 #include <h/mh.h>
-
+#include <h/utils.h>
 
 void
 folder_free(struct msgs *mp)
@@ -18,12 +18,12 @@ folder_free(struct msgs *mp)
                return;
 
        if (mp->foldpath)
-               free(mp->foldpath);
+               mh_free0(&(mp->foldpath));
 
        /* free the sequence names */
        for (i = 0; mp->msgattrs[i]; i++)
-               free(mp->msgattrs[i]);
+               mh_free0(&(mp->msgattrs[i]));
 
-       free(mp->msgstats);  /* free message status area */
-       free(mp);  /* free main folder structure */
+       mh_free0(&(mp->msgstats));  /* free message status area */
+       mh_free0(&mp);  /* free main folder structure */
 }
index ec51d64e664947ce87687ee4140e5ca2f515792b..722ee2fd51f7abcc023f39f57383ce344e7fb230 100644 (file)
@@ -33,20 +33,20 @@ folder_read(char *name)
        struct dirent *dp;
        DIR *dd;
 
-       name = getcpy(toabsdir(name));
+       name = mh_xstrdup(toabsdir(name));
        if (!(dd = opendir(name))) {
-               free(name);
+               mh_free0(&name);
                return NULL;
        }
 
        if (stat(name, &st) == -1) {
-               free(name);
+               mh_free0(&name);
                closedir(dd);
                return NULL;
        }
 
        /* Allocate the main structure for folder information */
-       mp = (struct msgs *) mh_xmalloc((size_t) sizeof(*mp));
+       mp = mh_xcalloc(1, sizeof(*mp));
 
        clear_folder_flags(mp);
        mp->foldpath = name;
@@ -66,7 +66,7 @@ folder_read(char *name)
        ** name of the messages in this folder.
        */
        len = NUMMSGS;
-       mi = (int *) mh_xmalloc((size_t) (len * sizeof(*mi)));
+       mi = mh_xcalloc(len, sizeof(*mi));
 
        while ((dp = readdir(dd))) {
                if ((msgnum = m_atoi(dp->d_name)) && msgnum > 0) {
@@ -76,7 +76,7 @@ folder_read(char *name)
                        */
                        if (mp->nummsg >= len) {
                                len += NUMMSGS;
-                               mi = (int *) mh_xrealloc(mi, (size_t) (len * sizeof(*mi)));
+                               mi = mh_xrealloc(mi, len * sizeof(*mi));
                        }
 
                        /* Check if this is the first message we've seen */
@@ -128,7 +128,7 @@ folder_read(char *name)
 
        /* Allocate space for status of each message. */
 
-       mp->msgstats = mh_xmalloc(MSGSTATSIZE(mp, mp->lowoff, mp->hghoff));
+       mp->msgstats = mh_xcalloc(MSGSTATSIZE(mp, mp->lowoff, mp->hghoff), 1);
 
        /*
        ** Clear all the flag bits for all the message
@@ -146,7 +146,7 @@ folder_read(char *name)
        for (msgnum = 0; msgnum < mp->nummsg; msgnum++)
                set_exists(mp, mi[msgnum]);
 
-       free(mi);  /* We don't need this anymore */
+       mh_free0(&mi);  /* We don't need this anymore */
 
        /*
        ** Read and initialize the sequence information.
index 47b9281ee92205ed9a4d31cb78e079a74522f74d..64a66409b40dc253fd5e58be44a99c56337039df 100644 (file)
@@ -54,7 +54,7 @@ folder_realloc(struct msgs *mp, int lo, int hi)
                seqset_t *tmpstats;
 
                /* first allocate the new message status space */
-               tmpstats = mh_xmalloc(MSGSTATSIZE(mp, lo, hi));
+               tmpstats = mh_xcalloc(MSGSTATSIZE(mp, lo, hi), 1);
 
                /* then copy messages status array with shift */
                if (mp->nummsg > 0) {
@@ -62,7 +62,7 @@ folder_realloc(struct msgs *mp, int lo, int hi)
                                tmpstats[msgnum - lo] = mp->msgstats[msgnum - mp->lowoff];
                        }
                }
-               free(mp->msgstats);
+               mh_free0(&(mp->msgstats));
                mp->msgstats = tmpstats;
        }
 
index 14c9a23d7f1c15e9dd4582cd9737ad1701ca4a9b..e8da9849b8eaad0b25b63068c721f97d080a8996 100644 (file)
@@ -19,7 +19,7 @@ getarguments(char *invo_name, int argc, char **argv, int check_context)
        ** Check if profile/context specifies any arguments
        */
        if (check_context && (cp = context_find(invo_name))) {
-               cp = getcpy(cp);  /* make copy */
+               cp = mh_xstrdup(cp);  /* make copy */
                ap = brkstring(cp, " ", "\n");  /* split string */
 
                /* Count number of arguments split */
@@ -28,7 +28,7 @@ getarguments(char *invo_name, int argc, char **argv, int check_context)
                        n++;
        }
 
-       arguments = (char **) mh_xmalloc((argc + n) * sizeof(*arguments));
+       arguments = mh_xcalloc(argc + n, sizeof(*arguments));
        bp = arguments;
 
        /* Copy any arguments from profile/context */
diff --git a/sbr/getcpy.c b/sbr/getcpy.c
deleted file mode 100644 (file)
index 478986a..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-** getcpy.c -- copy a string in managed memory
-**
-** THIS IS OBSOLETE.  NEED TO REPLACE ALL OCCURENCES
-** OF GETCPY WITH STRDUP.  BUT THIS WILL REQUIRE
-** CHANGING PARTS OF THE CODE TO DEAL WITH NULL VALUES.
-**
-** This code is Copyright (c) 2002, by the authors of nmh.  See the
-** COPYRIGHT file in the root directory of the nmh distribution for
-** complete copyright information.
-*/
-
-#include <h/mh.h>
-#include <h/utils.h>
-
-
-char *
-getcpy(char *str)
-{
-       char *cp;
-       size_t len;
-
-       if (str) {
-               len = strlen(str) + 1;
-               cp = mh_xmalloc(len);
-               memcpy(cp, str, len);
-       } else {
-               cp = mh_xmalloc((size_t) 1);
-               *cp = '\0';
-       }
-       return cp;
-}
index 7309c8681b849e76d73673af755461590b82fde4..957bc4e89bbba93f0d5c59a8e6fd8bcde20521ee 100644 (file)
@@ -516,11 +516,11 @@ timerON(char *curlock, int fd)
        struct lock *lp;
        size_t len;
 
-       lp = (struct lock *) mh_xmalloc(sizeof(*lp));
+       lp = mh_xcalloc(1, sizeof(*lp));
 
        len = strlen(curlock) + 1;
        lp->l_fd = fd;
-       lp->l_lock = mh_xmalloc(len);
+       lp->l_lock = mh_xcalloc(len, sizeof(char));
        memcpy(lp->l_lock, curlock, len);
        lp->l_next = l_top;
 
@@ -557,8 +557,8 @@ timerOFF(int fd)
                        else
                                pp->l_next = lp->l_next;
 
-                       free(lp->l_lock);
-                       free(lp);
+                       mh_free0(&(lp->l_lock));
+                       mh_free0(&lp);
                }
        }
 
index 549e89b6aecd56504d9e98b98c869ac8d8543ad5..ee85790048bde9771d1feae7303fbea4fb0f08de 100644 (file)
@@ -23,12 +23,12 @@ m_draft(char *which)
        static char buffer[BUFSIZ];
        char *folder;
 
-       folder = getcpy(toabsdir(draftfolder));
+       folder = mh_xstrdup(toabsdir(draftfolder));
        create_folder(folder, 0, exit);
        if (!(mp = folder_read(folder))) {
                adios(EX_IOERR, NULL, "unable to read folder %s", folder);
        }
-       free(folder);
+       mh_free0(&folder);
 
        /*
        ** Make sure we have enough message status space for all
index 633522b804eb72a0c51abfc24111c27b78e801ed..c86d4d5dd0f26e1d52545cee072b265d390fb32f 100644 (file)
--- a/sbr/mf.c
+++ b/sbr/mf.c
@@ -42,7 +42,7 @@ getcpy(char *s)
                for(;;)
                        pause();
        }
-       p = mh_xmalloc((size_t) (strlen(s) + 2));
+       p = mh_xcalloc(strlen(s) + 2, sizeof(char));
        strcpy(p, s);
        return p;
 }
@@ -168,33 +168,31 @@ getadrx(char *addrs)
        struct adrx *adrxp = &adrxs2;
 
        if (pers)
-               free(pers);
+               mh_free0(&pers);
        if (mbox)
-               free(mbox);
+               mh_free0(&mbox);
        if (host)
-               free(host);
+               mh_free0(&host);
        if (path)
-               free(path);
+               mh_free0(&path);
        if (grp)
-               free(grp);
+               mh_free0(&grp);
        if (note)
-               free(note);
-       pers = mbox = host = path = grp = note = NULL;
+               mh_free0(&note);
        err[0] = 0;
 
        if (dp == NULL) {
                dp = cp = getcpy(addrs ? addrs : "");
                glevel = 0;
        } else if (cp == NULL) {
-               free(dp);
-               dp = NULL;
+               mh_free0(&dp);
                return NULL;
        }
 
        switch (parse_address()) {
        case DONE:
-               free(dp);
-               dp = cp = NULL;
+               mh_free0(&dp);
+               cp = NULL;
                return NULL;
 
        case OK:
@@ -272,8 +270,7 @@ again: ;
                }
        case LX_COMA:
                if (note) {
-                       free(note);
-                       note = NULL;
+                       mh_free0(&note);
                }
                goto again;
 
@@ -501,8 +498,7 @@ domain(char *buffer)
 
                case LX_AT:  /* sigh (0) */
                        mbox = add(host, add("%", mbox));
-                       free(host);
-                       host = NULL;
+                       mh_free0(&host);
                        continue;
 
                default:
index a2ec7d3a91d8ade38c2b83a4c69b9d9fb96c8329..c47f26ea39ca0366a2763b15791caac46ebdcdcb 100644 (file)
@@ -25,7 +25,7 @@ m_putenv(char *name, char *value)
        int i;
        char **ep, **nep, *cp;
 
-       cp = mh_xmalloc((size_t) (strlen(name) + strlen(value) + 2));
+       cp = mh_xcalloc(strlen(name) + strlen(value) + 2, sizeof(char));
 
        sprintf(cp, "%s=%s", name, value);
 
@@ -35,7 +35,7 @@ m_putenv(char *name, char *value)
                        return 0;
                }
 
-       nep = (char **) mh_xmalloc((size_t) ((i + 2) * sizeof(*nep)));
+       nep = mh_xcalloc(i + 2, sizeof(*nep));
 
        for (ep = environ, i = 0; *ep; nep[i++] = *ep++)
                continue;
index ccdf867c63cec3d1c2988ed6feeef48846daf1bb..6975d724ad50f943e09bff5f035e02b4369a13a0 100644 (file)
@@ -49,10 +49,10 @@ readconfig(struct node **npp, FILE *ib, char *file, int ctx)
        for (state = FLD2;;) {
                switch (state = m_getfld2(state, &f, ib)) {
                case FLD2:
-                       np = (struct node *) mh_xmalloc(sizeof(*np));
+                       np = mh_xcalloc(1, sizeof(*np));
                        *npp = np;
                        *(npp = &np->n_next) = NULL;
-                       np->n_name = getcpy(f.name);
+                       np->n_name = mh_xstrdup(f.name);
                        np->n_field = trimcpy(f.value);
                        np->n_context = ctx;
 
index 148ecb90f4263aa663f84be387dcf4e2d82a9f82..3606f6f399add19e0098d79a85dd046305cccb77 100644 (file)
@@ -27,7 +27,7 @@ seq_list(struct msgs *mp, char *seqname)
        /* On first invocation, allocate initial buffer space */
        if (!buffer) {
                len = MAXBUFFER;
-               buffer = mh_xmalloc((size_t) len);
+               buffer = mh_xcalloc(len, sizeof(char));
        }
 
        /*
@@ -72,7 +72,7 @@ seq_list(struct msgs *mp, char *seqname)
                        char *newbuf;
 
                        len += MAXBUFFER;
-                       newbuf = mh_xrealloc(buffer, (size_t) len);
+                       newbuf = mh_xrealloc(buffer, len);
                        bp = newbuf + (bp - buffer);
                        buffer = newbuf;
                }
index 1929b263f8400d392c4f93ee78b07e2861b57c1e..1fdccf96211d8d558919eabde3c0145f45b4b769 100644 (file)
@@ -32,7 +32,7 @@ seq_read(struct msgs *mp)
        ** Initialize the list of sequence names.  Go ahead and
        ** add the cur sequence to the list of sequences.
        */
-       mp->msgattrs[0] = getcpy(seq_cur);
+       mp->msgattrs[0] = mh_xstrdup(seq_cur);
        mp->msgattrs[1] = NULL;
        make_all_public(mp);  /* initially, make all public */
 
@@ -77,7 +77,7 @@ seq_public(struct msgs *mp)
        for (state = FLD2;;) {
                switch (state = m_getfld2(state, &f, fp)) {
                case FLD2:
-                       seq_init(mp, getcpy(f.name), trimcpy(f.value));
+                       seq_init(mp, mh_xstrdup(f.name), trimcpy(f.value));
                        continue;
 
                case BODY2:
@@ -120,9 +120,9 @@ seq_private(struct msgs *mp)
                                (j = strlen(np->n_name) - plen) > alen &&
                                *(np->n_name + j) == '-' &&
                                strcmp(mp->foldpath, np->n_name + j + 1)==0) {
-                       cp = getcpy(np->n_name + alen);
+                       cp = mh_xstrdup(np->n_name + alen);
                        *(cp + j - alen) = '\0';
-                       if ((i = seq_init(mp, cp, getcpy(np->n_field))) != -1)
+                       if ((i = seq_init(mp, cp, mh_xstrdup(np->n_field))) != -1)
                                make_seq_private(mp, i);
                }
        }
@@ -168,8 +168,8 @@ seq_init(struct msgs *mp, char *name, char *field)
 
        /* Return error, if too many sequences */
        if (i >= NUMATTRS) {
-               free(name);
-               free(field);
+               mh_free0(&name);
+               mh_free0(&field);
                return -1;
        }
 
@@ -178,7 +178,7 @@ seq_init(struct msgs *mp, char *name, char *field)
        ** name string.  Else add it to the list of sequence names.
        */
        if (mp->msgattrs[i]) {
-               free(name);
+               mh_free0(&name);
        } else {
                mp->msgattrs[i] = name;
                mp->msgattrs[i + 1] = NULL;
@@ -215,6 +215,6 @@ seq_init(struct msgs *mp, char *name, char *field)
                }
        }
 
-       free(field);  /* free string containing message ranges */
+       mh_free0(&field);  /* free string containing message ranges */
        return i;
 }
index c66c13287798123ded4f2c73ed88d65351a29fb1..f4304cc523ca2e36e7033361e7bdd059f16192af 100644 (file)
@@ -7,6 +7,7 @@
 */
 
 #include <h/mh.h>
+#include <h/utils.h>
 
 /*
 ** Add all the messages currently SELECTED to
@@ -26,9 +27,9 @@ seq_setprev(struct msgs *mp)
        ** and split them.
        */
        if ((cp = context_find(psequence))) {
-               dp = getcpy(cp);
+               dp = mh_xstrdup(cp);
                if (!(ap = brkstring(dp, " ", "\n")) || !*ap) {
-                       free(dp);
+                       mh_free0(&dp);
                        return;
                }
        } else {
@@ -39,5 +40,5 @@ seq_setprev(struct msgs *mp)
        for (; *ap; ap++)
                seq_addsel(mp, *ap, -1, 1);
 
-       free(dp);
+       mh_free0(&dp);
 }
index e628393221d73ea3772941a91a92c8dc737a2046..d83365039df1a4af3cdf3a4996c87f6d6ef8e6f9 100644 (file)
@@ -8,6 +8,7 @@
 */
 
 #include <h/mh.h>
+#include <h/utils.h>
 
 /*
 ** We scan through the folder and act upon all messages
@@ -27,14 +28,14 @@ seq_setunseen(struct msgs *mp, int doadd)
        ** and split them.
        */
        if ((cp = context_find(usequence))) {
-               dp = getcpy(cp);
+               dp = mh_xstrdup(cp);
        } else {
                /* not set in profile, thus use the default */
-               dp = getcpy(seq_unseen);
+               dp = mh_xstrdup(seq_unseen);
        }
        if (!(ap = brkstring(dp, " ", "\n")) || !*ap) {
                /* contains no sequence name, i.e. we're finished */
-               free(dp);
+               mh_free0(&dp);
                return;
        }
 
@@ -61,5 +62,5 @@ seq_setunseen(struct msgs *mp, int doadd)
                }
        }
 
-       free(dp);
+       mh_free0(&dp);
 }
index 0d7f58a8190b2b373a3e98865e9753b9aa32343d..ffa6b575e8fd4641f663fd5ee63769043aa20451 100644 (file)
@@ -9,6 +9,7 @@
 */
 
 #include <h/mh.h>
+#include <h/utils.h>
 #include <ctype.h>
 
 
@@ -36,5 +37,5 @@ trimcpy(unsigned char *cp)
        }
 
        /* now return a copy */
-       return getcpy(cp);
+       return mh_xstrdup(cp);
 }
index fa4cfdb2b3b8e5e97831407f5599327b05fa43e5..466b9aba2627e7c4f1e6d9d384e2ca69e83063e4 100644 (file)
 */
 #define MAXMSGS 256
 
-/*
-** Safely call malloc
-*/
-void *
-mh_xmalloc(size_t size)
-{
-       void *memory;
-
-       if (size == 0) {
-               adios(EX_SOFTWARE, NULL, "Tried to malloc 0 bytes");
-       }
-
-       memory = malloc(size);
-       if (!memory) {
-               adios(EX_OSERR, NULL, "Malloc failed");
-       }
-
-       return memory;
-}
-
 /*
 ** Safely call realloc
 */
@@ -51,7 +31,7 @@ mh_xrealloc(void *ptr, size_t size)
 
        /* Some non-POSIX realloc()s don't cope with realloc(NULL,sz) */
        if (!ptr) {
-               return mh_xcalloc((size_t) 1, size);
+               return mh_xcalloc(1, size);
        }
        if (size == 0) {
                adios(EX_SOFTWARE, NULL, "Tried to realloc 0 bytes");
@@ -84,6 +64,18 @@ mh_xcalloc(size_t nmemb, size_t size)
        }
 }
 
+/*
+** Free a pointer and set it to NULL.
+*/
+void
+mh_free0(void * ptr)
+{
+       void ** p;
+       p = ptr;
+       free(*p);
+       *p = NULL;
+}
+
 /*
 ** Return the present working directory, if the current directory does not
 ** exist, or is too long, make / the pwd.
@@ -115,7 +107,7 @@ pwd(void)
 /*
 ** add   -- If "s1" is NULL, this routine just creates a
 **       -- copy of "s2" into newly malloc'ed memory.
-**       -- (use getcpy() instead in this case)
+**       -- (use mh_xstrdup() instead in this case)
 **       --
 **       -- If "s1" is not NULL, then copy the concatenation
 **       -- of "s1" and "s2" (note the order) into newly
@@ -134,12 +126,12 @@ add(char *s2, char *s1)
                len2 = strlen(s2);
        }
 
-       cp = mh_xmalloc(len1 + len2 + 1);
+       cp = mh_xcalloc(len1 + len2 + 1, sizeof(char));
 
        /* Copy s1 and free it */
        if (s1) {
                memcpy(cp, s1, len1);
-               free(s1);
+               mh_free0(&s1);
        }
 
        /* Copy s2 */
@@ -175,7 +167,7 @@ create_folder(char *folder, int autocreate, void (*done_callback)(int))
                        if (!getanswer(cp)) {
                                done_callback(EX_CANTCREAT);
                        }
-                       free(cp);
+                       mh_free0(&cp);
                } else if (autocreate == -1) {
                        /* do not create, so exit */
                        done_callback(EX_CANTCREAT);
@@ -226,3 +218,19 @@ app_msgarg(struct msgs_array *msgs, char *cp)
        }
        msgs->msgs[msgs->size++] = cp;
 }
+
+/*
+** mh_xstrdup() is a wrapper of strdup() to replace getcpy().  It returns
+** a copy of its argument if this is nonnull; otherwise, it returns a
+** string of length 0.
+*/
+char *
+mh_xstrdup(char * s)
+{
+       char * tmp;
+       tmp = strdup(s ? s : "");
+       if (!tmp) {
+               adios(EX_OSERR, "strdup", "can't copy string");
+       }
+       return tmp;
+}
index 3e71ad0b6dc954e15a0cf89989282b918aaf80ea..1ddd99b9b55f3c1d54615bafb7617297554550d0 100644 (file)
@@ -22,7 +22,7 @@ vfgets(FILE *in, char **bp)
        static char *pp = NULL;
 
        if (pp == NULL)
-               pp = mh_xmalloc((size_t) (len = BUFSIZ));
+               pp = mh_xcalloc(len = BUFSIZ, sizeof(char));
 
        for (ep = (cp = pp) + len - 1;;) {
                if (fgets(cp, ep - cp + 1, in) == NULL) {
@@ -64,7 +64,7 @@ wrong_guess:
                if (cp >= ep) {
                        int curlen = cp - pp;
 
-                       dp = mh_xrealloc(pp, (size_t) (len += BUFSIZ));
+                       dp = mh_xrealloc(pp, len += BUFSIZ);
                        cp = dp + curlen;
                        ep = (pp = dp) + len - 1;
                }
diff --git a/test/tests/mhsign/test-mhsign b/test/tests/mhsign/test-mhsign
new file mode 100755 (executable)
index 0000000..7654e5f
--- /dev/null
@@ -0,0 +1,77 @@
+#!/bin/sh
+######################################################
+#
+# Test mhsign (correct alias expansion with -enc)
+#
+######################################################
+
+. "$MH_TEST_COMMON"
+
+
+# setup some aliases
+
+cat >"$MH_TEST_DIR/.mmh/aliases" <<!
+a1:     unknownperson
+a2:     unknownperson@example.org
+a3:     Unknown Person <unknownperson>
+a4:     Unknown Person <unknownperson@example.org>
+a5:     "Unknown Person" <unknownperson@example.org>
+a6:     (Unknown) <unknownperson@example.org> (Person)
+a7:     Unknown <unknownperson@example.org>, unknownperson@example.org
+!
+cat >>"$MH_TEST_DIR/.mmh/profile" <<!
+aliasfile: aliases
+!
+
+
+# override gpg with our own function for defined output
+
+echo '#!/bin/sh
+exit 1
+' >"$MH_TEST_DIR/bin/gpg"
+chmod +x "$MH_TEST_DIR/bin/gpg"
+export MMHPGPKEY=0x12345678
+
+
+# now test it
+
+draft=`mhpath +drafts b`
+cat >"$draft" <<!
+To: a1, a2, a3, a4, a5
+Cc: a6, a7
+Subject: mhsign -enc test
+--------
+secret
+!
+
+runandcheck "whom -noali $draft" <<!
+a1
+a2
+a3
+a4
+a5
+a6
+a7
+!
+
+runandcheck "whom -ali $draft" <<!
+unknownperson
+unknownperson@example.org
+Unknown Person <unknownperson>
+Unknown Person <unknownperson@example.org>
+"Unknown Person" <unknownperson@example.org>
+(Unknown) <unknownperson@example.org> (Person)
+Unknown <unknownperson@example.org>
+unknownperson@example.org
+!
+
+runandcheck "mhsign -enc $draft" <<!
+Could not find key for <unknownperson>
+Could not find key for <unknownperson@example.org>
+Could not find key for <unknownperson>
+Could not find key for <unknownperson@example.org>
+Could not find key for <unknownperson@example.org>
+Could not find key for <unknownperson@example.org>
+Could not find key for <unknownperson@example.org>
+Could not find key for <unknownperson@example.org>
+!
diff --git a/test/tests/refile/test-refile b/test/tests/refile/test-refile
new file mode 100755 (executable)
index 0000000..9dd852a
--- /dev/null
@@ -0,0 +1,135 @@
+#!/bin/sh
+######################################################
+#
+# Test refile
+#
+######################################################
+
+. "$MH_TEST_COMMON"
+
+
+runandcheck "scan +inbox" <<!
+   1  2006-09-29 00:00  Test1              Testing message 1
+   2  2006-09-29 00:00  Test2              Testing message 2
+   3  2006-09-29 00:00  Test3              Testing message 3
+   4  2006-09-29 00:00  Test4              Testing message 4
+   5  2006-09-29 00:00  Test5              Testing message 5
+   6  2006-09-29 00:00  Test6              Testing message 6
+   7  2006-09-29 00:00  Test7              Testing message 7
+   8  2006-09-29 00:00  Test8              Testing message 8
+   9  2006-09-29 00:00  Test9              Testing message 9
+  10  2006-09-29 00:00  Test10             Testing message 10
+!
+
+
+# refile one msg from cur folder into one other folder
+
+folder +inbox >/dev/null
+runandcheck "refile 4 +fol1" <<!
+!
+runandcheck folder <<!
+inbox+ has 9 messages  (1-10)
+!
+runandcheck "scan +inbox" <<!
+   1  2006-09-29 00:00  Test1              Testing message 1
+   2  2006-09-29 00:00  Test2              Testing message 2
+   3  2006-09-29 00:00  Test3              Testing message 3
+   5  2006-09-29 00:00  Test5              Testing message 5
+   6  2006-09-29 00:00  Test6              Testing message 6
+   7  2006-09-29 00:00  Test7              Testing message 7
+   8  2006-09-29 00:00  Test8              Testing message 8
+   9  2006-09-29 00:00  Test9              Testing message 9
+  10  2006-09-29 00:00  Test10             Testing message 10
+!
+runandcheck "scan +fol1" <<!
+   1  2006-09-29 00:00  Test4              Testing message 4
+!
+
+
+# refile one msg from cur folder into two other folders
+
+folder +inbox >/dev/null
+runandcheck "refile 6 +fol1 +fol2" <<!
+!
+runandcheck folder <<!
+inbox+ has 8 messages  (1-10)
+!
+runandcheck "scan +inbox" <<!
+   1  2006-09-29 00:00  Test1              Testing message 1
+   2  2006-09-29 00:00  Test2              Testing message 2
+   3  2006-09-29 00:00  Test3              Testing message 3
+   5  2006-09-29 00:00  Test5              Testing message 5
+   7  2006-09-29 00:00  Test7              Testing message 7
+   8  2006-09-29 00:00  Test8              Testing message 8
+   9  2006-09-29 00:00  Test9              Testing message 9
+  10  2006-09-29 00:00  Test10             Testing message 10
+!
+runandcheck "scan +fol1" <<!
+   1  2006-09-29 00:00  Test4              Testing message 4
+   2  2006-09-29 00:00  Test6              Testing message 6
+!
+runandcheck "scan +fol2" <<!
+   1  2006-09-29 00:00  Test6              Testing message 6
+!
+
+
+# refile two msg from cur folder into two other folders
+
+folder +inbox >/dev/null
+runandcheck "refile 8 9 +fol1 +fol2" <<!
+!
+runandcheck folder <<!
+inbox+ has 6 messages  (1-10)
+!
+runandcheck "scan +inbox" <<!
+   1  2006-09-29 00:00  Test1              Testing message 1
+   2  2006-09-29 00:00  Test2              Testing message 2
+   3  2006-09-29 00:00  Test3              Testing message 3
+   5  2006-09-29 00:00  Test5              Testing message 5
+   7  2006-09-29 00:00  Test7              Testing message 7
+  10  2006-09-29 00:00  Test10             Testing message 10
+!
+runandcheck "scan +fol1" <<!
+   1  2006-09-29 00:00  Test4              Testing message 4
+   2  2006-09-29 00:00  Test6              Testing message 6
+   3  2006-09-29 00:00  Test8              Testing message 8
+   4  2006-09-29 00:00  Test9              Testing message 9
+!
+runandcheck "scan +fol2" <<!
+   1  2006-09-29 00:00  Test6              Testing message 6
+   2  2006-09-29 00:00  Test8              Testing message 8
+   3  2006-09-29 00:00  Test9              Testing message 9
+!
+
+
+# refile one msg from other folder into one other folder
+
+folder +inbox >/dev/null
+runandcheck "refile -src +fol1 1 +fol2" <<!
+!
+# Check new behavior as of mmh-0.3: Current folder stays the same!
+runandcheck folder <<!
+inbox+ has 6 messages  (1-10)
+!
+runandcheck "scan +inbox" <<!
+   1  2006-09-29 00:00  Test1              Testing message 1
+   2  2006-09-29 00:00  Test2              Testing message 2
+   3  2006-09-29 00:00  Test3              Testing message 3
+   5  2006-09-29 00:00  Test5              Testing message 5
+   7  2006-09-29 00:00  Test7              Testing message 7
+  10  2006-09-29 00:00  Test10             Testing message 10
+!
+runandcheck "scan +fol1" <<!
+   2  2006-09-29 00:00  Test6              Testing message 6
+   3  2006-09-29 00:00  Test8              Testing message 8
+   4  2006-09-29 00:00  Test9              Testing message 9
+!
+runandcheck "scan +fol2" <<!
+   1  2006-09-29 00:00  Test6              Testing message 6
+   2  2006-09-29 00:00  Test8              Testing message 8
+   3  2006-09-29 00:00  Test9              Testing message 9
+   4  2006-09-29 00:00  Test4              Testing message 4
+!
+
+
+
diff --git a/test/tests/repl/test-decode-addr b/test/tests/repl/test-decode-addr
new file mode 100644 (file)
index 0000000..145957c
--- /dev/null
@@ -0,0 +1,71 @@
+#!/bin/sh
+######################################################
+#
+# Test that repl and repl -g decode recipient addrs
+#
+######################################################
+
+. "$MH_TEST_COMMON"
+
+
+# create message to reply to
+
+msgfile=`mhpath b +inbox`
+cat >"$msgfile" <<EOF
+From: =?UTF-8?Q?J=C3=BCrgen?= <juergen@example.net>
+To: bob@example.com
+Cc: =?UTF-8?Q?K=C3=A4the?= <kaethe@example.org>
+Subject: repl addr decode
+Date: Mon, 18 Apr 2016 08:36:14 +0200
+MIME-Version: 1.0
+Content-Type: text/plain; charset="us-ascii"
+Message-ID: <1as2n8-1Q9-00@deseo.home.schnalke.org>
+
+foo
+EOF
+
+
+# create the reply draft
+runandcheck 'repl -nocc all -whatnow true l +inbox' <<!
+!
+
+# check the draft
+runandcheck 'cat `mhpath +drafts l`' <<!
+To: Jürgen <juergen@example.net>
+Cc: 
+Fcc: +sent
+Subject: Re: repl addr decode
+In-reply-to: <1as2n8-1Q9-00@deseo.home.schnalke.org>
+References: <1as2n8-1Q9-00@deseo.home.schnalke.org>
+Comments: In-reply-to Jürgen <juergen@example.net>
+   message dated "Mon, 18 Apr 2016 08:36:14 +0200."
+--------
+[2016-04-18 08:36] Jürgen <juergen@example.net>
+>
+> part       text/plain                   4
+> foo
+!
+
+
+
+# create the group reply draft
+runandcheck 'repl -group -nocc me -whatnow true l +inbox' <<!
+!
+
+# check the draft
+runandcheck 'cat `mhpath +drafts l`' <<!
+To: Jürgen <juergen@example.net>
+Cc: bob@example.com, Käthe <kaethe@example.org>
+Fcc: +sent
+Subject: Re: repl addr decode
+In-reply-to: <1as2n8-1Q9-00@deseo.home.schnalke.org>
+References: <1as2n8-1Q9-00@deseo.home.schnalke.org>
+Comments: In-reply-to Jürgen <juergen@example.net>
+   message dated "Mon, 18 Apr 2016 08:36:14 +0200."
+--------
+[2016-04-18 08:36] Jürgen <juergen@example.net>
+>
+> part       text/plain                   4
+> foo
+!
+
index 7d6604b1627cb6cb4db5ff4dec077d83e006a68f..b23d498de8b77eba196ac623f26a2b7aaa7ceac9 100644 (file)
@@ -27,6 +27,7 @@ X-NUMBER: 0 yes
 X-NOSTRING: 3x missing
 X-NONUMBER: 3x no
 --------
+> part       text/plain                  25
 > This is message number 1
 EOF
 
diff --git a/test/tests/scan/test-mh-format b/test/tests/scan/test-mh-format
new file mode 100644 (file)
index 0000000..2771934
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/sh
+######################################################
+#
+# Test trailing space handling in format files
+#
+######################################################
+
+. "$MH_TEST_COMMON"
+
+
+msgfile=`mhpath b +inbox`
+cat >"$msgfile" <<!
+Subject: =?UTF-8?Q?3_trailing_spaces___?=
+Mime-Version: 1.0
+From: Bob <bob@example.org>
+Date: Wed, 20 Apr 2016 07:38:12 +0200
+Message-Id: <83C58147-7B2B-4B7F-9502-17C1EB9526BC@example.org>
+To: Alice <alice@example.net>
+Content-Type: text/plain; charset=utf-8
+
+The subject line has three trailing spaces, inside the RFC 2047
+encoding. They get removed if we first (decode) and afterwards
+(trim) on diplay.
+!
+
+
+# output has no trailing spaces
+runandcheck "scan -width 80 +inbox l" <<!
+  11  2016-04-20 07:38  Bob                3 trailing spaces
+!
+
+
+
+runandcheck "show +inbox l" <<!
+Date:    Wed, 20 Apr 2016 07:38:12 +0200
+From:    Bob <bob@example.org>
+To:      Alice <alice@example.net>
+Subject: 3 trailing spaces
+
+part       text/plain                 145
+The subject line has three trailing spaces, inside the RFC 2047
+encoding. They get removed if we first (decode) and afterwards
+(trim) on diplay.
+!
index be02b670ea03e9aa360432a0ffbbd2e6f0af32de..6b7a570a44d830face383943f772da61e2faec97 100644 (file)
@@ -130,7 +130,7 @@ mmhwrap: mmhwrap.sh
        chmod +x mmhwrap
 
 mhsign: mhsign.sh
-       cp $(srcdir)/mhsign.sh mhsign
+       sed "s,%libdir%,"$(libdir)"," $(srcdir)/mhsign.sh >mhsign
        chmod +x mhsign
 
 mhpgp: mhpgp.sh
index dc2a3414d40510f0ffc0a110562f9688a4694231..9ab6515eba32990a9f3fd1ccf358c8ef6279c807 100644 (file)
--- a/uip/ali.c
+++ b/uip/ali.c
@@ -125,7 +125,7 @@ main(int argc, char **argv)
        if (deffiles && (cp = context_find("Aliasfile"))) {
                char *dp = NULL;
 
-               for (ap = brkstring(dp=getcpy(cp), " ", "\n");
+               for (ap = brkstring(dp=mh_xstrdup(cp), " ", "\n");
                                ap && *ap; ap++) {
                        if ((i = alias(etcpath(*ap))) != AK_OK) {
                                adios(EX_DATAERR, NULL, "aliasing error in %s: %s",
@@ -133,7 +133,7 @@ main(int argc, char **argv)
                        }
                }
                if (dp) {
-                       free(dp);
+                       mh_free0(&dp);
                }
        }
 
@@ -230,7 +230,7 @@ print_usr(char *s, int list, int norm)
                        if (!mh_strcasecmp(mp->m_host, np->m_host)
                                        && !mh_strcasecmp(mp->m_mbox, np->m_mbox)) {
                                vp = vp ? add(ak->ak_name, add(",", vp))
-                                       : getcpy(ak->ak_name);
+                                       : mh_xstrdup(ak->ak_name);
                                mnfree(np);
                                while (getname(""))
                                        continue;
@@ -244,5 +244,5 @@ print_usr(char *s, int list, int norm)
        print_aka(vp ? vp : s, list, 0);
 
        if (vp)
-               free(vp);
+               mh_free0(&vp);
 }
index bda73261b8192060f945a8903af885dd8d3311c0..b00f51bc4b42c89368379e5b6d821d395bd2aba7 100644 (file)
@@ -76,13 +76,13 @@ akresult(struct aka *ak)
 
        for (ad = ak->ak_addr; ad; ad = ad->ad_next) {
                pp = ad->ad_local ? akval(ak->ak_next, ad->ad_text)
-                       : getcpy(ad->ad_text);
+                       : mh_xstrdup(ad->ad_text);
 
                if (cp) {
                        dp = cp;
                        cp = concat(cp, ",", pp, NULL);
-                       free(dp);
-                       free(pp);
+                       mh_free0(&dp);
+                       mh_free0(&pp);
                } else
                        cp = pp;
        }
@@ -103,7 +103,7 @@ akval(struct aka *ak, char *s)
                if (aleq(s, ak->ak_name))
                        return akresult(ak);
 
-       return getcpy(s);
+       return mh_xstrdup(s);
 }
 
 
@@ -431,8 +431,8 @@ add_aka(struct aka *ak, char *pp)
                if (strcmp(pp, ad->ad_text)==0)
                        return;
 
-       ad = (struct adr *) mh_xmalloc(sizeof(*ad));
-       ad->ad_text = getcpy(pp);
+       ad = mh_xcalloc(1, sizeof(*ad));
+       ad->ad_text = mh_xstrdup(pp);
        ad->ad_local = strchr(pp, '@') == NULL;
        ad->ad_next = NULL;
        if (ak->ak_addr)
@@ -468,9 +468,9 @@ akalloc(char *id)
 {
        struct aka *p;
 
-       p = (struct aka *) mh_xmalloc(sizeof(*p));
+       p = mh_xcalloc(1, sizeof(*p));
 
-       p->ak_name = getcpy(id);
+       p->ak_name = mh_xstrdup(id);
        p->ak_visible = 0;
        p->ak_addr = NULL;
        p->ak_next = NULL;
@@ -489,13 +489,13 @@ hmalloc(struct passwd *pw)
 {
        struct home *p;
 
-       p = (struct home *) mh_xmalloc(sizeof(*p));
+       p = mh_xcalloc(1, sizeof(*p));
 
-       p->h_name = getcpy(pw->pw_name);
+       p->h_name = mh_xstrdup(pw->pw_name);
        p->h_uid = pw->pw_uid;
        p->h_gid = pw->pw_gid;
-       p->h_home = getcpy(pw->pw_dir);
-       p->h_shell = getcpy(pw->pw_shell);
+       p->h_home = mh_xstrdup(pw->pw_dir);
+       p->h_shell = mh_xstrdup(pw->pw_shell);
        p->h_ngrps = 0;
        p->h_next = NULL;
        /* append to end */
index 1c97179160c388f3ed3a129c67151edbed76d88d..9e287be4a3a7b94b68c0fcc52a0d829cea9958da 100644 (file)
@@ -181,7 +181,7 @@ main(int argc, char **argv)
                        if (folder)
                                adios(EX_USAGE, NULL, "only one folder at a time!");
                        else
-                               folder = getcpy(expandfol(cp));
+                               folder = mh_xstrdup(expandfol(cp));
                } else if (*cp == '/' || *cp == '.') {
                        if (file)
                                adios(EX_USAGE, NULL, "only one file at a time!");
@@ -305,7 +305,7 @@ annolist(char *file, unsigned char *comp, int number)
        }
 
        /* We'll grow this buffer as needed. */
-       field = (char *)mh_xmalloc(field_size = 256);
+       field = mh_xcalloc(field_size = 256, sizeof(char));
 
        make_comp(&comp);
        length = strlen(comp); /* Convenience copy. */
@@ -325,8 +325,7 @@ annolist(char *file, unsigned char *comp, int number)
                                break;
                        }
                        if (++n >= field_size - 1) {
-                               field = (char *)mh_xrealloc(field,
-                                               field_size += 256);
+                               field = mh_xrealloc(field, field_size += 256);
                                cp = field + n - 1;
                        }
                }
@@ -343,7 +342,7 @@ annolist(char *file, unsigned char *comp, int number)
 
        } while (*field && *field != '-');
 
-       free(field);
+       mh_free0(&field);
        fclose(fp);
 
        return;
@@ -459,7 +458,7 @@ dodel(int fd, unsigned char *comp, char *text, FILE *tmp, int number)
        if ((fp = fdopen(fd, "r")) == NULL) {
                adios(EX_IOERR, NULL, "unable to fdopen file.");
        }
-       field = (char *)mh_xmalloc(field_size);
+       field = mh_xcalloc(field_size, sizeof(char));
 
        /*
        **  Copy lines from the input file to the temporary file
@@ -487,8 +486,7 @@ dodel(int fd, unsigned char *comp, char *text, FILE *tmp, int number)
                        }
 
                        if (++n >= field_size - 1) {
-                               field = (char *) mh_xrealloc(field,
-                                               field_size *= 2);
+                               field = mh_xrealloc(field, field_size *= 2);
                                cp = field + n - 1;
                        }
                }
@@ -544,7 +542,7 @@ dodel(int fd, unsigned char *comp, char *text, FILE *tmp, int number)
 
        } while (*field && *field != '-');
 
-       free(field);
+       mh_free0(&field);
 
        fflush(tmp);
        fflush(fp); /* The underlying fd will be closed by lkclose() */
index e2d43dabde09ab34989ca18853d214b8d942bcaf..9d3560184e50fdc7570766fa5050a4478613fdc0 100644 (file)
--- a/uip/ap.c
+++ b/uip/ap.c
@@ -138,13 +138,13 @@ process(char *arg, int norm)
 
        (q = &pq)->pq_next = NULL;
        while ((cp = getname(arg))) {
-               p = (struct pqpair *) mh_xcalloc((size_t) 1, sizeof(*p));
+               p = mh_xcalloc(1, sizeof(*p));
                if ((mp = getm(cp, NULL, 0, norm, error)) == NULL) {
-                       p->pq_text = getcpy(cp);
-                       p->pq_error = getcpy(error);
+                       p->pq_text = mh_xstrdup(cp);
+                       p->pq_error = mh_xstrdup(error);
                        status++;
                } else {
-                       p->pq_text = getcpy(mp->m_text);
+                       p->pq_text = mh_xstrdup(mp->m_text);
                        mnfree(mp);
                }
                q = (q->pq_next = p);
@@ -161,11 +161,11 @@ process(char *arg, int norm)
                fmt_scan(fmt, buffer, BUFSIZ, dat);
                fputs(buffer, stdout);
 
-               free(p->pq_text);
+               mh_free0(&(p->pq_text));
                if (p->pq_error)
-                       free(p->pq_error);
+                       mh_free0(&(p->pq_error));
                q = p->pq_next;
-               free((char *) p);
+               mh_free0(&p);
        }
 
        return status;
index 04e5450a403989f72ffbb27e5704b9f606ee35d4..a68420a129b7f1d6b911ffea870ae2d9bc3ca006 100644 (file)
@@ -88,7 +88,7 @@ main(int argc, char **argv)
                        if (folder)
                                adios(EX_USAGE, NULL, "only one folder at a time!");
                        else
-                               folder = getcpy(expandfol(cp));
+                               folder = mh_xstrdup(expandfol(cp));
                } else {
                        msgs[msgp++] = cp;
                }
@@ -117,8 +117,7 @@ main(int argc, char **argv)
                        exit(EX_SOFTWARE);
        seq_setprev(mp);  /* set the previous-sequence */
 
-       smsgs = (struct smsg *)
-               mh_xcalloc((size_t) (MAXFOLDER + 2), sizeof(*smsgs));
+       smsgs = mh_xcalloc(MAXFOLDER + 2, sizeof(*smsgs));
 
        hi = mp->hghmsg + 1;
 
@@ -137,7 +136,7 @@ main(int argc, char **argv)
                }
        }
 
-       free(smsgs);
+       mh_free0(&smsgs);
        context_replace(curfolder, folder);
 
        /*
index 159d7e76122e7b286e61210984de7157ed53e737..c34ce43f07d4c0e380c371bc6e8d7991d344c822 100644 (file)
@@ -100,7 +100,7 @@ main(int argc, char **argv)
                        if (folder) {
                                adios(EX_USAGE, NULL, "only one folder at a time!");
                        } else {
-                               folder = getcpy(expandfol(cp));
+                               folder = mh_xstrdup(expandfol(cp));
                        }
                } else {
                        if (msg) {
@@ -111,7 +111,7 @@ main(int argc, char **argv)
                }
        }
 
-       cwd = getcpy(pwd());
+       cwd = mh_xstrdup(pwd());
 
        if (form && (folder || msg)) {
                adios(EX_USAGE, NULL, "can't mix forms and folders/msgs");
@@ -151,7 +151,7 @@ main(int argc, char **argv)
                if (mp->numsel > 1) {
                        adios(EX_USAGE, NULL, "only one message at a time!");
                }
-               if ((in = open(form = getcpy(m_name(mp->lowsel)),
+               if ((in = open(form = mh_xstrdup(m_name(mp->lowsel)),
                                O_RDONLY)) == NOTOK) {
                        adios(EX_IOERR, form, "unable to open message");
                }
index 07107127353ee4297d697bd93fcc04fbee559520..d74e498b0e20d57e927637fac77cb701bb6c4119 100644 (file)
@@ -103,7 +103,7 @@ main(int argc, char **argv)
                        if (folder) {
                                adios(EX_USAGE, NULL, "only one folder at a time!");
                        } else {
-                               folder = getcpy(expandfol(cp));
+                               folder = mh_xstrdup(expandfol(cp));
                        }
                } else {
                        if (msg) {
@@ -114,7 +114,7 @@ main(int argc, char **argv)
                }
        }
 
-       cwd = getcpy(pwd());
+       cwd = mh_xstrdup(pwd());
 
        strncpy(drft, m_draft(seq_beyond), sizeof(drft));
        if ((out = creat(drft, m_gmprot())) == NOTOK) {
@@ -158,7 +158,7 @@ main(int argc, char **argv)
                adios(EX_USAGE, NULL, "only one message at a time!");
        }
 
-       msgnam = getcpy(m_name(mp->lowsel));
+       msgnam = mh_xstrdup(m_name(mp->lowsel));
        if ((in = open(msgnam, O_RDONLY)) == NOTOK) {
                adios(EX_IOERR, msgnam, "unable to open message");
        }
index 68acabb11f3ca5d7f2eae0cc05cfe67062f68c1c..63fcb0f50aff921d5aafbb27ec56d6cd9cc4bc72 100644 (file)
@@ -143,8 +143,7 @@ main(int argc, char **argv)
        /* allocate the initial space to record the folder names */
        numfolders = 0;
        maxfolders = MAXFOLDERS;
-       foldersToDo = (char **) mh_xmalloc((size_t)
-                       (maxfolders * sizeof(*foldersToDo)));
+       foldersToDo = mh_xcalloc(maxfolders, sizeof(*foldersToDo));
 
        /* no sequences yet */
        numsequences = 0;
@@ -221,10 +220,10 @@ main(int argc, char **argv)
                        */
                        if (numfolders >= maxfolders) {
                                maxfolders += MAXFOLDERS;
-                               foldersToDo = (char **) mh_xrealloc(foldersToDo, (size_t) (maxfolders * sizeof(*foldersToDo)));
+                               foldersToDo = mh_xrealloc(foldersToDo, maxfolders * sizeof(*foldersToDo));
                        }
                        if (*cp == '+' || *cp == '@') {
-                               foldersToDo[numfolders++] = getcpy(expandfol(cp));
+                               foldersToDo[numfolders++] = mh_xstrdup(expandfol(cp));
                        } else
                                foldersToDo[numfolders++] = cp;
                }
@@ -251,7 +250,7 @@ main(int argc, char **argv)
                } else {
                        cp = seq_unseen;  /* use default */
                }
-               dp = getcpy(cp);
+               dp = mh_xstrdup(cp);
                ap = brkstring(dp, " ", "\n");
                for (; ap && *ap; ap++) {
                        if (numsequences >= NUMATTRS) {
@@ -295,7 +294,7 @@ GetFolderOrder(void)
                        AllocFolders(&orders, &nOrdersAlloced, nOrders + 1);
                        o = &orders[nOrders++];
                        o->priority = priority++;
-                       o->name = (char *) mh_xmalloc(p - s + 1);
+                       o->name = mh_xcalloc(p - s + 1, sizeof(char));
                        strncpy(o->name, s, p - s);
                        o->name[p - s] = 0;
                } else
@@ -465,7 +464,7 @@ AddFolder(char *name, int force)
                /* Oops, error occurred.  Record it and continue. */
                AllocFolders(&folders, &nFoldersAlloced, nFolders + 1);
                f = &folders[nFolders++];
-               f->name = getcpy(name);
+               f->name = mh_xstrdup(name);
                f->error = 1;
                f->priority = AssignPriority(f->name);
                return 0;
@@ -502,7 +501,7 @@ AddFolder(char *name, int force)
                /* save general folder information */
                AllocFolders(&folders, &nFoldersAlloced, nFolders + 1);
                f = &folders[nFolders++];
-               f->name = getcpy(name);
+               f->name = mh_xstrdup(name);
                f->nMsgs = mp->nummsg;
                f->error = 0;
                f->priority = AssignPriority(f->name);
@@ -624,12 +623,10 @@ AllocFolders(struct Folder **f, int *nfa, int n)
                return;
        if (*f == NULL) {
                *nfa = 10;
-               *f = (struct Folder *) mh_xmalloc(
-                               *nfa * (sizeof(struct Folder)));
+               *f = mh_xcalloc(*nfa, sizeof(struct Folder));
        } else {
                *nfa *= 2;
-               *f = (struct Folder *) mh_xrealloc(
-                               *f, *nfa * (sizeof(struct Folder)));
+               *f = mh_xrealloc(*f, *nfa * sizeof(struct Folder));
        }
 }
 
index 5266235a5dd39eb145307fbc72f9b64d16065749..a91333b7d2a3ecbdfa0524c012bb8eace75809b2 100644 (file)
@@ -89,10 +89,8 @@ main(int argc, char **argv)
                        form = cp;
        }
 
-       /*
-       ** Get new format string.  Must be before chdir().
-       */
-       fmtstr = new_fs(form, FORMAT);
+       /* Set format string.  Must be before chdir(). */
+       fmtstr = new_fs(form, scanformat);
        fmt_compile(fmtstr, &fmt);
 
        fmt_dump(fmt);
index 4ffb9f5b18622ee6f7eb93323e0682244a3749b5..3e3cd760804afa8c0bf37974787eb08fa03f39c0 100644 (file)
@@ -231,7 +231,7 @@ main(int argc, char **argv)
                        if (argfolder)
                                adios(EX_USAGE, NULL, "only one folder at a time!");
                        else
-                               argfolder = getcpy(expandfol(cp));
+                               argfolder = mh_xstrdup(expandfol(cp));
                } else {
                        if (msg)
                                adios(EX_USAGE, NULL, "only one (current) message at a time!");
@@ -255,21 +255,21 @@ main(int argc, char **argv)
                        /* If no folder is given, the current folder and */
                        /* the top of the folder stack are swapped. */
                        if ((cp = context_find(stack))) {
-                               dp = getcpy(cp);
+                               dp = mh_xstrdup(cp);
                                ap = brkstring(dp, " ", "\n");
-                               argfolder = getcpy(*ap++);
+                               argfolder = mh_xstrdup(*ap++);
                        } else {
                                adios(EX_USAGE, NULL, "no other folder");
                        }
-                       for (cp = getcpy(getcurfol()); *ap; ap++)
+                       for (cp = mh_xstrdup(getcurfol()); *ap; ap++)
                                cp = add(*ap, add(" ", cp));
-                       free(dp);
+                       mh_free0(&dp);
                        context_replace(stack, cp);  /* update folder stack */
                } else {
                        /* update folder stack */
                        context_replace(stack, (cp = context_find (stack)) ?
                                        concat(getcurfol(), " ", cp, NULL) :
-                                       getcpy(getcurfol()));
+                                       mh_xstrdup(getcurfol()));
                }
        }
 
@@ -278,15 +278,15 @@ main(int argc, char **argv)
                if (argfolder)
                        adios(EX_USAGE, NULL, "sorry, no folders allowed with -pop");
                if ((cp = context_find(stack))) {
-                       dp = getcpy(cp);
+                       dp = mh_xstrdup(cp);
                        ap = brkstring(dp, " ", "\n");
-                       argfolder = getcpy(*ap++);
+                       argfolder = mh_xstrdup(*ap++);
                } else {
                        adios(EX_DATAERR, NULL, "folder stack empty");
                }
                if (*ap) {
                        /* if there's anything left in the stack */
-                       cp = getcpy(*ap++);
+                       cp = mh_xstrdup(*ap++);
                        for (; *ap; ap++)
                                cp = add(*ap, add(" ", cp));
                        context_replace(stack, cp);  /* update folder stack */
@@ -294,7 +294,7 @@ main(int argc, char **argv)
                        /* delete folder stack entry from context */
                        context_del(stack);
                }
-               free(dp);
+               mh_free0(&dp);
        }
        if (pushsw || popsw) {
                cp = toabsdir(argfolder);
@@ -310,10 +310,10 @@ main(int argc, char **argv)
        if (listsw) {
                printf("%s", argfolder ? argfolder : getcurfol());
                if ((cp = context_find(stack))) {
-                       dp = getcpy(cp);
+                       dp = mh_xstrdup(cp);
                        for (ap = brkstring(dp, " ", "\n"); *ap; ap++)
                                printf(" %s", *ap);
-                       free(dp);
+                       mh_free0(&dp);
                }
                printf("\n");
 
@@ -324,7 +324,7 @@ main(int argc, char **argv)
 
        /* Allocate initial space to record folder information */
        maxFolderInfo = CRAWL_NUMFOLDERS;
-       fi = mh_xmalloc(maxFolderInfo * sizeof(*fi));
+       fi = mh_xcalloc(maxFolderInfo, sizeof(*fi));
 
        /*
        ** Scan the folders
index 4bb03d34d3cfcb6738f4d82a85fa2d8093be5a52..d8d69f7865049d1c23c24475e9555b80ea2adc7a 100644 (file)
@@ -153,13 +153,13 @@ main(int argc, char **argv)
                        if (folder)
                                adios(EX_USAGE, NULL, "only one folder at a time!");
                        else
-                               folder = getcpy(expandfol(cp));
+                               folder = mh_xstrdup(expandfol(cp));
                } else {
                        msgs[msgp++] = cp;
                }
        }
 
-       cwd = getcpy(pwd());
+       cwd = mh_xstrdup(pwd());
        strncpy(drft, buildsw ? toabsdir("draft") : m_draft(seq_beyond),
                        sizeof(drft));
        /*
@@ -233,10 +233,10 @@ main(int argc, char **argv)
        if (digest) {
                snprintf(buf, sizeof(buf), IFORMAT, digest);
                snprintf(value, sizeof(value), "%d", issue);
-               context_replace(buf, getcpy(value));
+               context_replace(buf, mh_xstrdup(value));
                snprintf(buf, sizeof(buf), VFORMAT, digest);
                snprintf(value, sizeof(value), "%d", volume);
-               context_replace(buf, getcpy(value));
+               context_replace(buf, mh_xstrdup(value));
        }
 
        context_replace(curfolder, folder); /* update current folder */
@@ -316,7 +316,7 @@ build_form(char *form, char *digest, int volume, int issue)
                cptr->c_text = digest;
        FINDCOMP(cptr, "date");
        if (cptr)
-               cptr->c_text = getcpy(dtimenow());
+               cptr->c_text = mh_xstrdup(dtimenow());
 
        dat[0] = issue;
        dat[1] = volume;
@@ -333,10 +333,10 @@ build_form(char *form, char *digest, int volume, int issue)
        if ((in = dup(fileno(tmp))) == NOTOK)
                adios(EX_OSERR, "dup", "unable to");
 
-       line = mh_xmalloc((unsigned) fmtsize);
+       line = mh_xcalloc(fmtsize, sizeof(char));
        fmt_scan(fmt, line, fmtsize, dat);
        fputs(line, tmp);
-       free(line);
+       mh_free0(&line);
        if (fclose(tmp))
                adios(EX_IOERR, tmpfil, "error writing");
 
index 5f08df4598ffb3e047714b3582e66e2eec42c4f1..0cb2a5e0083186c5643560e6c6f872f6374c46de 100644 (file)
--- a/uip/inc.c
+++ b/uip/inc.c
@@ -197,7 +197,7 @@ main(int argc, char **argv)
                        case AUDSW:
                                if (!(cp = *argp++) || *cp == '-')
                                        adios(EX_USAGE, NULL, "missing argument to %s", argp[-2]);
-                               audfile = getcpy(expanddir(cp));
+                               audfile = mh_xstrdup(expanddir(cp));
                                continue;
                        case NAUDSW:
                                audfile = NULL;
@@ -228,7 +228,7 @@ main(int argc, char **argv)
                                if (!(cp = *argp++) || *cp == '-')
                                        adios(EX_USAGE, NULL, "missing argument to %s",
                                                        argp[-2]);
-                               from = getcpy(expanddir(cp));
+                               from = mh_xstrdup(expanddir(cp));
 
                                /*
                                ** If the truncate file is in default state,
@@ -263,7 +263,7 @@ main(int argc, char **argv)
                        if (folder)
                                adios(EX_USAGE, NULL, "only one folder at a time!");
                        else
-                               folder = getcpy(expandfol(cp));
+                               folder = mh_xstrdup(expandfol(cp));
                } else {
                        adios(EX_USAGE, NULL, "usage: %s [+folder] [switches]",
                                        invo_name);
@@ -350,8 +350,8 @@ main(int argc, char **argv)
                         dtimenow(), from);
        }
 
-       /* Get new format string */
-       fmtstr = new_fs(form, FORMAT);
+       /* Set format string */
+       fmtstr = new_fs(form, scanformat);
 
        if (noisy) {
                printf("Incorporating new mail into %s...\n\n", folder);
@@ -445,7 +445,7 @@ main(int argc, char **argv)
                break;
        }
 giveup:;
-       free(maildir_copy);
+       mh_free0(&maildir_copy);
 
        if (incerr < 0) {  /* error */
                if (locked) {
index a6ac480e524ef9730f30282f7b1a0a6063cbb17b..1e57d1cc8693696c1c134b5ccfe3a15edeef2d34 100644 (file)
@@ -137,7 +137,7 @@ main(int argc, char **argv)
                        if (folder) {
                                adios(EX_USAGE, NULL, "only one folder at a time!");
                        } else {
-                               folder = getcpy(expandfol(cp));
+                               folder = mh_xstrdup(expandfol(cp));
                        }
                } else {
                        app_msgarg(&msgs, cp);
index ec5623a6633dba52458fbeb8be97aa8c79ea11cf..fe3e946685f825f35d947159e88c91974c10120f 100644 (file)
@@ -204,7 +204,7 @@ main(int argc, char **argv)
        if ((cp = context_find(nmhstorage)) && *cp)
                tmp = concat(cp, "/", invo_name, NULL);
        else
-               tmp = getcpy(toabsdir(invo_name));
+               tmp = mh_xstrdup(toabsdir(invo_name));
 
        /* Check if we have a file to process */
        if (!compfile)
@@ -333,7 +333,7 @@ build_mime(char *infile)
        /*
        ** Allocate space for primary (outside) content
        */
-       ct = (CT) mh_xcalloc(1, sizeof(*ct));
+       ct = mh_xcalloc(1, sizeof(*ct));
 
        /*
        ** Allocate structure for handling decoded content
@@ -371,7 +371,7 @@ build_mime(char *infile)
                        }
 
                        /* add the header data to the list */
-                       add_header(ct, getcpy(f.name), getcpy(f.value));
+                       add_header(ct, mh_xstrdup(f.name), mh_xstrdup(f.value));
 
                        continue;
 
@@ -409,7 +409,7 @@ build_mime(char *infile)
        ** Now add the MIME-Version header field
        ** to the list of header fields.
        */
-       np = getcpy(VRSN_FIELD);
+       np = mh_xstrdup(VRSN_FIELD);
        vp = concat(" ", VRSN_VALUE, "\n", NULL);
        add_header(ct, np, vp);
 
@@ -423,7 +423,7 @@ build_mime(char *infile)
        }
        ct->c_type = CT_MULTIPART;
        ct->c_subtype = MULTI_MIXED;
-       ct->c_file = getcpy(infile);
+       ct->c_file = mh_xstrdup(infile);
 
        m = (struct multipart *) mh_xcalloc(1, sizeof(*m));
        ct->c_ctparams = (void *) m;
@@ -444,7 +444,7 @@ build_mime(char *infile)
                if (!p)
                        continue;
 
-               part = (struct part *) mh_xcalloc(1, sizeof(*part));
+               part = mh_xcalloc(1, sizeof(*part));
                *pp = part;
                pp = &part->mp_next;
                part->mp_part = p;
@@ -524,7 +524,7 @@ init_decoded_content(CT ct)
 {
        CE ce;
 
-       ce = (CE) mh_xcalloc(1, sizeof(*ce));
+       ce = mh_xcalloc(1, sizeof(*ce));
 
        ct->c_cefile     = ce;
        ct->c_ceopenfnx  = open7Bit;  /* since unencoded */
@@ -584,7 +584,7 @@ user_content(FILE *in, char *file, char *buf, CT *ctp)
        }
 
        /* allocate basic Content structure */
-       ct = (CT) mh_xcalloc(1, sizeof(*ct));
+       ct = mh_xcalloc(1, sizeof(*ct));
        *ctp = ct;
 
        /* allocate basic structure for handling decoded content */
@@ -615,7 +615,7 @@ user_content(FILE *in, char *file, char *buf, CT *ctp)
                        adios(EX_CANTCREAT, "mhbuild", "unable to create temporary file");
 
                /* use a temp file to collect the plain text lines */
-               ce->ce_file = getcpy(cp);
+               ce->ce_file = mh_xstrdup(cp);
                ce->ce_unlink = 1;
 
                if (buf[0] == '#' && buf[1] == '<') {
@@ -797,8 +797,8 @@ use_forw:
                                        continue;
                                if (!*cp)
                                        adios(EX_DATAERR, NULL, "empty pipe command for #%s directive", ci->ci_type);
-                               cp = getcpy(cp);
-                               free(ci->ci_magic);
+                               cp = mh_xstrdup(cp);
+                               mh_free0(&(ci->ci_magic));
                                ci->ci_magic = cp;
                        } else {
                                /* record filename of decoded contents */
@@ -825,7 +825,7 @@ use_forw:
                                exit(EX_CONFIG);
                        }
                }
-               ci->ci_magic = getcpy(cp);
+               ci->ci_magic = mh_xstrdup(cp);
                return OK;
        }
 
@@ -860,13 +860,13 @@ use_forw:
                                if (folder)
                                        adios(EX_USAGE, NULL, "only one folder per #forw directive");
                                else
-                                       folder = getcpy(expandfol(cp));
+                                       folder = mh_xstrdup(expandfol(cp));
                        }
                }
 
                /* else, use the current folder */
                if (!folder)
-                       folder = getcpy(getcurfol());
+                       folder = mh_xstrdup(getcurfol());
 
                if (!(mp = folder_read(folder)))
                        adios(EX_IOERR, NULL, "unable to read folder %s", folder);
@@ -876,7 +876,7 @@ use_forw:
                                if (!m_convert(mp, cp))
                                        exit(EX_USAGE);
                }
-               free(folder);
+               mh_free0(&folder);
                free_ctinfo(ct);
 
                /*
@@ -892,7 +892,7 @@ use_forw:
                        ct->c_type = CT_MULTIPART;
                        ct->c_subtype = MULTI_DIGEST;
 
-                       m = (struct multipart *) mh_xcalloc(1, sizeof(*m));
+                       m = mh_xcalloc(1, sizeof(*m));
                        ct->c_ctparams = (void *) m;
                        pp = &m->mp_parts;
 
@@ -902,7 +902,7 @@ use_forw:
                                        CT p;
                                        CE pe;
 
-                                       p = (CT) mh_xcalloc(1, sizeof(*p));
+                                       p = mh_xcalloc(1, sizeof(*p));
                                        init_decoded_content(p);
                                        pe = p->c_cefile;
                                        if (get_ctinfo("message/rfc822", p, 0)
@@ -914,9 +914,9 @@ use_forw:
                                        snprintf(buffer, sizeof(buffer),
                                                        "%s/%d", mp->foldpath,
                                                        msgnum);
-                                       pe->ce_file = getcpy(buffer);
+                                       pe->ce_file = mh_xstrdup(buffer);
 
-                                       part = (struct part *) mh_xcalloc(1, sizeof(*part));
+                                       part = mh_xcalloc(1, sizeof(*part));
                                        *pp = part;
                                        pp = &part->mp_next;
                                        part->mp_part = p;
@@ -932,7 +932,7 @@ use_forw:
                        msgnum = mp->lowsel;
                        snprintf(buffer, sizeof(buffer), "%s/%d",
                                        mp->foldpath, msgnum);
-                       ce->ce_file = getcpy(buffer);
+                       ce->ce_file = mh_xstrdup(buffer);
                }
 
                folder_free(mp);  /* free folder/message structure */
@@ -975,7 +975,7 @@ use_forw:
                ct->c_type = CT_MULTIPART;
                ct->c_subtype = vrsn;
 
-               m = (struct multipart *) mh_xcalloc(1, sizeof(*m));
+               m = mh_xcalloc(1, sizeof(*m));
                ct->c_ctparams = (void *) m;
 
                pp = &m->mp_parts;
@@ -991,7 +991,7 @@ use_forw:
                        if (!p)
                                continue;
 
-                       part = (struct part *) mh_xcalloc(1, sizeof(*part));
+                       part = mh_xcalloc(1, sizeof(*part));
                        *pp = part;
                        pp = &part->mp_next;
                        part->mp_part = p;
@@ -1021,10 +1021,10 @@ set_id(CT ct, int top)
                snprintf(msgid, sizeof(msgid), "<%d.%ld.%%d@%s>\n",
                                (int) getpid(), (long) clock, LocalName());
                partno = 0;
-               msgfmt = getcpy(msgid);
+               msgfmt = mh_xstrdup(msgid);
        }
        snprintf(msgid, sizeof(msgid), msgfmt, top ? 0 : ++partno);
-       ct->c_id = getcpy(msgid);
+       ct->c_id = mh_xstrdup(msgid);
 }
 
 
@@ -1062,7 +1062,7 @@ compose_content(CT ct)
                        CT p = part->mp_part;
 
                        sprintf(pp, "%d", partnum);
-                       p->c_partno = getcpy(partnam);
+                       p->c_partno = mh_xstrdup(partnam);
                        if (compose_content(p) == NOTOK)
                                return NOTOK;
                }
@@ -1093,7 +1093,7 @@ compose_content(CT ct)
                        if (tfile == NULL) {
                                adios(EX_CANTCREAT, "mhbuild", "unable to create temporary file");
                        }
-                       ce->ce_file = getcpy(tfile);
+                       ce->ce_file = mh_xstrdup(tfile);
                        ce->ce_unlink = 1;
 
                        xstdout = 0;
@@ -1380,7 +1380,7 @@ scan_content(CT ct)
                                                NULL);
                        } else {
                                t->tx_charset = CHARSET_USASCII;
-                               *ap = getcpy("charset=us-ascii");
+                               *ap = mh_xstrdup("charset=us-ascii");
                        }
 
                        cp = strchr(*ap++, '=');
@@ -1442,7 +1442,7 @@ build_headers(CT ct)
                ep = ci->ci_values;
                snprintf(buffer, sizeof(buffer), "boundary=%s%d",
                                prefix, level++);
-               cp = strchr(*ap++ = getcpy(buffer), '=');
+               cp = strchr(*ap++ = mh_xstrdup(buffer), '=');
                *ap = NULL;
                *cp++ = '\0';
                *ep = cp;
@@ -1451,7 +1451,7 @@ build_headers(CT ct)
        /*
        ** output the content type and subtype
        */
-       np = getcpy(TYPE_FIELD);
+       np = mh_xstrdup(TYPE_FIELD);
        vp = concat(" ", ci->ci_type, "/", ci->ci_subtype, NULL);
 
        /* keep track of length of line */
@@ -1501,7 +1501,7 @@ build_headers(CT ct)
        ** output the Content-ID
        */
        if (ct->c_id) {
-               np = getcpy(ID_FIELD);
+               np = mh_xstrdup(ID_FIELD);
                vp = concat(" ", ct->c_id, NULL);
                add_header(ct, np, vp);
        }
@@ -1510,7 +1510,7 @@ build_headers(CT ct)
        ** output the Content-Description
        */
        if (ct->c_descr) {
-               np = getcpy(DESCR_FIELD);
+               np = mh_xstrdup(DESCR_FIELD);
                vp = concat(" ", ct->c_descr, NULL);
                if (encode_rfc2047(DESCR_FIELD, &vp, NULL)) {
                        adios(EX_DATAERR, NULL, "Unable to encode %s header", DESCR_FIELD);
@@ -1522,7 +1522,7 @@ build_headers(CT ct)
        ** output the Content-Disposition
        */
        if (ct->c_dispo) {
-               np = getcpy(DISPO_FIELD);
+               np = mh_xstrdup(DISPO_FIELD);
                vp = concat(" ", ct->c_dispo, NULL);
                add_header(ct, np, vp);
        }
@@ -1539,7 +1539,7 @@ build_headers(CT ct)
                if (ct->c_type == CT_MESSAGE)
                        adios(EX_DATAERR, NULL, "internal error, invalid encoding");
 
-               np = getcpy(ENCODING_FIELD);
+               np = mh_xstrdup(ENCODING_FIELD);
                vp = concat(" ", "8bit", "\n", NULL);
                add_header(ct, np, vp);
                break;
@@ -1548,7 +1548,7 @@ build_headers(CT ct)
                if (ct->c_type == CT_MESSAGE || ct->c_type == CT_MULTIPART)
                        adios(EX_DATAERR, NULL, "internal error, invalid encoding");
 
-               np = getcpy(ENCODING_FIELD);
+               np = mh_xstrdup(ENCODING_FIELD);
                vp = concat(" ", "quoted-printable", "\n", NULL);
                add_header(ct, np, vp);
                break;
@@ -1557,7 +1557,7 @@ build_headers(CT ct)
                if (ct->c_type == CT_MESSAGE || ct->c_type == CT_MULTIPART)
                        adios(EX_DATAERR, NULL, "internal error, invalid encoding");
 
-               np = getcpy(ENCODING_FIELD);
+               np = mh_xstrdup(ENCODING_FIELD);
                vp = concat(" ", "base64", "\n", NULL);
                add_header(ct, np, vp);
                break;
@@ -1566,7 +1566,7 @@ build_headers(CT ct)
                if (ct->c_type == CT_MESSAGE)
                        adios(EX_DATAERR, NULL, "internal error, invalid encoding");
 
-               np = getcpy(ENCODING_FIELD);
+               np = mh_xstrdup(ENCODING_FIELD);
                vp = concat(" ", "binary", "\n", NULL);
                add_header(ct, np, vp);
                break;
index c87306691f453bb4a6753700c4eab7a8738a4dc3..5378c35c0a4e174e759b1edc2e773b051af45cbb 100644 (file)
@@ -8,6 +8,7 @@
 */
 
 #include <h/mh.h>
+#include <h/utils.h>
 #include <errno.h>
 #include <h/mime.h>
 #include <h/mhparse.h>
@@ -49,13 +50,13 @@ free_content(CT ct)
        free_header(ct);
 
        if (ct->c_partno)
-               free(ct->c_partno);
+               mh_free0(&(ct->c_partno));
 
        if (ct->c_vrsn)
-               free(ct->c_vrsn);
+               mh_free0(&(ct->c_vrsn));
 
        if (ct->c_ctline)
-               free(ct->c_ctline);
+               mh_free0(&(ct->c_ctline));
 
        free_ctinfo(ct);
 
@@ -80,39 +81,39 @@ free_content(CT ct)
        }
 
        if (ct->c_charset)
-               free(ct->c_charset);
+               mh_free0(&(ct->c_charset));
        if (ct->c_showproc)
-               free(ct->c_showproc);
+               mh_free0(&(ct->c_showproc));
        if (ct->c_storeproc)
-               free(ct->c_storeproc);
+               mh_free0(&(ct->c_storeproc));
 
        if (ct->c_celine)
-               free(ct->c_celine);
+               mh_free0(&(ct->c_celine));
 
        /* free structures for content encodings */
        free_encoding(ct, 1);
 
        if (ct->c_id)
-               free(ct->c_id);
+               mh_free0(&(ct->c_id));
        if (ct->c_descr)
-               free(ct->c_descr);
+               mh_free0(&(ct->c_descr));
        if (ct->c_dispo)
-               free(ct->c_dispo);
+               mh_free0(&(ct->c_dispo));
 
        if (ct->c_file) {
                if (ct->c_unlink)
                        unlink(ct->c_file);
-               free(ct->c_file);
+               mh_free0(&(ct->c_file));
        }
        if (ct->c_fp)
                fclose(ct->c_fp);
 
        if (ct->c_storage)
-               free(ct->c_storage);
+               mh_free0(&(ct->c_storage));
        if (ct->c_folder)
-               free(ct->c_folder);
+               mh_free0(&(ct->c_folder));
 
-       free(ct);
+       mh_free0(&ct);
 }
 
 
@@ -130,9 +131,9 @@ free_header(CT ct)
        while (hp1) {
                hp2 = hp1->next;
 
-               free(hp1->name);
-               free(hp1->value);
-               free(hp1);
+               mh_free0(&(hp1->name));
+               mh_free0(&(hp1->value));
+               mh_free0(&hp1);
 
                hp1 = hp2;
        }
@@ -150,24 +151,19 @@ free_ctinfo(CT ct)
 
        ci = &ct->c_ctinfo;
        if (ci->ci_type) {
-               free(ci->ci_type);
-               ci->ci_type = NULL;
+               mh_free0(&(ci->ci_type));
        }
        if (ci->ci_subtype) {
-               free(ci->ci_subtype);
-               ci->ci_subtype = NULL;
+               mh_free0(&(ci->ci_subtype));
        }
        for (ap = ci->ci_attrs; *ap; ap++) {
-               free(*ap);
-               *ap = NULL;
+               mh_free0(ap);
        }
        if (ci->ci_comment) {
-               free(ci->ci_comment);
-               ci->ci_comment = NULL;
+               mh_free0(&(ci->ci_comment));
        }
        if (ci->ci_magic) {
-               free(ci->ci_magic);
-               ci->ci_magic = NULL;
+               mh_free0(&(ci->ci_magic));
        }
 }
 
@@ -180,8 +176,7 @@ free_text(CT ct)
        if (!(t = (struct text *) ct->c_ctparams))
                return;
 
-       free((char *) t);
-       ct->c_ctparams = NULL;
+       mh_free0(&t);
 }
 
 
@@ -195,19 +190,17 @@ free_multi(CT ct)
                return;
 
        if (m->mp_start)
-               free(m->mp_start);
+               mh_free0(&(m->mp_start));
        if (m->mp_stop)
-               free(m->mp_stop);
+               mh_free0(&(m->mp_stop));
 
        for (part = m->mp_parts; part; part = next) {
                next = part->mp_next;
                free_content(part->mp_part);
-               free((char *) part);
+               mh_free0(&part);
        }
-       m->mp_parts = NULL;
 
-       free((char *) m);
-       ct->c_ctparams = NULL;
+       mh_free0(&m);
 }
 
 
@@ -220,10 +213,9 @@ free_partial(CT ct)
                return;
 
        if (p->pm_partid)
-               free(p->pm_partid);
+               mh_free0(&(p->pm_partid));
 
-       free((char *) p);
-       ct->c_ctparams = NULL;
+       mh_free0(&p);
 }
 
 
@@ -248,13 +240,11 @@ free_encoding(CT ct, int toplevel)
        if (ce->ce_file) {
                if (ce->ce_unlink)
                        unlink(ce->ce_file);
-               free(ce->ce_file);
-               ce->ce_file = NULL;
+               mh_free0(&(ce->ce_file));
        }
 
        if (toplevel) {
-               free((char *) ce);
-               ct->c_cefile = NULL;
+               mh_free0(&ce);
        } else {
                ct->c_ceopenfnx = NULL;
        }
index 8becba9bb1a50ecd874d9b558431f9387e63c902..c089d8e0bab3a6500b0a732d13d1aeb8bb44696a 100644 (file)
--- a/uip/mhl.c
+++ b/uip/mhl.c
@@ -369,7 +369,7 @@ mhl_format(char *file, int width)
                                int n = 0;
 
                                /* split the fields */
-                               tmparray = brkstring(getcpy(++parptr), ",",
+                               tmparray = brkstring(mh_xstrdup(++parptr), ",",
                                                NULL);
                                /*
                                ** copy pointers to split fields
@@ -400,10 +400,10 @@ mhl_format(char *file, int width)
                        if (!c1->c_fstr && global.c_fstr) {
                                if ((c1->c_flags & DATEFMT) &&
                                                (global.c_flags & DATEFMT)) {
-                                       c1->c_fstr = getcpy(global.c_fstr);
+                                       c1->c_fstr = mh_xstrdup(global.c_fstr);
                                } else if ((c1->c_flags & ADDRFMT) &&
                                                (global.c_flags & ADDRFMT)) {
-                                       c1->c_fstr = getcpy(global.c_fstr);
+                                       c1->c_fstr = mh_xstrdup(global.c_fstr);
                                }
                        }
                        continue;
@@ -458,8 +458,8 @@ evalvar(struct mcomp *c1)
                        return 1;
                cp = concat("=", cp, NULL);
                fmtstr = new_fs(cp, NULL);
-               free(cp);
-               c1->c_fstr = getcpy(fmtstr);
+               mh_free0(&cp);
+               c1->c_fstr = mh_xstrdup(fmtstr);
                c1->c_flags |= FORMAT;
                return 0;
        }
@@ -468,7 +468,7 @@ evalvar(struct mcomp *c1)
                char *fmtstr;
 
                fmtstr = new_fs("=%(decode{text})", NULL);
-               c1->c_fstr = getcpy(fmtstr);
+               c1->c_fstr = mh_xstrdup(fmtstr);
                c1->c_flags |= FORMAT;
                return 0;
        }
@@ -530,7 +530,7 @@ ptos(char *name, char **s)
        }
        c = *parptr;
        *parptr = 0;
-       *s = getcpy(cp);
+       *s = mh_xstrdup(cp);
        if ((*parptr = c) == '"')
                parptr++;
        return 0;
@@ -586,8 +586,7 @@ process(char *fname, int ofilen, int ofilec)
        if (fp != stdin)
                fclose(fp);
        if (holder.c_text) {
-               free(holder.c_text);
-               holder.c_text = NULL;
+               mh_free0(&(holder.c_text));
        }
        free_queue(&msghd, &msgtl);
        for (c1 = fmthd; c1; c1 = c1->c_next)
@@ -661,8 +660,7 @@ mhlfile(FILE *fp, char *mname, int ofilen, int ofilec)
                                        holder.c_text = concat("(Message ",
                                                        mname, ")\n", NULL);
                                        putcomp(c1, &holder, ONECOMP);
-                                       free(holder.c_text);
-                                       holder.c_text = NULL;
+                                       mh_free0(&(holder.c_text));
                                        continue;
                                }
                                if (mh_strcasecmp(c1->c_name, "extras")==0) {
@@ -674,15 +672,14 @@ mhlfile(FILE *fp, char *mname, int ofilen, int ofilec)
                                        continue;
                                }
                                if (dobody && mh_strcasecmp(c1->c_name, "body")==0) {
-                                       holder.c_text = getcpy(f.value);
+                                       holder.c_text = mh_xstrdup(f.value);
                                        while (state == BODY2) {
                                                putcomp(c1, &holder, BODYCOMP);
                                                state = m_getfld2(state, &f, fp);
                                                free(holder.c_text);
-                                               holder.c_text = getcpy(f.value);
+                                               holder.c_text = mh_xstrdup(f.value);
                                        }
-                                       free(holder.c_text);
-                                       holder.c_text = NULL;
+                                       mh_free0(&(holder.c_text));
                                        continue;
                                }
                                for (c2 = msghd; c2; c2 = c2->c_next) {
@@ -776,21 +773,21 @@ mcomp_format(struct mcomp *c1, struct mcomp *c2)
 
                fmt_scan(c1->c_fmt, buffer, sizeof(buffer) - 1, dat);
                /* Don't need to append a newline, dctime() already did */
-               c2->c_text = getcpy(buffer);
+               c2->c_text = mh_xstrdup(buffer);
 
-               free(ap);
+               mh_free0(&ap);
                return;
        }
 
        (q = &pq)->pq_next = NULL;
        while ((cp = getname(ap))) {
-               p = (struct pqpair *) mh_xcalloc((size_t) 1, sizeof(*p));
+               p = mh_xcalloc(1, sizeof(*p));
 
                if ((mp = getm(cp, NULL, 0, AD_NAME, error)) == NULL) {
-                       p->pq_text = getcpy(cp);
-                       p->pq_error = getcpy(error);
+                       p->pq_text = mh_xstrdup(cp);
+                       p->pq_error = mh_xstrdup(error);
                } else {
-                       p->pq_text = getcpy(mp->m_text);
+                       p->pq_text = mh_xstrdup(mp->m_text);
                        mnfree(mp);
                }
                q = (q->pq_next = p);
@@ -813,11 +810,11 @@ mcomp_format(struct mcomp *c1, struct mcomp *c2)
                        c2->c_text = add(buffer, c2->c_text);
                }
 
-               free(p->pq_text);
+               mh_free0(&(p->pq_text));
                if (p->pq_error)
-                       free(p->pq_error);
+                       mh_free0(&(p->pq_error));
                q = p->pq_next;
-               free((char *) p);
+               mh_free0(&p);
        }
 
        c2->c_text = add("\n", c2->c_text);
@@ -831,15 +828,15 @@ add_queue(struct mcomp **head, struct mcomp **tail, char *name,
 {
        struct mcomp *c1;
 
-       c1 = (struct mcomp *) mh_xcalloc((size_t) 1, sizeof(*c1));
+       c1 = mh_xcalloc(1, sizeof(*c1));
 
        c1->c_flags = flags & ~INIT;
-       if ((c1->c_name = name ? getcpy(name) : NULL))
+       if ((c1->c_name = name ? mh_xstrdup(name) : NULL))
                c1->c_flags |= mcomp_flags(c1->c_name);
-       c1->c_text = text ? getcpy(text) : NULL;
+       c1->c_text = text ? mh_xstrdup(text) : NULL;
        if (flags & INIT) {
                if (global.c_ovtxt)
-                       c1->c_ovtxt = getcpy(global.c_ovtxt);
+                       c1->c_ovtxt = mh_xstrdup(global.c_ovtxt);
                c1->c_offset = global.c_offset;
                c1->c_ovoff = global. c_ovoff;
                c1->c_width = 0;
@@ -864,16 +861,16 @@ free_queue(struct mcomp **head, struct mcomp **tail)
        for (c1 = *head; c1; c1 = c2) {
                c2 = c1->c_next;
                if (c1->c_name)
-                       free(c1->c_name);
+                       mh_free0(&(c1->c_name));
                if (c1->c_text)
-                       free(c1->c_text);
+                       mh_free0(&(c1->c_text));
                if (c1->c_ovtxt)
-                       free(c1->c_ovtxt);
+                       mh_free0(&(c1->c_ovtxt));
                if (c1->c_fstr)
-                       free(c1->c_fstr);
+                       mh_free0(&(c1->c_fstr));
                if (c1->c_fmt)
-                       free((char *) c1->c_fmt);
-               free((char *) c1);
+                       mh_free0(&(c1->c_fmt));
+               mh_free0(&c1);
        }
 
        *head = *tail = NULL;
index 6d7b8e7a6a594a32d56416864e0a61eedb4eeed4..c9194cc090b0fcf7e3a0d2b27335853945257241 100644 (file)
@@ -151,7 +151,7 @@ main(int argc, char **argv)
                                if (!(cp = *argp++) || (*cp == '-' && cp[1]))
                                        adios(EX_USAGE, NULL, "missing argument to %s",
                                                        argp[-2]);
-                               file = *cp == '-' ? cp : getcpy(expanddir(cp));
+                               file = *cp == '-' ? cp : mh_xstrdup(expanddir(cp));
                                continue;
 
                        case VERBSW:
@@ -169,7 +169,7 @@ main(int argc, char **argv)
                        if (folder)
                                adios(EX_USAGE, NULL, "only one folder at a time!");
                        else
-                               folder = getcpy(expandfol(cp));
+                               folder = mh_xstrdup(expandfol(cp));
                } else
                        app_msgarg(&msgs, cp);
        }
@@ -188,7 +188,7 @@ main(int argc, char **argv)
        if ((cp = context_find(nmhstorage)) && *cp)
                tmp = concat(cp, "/", invo_name, NULL);
        else
-               tmp = getcpy(toabsdir(invo_name));
+               tmp = mh_xstrdup(toabsdir(invo_name));
 
        if (file && msgs.size)
                adios(EX_USAGE, NULL, "cannot specify msg and file at same time!");
@@ -197,7 +197,7 @@ main(int argc, char **argv)
        ** check if message is coming from file
        */
        if (file) {
-               cts = (CT *) mh_xcalloc((size_t) 2, sizeof(*cts));
+               cts = mh_xcalloc(2, sizeof(*cts));
                ctp = cts;
 
                if ((ct = parse_mime(file)))
@@ -231,8 +231,7 @@ main(int argc, char **argv)
                }
                seq_setprev(mp);  /* set the previous-sequence */
 
-               cts = (CT *) mh_xcalloc((size_t) (mp->numsel + 1),
-                               sizeof(*cts));
+               cts = mh_xcalloc(mp->numsel + 1, sizeof(*cts));
                ctp = cts;
 
                for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
@@ -277,8 +276,7 @@ main(int argc, char **argv)
        for (ctp = cts; *ctp; ctp++)
                free_content(*ctp);
 
-       free((char *) cts);
-       cts = NULL;
+       mh_free0(&cts);
 
        /* If reading from a folder, do some updating */
        if (mp) {
index 2a4f5041e9788c6110078336ae3c28e535c738ea..dd6264bf53e6c164902315babb51013ef7598cfe 100644 (file)
@@ -174,11 +174,10 @@ list_content(CT ct, int toplevel, int verbose, int debug)
        /* print Content-Description */
        if (ct->c_descr) {
                char *dp;
-
-               dp = trimcpy(cp = getcpy(ct->c_descr));
-               free(cp);
+               dp = trimcpy(cp = mh_xstrdup(ct->c_descr));
+               mh_free0(&cp);
                printf(LSTFMT2d1, dp);
-               free(dp);
+               mh_free0(&dp);
        }
 
        printf("\n");
@@ -201,7 +200,7 @@ list_content(CT ct, int toplevel, int verbose, int debug)
                        dp = trimcpy(cp = add(ci->ci_comment, NULL));
                        free (cp);
                        snprintf(buffer, sizeof(buffer), "(%s)", dp);
-                       free(dp);
+                       mh_free0(&dp);
                        printf(LSTFMT2d2, buffer);
                }
        }
index 1515858b0e9733bc852b6b5fc2e1927e8c1ed363..06630b3bce882711d03b8eed3d2b6c73f065a44f 100644 (file)
@@ -107,10 +107,10 @@ main(int argc, char **argv)
                }
                if (iscc)
                        cclist = cclist ? add(cp, add(", ", cclist)) :
-                                       getcpy(cp);
+                                       mh_xstrdup(cp);
                else
                        tolist = tolist ? add(cp, add(", ", tolist)) :
-                                       getcpy(cp);
+                                       mh_xstrdup(cp);
        }
 
        if (tolist == NULL)
index 0f0a8d60682ccd1ad772bf08054aeee5f348d5b7..eb29e833616e29a89f74958da6e59e893dcbd8d1 100644 (file)
@@ -121,7 +121,7 @@ losing_directory:
 
                        ep = concat("Create directory \"", file, "\"? ", NULL);
                        answer = getanswer(ep);
-                       free(ep);
+                       mh_free0(&ep);
 
                        if (!answer)
                                goto losing_directory;
@@ -237,7 +237,6 @@ flush_errors(void)
        if (errs) {
                fflush(stdout);
                fprintf(stderr, "%s", errs);
-               free(errs);
-               errs = NULL;
+               mh_free0(&errs);
        }
 }
index 76fe4279998e4557aabc6fdef7aa28ea30f459ea..29d4170df4ac251c32c0957c78f8753cf51d8b12 100644 (file)
@@ -98,6 +98,7 @@ static struct proc procs [] = {
        { "replgroupcomps",    &replgroupcomps },
        { "mhlformat",         &mhlformat },
        { "mhlreply",          &mhlreply },
+       { "scanformat",        &scanformat },
 
        { "#--Default-Sequence-Names--", &empty },
        { "seq-all",           &seq_all },
index 257bc66e914318154a612af0a0a77f26bfb6c2b0..67d769caf01ea497d3ec1a2056c50b2a7a0c7c20 100644 (file)
@@ -166,7 +166,7 @@ parse_mime(char *file)
                        advise("mhparse", "unable to create temporary file");
                        return NULL;
                }
-               file = getcpy(tfile);
+               file = mh_xstrdup(tfile);
                chmod(file, 0600);
 
                while (fgets(buffer, sizeof(buffer), stdin))
@@ -238,10 +238,10 @@ get_content(FILE *in, char *file, int toplevel)
        HF hp;
 
        /* allocate the content structure */
-       ct = (CT) mh_xcalloc(1, sizeof(*ct));
+       ct = mh_xcalloc(1, sizeof(*ct));
 
        ct->c_fp = in;
-       ct->c_file = getcpy(file);
+       ct->c_file = mh_xstrdup(file);
        ct->c_begin = ftell(ct->c_fp) + 1;
 
        /*
@@ -254,7 +254,7 @@ get_content(FILE *in, char *file, int toplevel)
                        compnum++;
 
                        /* add the header data to the list */
-                       add_header(ct, getcpy(f.name), getcpy(f.value));
+                       add_header(ct, mh_xstrdup(f.name), mh_xstrdup(f.value));
 
                        ct->c_begin = ftell(in) + 1;
                        continue;
@@ -298,7 +298,7 @@ get_content(FILE *in, char *file, int toplevel)
                                advise(NULL, "message %s has multiple %s: fields", ct->c_file, VRSN_FIELD);
                                goto next_header;
                        }
-                       ct->c_vrsn = getcpy(hp->value);
+                       ct->c_vrsn = mh_xstrdup(hp->value);
 
                        /* Now, cleanup this field */
                        cp = ct->c_vrsn;
@@ -370,7 +370,7 @@ get_content(FILE *in, char *file, int toplevel)
                        }
 
                        /* get copy of this field */
-                       ct->c_celine = cp = getcpy(hp->value);
+                       ct->c_celine = cp = mh_xstrdup(hp->value);
 
                        while (isspace(*cp))
                                cp++;
@@ -462,7 +462,7 @@ add_header(CT ct, char *name, char *value)
        HF hp;
 
        /* allocate header field structure */
-       hp = mh_xmalloc(sizeof(*hp));
+       hp = mh_xcalloc(1, sizeof(*hp));
 
        /* link data into header structure */
        hp->name = name;
@@ -517,24 +517,24 @@ incl_name_value(unsigned char *buf, char *name, char *value) {
                        ** Insert at first semicolon, if any.
                        ** If none, append to end.
                        */
-                       prefix = getcpy(buf);
+                       prefix = mh_xstrdup(buf);
                        if ((cp = strchr(prefix, ';'))) {
                                suffix = concat(cp, NULL);
                                *cp = '\0';
                                newbuf = concat(prefix, insertion, suffix,
                                                "\n", NULL);
-                               free(suffix);
+                               mh_free0(&suffix);
                        } else {
                                /* Append to end. */
                                newbuf = concat(buf, insertion, "\n", NULL);
                        }
 
-                       free(prefix);
-                       free(insertion);
-                       free(buf);
+                       mh_free0(&prefix);
+                       mh_free0(&insertion);
+                       mh_free0(&buf);
                }
 
-               free(name_plus_equal);
+               mh_free0(&name_plus_equal);
        }
 
        return newbuf;
@@ -552,7 +552,7 @@ extract_name_value(char *name_suffix, char *value) {
        char *name_suffix_equals = strstr(value, name_suffix_plus_quote);
        char *cp;
 
-       free(name_suffix_plus_quote);
+       mh_free0(&name_suffix_plus_quote);
        if (name_suffix_equals) {
                char *name_suffix_begin;
 
@@ -564,7 +564,7 @@ extract_name_value(char *name_suffix, char *value) {
                for (; *cp != '"'; ++cp)
                        ;
 
-               extracted_name_value = mh_xmalloc(cp - name_suffix_begin + 1);
+               extracted_name_value = mh_xcalloc(cp - name_suffix_begin + 1, sizeof(char));
                memcpy(extracted_name_value, name_suffix_begin,
                                cp - name_suffix_begin);
                extracted_name_value[cp - name_suffix_begin] = '\0';
@@ -590,7 +590,7 @@ get_ctinfo(unsigned char *cp, CT ct, int magic)
        i = strlen(invo_name) + 2;
 
        /* store copy of Content-Type line */
-       cp = ct->c_ctline = getcpy(cp);
+       cp = ct->c_ctline = mh_xstrdup(cp);
 
        while (isspace(*cp))  /* trim leading spaces */
                cp++;
@@ -614,7 +614,7 @@ get_ctinfo(unsigned char *cp, CT ct, int magic)
        for (dp = cp; istoken(*dp); dp++)
                continue;
        c = *dp, *dp = '\0';
-       ci->ci_type = getcpy(cp);  /* store content type */
+       ci->ci_type = mh_xstrdup(cp);  /* store content type */
        *dp = c, cp = dp;
 
        if (!*ci->ci_type) {
@@ -636,7 +636,7 @@ get_ctinfo(unsigned char *cp, CT ct, int magic)
 
        if (*cp != '/') {
                if (!magic)
-                       ci->ci_subtype = getcpy("");
+                       ci->ci_subtype = mh_xstrdup("");
                goto magic_skip;
        }
 
@@ -650,7 +650,7 @@ get_ctinfo(unsigned char *cp, CT ct, int magic)
        for (dp = cp; istoken(*dp); dp++)
                continue;
        c = *dp, *dp = '\0';
-       ci->ci_subtype = getcpy(cp);  /* store the content subtype */
+       ci->ci_subtype = mh_xstrdup(cp);  /* store the content subtype */
        *dp = c, cp = dp;
 
        if (!*ci->ci_subtype) {
@@ -707,7 +707,7 @@ magic_skip:
                        return NOTOK;
                }
 
-               vp = (*ap = getcpy(cp)) + (up - cp);
+               vp = (*ap = mh_xstrdup(cp)) + (up - cp);
                *vp = '\0';
                for (dp++; isspace(*dp);)
                        dp++;
@@ -764,8 +764,7 @@ bad_quote:
        */
        if (magic && *cp == '<') {
                if (ct->c_id) {
-                       free(ct->c_id);
-                       ct->c_id = NULL;
+                       mh_free0(&(ct->c_id));
                }
                if (!(dp = strchr(ct->c_id = ++cp, '>'))) {
                        advise(NULL, "invalid ID in message %s", ct->c_file);
@@ -845,7 +844,7 @@ bad_quote:
        */
        if (*cp) {
                if (magic) {
-                       ci->ci_magic = getcpy(cp);
+                       ci->ci_magic = mh_xstrdup(cp);
 
                        /*
                        ** If there is a Content-Disposition header and
@@ -912,9 +911,9 @@ invalid:
        if (istype) {
                if ((dp = ci->ci_comment)) {
                        ci->ci_comment = concat(dp, " ", buffer, NULL);
-                       free(dp);
+                       mh_free0(&dp);
                } else {
-                       ci->ci_comment = getcpy(buffer);
+                       ci->ci_comment = mh_xstrdup(buffer);
                }
        }
 
@@ -963,7 +962,7 @@ InitText(CT ct)
        ct->c_subtype = kv->kv_value;
 
        /* allocate text character set structure */
-       t = (struct text *) mh_xcalloc(1, sizeof(*t));
+       t = mh_xcalloc(1, sizeof(*t));
        ct->c_ctparams = (void *) t;
 
        /* scan for charset parameter */
@@ -974,7 +973,7 @@ InitText(CT ct)
        /* check if content specified a character set */
        if (*ap) {
                /* store its name */
-               ct->c_charset = getcpy(norm_charmap(*ep));
+               ct->c_charset = mh_xstrdup(norm_charmap(*ep));
                /* match character set or set to CHARSET_UNKNOWN */
                for (kv = Charset; kv->kv_key; kv++) {
                        if (!mh_strcasecmp(*ep, kv->kv_key)) {
@@ -1044,7 +1043,7 @@ InitMultiPart(CT ct)
        }
 
        /* allocate primary structure for multipart info */
-       m = (struct multipart *) mh_xcalloc(1, sizeof(*m));
+       m = mh_xcalloc(1, sizeof(*m));
        ct->c_ctparams = (void *) m;
 
        /* check if boundary parameter contains only whitespace characters */
@@ -1087,7 +1086,7 @@ InitMultiPart(CT ct)
                        if (strcmp(buffer + 2, m->mp_start)!=0)
                                continue;
 next_part:
-                       part = (struct part *) mh_xcalloc(1, sizeof(*part));
+                       part = mh_xcalloc(1, sizeof(*part));
                        *next = part;
                        next = &part->mp_next;
 
@@ -1130,7 +1129,7 @@ end_part:
                                continue;
                        *next = NULL;
                        free_content(p);
-                       free((char *) part);
+                       mh_free0(&part);
                }
        }
 
@@ -1161,7 +1160,7 @@ last_part:
                        p = part->mp_part;
 
                        sprintf(pp, "%d", partnum);
-                       p->c_partno = getcpy(partnam);
+                       p->c_partno = mh_xstrdup(partnam);
 
                        /* initialize the content of the subparts */
                        if (p->c_ctinitfnx && (*p->c_ctinitfnx) (p) == NOTOK) {
@@ -1201,7 +1200,7 @@ reverse_parts(CT ct)
                i++;
 
        /* allocate array of pointers to the parts */
-       base = (struct part **) mh_xcalloc((size_t) (i + 1), sizeof(*base));
+       base = mh_xcalloc(i + 1, sizeof(*base));
        bmp = base;
 
        /* point at all the parts */
@@ -1219,7 +1218,7 @@ reverse_parts(CT ct)
        *next = NULL;
 
        /* free array of pointers */
-       free((char *) base);
+       mh_free0(&base);
 }
 
 
@@ -1257,7 +1256,7 @@ InitMessage(CT ct)
                char **ap, **ep;
                struct partial *p;
 
-               p = (struct partial *) mh_xcalloc(1, sizeof(*p));
+               p = mh_xcalloc(1, sizeof(*p));
                ct->c_ctparams = (void *) p;
 
                /*
@@ -1266,7 +1265,7 @@ InitMessage(CT ct)
                */
                for (ap = ci->ci_attrs, ep = ci->ci_values; *ap; ap++, ep++) {
                        if (!mh_strcasecmp(*ap, "id")) {
-                               p->pm_partid = getcpy(*ep);
+                               p->pm_partid = mh_xstrdup(*ep);
                                continue;
                        }
                        if (!mh_strcasecmp(*ap, "number")) {
@@ -1369,7 +1368,7 @@ init_encoding(CT ct, OpenCEFunc openfnx)
 {
        CE ce;
 
-       ce = (CE) mh_xcalloc(1, sizeof(*ce));
+       ce = mh_xcalloc(1, sizeof(*ce));
 
        ct->c_cefile     = ce;
        ct->c_ceopenfnx  = openfnx;
@@ -1499,10 +1498,10 @@ openBase64(CT ct, char **file)
        }
 
        if (*file == NULL) {
-               ce->ce_file = getcpy(m_mktemp(tmp, NULL, NULL));
+               ce->ce_file = mh_xstrdup(m_mktemp(tmp, NULL, NULL));
                ce->ce_unlink = 1;
        } else {
-               ce->ce_file = getcpy(*file);
+               ce->ce_file = mh_xstrdup(*file);
                ce->ce_unlink = 0;
        }
 
@@ -1522,13 +1521,13 @@ openBase64(CT ct, char **file)
                        ** Temporary file already exists, so we rename to
                        ** version with extension.
                        */
-                       char *file_org = strdup(ce->ce_file);
+                       char *file_org = mh_xstrdup(ce->ce_file);
                        ce->ce_file = add(cp, ce->ce_file);
                        if (rename(file_org, ce->ce_file)) {
                                adios(EX_IOERR, ce->ce_file, "unable to rename %s to ",
                                                file_org);
                        }
-                       free(file_org);
+                       mh_free0(&file_org);
 
                } else {
                        ce->ce_file = add(cp, ce->ce_file);
@@ -1710,10 +1709,10 @@ openQuoted(CT ct, char **file)
        }
 
        if (*file == NULL) {
-               ce->ce_file = getcpy(m_mktemp(tmp, NULL, NULL));
+               ce->ce_file = mh_xstrdup(m_mktemp(tmp, NULL, NULL));
                ce->ce_unlink = 1;
        } else {
-               ce->ce_file = getcpy(*file);
+               ce->ce_file = mh_xstrdup(*file);
                ce->ce_unlink = 0;
        }
 
@@ -1733,13 +1732,13 @@ openQuoted(CT ct, char **file)
                        ** Temporary file already exists, so we rename to
                        ** version with extension.
                        */
-                       char *file_org = strdup(ce->ce_file);
+                       char *file_org = mh_xstrdup(ce->ce_file);
                        ce->ce_file = add(cp, ce->ce_file);
                        if (rename(file_org, ce->ce_file)) {
                                adios(EX_IOERR, ce->ce_file, "unable to rename %s to ",
                                                file_org);
                        }
-                       free(file_org);
+                       mh_free0(&file_org);
 
                } else {
                        ce->ce_file = add(cp, ce->ce_file);
@@ -1927,10 +1926,10 @@ open7Bit(CT ct, char **file)
        }
 
        if (*file == NULL) {
-               ce->ce_file = getcpy(m_mktemp(tmp, NULL, NULL));
+               ce->ce_file = mh_xstrdup(m_mktemp(tmp, NULL, NULL));
                ce->ce_unlink = 1;
        } else {
-               ce->ce_file = getcpy(*file);
+               ce->ce_file = mh_xstrdup(*file);
                ce->ce_unlink = 0;
        }
 
@@ -1950,13 +1949,13 @@ open7Bit(CT ct, char **file)
                        ** Temporary file already exists, so we rename to
                        ** version with extension.
                        */
-                       char *file_org = strdup(ce->ce_file);
+                       char *file_org = mh_xstrdup(ce->ce_file);
                        ce->ce_file = add(cp, ce->ce_file);
                        if (rename(file_org, ce->ce_file)) {
                                adios(EX_IOERR, ce->ce_file, "unable to rename %s to ",
                                                file_org);
                        }
-                       free(file_org);
+                       mh_free0(&file_org);
 
                } else {
                        ce->ce_file = add(cp, ce->ce_file);
index c400fa6dfef22f1c2eab493480c5f20f33058f59..aa63f4d73cba9190191792997bc4884572a45fad 100644 (file)
@@ -64,7 +64,7 @@ main(int argc, char **argv)
                        if (folder) {
                                adios(EX_USAGE, NULL, "only one folder at a time!");
                        } else {
-                               folder = getcpy(expandfol(cp));
+                               folder = mh_xstrdup(expandfol(cp));
                        }
                } else {
                        app_msgarg(&msgs, cp);
index bb03939cce43e199722234c2b963e4c6909f98f6..e39bf65af13cbd687aff826d2e9e624124982bf4 100644 (file)
@@ -166,7 +166,7 @@ main(int argc, char **argv)
                                if (!(cp = *argp++) || (*cp == '-' && cp[1]))
                                        adios(EX_USAGE, NULL, "missing argument to %s",
                                                        argp[-2]);
-                               file = *cp == '-' ? cp : getcpy(expanddir(cp));
+                               file = *cp == '-' ? cp : mh_xstrdup(expanddir(cp));
                                continue;
 
                        case FORMSW:
@@ -174,8 +174,8 @@ main(int argc, char **argv)
                                        adios(EX_USAGE, NULL, "missing argument to %s",
                                                        argp[-2]);
                                if (formsw)
-                                       free(formsw);
-                               formsw = getcpy(etcpath(cp));
+                                       mh_free0(&formsw);
+                               formsw = mh_xstrdup(etcpath(cp));
                                continue;
 
                        case VERBSW:
@@ -193,7 +193,7 @@ main(int argc, char **argv)
                        if (folder)
                                adios(EX_USAGE, NULL, "only one folder at a time!");
                        else
-                               folder = getcpy(expandfol(cp));
+                               folder = mh_xstrdup(expandfol(cp));
                } else if (mode != SHOW) {
                        adios(EX_USAGE, NULL, "Either call show as `%s' or give message arguments", invo_name);
                } else {
@@ -240,7 +240,7 @@ main(int argc, char **argv)
        if ((cp = context_find(nmhstorage)) && *cp)
                tmp = concat(cp, "/", invo_name, NULL);
        else
-               tmp = getcpy(toabsdir(invo_name));
+               tmp = mh_xstrdup(toabsdir(invo_name));
 
        if (file && msgs.size)
                adios(EX_USAGE, NULL, "cannot specify msg and file at same time!");
@@ -249,7 +249,7 @@ main(int argc, char **argv)
        ** check if message is coming from file
        */
        if (file) {
-               cts = (CT *) mh_xcalloc((size_t) 2, sizeof(*cts));
+               cts = mh_xcalloc(2, sizeof(*cts));
                ctp = cts;
 
                if ((ct = parse_mime(file)))
@@ -303,8 +303,7 @@ main(int argc, char **argv)
                seq_setprev(mp);  /* set the Previous-Sequence */
                seq_setunseen(mp, 0);  /* unset unseen seqs for shown msgs */
 
-               cts = (CT *) mh_xcalloc((size_t) (mp->numsel + 1),
-                               sizeof(*cts));
+               cts = mh_xcalloc(mp->numsel + 1, sizeof(*cts));
                ctp = cts;
 
                /*
@@ -360,8 +359,7 @@ main(int argc, char **argv)
        for (ctp = cts; *ctp; ctp++)
                free_content(*ctp);
 
-       free((char *) cts);
-       cts = NULL;
+       mh_free0(&cts);
 
        /* If reading from a folder, do some updating */
        if (mp) {
index aeaf0e8e0c76152d1adc01b14bebae795179da61..c7923c87db021f477770fc8c76484ccdd1198b71 100644 (file)
@@ -76,7 +76,7 @@ show_all_messages(CT *cts)
        ** for showing headers of MIME messages.
        */
        if (!formsw)
-               formsw = getcpy(etcpath("mhl.headers"));
+               formsw = mh_xstrdup(etcpath("mhl.headers"));
 
        /*
        ** If form is "mhl.null", suppress display of header.
@@ -332,7 +332,7 @@ show_content_aux(CT ct, int alternate, char *cp, char *cracked)
 
                                        s = trimcpy(ct->c_descr);
                                        strncpy(bp, s, buflen);
-                                       free(s);
+                                       mh_free0(&s);
                                }
                                break;
 
@@ -527,7 +527,7 @@ show_text(CT ct, int alternate)
                } else {
                        snprintf(buffer, sizeof(buffer), "%%lcat");
                }
-               ct->c_showproc = getcpy(buffer);
+               ct->c_showproc = mh_xstrdup(buffer);
                return show_content_aux(ct, alternate, ct->c_showproc, NULL);
        }
 
@@ -681,7 +681,7 @@ show_multi_aux(CT ct, int alternate, char *cp)
                                return NOTOK;
 
                        /* I'm not sure if this is necessary? */
-                       p->c_storage = getcpy(file);
+                       p->c_storage = mh_xstrdup(file);
 
                        if (p->c_showproc && strcmp(p->c_showproc, "true")==0)
                                return (alternate ? DONE : OK);
@@ -733,7 +733,7 @@ show_multi_aux(CT ct, int alternate, char *cp)
 
                                        s = trimcpy(ct->c_descr);
                                        strncpy(bp, s, buflen);
-                                       free(s);
+                                       mh_free0(&s);
                                }
                                break;
 
@@ -866,7 +866,7 @@ show_message_rfc822(CT ct, int alternate)
 
        /* default method for message/rfc822 */
        if (ct->c_subtype == MESSAGE_RFC822) {
-               cp = (ct->c_showproc = getcpy("%lshow -file %F"));
+               cp = (ct->c_showproc = mh_xstrdup("%lshow -file %F"));
                return show_content_aux(ct, alternate, cp, NULL);
        }
 
index 038052b368c7212f30543c6ddccdeea7d87ee601..17b7489394267a24d1d9e29a60d535b2845f5113 100755 (executable)
@@ -108,14 +108,17 @@ lookupkeys() {
                echo "Encryption is not supported for BCCs" >&2
                return 1
        fi
-               
-       for i in `whom -ali -tocc -nobcc "$1"` ; do
+
+       whom -ali -tocc -nobcc "$1" | while read i ; do
                case "$i" in
                '|'*)   echo "Ignoring pipe address" >&2
                        continue ;;
                *@*)    ;;
-               *)      i="$i@`hostname -f`" ;;
+               *)      a="$i@`hostname -f`" ;;
                esac
+               # extract the actual address
+               format='%<{error}%{error}: %{text}%|%(addr{text})%>'
+               i=`%libdir%/ap -form "=$format" "$i"`
                if k=`lookupkeyfile "$i"` ; then
                        KL="$KL $k"
                elif k=`lookupkeyring "$i"` ; then
index fae054fa1461075beb4b4ea7b2a5b5e3b886ba03..adaca774d191b82f486880013cfbc88c2e37533a 100644 (file)
@@ -195,7 +195,7 @@ main(int argc, char **argv)
                                if (!(cp = *argp++) || (*cp == '-' && cp[1]))
                                        adios(EX_USAGE, NULL, "missing argument to %s",
                                                        argp[-2]);
-                               file = *cp == '-' ? cp : getcpy(expanddir(cp));
+                               file = *cp == '-' ? cp : mh_xstrdup(expanddir(cp));
                                continue;
 
                        case DEBUGSW:
@@ -207,7 +207,7 @@ main(int argc, char **argv)
                        if (folder)
                                adios(EX_USAGE, NULL, "only one folder at a time!");
                        else
-                               folder = getcpy(expandfol(cp));
+                               folder = mh_xstrdup(expandfol(cp));
                } else
                        app_msgarg(&msgs, cp);
        }
@@ -242,7 +242,7 @@ main(int argc, char **argv)
        /*
        ** Cache the current directory before we do any chdirs()'s.
        */
-       cwd = getcpy(pwd());
+       cwd = mh_xstrdup(pwd());
 
        /*
        ** Check for storage directory.  If specified,
@@ -252,7 +252,7 @@ main(int argc, char **argv)
        if ((cp = context_find(nmhstorage)) && *cp)
                tmp = concat(cp, "/", invo_name, NULL);
        else
-               tmp = getcpy(toabsdir(invo_name));
+               tmp = mh_xstrdup(toabsdir(invo_name));
 
        if (file && msgs.size)
                adios(EX_USAGE, NULL, "cannot specify msg and file at same time!");
@@ -261,7 +261,7 @@ main(int argc, char **argv)
        ** check if message is coming from file
        */
        if (file) {
-               cts = (CT *) mh_xcalloc((size_t) 2, sizeof(*cts));
+               cts = mh_xcalloc(2, sizeof(*cts));
                ctp = cts;
 
                if ((ct = parse_mime(file)))
@@ -293,8 +293,7 @@ main(int argc, char **argv)
                                exit(EX_USAGE);
                seq_setprev(mp);  /* set the previous-sequence */
 
-               cts = (CT *) mh_xcalloc((size_t) (mp->numsel + 1),
-                               sizeof(*cts));
+               cts = mh_xcalloc(mp->numsel + 1, sizeof(*cts));
                ctp = cts;
 
                for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
@@ -339,8 +338,7 @@ main(int argc, char **argv)
        for (ctp = cts; *ctp; ctp++)
                free_content(*ctp);
 
-       free((char *) cts);
-       cts = NULL;
+       mh_free0(&cts);
 
        /* If reading from a folder, do some updating */
        if (mp) {
@@ -384,9 +382,9 @@ store_all_messages(CT *cts)
        ** store any contents.
        */
        if ((cp = context_find(nmhstorage)) && *cp)
-               dir = getcpy(cp);
+               dir = mh_xstrdup(cp);
        else
-               dir = getcpy(cwd);
+               dir = mh_xstrdup(cwd);
 
        for (ctp = cts; *ctp; ctp++) {
                ct = *ctp;
@@ -492,7 +490,7 @@ store_generic(CT ct)
                        if (*cp && *cp!='.' && *cp!='|' && *cp!='!' &&
                                        !strchr(cp, '%')) {
                                /* filename looks good: use it */
-                               ct->c_storeproc = getcpy(cp);
+                               ct->c_storeproc = mh_xstrdup(cp);
                        }
                        break;
                }
@@ -568,7 +566,7 @@ store_partial(CT ct)
                return NOTOK;
        }
 
-       base = (CT *) mh_xcalloc((size_t) (i + 1), sizeof(*base));
+       base = mh_xcalloc(i + 1, sizeof(*base));
 
        ctq = base;
        for (ctp = cts; *ctp; ctp++) {
@@ -614,7 +612,7 @@ missing_part:
        ct = *ctq++;
        if (store_content(ct, NULL) == NOTOK) {
 losing:
-               free((char *) base);
+               mh_free0(&base);
                return NOTOK;
        }
 
@@ -624,7 +622,7 @@ losing:
                        goto losing;
        }
 
-       free((char *) base);
+       mh_free0(&base);
        return OK;
 }
 
@@ -730,11 +728,11 @@ store_content(CT ct, CT p)
                */
                if (p) {
                        appending = 1;
-                       ct->c_storage = getcpy(p->c_storage);
+                       ct->c_storage = mh_xstrdup(p->c_storage);
 
                        /* record the folder name */
                        if (p->c_folder) {
-                               ct->c_folder = getcpy(p->c_folder);
+                               ct->c_folder = mh_xstrdup(p->c_folder);
                        }
                        goto got_filename;
                }
@@ -774,11 +772,11 @@ store_content(CT ct, CT p)
 
                /* Store content in temporary file for now */
                tmpfilenam = m_mktemp(invo_name, NULL, NULL);
-               ct->c_storage = getcpy(tmpfilenam);
+               ct->c_storage = mh_xstrdup(tmpfilenam);
 
                /* Get the folder name */
                if (cp[1])
-                       folder = getcpy(expandfol(cp));
+                       folder = mh_xstrdup(expandfol(cp));
                else
                        folder = getcurfol();
 
@@ -786,10 +784,10 @@ store_content(CT ct, CT p)
                create_folder(toabsdir(folder), 0, exit);
 
                /* Record the folder name */
-               ct->c_folder = getcpy(folder);
+               ct->c_folder = mh_xstrdup(folder);
 
                if (cp[1])
-                       free(folder);
+                       mh_free0(&folder);
 
                goto got_filename;
        }
@@ -808,7 +806,7 @@ store_content(CT ct, CT p)
                return show_content_aux(ct, 0, buffer + 1, dir);
 
        /* record the filename */
-       ct->c_storage = getcpy(buffer);
+       ct->c_storage = mh_xstrdup(buffer);
 
 got_filename:
        /* flush the output stream */
index dd456263796649b743a38adb305516bb6db5607c..cecf2ee562120dd9ff91fbcf2d41870840b2eccb 100644 (file)
@@ -153,14 +153,14 @@ main(int argc, char **argv)
                                if (!(cp = *argp++) || (*cp == '-' && cp[1]))
                                        adios(EX_USAGE, NULL, "missing argument to %s",
                                                        argp[-2]);
-                               file = *cp == '-' ? cp : getcpy(expanddir(cp));
+                               file = *cp == '-' ? cp : mh_xstrdup(expanddir(cp));
                                continue;
 
                        case OUTFILESW:
                                if (!(cp = *argp++) || (*cp == '-' && cp[1]))
                                        adios(EX_USAGE, NULL, "missing argument to %s",
                                                        argp[-2]);
-                               outfile = *cp == '-' ? cp : getcpy(expanddir(cp));
+                               outfile = *cp == '-' ? cp : mh_xstrdup(expanddir(cp));
                                continue;
 
                        case VERBSW:
@@ -178,7 +178,7 @@ main(int argc, char **argv)
                        if (folder)
                                adios(EX_USAGE, NULL, "only one folder at a time!");
                        else
-                               folder = getcpy(expandfol(cp));
+                               folder = mh_xstrdup(expandfol(cp));
                } else
                        app_msgarg(&msgs, cp);
        }
@@ -200,7 +200,7 @@ main(int argc, char **argv)
        if ((cp = context_find(nmhstorage)) && *cp)
                tmp = concat(cp, "/", invo_name, NULL);
        else
-               tmp = getcpy(toabsdir(invo_name));
+               tmp = mh_xstrdup(toabsdir(invo_name));
 
        if (file && msgs.size)
                adios(EX_USAGE, NULL, "cannot specify msg and file at same time!");
@@ -209,7 +209,7 @@ main(int argc, char **argv)
        ** check if message is coming from file
        */
        if (file) {
-               cts = (CT *) mh_xcalloc((size_t) 2, sizeof(*cts));
+               cts = mh_xcalloc(2, sizeof(*cts));
                ctp = cts;
 
                if ((ct = parse_mime(file)))
@@ -241,8 +241,7 @@ main(int argc, char **argv)
                                exit(EX_USAGE);
                seq_setprev(mp);  /* set the previous-sequence */
 
-               cts = (CT *) mh_xcalloc((size_t) (mp->numsel + 1),
-                               sizeof(*cts));
+               cts = mh_xcalloc(mp->numsel + 1, sizeof(*cts));
                ctp = cts;
 
                for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
@@ -287,8 +286,7 @@ main(int argc, char **argv)
        for (ctp = cts; *ctp; ctp++)
                free_content(*ctp);
 
-       free((char *) cts);
-       cts = NULL;
+       mh_free0(&cts);
 
        /* If reading from a folder, do some updating */
        if (mp) {
index a2be29bf0c2742cb6ecfaf68d050b7bf5c8c091f..4335892e0497b636421449498e882f67ddc741bf 100644 (file)
--- a/uip/new.c
+++ b/uip/new.c
@@ -55,7 +55,7 @@ count_messages(char *field)
        int j, k;
        char *cp, **ap;
 
-       field = getcpy(field);
+       field = mh_xstrdup(field);
 
        /* copied from seq_read.c:seq_init */
        for (ap = brkstring(field, " ", "\n"); *ap; ap++) {
@@ -68,7 +68,7 @@ count_messages(char *field)
                }
        }
 
-       free(field);
+       mh_free0(&field);
 
        return total;
 }
@@ -121,9 +121,9 @@ get_msgnums(char *folder, char *sequences[])
                                        old_msgnums = msgnums;
                                        msgnums = concat(old_msgnums, " ",
                                                        this_msgnums,
-                                                       (void *)NULL);
-                                       free(old_msgnums);
-                                       free(this_msgnums);
+                                                       NULL);
+                                       mh_free0(&old_msgnums);
+                                       mh_free0(&this_msgnums);
                                }
                        }
                        continue;
@@ -158,9 +158,9 @@ check_folder(char *folder, size_t len, struct list_state *b)
 
        if (is_cur || msgnums != NULL) {
                if (*b->first == NULL) {
-                       *b->first = b->node = mh_xmalloc(sizeof(*b->node));
+                       *b->first = b->node = mh_xcalloc(1, sizeof(*b->node));
                } else {
-                       b->node->n_next = mh_xmalloc(sizeof(*b->node));
+                       b->node->n_next = mh_xcalloc(1, sizeof(*b->node));
                        b->node = b->node->n_next;
                }
                b->node->n_name = folder;
@@ -229,7 +229,7 @@ check_folders(struct node **first, struct node **last,
                while (vfgets(fp, &line) == OK) {
                        len = strlen(line) - 1;
                        line[len] = '\0';
-                       check_folder(getcpy(line), len, &b);
+                       check_folder(mh_xstrdup(line), len, &b);
                }
                fclose(fp);
        }
@@ -251,7 +251,7 @@ join_sequences(char *sequences[])
        for (i = 0; sequences[i] != NULL; i++) {
                len += strlen(sequences[i]) + 1;
        }
-       result = mh_xmalloc(len + 1);
+       result = mh_xcalloc(len + 1, sizeof(char));
 
        for (i = 0, cp = result; sequences[i] != NULL; i++, cp += len + 1) {
                len = strlen(sequences[i]);
@@ -485,7 +485,7 @@ main(int argc, char **argv)
                } else {
                        unseen = seq_unseen;  /* use default */
                }
-               dp = getcpy(unseen);
+               dp = mh_xstrdup(unseen);
                for (ap = brkstring(dp, " ", "\n"); *ap; ap++) {
                        sequences[i++] = *ap;
                }
index c81db88d0d1793d19ed3e193f808ffd1742de584..a8c2c421a40cba44f32e73aa4b5e2170d4f45390 100644 (file)
@@ -66,7 +66,7 @@ main(int argc, char **argv)
                if (*cp == '+' || *cp == '@') {
                        if (folder)
                                adios(EX_USAGE, NULL, "only one folder at a time!");
-                       folder = getcpy(expandfol(cp));
+                       folder = mh_xstrdup(expandfol(cp));
                } else
                        app_msgarg(&msgs, cp);
        }
index 993527b471828578e444f703cdd7fd91419877bc..5df2861a2c19b6ca03f4c483a4fe9cb70342d561 100644 (file)
@@ -197,7 +197,7 @@ main(int argc, char **argv)
                        if (folder)
                                adios(EX_USAGE, NULL, "only one folder at a time!");
                        else
-                               folder = getcpy(expandfol(cp));
+                               folder = mh_xstrdup(expandfol(cp));
                } else
                        app_msgarg(&msgs, cp);
        }
@@ -731,7 +731,7 @@ pattern: ;
                        padvise(NULL, "pattern error in %s %s", argp[-2], cp);
                        return NULL;
                }
-               n->n_patbuf = getcpy(dp);
+               n->n_patbuf = mh_xstrdup(dp);
                return n;
 
        case PROTHR:
@@ -768,7 +768,7 @@ newnexus(int (*action)())
 {
        struct nexus *p;
 
-       p = (struct nexus *) mh_xcalloc((size_t) 1, sizeof *p);
+       p = mh_xcalloc(1, sizeof *p);
 
        p->n_action = action;
        return p;
@@ -1251,10 +1251,9 @@ plist
                switch (state = m_getfld2(state, &f, fp)) {
                case FLD2:
                        if (bp) {
-                               free(bp);
-                               bp = NULL;
+                               mh_free0(&bp);
                        }
-                       bp = getcpy(f.value);
+                       bp = mh_xstrdup(f.value);
                        if (mh_strcasecmp(f.name, n->n_datef)==0) {
                                break;
                        }
@@ -1268,9 +1267,7 @@ plist
 
                case BODY2:
                case FILEEOF2:
-                       if (bp) {
-                               free(bp);
-                       }
+                       mh_free0(&bp);
                        return 0;
 
                default:
@@ -1287,6 +1284,6 @@ plist
                        : (twsort(tw, &n->n_tws) < 0);
 
        if (bp != NULL)
-               free(bp);
+               mh_free0(&bp);
        return state;
 }
index 8292a20bac1ac2f262c7d490b68751cbf9ef06ba..d08058be6c76bc789a82c8dbf654545ea4d8300c 100644 (file)
@@ -85,7 +85,7 @@ main(int argc, char **argv)
                                continue;
                        }
                }
-               addrs = addrs ? add(cp, add(", ", addrs)) : getcpy(cp);
+               addrs = addrs ? add(cp, add(", ", addrs)) : mh_xstrdup(cp);
        }
 
        if (!addrs) {
@@ -192,7 +192,7 @@ rcvdistout(FILE *inb, char *form, char *addrs)
                                        }
                                        char_read += strlen(f.value);
                                        if (!cptr->c_text) {
-                                               cptr->c_text = getcpy(f.value);
+                                               cptr->c_text = mh_xstrdup(f.value);
                                        } else {
                                                cp = cptr->c_text;
                                                i = strlen(cp) - 1;
@@ -225,7 +225,7 @@ rcvdistout(FILE *inb, char *form, char *addrs)
 finished: ;
 
        i = format_len + char_read + 256;
-       scanl = mh_xmalloc((size_t) i + 2);
+       scanl = mh_xcalloc(i + 2, sizeof(char));
        dat[0] = dat[1] = dat[2] = dat[4] = 0;
        dat[3] = OUTPUTLINELEN;
        fmt_scan(fmt, scanl, i, dat);
@@ -236,7 +236,7 @@ finished: ;
        }
        fclose(out);
 
-       free(scanl);
+       mh_free0(&scanl);
 }
 
 
index 5c7f9d8294982fac8dbfee9b3dec6b049e825a39..83c5150ff51a606824666259e69f9278bd59f947 100644 (file)
@@ -7,6 +7,7 @@
 */
 
 #include <h/mh.h>
+#include <h/utils.h>
 #include <fcntl.h>
 #include <h/signals.h>
 #include <errno.h>
@@ -139,7 +140,7 @@ main(int argc, char **argv)
                        if (folder)
                                adios(EX_USAGE, NULL, "only one folder at a time!");
                        else
-                               folder = getcpy(expandfol(cp));
+                               folder = mh_xstrdup(expandfol(cp));
                } else {
                        adios(EX_USAGE, NULL, "usage: %s [+folder] [switches]",
                                        invo_name);
index a67b15052284bbdc25223884315e38a4c27f5aea..182f315ea1836b3c7378a9e0899ba742cac36fd3 100644 (file)
@@ -101,7 +101,7 @@ main(int argc, char **argv)
                                if (!(cp = *argp++) || *cp == '-')
                                        adios(EX_USAGE, NULL, "missing argument to %s",
                                                        argp[-2]);
-                               folder = getcpy(expandfol(cp));
+                               folder = mh_xstrdup(expandfol(cp));
                                continue;
                        case FILESW:
                                if (filep > NFOLDERS)
@@ -110,7 +110,7 @@ main(int argc, char **argv)
                                if (!(cp = *argp++) || *cp == '-')
                                        adios(EX_USAGE, NULL, "missing argument to %s",
                                                        argp[-2]);
-                               files[filep++] = getcpy(expanddir(cp));
+                               files[filep++] = mh_xstrdup(expanddir(cp));
                                continue;
                        }
                }
@@ -118,7 +118,7 @@ main(int argc, char **argv)
                        if (foldp > NFOLDERS)
                                adios(EX_USAGE, NULL, "only %d folders allowed!",
                                                NFOLDERS);
-                       folders[foldp++].f_name = getcpy(expandfol(cp));
+                       folders[foldp++].f_name = mh_xstrdup(expandfol(cp));
                } else
                        app_msgarg(&msgs, cp);
        }
@@ -126,57 +126,73 @@ main(int argc, char **argv)
        if (foldp == 0)
                adios(EX_USAGE, NULL, "no folder specified");
 
-       /*
-       ** We are refiling a file to the folders
-       */
        if (filep > 0) {
-               if (folder || msgs.size)
+               /*
+               ** We are refiling one or more files (-file) to the folders
+               */
+               if (msgs.size) {
                        adios(EX_USAGE, NULL, "use -file or msgs, not both");
+               }
+               if (folder) {
+                       adios(EX_USAGE, NULL, "use -file or -src, not both");
+               }
                opnfolds(folders, foldp);
-               for (i = 0; i < filep; i++)
-                       if (m_file(files[i], folders, foldp, 0))
+               for (i = 0; i < filep; i++) {
+                       if (m_file(files[i], folders, foldp, 0)) {
                                exit(EX_IOERR);
+                       }
+               }
                /* If -nolink, then unlink files */
                if (!linkf) {
                        int i;
                        char **files = filevec;
 
-                       /* just unlink the files */
                        for (i = 0; i < filep; i++) {
-                               if (unlink(files[i]) == NOTOK)
+                               if (unlink(files[i]) == NOTOK) {
                                        admonish(files[i], "unable to unlink");
+                               }
                        }
                }
                exit(EX_OK);
        }
 
-       if (!msgs.size)
+       /*
+       ** We are refiling messages to the folders
+       */
+       if (!msgs.size) {
                app_msgarg(&msgs, seq_cur);
-       if (!folder)
+       }
+       if (!folder) {
                folder = getcurfol();
-       strncpy(maildir, toabsdir(folder), sizeof(maildir));
+       }
 
-       if (chdir(maildir) == NOTOK)
+       strncpy(maildir, toabsdir(folder), sizeof(maildir));
+       if (chdir(maildir) == NOTOK) {
                adios(EX_OSERR, maildir, "unable to change directory to");
+       }
 
        /* read source folder and create message structure */
-       if (!(mp = folder_read(folder)))
+       if (!(mp = folder_read(folder))) {
                adios(EX_IOERR, NULL, "unable to read folder %s", folder);
+       }
 
-       /* check for empty folder */
-       if (mp->nummsg == 0)
+       if (mp->nummsg == 0) {
                adios(EX_DATAERR, NULL, "no messages in %s", folder);
+       }
 
        /* parse the message range/sequence/name and set SELECTED */
-       for (msgnum = 0; msgnum < msgs.size; msgnum++)
-               if (!m_convert(mp, msgs.msgs[msgnum]))
+       for (msgnum = 0; msgnum < msgs.size; msgnum++) {
+               if (!m_convert(mp, msgs.msgs[msgnum])) {
                        exit(EX_SOFTWARE);
-       seq_setprev(mp);  /* set the previous-sequence */
+               }
+       }
+       seq_setprev(mp);
 
        /* create folder structures for each destination folder */
        opnfolds(folders, foldp);
 
-       /* Link all the selected messages into destination folders.
+       /*
+       ** Link all the selected messages into destination folders.
        **
        ** This causes the add hook to be run for messages that are
        ** linked into another folder.  The refile hook is run for
@@ -184,10 +200,11 @@ main(int argc, char **argv)
        */
        for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
                if (is_selected(mp, msgnum)) {
-                       cp = getcpy(m_name(msgnum));
-                       if (m_file(cp, folders, foldp, !linkf))
+                       cp = mh_xstrdup(m_name(msgnum));
+                       if (m_file(cp, folders, foldp, !linkf)) {
                                exit(EX_IOERR);
-                       free(cp);
+                       }
+                       mh_free0(&cp);
                }
        }
 
@@ -206,9 +223,8 @@ main(int argc, char **argv)
        if (linkf) {
                seq_setcur(mp, mp->hghsel);
        }
-       seq_save(mp);  /* synchronize message sequences */
+       seq_save(mp);
 
-       context_replace(curfolder, folder);
        context_save();
        folder_free(mp);
        return 0;
@@ -232,10 +248,12 @@ opnfolds(struct st_fold *folders, int nfolders)
 
                create_folder(nmaildir, 0, exit);
 
-               if (chdir(nmaildir) == NOTOK)
+               if (chdir(nmaildir) == NOTOK) {
                        adios(EX_OSERR, nmaildir, "unable to change directory to");
-               if (!(mp = folder_read(fp->f_name)))
+               }
+               if (!(mp = folder_read(fp->f_name))) {
                        adios(EX_IOERR, NULL, "unable to read folder %s", fp->f_name);
+               }
                mp->curmsg = 0;
 
                fp->f_mp = mp;
@@ -274,9 +292,10 @@ m_file(char *msgfile, struct st_fold *folders, int nfolders, int refile)
        struct st_fold *fp, *ep;
 
        for (fp = folders, ep = folders + nfolders; fp < ep; fp++) {
-               if ((msgnum = folder_addmsg(&fp->f_mp, msgfile, 1, 0,
-                               0, nfolders == 1 && refile, maildir)) == -1)
+               if ((msgnum = folder_addmsg(&fp->f_mp, msgfile, 1, 0, 0,
+                               nfolders == 1 && refile, maildir)) == -1) {
                        return 1;
+               }
        }
        return 0;
 }
index d71f27b31f6f601a617928de19ee2a4cb058c878..9006dec24b0dbc1a0c41b4e586ab09095d8a6d46 100644 (file)
@@ -134,14 +134,14 @@ main(int argc, char **argv)
        FILE *in;
        int buildsw = 0;
 
-       filter = getcpy(etcpath(mhlreply));
-
        setlocale(LC_ALL, "");
        invo_name = mhbasename(argv[0]);
 
        /* read user profile/context */
        context_read();
 
+       filter = mh_xstrdup(etcpath(mhlreply));
+
        arguments = getarguments(invo_name, argc, argv, 1);
        argp = arguments;
 
@@ -212,7 +212,7 @@ main(int argc, char **argv)
                                if (!(cp = *argp++) || *cp == '-')
                                        adios(EX_USAGE, NULL, "missing argument to %s",
                                                        argp[-2]);
-                               file = getcpy(expanddir(cp));
+                               file = mh_xstrdup(expanddir(cp));
                                continue;
                        case FORMSW:
                                if (!(form = *argp++) || *form == '-')
@@ -224,7 +224,7 @@ main(int argc, char **argv)
                                if (!(cp = *argp++) || *cp == '-')
                                        adios(EX_USAGE, NULL, "missing argument to %s",
                                                        argp[-2]);
-                               filter = getcpy(etcpath(cp));
+                               filter = mh_xstrdup(etcpath(cp));
                                continue;
                        case NFILTSW:
                                filter = NULL;
@@ -250,7 +250,7 @@ main(int argc, char **argv)
                        if (folder)
                                adios(EX_USAGE, NULL, "only one folder at a time!");
                        else
-                               folder = getcpy(expandfol(cp));
+                               folder = mh_xstrdup(expandfol(cp));
                } else {
                        if (msg)
                                adios(EX_USAGE, NULL, "only one message at a time!");
@@ -266,7 +266,7 @@ main(int argc, char **argv)
        if (ccme == -1)
                ccme = groupreply;
 
-       cwd = getcpy(pwd());
+       cwd = mh_xstrdup(pwd());
 
        if (file && (msg || folder))
                adios(EX_USAGE, NULL, "can't mix files and folders/msgs");
@@ -320,7 +320,7 @@ main(int argc, char **argv)
                context_save();  /* save the context file   */
        }
 
-       msg = file ? file : getcpy(m_name(mp->lowsel));
+       msg = file ? file : mh_xstrdup(m_name(mp->lowsel));
 
        if ((in = fopen(msg, "r")) == NULL)
                adios(EX_IOERR, msg, "unable to open");
@@ -422,7 +422,7 @@ replout(FILE *inb, char *drft, struct msgs *mp,
        if ((cp = getenv("USER"))) {
                FINDCOMP(cptr, "user");
                if (cptr)
-                       cptr->c_text = getcpy(cp);
+                       cptr->c_text = mh_xstrdup(cp);
        }
        if (!ccme)
                ismymbox(NULL);
@@ -448,7 +448,7 @@ replout(FILE *inb, char *drft, struct msgs *mp,
                                        }
                                        char_read += strlen(f.value);
                                        if (!cptr->c_text) {
-                                               cptr->c_text = getcpy(f.value);
+                                               cptr->c_text = mh_xstrdup(f.value);
                                                i = strlen(cptr->c_text) - 1;
                                                if (cptr->c_text[i] == '\n') {
                                                        cptr->c_text[i] = '\0';
@@ -506,12 +506,12 @@ finished:
                }
                if (sp != cptr->c_text) {
                        cp = cptr->c_text;
-                       cptr->c_text = getcpy(sp);
-                       free(cp);
+                       cptr->c_text = mh_xstrdup(sp);
+                       mh_free0(&cp);
                }
        }
        i = format_len + char_read + 256;
-       scanl = mh_xmalloc((size_t) i + 2);
+       scanl = mh_xcalloc(i + 2, sizeof(char));
        dat[0] = 0;
        dat[1] = 0;
        dat[2] = 0;
@@ -552,7 +552,7 @@ finished:
        }
 
        /* return dynamically allocated buffers */
-       free(scanl);
+       mh_free0(&scanl);
 }
 
 static char *buf;  /* our current working buffer */
@@ -588,7 +588,7 @@ static unsigned int bufsiz=0;  /* current size of buf */
 ** returns a pointer to the concatenated address string.
 **
 ** We try to not do a lot of malloc/copy/free's (which is why we
-** don't call "getcpy") but still place no upper limit on the
+** don't call "mh_xstrdup") but still place no upper limit on the
 ** length of the result string.
 **
 ** This routine is an override for the equally named one in sbr/fmt_addr.c.
@@ -607,7 +607,7 @@ formataddr(char *orig, char *str)
 
        /* if we don't have a buffer yet, get one */
        if (bufsiz == 0) {
-               buf = mh_xmalloc(BUFINCR);
+               buf = mh_xcalloc(BUFINCR, sizeof(char));
                last_dst = buf;  /* XXX */
                bufsiz = BUFINCR - 6;  /* leave some slop */
                bufend = buf + bufsiz;
@@ -701,7 +701,8 @@ insert(struct mailname *np)
 static void
 replfilter(FILE *in, FILE *out, char *filter)
 {
-       int pid, n;
+       int pid, pid_show, n;
+       int mailpipe[2];
        char *errstr;
 
        if (filter == NULL)
@@ -713,12 +714,32 @@ replfilter(FILE *in, FILE *out, char *filter)
        rewind(in);
        lseek(fileno(in), (off_t) 0, SEEK_SET);
 
-       switch (pid = fork()) {
+       if (pipe(mailpipe) == -1) {
+               adios(EX_OSERR, "pipe", "can't create pipe");
+       }
+
+       switch (pid_show = fork()) {
        case NOTOK:
                adios(EX_OSERR, "fork", "unable to");
 
        case OK:
                dup2(fileno(in), fileno(stdin));
+               dup2(mailpipe[1], fileno(stdout));
+               for (n=3; n<OPEN_MAX; n++) {
+                       close(n);
+               }
+
+               execlp("show", "show", "-file", "-", NULL);
+
+               adios(EX_OSERR, "exec", "unable to");
+       }
+
+       switch (pid = fork()) {
+       case NOTOK:
+               adios(EX_OSERR, "fork", "unable to");
+
+       case OK:
+               dup2(mailpipe[0], fileno(stdin));
                dup2(fileno(out), fileno(stdout));
                for (n=3; n<OPEN_MAX; n++) {
                        close(n);
@@ -732,9 +753,12 @@ replfilter(FILE *in, FILE *out, char *filter)
                _exit(EX_OSERR);
 
        default:
-               if (pidXwait(pid, "mhl"))
+               if (pidXwait(-1, "show | mhl"))
                        exit(EX_SOFTWARE);
                fseek(out, 0L, SEEK_END);
                break;
        }
+
+       close(mailpipe[0]);
+       close(mailpipe[1]);
 }
index 230360b8d69bb6f979a7c4501bd1fb0286c71a6f..e435a276892449e84b2aafa718b3671c8f877e1c 100644 (file)
--- a/uip/rmf.c
+++ b/uip/rmf.c
@@ -7,6 +7,7 @@
 */
 
 #include <h/mh.h>
+#include <h/utils.h>
 #include <unistd.h>
 #include <dirent.h>
 #include <locale.h>
@@ -76,7 +77,7 @@ main(int argc, char **argv)
                        if (folder)
                                adios(EX_USAGE, NULL, "only one folder at a time!");
                        else
-                               folder = getcpy(expandfol(cp));
+                               folder = mh_xstrdup(expandfol(cp));
                } else {
                        adios(EX_USAGE, NULL, "usage: %s [+folder] [switches]",
                                        invo_name);
@@ -110,7 +111,7 @@ main(int argc, char **argv)
                cp = concat("Remove folder \"", folder, "\"? ", NULL);
                if (!getanswer(cp))
                        exit(EX_OK);
-               free(cp);
+               mh_free0(&cp);
        }
 
        if (rmf(folder) == OK) {
@@ -223,7 +224,7 @@ rma(char *folder)
        struct node *np, *pp;
 
        alen = strlen("atr-");
-       plen = strlen(cp = getcpy(toabsdir(folder))) + 1;
+       plen = strlen(cp = mh_xstrdup(toabsdir(folder))) + 1;
 
        /*
        ** Search context list for keys that look like
@@ -248,5 +249,5 @@ rma(char *folder)
                        pp = np;
                }
        }
-       free(cp);
+       mh_free0(&cp);
 }
index f99dcbc70b23ac47d2e32d135ee188d01665cfd6..99820e946130009ced6d47446cf286a8e0003ec5 100644 (file)
--- a/uip/rmm.c
+++ b/uip/rmm.c
@@ -73,7 +73,7 @@ main(int argc, char **argv)
                        if (folder) {
                                adios(EX_USAGE, NULL, "only one folder at a time!");
                        } else {
-                               folder = getcpy(expandfol(cp));
+                               folder = mh_xstrdup(expandfol(cp));
                        }
                } else {
                        app_msgarg(&msgs, cp);
@@ -131,7 +131,7 @@ main(int argc, char **argv)
                adios(EX_SOFTWARE, NULL, "more than %d messages for refile exec",
                                MAXARGS - 6);
        }
-       vec = (char **)mh_xmalloc((size_t)(msgs.size + 6) * sizeof(*vec));
+       vec = mh_xcalloc(msgs.size + 6, sizeof(*vec));
        vec[vecp++] = "refile";
        vec[vecp++] = "-src";
        vec[vecp++] = concat("+", folder, NULL);
index 3a8342083a57c8caacbde92b48d50fccbddbbaba..a735b315e36606900bcb81457883840a8bff1d85 100644 (file)
@@ -91,7 +91,7 @@ main(int argc, char **argv)
                                        adios(EX_USAGE, NULL, "missing argument to %s",
                                                        argp[-2]);
                                if (strcmp(file = cp, "-")!=0)
-                                       file = getcpy(expanddir(cp));
+                                       file = mh_xstrdup(expanddir(cp));
                                continue;
                        }
                }
@@ -99,15 +99,13 @@ main(int argc, char **argv)
                        if (folder)
                                adios(EX_USAGE, NULL, "only one folder at a time!");
                        else
-                               folder = getcpy(expandfol(cp));
+                               folder = mh_xstrdup(expandfol(cp));
                } else
                        app_msgarg(&msgs, cp);
        }
 
-       /*
-       ** Get new format string.  Must be before chdir().
-       */
-       fmtstr = new_fs(form, FORMAT);
+       /* Set format string.  Must be before chdir(). */
+       fmtstr = new_fs(form, scanformat);
 
        /*
        ** We are scanning a maildrop file
@@ -174,14 +172,14 @@ main(int argc, char **argv)
        if (*cp) {
                char **ap, *dp;
 
-               dp = getcpy(cp);
+               dp = mh_xstrdup(cp);
                ap = brkstring(dp, " ", "\n");
                for (i = 0; ap && *ap; i++, ap++) {
                        seqnum[i] = seq_getnum(mp, *ap);
                }
                num_unseen_seq = i;
                if (dp) {
-                       free(dp);
+                       mh_free0(&dp);
                }
        }
 
index 50b250e558ec086590a99ac015c8f824a3b88868..feef5c0495be89910ff621cdf9b4651ec6aabf67 100644 (file)
@@ -74,8 +74,7 @@ scan(FILE *inb, int innum, int outnum, char *fmtstr, int width, int curflg,
                                        width = MAXSCANL;
                        }
                        dat[3] = slwidth = width;
-                       scanl = (char *) mh_xmalloc((size_t) SCAN_CHARWIDTH *
-                                       (slwidth + 2));  /* probably for \n and \0 */
+                       scanl = mh_xcalloc(slwidth + 2, SCAN_CHARWIDTH);  /* probably for \n and \0 */
                        /* Compile format string */
                        ncomps = fmt_compile(fmtstr, &fmt) + 1;
                        FINDCOMP(datecomp, "date");
@@ -129,7 +128,7 @@ scan(FILE *inb, int innum, int outnum, char *fmtstr, int width, int curflg,
                                                free(cptr->c_text);
                                                cptr->c_text = NULL;
                                        }
-                                       cptr->c_text = getcpy(f.value);
+                                       cptr->c_text = mh_xstrdup(f.value);
                                        cp = cptr->c_text + strlen(cptr->c_text) - 1;
                                        for (; cp >= cptr->c_text; cp--) {
                                                if (isspace(*cp)) {
@@ -252,7 +251,7 @@ finished:
                if (datecomp && !datecomp->c_text) {
                        if (!datecomp->c_text) {
                                if (!datecomp->c_tws)
-                                       datecomp->c_tws = (struct tws *) mh_xcalloc((size_t) 1, sizeof(*datecomp->c_tws));
+                                       datecomp->c_tws = mh_xcalloc(1, sizeof(*datecomp->c_tws));
                                if (!datecomp->c_tws)
                                        adios(EX_OSERR, NULL, "unable to allocate tws buffer");
                                *datecomp->c_tws = *dlocaltime((time_t *) &st.st_mtime);
index df8134017dd73e6d76c2d9a521420c651c46f02d..619ff628eb88b8c07109453aa89a24c5a5485937 100644 (file)
@@ -162,7 +162,7 @@ main(int argc, char **argv)
                for (nmsgs = 0, msgnum = mp->lowsel;
                                msgnum <= mp->hghsel; msgnum++) {
                        if (is_selected(mp, msgnum)) {
-                               files[nfiles++] = getcpy(m_name(msgnum));
+                               files[nfiles++] = mh_xstrdup(m_name(msgnum));
                                unset_exists(mp, msgnum);
                        }
                }
@@ -196,7 +196,7 @@ main(int argc, char **argv)
                        adios(EX_IOERR, altmsg, "unable to open for reading");
                }
                fstat(in, &st2);
-               distfile = getcpy(m_mktemp2(NULL, invo_name, NULL, NULL));
+               distfile = mh_xstrdup(m_mktemp2(NULL, invo_name, NULL, NULL));
                if ((out = creat(distfile, (int)st2.st_mode & 0777))==NOTOK) {
                        adios(EX_IOERR, distfile, "unable to open for writing");
                }
@@ -348,7 +348,7 @@ attach(char *draft_file_name)
        }
 
        /* We'll grow the buffer as needed. */
-       field = (char *)mh_xmalloc(field_size = 256);
+       field = mh_xcalloc(field_size = 256, sizeof(char));
 
        /*
        ** Scan the draft file for an attachment header field name.
@@ -484,7 +484,7 @@ signandenc(char *draft_file_name)
        }
 
        /* We'll grow the buffer as needed. */
-       field = (char *)mh_xmalloc(field_size = 256);
+       field = mh_xcalloc(field_size = 256, sizeof(char));
 
        /* Scan the draft file for an attachment header field name. */
        while (get_line() != EOF && *field != '\0' && *field != '-') {
@@ -553,7 +553,7 @@ get_line(void)
                        break;
                }
                if (++n >= field_size - 1) {
-                       field = (char *)mh_xrealloc(field, field_size += 256);
+                       field = mh_xrealloc(field, field_size += 256);
                        p = field + n - 1;
                }
        }
index c3b45e87aaf8b3b7b8a068fa2a675bb28ebf4b00..f8f9d9537931be93650a662e70d8cfff4b4e4423 100644 (file)
@@ -747,10 +747,10 @@ parse(int fd)
 
        /* add special entries to lookup table */
        if ((p = lookup(hdrs, "source"))) {
-               p->p_value = getcpy(sender);
+               p->p_value = mh_xstrdup(sender);
        }
        if ((p = lookup(hdrs, "addr"))) {
-               p->p_value = getcpy(addr);
+               p->p_value = mh_xstrdup(addr);
        }
 
        /*
@@ -759,7 +759,7 @@ parse(int fd)
        for (i = 0, state = FLD2;;) {
                switch (state = m_getfld2(state, &f, in)) {
                case FLD2:
-                       lp = getcpy(f.value);
+                       lp = mh_xstrdup(f.value);
                        for (p = hdrs; p->p_name; p++) {
                                if (mh_strcasecmp(p->p_name, f.name)!=0) {
                                        if (!(p->p_flags & P_HID)) {
@@ -776,12 +776,12 @@ parse(int fd)
                                                }
                                                p->p_value = add(lp, cp);
                                        }
-                                       free(lp);
+                                       mh_free0(&lp);
                                        break;
                                }
                        }
                        if (!p->p_name && i < NVEC) {
-                               p->p_name = getcpy(f.name);
+                               p->p_name = mh_xstrdup(f.name);
                                p->p_value = lp;
                                p->p_flags = P_NIL;
                                p++, i++;
@@ -812,7 +812,7 @@ parse(int fd)
                if (!(q = lookup(hdrs, "reply-to")) || !q->p_value) {
                        q = lookup(hdrs, "from");
                }
-               p->p_value = getcpy(q ? q->p_value : "");
+               p->p_value = mh_xstrdup(q ? q->p_value : "");
                p->p_flags &= ~P_CHK;
                if (debug) {
                        debug_printf("vars[%d]: name=\"%s\" value=\"%s\"\n",
@@ -885,18 +885,18 @@ glob(int fd)
                return;
        }
        if ((p = lookup(vars, "sender"))) {
-               p->p_value = getcpy(sender);
+               p->p_value = mh_xstrdup(sender);
        }
        if ((p = lookup(vars, "address"))) {
-               p->p_value = getcpy(addr);
+               p->p_value = mh_xstrdup(addr);
        }
        if ((p = lookup(vars, "size"))) {
                snprintf(buffer, sizeof(buffer), "%d",
                                fstat(fd, &st) != -1 ? (int) st.st_size : 0);
-               p->p_value = getcpy(buffer);
+               p->p_value = mh_xstrdup(buffer);
        }
        if ((p = lookup(vars, "info"))) {
-               p->p_value = getcpy(info);
+               p->p_value = mh_xstrdup(info);
        }
        if (debug) {
                for (p = vars; p->p_name; p++) {
@@ -1084,7 +1084,7 @@ get_sender(char *envelope, char **sender)
        unsigned char buffer[BUFSIZ];
 
        if (!envelope) {
-               *sender = getcpy("");
+               *sender = mh_xstrdup("");
                return;
        }
 
@@ -1108,7 +1108,7 @@ get_sender(char *envelope, char **sender)
                } else {
                        break;
                }
-       *sender = getcpy(buffer);
+       *sender = mh_xstrdup(buffer);
 }
 
 
@@ -1188,7 +1188,7 @@ you_lose:
                                ** get copy of envelope information
                                ** ("From " line)
                                */
-                               envelope = getcpy(buffer);
+                               envelope = mh_xstrdup(buffer);
 
                                /* Put the delivery date in message */
                                fputs(ddate, ffp);
@@ -1258,7 +1258,7 @@ trimstr(char *cp)
                        *sp = ' ';
                }
        }
-       return getcpy(bp);
+       return mh_xstrdup(bp);
 }
 
 /*
index 61953e17fbe7fbcb61737b22ee1c384d80992bf0..56fa7cb59a43ea3701d9534b4ecfd4e85601a17c 100644 (file)
@@ -161,7 +161,7 @@ main(int argc, char **argv)
                        if (folder)
                                adios(EX_USAGE, NULL, "only one folder at a time!");
                        else
-                               folder = getcpy(expandfol(cp));
+                               folder = mh_xstrdup(expandfol(cp));
                } else
                        app_msgarg(&msgs, cp);
        }
@@ -197,7 +197,7 @@ main(int argc, char **argv)
        /*
        ** sort a list of pointers to our "messages to be sorted".
        */
-       dlist = (struct smsg **) mh_xcalloc((size_t) (nmsgs+1), sizeof(*dlist));
+       dlist = mh_xcalloc(nmsgs+1, sizeof(*dlist));
        for (i = 0; i < nmsgs; i++)
                dlist[i] = &smsgs[i];
        dlist[nmsgs] = 0;
@@ -224,8 +224,7 @@ main(int argc, char **argv)
                struct smsg **slist, **flist;
                struct smsg ***il, **fp, **dp;
 
-               slist = (struct smsg **)
-                               mh_xmalloc((nmsgs+1) * sizeof(*slist));
+               slist = mh_xcalloc(nmsgs+1, sizeof(*slist));
                memcpy((char *)slist, (char *)dlist, (nmsgs+1)*sizeof(*slist));
                qsort((char *)slist, nmsgs, sizeof(*slist),
                                (qsort_comp) subsort);
@@ -235,7 +234,7 @@ main(int argc, char **argv)
                ** the collection of messages with the same subj
                ** given a message number.
                */
-               il = (struct smsg ***) mh_xcalloc(mp->hghsel+1, sizeof(*il));
+               il = mh_xcalloc(mp->hghsel+1, sizeof(*il));
                if (! il)
                        adios(EX_OSERR, NULL, "couldn't allocate msg list");
                for (i = 0; i < nmsgs; i++)
@@ -244,8 +243,7 @@ main(int argc, char **argv)
                ** make up the final list, chronological but with
                ** all the same subjects grouped together.
                */
-               flist = (struct smsg **)
-                               mh_xmalloc((nmsgs+1) * sizeof(*flist));
+               flist = mh_xcalloc(nmsgs+1, sizeof(*flist));
                fp = flist;
                for (dp = dlist; *dp;) {
                        struct smsg **s = il[(*dp++)->s_msg];
@@ -267,8 +265,8 @@ main(int argc, char **argv)
                        }
                }
                *fp = 0;
-               free(slist);
-               free(dlist);
+               mh_free0(&slist);
+               mh_free0(&dlist);
                dlist = flist;
        }
 
@@ -295,8 +293,7 @@ read_hdrs(struct msgs *mp, char *datesw)
 
        twscopy(&tb, dlocaltimenow());
 
-       smsgs = (struct smsg *) mh_xcalloc((size_t) (mp->hghsel - mp->lowsel + 2),
-                       sizeof(*smsgs));
+       smsgs = mh_xcalloc(mp->hghsel - mp->lowsel + 2, sizeof(*smsgs));
 
        s = smsgs;
        for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
@@ -336,13 +333,13 @@ get_fields(char *datesw, int msg, struct smsg *smsg)
                switch (state = m_getfld2(state, &f, in)) {
                case FLD2:
                        if (mh_strcasecmp(f.name, datesw)==0) {
-                               datecomp = getcpy(f.value);
+                               datecomp = mh_xstrdup(f.value);
                                if (!subjsort || subjcomp) {
                                        break;
                                }
                        } else if (subjsort && mh_strcasecmp(f.name,
                                        subjsort)==0) {
-                               subjcomp = getcpy(f.value);
+                               subjcomp = mh_xstrdup(f.value);
                                if (datecomp) {
                                        break;
                                }
@@ -358,10 +355,10 @@ get_fields(char *datesw, int msg, struct smsg *smsg)
                case IOERR2:
                        admonish(NULL, "format error in message %d (header #%d)", msg, compnum);
                        if (datecomp) {
-                               free(datecomp);
+                               mh_free0(&datecomp);
                        }
                        if (subjcomp) {
-                               free(subjcomp);
+                               mh_free0(&subjcomp);
                        }
                        fclose(in);
                        return (0);
@@ -424,7 +421,7 @@ get_fields(char *datesw, int msg, struct smsg *smsg)
        }
        fclose(in);
        if (datecomp)
-               free(datecomp);
+               mh_free0(&datecomp);
 
        return (1);
 }
index 04479a1f6247e2ebcd3afbd1c2bc721ea254b3d6..53ae86a72538b71b30764bdec435315988c0e6f8 100644 (file)
@@ -117,6 +117,7 @@ static enum {
 static char *tmpfil;
 
 static char *subject = NULL;  /* the subject field for BCC'ing */
+static struct mailname *from = NULL;  /* the from field for BCC'ing */
 static char fccs[BUFSIZ] = "";
 struct mailname *bccs = NULL;  /* list of the bcc recipients */
 struct mailname *recipients = NULL;  /* list of the recipients */
@@ -212,7 +213,7 @@ main(int argc, char **argv)
                verbose++;
                out = stdout;
        } else {
-               tmpfil = getcpy(m_mktemp2("/tmp/", invo_name, NULL, &out));
+               tmpfil = mh_xstrdup(m_mktemp2("/tmp/", invo_name, NULL, &out));
        }
 
        /* check for "Aliasfile:" profile entry */
@@ -220,7 +221,7 @@ main(int argc, char **argv)
                char *dp, **ap; 
 
                aliasflg = 1;
-               for (ap=brkstring(dp=getcpy(cp), " ", "\n"); ap && *ap;
+               for (ap=brkstring(dp=mh_xstrdup(cp), " ", "\n"); ap && *ap;
                                ap++) {
                        if ((state = alias(etcpath(*ap))) != AK_OK) {
                                adios(EX_IOERR, NULL, "aliasing error in file %s: %s",
@@ -311,7 +312,7 @@ main(int argc, char **argv)
                adios(EX_DATAERR, NULL, "message has no recipients");
        }
 
-       sargv = mh_xmalloc(sizeof(char **) * (recipientsc + 4));
+       sargv = mh_xcalloc(recipientsc + 4, sizeof(char **));
 
        argp = sargv;
        *argp++ = "send-mail";
@@ -321,7 +322,7 @@ main(int argc, char **argv)
        }
 
        while (recipients != NULL) {
-               cp = getcpy(recipients->m_mbox);
+               cp = mh_xstrdup(recipients->m_mbox);
                if (recipients->m_host) {
                        cp = add("@", cp);
                        cp = add(recipients->m_host, cp);
@@ -397,7 +398,7 @@ putfmt(char *name, char *str, FILE *out)
        }
 
        if (hdr->flags & HSUB) {
-               subject = getcpy(str);
+               subject = mh_xstrdup(str);
        }
 
        if (!(hdr->flags & HADR)) {
@@ -428,11 +429,11 @@ putfmt(char *name, char *str, FILE *out)
                /* needed because the address parser holds global state */
                ismymbox(NULL);
 
-               for ( mp = addr_start.m_next; mp; mp = mp->m_next) {
+               for (mp = addr_start.m_next; mp; mp = mp->m_next) {
                        if (ismymbox(mp)) {
                                msgflags |= MFMM;
                                if (my == NULL) {
-                                       my = mp;
+                                       from = my = mp;
                                }
                        }
                }
@@ -543,10 +544,10 @@ putadr(char *name, struct mailname *nl)
                }
                if (mp->m_ingrp) {
                        if (mp->m_gname != NULL) {
-                               cp = getcpy(mp->m_gname);
+                               cp = mh_xstrdup(mp->m_gname);
                                cp = add(";", cp);
                                linepos = putone(cp, linepos, namelen);
-                               free(cp);
+                               mh_free0(&cp);
                                cp = NULL;
                        }
                } else {
@@ -642,7 +643,7 @@ fcc(char *file, char *folders)
                fprintf(stderr, "Skipped %sFcc %s: unable to system().\n",
                                msgstate == resent ? "Resent-" : "", folders);
        } else if (status != 0) {
-               fprintf(stderr, "%sFcc %s: Problems occured.\n",
+               fprintf(stderr, "%sFcc %s: Problems occurred.\n",
                                msgstate == resent ? "Resent-" : "", folders);
        }
 }
@@ -658,8 +659,11 @@ process_bccs(char *origmsg)
        FILE *out = NULL;
 
        for (mp=bccs; mp; mp=mp->m_next) {
-               bccdraft = getcpy(m_mktemp2("/tmp/", invo_name, NULL, &out));
+               bccdraft = mh_xstrdup(m_mktemp2("/tmp/", invo_name, NULL, &out));
                fprintf(out, "To: %s\n", mp->m_text);
+               if (from) {
+                       fprintf(out, "From: %s\n", from->m_text);
+               }
                fprintf(out, "Subject: [BCC] %s", subject ? subject : "");
                fprintf(out, "%s: %s\n", attach_hdr, origmsg);
                fprintf(out, "------------\n");
index 4b45a0c45ba27929e4c1107172b5e65252dd6ef2..65d2fb021c5f176e632a0e0bf4b8d4fa169e113f 100644 (file)
@@ -153,7 +153,7 @@ main(int argc, char **argv)
        }
 
        if ((!drft && !(drft = getenv("mhdraft"))) || !*drft)
-               drft = getcpy(m_draft(seq_cur));
+               drft = mh_xstrdup(m_draft(seq_cur));
 
        if ((cp = getenv("mhuse")) && *cp)
                use = atoi(cp);
@@ -557,7 +557,7 @@ editfile(char **ed, char **arg, char *file)
        }
 
        /* remember which editor we used */
-       edsave = getcpy(*ed);
+       edsave = mh_xstrdup(*ed);
 
        *ed = NULL;
 
index a72c84f0977d88ad413c2d103018482a5676ba00..daca343b121b1dcd76c7fe711a496bcf971f2aac 100644 (file)
@@ -167,7 +167,7 @@ main(int argc, char **argv)
                }
                pclose(in);
        }
-       free(cmd);
+       mh_free0(&cmd);
        naddrs += n;
 
        cmd = add("ali -list", NULL);
@@ -180,7 +180,7 @@ main(int argc, char **argv)
                }
                pclose(in);
        }
-       free(cmd);
+       mh_free0(&cmd);
        naddrs += n;
 
        cmd = add("ali -list", NULL);
@@ -193,7 +193,7 @@ main(int argc, char **argv)
                }
                pclose(in);
        }
-       free(cmd);
+       mh_free0(&cmd);
        naddrs += n;
 
        return naddrs ? 0 : 1;