Selaa lähdekoodia

dpkg-scansources: Handle parsed source control data just once

Move all control data processing after having parsed it. Sort the
entries if necessary, and then print them.
Guillem Jover 11 vuotta sitten
vanhempi
commit
6ec2138f61
1 muutettua tiedostoa jossa 9 lisäystä ja 19 poistoa
  1. 9 19
      scripts/dpkg-scansources.pl

+ 9 - 19
scripts/dpkg-scansources.pl

@@ -62,6 +62,7 @@ my $debug = 0;
 my $no_sort = 0;
 my $no_sort = 0;
 my $src_override = undef;
 my $src_override = undef;
 my $extra_override_file = undef;
 my $extra_override_file = undef;
+my @sources;
 
 
 my @option_spec = (
 my @option_spec = (
     'debug!' => \$debug,
     'debug!' => \$debug,
@@ -285,12 +286,10 @@ sub process_dsc {
 
 
     $checksums->export_to_control($fields, use_files_for_md5 => 1);
     $checksums->export_to_control($fields, use_files_for_md5 => 1);
 
 
-    return $fields;
+    push @sources, $fields;
 }
 }
 
 
 sub main {
 sub main {
-    my (@out);
-
     {
     {
         local $SIG{__WARN__} = sub { usageerr($_[0]) };
         local $SIG{__WARN__} = sub { usageerr($_[0]) };
         GetOptions(@option_spec);
         GetOptions(@option_spec);
@@ -312,32 +311,23 @@ sub main {
     	chomp;
     	chomp;
 	s{^\./+}{};
 	s{^\./+}{};
 
 
-        my $fields;
-
         # FIXME: Fix it instead to not die on syntax and general errors?
         # FIXME: Fix it instead to not die on syntax and general errors?
         eval {
         eval {
-            $fields = process_dsc($prefix, $_);
+            process_dsc($prefix, $_);
         };
         };
         if ($@) {
         if ($@) {
             warn $@;
             warn $@;
             next;
             next;
         }
         }
-
-	if ($no_sort) {
-            $fields->output(\*STDOUT);
-            print "\n";
-	}
-	else {
-            push @out, $fields;
-	}
     }
     }
     close $find_fh or syserr(g_('error closing %s (%s)'), 'find', $!);
     close $find_fh or syserr(g_('error closing %s (%s)'), 'find', $!);
 
 
-    if (@out) {
-        foreach my $dsc (sort { $a->{Package} cmp $b->{Package} } @out) {
-            $dsc->output(\*STDOUT);
-            print "\n";
-        }
+    if (not $no_sort) {
+        @sources = sort { $a->{Package} cmp $b->{Package} } @sources;
+    }
+    foreach my $dsc (@sources) {
+        $dsc->output(\*STDOUT);
+        print "\n";
     }
     }
 
 
     return 0;
     return 0;