Previously, the final entry (packet) in a key would be wrongly
attributed to the next key in the output, except for the final entry in
the keyring, which would be attributed correctly.

Since this happened consistently, the diff would not be influenced much
as long as the keys remained in the same order. However, when adding a
key, the final entry in the keyring changes, causing one bogus change to
appear in the diff output.

This commit slightly restructures the parsing function to push out a
previous packet before changing the current key id. It also adds a few
comments.
---
 jetring-diff |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/jetring-diff b/jetring-diff
index 6a75e72..6f5b2f4 100755
--- a/jetring-diff
+++ b/jetring-diff
@@ -95,16 +95,24 @@ sub parse_keyring {
                my @fields=split(":", $_);
                $fields[5]="-"; # ignore creation date, varies
                next if $fields[0] eq 'tru';
-               if ($fields[0] eq 'pub') {
-                       $id=$fields[4];
-               }
                if ($fields[0] ne 'sig' && $fields[0] ne 'rev') {
+                       # sig and rev fields tag along with the preceding 
packet,
+                       # any other fields need their own packet. If there is a
+                       # previous packet, push it and create a new one.
                        if (defined($packet)) {
                                push @{$keys{$id}}, $packet;
                                undef $packet;
                        }
                        $packet->{'details'} = \...@fields;
+                       
+                       # If this is the start of a new public key, save the id 
for
+                       # all the subsequent packets
+                       if ($fields[0] eq 'pub') {
+                               $id=$fields[4];
+                       }
                } else {
+                       # This is a signature or revocation, it needs a key and
+                       # packet to go with
                        if (! defined $id or !defined($packet)) {
                                die "parse error: $_";
                                next;
@@ -112,6 +120,7 @@ sub parse_keyring {
                        push @{$packet->{'sigs'}}, \...@fields;
                }
        }
+       # Push any last packet still hanging around
        push @{$keys{$id}}, $packet;
        close DUMP;
 
-- 
1.6.3.3




-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to