Kevin J. McCarthy wrote:
> Pull is_numerical_keyid() into crypt.c.
> 
> A subsequent patch (re?)-introduces a call to is_numerical_keyid inside
> find_keys().  Rather than duplicate the function, this patch pulls it
> into crypt.c, where find_keys() and pgp_findKeys() can both call it.

A recent commit introduced a merge conflict with this patch.  Attached
is a revised patch.

-Kevin
# HG changeset patch
# User Kevin McCarthy <[email protected]>
# Date 1423248570 28800
#      Fri Feb 06 10:49:30 2015 -0800
# Node ID f2a37ffe2af3c31331964411ddcfa23b26e41c00
# Parent  47aaaf6fa679009e40f7456e0242bd8988ebc2df
Pull is_numerical_keyid() into crypt.c.

A subsequent patch (re?)-introduces a call to is_numerical_keyid inside
find_keys().  Rather than duplicate the function, this patch pulls it
into crypt.c, where find_keys() and pgp_findKeys() can both call it.

diff --git a/crypt.c b/crypt.c
--- a/crypt.c
+++ b/crypt.c
@@ -992,8 +992,30 @@
     }
   }
 
   *pphint = phint;
   *ppl = pl;
   *pps = ps;
   return pfcopy;
 }
+
+
+/*
+ * Used by pgp_findKeys and find_keys to check if a crypt-hook
+ * value is a key id.
+ */
+
+short crypt_is_numerical_keyid (const char *s)
+{
+  /* or should we require the "0x"? */
+  if (strncmp (s, "0x", 2) == 0)
+    s += 2;
+  if (strlen (s) % 8)
+    return 0;
+  while (*s)
+    if (strchr ("0123456789ABCDEFabcdef", *s++) == NULL)
+      return 0;
+
+  return 1;
+}
+
+
diff --git a/mutt_crypt.h b/mutt_crypt.h
--- a/mutt_crypt.h
+++ b/mutt_crypt.h
@@ -162,16 +162,19 @@
             Must be FREE'd by caller.
    *pphint  Start of string to be passed to pgp_add_string_to_hints() or 
             crypt_add_string_to_hints().
    *ppl     Start of long key ID if detected, else NULL.
    *pps     Start of short key ID if detected, else NULL. */
 const char* crypt_get_fingerprint_or_id (char *p, const char **pphint,
     const char **ppl, const char **pps);
 
+/* Check if a string contains a numerical key */
+short crypt_is_numerical_keyid (const char *s);
+
 
 
 /*-- cryptglue.c --*/
 
 /* Show a message that a backend will be invoked. */
 void crypt_invoke_message (int type);
 
 
diff --git a/pgp.c b/pgp.c
--- a/pgp.c
+++ b/pgp.c
@@ -26,16 +26,17 @@
  * a message.
  */
 
 #if HAVE_CONFIG_H
 # include "config.h"
 #endif
 
 #include "mutt.h"
+#include "mutt_crypt.h"
 #include "mutt_curses.h"
 #include "pgp.h"
 #include "mime.h"
 #include "copy.h"
 
 #include <sys/wait.h>
 #include <string.h>
 #include <stdlib.h>
@@ -1149,30 +1150,16 @@
   t->disposition = DISPNONE;
   t->encoding = ENC7BIT;
   t->unlink = 1; /* ok to remove this file after sending. */
   mutt_set_parameter ("name", "signature.asc", &t->parameter);
 
   return (a);
 }
 
-static short is_numerical_keyid (const char *s)
-{
-  /* or should we require the "0x"? */
-  if (strncmp (s, "0x", 2) == 0)
-    s += 2;
-  if (strlen (s) % 8)
-    return 0;
-  while (*s)
-    if (strchr ("0123456789ABCDEFabcdef", *s++) == NULL)
-      return 0;
-  
-  return 1;
-}
-
 /* This routine attempts to find the keyids of the recipients of a message.
  * It returns NULL if any of the keys can not be found.
  * If oppenc_mode is true, only keys that can be determined without
  * prompting will be used.
  */
 char *pgp_findKeys (ADDRESS *adrlist, int oppenc_mode)
 {
   char *keyID, *keylist = NULL;
@@ -1192,17 +1179,17 @@
     k_info = NULL;
 
     if ((keyID = mutt_crypt_hook (p)) != NULL)
     {
       int r;
       snprintf (buf, sizeof (buf), _("Use keyID = \"%s\" for %s?"), keyID, 
p->mailbox);
       if ((r = mutt_yesorno (buf, M_YES)) == M_YES)
       {
-       if (is_numerical_keyid (keyID))
+       if (crypt_is_numerical_keyid (keyID))
        {
          if (strncmp (keyID, "0x", 2) == 0)
            keyID += 2;
          goto bypass_selection;                /* you don't see this. */
        }
        
        /* check for e-mail address */
        if (strchr (keyID, '@') && 

Attachment: signature.asc
Description: PGP signature

Reply via email to