From: Ralph Corderoy Date: Sun, 27 Aug 2017 11:13:39 +0000 (+0100) Subject: Replace add(foo, NULL) with mh_xstrdup(foo). X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/9e4dbc2d5379b96a8d90e28cf8fce803d6cc1ff4?ds=inline;hp=2fc70e8bf64ead869fce76abb74f04bf1af94923 Replace add(foo, NULL) with mh_xstrdup(foo). 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. --- diff --git a/sbr/m_mktemp.c b/sbr/m_mktemp.c index 9a28b48a..d4b8fde0 100644 --- a/sbr/m_mktemp.c +++ b/sbr/m_mktemp.c @@ -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)); } /* diff --git a/uip/aliasbr.c b/uip/aliasbr.c index 1376cad7..b3978ef4 100644 --- a/uip/aliasbr.c +++ b/uip/aliasbr.c @@ -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? */ diff --git a/uip/mhbuildsbr.c b/uip/mhbuildsbr.c index a615dcf9..bccf33a9 100644 --- a/uip/mhbuildsbr.c +++ b/uip/mhbuildsbr.c @@ -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; } diff --git a/uip/mhlsbr.c b/uip/mhlsbr.c index e7651f58..5140b88e 100644 --- a/uip/mhlsbr.c +++ b/uip/mhlsbr.c @@ -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; diff --git a/uip/mhparse.c b/uip/mhparse.c index 2842b0c6..08d22407 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -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")) { diff --git a/uip/mhshowsbr.c b/uip/mhshowsbr.c index 0a40bfc1..99bb4067 100644 --- a/uip/mhshowsbr.c +++ b/uip/mhshowsbr.c @@ -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; diff --git a/uip/mhstoresbr.c b/uip/mhstoresbr.c index 2bc78ceb..46fd8ed0 100644 --- a/uip/mhstoresbr.c +++ b/uip/mhstoresbr.c @@ -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) {