/* Don't use mailcap; the attachment is viewed in the pager */
if (flag == M_AS_TEXT) {
+ unlink(pagerfile);
+ close(pagerfd);
/* just let me see the raw data */
if (mutt_save_attachment (fp, a, pagerfile, 0, NULL))
goto return_error;
p_clear(&s, 1);
s.flags = displaying;
-
s.fpout = fdopen (pathfd, "w");
if (s.fpout == NULL) {
+ close(pathfd);
mutt_perror ("fopen");
return (-1);
}
if (tok == MIME_TEXT_PLAIN || tok == MIME_APPLICATION_POSTSCRIPT) {
return (mutt_pipe_attachment (fp, a, NONULL (PrintCmd), NULL));
}
- else if (mutt_can_decode (a)) {
+
+ if (mutt_can_decode (a)) {
/* decode and print */
int rc = 0;
newfile_fd = m_tempfd(newfile, sizeof(newfile), NONULL(Tempdir), NULL);
if (mutt_decode_save_attachment (fp, a, newfile_fd, M_PRINTING) == 0) {
- if ((ifp = fdopen (newfile_fd, "r")) == NULL) {
+ if ((ifp = fopen(newfile, "r")) == NULL) {
mutt_perror ("fopen");
goto bail0;
}
goto bail0;
}
- mutt_copy_stream (ifp, fpout);
-
+ mutt_copy_stream(ifp, fpout);
m_fclose(&fpout);
m_fclose(&ifp);
m_fclose(&fpout);
mutt_unlink (newfile);
return rc;
- }
- else {
+ } else {
mutt_error _("I don't know how to print that!");
return 0;
return 0;
tempfd = m_tempfd(tempfile, sizeof(tempfile), NONULL(Tempdir), NULL);
-
if (mutt_decode_save_attachment (fp, b, tempfd, 0) != 0) {
unlink (tempfile);
return 0;
}
- if ((tfp = fdopen (tempfd, "r")) == NULL) {
- unlink (tempfile);
+ if (!(tfp = fopen(tempfile, "r"))) {
+ unlink(tempfile);
return 0;
}