Replace getcpy() and strdup() with mh_xstrdup()
authorm@mmmmarascio.xyz <m@mmmmarascio.xyz>
Mon, 4 Apr 2016 04:33:34 +0000 (21:33 -0700)
committerPhilipp Takacs <philipp@bureaucracy.de>
Sat, 9 Apr 2016 15:05:14 +0000 (17:05 +0200)
this harmonise the code.

Also fix some bugs, if return value of strdup is not checked.

60 files changed:
docs/TODO
h/prototypes.h
h/utils.h
sbr/Makefile.in
sbr/addrsbr.c
sbr/context_read.c
sbr/context_replace.c
sbr/crawl_folders.c
sbr/fmt_addr.c
sbr/fmt_compile.c
sbr/fmt_new.c
sbr/folder_read.c
sbr/getarguments.c
sbr/getcpy.c [deleted file]
sbr/m_draft.c
sbr/readconfig.c
sbr/seq_read.c
sbr/seq_setprev.c
sbr/seq_setunseen.c
sbr/trimcpy.c
sbr/utils.c
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/folder.c
uip/forw.c
uip/inc.c
uip/mark.c
uip/mhbuild.c
uip/mhl.c
uip/mhlist.c
uip/mhlistsbr.c
uip/mhmail.c
uip/mhparse.c
uip/mhpath.c
uip/mhshow.c
uip/mhshowsbr.c
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/send.c
uip/slocal.c
uip/sortm.c
uip/spost.c
uip/whatnow.c
uip/whom.c

index a439680..308f755 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 8575b22..8455b38 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 60cc34c..c0d2835 100644 (file)
--- a/h/utils.h
+++ b/h/utils.h
@@ -9,6 +9,7 @@ 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 51049c7..77c0c1b 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_getfld.c m_gmprot.c  \
index b2e1176..db5b42e 100644 (file)
@@ -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;
 }
index 4475ca0..cfdcff2 100644 (file)
@@ -25,7 +25,7 @@
 */
 
 #include <h/mh.h>    /* mh internals */
-#include <h/utils.h> /* mh_free0() */
+#include <h/utils.h>
 #include <errno.h>   /* system call errors */
 #include <pwd.h>     /* structure for getpwuid() results */
 #include <unistd.h>
@@ -65,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);
                }
@@ -83,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);
                }
@@ -169,7 +169,7 @@ context_read(void)
        }
 
        if (*cp == '/') {
-               ctxpath = getcpy(cp);
+               ctxpath = mh_xstrdup(cp);
        } else {
                ctxpath = concat(mmhpath, "/", cp, NULL);
        }
index 1b39b27..bfa3daf 100644 (file)
@@ -22,8 +22,8 @@ context_replace(char *key, char *value)
                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;
@@ -41,7 +41,7 @@ context_replace(char *key, char *value)
                                        admonish(NULL, "bug: context_replace(key=\"%s\",value=\"%s\")", key, value);
                                if (np->n_field)
                                        mh_free0(&(np->n_field));
-                               np->n_field = getcpy(value);
+                               np->n_field = mh_xstrdup(value);
                                ctxflags |= CTXMOD;
                        }
                        return;
@@ -56,8 +56,8 @@ context_replace(char *key, char *value)
        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 3841b97..7164616 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);
        }
index c89a195..25c0e16 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
index f4d92d2..566f620 100644 (file)
@@ -309,7 +309,7 @@ fmt_compile(char *fstring, struct format **fmt)
 
        if (format_string)
                mh_free0(&format_string);
-       format_string = getcpy(fstring);
+       format_string = mh_xstrdup(fstring);
        usr_fstring = fstring;
 
        /* init the component hash table. */
index 6dcc70b..c1386d4 100644 (file)
@@ -35,7 +35,7 @@ new_fs(char *form, char *def_form)
 
        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");
@@ -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");
index 1eeee00..722ee2f 100644 (file)
@@ -33,7 +33,7 @@ folder_read(char *name)
        struct dirent *dp;
        DIR *dd;
 
