aboutsummaryrefslogtreecommitdiffstats
path: root/libtests/qtest/arg_parser/filter-completion.pl
blob: 2d1763090eb74f341603eebb8dc42e8ab35d4694 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use warnings;
use strict;

# THIS SCRIPT IS ALSO USED IN qpdf.test

# Output every line from STDIN that appears in the file.
my %wanted = ();
my %notwanted = ();
my $f = $ARGV[0];
if (open(F, "<$f"))
{
    while (<F>)
    {
        chomp;
        if (s/^!//)
        {
            $notwanted{$_} = 1;
        }
        else
        {
            $wanted{$_} = 1;
        }
    }
    close(F);
}
while (<STDIN>)
{
    chomp;
    if (exists $wanted{$_})
    {
        print $_, "\n";
    }
    elsif (exists $notwanted{$_})
    {
        delete $notwanted{$_};
    }
}
foreach my $k (sort keys %notwanted)
{
    print "!$k\n";
}