From 9dbe02ed5bc5737333082e388e12680c24dac76c Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Sat, 19 Oct 2019 16:53:57 +0100 Subject: [PATCH] eliminate MuttIndexWindow from mutt_copy_message() `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()` --- commands.c | 4 ++-- copy.c | 42 ++++++++++++++++++++++++------------------ copy.h | 8 ++++---- editmsg.c | 2 +- handler.c | 11 +++++++---- maildir/shared.c | 2 +- mbox/mbox.c | 2 +- mutt_attach.c | 2 +- ncrypt/crypt.c | 17 ++++++++++------- ncrypt/smime.c | 4 ++-- pattern.c | 2 +- recvcmd.c | 8 ++++---- send.c | 8 ++------ sendlib.c | 10 +++++----- state.h | 9 +++++---- 15 files changed, 70 insertions(+), 61 deletions(-) diff --git a/commands.c b/commands.c index f1ba0c7e1..1333c33bf 100644 --- a/commands.c +++ b/commands.c @@ -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 0a9d16f38..c707e6782 100644 --- 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 11e5742f5..beddf1a40 100644 --- 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); diff --git a/editmsg.c b/editmsg.c index 4593621bd..cdd7e1fa8 100644 --- 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); diff --git a/handler.c b/handler.c index 3332626e9..bfd0aaf8a 100644 --- 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); } } diff --git a/maildir/shared.c b/maildir/shared.c index c778446c9..1d8a494dd 100644 --- a/maildir/shared.c +++ b/maildir/shared.c @@ -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]; diff --git a/mbox/mbox.c b/mbox/mbox.c index 7f55bb8d3..a54321994 100644 --- a/mbox/mbox.c +++ b/mbox/mbox.c @@ -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); diff --git a/mutt_attach.c b/mutt_attach.c index 0083a01aa..09712dd54 100644 --- a/mutt_attach.c +++ b/mutt_attach.c @@ -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; diff --git a/ncrypt/crypt.c b/ncrypt/crypt.c index c407daafb..b99f97f70 100644 --- a/ncrypt/crypt.c +++ b/ncrypt/crypt.c @@ -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); } } diff --git a/ncrypt/smime.c b/ncrypt/smime.c index 3daf78168..e34ecf897 100644 --- a/ncrypt/smime.c +++ b/ncrypt/smime.c @@ -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); diff --git a/pattern.c b/pattern.c index f5e657db2..6fcfccb4a 100644 --- 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) { diff --git a/recvcmd.c b/recvcmd.c index 8ee1e734e..1d450a647 100644 --- 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 1aebc93c7..c23eee02d 100644 --- 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); diff --git a/sendlib.c b/sendlib.c index df679a856..965d5db4e 100644 --- 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 36de1b10e..998bcefa7 100644 --- 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) -- 2.40.0