-       name = getcpy(toabsdir(name));
+       name = mh_xstrdup(toabsdir(name));
        if (!(dd = opendir(name))) {
                mh_free0(&name);
                return NULL;
index 33db7f7..e8da984 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 */
diff --git a/sbr/getcpy.c b/sbr/getcpy.c
deleted file mode 100644 (file)
index 67375bb..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_xcalloc(len, sizeof(char));
-               memcpy(cp, str, len);
-       } else {
-               cp = mh_xcalloc(1, sizeof(char));
-               *cp = '\0';
-       }
-       return cp;
-}
index b8d385f..ee85790 100644 (file)
@@ -23,7 +23,7 @@ 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);
index ec97e1e..2fe2d7d 100644 (file)
@@ -55,9 +55,9 @@ readconfig(struct node **npp, FILE *ib, char *file, int ctx)
                        np = mh_xcalloc(1, sizeof(*np));
                        *npp = np;
                        *(npp = &np->n_next) = NULL;
-                       np->n_name = getcpy(name);
+                       np->n_name = mh_xstrdup(name);
                        if (state == FLDPLUS) {
-                               cp = getcpy(field);
+                               cp = mh_xstrdup(field);
                                while (state == FLDPLUS) {
                                        state = m_getfld(state, name, field,
                                                        sizeof(field), ib);
index 1ceb421..e76bcc6 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 */
 
@@ -80,16 +80,16 @@ seq_public(struct msgs *mp)
                case FLD:
                case FLDPLUS:
                        if (state == FLDPLUS) {
-                               cp = getcpy(field);
+                               cp = mh_xstrdup(field);
                                while (state == FLDPLUS) {
                                        state = m_getfld(state, name, field,
                                                        sizeof(field), fp);
                                        cp = add(field, cp);
                                }
-                               seq_init(mp, getcpy(name), trimcpy(cp));
+                               seq_init(mp, mh_xstrdup(name), trimcpy(cp));
                                mh_free0(&cp);
                        } else {
-                               seq_init(mp, getcpy(name), trimcpy(field));
+                               seq_init(mp, mh_xstrdup(name), trimcpy(field));
                        }
                        continue;
 
@@ -133,9 +133,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);
                }
        }
index aecbea6..f4304cc 100644 (file)
@@ -27,7 +27,7 @@ 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) {
                        mh_free0(&dp);
                        return;
index 73bd83d..d833650 100644 (file)
@@ -8,7 +8,7 @@
 */
 
 #include <h/mh.h>
-#include <h/utils.h> /* mh_free0() */
+#include <h/utils.h>
 
 /*
 ** We scan through the folder and act upon all messages
@@ -28,10 +28,10 @@ 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 */
index 0d7f58a..ffa6b57 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 f61456d..466b9ab 100644 (file)
@@ -107,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
@@ -218,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 d6a480c..9ab6515 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",
@@ -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;
index 1ed527f..b00f51b 100644 (file)
@@ -76,7 +76,7 @@ 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;
@@ -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);
 }
 
 
@@ -432,7 +432,7 @@ add_aka(struct aka *ak, char *pp)
                        return;
 
        ad = mh_xcalloc(1, sizeof(*ad));
-       ad->ad_text = getcpy(pp);
+       ad->ad_text = mh_xstrdup(pp);
        ad->ad_local = strchr(pp, '@') == NULL;
        ad->ad_next = NULL;
        if (ak->ak_addr)
@@ -470,7 +470,7 @@ akalloc(char *id)
 
        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;
@@ -491,11 +491,11 @@ hmalloc(struct passwd *pw)
 
        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 81ad042..9e287be 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!");
index 041abf1..9d35601 100644 (file)
--- a/uip/ap.c
+++ b/uip/ap.c
@@ -140,11 +140,11 @@ process(char *arg, int norm)
        while ((cp = getname(arg))) {
                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);
index eb2fb7a..a68420a 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;
                }
index 159d7e7..c34ce43 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 0710712..d74e498 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 f7e5ba3..63fcb0f 100644 (file)
@@ -223,7 +223,7 @@ main(int argc, char **argv)
                                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;
                }
