]> diplodocus.org Git - nmh/commitdiff
Replace add(foo, NULL) with mh_xstrdup(foo).
authorRalph Corderoy <ralph@inputplus.co.uk>
Sun, 27 Aug 2017 11:13:39 +0000 (12:13 +0100)
committerRalph Corderoy <ralph@inputplus.co.uk>
Sun, 27 Aug 2017 11:13:39 +0000 (12:13 +0100)
add()'s arguments are back to front so add(foo, bar) produces bar+foo in
the normal case.  Thus add(foo, NULL) is read as the jarring NULL+foo.
Removing the NULL with mh_xstrdup() avoids this.  FENDNULL is used when
it isn't obvious foo can't be NULL as add() treats it as "" in that
case.

sbr/m_mktemp.c
uip/aliasbr.c
uip/mhbuildsbr.c
uip/mhlsbr.c
uip/mhparse.c
uip/mhshowsbr.c
uip/mhstoresbr.c

index 9a28b48af587dba8d8bcb62221dcfd037bb1537c..d4b8fde05154d28b954463c115697cfb62203339 100644 (file)
@@ -258,7 +258,7 @@ static svector_t exit_filelist = NULL;
 static void
 register_for_removal(const char *pathname) {
     if (exit_filelist == NULL) exit_filelist = svector_create(20);
-    (void) svector_push_back(exit_filelist, add(pathname, NULL));
+    (void) svector_push_back(exit_filelist, mh_xstrdup(pathname));
 }
 
 /*
index 1376cad7eaada9724c26d913d092e2c73ea972f2..b3978ef416b2c2bd95ddb93c08b1eb124fd40be2 100644 (file)
@@ -120,7 +120,7 @@ akval (struct aka *ak, char *s)
                struct mailname *mp = getm (name, NULL, 0, NULL, 0);
 
                if (mp  &&  mp->m_ingrp) {
-                   char *gname = add (mp->m_gname, NULL);
+                   char *gname = mh_xstrdup(FENDNULL(mp->m_gname));
 
                     /* FIXME: gname must be true;  add() never returns NULL.
                     * Is some other test required? */
index a615dcf9704bd55ed484f051bf02ad0c64c0a35b..bccf33a90aa7a3b22ae11f0070a7edca04d71c61 100644 (file)
@@ -590,7 +590,7 @@ init_decoded_content (CT ct, const char *filename)
     ct->c_ceclosefnx = close_encoding;
     ct->c_cesizefnx  = NULL;           /* since unencoded */
     ct->c_encoding = CE_7BIT;          /* Seems like a reasonable default */
-    ct->c_file = add(filename, NULL);
+    ct->c_file = mh_xstrdup(FENDNULL(filename));
 
     return OK;
 }
index e7651f584992a21ba81bbbf9290314b3030ce0e8..5140b88eefb689a3d97e49614b38ef8ce18bafde 100644 (file)
@@ -1294,7 +1294,7 @@ putcomp (struct mcomp *c1, struct mcomp *c2, int flag)
     text = c1->c_text ? c1->c_text : c1->c_name;
     /* Create a copy with trailing whitespace trimmed, for use with
      * blank lines. */
-    trimmed_prefix = rtrim(add(text, NULL));
+    trimmed_prefix = rtrim(mh_xstrdup(FENDNULL(text)));
 
     cchdr = 0;
     lm = 0;
index 2842b0c65781680e823f1a08b90ccd074d94f96d..08d2240734ade1a54337b63d3a32c9d2f0526f38 100644 (file)
@@ -300,7 +300,7 @@ get_content (FILE *in, char *file, int toplevel)
     /* allocate the content structure */
     NEW0(ct);
     ct->c_fp = in;
-    ct->c_file = add (file, NULL);
+    ct->c_file = mh_xstrdup(FENDNULL(file));
     ct->c_begin = ftell (ct->c_fp) + 1;
 
     /*
@@ -391,7 +391,7 @@ get_content (FILE *in, char *file, int toplevel)
            char c, *cp, *dp;
            char *vrsn;
 
-           vrsn = add (hp->value, NULL);
+           vrsn = mh_xstrdup(FENDNULL(hp->value));
 
            /* Now, cleanup this field */
            cp = vrsn;
@@ -474,7 +474,7 @@ get_content (FILE *in, char *file, int toplevel)
            }
 
            /* get copy of this field */
-           ct->c_celine = cp = add (hp->value, NULL);
+           ct->c_celine = cp = mh_xstrdup(FENDNULL(hp->value));
 
            while (isspace ((unsigned char) *cp))
                cp++;
@@ -512,7 +512,7 @@ get_content (FILE *in, char *file, int toplevel)
                goto next_header;
            }
 
-           ep = cp = add (hp->value, NULL);    /* get a copy */
+           ep = cp = mh_xstrdup(FENDNULL(hp->value)); /* get a copy */
 
            while (isspace ((unsigned char) *cp))
                cp++;
@@ -642,7 +642,7 @@ get_ctinfo (char *cp, CT ct, int magic)
     ci = &ct->c_ctinfo;
 
     /* store copy of Content-Type line */
-    cp = ct->c_ctline = add (cp, NULL);
+    cp = ct->c_ctline = mh_xstrdup(FENDNULL(cp));
 
     while (isspace ((unsigned char) *cp))      /* trim leading spaces */
        cp++;
@@ -891,7 +891,7 @@ get_dispo (char *cp, CT ct, int buildflag)
      * time.
      */
 
-    dispoheader = cp = add(cp, NULL);
+    dispoheader = cp = mh_xstrdup(FENDNULL(cp));
 
     while (isspace ((unsigned char) *cp))      /* trim leading spaces */
        cp++;
@@ -1436,7 +1436,7 @@ InitMessage (CT ct)
                /* scan for parameters "id", "number", and "total" */
                for (pm = ci->ci_first_pm; pm; pm = pm->pm_next) {
                    if (!strcasecmp (pm->pm_name, "id")) {
-                       p->pm_partid = add (pm->pm_value, NULL);
+                       p->pm_partid = mh_xstrdup(FENDNULL(pm->pm_value));
                        continue;
                    }
                    if (!strcasecmp (pm->pm_name, "number")) {
index 0a40bfc197af51637fd58530ab3470e58183b128..99bb406777376d75136c544087fa02445180c5dd 100644 (file)
@@ -714,7 +714,7 @@ show_multi_aux (CT ct, int alternate, char *cp, struct format *fmt)
            if ((*p->c_ceopenfnx) (p, &file) == NOTOK)
                return NOTOK;
 
-           p->c_storage = add (file, NULL);
+           p->c_storage = mh_xstrdup(FENDNULL(file));
 
            if (p->c_showproc && !strcmp (p->c_showproc, "true"))
                return OK;
index 2bc78ceb948f43fdcfdc8e9baf23a305b5be5f06..46fd8ed0e18e136fd6ac8ca62ff08b6e39dfb8b2 100644 (file)
@@ -531,7 +531,7 @@ store_content (CT ct, CT p, mhstoreinfo_t info)
        if (p) {
            appending = 1;
             if (! ct->c_storage) {
-               ct->c_storage = add (p->c_storage, NULL);
+               ct->c_storage = mh_xstrdup(FENDNULL(p->c_storage));
 
                /* record the folder name */
                if (p->c_folder) {