From 336cfe9843cf4aeb2030e7fb7aa9128d6b9a03e7 Mon Sep 17 00:00:00 2001 From: Patryk Zawadzki Date: Tue, 8 Jan 2008 17:27:02 +0000 Subject: - simplify parsing by storing mapping between numbers and URIs Changed files: specparser.pl -> 1.17 diff --git a/specparser.pl b/specparser.pl index 412005a..f4d7d05 100644 --- a/specparser.pl +++ b/specparser.pl @@ -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 () { 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); -- cgit v0.10.2