@@ -250,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) {
@@ -464,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;
@@ -501,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);
index c8b3c60..3e3cd76 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,13 +255,13 @@ 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));
                        mh_free0(&dp);
                        context_replace(stack, cp);  /* update folder stack */
@@ -269,7 +269,7 @@ main(int argc, char **argv)
                        /* 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 */
@@ -310,7 +310,7 @@ 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);
                        mh_free0(&dp);
index 5b577bd..d8d69f7 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;
index cbbec1b..1523a2c 100644 (file)
--- a/uip/inc.c
+++ b/uip/inc.c
@@ -198,7 +198,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;
@@ -229,7 +229,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,
@@ -264,7 +264,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 a6ac480..1e57d1c 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 4ff06ef..0f77f33 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)
@@ -370,8 +370,8 @@ build_mime(char *infile)
                        }
 
                        /* get copies of the buffers */
-                       np = getcpy(name);
-                       vp = getcpy(buf);
+                       np = mh_xstrdup(name);
+                       vp = mh_xstrdup(buf);
 
                        /* if necessary, get rest of field */
                        while (state == FLDPLUS) {
@@ -418,7 +418,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);
 
@@ -432,7 +432,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 = mh_xcalloc(1, sizeof(*m));
        ct->c_ctparams = (void *) m;
@@ -624,7 +624,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] == '<') {
@@ -806,7 +806,7 @@ use_forw:
                                        continue;
                                if (!*cp)
                                        adios(EX_DATAERR, NULL, "empty pipe command for #%s directive", ci->ci_type);
-                               cp = getcpy(cp);
+                               cp = mh_xstrdup(cp);
                                mh_free0(&(ci->ci_magic));
                                ci->ci_magic = cp;
                        } else {
@@ -834,7 +834,7 @@ use_forw:
                                exit(EX_CONFIG);
                        }
                }
-               ci->ci_magic = getcpy(cp);
+               ci->ci_magic = mh_xstrdup(cp);
                return OK;
        }
 
@@ -869,13 +869,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);
@@ -923,7 +923,7 @@ use_forw:
                                        snprintf(buffer, sizeof(buffer),
                                                        "%s/%d", mp->foldpath,
                                                        msgnum);
-                                       pe->ce_file = getcpy(buffer);
+                                       pe->ce_file = mh_xstrdup(buffer);
 
                                        part = mh_xcalloc(1, sizeof(*part));
                                        *pp = part;
@@ -941,7 +941,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 */
@@ -1030,10 +1030,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);
 }
 
 
@@ -1071,7 +1071,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;
                }
@@ -1102,7 +1102,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;
@@ -1389,7 +1389,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++, '=');
@@ -1451,7 +1451,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;
@@ -1460,7 +1460,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 */
@@ -1510,7 +1510,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);
        }
@@ -1519,7 +1519,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);
@@ -1531,7 +1531,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);
        }
@@ -1548,7 +1548,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;
@@ -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(" ", "quoted-printable", "\n", NULL);
                add_header(ct, np, vp);
                break;
@@ -1566,7 +1566,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;
@@ -1575,7 +1575,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 ddf32ec..e4e8dbf 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;
@@ -459,7 +459,7 @@ evalvar(struct mcomp *c1)
                cp = concat("=", cp, NULL);
                fmtstr = new_fs(cp, NULL);
                mh_free0(&cp);
-               c1->c_fstr = getcpy(fmtstr);
+               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;
@@ -769,7 +769,7 @@ 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);
 
                mh_free0(&ap);
                return;
@@ -780,10 +780,10 @@ mcomp_format(struct mcomp *c1, struct mcomp *c2)
                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);
@@ -827,12 +827,12 @@ add_queue(struct mcomp **head, struct mcomp **tail, char *name,
        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;
index 72dc9ed..c9194cc 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!");
index 46b0d4c..dd6264b 100644 (file)
@@ -174,8 +174,7 @@ 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));
+               dp = trimcpy(cp = mh_xstrdup(ct->c_descr));
                mh_free0(&cp);
                printf(LSTFMT2d1, dp);
                mh_free0(&dp);
