X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/8890670d4c1e8e3f9608c2850c1fe299fb256776..ef1ba39e8dae81091b6c3e73e72825ef6edea3c6:/uip/mhfixmsg.c?ds=inline diff --git a/uip/mhfixmsg.c b/uip/mhfixmsg.c index 4cccbad4..ee25624c 100644 --- a/uip/mhfixmsg.c +++ b/uip/mhfixmsg.c @@ -819,9 +819,7 @@ replace_boundary (CT ct, char *file, char *boundary) { fprintf (fpout, "%s:%s%s\n", np, new_ctline, new_params ? new_params : ""); free(new_ctline); - if (new_params) { - free(new_params); - } + mh_xfree(new_params); } free (vp); @@ -830,7 +828,7 @@ replace_boundary (CT ct, char *file, char *boundary) { continue; case BODY: - fputs ("\n", fpout); + putc('\n', fpout); /* buf will have a terminating NULL, skip it. */ if ((int) fwrite (buf, 1, bufsz-1, fpout) < bufsz-1) { advise (file, "fwrite"); @@ -924,10 +922,10 @@ fix_types (CT ct, svector_t fixtypes, int *message_mods) { * c_ctline */ /* Extract type and subtype from type/subtype. */ - ct_type = getcpy (ct_type_subtype); + ct_type = mh_xstrdup(ct_type_subtype); if ((cp = strchr (ct_type, '/'))) { *cp = '\0'; - ct_subtype = getcpy (++cp); + ct_subtype = mh_xstrdup(++cp); } else { advise (NULL, "missing / in MIME type of %s %s", ct->c_file, ct->c_partno); @@ -991,7 +989,7 @@ replace_substring (char **str, const char *old, const char *new) { char *prefix, *new_str; if (cp - *str) { - prefix = getcpy (*str); + prefix = mh_xstrdup(*str); *(prefix + (cp - *str)) = '\0'; new_str = concat (prefix, new, remainder, NULL); free (prefix); @@ -1002,9 +1000,9 @@ replace_substring (char **str, const char *old, const char *new) { free (*str); return *str = new_str; - } else { - return NULL; } + + return NULL; } @@ -1078,8 +1076,9 @@ fix_composite_cte (CT ct, int *message_mods) { if (! strncasecmp (name, ENCODING_FIELD, strlen (ENCODING_FIELD))) { char *prefix = "Nmh-REPLACED-INVALID-"; - HF h = mh_xmalloc (sizeof *h); + HF h; + NEW(h); h->name = add (hf->name, NULL); h->hf_encoding = hf->hf_encoding; h->next = hf->next; @@ -1179,9 +1178,9 @@ set_ce (CT ct, int encoding) { ct->c_celine = add (cte, NULL); return OK; - } else { - return NOTOK; } + + return NOTOK; } @@ -1276,7 +1275,7 @@ ensure_text_plain (CT *ct, CT parent, int *message_mods, int replacetextplain) { HF hf; parent->c_subtype = MULTI_ALTERNATE; - parent->c_ctinfo.ci_subtype = getcpy ("alternative"); + parent->c_ctinfo.ci_subtype = mh_xstrdup("alternative"); if (! replace_substring (&parent->c_ctline, "/related", "/alternative")) { advise (NULL, @@ -1395,8 +1394,9 @@ find_textplain_sibling (CT parent, int replacetextplain, static int insert_new_text_plain_part (CT ct, int new_subpart_number, CT parent) { struct multipart *mp = (struct multipart *) parent->c_ctparams; - struct part *new_part = mh_xmalloc (sizeof *new_part); + struct part *new_part; + NEW(new_part); if ((new_part->mp_part = build_text_plain_part (ct))) { char buffer[16]; snprintf (buffer, sizeof buffer, "%d", new_subpart_number); @@ -1408,12 +1408,12 @@ insert_new_text_plain_part (CT ct, int new_subpart_number, CT parent) { buffer, NULL); return 1; - } else { - free_content (new_part->mp_part); - free (new_part); - - return 0; } + + free_content (new_part->mp_part); + free (new_part); + + return 0; } @@ -1501,7 +1501,7 @@ static CT divide_part (CT ct) { CT new_part; - new_part = mh_xcalloc(1, sizeof *new_part); + NEW0(new_part); /* Just copy over what is needed for decoding. c_vrsn and c_celine aren't necessary. */ new_part->c_file = add (ct->c_file, NULL); @@ -1538,10 +1538,10 @@ copy_ctinfo (CI dest, CI src) { d_pm = add_param(&dest->ci_first_pm, &dest->ci_last_pm, s_pm->pm_name, s_pm->pm_value, 0); if (s_pm->pm_charset) { - d_pm->pm_charset = getcpy(s_pm->pm_charset); + d_pm->pm_charset = mh_xstrdup(s_pm->pm_charset); } if (s_pm->pm_lang) { - d_pm->pm_lang = getcpy(s_pm->pm_lang); + d_pm->pm_lang = mh_xstrdup(s_pm->pm_lang); } } @@ -1599,14 +1599,13 @@ reformat_part (CT ct, char *file, char *type, char *subtype, int c_type) { ct->c_file, invo_name, type, subtype); } return NOTOK; - } else { - if (strchr (cf, '>')) { - advise (NULL, "'>' prohibited in \"%s\",\nplease fix your " - "%s-format-%s/%s profile entry", cf, invo_name, type, - subtype ? subtype : ""); + } + if (strchr (cf, '>')) { + advise (NULL, "'>' prohibited in \"%s\",\nplease fix your " + "%s-format-%s/%s profile entry", cf, invo_name, type, + subtype ? subtype : ""); - return NOTOK; - } + return NOTOK; } cp = concat (cf, " >", file, NULL); @@ -1656,7 +1655,7 @@ build_multipart_alt (CT first_alt, CT new_part, int type, int subtype) { struct multipart *m; const struct str2init *ctinit; - ct = mh_xcalloc(1, sizeof *ct); + NEW0(ct); /* Set up the multipart/alternative part. These fields of *ct were initialized to 0 by mh_xcalloc(): @@ -1758,12 +1757,12 @@ build_multipart_alt (CT first_alt, CT new_part, int type, int subtype) { add_param(&ct->c_ctinfo.ci_first_pm, &ct->c_ctinfo.ci_last_pm, "boundary", boundary, 0); - p = (struct part *) mh_xmalloc (sizeof *p); - p->mp_next = (struct part *) mh_xmalloc (sizeof *p->mp_next); + NEW(p); + NEW(p->mp_next); p->mp_next->mp_next = NULL; p->mp_next->mp_part = first_alt; - m = mh_xcalloc(1, sizeof *m); + NEW0(m); m->mp_start = concat (boundary, "\n", NULL); m->mp_stop = concat (boundary, "--\n", NULL); m->mp_parts = p; @@ -2245,12 +2244,10 @@ strip_crs (CT ct, int *message_mods) { status = NOTOK; } else { /* Replace the decoded file with the converted one. */ - if (ct->c_cefile.ce_file) { - if (ct->c_cefile.ce_unlink) { - (void) m_unlink (ct->c_cefile.ce_file); - } - free (ct->c_cefile.ce_file); - } + if (ct->c_cefile.ce_file && ct->c_cefile.ce_unlink) + (void) m_unlink (ct->c_cefile.ce_file); + + mh_xfree(ct->c_cefile.ce_file); ct->c_cefile.ce_file = stripped_content_file; ct->c_cefile.ce_unlink = 1; @@ -2601,8 +2598,8 @@ fix_filename_encoding (CT ct) { const char *const new_params = concat (params, "\n", NULL); replace_substring (&hf->value, semicolon_loc, new_params); - free ((char *) new_params); - free ((char *) params); + free((void *)new_params); /* Cast away const. Sigh. */ + free((void *)params); } else { advise (NULL, "did not find semicolon in %s:%s\n", hf->name, hf->value); @@ -2739,12 +2736,11 @@ remove_file (const char *file) { free (rmm_command); return WIFEXITED (status) ? WEXITSTATUS (status) : NOTOK; - } else { - /* This is OK for a non-message file, it still uses the - BACKUP_PREFIX form. The backup file will be in the same - directory as file. */ - return rename (file, m_backup (file)); } + /* This is OK for a non-message file, it still uses the + BACKUP_PREFIX form. The backup file will be in the same + directory as file. */ + return rename (file, m_backup (file)); }