From: doogie <>
Date: Thu, 22 Nov 2001 09:47:41 +0000 (-0800)
Subject: [project @ 2001-11-22 01:47:41 by doogie]
X-Git-Tag: release/2.6.0~1080
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=3548f7a3d7fd1e3e6915ae6d8ccacea2ca5ce3f4;p=debbugs.git

[project @ 2001-11-22 01:47:41 by doogie]
Unify the option parsing for pkg, src, maint, maintenc, submitter, and
severity.  Also, allow for which=src&data=dpkg style querying.
---

diff --git a/cgi/pkgreport.cgi b/cgi/pkgreport.cgi
index 507f4809..d2d93399 100755
--- a/cgi/pkgreport.cgi
+++ b/cgi/pkgreport.cgi
@@ -17,16 +17,45 @@ my %param = readparse();
 
 my ($pkg, $src, $maint, $maintenc, $submitter, $severity, $status);
 
-if (defined ($pkg = $param{'pkg'})) {
-} elsif (defined ($src = $param{'src'})) {
-} elsif (defined ($maint = $param{'maint'})) {
-} elsif (defined ($maintenc = $param{'maintenc'})) {
-} elsif (defined ($submitter= $param{'submitter'})) { 
-} elsif (defined ($severity = $param{'severity'})) { 
-	$status = $param{'status'} || 'open';
-} else {
-	quit("You have to choose something to select by");
+my %which = (
+	'pkg' => \$pkg,
+	'src' => \$src,
+	'maint' => \$maint,
+	'maintenc' => \$maintenc,
+	'submitter' => \$submitter,
+	'severity' => \$severity,
+	);
+my @allowedEmpty = ( 'maint' );
+
+my $found;
+foreach ( keys %which ) {
+	$status = $param{'status'} || 'open' if /^severity$/;
+	if (($found = $param{$_})) {
+		${ $which{$_} } = $found;
+		last;
+	}
+}
+if (!$found) {
+	foreach ( @allowedEmpty ) {
+		if (exists($param{$_})) {
+			${ $which{$_} } = '';
+			$found = 1;
+			last;
+		}
+	}
+}
+if (!$found) {
+	my $which;
+	if (($which = $param{'which'})) {
+		if (grep( /^\Q$which\E$/, @allowedEmpty)) {
+			${ $which{$which} } = $param{'data'};
+			$found = 1;
+		} elsif (($found = $param{'data'})) {
+			${ $which{$which} } = $found if (exists($which{$which}));
+		}
+	}
 }
+quit("You have to choose something to select by") if (!$found);
 
 my $repeatmerged = ($param{'repeatmerged'} || "yes") eq "yes";
 my $archive = ($param{'archive'} || "no") eq "yes";