- return \@results;
-}
-sub do_fulltext_search {
- my ($keword, $file, $mapping, $lookup, $read_entry, $opts) = @_;
- my @results;
-
- my @lines;
- my $regex;
- if ($opts->{case_bool}) {
- if ($opts->{exact}) {
- $regex = qr/\b\Q$keyword\E\b/o;
- } else {
- $regex = qr/\Q$keyword\E/o;
- }
- } else {
- if ($exact) {
- $regex = qr/\b\Q$keyword\E\b/io;
- } else {
- $regex = qr/\Q$keyword\E/io;
- }
- }
-
- open DESC, '<', "$DBDIR/$file"
- or die "couldn't open $DBDIR/$file: $!";
- while (<DESC>) {
- $_ =~ $regex or next;
- print "DEBUG: Matched line $.<br>" if $debug > 2;
- push @lines, $.;
- }
- close DESC;
-
- tie my %packages, 'DB_File', "$DBDIR/$lookup", O_RDONLY, 0666, $DB_BTREE
- or die "couldn't tie DB $DBDIR/$lookup: $!";
- tie my %did2pkg, 'DB_File', "$DBDIR/$mapping", O_RDONLY, 0666, $DB_BTREE
- or die "couldn't tie DB $DBDIR/$mapping: $!";
-
- my %tmp_results;
- foreach my $l (@lines) {
- my $result = $did2pkg{$l};
- foreach (split /\000/o, $result) {
- my @data = split /\s/, $_, 3;
- next unless $archs{$data[2]};
- $tmp_results{$data[0]}++;
- }
- }
- foreach my $pkg (keys %tmp_results) {
- &$read_entry( \%packages, $pkg, \@results );
- }
- return \@results;
-}
-
-if ($searchon eq 'names') {
- push @results, @{ do_names_search( $keyword, 'packages_small.db',
- 'package_postfixes.db',
- \&read_entry, \%opts ) };
-} elsif ($searchon eq 'sourcenames') {
- push @results, @{ do_names_search( $keyword, 'sources_small.db',
- 'source_postfixes.db',
- \&read_src_entry, \%opts ) };
-} else {
- push @results, @{ do_names_search( $keyword, 'packages_small.db',
- 'package_postfixes.db',
- \&read_entry, \%opts ) };
- push @results, @{ do_fulltext_search( $keyword, 'descriptions.txt',
- 'descriptions_packages.db',
- 'packages_small.db',
- \&read_entry, \%opts ) };