From: Ralph Corderoy Date: Sun, 13 Nov 2016 01:05:09 +0000 (+0000) Subject: Replace many add(s, NULL) with mh_xstrdup(s). X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/bc4927948a1b01bf2ae8b952dfd2639c1f929f00?ds=inline Replace many add(s, NULL) with mh_xstrdup(s). Where s is known to be non-NULL. --- diff --git a/sbr/encode_rfc2047.c b/sbr/encode_rfc2047.c index aff04c81..d1ccd2e9 100644 --- a/sbr/encode_rfc2047.c +++ b/sbr/encode_rfc2047.c @@ -743,7 +743,7 @@ do_reformat: groupflag = mn->m_ingrp; if (mn->m_gname) { - cp = add(mn->m_gname, NULL); + cp = mh_xstrdup(mn->m_gname); } if (reformat) { diff --git a/sbr/m_mktemp.c b/sbr/m_mktemp.c index 2ab8d129..15bee939 100644 --- a/sbr/m_mktemp.c +++ b/sbr/m_mktemp.c @@ -155,7 +155,7 @@ m_mktemps( if (suffix == NULL) { if ((tmpfil = m_mktemp2(NULL, pfx_in, fd_ret, fp_ret))) { - return add(tmpfil, NULL); + return mh_xstrdup(tmpfil); } return NULL; } diff --git a/sbr/trimcpy.c b/sbr/trimcpy.c index 50e7142e..8cdb065b 100644 --- a/sbr/trimcpy.c +++ b/sbr/trimcpy.c @@ -58,7 +58,7 @@ cpytrim (const char *sp) { /* skip over leading whitespace */ while (isspace ((unsigned char) *sp)) ++sp; - dp = add (sp, NULL); + dp = mh_xstrdup(sp); /* start at the end and zap trailing whitespace */ for (cp = dp + strlen (dp) - 1; diff --git a/uip/mhbuildsbr.c b/uip/mhbuildsbr.c index 5a0001bf..5607be17 100644 --- a/uip/mhbuildsbr.c +++ b/uip/mhbuildsbr.c @@ -204,8 +204,8 @@ build_mime (char *infile, int autobuild, int dist, int directives, } /* get copies of the buffers */ - np = add (name, NULL); - vp = add (buf, NULL); + np = mh_xstrdup(name); + vp = mh_xstrdup(buf); /* if necessary, get rest of field */ while (state == FLDPLUS) { @@ -704,7 +704,7 @@ user_content (FILE *in, char *buf, CT *ctp, const char *infilename) } /* use a temp file to collect the plain text lines */ - ce->ce_file = add (cp, NULL); + ce->ce_file = mh_xstrdup(cp); ce->ce_unlink = 1; if (do_direct() && (buf[0] == '#' && buf[1] == '<')) { @@ -931,7 +931,7 @@ use_forw: continue; if (!*cp) adios (NULL, "empty pipe command for #%s directive", ci->ci_type); - cp = add (cp, NULL); + cp = mh_xstrdup(cp); free (ci->ci_magic); ci->ci_magic = cp; } else { @@ -955,7 +955,7 @@ use_forw: content_error (NULL, ct, "don't know how to compose content"); done (1); } - ci->ci_magic = add (cp, NULL); + ci->ci_magic = mh_xstrdup(cp); return OK; } @@ -1038,7 +1038,7 @@ use_forw: p->c_subtype = MESSAGE_RFC822; snprintf (buffer, sizeof(buffer), "%s/%d", mp->foldpath, msgnum); - pe->ce_file = add (buffer, NULL); + pe->ce_file = mh_xstrdup(buffer); if (listsw && stat (pe->ce_file, &st) != NOTOK) p->c_end = (long) st.st_size; @@ -1057,7 +1057,7 @@ use_forw: msgnum = mp->lowsel; snprintf (buffer, sizeof(buffer), "%s/%d", mp->foldpath, msgnum); - ce->ce_file = add (buffer, NULL); + ce->ce_file = mh_xstrdup(buffer); if (listsw && stat (ce->ce_file, &st) != NOTOK) ct->c_end = (long) st.st_size; } @@ -1186,7 +1186,7 @@ compose_content (CT ct, int verbose) CT p = part->mp_part; sprintf (pp, "%d", partnum); - p->c_partno = add (partnam, NULL); + p->c_partno = mh_xstrdup(partnam); if (compose_content (p, verbose) == NOTOK) return NOTOK; } @@ -1252,7 +1252,7 @@ compose_content (CT ct, int verbose) adios("mhbuildsbr", "unable to create temporary file in %s", get_temp_dir()); } - ce->ce_file = add (tfile, NULL); + ce->ce_file = mh_xstrdup(tfile); ce->ce_unlink = 1; xstdout = 0; diff --git a/uip/mhcachesbr.c b/uip/mhcachesbr.c index e91cc56e..7ac0a0de 100644 --- a/uip/mhcachesbr.c +++ b/uip/mhcachesbr.c @@ -388,7 +388,7 @@ find_cache_aux2 (char *mapfile, char *id, char *mapname, int namelen) if (state != FLDPLUS) cp = buf; else { - cp = add (buf, NULL); + cp = mh_xstrdup(buf); while (state == FLDPLUS) { bufsz = sizeof buf; state = m_getfld (&gstate, name, buf, &bufsz, fp); diff --git a/uip/mhical.c b/uip/mhical.c index 6a35bed5..573d7cf4 100644 --- a/uip/mhical.c +++ b/uip/mhical.c @@ -140,12 +140,12 @@ main (int argc, char *argv[]) { case INFILESW: if (! (cp = *argp++) || (*cp == '-' && cp[1])) adios (NULL, "missing argument to %s", argp[-2]); - infile = *cp == '-' ? add (cp, NULL) : path (cp, TFILE); + infile = *cp == '-' ? mh_xstrdup(cp) : path (cp, TFILE); continue; case OUTFILESW: if (! (cp = *argp++) || (*cp == '-' && cp[1])) adios (NULL, "missing argument to %s", argp[-2]); - outfile = *cp == '-' ? add (cp, NULL) : path (cp, TFILE); + outfile = *cp == '-' ? mh_xstrdup(cp) : path (cp, TFILE); continue; case CONTENTTYPESW: diff --git a/uip/mhparse.c b/uip/mhparse.c index d729768a..42566aaa 100644 --- a/uip/mhparse.c +++ b/uip/mhparse.c @@ -222,7 +222,7 @@ parse_mime (char *file) get_temp_dir()); return NULL; } - file = add (tfile, NULL); + file = mh_xstrdup(tfile); while ((n = fread(buffer, 1, sizeof(buffer), stdin)) > 0) { if (fwrite(buffer, 1, n, fp) != n) { @@ -317,8 +317,8 @@ get_content (FILE *in, char *file, int toplevel) compnum++; /* get copies of the buffers */ - np = add (name, NULL); - vp = add (buf, NULL); + np = mh_xstrdup(name); + vp = mh_xstrdup(buf); /* if necessary, get rest of field */ while (state == FLDPLUS) { @@ -654,7 +654,7 @@ get_ctinfo (char *cp, CT ct, int magic) for (dp = cp; istoken (*dp); dp++) continue; c = *dp, *dp = '\0'; - ci->ci_type = add (cp, NULL); /* store content type */ + ci->ci_type = mh_xstrdup(cp); /* store content type */ *dp = c, cp = dp; if (!*ci->ci_type) { @@ -673,7 +673,7 @@ get_ctinfo (char *cp, CT ct, int magic) if (*cp != '/') { if (!magic) - ci->ci_subtype = add ("", NULL); + ci->ci_subtype = mh_xstrdup(""); goto magic_skip; } @@ -688,7 +688,7 @@ get_ctinfo (char *cp, CT ct, int magic) for (dp = cp; istoken (*dp); dp++) continue; c = *dp, *dp = '\0'; - ci->ci_subtype = add (cp, NULL); /* store the content subtype */ + ci->ci_subtype = mh_xstrdup(cp); /* store the content subtype */ *dp = c, cp = dp; if (!*ci->ci_subtype) { @@ -836,7 +836,7 @@ magic_skip: */ if (*cp) { if (magic) { - ci->ci_magic = add (cp, NULL); + ci->ci_magic = mh_xstrdup(cp); /* If there is a Content-Disposition header and it doesn't have a *filename=, extract it from the magic contents. @@ -903,7 +903,7 @@ get_dispo (char *cp, CT ct, int buildflag) for (dp = cp; istoken (*dp); dp++) continue; c = *dp, *dp = '\0'; - ct->c_dispo_type = add (cp, NULL); /* store disposition type */ + ct->c_dispo_type = mh_xstrdup(cp); /* store disposition type */ *dp = c, cp = dp; if (*cp == '(' && get_comment (ct->c_file, DISPO_FIELD, &cp, NULL) == NOTOK) @@ -980,7 +980,7 @@ invalid: *commentp = concat (dp, " ", buffer, NULL); free (dp); } else { - *commentp = add (buffer, NULL); + *commentp = mh_xstrdup(buffer); } } @@ -1092,7 +1092,7 @@ InitMultiPart (CT ct) ct->c_encoding != CE_8BIT && ct->c_encoding != CE_BINARY) { /* Copy the Content-Transfer-Encoding header field body so we can remove any trailing whitespace and leading blanks from it. */ - char *cte = add (ct->c_celine ? ct->c_celine : "(null)", NULL); + char *cte = mh_xstrdup(ct->c_celine ? ct->c_celine : "(null)"); bp = cte + strlen (cte) - 1; while (bp >= cte && isspace ((unsigned char) *bp)) *bp-- = '\0'; @@ -1257,7 +1257,7 @@ last_part: p = part->mp_part; sprintf (pp, "%d", partnum); - p->c_partno = add (partnam, NULL); + p->c_partno = mh_xstrdup(partnam); /* initialize the content of the subparts */ if (p->c_ctinitfnx && (*p->c_ctinitfnx) (p) == NOTOK) { @@ -1764,7 +1764,7 @@ openBase64 (CT ct, char **file) if (*file == NULL) { ce->ce_unlink = 1; } else { - ce->ce_file = add (*file, NULL); + ce->ce_file = mh_xstrdup(*file); ce->ce_unlink = 0; } @@ -1786,7 +1786,7 @@ openBase64 (CT ct, char **file) adios(NULL, "unable to create temporary file in %s", get_temp_dir()); } - ce->ce_file = add (tempfile, NULL); + ce->ce_file = mh_xstrdup(tempfile); } if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) { @@ -1948,7 +1948,7 @@ openQuoted (CT ct, char **file) if (*file == NULL) { ce->ce_unlink = 1; } else { - ce->ce_file = add (*file, NULL); + ce->ce_file = mh_xstrdup(*file); ce->ce_unlink = 0; } @@ -1970,7 +1970,7 @@ openQuoted (CT ct, char **file) adios(NULL, "unable to create temporary file in %s", get_temp_dir()); } - ce->ce_file = add (tempfile, NULL); + ce->ce_file = mh_xstrdup(tempfile); } if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) { @@ -2168,7 +2168,7 @@ open7Bit (CT ct, char **file) if (*file == NULL) { ce->ce_unlink = 1; } else { - ce->ce_file = add (*file, NULL); + ce->ce_file = mh_xstrdup(*file); ce->ce_unlink = 0; } @@ -2190,7 +2190,7 @@ open7Bit (CT ct, char **file) adios(NULL, "unable to create temporary file in %s", get_temp_dir()); } - ce->ce_file = add (tempfile, NULL); + ce->ce_file = mh_xstrdup(tempfile); } if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) { @@ -2533,16 +2533,16 @@ openFTP (CT ct, char **file) } if (*file) - ce->ce_file = add (*file, NULL); + ce->ce_file = mh_xstrdup(*file); else if (caching) - ce->ce_file = add (cachefile, NULL); + ce->ce_file = mh_xstrdup(cachefile); else { char *tempfile; if ((tempfile = m_mktemp2(NULL, invo_name, NULL, NULL)) == NULL) { adios(NULL, "unable to create temporary file in %s", get_temp_dir()); } - ce->ce_file = add (tempfile, NULL); + ce->ce_file = mh_xstrdup(tempfile); } if ((ce->ce_fp = fopen (ce->ce_file, "w+")) == NULL) { @@ -2731,10 +2731,10 @@ openMail (CT ct, char **file) adios(NULL, "unable to create temporary file in %s", get_temp_dir()); } - ce->ce_file = add (tempfile, NULL); + ce->ce_file = mh_xstrdup(tempfile); ce->ce_unlink = 1; } else { - ce->ce_file = add (*file, NULL); + ce->ce_file = mh_xstrdup(*file); ce->ce_unlink = 0; } @@ -2746,7 +2746,7 @@ openMail (CT ct, char **file) /* showproc is for mhshow and mhstore, though mhlist -debug * prints it, too. */ mh_xfree(ct->c_showproc); - ct->c_showproc = add ("true", NULL); + ct->c_showproc = mh_xstrdup("true"); fseek (ce->ce_fp, 0L, SEEK_SET); *file = ce->ce_file; @@ -2813,16 +2813,16 @@ openURL (CT ct, char **file) } if (*file) - ce->ce_file = add(*file, NULL); + ce->ce_file = mh_xstrdup(*file); else if (caching) - ce->ce_file = add(cachefile, NULL); + ce->ce_file = mh_xstrdup(cachefile); else { char *tempfile; if ((tempfile = m_mktemp2(NULL, invo_name, NULL, NULL)) == NULL) { adios(NULL, "unable to create temporary file in %s", get_temp_dir()); } - ce->ce_file = add (tempfile, NULL); + ce->ce_file = mh_xstrdup(tempfile); } if ((ce->ce_fp = fopen(ce->ce_file, "w+")) == NULL) { diff --git a/uip/mhshowsbr.c b/uip/mhshowsbr.c index e8ce3f36..7298f5b0 100644 --- a/uip/mhshowsbr.c +++ b/uip/mhshowsbr.c @@ -539,7 +539,7 @@ show_text (CT ct, int alternate, int concatsw, struct format *fmt) } else snprintf (buffer, sizeof(buffer), "%%l%s %%F", progsw ? progsw : moreproc && *moreproc ? moreproc : DEFAULT_PAGER); - cp = (ct->c_showproc = add (buffer, NULL)); + cp = (ct->c_showproc = mh_xstrdup(buffer)); return show_content_aux (ct, alternate, cp, NULL, fmt); } @@ -747,7 +747,7 @@ show_message_rfc822 (CT ct, int alternate, struct format *fmt) /* default method for message/rfc822 */ if (ct->c_subtype == MESSAGE_RFC822) { - cp = (ct->c_showproc = add ("%pshow -file %F", NULL)); + cp = (ct->c_showproc = mh_xstrdup("%pshow -file %F")); return show_content_aux (ct, alternate, cp, NULL, fmt); } @@ -1094,7 +1094,7 @@ convert_charset (CT ct, char *dest_charset, int *message_mods) { adios (NULL, "unable to create temporary file in %s", get_temp_dir()); } - dest = add (tempfile, NULL); + dest = mh_xstrdup(tempfile); if (ct->c_cefile.ce_file) { file = &ct->c_cefile.ce_file; diff --git a/uip/mhstore.c b/uip/mhstore.c index 183fe7d4..98e62396 100644 --- a/uip/mhstore.c +++ b/uip/mhstore.c @@ -284,7 +284,7 @@ do_cache: if ((ct = parse_mime (file))) { *ctp++ = ct; if (outfile) { - ct->c_storage = add (outfile, NULL); + ct->c_storage = mh_xstrdup(outfile); } } } else { @@ -325,7 +325,7 @@ do_cache: if ((ct = parse_mime (msgnam))) { *ctp++ = ct; if (outfile) { - ct->c_storage = add (outfile, NULL); + ct->c_storage = mh_xstrdup(outfile); } } } diff --git a/uip/mhstoresbr.c b/uip/mhstoresbr.c index a2bc919e..210a91be 100644 --- a/uip/mhstoresbr.c +++ b/uip/mhstoresbr.c @@ -292,7 +292,7 @@ store_multi (CT ct, mhstoreinfo_t info) /* Support mhstore -outfile. The MIME parser doesn't load c_storage, so we know that p->c_storage is NULL here. */ - p->c_storage = add (ct->c_storage, NULL); + p->c_storage = mh_xstrdup(ct->c_storage); } result = store_switch (p, info); @@ -438,9 +438,9 @@ store_external (CT ct, mhstoreinfo_t info) && *cp != '!' && !strchr (cp, '%')) { if (!ct->c_storeproc) - ct->c_storeproc = add (cp, NULL); + ct->c_storeproc = mh_xstrdup(cp); if (!p->c_storeproc) - p->c_storeproc = add (cp, NULL); + p->c_storeproc = mh_xstrdup(cp); } } @@ -456,7 +456,7 @@ store_external (CT ct, mhstoreinfo_t info) if (ct->c_storage) { /* Support mhstore -outfile. The MIME parser doesn't load c_storage, so we know that p->c_storage is NULL here. */ - p->c_storage = add (ct->c_storage, NULL); + p->c_storage = mh_xstrdup(ct->c_storage); } result = store_switch (p, info); @@ -537,7 +537,7 @@ store_content (CT ct, CT p, mhstoreinfo_t info) /* record the folder name */ if (p->c_folder) { - ct->c_folder = add (p->c_folder, NULL); + ct->c_folder = mh_xstrdup(p->c_folder); } } goto got_filename; @@ -575,7 +575,7 @@ store_content (CT ct, CT p, mhstoreinfo_t info) adios(NULL, "unable to create temporary file in %s", get_temp_dir()); } - ct->c_storage = add (tmpfilenam, NULL); + ct->c_storage = mh_xstrdup(tmpfilenam); /* Get the folder name */ if (cp[1]) @@ -609,7 +609,7 @@ store_content (CT ct, CT p, mhstoreinfo_t info) return show_content_aux (ct, 0, buffer + 1, info->dir, NULL); /* record the filename */ - if ((ct->c_storage = clobber_check (add (buffer, NULL), info)) == + if ((ct->c_storage = clobber_check (mh_xstrdup(buffer), info)) == NULL) { return NOTOK; } @@ -1074,7 +1074,7 @@ get_storeproc (CT ct) && *cp != '|' && *cp != '!' && !strchr (cp, '%')) { - ct->c_storeproc = add (cp, NULL); + ct->c_storeproc = mh_xstrdup(cp); free(cp); return; } @@ -1093,7 +1093,7 @@ get_storeproc (CT ct) && *cp != '|' && *cp != '!' && !strchr (cp, '%')) { - ct->c_storeproc = add (cp, NULL); + ct->c_storeproc = mh_xstrdup(cp); } mh_xfree(cp); @@ -1239,7 +1239,7 @@ clobber_check (char *original_file, mhstoreinfo_t info) { /* Save cwd for possible use in loop below. */ char *slash; - cwd = add (original_file, NULL); + cwd = mh_xstrdup(original_file); slash = strrchr (cwd, '/'); if (slash) { @@ -1316,10 +1316,10 @@ clobber_check (char *original_file, mhstoreinfo_t info) { if (buf[0] == '/') { /* Full path, use it. */ - file = add (buf, NULL); + file = mh_xstrdup(buf); } else { /* Relative path. */ - file = cwd ? concat (cwd, "/", buf, NULL) : add (buf, NULL); + file = cwd ? concat (cwd, "/", buf, NULL) : mh_xstrdup(buf); } check_again = 1; diff --git a/uip/picksbr.c b/uip/picksbr.c index 6433d2d0..3d9c5b5b 100644 --- a/uip/picksbr.c +++ b/uip/picksbr.c @@ -946,7 +946,7 @@ plist case FLD: case FLDPLUS: mh_xfree(bp); - bp = add (buf, NULL); + bp = mh_xstrdup(buf); while (state == FLDPLUS) { bufsz = sizeof buf; state = m_getfld (&gstate, name, buf, &bufsz, fp); diff --git a/uip/post.c b/uip/post.c index 95b23aab..e62473e7 100644 --- a/uip/post.c +++ b/uip/post.c @@ -623,7 +623,7 @@ main (int argc, char **argv) case FLD: case FLDPLUS: compnum++; - cp = add (buf, NULL); + cp = mh_xstrdup(buf); while (state == FLDPLUS) { bufsz = sizeof buf; state = m_getfld (&gstate, name, buf, &bufsz, in); diff --git a/uip/show.c b/uip/show.c index 25ed7573..9aa84b39 100644 --- a/uip/show.c +++ b/uip/show.c @@ -386,7 +386,7 @@ is_nontext (char *msgnam) int passno; char c; - cp = add (buf, NULL); + cp = mh_xstrdup(buf); while (state == FLDPLUS) { bufsz = sizeof buf; state = m_getfld (&gstate, name, buf, &bufsz, fp); @@ -491,7 +491,7 @@ out: * Check Content-Transfer-Encoding field */ if (!strcasecmp (name, ENCODING_FIELD)) { - cp = add (buf, NULL); + cp = mh_xstrdup(buf); while (state == FLDPLUS) { bufsz = sizeof buf; state = m_getfld (&gstate, name, buf, &bufsz, fp); diff --git a/uip/slocal.c b/uip/slocal.c index 41eda311..fd60e232 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -735,7 +735,7 @@ parse (int fd) switch (state = m_getfld (&gstate, name, field, &fieldsz, in)) { case FLD: case FLDPLUS: - lp = add (field, NULL); + lp = mh_xstrdup(field); while (state == FLDPLUS) { fieldsz = sizeof field; state = m_getfld (&gstate, name, field, &fieldsz, in); @@ -1432,7 +1432,7 @@ suppress_duplicates (int fd, char *file) continue; } - cp = add (buf, NULL); + cp = mh_xstrdup(buf); while (state == FLDPLUS) { bufsz = sizeof buf; state = m_getfld (&gstate, name, buf, &bufsz, in);