From 4782b5904f2cddc7ecda86abc0590a2ff8715b33 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Thu, 30 Dec 2021 12:56:27 -0500 Subject: Move filter-completion.pl to libtests/arg_parser --- libtests/qtest/arg_parser/filter-completion.pl | 41 ++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 libtests/qtest/arg_parser/filter-completion.pl (limited to 'libtests/qtest') diff --git a/libtests/qtest/arg_parser/filter-completion.pl b/libtests/qtest/arg_parser/filter-completion.pl new file mode 100644 index 00000000..2d176309 --- /dev/null +++ b/libtests/qtest/arg_parser/filter-completion.pl @@ -0,0 +1,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 () + { + chomp; + if (s/^!//) + { + $notwanted{$_} = 1; + } + else + { + $wanted{$_} = 1; + } + } + close(F); +} +while () +{ + chomp; + if (exists $wanted{$_}) + { + print $_, "\n"; + } + elsif (exists $notwanted{$_}) + { + delete $notwanted{$_}; + } +} +foreach my $k (sort keys %notwanted) +{ + print "!$k\n"; +} -- cgit v1.2.3-54-g00ecf