Primary Photo ID Question

David Shaw dshaw at jabberwocky.com
Mon Aug 29 02:12:45 CEST 2005


On Sun, Aug 28, 2005 at 05:06:49PM -0400, Adam Schreiber wrote:
> Is there a reason why when a photo ID is made primary it isn't made the
> first photo ID on the key like regular uids are? i.e., 5 is the primary
> photo ID but it wasn't moved up to 3.
> 
> [ultimate] (3)  [jpeg image of size 334]
> [ultimate] (4)  [jpeg image of size 334]
> [ultimate] (5). [jpeg image of size 4827]
> [ultimate] (6)  [jpeg image of size 3873]

No real reason, just never got around to it.  Try the attached patch.

David
-------------- next part --------------
Index: keylist.c
===================================================================
--- keylist.c	(revision 3875)
+++ keylist.c	(working copy)
@@ -1379,15 +1379,16 @@
  * Reorder the keyblock so that the primary user ID (and not attribute
  * packet) comes first.  Fixme: Replace this by a generic sort
  * function.  */
-void
-reorder_keyblock (KBNODE keyblock)
+static void
+do_reorder_keyblock (KBNODE keyblock,int attr)
 {
     KBNODE primary = NULL, primary0 = NULL, primary2 = NULL;
     KBNODE last, node;
 
     for (node=keyblock; node; primary0=node, node = node->next) {
 	if( node->pkt->pkttype == PKT_USER_ID &&
-	    !node->pkt->pkt.user_id->attrib_data &&
+	    ((attr && node->pkt->pkt.user_id->attrib_data) ||
+	     (!attr && !node->pkt->pkt.user_id->attrib_data)) &&
             node->pkt->pkt.user_id->is_primary ) {
             primary = primary2 = node;
             for (node=node->next; node; primary2=node, node = node->next ) {
@@ -1419,6 +1420,13 @@
 }
 
 void
+reorder_keyblock (KBNODE keyblock)
+{
+  do_reorder_keyblock(keyblock,1);
+  do_reorder_keyblock(keyblock,0);
+}
+
+void
 list_keyblock( KBNODE keyblock, int secret, int fpr, void *opaque )
 {
     reorder_keyblock (keyblock);


More information about the Gnupg-devel mailing list