]> granicus.if.org Git - neomutt/commitdiff
eliminate MuttIndexWindow from mutt_copy_message()
authorRichard Russon <rich@flatcap.org>
Sat, 19 Oct 2019 15:53:57 +0000 (16:53 +0100)
committerRichard Russon <rich@flatcap.org>
Wed, 23 Oct 2019 10:37:44 +0000 (11:37 +0100)
`mutt_copy_message()` uses a huge tree of functions to process and copy
the header and body of a message.

Some of these functions perform wrapping and some of the wrapping
functions use `MuttIndexWindow` to get the width of the current panel.

These functions needed an extra parameter:

- `mutt_copy_hdr()`
- `mutt_copy_header()`
- `mutt_copy_message()`
- `mutt_copy_message_fp()`
- `mutt_write_one_header()`

The rest used an extra member in `struct State`.
For example, this sequence of functions:

- `mutt_body_handler()`
- `valid_pgp_encrypted_handler()`
- `run_decode_and_handler()`
- `crypt_pgp_encrypted_handler()`
- `pgp_gpgme_encrypted_handler()`
- `mutt_protected_headers_handler()`

15 files changed:
commands.c
copy.c
copy.h
editmsg.c
handler.c
maildir/shared.c
mbox/mbox.c
mutt_attach.c
ncrypt/crypt.c
ncrypt/smime.c
pattern.c
recvcmd.c
send.c
sendlib.c
state.h

index f1ba0c7e12866f11c6f0416660a05c929594d15a..1333c33bf7831431fc2beff85bccfc2ae7a1c0c0 100644 (file)
@@ -289,7 +289,7 @@ int mutt_display_message(struct Mailbox *m, struct Email *e)
   if (m->magic == MUTT_NOTMUCH)
     chflags |= CH_VIRTUAL;
 #endif
