]> granicus.if.org Git - mutt/commitdiff
Smarter header wrapping -- different behavior for display
authorThomas Roessler <roessler@does-not-exist.org>
Tue, 9 Jan 2007 10:29:09 +0000 (10:29 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Tue, 9 Jan 2007 10:29:09 +0000 (10:29 +0000)
purposes and sent messages.

copy.c
protos.h
sendlib.c

diff --git a/copy.c b/copy.c
index 68cfcae1b0b2c4bc25c5d5c1a23b58e03e050edf..114b99c4f0e2498206556bcf37ade5a88db0903c 100644 (file)
--- a/copy.c
+++ b/copy.c
@@ -28,6 +28,7 @@
 #include "mime.h"
 #include "mutt_crypt.h"
 #include "mutt_idna.h"
+#include "mutt_curses.h"
 
 #include <string.h>
 #include <stdlib.h>
@@ -280,7 +281,7 @@ mutt_copy_hdr (FILE *in, FILE *out, LOFF_T off_start, LOFF_T off_end, int flags,
       if (flags & (CH_DECODE|CH_PREFIX))
       {
        if (mutt_write_one_header (out, 0, headers[x], 
-                                  flags & CH_PREFIX ? prefix : 0) == -1)
+                                  flags & CH_PREFIX ? prefix : 0, COLS - WrapMargin) == -1)
        {
          error = TRUE;
          break;
index f0456fe60de0084e5fa921a446c0098e4a78540c..baec526bb430aa4c9974b9135bb06651124a67fb 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -350,7 +350,7 @@ int mutt_which_case (const char *);
 int mutt_write_fcc (const char *path, HEADER *hdr, const char *msgid, int, char *);
 int mutt_write_mime_body (BODY *, FILE *);
 int mutt_write_mime_header (BODY *, FILE *);
-int mutt_write_one_header (FILE *fp, const char *tag, const char *value, const char *pfx);
+int mutt_write_one_header (FILE *fp, const char *tag, const char *value, const char *pfx, int wraplen);
 int mutt_write_rfc822_header (FILE *, ENVELOPE *, BODY *, int, int);
 int mutt_yesorno (const char *, int);
 void mutt_set_header_color(CONTEXT *, HEADER *);
index 1543a6bfcac60cfeb35654d41bd7b26934bbea45..13b0392058bf58092e3a9ead190321b3e547104a 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -1518,8 +1518,6 @@ static void write_references (LIST *r, FILE *f)
 }
 
 
-#define WRAPLEN 76
-
 static void foldingstrfcpy (char *d, const char *s, int n)
 {
   while (--n >= 0 && *s)
@@ -1533,7 +1531,7 @@ static void foldingstrfcpy (char *d, const char *s, int n)
   *d = '\0';
 }
 
-int mutt_write_one_header (FILE *fp, const char *tag, const char *value, const char *pfx)
+int mutt_write_one_header (FILE *fp, const char *tag, const char *value, const char *pfx, int wraplen)
 {
   int col = 0;
   int i, k, n;
@@ -1545,6 +1543,9 @@ int mutt_write_one_header (FILE *fp, const char *tag, const char *value, const c
   int wrapped = 0;
   int in_encoded_word = 0;
   
+  if (wraplen <= 0)
+    wraplen = 76;
+  
   if (tag)
   {
     if (fprintf (fp, "%s%s: ", NONULL (pfx), tag) < 0)
@@ -1588,8 +1589,8 @@ int mutt_write_one_header (FILE *fp, const char *tag, const char *value, const c
      * yuck
      */
     
-    for (i = 0, k = 0, l = 0, n = 0; i < sizeof (buf) && cp[i] != '\0' &&
-        ((col < (WRAPLEN + (k ? 0 : WRAPLEN)) || in_encoded_word));
+    for (i = 0, k = 0, l = 0, n = 0; i + MB_CUR_MAX < sizeof (buf) && cp[i] != '\0' &&
+        ((col < (wraplen + (k ? 0 : wraplen)) || in_encoded_word));
         i += l)
     {
       
@@ -1631,7 +1632,7 @@ int mutt_write_one_header (FILE *fp, const char *tag, const char *value, const c
        }
 
        if (iswspace (w) && 
-           (!k || col <= WRAPLEN))
+           (!k || col <= wraplen))
        {
          if (!k || i != n)
            k = i;
@@ -1685,7 +1686,6 @@ int mutt_write_one_header (FILE *fp, const char *tag, const char *value, const c
   return 0;
 }
 
-#undef WRAPLEN
 
 /* Note: all RFC2047 encoding should be done outside of this routine, except
  * for the "real name."  This will allow this routine to be used more than
@@ -1754,13 +1754,13 @@ int mutt_write_rfc822_header (FILE *fp, ENVELOPE *env, BODY *attach,
     fputs ("Bcc: \n", fp);
 
   if (env->subject)
-    mutt_write_one_header (fp, "Subject", env->subject, NULL);
+    mutt_write_one_header (fp, "Subject", env->subject, NULL, 0);
   else if (mode == 1)
     fputs ("Subject: \n", fp);
 
   /* save message id if the user has set it */
   if (env->message_id && !privacy)
-    mutt_write_one_header (fp, "Message-ID", env->message_id, NULL);
+    mutt_write_one_header (fp, "Message-ID", env->message_id, NULL, 0);
 
   if (env->reply_to)
   {
@@ -1824,7 +1824,7 @@ int mutt_write_rfc822_header (FILE *fp, ENVELOPE *env, BODY *attach,
        }
       }
       
-      mutt_write_one_header (fp, tmp->data, p, NULL);
+      mutt_write_one_header (fp, tmp->data, p, NULL, 0);
       *q = ':';
     }
   }