]> granicus.if.org Git - neomutt/commitdiff
build: add a constant for an aborted question
authorPietro Cerutti <gahr@gahr.ch>
Tue, 22 Nov 2016 12:14:15 +0000 (12:14 +0000)
committerRichard Russon <rich@flatcap.org>
Tue, 29 Nov 2016 14:01:18 +0000 (14:01 +0000)
Mnemonize mutt_yesorno()'s return on Ctrl-G as MUTT_ABORT

Closes: #231
16 files changed:
alias.c
commands.c
compose.c
crypt-gpgme.c
crypt.c
curs_lib.c
imap/imap.c
imap/message.c
mutt.h
muttlib.c
mx.c
pgp.c
pop_lib.c
recvcmd.c
send.c
smtp.c

diff --git a/alias.c b/alias.c
index 131629a3f10f0afc4f880890f23e940222efbda5..aa079ea8322bab76f1211b45dc91972a0ef75c36 100644 (file)
--- 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;
     }
   }
index baf808600b1cffc502394b0513dcd44b8ac34776..9d6a4dc83c97a9f97ee94a2ef68108d124d4defa 100644 (file)
@@ -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);
   }
 
index 10c143421fd069fb30afdb85e1e40fa1c724d462..0c524ab6d2e23effab8ed98936bc7edd3cc77596 100644 (file)
--- 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! */
index 2a325e6d75e6dc82b46afd1657947c522b9e4935..596b7116165fbcefcaf8451e73e94c2765f53d40 100644 (file)
@@ -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 ba2290af08d8a0cc2e5a447210c0ea3c60b9f1b2..d20f270a28b6a09ffe0d82e7dd903c1a35d9e4a5 100644 (file)
--- 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;
index c5d279305e4fb9014effbd648dc718af17d632af..0481426f9cf8a34d2c3d263c2cbb6e5a6174201f 100644 (file)
@@ -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 ();
index 73809ff358a747386371f945ff335aad8413f517..52d77664e220501e35dbabcd29bae887756965bc 100644 (file)
@@ -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;
index 80144cec069f85adf66a52107a6e70e19d2ff794..1b28d16a965ea0d930292780354769e72b0e36e3 100644 (file)
@@ -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 4e31f56ae74dcc3b0ca72bca36f7a5353e56f04d..bb8d09f3a7a1e2520a834d902a2c57bfad28cce7 100644 (file)
--- 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,
index 84cf0c2274354c8162dce93e8b125549a9c81350..8a1114d3dc0ca7a1f85d4089e552408b4f88e28a 100644 (file)
--- 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 3173e860ab071d812495823a586d2e54f02e022b..af1ae0c3905287965888cdd0888772a6ada94eaa 100644 (file)
--- 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 6a6f3c91b5fc11c47bb3437af58d7e37f107a810..6a5dea20cd41fe737c7adf407bcbb4f140446475 100644 (file)
--- 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);
index 023745e866849c113b579db0d777384c55be7036..44eb333eeaba78960e5dc16975c5b817e788cf7c 100644 (file)
--- 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)
index 7f310be5e9806e065c21e9c1d5371e7ba5f80089..a00744decfd9981f531b87b62282f8d82b83bc13 100644 (file)
--- 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 bb468f7608fb2a68ac8a70763fca0497d69858cc..8f9acfc0a0efc9bf6acb9ac794cbb5f35106c508 100644 (file)
--- 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 1d147a5af51daab55657403cf11035144642c779..a99e50aea1effacf091e68f0243d1a89cc780aee 100644 (file)
--- 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)