-  res = mutt_copy_message(fp_out, m, e, cmflags, chflags);
+  res = mutt_copy_message(fp_out, m, e, cmflags, chflags, MuttIndexWindow->cols);
 
   if (((mutt_file_fclose(&fp_out) != 0) && (errno != EPIPE)) || (res < 0))
   {
@@ -540,7 +540,7 @@ static void pipe_msg(struct Mailbox *m, struct Email *e, FILE *fp, bool decode,
   if (decode)
     mutt_parse_mime_message(m, e);
 
-  mutt_copy_message(fp, m, e, cmflags, chflags);
+  mutt_copy_message(fp, m, e, cmflags, chflags, 0);
 }
 
 /**
diff --git a/copy.c b/copy.c
index 0a9d16f38306d6fc5882407a6d1d11db6548bdce..c707e678207b9683f5ed7f8788cdec9ab612df12 100644 (file)
--- a/copy.c
+++ b/copy.c
@@ -66,6 +66,7 @@ static int copy_delete_attach(struct Body *b, FILE *fp_in, FILE *fp_out, char *d
  * @param off_end   Offset to finish at
  * @param chflags   Flags, see #CopyHeaderFlags
  * @param prefix    Prefix for quoting headers
+ * @param wraplen   Width to wrap at (when chflags & CH_DISPLAY)
  * @retval  0 Success
  * @retval -1 Failure
  *
@@ -74,7 +75,7 @@ static int copy_delete_attach(struct Body *b, FILE *fp_in, FILE *fp_out, char *d
  * wrap headers much more aggressively than the other one.
  */
 int mutt_copy_hdr(FILE *fp_in, FILE *fp_out, LOFF_T off_start, LOFF_T off_end,
-                  CopyHeaderFlags chflags, const char *prefix)
+                  CopyHeaderFlags chflags, const char *prefix, int wraplen)
 {
   bool from = false;
   bool this_is_from = false;
@@ -348,7 +349,7 @@ int mutt_copy_hdr(FILE *fp_in, FILE *fp_out, LOFF_T off_start, LOFF_T off_end,
       if (chflags & (CH_DECODE | CH_PREFIX))
       {
         const char *pre = (chflags & CH_PREFIX) ? prefix : NULL;
-        const int wraplen = mutt_window_wrap_cols(MuttIndexWindow->cols, C_Wrap);
+        wraplen = mutt_window_wrap_cols(wraplen, C_Wrap);
 
         if (mutt_write_one_header(fp_out, 0, headers[x], pre, wraplen, chflags) == -1)
         {
@@ -385,11 +386,12 @@ int mutt_copy_hdr(FILE *fp_in, FILE *fp_out, LOFF_T off_start, LOFF_T off_end,
  * @param fp_out   FILE pointer to write to
  * @param chflags  See #CopyHeaderFlags
  * @param prefix   Prefix for quoting headers (if #CH_PREFIX is set)
+ * @param wraplen  Width to wrap at (when chflags & CH_DISPLAY)
  * @retval  0 Success
  * @retval -1 Failure
  */
 int mutt_copy_header(FILE *fp_in, struct Email *e, FILE *fp_out,
-                     CopyHeaderFlags chflags, const char *prefix)
+                     CopyHeaderFlags chflags, const char *prefix, int wraplen)
 {
   char *temp_hdr = NULL;
 
@@ -401,7 +403,8 @@ int mutt_copy_header(FILE *fp_in, struct Email *e, FILE *fp_out,
                ((e->env->changed & MUTT_ENV_CHANGED_SUBJECT) ? CH_UPDATE_SUBJECT : 0);
   }
 
-  if (mutt_copy_hdr(fp_in, fp_out, e->offset, e->content->offset, chflags, prefix) == -1)
+  if (mutt_copy_hdr(fp_in, fp_out, e->offset, e->content->offset, chflags,
+                    prefix, wraplen) == -1)
     return -1;
 
   if (chflags & CH_TXTPLAIN)
@@ -502,9 +505,8 @@ int mutt_copy_header(FILE *fp_in, struct Email *e, FILE *fp_out,
       temp_hdr = mutt_str_strdup(temp_hdr);
       rfc2047_encode(&temp_hdr, NULL, sizeof("X-Label:"), C_SendCharset);
     }
-    if (mutt_write_one_header(
-            fp_out, "X-Label", temp_hdr, (chflags & CH_PREFIX) ? prefix : 0,
-            mutt_window_wrap_cols(MuttIndexWindow->cols, C_Wrap), chflags) == -1)
+    if (mutt_write_one_header(fp_out, "X-Label", temp_hdr, (chflags & CH_PREFIX) ? prefix : 0,
+                              mutt_window_wrap_cols(wraplen, C_Wrap), chflags) == -1)
     {
       return -1;
     }
@@ -522,9 +524,8 @@ int mutt_copy_header(FILE *fp_in, struct Email *e, FILE *fp_out,
       temp_hdr = mutt_str_strdup(temp_hdr);
       rfc2047_encode(&temp_hdr, NULL, sizeof("Subject:"), C_SendCharset);
     }
-    if (mutt_write_one_header(
-            fp_out, "Subject", temp_hdr, (chflags & CH_PREFIX) ? prefix : 0,
-            mutt_window_wrap_cols(MuttIndexWindow->cols, C_Wrap), chflags) == -1)
+    if (mutt_write_one_header(fp_out, "Subject", temp_hdr, (chflags & CH_PREFIX) ? prefix : 0,
+                              mutt_window_wrap_cols(wraplen, C_Wrap), chflags) == -1)
     {
       return -1;
     }
@@ -586,16 +587,17 @@ static int count_delete_lines(FILE *fp, struct Body *b, LOFF_T *length, size_t d
 
 /**
  * mutt_copy_message_fp - make a copy of a message from a FILE pointer
- * @param fp_out   Where to write output
- * @param fp_in    Where to get input
+ * @param fp_out  Where to write output
+ * @param fp_in   Where to get input
  * @param e       Email being copied
  * @param cmflags Flags, see #CopyMessageFlags
  * @param chflags Flags, see #CopyHeaderFlags
+ * @param wraplen Width to wrap at (when chflags & CH_DISPLAY)
  * @retval  0 Success
  * @retval -1 Failure
  */
 int mutt_copy_message_fp(FILE *fp_out, FILE *fp_in, struct Email *e,
-                         CopyMessageFlags cmflags, CopyHeaderFlags chflags)
+                         CopyMessageFlags cmflags, CopyHeaderFlags chflags, int wraplen)
 {
   struct Body *body = e->content;
   char prefix[128];
@@ -635,7 +637,7 @@ int mutt_copy_message_fp(FILE *fp_out, FILE *fp_in, struct Email *e,
       new_lines = e->lines - count_delete_lines(fp_in, body, &new_length, dlen);
 
       /* Copy the headers */
-      if (mutt_copy_header(fp_in, e, fp_out, chflags | CH_NOLEN | CH_NONEWLINE, NULL))
+      if (mutt_copy_header(fp_in, e, fp_out, chflags | CH_NOLEN | CH_NONEWLINE, NULL, wraplen))
         return -1;
       fprintf(fp_out, "Content-Length: " OFF_T_FMT "\n", new_length);
       if (new_lines <= 0)
@@ -684,7 +686,7 @@ int mutt_copy_message_fp(FILE *fp_out, FILE *fp_in, struct Email *e,
     }
 
     if (mutt_copy_header(fp_in, e, fp_out, chflags,
-                         (chflags & CH_PREFIX) ? prefix : NULL) == -1)
+                         (chflags & CH_PREFIX) ? prefix : NULL, wraplen) == -1)
     {
       return -1;
     }
@@ -701,7 +703,10 @@ int mutt_copy_message_fp(FILE *fp_out, FILE *fp_in, struct Email *e,
     if (cmflags & MUTT_CM_PREFIX)
       s.prefix = prefix;
     if (cmflags & MUTT_CM_DISPLAY)
+    {
       s.flags |= MUTT_DISPLAY;
+      s.wraplen = wraplen;
+    }
     if (cmflags & MUTT_CM_PRINTING)
       s.flags |= MUTT_PRINTING;
     if (cmflags & MUTT_CM_WEED)
@@ -797,6 +802,7 @@ int mutt_copy_message_fp(FILE *fp_out, FILE *fp_in, struct Email *e,
  * @param e       Email
  * @param cmflags Flags, see #CopyMessageFlags
  * @param chflags Flags, see #CopyHeaderFlags
+ * @param wraplen Width to wrap at (when chflags & CH_DISPLAY)
  * @retval  0 Success
  * @retval -1 Failure
  *
@@ -804,14 +810,14 @@ int mutt_copy_message_fp(FILE *fp_out, FILE *fp_in, struct Email *e,
  * like partial decode, where it is worth displaying as much as possible
  */
 int mutt_copy_message(FILE *fp_out, struct Mailbox *m, struct Email *e,
-                      CopyMessageFlags cmflags, CopyHeaderFlags chflags)
+                      CopyMessageFlags cmflags, CopyHeaderFlags chflags, int wraplen)
 {
   struct Message *msg = mx_msg_open(m, e->msgno);
   if (!msg)
     return -1;
   if (!e->content)
     return -1;
-  int rc = mutt_copy_message_fp(fp_out, msg->fp, e, cmflags, chflags);
+  int rc = mutt_copy_message_fp(fp_out, msg->fp, e, cmflags, chflags, wraplen);
   if ((rc == 0) && (ferror(fp_out) || feof(fp_out)))
   {
     mutt_debug(LL_DEBUG1, "failed to detect EOF!\n");
@@ -850,7 +856,7 @@ static int append_message(struct Mailbox *dest, FILE *fp_in, struct Mailbox *src
   if ((dest->magic == MUTT_MBOX) || (dest->magic == MUTT_MMDF))
     chflags |= CH_FROM | CH_FORCE_FROM;
   chflags |= ((dest->magic == MUTT_MAILDIR) ? CH_NOSTATUS : CH_UPDATE);
-  rc = mutt_copy_message_fp(msg->fp, fp_in, e, cmflags, chflags);
+  rc = mutt_copy_message_fp(msg->fp, fp_in, e, cmflags, chflags, 0);
   if (mx_msg_commit(dest, msg) != 0)
     rc = -1;
 
diff --git a/copy.h b/copy.h
index 11e5742f5caeb3384c4291eadfb177af3b8017c9..beddf1a40b2975824626f70e752783a8cc97563e 100644 (file)
--- a/copy.h
+++ b/copy.h
@@ -71,12 +71,12 @@ typedef uint32_t CopyHeaderFlags;   ///< Flags for mutt_copy_header(), e.g. #CH_
 #define CH_UPDATE_SUBJECT (1 << 20) ///< Update Subject: protected header update
 #define CH_VIRTUAL        (1 << 21) ///< Write virtual header lines too
 
-int mutt_copy_hdr(FILE *fp_in, FILE *fp_out, LOFF_T off_start, LOFF_T off_end, CopyHeaderFlags chflags, const char *prefix);
+int mutt_copy_hdr(FILE *fp_in, FILE *fp_out, LOFF_T off_start, LOFF_T off_end, CopyHeaderFlags chflags, const char *prefix, int wraplen);
 
-int mutt_copy_header(FILE *fp_in, struct Email *e, FILE *fp_out, CopyHeaderFlags chflags, const char *prefix);
+int mutt_copy_header(FILE *fp_in, struct Email *e, FILE *fp_out, CopyHeaderFlags chflags, const char *prefix, int wraplen);
 
-int mutt_copy_message_fp(FILE *fp_out, FILE *fp_in,       struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags);
-int mutt_copy_message   (FILE *fp_out, struct Mailbox *m, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags);
+int mutt_copy_message_fp(FILE *fp_out, FILE *fp_in,       struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags, int wraplen);
+int mutt_copy_message   (FILE *fp_out, struct Mailbox *m, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags, int wraplen);
 
 int mutt_append_message(struct Mailbox *dest, struct Mailbox *src, struct Email *e, CopyMessageFlags cmflags, CopyHeaderFlags chflags);
 
index 4593621bd238ef2bd997b147e895bdc06b013618..cdd7e1fa86a60efdee41497e15d016fa2cc633ef 100644 (file)
--- a/editmsg.c
+++ b/editmsg.c
@@ -217,7 +217,7 @@ static int ev_message(enum EvMessage action, struct Mailbox *m, struct Email *e)
     goto bail;
   }
 
-  rc = mutt_copy_hdr(fp, msg->fp, 0, sb.st_size, CH_NOLEN | cf, NULL);
+  rc = mutt_copy_hdr(fp, msg->fp, 0, sb.st_size, CH_NOLEN | cf, NULL, 0);
   if (rc == 0)
   {
     fputc('\n', msg->fp);
index 3332626e9d257167cef33d388b8d65d3e5dfed4c..bfd0aaf8ac7eb005a49d35b94e11683b3d21e11e 100644 (file)
--- a/handler.c
+++ b/handler.c
@@ -730,7 +730,7 @@ static int message_handler(struct Body *a, struct State *s)
     if (s->flags & MUTT_DISPLAY)
       chflags |= CH_DISPLAY;
 
-    mutt_copy_hdr(s->fp_in, s->fp_out, off_start, b->parts->offset, chflags, s->prefix);
+    mutt_copy_hdr(s->fp_in, s->fp_out, off_start, b->parts->offset, chflags, s->prefix, 0);
 
     if (s->prefix)
       state_puts(s->prefix, s);
@@ -872,7 +872,8 @@ static int external_body_handler(struct Body *b, struct State *s)
       if (C_Weed)
         chflags |= CH_WEED | CH_REORDER;
 
-      mutt_copy_hdr(s->fp_in, s->fp_out, ftello(s->fp_in), b->parts->offset, chflags, NULL);
+      mutt_copy_hdr(s->fp_in, s->fp_out, ftello(s->fp_in), b->parts->offset,
+                    chflags, NULL, 0);
     }
   }
   else if (expiration && (expire < mutt_date_epoch()))
@@ -890,7 +891,8 @@ static int external_body_handler(struct Body *b, struct State *s)
       if (C_Weed)
         chflags |= CH_WEED | CH_REORDER;
 
-      mutt_copy_hdr(s->fp_in, s->fp_out, ftello(s->fp_in), b->parts->offset, chflags, NULL);
+      mutt_copy_hdr(s->fp_in, s->fp_out, ftello(s->fp_in), b->parts->offset,
+                    chflags, NULL, 0);
     }
   }
   else
@@ -910,7 +912,8 @@ static int external_body_handler(struct Body *b, struct State *s)
       if (C_Weed)
         chflags |= CH_WEED | CH_REORDER;
 
-      mutt_copy_hdr(s->fp_in, s->fp_out, ftello(s->fp_in), b->parts->offset, chflags, NULL);
+      mutt_copy_hdr(s->fp_in, s->fp_out, ftello(s->fp_in), b->parts->offset,
+                    chflags, NULL, 0);
     }
   }
 
index c778446c982149fc89f9f8e4f74551fef076662d..1d8a494dd3f91dd413929e4a3f8d6b5bfd1f1d8a 100644 (file)
@@ -1073,7 +1073,7 @@ int mh_rewrite_message(struct Mailbox *m, int msgno)
   if (!dest)
     return -1;
 
-  int rc = mutt_copy_message(dest->fp, m, e, MUTT_CM_UPDATE, CH_UPDATE | CH_UPDATE_LEN);
+  int rc = mutt_copy_message(dest->fp, m, e, MUTT_CM_UPDATE, CH_UPDATE | CH_UPDATE_LEN, 0);
   if (rc == 0)
   {
     char oldpath[PATH_MAX];
index 7f55bb8d348e08b3aaf254b5ebe362a5f69c0c4f..a543219942e00c432fc587287fcc4f9b28496a53 100644 (file)
@@ -1296,7 +1296,7 @@ static int mbox_mbox_sync(struct Mailbox *m, int *index_hint)
       new_offset[i - first].hdr = ftello(fp) + offset;
 
       if (mutt_copy_message(fp, m, m->emails[i], MUTT_CM_UPDATE,
-                            CH_FROM | CH_UPDATE | CH_UPDATE_LEN) != 0)
+                            CH_FROM | CH_UPDATE | CH_UPDATE_LEN, 0) != 0)
       {
         mutt_perror(tempfile);
         unlink(tempfile);
index 0083a01aad71ecce6a332ba56593f3b8e9ee1dd0..09712dd542fab5fef933043cab0fb7be8f168558 100644 (file)
@@ -831,7 +831,7 @@ int mutt_save_attachment(FILE *fp, struct Body *m, const char *path,
       if ((ctx->mailbox->magic == MUTT_MBOX) || (ctx->mailbox->magic == MUTT_MMDF))
         chflags = CH_FROM | CH_UPDATE_LEN;
       chflags |= ((ctx->mailbox->magic == MUTT_MAILDIR) ? CH_NOSTATUS : CH_UPDATE);
-      if ((mutt_copy_message_fp(msg->fp, fp, e_new, MUTT_CM_NO_FLAGS, chflags) == 0) &&
+      if ((mutt_copy_message_fp(msg->fp, fp, e_new, MUTT_CM_NO_FLAGS, chflags, 0) == 0) &&
           (mx_msg_commit(ctx->mailbox, msg) == 0))
       {
         rc = 0;
index c407daafba7554603a8a7d794aeeaf826807a646..b99f97f70bc610d30c3b8cdccdc319ce2dfb5fb5 100644 (file)
@@ -883,7 +883,7 @@ void crypt_extract_keys_from_messages(struct Mailbox *m, struct EmailList *el)
 
     if (((WithCrypto & APPLICATION_PGP) != 0) && (e->security & APPLICATION_PGP))
     {
-      mutt_copy_message(fp_out, m, e, MUTT_CM_DECODE | MUTT_CM_CHARCONV, CH_NO_FLAGS);
+      mutt_copy_message(fp_out, m, e, MUTT_CM_DECODE | MUTT_CM_CHARCONV, CH_NO_FLAGS, 0);
       fflush(fp_out);
 
       mutt_endwin();
@@ -896,10 +896,10 @@ void crypt_extract_keys_from_messages(struct Mailbox *m, struct EmailList *el)
       if (e->security & SEC_ENCRYPT)
       {
         mutt_copy_message(fp_out, m, e, MUTT_CM_NOHEADER | MUTT_CM_DECODE_CRYPT | MUTT_CM_DECODE_SMIME,
-                          CH_NO_FLAGS);
+                          CH_NO_FLAGS, 0);
       }
       else
-        mutt_copy_message(fp_out, m, e, MUTT_CM_NO_FLAGS, CH_NO_FLAGS);
+        mutt_copy_message(fp_out, m, e, MUTT_CM_NO_FLAGS, CH_NO_FLAGS, 0);
       fflush(fp_out);
 
       char *mbox = NULL;
@@ -1101,13 +1101,16 @@ int mutt_protected_headers_handler(struct Body *a, struct State *s)
   {
     if (a->mime_headers->subject)
     {
-      if ((s->flags & MUTT_DISPLAY) && C_Weed && mutt_matches_ignore("subject"))
+      const bool display = (s->flags & MUTT_DISPLAY);
+
+      if (display && C_Weed && mutt_matches_ignore("subject"))
         return 0;
 
       state_mark_protected_header(s);
-      mutt_write_one_header(s->fp_out, "Subject", a->mime_headers->subject, s->prefix,
-                            mutt_window_wrap_cols(MuttIndexWindow->cols, C_Wrap),
-                            (s->flags & MUTT_DISPLAY) ? CH_DISPLAY : CH_NO_FLAGS);
+      int wraplen = display ? mutt_window_wrap_cols(s->wraplen, C_Wrap) : 0;
+
+      mutt_write_one_header(s->fp_out, "Subject", a->mime_headers->subject,
+                            s->prefix, wraplen, display ? CH_DISPLAY : CH_NO_FLAGS);
       state_puts("\n", s);
     }
   }
index 3daf78168c139f8f7c563a05e543e2cb7f517853..e34ecf897e0429392d561943672cb56efe42bb89 100644 (file)
@@ -1428,10 +1428,10 @@ int smime_class_verify_sender(struct Mailbox *m, struct Email *e)
   if (e->security & SEC_ENCRYPT)
   {
     mutt_copy_message(fp_out, m, e, MUTT_CM_DECODE_CRYPT & MUTT_CM_DECODE_SMIME,
-                      CH_MIME | CH_WEED | CH_NONEWLINE);
+                      CH_MIME | CH_WEED | CH_NONEWLINE, 0);
   }
   else
-    mutt_copy_message(fp_out, m, e, MUTT_CM_NO_FLAGS, CH_NO_FLAGS);
+    mutt_copy_message(fp_out, m, e, MUTT_CM_NO_FLAGS, CH_NO_FLAGS, 0);
 
   fflush(fp_out);
   mutt_file_fclose(&fp_out);
index f5e657db26ada635a237a98ed71c5bbc7a789079..6fcfccb4a3f49e14a77fda423a35f6a12a734bf8 100644 (file)
--- a/pattern.c
+++ b/pattern.c
@@ -1122,7 +1122,7 @@ static bool msg_search(struct Mailbox *m, struct Pattern *pat, int msgno)
 #endif
 
     if (pat->op != MUTT_PAT_BODY)
-      mutt_copy_header(msg->fp, e, s.fp_out, CH_FROM | CH_DECODE, NULL);
+      mutt_copy_header(msg->fp, e, s.fp_out, CH_FROM | CH_DECODE, NULL, 0);
 
     if (pat->op != MUTT_PAT_HEADER)
     {
index 8ee1e734e6324b1b42c81e46f4bd71e941869aec..1d450a64734692d95d6838ef79955e7376180443 100644 (file)
--- a/recvcmd.c
+++ b/recvcmd.c
@@ -419,7 +419,7 @@ static void include_header(bool quote, FILE *fp_in, struct Email *e, FILE *fp_ou
     chflags |= CH_PREFIX;
   }
 
-  mutt_copy_header(fp_in, e, fp_out, chflags, quote ? prefix2 : NULL);
+  mutt_copy_header(fp_in, e, fp_out, chflags, quote ? prefix2 : NULL, 0);
 }
 
 /**
@@ -694,7 +694,7 @@ static void attach_forward_msgs(FILE *fp, struct AttachCtx *actx,
     if (cur)
     {
       mutt_forward_intro(Context->mailbox, cur->email, fp_tmp);
-      mutt_copy_message_fp(fp_tmp, fp, cur->email, cmflags, chflags);
+      mutt_copy_message_fp(fp_tmp, fp, cur->email, cmflags, chflags, 0);
       mutt_forward_trailer(Context->mailbox, cur->email, fp_tmp);
     }
     else
@@ -705,7 +705,7 @@ static void attach_forward_msgs(FILE *fp, struct AttachCtx *actx,
         {
           mutt_forward_intro(Context->mailbox, actx->idx[i]->content->email, fp_tmp);
           mutt_copy_message_fp(fp_tmp, actx->idx[i]->fp,
-                               actx->idx[i]->content->email, cmflags, chflags);
+                               actx->idx[i]->content->email, cmflags, chflags, 0);
           mutt_forward_trailer(Context->mailbox, actx->idx[i]->content->email, fp_tmp);
         }
       }
@@ -882,7 +882,7 @@ static void attach_include_reply(FILE *fp, FILE *fp_tmp, struct Email *e)
     cmflags |= MUTT_CM_WEED;
   }
 
-  mutt_copy_message_fp(fp_tmp, fp, e, cmflags, chflags);
+  mutt_copy_message_fp(fp_tmp, fp, e, cmflags, chflags, 0);
   mutt_make_post_indent(Context->mailbox, e, fp_tmp);
 }
 
diff --git a/send.c b/send.c
index 1aebc93c7ff301851b62247411b22398027ab1d7..c23eee02d98a5303efe250df372ff5bc38629cce 100644 (file)
--- a/send.c
+++ b/send.c
@@ -498,11 +498,7 @@ static int include_forward(struct Mailbox *m, struct Email *e, FILE *fp_out)
   if (C_ForwardQuote)
     cmflags |= MUTT_CM_PREFIX;
 
-  /* wrapping headers for forwarding is considered a display
-   * rather than send action */
-  chflags |= CH_DISPLAY;
-
-  mutt_copy_message(fp_out, m, e, cmflags, chflags);
+  mutt_copy_message(fp_out, m, e, cmflags, chflags, 0);
   mutt_forward_trailer(m, e, fp_out);
   return 0;
 }
@@ -701,7 +697,7 @@ static int include_reply(struct Mailbox *m, struct Email *e, FILE *fp_out)
     cmflags |= MUTT_CM_WEED;
   }
 
-  mutt_copy_message(fp_out, m, e, cmflags, chflags);
+  mutt_copy_message(fp_out, m, e, cmflags, chflags, 0);
 
   mutt_make_post_indent(m, e, fp_out);
 
index df679a8566919e833220d80cfedffda26397129f..965d5db4ea3efa4a4fc463dc98d426c0b60e11bd 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -1318,7 +1318,7 @@ void mutt_message_to_7bit(struct Body *a, FILE *fp)
   transform_to_7bit(a->parts, fp_in);
 
   mutt_copy_hdr(fp_in, fp_out, a->offset, a->offset + a->length,
-                CH_MIME | CH_NONEWLINE | CH_XMIT, NULL);
+                CH_MIME | CH_NONEWLINE | CH_XMIT, NULL, 0);
 
   fputs("MIME-Version: 1.0\n", fp_out);
   mutt_write_mime_header(a->parts, fp_out);
@@ -1551,7 +1551,7 @@ struct Body *mutt_make_message_attach(struct Mailbox *m, struct Email *e, bool a
     }
   }
 
-  mutt_copy_message(fp, m, e, cmflags, chflags);
+  mutt_copy_message(fp, m, e, cmflags, chflags, 0);
 
   fflush(fp);
   rewind(fp);
@@ -2148,8 +2148,8 @@ int mutt_write_one_header(FILE *fp, const char *tag, const char *value,
     else
       wraplen = C_WrapHeaders;
   }
-  else if ((wraplen <= 0) || (wraplen > MuttIndexWindow->cols))
-    wraplen = MuttIndexWindow->cols;
+  else if (wraplen <= 0)
+    wraplen = 78;
 
   if (tag)
   {
@@ -3082,7 +3082,7 @@ static int bounce_message(FILE *fp, struct Email *e, struct AddressList *to,
     FREE(&msgid_str);
     fputs("Resent-To: ", fp_tmp);
     mutt_write_addrlist(to, fp_tmp, 11, 0);
-    mutt_copy_header(fp, e, fp_tmp, chflags, NULL);
+    mutt_copy_header(fp, e, fp_tmp, chflags, NULL, 0);
     fputc('\n', fp_tmp);
     mutt_file_copy_bytes(fp, fp_tmp, e->content->length);
     if (mutt_file_fclose(&fp_tmp) != 0)
diff --git a/state.h b/state.h
index 36de1b10ea645bd78eff6aed6b91469676fef10a..998bcefa70734eefc5b51853f49353c56ca91798 100644 (file)
--- a/state.h
+++ b/state.h
@@ -43,10 +43,11 @@ typedef uint8_t StateFlags;          ///< Flags for State->flags, e.g. #MUTT_DIS
  */
 struct State
 {
-  FILE      *fp_in;  ///< File to read from
-  FILE      *fp_out; ///< File to write to
-  char      *prefix; ///< String to add to the beginning of each output line
-  StateFlags flags;  ///< Flags, e.g. #MUTT_DISPLAY
+  FILE      *fp_in;   ///< File to read from
+  FILE      *fp_out;  ///< File to write to
+  char      *prefix;  ///< String to add to the beginning of each output line
+  StateFlags flags;   ///< Flags, e.g. #MUTT_DISPLAY
+  int        wraplen; ///< Width to wrap lines to (when flags & #MUTT_DISPLAY)
 };
 
 #define state_set_prefix(state) ((state)->flags |= MUTT_PENDINGPREFIX)