]> git.pld-linux.org Git - projects/distfiles.git/commitdiff
- simplify parsing by storing mapping between numbers and URIs
authorPatryk Zawadzki <patrys@room-303.com>
Tue, 8 Jan 2008 17:27:02 +0000 (17:27 +0000)
committercvs2git <feedback@pld-linux.org>
Thu, 29 Nov 2012 22:58:16 +0000 (22:58 +0000)
Changed files:
    specparser.pl -> 1.17

specparser.pl

index 412005a4dfc307566380abed33b0f3eb10ece051..f4d7d05408fa97c806315eb8817ba47c7421b9a6 100644 (file)
@@ -241,47 +241,35 @@ sub print_source($$$) # {{{
 sub add_md5_to_print($) # {{{
 {
        open(F, "< $_[0]") or die;
-       my $sourceno = undef;
-       my $source = undef;
+       my @sourcemap = ();
        while (<F>) {
                chomp;
                if (/^Source(\d+)\s*:\s*(.*)/i) {
-                       $sourceno = $1;
-                       $source = $2;
+                       my $sourceno = $1;
+                       my $source = $2;
+                       $sourcemap[$sourceno] = $source;
                } elsif (/^\s*#\s*source(\d+)-md5\s*:\s*([a-f0-9]{32})/i) {
                        my $no = $1;
                        my $md5 = $2;
                        if (defined $no_source{$no}) {
                                error("both NoSource: $no and md5 given");
-                       } if (defined $sourceno) {
-                               if ($sourceno == $no) {
-                                       push @sources, [$no, $md5, $source];
-                               } else {
-                                       error("found md5 for source $no, but last defined source is $sourceno (# SourceN-md5: has to be placed just after SourceN:)");
-                               }
+                       } if (defined $sourcemap[$no]) {
+                               my $source = $sourcemap[$no];
+                               push @sources, [$no, $md5, $source];
                        } else {
                                error("source $no not defined (# SourceN-md5: has to be placed just after SourceN:)");
                        }
-
-                       $sourceno = undef;
-                       $source = undef;
                } elsif (/^\s*BuildRequires:\s*digest\(%SOURCE(\d+)\)\s*=\s*([a-f0-9]{32})/i) {
                        my $no = $1;
                        my $md5 = $2;
                        if (defined $no_source{$no}) {
                                error("both NoSource: $no and md5 given");
-                       } if (defined $sourceno) {
-                               if ($sourceno == $no) {
-                                       push @sources, [$no, $md5, $source];
-                               } else {
-                                       error("found md5 for source $no, but last defined source is $sourceno (# SourceN-md5: has to be placed just after SourceN:)");
-                               }
+                       } if (defined $sourcemap[$no]) {
+                               my $source = $sourcemap[$no];
+                               push @sources, [$no, $md5, $source];
                        } else {
-                               error("source $no not defined (# SourceN-md5: has to be placed just after SourceN:)");
+                               error("source $no not defined (# Source digest has to be placed after SourceN:)");
                        }
-
-                       $sourceno = undef;
-                       $source = undef;
                }
        }
        close(F);
This page took 0.047532 seconds and 4 git commands to generate.