-
-sub nextlink {
- my ($cgi, $params, $no_results ) = @_;
-
- my $page = $params->{values}{page}{final}
- || DEFAULT_PAGE;
- $page++;
- my $res_per_page = $params->{values}{number}{final}
- || DEFAULT_RES_PER_PAGE;
-
- if ((($page-1)*$res_per_page + 1) > $no_results) {
- return ">>";
+sub read_src_entry {
+ my ($hash, $key, $results, $opts) = @_;
+ my @non_results;
+ read_src_entry_all( $hash, $key, $results, \@non_results, $opts );
+}
+sub do_names_search {
+ my ($keywords, $packages, $postfixes, $read_entry, $opts,
+ $results, $non_results) = @_;
+
+ my $first_keyword = lc shift @$keywords;
+ @$keywords = map { lc $_ } @$keywords;
+
+ my ($key, $prefixes) = ($first_keyword, '');
+ my %pkgs;
+ $postfixes->seq( $key, $prefixes, R_CURSOR );
+ while (index($key, $first_keyword) >= 0) {
+ if ($prefixes =~ /^\001(\d+)/o) {
+ debug( "$key has too many hits", 2 ) if DEBUG;
+ $too_many_hits += $1;
+ } else {
+ PREFIX:
+ foreach (split /\000/o, $prefixes) {
+ $_ = '' if $_ eq '^';
+ my $word = "$_$key";
+ foreach my $k (@$keywords) {
+ next PREFIX unless $word =~ /\Q$k\E/;
+ }
+ debug( "add word $word", 2) if DEBUG;
+ $pkgs{$word}++;
+ }
+ }
+ last if $postfixes->seq( $key, $prefixes, R_NEXT ) != 0;
+ last if $too_many_hits or keys %pkgs >= 100;
+ }
+
+ my $no_results = keys %pkgs;
+ if ($too_many_hits || ($no_results >= 100)) {
+ $too_many_hits += $no_results;
+ %pkgs = ( $first_keyword => 1 ) unless @$keywords;
+ }
+ foreach my $pkg (sort keys %pkgs) {
+ &$read_entry( $packages, $pkg, $results, $non_results, $opts );