index 1515858..06630b3 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 f04a348..71c1e8e 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))
@@ -241,7 +241,7 @@ get_content(FILE *in, char *file, int toplevel)
        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;
 
        /*
@@ -255,8 +255,8 @@ get_content(FILE *in, char *file, int toplevel)
                        compnum++;
 
                        /* get copies of the buffers */
-                       np = getcpy(name);
-                       vp = getcpy(buf);
+                       np = mh_xstrdup(name);
+                       vp = mh_xstrdup(buf);
 
                        /* if necessary, get rest of field */
                        while (state == FLDPLUS) {
@@ -311,7 +311,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;
@@ -383,7 +383,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++;
@@ -530,7 +530,7 @@ 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';
@@ -603,7 +603,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++;
@@ -627,7 +627,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) {
@@ -649,7 +649,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;
        }
 
@@ -663,7 +663,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) {
@@ -720,7 +720,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++;
@@ -857,7 +857,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
@@ -926,7 +926,7 @@ invalid:
                        ci->ci_comment = concat(dp, " ", buffer, NULL);
                        mh_free0(&dp);
                } else {
-                       ci->ci_comment = getcpy(buffer);
+                       ci->ci_comment = mh_xstrdup(buffer);
                }
        }
 
@@ -986,7 +986,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)) {
@@ -1173,7 +1173,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) {
@@ -1278,7 +1278,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")) {
@@ -1511,10 +1511,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;
        }
 
@@ -1534,7 +1534,7 @@ 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 ",
@@ -1722,10 +1722,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;
        }
 
@@ -1745,7 +1745,7 @@ 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 ",
@@ -1939,10 +1939,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;
        }
 
@@ -1962,7 +1962,7 @@ 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 ",
index c400fa6..aa63f4d 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 dc5c202..e39bf65 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:
@@ -175,7 +175,7 @@ main(int argc, char **argv)
                                                        argp[-2]);
                                if (formsw)
                                        mh_free0(&formsw);
-                               formsw = getcpy(etcpath(cp));
+                               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!");
index 6298869..c7923c8 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.
@@ -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);
@@ -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 4f84570..adaca77 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!");
@@ -382,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;
@@ -490,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;
                }
@@ -728,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;
                }
@@ -772,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();
 
@@ -784,7 +784,7 @@ 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])
                        mh_free0(&folder);
@@ -806,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 0fa9741..cecf2ee 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!");
index 25ee492..5bc7136 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++) {
@@ -114,7 +114,7 @@ get_msgnums(char *folder, char *sequences[])
                case FLD:
                case FLDPLUS:
                        if (state == FLDPLUS) {
-                               cp = getcpy(field);
+                               cp = mh_xstrdup(field);
                                while (state == FLDPLUS) {
                                        state = m_getfld(state, name, field,
                                                        sizeof(field), fp);
@@ -258,7 +258,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);
        }
@@ -514,7 +514,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 c81db88..a8c2c42 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 0465ef5..1df59b1 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:
@@ -1254,7 +1254,7 @@ plist
                        if (bp != NULL) {
                                mh_free0(&bp);
                        }
-                       bp = getcpy(buf);
+                       bp = mh_xstrdup(buf);
                        while (state == FLDPLUS) {
                                state = m_getfld(state, name, buf,
                                                sizeof buf, fp);
index e3c38cd..f3caa50 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) {
index 9c84270..5fd9ae0 100644 (file)
@@ -7,6 +7,7 @@
 */
 
 #include <h/mh.h>
+#include <h/utils.h>
 #include <fcntl.h>
 #include <h/signals.h>
 #include <errno.h>
@@ -138,7 +139,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 ab5d55f..e75deb9 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);
        }
