]> granicus.if.org Git - neomutt/commitdiff
Some fixes to the size calculation code.
authorThomas Roessler <roessler@does-not-exist.org>
Tue, 16 May 2000 19:00:15 +0000 (19:00 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Tue, 16 May 2000 19:00:15 +0000 (19:00 +0000)
compose.c
mutt.h
protos.h
sendlib.c

index bb9661788ead5b232aec151f49f1b73dca66fd20..034424f27d6b8d9b5c6d209711fd5d9d12c32ab4 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -417,9 +417,10 @@ static int change_attachment_charset (BODY *b)
 /* 
  * cum_attachs_size: Cumulative Attachments Size
  *
- * 
  * Returns the total number of bytes used by the attachments in the
- * attachment list.
+ * attachment list _after_ content-transfer-encodings have been
+ * applied.
+ * 
  */
 
 static unsigned long cum_attachs_size (MUTTMENU *menu)
@@ -428,21 +429,27 @@ static unsigned long cum_attachs_size (MUTTMENU *menu)
   unsigned short i;
   ATTACHPTR **idx = menu->data;
   CONTENT *info;
+  BODY *b;
   
   for (i = 0, s = 0; i < menu->max; i++)
   {
-    if ((info = idx[i]->content->content))
+    b = idx[i]->content;
+
+    if (!b->content)
+      b->content = mutt_get_content_info (b->filename, b);
+
+    if ((info = b->content))
     {
-      switch (idx[i]->content->encoding)
+      switch (b->encoding)
       {
        case ENCQUOTEDPRINTABLE:
-         s += 3 * (info->lobin + info->hibin) + info->ascii;
+         s += 3 * (info->lobin + info->hibin) + info->ascii + info->crlf;
          break;
        case ENCBASE64:
-         s += (4 * (info->lobin + info->hibin + info->ascii)) / 3;
+         s += (4 * (info->lobin + info->hibin + info->ascii + info->crlf)) / 3;
          break;
        default:
-         s += info->lobin + info->hibin + info->ascii;
+         s += info->lobin + info->hibin + info->ascii + info->crlf;
          break;
       }
     }
diff --git a/mutt.h b/mutt.h
index f8656118cf08ff3b508ae050631a798fa5e22edb..37ed6a9af82697b2a4a222f5b31293035083fa16 100644 (file)
--- a/mutt.h
+++ b/mutt.h
@@ -483,6 +483,7 @@ typedef struct content
 {
   long hibin;              /* 8-bit characters */
   long lobin;              /* unprintable 7-bit chars (eg., control chars) */
+  long crlf;              /* '\r' and '\n' characters */
   long ascii;              /* number of ascii chars */
   long linemax;            /* length of the longest line in the file */
   unsigned int space : 1;  /* whitespace at the end of lines? */
index d67e43abb31c01ac607ac9cd4b7e9eb946927433..5ccdf4d5bfdc2552c8c10e7f548e0361a6b6eff4 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -89,6 +89,8 @@ BODY *mutt_parse_multipart (FILE *, const char *, long, int);
 BODY *mutt_parse_messageRFC822 (FILE *, BODY *);
 BODY *mutt_read_mime_header (FILE *, int);
 
+CONTENT *mutt_get_content_info (const char *fname, BODY *b);
+
 LIST *mutt_make_references(ENVELOPE *e);
 
 ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short, short);
index 5d24ca9335c723c9838a1b000085f9e78366903f..840565bd36c90ee9db1546a3ad6cd95410184912 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -512,7 +512,7 @@ void mutt_generate_boundary (PARAMETER **parm)
 }
 
 /* analyze the contents of a file to determine which MIME encoding to use */
-static CONTENT *mutt_get_content_info (const char *fname, BODY *b)
+CONTENT *mutt_get_content_info (const char *fname, BODY *b)
 {
   CONTENT *info;
   FILE *fp;
@@ -533,6 +533,7 @@ static CONTENT *mutt_get_content_info (const char *fname, BODY *b)
     linelen++;
     if (ch == '\n')
     {
+      info->crlf++;
       if (whitespace) info->space = 1;
       if (dot) info->dot = 1;
       if (linelen > info->linemax) info->linemax = linelen;
@@ -542,6 +543,7 @@ static CONTENT *mutt_get_content_info (const char *fname, BODY *b)
     }
     else if (ch == '\r')
     {
+      info->crlf++;
       info->cr = 1;
       if ((ch = fgetc (fp)) == EOF)
       {
@@ -952,9 +954,7 @@ void mutt_update_encoding (BODY *a)
 
   safe_free ((void **) &a->content);
   a->content = info;
-  info = NULL;
 
-  safe_free ((void **) &info);
 }
 
 BODY *mutt_make_message_attach (CONTEXT *ctx, HEADER *hdr, int attach_msg)
@@ -1087,18 +1087,8 @@ BODY *mutt_make_file_attach (const char *path)
 
   if (att->type == TYPETEXT)
     mutt_set_body_charset(att, get_text_charset(att, info));
-  
-#ifdef HAVE_PGP
-  /*
-   * save the info in case this message is signed.  we will want to do Q-P
-   * encoding if any lines begin with "From " so the signature won't be munged,
-   * for example.
-   */
-  att->content = info;
-  info = NULL;
-#endif
 
-  safe_free ((void **) &info);
+  att->content = info;
 
   return (att);
 }