diff options
author | Stefan Fritsch <sf@sfritsch.de> | 2008-09-23 23:11:54 +0000 |
---|---|---|
committer | Stefan Fritsch <sf@sfritsch.de> | 2008-09-23 23:11:54 +0000 |
commit | 8829bd9ec04d876019c78f9a0da5f6952b392b2b (patch) | |
tree | c11654ee46299474117e6f4f6f538ca06d966125 /bin/check-new-issues | |
parent | 567245d1e0b02c4761fc2c2e4995762f478f66c0 (diff) |
if automatic search gives only a few results, display all of them instead of just the count (-a 0 gives the old behaviour)
git-svn-id: svn+ssh://svn.debian.org/svn/secure-testing@9877 e39458fd-73e7-0310-bf30-c45bca0a0e42
Diffstat (limited to 'bin/check-new-issues')
-rwxr-xr-x | bin/check-new-issues | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/bin/check-new-issues b/bin/check-new-issues index 606f452308..e849a5c0d6 100755 --- a/bin/check-new-issues +++ b/bin/check-new-issues @@ -7,7 +7,7 @@ use Getopt::Std; use Term::ReadLine; my %opts; -getopts('ln:fhi:t:Tc', \%opts); +getopts('ln:fhi:t:Tca:', \%opts); if ($opts{h}) { print <<'EOF'; @@ -36,6 +36,8 @@ OPTIONS: [ -l [-n <n>] [-f] ] -t regexp : use regexp to select todos (default: '^\s+TODO: check$' ) -T : same as -t '^\s+TODO: check' (note the missing $) -c : only do syntax check of embedded-code-copies +-a <n> : If automatic apt-cache/apt-file search gives more than n results, + display only the count (default 10) EOF @@ -76,6 +78,8 @@ my $allitemsurl="http://cve.mitre.org/data/downloads/allitems.txt.gz"; my $issue_regexp= $opts{i} || 'CVE-200[3-9]'; my $todo_regexp= $opts{t} || ( $opts{T} ? '^\s+TODO: check' : '^\s+TODO: check$' ); +my $auto_display_limit = 10; +$auto_display_limit = $opts{a} if defined $opts{a}; my $editor=$ENV{EDITOR} || $ENV{VISUAL} || "vi"; @@ -285,9 +289,13 @@ sub auto_search { if ($prog) { my $prog_esc = quotemeta($prog); print "doing apt-cache search..."; - my $ac=`apt-cache search $prog_esc |wc -l`; - chomp $ac; - print "\r$ac results from apt-cache search $prog\n"; + my @ac=`apt-cache search $prog_esc`; + if (scalar @ac > $auto_display_limit || scalar @ac == 0) { + print "\r", scalar @ac, " results from apt-cache search $prog_esc\n"; + } + else { + print "\r=== apt-cache search $prog_esc:\n", @ac, "===\n"; + } foreach my $p (split /\s+/, $prog) { search_embed($p); @@ -300,10 +308,22 @@ sub auto_search { if (! exists $afcache{$file}) { my $file_esc = quotemeta($file); print "doing apt-file search..."; - $afcache{$file}=`apt-file -i search $file_esc |wc -l`; - chomp $afcache{$file}; + $afcache{$file}=[`apt-file -i search $file_esc`]; + if (scalar @{$afcache{$file}} > $auto_display_limit) { + # replace with empty array to save mem + my $num = scalar @{$afcache{$file}}; + $afcache{$file} = []; + $afcache{$file}->[$num-1] = undef; + } + } + if (scalar @{$afcache{$file}} > $auto_display_limit || + scalar @{$afcache{$file}} == 0) { + print "\r", scalar @{$afcache{$file}}, + " results from apt-file -i search $file\n"; + } + else { + print "\r=== apt-file -i search $file:\n", @{$afcache{$file}}, "===\n"; } - print "\r$afcache{$file} results from apt-file -i search $file\n"; } } |