more tweaks and fixes.
[apps/madmutt.git] / imap / imap.c
index 4b557fe..b390b45 100644 (file)
@@ -178,7 +178,6 @@ int imap_read_literal (FILE * fp, IMAP_DATA * idata, long bytes, progress_t* bar
       return -1;
     }
 
-#if 1
     if (r == 1 && c != '\n')
       fputc ('\r', fp);
 
@@ -188,7 +187,7 @@ int imap_read_literal (FILE * fp, IMAP_DATA * idata, long bytes, progress_t* bar
     }
     else
       r = 0;
-#endif
+
     fputc (c, fp);
     if (bar && !(pos % 1024))
       mutt_progress_bar (bar, pos);
@@ -1598,15 +1597,16 @@ static int imap_open_new_message (MESSAGE * msg,
                                   CONTEXT * dest __attribute__ ((unused)),
                                   HEADER * hdr __attribute__ ((unused)))
 {
-  char tmp[_POSIX_PATH_MAX];
+    char tmp[_POSIX_PATH_MAX];
 
-  mutt_mktemp (tmp);
-  if ((msg->fp = safe_fopen (tmp, "w")) == NULL) {
-    mutt_perror (tmp);
-    return (-1);
-  }
-  msg->path = m_strdup(tmp);
-  return 0;
+    msg->fp = m_tempfile(tmp, sizeof(tmp), NONULL(Tempdir), NULL);
+    if (!msg->fp) {
+        mutt_perror(tmp);
+        return -1;
+    }
+
+    msg->path = m_strdup(tmp);
+    return 0;
 }
 
 /* this ugly kludge is required since the last int to
@@ -1620,7 +1620,7 @@ static int _imap_check_mailbox (CONTEXT* ctx,
 static int imap_commit_message (MESSAGE* msg, CONTEXT* ctx) {
   int r = 0;
 
-  if ((r = safe_fclose (&msg->fp)) == 0)
+  if ((r = m_fclose(&msg->fp)) == 0)
     r = imap_append_message (ctx, msg);
   return (r);
 }