From db45dced32e561cd9034b616ffb5da653564f640 Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Mon, 8 Jul 2019 15:23:44 -0700 Subject: [PATCH] Factor out mutt_edit_address() in send.c For reuse by autocrypt for address prompts. Co-authored-by: Richard Russon --- send.c | 15 ++++++++------- send.h | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/send.c b/send.c index 3c3daba9e..d778ed60a 100644 --- a/send.c +++ b/send.c @@ -197,13 +197,13 @@ static void add_mailing_lists(struct AddressList *out, const struct AddressList } /** - * edit_address - Edit an email address + * mutt_edit_address - Edit an email address * @param[in,out] al AddressList to edit * @param[in] field Prompt for user * @retval 0 Success * @retval -1 Failure */ -static int edit_address(struct AddressList *al, const char *field) +int mutt_edit_address(struct AddressList *al, const char *field, int expand_aliases) { char buf[8192]; char *err = NULL; @@ -218,7 +218,8 @@ static int edit_address(struct AddressList *al, const char *field) return -1; mutt_addrlist_clear(al); mutt_addrlist_parse2(al, buf); - mutt_expand_aliases(al); + if (expand_aliases) + mutt_expand_aliases(al); idna_ok = mutt_addrlist_to_intl(al, &err); if (idna_ok != 0) { @@ -278,14 +279,14 @@ static int edit_envelope(struct Envelope *en, SendFlags flags) else #endif { - if ((edit_address(&en->to, _("To: ")) == -1) || TAILQ_EMPTY(&en->to)) + if ((mutt_edit_address(&en->to, _("To: "), 1) == -1) || TAILQ_EMPTY(&en->to)) return -1; - if (C_Askcc && (edit_address(&en->cc, _("Cc: ")) == -1)) + if (C_Askcc && (mutt_edit_address(&en->cc, _("Cc: "), 1) == -1)) return -1; - if (C_Askbcc && (edit_address(&en->bcc, _("Bcc: ")) == -1)) + if (C_Askbcc && (mutt_edit_address(&en->bcc, _("Bcc: "), 1) == -1)) return -1; if (C_ReplyWithXorig && (flags & (SEND_REPLY | SEND_LIST_REPLY | SEND_GROUP_REPLY)) && - (edit_address(&en->from, "From: ") == -1)) + (mutt_edit_address(&en->from, "From: ", 1) == -1)) { return -1; } diff --git a/send.h b/send.h index 17e631de4..5c38fb456 100644 --- a/send.h +++ b/send.h @@ -103,6 +103,7 @@ typedef uint16_t SendFlags; ///< Flags for ci_send_message(), e.g. # int ci_send_message(SendFlags flags, struct Email *e_templ, const char *tempfile, struct Context *ctx, struct EmailList *el); void mutt_add_to_reference_headers(struct Envelope *env, struct Envelope *curenv); struct Address *mutt_default_from(void); +int mutt_edit_address(struct AddressList *al, const char *field, int expand_aliases); void mutt_encode_descriptions(struct Body *b, bool recurse); int mutt_fetch_recips(struct Envelope *out, struct Envelope *in, SendFlags flags); void mutt_fix_reply_recipients(struct Envelope *env); -- 2.40.0