X-Git-Url: https://git.deb.at/?a=blobdiff_plain;ds=sidebyside;f=cgi-bin%2Fsearch_packages.pl;h=88f9877a01d1ecc66748b1e938d0806ad9dcfb7a;hb=de413c76fc1abbada02c3fb8174d7ac3e4cd5a0b;hp=060602a630138142dfe39b5f0b17402b397d316b;hpb=d0086d64f40f548b3cdd63ca4223cc9bbaf70b76;p=deb%2Fpackages.git diff --git a/cgi-bin/search_packages.pl b/cgi-bin/search_packages.pl index 060602a..88f9877 100755 --- a/cgi-bin/search_packages.pl +++ b/cgi-bin/search_packages.pl @@ -26,7 +26,7 @@ use Deb::Versions; use Packages::Search qw( :all ); use Packages::HTML (); -my $thisscript = "search_packages.pl"; +my $thisscript = $Packages::HTML::SEARCH_CGI; my $HOME = "http://www.debian.org"; my $ROOT = ""; my $SEARCHPAGE = "http://packages.debian.org/"; @@ -44,12 +44,18 @@ my %ARCHITECTURES = map { $_ => 1 } @ARCHITECTURES; $ENV{PATH} = "/bin:/usr/bin"; # Read in all the variables set by the form -my $input = new CGI; +my $input; +if ($ARGV[0] eq 'php') { + $input = new CGI(\*STDIN); +} else { + $input = new CGI; +} my $pet0 = new Benchmark; # use this to disable debugging in production mode completly my $debug_allowed = 1; my $debug = $debug_allowed && $input->param("debug"); +$debug = 0 if not defined($debug); $Search::Param::debug = 1 if $debug > 1; # If you want, just print out a list of all of the variables and exit. @@ -230,21 +236,20 @@ sub do_names_search { my $p_obj = tie my %pref, 'DB_File', "$DBDIR/$postfix_file", O_RDONLY, 0666, $DB_BTREE or die "couldn't tie postfix db $DBDIR/$postfix_file: $!"; $p_obj->seq( $key, $prefixes, R_CURSOR ); - do { + while (index($key, $keyword) >= 0) { if ($prefixes =~ /^\001(\d+)/o) { $too_much_hits += $1; } else { - print "DEBUG: add word $key
" if $debug > 2; - $pkgs{$key}++; foreach (split /\000/o, $prefixes) { + $_ = '' if $_ eq '^'; print "DEBUG: add word $_$key
" if $debug > 2; $pkgs{$_.$key}++; } } - } while (($p_obj->seq( $key, $prefixes, R_NEXT ) == 0) - && (index($key, $keyword) >= 0) - && !$too_much_hits - && (keys %pkgs < 100)); + last if $p_obj->seq( $key, $prefixes, R_NEXT ) != 0; + last if $too_much_hits; + last if keys %pkgs < 100; + } my $no_results = keys %pkgs; if ($too_much_hits || ($no_results >= 100)) { @@ -595,3 +600,5 @@ END print $input->end_html; } + +# vim: ts=8 sw=4