[svn] GnuPG - r4686 - trunk/sm

svn author marcus cvs at cvs.gnupg.org
Wed Jan 30 18:21:30 CET 2008


Author: marcus
Date: 2008-01-30 18:21:28 +0100 (Wed, 30 Jan 2008)
New Revision: 4686

Modified:
   trunk/sm/ChangeLog
   trunk/sm/keylist.c
Log:
2008-01-29  Marcus Brinkmann  <marcus at g10code.de>

	* keylist.c (list_internal_keys): New variable lastcert.  Use it
	to suppress duplicates which immediately follow each other.


Modified: trunk/sm/ChangeLog
===================================================================
--- trunk/sm/ChangeLog	2008-01-30 14:26:57 UTC (rev 4685)
+++ trunk/sm/ChangeLog	2008-01-30 17:21:28 UTC (rev 4686)
@@ -1,3 +1,8 @@
+2008-01-29  Marcus Brinkmann  <marcus at g10code.de>
+
+	* keylist.c (list_internal_keys): New variable lastcert.  Use it
+	to suppress duplicates which immediately follow each other.
+
 2008-01-27  Werner Koch  <wk at g10code.com>
 
 	* import.c (popen_protect_tool): Set bit 7 in the flags for

Modified: trunk/sm/keylist.c
===================================================================
--- trunk/sm/keylist.c	2008-01-30 14:26:57 UTC (rev 4685)
+++ trunk/sm/keylist.c	2008-01-30 17:21:28 UTC (rev 4686)
@@ -1171,6 +1171,7 @@
   strlist_t sl;
   int ndesc;
   ksba_cert_t cert = NULL;
+  ksba_cert_t lastcert = NULL;
   gpg_error_t rc = 0;
   const char *lastresname, *resname;
   int have_secret;
@@ -1228,6 +1229,7 @@
      currently we stop at the first match.  To do this we need an
      extra flag to enable this feature so */
 
+  /* Suppress duplicates at least when they follow each other.  */
   lastresname = NULL;
   while (!(rc = keydb_search (hd, desc, ndesc)))
     {
@@ -1248,7 +1250,15 @@
           log_error ("keydb_get_cert failed: %s\n", gpg_strerror (rc));
           goto leave;
         }
-      
+      /* Skip duplicated certificates, at least if they follow each
+	 others.  This works best if a single key is searched for and
+	 expected.  FIXME: Non-sequential duplicates remain.  */
+      if (gpgsm_certs_identical_p (cert, lastcert))
+	{
+	  ksba_cert_release (cert);
+	  continue;
+	}
+
       resname = keydb_get_resource_name (hd);
       
       if (lastresname != resname ) 
@@ -1301,7 +1311,9 @@
               es_putc ('\n', fp);
             }
         }
-      ksba_cert_release (cert); 
+
+      ksba_cert_release (lastcert); 
+      lastcert = cert;
       cert = NULL;
     }
   if (gpg_err_code (rc) == GPG_ERR_EOF || rc == -1 )
@@ -1311,6 +1323,7 @@
   
  leave:
   ksba_cert_release (cert);
+  ksba_cert_release (lastcert); 
   xfree (desc);
   keydb_release (hd);
   return rc;




More information about the Gnupg-commits mailing list