]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
finally a grep that works. Next -v and then we're ready
authorMiek Gieben <miekg@NLnetLabs.nl>
Fri, 10 Mar 2006 11:50:38 +0000 (11:50 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Fri, 10 Mar 2006 11:50:38 +0000 (11:50 +0000)
pcat/pcat-diff.c
pcat/pcat-grep.pl

index b65183a1dd5ee30a1de9872a274e003ab0e953f3..e7e534aa8edae7385a59642f14fe3136a4fa3618 100644 (file)
@@ -27,13 +27,13 @@ usage(FILE *fp)
        fprintf(fp, "There are no options, is FILE2 is not given, standard input is read\n");
         fprintf(fp, "\nOUTPUT FORMAT:\n");
         fprintf(fp, "    Line based output format, each record consists of 4 lines:\n");
-        fprintf(fp, "    1. xxx\t\tdecimal sequence number\n");
+        fprintf(fp, "    1. xxx:yyy\t\tdecimal sequence numbers\n");
         fprintf(fp, "    2. hex dump\t\tquery in hex, network order\n");
         fprintf(fp, "    3. hex dump\t\tanswer of FILE 1 in hex, network order\n");
         fprintf(fp, "    4. hex dump\t\tanswer of FILE 2 in hex, network order\n\n");
         fprintf(fp, " If a difference in the query is spotted the sequence nmuber\n");
         fprintf(fp, " is prefixed by a 'q: ' and the query data is printed:\n");
-        fprintf(fp, "    1. q: xxx\t\tdecimal sequence number\n");
+        fprintf(fp, "    1. q: xxx:yyy\tdecimal sequence numbers\n");
         fprintf(fp, "    2. hex dump\t\tquery in hex, network order\n");
         fprintf(fp, "    3. hex dump\t\tquery of FILE 1 in hex, network order\n");
         fprintf(fp, "    4. hex dump\t\tquery of FILE 2 in hex, network order\n");
index 333d02654a14e97d4747933a930961bedba2f4e5..7e5e1d4ab9960797bc89967aa72035d95498c7f0 100755 (executable)
@@ -7,10 +7,14 @@
 # seperated by comma's
 # -v reverse
 
-%numbers = ();
-$reverse = 0;
+use strict;
 
-foreach $r (@ARGV) {
+my %numbers = ();
+my $reverse = 0;
+my $i;
+my $k;
+
+foreach my $r (@ARGV) {
 
         if ($r eq "-v") {
                 $reverse = 1;
@@ -18,7 +22,7 @@ foreach $r (@ARGV) {
         }
         
         if ($r =~ /-/) {
-                ($s, $e) = split /-/, $r;
+                my ($s, $e) = split /-/, $r;
                 
                 if ($s > $e) {
                         next;
@@ -33,40 +37,25 @@ foreach $r (@ARGV) {
 }
 
 # read in the input, pcat style
+my $line; my $left; my $right;
 $i = 1;
-LINE: while(<STDIN>) {
+my $print = 0;
+while(<STDIN>) {
         if ($i % 4 == 1) {
                 ($left, $right) = split /:/, $_;
-                
-                if ($reverse == 0) {
-                        foreach $k (keys %numbers) {
-                                if ($k == $left) {
-                                        print $_;
-                                        print <STDIN>;
-                                        print <STDIN>;
-                                        print <STDIN>;
-                                        $i++;
-                                        next LINE;
-                                }
+                foreach $k (keys %numbers) {
+                        if ($k == $left) {
+                                $print = 1;
+                                last;
                         }
-                        <STDIN>;
-                        <STDIN>;
-                        <STDIN>;
-                } else {
-                        foreach $k (keys %numbers) {
-                                if ($k == $left) {
-                                        <STDIN>;
-                                        <STDIN>;
-                                        <STDIN>;
-                                        $i++;
-                                        next LINE;
-                                }
-                        }
-                        print $_;
-                        print <STDIN>;
-                        print <STDIN>;
-                        print <STDIN>;
+                        $print = 0;
                 }
+        }        
+        if ($print == 1) {
+                print $_;
+        }
+        if ($i % 4 == 0) {
+                $print = 0;
         }
         $i++;
 }