Debian Codegraph @

helper/list-words-cont

raw
1 #! /usr/bin/perl
2 use warnings;
3 use strict;
4 use integer;
5 use FindBin;
6 use lib $FindBin::RealBin;
7 use Def;
8
9 # This script scans the Package, Provides and Sources fields of a
10 # Packages file for words containing the words you list on the command
11 # line.
12 #
13 # You probably won't use this script much, but it may prove useful if
14 # you want a full list of words to search for when searching
15 # dependencies. For example, when searching for Perl dependencies, you
16 # might not think to include "perlapi" but to exclude "hyperlatex" in
17 # your search. This script will at least remind you of both words.
18 #
19 # The script scans case-insensitively. It is insensitive to the cases
20 # of the words you supply.
21
22 our $usage = <<END;
23 usage: $0 [-h] [Packages file] [word]...
24 -h print this usage message
25 END
26
27 # Read command-line arguments and options.
28 my @opt;
29 my @arg;
30 {
31 my $stopopt = '';
32 for ( @ARGV ) {
33 if ( $stopopt ) { push @arg, $_ }
34 elsif ( $_ eq '-' ) { $stopopt = '1' }
35 else { push @{ /^-/ ? \@opt : \@arg }, $_ }
36 }
37 }
38 my %opt = map { my @o = split ''; shift @o; map {$_=>1} @o; } @opt;
39 if ( $opt{'?'} || $opt{h} || @arg < 1 ) { print $usage; exit 0; }
40
41 my %word;
42 my $fn_packages = shift @arg;
43 $_ = quotemeta for @arg;
44
45 open P, '<', $fn_packages;
46 while (<P>) {
47 my( $text ) = /^(?:Package|Source|Provides):(.*)$/ or next;
48 for my $word ( $text =~ /\b\w+\b/g ) {
49 for my $w ( @arg ) {
50 $word{$word} = 1 if $word =~ /$w/i;
51 }
52 }
53 }
54 close P;
55
56 print "$_\n" for sort keys %word;
57