From 8bd0d8788415591f0a43c31bdb5ab6057ac82b98 Mon Sep 17 00:00:00 2001 From: Pietro Cerutti Date: Tue, 22 Nov 2016 12:14:15 +0000 Subject: [PATCH] build: add a constant for an aborted question Mnemonize mutt_yesorno()'s return on Ctrl-G as MUTT_ABORT Closes: #231 --- alias.c | 2 +- commands.c | 2 +- compose.c | 6 +++--- crypt-gpgme.c | 4 ++-- crypt.c | 7 +++---- curs_lib.c | 4 ++-- imap/imap.c | 6 +++--- imap/message.c | 2 +- mutt.h | 1 + muttlib.c | 4 ++-- mx.c | 8 ++++---- pgp.c | 2 +- pop_lib.c | 2 +- recvcmd.c | 4 ++-- send.c | 10 +++++----- smtp.c | 2 +- 16 files changed, 33 insertions(+), 33 deletions(-) diff --git a/alias.c b/alias.c index 131629a3f..aa079ea83 100644 --- a/alias.c +++ b/alias.c @@ -275,7 +275,7 @@ retry_name: case MUTT_YES: strfcpy (buf, fixed, sizeof (buf)); goto retry_name; - case -1: + case MUTT_ABORT: return; } } diff --git a/commands.c b/commands.c index baf808600..9d6a4dc83 100644 --- a/commands.c +++ b/commands.c @@ -995,7 +995,7 @@ void mutt_edit_content_type (HEADER *h, BODY *b, FILE *fp) int r; snprintf (tmp, sizeof (tmp), _("Convert to %s upon sending?"), mutt_get_parameter ("charset", b->parameter)); - if ((r = mutt_yesorno (tmp, !b->noconv)) != -1) + if ((r = mutt_yesorno (tmp, !b->noconv)) != MUTT_ABORT) b->noconv = (r == MUTT_NO); } diff --git a/compose.c b/compose.c index 10c143421..0c524ab6d 100644 --- a/compose.c +++ b/compose.c @@ -263,7 +263,7 @@ check_attachments(ATTACHPTR **idx, short idxlen) if((r = mutt_yesorno(msg, MUTT_YES)) == MUTT_YES) mutt_update_encoding(idx[i]->content); - else if(r == -1) + else if(r == MUTT_ABORT) return -1; } } @@ -1130,7 +1130,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ if (!fccSet && *fcc) { if ((i = query_quadoption (OPT_COPY, - _("Save a copy of this message?"))) == -1) + _("Save a copy of this message?"))) == MUTT_ABORT) break; else if (i == MUTT_NO) *fcc = 0; @@ -1371,7 +1371,7 @@ int mutt_compose_menu (HEADER *msg, /* structure for new message */ loop = 0; break; } - else if (i == -1) + else if (i == MUTT_ABORT) break; /* abort */ /* fall through to postpone! */ diff --git a/crypt-gpgme.c b/crypt-gpgme.c index 2a325e6d7..596b71161 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -4116,7 +4116,7 @@ static crypt_key_t *crypt_select_key (crypt_key_t *keys, _("%s Do you really want to use the key?"), _(warn_s)); - if (mutt_yesorno (buff, 0) != 1) + if (mutt_yesorno (buff, 0) != MUTT_YES) { mutt_clear_error (); break; @@ -4504,7 +4504,7 @@ static char *find_keys (ADDRESS *adrlist, unsigned int app, int oppenc_mode) continue; } } - else if (r == -1) + else if (r == MUTT_ABORT) { FREE (&keylist); rfc822_free_address (&addr); diff --git a/crypt.c b/crypt.c index ba2290af0..d20f270a2 100644 --- a/crypt.c +++ b/crypt.c @@ -130,7 +130,6 @@ int mutt_protect (HEADER *msg, char *keylist) BODY *tmp_smime_pbody = NULL; BODY *tmp_pgp_pbody = NULL; int flags = (WithCrypto & APPLICATION_PGP)? msg->security: 0; - int i; if (!WithCrypto) return -1; @@ -146,8 +145,8 @@ int mutt_protect (HEADER *msg, char *keylist) if ((msg->content->type != TYPETEXT) || ascii_strcasecmp (msg->content->subtype, "plain")) { - if ((i = query_quadoption (OPT_PGPMIMEAUTO, - _("Inline PGP can't be used with attachments. Revert to PGP/MIME?"))) != MUTT_YES) + if (query_quadoption (OPT_PGPMIMEAUTO, + _("Inline PGP can't be used with attachments. Revert to PGP/MIME?")) != MUTT_YES) { mutt_error _("Mail not sent: inline PGP can't be used with attachments."); return -1; @@ -165,7 +164,7 @@ int mutt_protect (HEADER *msg, char *keylist) } /* otherwise inline won't work...ask for revert */ - if ((i = query_quadoption (OPT_PGPMIMEAUTO, _("Message can't be sent inline. Revert to using PGP/MIME?"))) != MUTT_YES) + if (query_quadoption (OPT_PGPMIMEAUTO, _("Message can't be sent inline. Revert to using PGP/MIME?")) != MUTT_YES) { mutt_error _("Mail not sent."); return -1; diff --git a/curs_lib.c b/curs_lib.c index c5d279305..0481426f9 100644 --- a/curs_lib.c +++ b/curs_lib.c @@ -271,7 +271,7 @@ int mutt_yesorno (const char *msg, int def) break; if (ch.ch < 0) { - def = -1; + def = MUTT_ABORT; break; } @@ -310,7 +310,7 @@ int mutt_yesorno (const char *msg, int def) regfree (& reno); #endif - if (def != -1) + if (def != MUTT_ABORT) { addstr ((char *) (def == MUTT_YES ? yes : no)); mutt_refresh (); diff --git a/imap/imap.c b/imap/imap.c index 73809ff35..52d77664e 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -431,7 +431,7 @@ int imap_open_connection (IMAP_DATA* idata) if (option(OPTSSLFORCETLS)) rc = MUTT_YES; else if ((rc = query_quadoption (OPT_SSLSTARTTLS, - _("Secure connection with TLS?"))) == -1) + _("Secure connection with TLS?"))) == MUTT_ABORT) goto err_close_conn; if (rc == MUTT_YES) { if ((rc = imap_exec (idata, "STARTTLS", IMAP_CMD_FAIL_OK)) == -1) @@ -806,7 +806,7 @@ static int imap_open_mailbox_append (CONTEXT *ctx, int flags) return -1; snprintf (buf, sizeof (buf), _("Create %s?"), mailbox); - if (option (OPTCONFIRMCREATE) && mutt_yesorno (buf, 1) < 1) + if (option (OPTCONFIRMCREATE) && mutt_yesorno (buf, 1) != MUTT_YES) return -1; if (imap_create_mailbox (idata, mailbox) < 0) @@ -2155,7 +2155,7 @@ int imap_fast_trash (CONTEXT* ctx, char* dest) break; dprint (3, (debugfile, "imap_fast_trash: server suggests TRYCREATE\n")); snprintf (prompt, sizeof (prompt), _("Create %s?"), mbox); - if (option (OPTCONFIRMCREATE) && mutt_yesorno (prompt, 1) < 1) + if (option (OPTCONFIRMCREATE) && mutt_yesorno (prompt, 1) != MUTT_YES) { mutt_clear_error (); goto out; diff --git a/imap/message.c b/imap/message.c index 80144cec0..1b28d16a9 100644 --- a/imap/message.c +++ b/imap/message.c @@ -877,7 +877,7 @@ int imap_copy_messages (CONTEXT* ctx, HEADER* h, char* dest, int delete) break; dprint (3, (debugfile, "imap_copy_messages: server suggests TRYCREATE\n")); snprintf (prompt, sizeof (prompt), _("Create %s?"), mbox); - if (option (OPTCONFIRMCREATE) && mutt_yesorno (prompt, 1) < 1) + if (option (OPTCONFIRMCREATE) && mutt_yesorno (prompt, 1) != MUTT_YES) { mutt_clear_error (); goto out; diff --git a/mutt.h b/mutt.h index 4e31f56ae..bb8d09f3a 100644 --- a/mutt.h +++ b/mutt.h @@ -282,6 +282,7 @@ enum /* possible arguments to set_quadoption() */ enum { + MUTT_ABORT = -1, MUTT_NO, MUTT_YES, MUTT_ASKNO, diff --git a/muttlib.c b/muttlib.c index 84cf0c227..8a1114d3d 100644 --- a/muttlib.c +++ b/muttlib.c @@ -1716,7 +1716,7 @@ int mutt_save_confirm (const char *s, struct stat *st) snprintf (tmp, sizeof (tmp), _("Append messages to %s?"), s); if ((rc = mutt_yesorno (tmp, MUTT_YES)) == MUTT_NO) ret = 1; - else if (rc == -1) + else if (rc == MUTT_ABORT) ret = -1; } } @@ -1749,7 +1749,7 @@ int mutt_save_confirm (const char *s, struct stat *st) snprintf (tmp, sizeof (tmp), _("Create %s?"), s); if ((rc = mutt_yesorno (tmp, MUTT_YES)) == MUTT_NO) ret = 1; - else if (rc == -1) + else if (rc == MUTT_ABORT) ret = -1; } } diff --git a/mx.c b/mx.c index 3173e860a..af1ae0c39 100644 --- a/mx.c +++ b/mx.c @@ -849,7 +849,7 @@ int mx_close_mailbox (CONTEXT *ctx, int *index_hint) if (nntp_data && nntp_data->nserv && nntp_data->group) { int rc = query_quadoption (OPT_CATCHUP, _("Mark all articles read?")); - if (rc < 0) + if (rc == MUTT_ABORT) { ctx->closing = 0; return -1; @@ -898,7 +898,7 @@ int mx_close_mailbox (CONTEXT *ctx, int *index_hint) { mutt_expand_path (mbox, sizeof (mbox)); snprintf (buf, sizeof (buf), _("Move read messages to %s?"), mbox); - if ((move_messages = query_quadoption (OPT_MOVE, buf)) == -1) + if ((move_messages = query_quadoption (OPT_MOVE, buf)) == MUTT_ABORT) { ctx->closing = 0; return (-1); @@ -915,7 +915,7 @@ int mx_close_mailbox (CONTEXT *ctx, int *index_hint) snprintf (buf, sizeof (buf), ctx->deleted == 1 ? _("Purge %d deleted message?") : _("Purge %d deleted messages?"), ctx->deleted); - if ((purge = query_quadoption (OPT_DELETE, buf)) < 0) + if ((purge = query_quadoption (OPT_DELETE, buf)) == MUTT_ABORT) { ctx->closing = 0; return (-1); @@ -1206,7 +1206,7 @@ int mx_sync_mailbox (CONTEXT *ctx, int *index_hint) snprintf (buf, sizeof (buf), ctx->deleted == 1 ? _("Purge %d deleted message?") : _("Purge %d deleted messages?"), ctx->deleted); - if ((purge = query_quadoption (OPT_DELETE, buf)) < 0) + if ((purge = query_quadoption (OPT_DELETE, buf)) == MUTT_ABORT) return (-1); else if (purge == MUTT_NO) { diff --git a/pgp.c b/pgp.c index 6a6f3c91b..6a5dea20c 100644 --- a/pgp.c +++ b/pgp.c @@ -1333,7 +1333,7 @@ char *pgp_findKeys (ADDRESS *adrlist, int oppenc_mode) continue; } } - else if (r == -1) + else if (r == MUTT_ABORT) { FREE (&keylist); rfc822_free_address (&addr); diff --git a/pop_lib.c b/pop_lib.c index 023745e86..44eb333ee 100644 --- a/pop_lib.c +++ b/pop_lib.c @@ -293,7 +293,7 @@ int pop_open_connection (POP_DATA *pop_data) { ret = query_quadoption (OPT_SSLSTARTTLS, _("Secure connection with TLS?")); - if (ret == -1) + if (ret == MUTT_ABORT) return -2; pop_data->use_stls = 1; if (ret == MUTT_YES) diff --git a/recvcmd.c b/recvcmd.c index 7f310be5e..a00744dec 100644 --- a/recvcmd.c +++ b/recvcmd.c @@ -483,7 +483,7 @@ static void attach_forward_bodies (FILE * fp, HEADER * hdr, && !check_can_decode (idx, idxlen, cur)) { if ((rc = query_quadoption (OPT_MIMEFWDREST, -_("Can't decode all tagged attachments. MIME-forward the others?"))) == -1) +_("Can't decode all tagged attachments. MIME-forward the others?"))) == MUTT_ABORT) goto bail; else if (rc == MUTT_NO) mime_fwd_any = 0; @@ -864,7 +864,7 @@ void mutt_attach_reply (FILE * fp, HEADER * hdr, if (nattach > 1 && !check_can_decode (idx, idxlen, cur)) { if ((rc = query_quadoption (OPT_MIMEFWDREST, - _("Can't decode all tagged attachments. MIME-encapsulate the others?"))) == -1) + _("Can't decode all tagged attachments. MIME-encapsulate the others?"))) == MUTT_ABORT) return; else if (rc == MUTT_YES) mime_reply_any = 1; diff --git a/send.c b/send.c index bb468f760..8f9acfc0a 100644 --- a/send.c +++ b/send.c @@ -589,7 +589,7 @@ int mutt_fetch_recips (ENVELOPE *out, ENVELOPE *in, int flags) in->mail_followup_to->mailbox, in->mail_followup_to->next ? ",..." : ""); - if ((hmfupto = query_quadoption (OPT_MFUPTO, prompt)) == -1) + if ((hmfupto = query_quadoption (OPT_MFUPTO, prompt)) == MUTT_ABORT) return -1; } @@ -600,12 +600,12 @@ int mutt_fetch_recips (ENVELOPE *out, ENVELOPE *in, int flags) rfc822_free_address (&tmp); if (in->mail_followup_to && hmfupto == MUTT_YES && - default_to (&out->cc, in, flags & SENDLISTREPLY, hmfupto) == -1) + default_to (&out->cc, in, flags & SENDLISTREPLY, hmfupto) == MUTT_ABORT) return (-1); /* abort */ } else { - if (default_to (&out->to, in, flags & SENDGROUPREPLY, hmfupto) == -1) + if (default_to (&out->to, in, flags & SENDGROUPREPLY, hmfupto) == MUTT_ABORT) return (-1); /* abort */ if ((flags & SENDGROUPREPLY) && (!in->mail_followup_to || hmfupto != MUTT_YES)) @@ -832,7 +832,7 @@ generate_body (FILE *tempfp, /* stream for outgoing message */ if (flags & SENDREPLY) { - if ((i = query_quadoption (OPT_INCLUDE, _("Include message in reply?"))) == -1) + if ((i = query_quadoption (OPT_INCLUDE, _("Include message in reply?"))) == MUTT_ABORT) return (-1); if (i == MUTT_YES) @@ -1313,7 +1313,7 @@ ci_send_message (int flags, /* send mode */ /* If the user is composing a new message, check to see if there * are any postponed messages first. */ - if ((i = query_quadoption (OPT_RECALL, _("Recall postponed message?"))) == -1) + if ((i = query_quadoption (OPT_RECALL, _("Recall postponed message?"))) == MUTT_ABORT) return rv; if(i == MUTT_YES) diff --git a/smtp.c b/smtp.c index 1d147a5af..a99e50aea 100644 --- a/smtp.c +++ b/smtp.c @@ -463,7 +463,7 @@ static int smtp_open (CONNECTION* conn) rc = MUTT_YES; else if (mutt_bit_isset (Capabilities, STARTTLS) && (rc = query_quadoption (OPT_SSLSTARTTLS, - _("Secure connection with TLS?"))) == -1) + _("Secure connection with TLS?"))) == MUTT_ABORT) return rc; if (rc == MUTT_YES) -- 2.40.0