admin: distfiles/specparser.pl - simplify parsing by storing mappi...

patrys patrys at pld-linux.org
Tue Jan 8 18:27:07 CET 2008


Author: patrys                       Date: Tue Jan  8 17:27:07 2008 GMT
Module: admin                         Tag: HEAD
---- Log message:
- simplify parsing by storing mapping between numbers and URIs

---- Files affected:
admin/distfiles:
   specparser.pl (1.16 -> 1.17) 

---- Diffs:

================================================================
Index: admin/distfiles/specparser.pl
diff -u admin/distfiles/specparser.pl:1.16 admin/distfiles/specparser.pl:1.17
--- admin/distfiles/specparser.pl:1.16	Tue Jan  8 17:44:55 2008
+++ admin/distfiles/specparser.pl	Tue Jan  8 18:27:02 2008
@@ -241,47 +241,35 @@
 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);
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/admin/distfiles/specparser.pl?r1=1.16&r2=1.17&f=u



More information about the pld-cvs-commit mailing list