@@ -184,7 +184,7 @@ main(int argc, char **argv)
        */
        for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) {
                if (is_selected(mp, msgnum)) {
-                       cp = getcpy(m_name(msgnum));
+                       cp = mh_xstrdup(m_name(msgnum));
                        if (m_file(cp, folders, foldp, !linkf))
                                exit(EX_IOERR);
                        mh_free0(&cp);
index 505160e..e3028fa 100644 (file)
@@ -151,7 +151,7 @@ main(int argc, char **argv)
        /* read user profile/context */
        context_read();
 
-       filter = getcpy(etcpath(mhlreply));
+       filter = mh_xstrdup(etcpath(mhlreply));
 
        arguments = getarguments(invo_name, argc, argv, 1);
        argp = arguments;
@@ -223,7 +223,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 == '-')
@@ -235,7 +235,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;
@@ -261,7 +261,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!");
@@ -277,7 +277,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");
@@ -331,7 +331,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");
@@ -445,7 +445,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);
@@ -536,7 +536,7 @@ finished:
                }
                if (sp != cptr->c_text) {
                        cp = cptr->c_text;
-                       cptr->c_text = getcpy(sp);
+                       cptr->c_text = mh_xstrdup(sp);
                        mh_free0(&cp);
                }
        }
@@ -625,7 +625,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.
index 64ee68c..e435a27 100644 (file)
--- a/uip/rmf.c
+++ b/uip/rmf.c
@@ -77,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);
@@ -224,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
index 3237deb..99820e9 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);
index e595857..dc54bf0 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,7 +99,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);
        }
@@ -176,7 +176,7 @@ 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);
index d7cf204..619ff62 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");
                }
index 17a1d36..18c4a58 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);
        }
 
        /*
@@ -761,7 +761,7 @@ parse(int fd)
                                in)) {
                case FLD:
                case FLDPLUS:
-                       lp = getcpy(field);
+                       lp = mh_xstrdup(field);
                        while (state == FLDPLUS) {
                                state = m_getfld(state, name, field,
                                                sizeof(field), in);
@@ -788,7 +788,7 @@ parse(int fd)
                                }
                        }
                        if (!p->p_name && i < NVEC) {
-                               p->p_name = getcpy(name);
+                               p->p_name = mh_xstrdup(name);
                                p->p_value = lp;
                                p->p_flags = P_NIL;
                                p++, i++;
@@ -818,7 +818,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",
@@ -891,18 +891,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++) {
@@ -1090,7 +1090,7 @@ get_sender(char *envelope, char **sender)
        unsigned char buffer[BUFSIZ];
 
        if (!envelope) {
-               *sender = getcpy("");
+               *sender = mh_xstrdup("");
                return;
        }
 
@@ -1114,7 +1114,7 @@ get_sender(char *envelope, char **sender)
                } else {
                        break;
                }
-       *sender = getcpy(buffer);
+       *sender = mh_xstrdup(buffer);
 }
 
 
@@ -1194,7 +1194,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);
@@ -1264,7 +1264,7 @@ trimstr(char *cp)
                        *sp = ' ';
                }
        }
-       return getcpy(bp);
+       return mh_xstrdup(bp);
 }
 
 /*
index 8f1d2ea..0c5511d 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);
        }
index e2b5a88..aacb633 100644 (file)
@@ -211,7 +211,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 */
@@ -219,7 +219,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",
@@ -236,7 +236,7 @@ main(int argc, char **argv)
                case FLD:
                case FLDPLUS:
                        compnum++;
-                       cp = getcpy(buf);
+                       cp = mh_xstrdup(buf);
                        while (state == FLDPLUS) {
                                state = m_getfld(state, name, buf,
                                                sizeof(buf), in);
@@ -329,7 +329,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);
@@ -405,7 +405,7 @@ putfmt(char *name, char *str, FILE *out)
        }
 
        if (hdr->flags & HSUB) {
-               subject = getcpy(str);
+               subject = mh_xstrdup(str);
        }
 
        if (!(hdr->flags & HADR)) {
@@ -551,7 +551,7 @@ 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);
                                mh_free0(&cp);
@@ -666,7 +666,7 @@ 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);
index 4b45a0c..65d2fb0 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 27c8d91..b987356 100644 (file)
@@ -222,7 +222,7 @@ process(char *file)
 
                case FLDPLUS:
                        compnum++;
-                       cp = getcpy(buf);
+                       cp = mh_xstrdup(buf);
                        while (state == FLDPLUS) {
                                state = m_getfld(state, name, buf,
                                                sizeof(buf), in);