X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/c6f2d14d9c38345075629af3487c2de491584ca1..372d8d466d78a89031d07323b898b4e0703336dc:/uip/replsbr.c diff --git a/uip/replsbr.c b/uip/replsbr.c index 80d1ff67..15cab6c0 100644 --- a/uip/replsbr.c +++ b/uip/replsbr.c @@ -104,30 +104,16 @@ replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen, * * This prevents the component from being found via fmt_findcomp(), * which makes sure no text gets added to it when the message is processed. - * - * getcpy(NULL) returns a malloc'd zero-length string, so it can safely - * be free()'d later. */ if (!ccto) { cptr = fmt_findcomp ("to"); if (cptr) - cptr->c_name = getcpy(NULL); + cptr->c_name = mh_xstrdup(""); } if (!cccc) { cptr = fmt_findcomp("cc"); if (cptr) - cptr->c_name = getcpy(NULL); - } - /* set up the "fcc" pseudo-component */ - if (fcc) { - cptr = fmt_findcomp ("fcc"); - if (cptr) - cptr->c_text = getcpy (fcc); - } - if ((cp = getenv("USER"))) { - cptr = fmt_findcomp ("user"); - if (cptr) - cptr->c_text = getcpy(cp); + cptr->c_name = mh_xstrdup(""); } if (!ccme) ismymbox (NULL); @@ -139,8 +125,8 @@ replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen, int msg_count = sizeof tmpbuf; state = m_getfld (&gstate, name, tmpbuf, &msg_count, inb); switch (state) { - case FLD: - case FLDPLUS: + case FLD: + case FLDPLUS: /* * if we're interested in this component, save a pointer * to the component text, then start using our next free @@ -165,13 +151,13 @@ replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen, } break; - case LENERR: - case FMTERR: - case BODY: + case LENERR: + case FMTERR: + case BODY: case FILEEOF: goto finished; - default: + default: adios (NULL, "m_getfld() returned %d", state); } } @@ -182,6 +168,24 @@ replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen, finished: m_getfld_state_destroy (&gstate); + /* set up the "fcc" pseudo-component */ + cptr = fmt_findcomp ("fcc"); + if (cptr) { + mh_xfree(cptr->c_text); + if (fcc) + cptr->c_text = mh_xstrdup(fcc); + else + cptr->c_text = NULL; + } + cptr = fmt_findcomp ("user"); + if (cptr) { + mh_xfree(cptr->c_text); + if ((cp = getenv("USER"))) + cptr->c_text = mh_xstrdup(cp); + else + cptr = NULL; + } + /* * if there's a "Subject" component, strip any "Re:"s off it */ @@ -200,7 +204,7 @@ finished: } if (sp != cptr->c_text) { cp = cptr->c_text; - cptr->c_text = getcpy (sp); + cptr->c_text = mh_xstrdup(sp); free (cp); } } @@ -438,10 +442,10 @@ replfilter (FILE *in, FILE *out, char *filter, int fmtproc) arglist = argsplit(mhlproc, &mhl, &argnum); switch (pid = fork()) { - case NOTOK: + case NOTOK: adios ("fork", "unable to"); - case OK: + case OK: dup2 (fileno (in), fileno (stdin)); dup2 (fileno (out), fileno (stdout)); closefds (3); @@ -478,7 +482,7 @@ replfilter (FILE *in, FILE *out, char *filter, int fmtproc) } _exit (-1); - default: + default: if (pidXwait (pid, mhl)) done (1); fseek (out, 0L, SEEK_END); @@ -532,7 +536,7 @@ fix_addresses (char *str) { const char *no_at_sign = "no at-sign after local-part"; adr_nodep->escape_local_part = - ! strncmp (error, no_at_sign, strlen (no_at_sign)); + has_prefix(error, no_at_sign); } else { mnfree (mp); } @@ -609,8 +613,7 @@ fix_addresses (char *str) { if (fixed_address) { return fixed_str; - } else { - free (fixed_str); - return str ? strdup (str) : NULL; } + free (fixed_str); + return str ? strdup (str) : NULL; }