]> git.donarmstrong.com Git - debbugs.git/commitdiff
[project @ 2001-11-22 01:47:41 by doogie]
authordoogie <>
Thu, 22 Nov 2001 09:47:41 +0000 (01:47 -0800)
committerdoogie <>
Thu, 22 Nov 2001 09:47:41 +0000 (01:47 -0800)
Unify the option parsing for pkg, src, maint, maintenc, submitter, and
severity.  Also, allow for which=src&data=dpkg style querying.

cgi/pkgreport.cgi

index 507f48092379df0ad5e164a58cb15d6908ca243e..d2d933994fe39486a32ba9a657010ace5c976a5b 100755 (executable)
@@ -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";