]> diplodocus.org Git - nmh/blobdiff - uip/mhfixmsg.c
Replace GNUism with standard touch flag in test-scan-file.
[nmh] / uip / mhfixmsg.c
index f410ecb4ff8becf8d767d338bbb6aa8b24e29d24..a820c638c98ea82a9486f9537b6216feac78d855 100644 (file)
@@ -437,7 +437,7 @@ main (int argc, char **argv)
 
                 if (copy_input_to_output (file, infp, outfile, outfp) != OK) {
                     inform("unable to copy message to %s, "
-                            "it might be lost\n", outfile);
+                            "it might be lost", outfile);
                 }
 
                 fclose (infp);
@@ -516,7 +516,7 @@ main (int argc, char **argv)
                         if (copy_input_to_output (input_filename, infp,
                                                   outfile, outfp) != OK) {
                             inform("unable to copy message to %s, "
-                                "it might be lost\n", outfile);
+                                "it might be lost", outfile);
                         }
 
                         fclose (infp);
@@ -551,6 +551,11 @@ main (int argc, char **argv)
                     (void) m_backup (file);
                 }
             }
+            if (outfp) {
+                /* close fp opened by the m_mktemp2() call in mhfixmsgsbr() */
+                fclose (outfp);
+                outfp = NULL;
+            }
         }
     } else {
         status = 1;
@@ -608,7 +613,7 @@ mhfixmsgsbr (CT *ctp, char *maildir, const fix_transformations *fx,
             }
             outfile = mh_xstrdup (tempfile);
         } else {
-            die("missing both input and output filenames\n");
+            die("missing both input and output filenames");
         }
     } /* else *outfp was defined by caller */
 
@@ -663,7 +668,7 @@ mhfixmsgsbr (CT *ctp, char *maildir, const fix_transformations *fx,
            to the output. */
         if (copy_input_to_output (input_filename, *infp, outfile,
                                   *outfp) != OK) {
-            inform("unable to copy message to %s, it might be lost\n",
+            inform("unable to copy message to %s, it might be lost",
                     outfile);
         }
     }
@@ -1077,7 +1082,9 @@ fix_types (CT ct, svector_t fixtypes, int *message_mods)
                                     }
                                     break;
                                 }
-                                inform("did not find %s in %s", type, hf->value);
+                                char *hf_value = cpytrim (hf->value);
+                                inform("did not find %s in %s", type, hf_value);
+                                free (hf_value);
                             }
                         }
                     }
@@ -1419,8 +1426,10 @@ ensure_text_plain (CT *ct, CT parent, int *message_mods, int replacetextplain)
                                     remove_parameter (hf->value, "type");
                                     break;
                                 }
+                                char *hf_value = cpytrim (hf->value);
                                 inform("did not find multipart/"
-                                    "related in header %s", hf->value);
+                                    "related in header %s", hf_value);
+                                free (hf_value);
                             }
                         }
                     } else {
@@ -1554,8 +1563,7 @@ build_text_plain_part (CT encoded_part)
 
         /* This m_mktemp2() call closes the temp file. */
         if ((tempfile = m_mktemp2 (NULL, invo_name, NULL, NULL)) == NULL) {
-            inform("unable to create temporary file in %s",
-                    get_temp_dir());
+            inform("unable to create temporary file in %s", get_temp_dir());
         } else {
             tmp_plain_file = mh_xstrdup (tempfile);
             if (reformat_part (tp_part, tmp_plain_file,
@@ -2737,22 +2745,19 @@ convert_charsets (CT ct, char *dest_charset, int *message_mods)
     switch (ct->c_type) {
     case CT_TEXT:
         if (ct->c_subtype == TEXT_PLAIN) {
+            char *const ct_charset = content_charset (ct);
+
             status = convert_charset (ct, dest_charset, message_mods);
             if (status == OK) {
                 if (verbosw) {
-                    char *ct_charset = content_charset (ct);
-
                     report (NULL, ct->c_partno, ct->c_file,
                             "convert %s to %s", ct_charset, dest_charset);
-                    free (ct_charset);
                 }
             } else {
-                char *ct_charset = content_charset (ct);
-
                 report ("iconv", ct->c_partno, ct->c_file,
                         "failed to convert %s to %s", ct_charset, dest_charset);
-                free (ct_charset);
             }
+            free (ct_charset);
         }
         break;
 
@@ -2929,7 +2934,9 @@ decode_header_field_bodies (CT ct, int *message_mods)
                     ++*message_mods;
                 }
             } else {
-                inform("failed to decode %s parameter %s", hf->name, hf->value);
+                char *hf_value = cpytrim (hf->value);
+                inform("failed to decode %s parameter %s", hf->name, hf_value);
+                free (hf_value);
                 status = NOTOK;
             }
         }
@@ -3021,9 +3028,6 @@ fix_filename_encoding (CT ct)
                 replace_substring (&hf->value, semicolon_loc, new_params);
                 free((void *)new_params); /* Cast away const.  Sigh. */
                 free((void *)params);
-            } else {
-                inform("did not find semicolon in %s:%s\n",
-                        hf->name, hf->value);
             }
         }
     }