my %counts; # For --counts param, count of each issue type
my %suppressed_files; # Files with at least one issue type to suppress
+my $HEADER = <<END;
+# This file is the data file for $0.
+# There are three types of lines.
+# Comment lines are white-space only or begin with a '#', like this one. Any
+# changes you make to the comment lines will be lost when the file is
+# regen'd.
+# Lines without tab characters are simply NAMES of pods that the program knows
+# will have links to them and the program does not check if those links are
+# valid.
+# All other lines should have three fields, each separated by a tab. The
+# first field is the name of a pod; the second field is an error message
+# generated by this program; and the third field is a count of how many
+# known instances of that message there are in the pod. -1 means that the
+# program can expect any number of this type of message.
+END
+my @existing_issues;
-if ($add_link) {
- $copy_fh = open_new($known_issues);
- my @existing_db = <$data_fh>;
- my_safer_print($copy_fh, @existing_db);
-
- foreach my $module (@files) {
- die "\"$module\" does not look like a module or man page"
- # Must look like (A or A::B or A::B::C ..., or foo(3C)
- if $module !~ /^ (?: \w+ (?: :: \w+ )* | \w+ \( \d \w* \) ) $/x;
- $module .= "\n";
- next if grep { $module eq $_ } @existing_db;
- my_safer_print($copy_fh, $module);
- }
- close_and_rename($copy_fh);
- exit;
-}
while (<$data_fh>) { # Read the data base
chomp;
next if /^\s*(?:#|$)/; # Skip comment and empty lines
if (/\t/) {
next if $show_all;
+ if ($add_link) { # The issues are saved and later output unchanged
+ push @existing_issues, $_;
+ next;
+ }
# Keep track of counts of each issue type for each file
my ($filename, $message, $count) = split /\t/;
}
close $data_fh;
+if ($add_link) {
+ $copy_fh = open_new($known_issues);
+
+ # Check for basic sanity, and add each command line argument
+ foreach my $module (@files) {
+ die "\"$module\" does not look like a module or man page"
+ # Must look like (A or A::B or A::B::C ..., or foo(3C)
+ if $module !~ /^ (?: \w+ (?: :: \w+ )* | \w+ \( \d \w* \) ) $/x;
+ $valid_modules{$module} = 1
+ }
+ my_safer_print($copy_fh, $HEADER);
+ foreach (sort { lc $a cmp lc $b } keys %valid_modules) {
+ my_safer_print($copy_fh, $_, "\n");
+ }
+
+ # The rest of the db file is output unchanged.
+ my_safer_print($copy_fh, join "\n", @existing_issues);
+
+ close_and_rename($copy_fh);
+ exit;
+}
+
if ($show_counts) {
my $total = 0;
foreach my $message (sort keys %counts) {
if ($regen) {
$copy_fh = open_new($known_issues);
note("Regenerating $known_issues, please be patient...");
- print $copy_fh <<END;
-# This file is the data file for $0.
-# There are three types of lines.
-# Comment lines are white-space only or begin with a '#', like this one. Any
-# changes you make to the comment lines will be lost when the file is
-# regen'd.
-# Lines without tab characters are simply NAMES of pods that the program knows
-# will have links to them and the program does not check if those links are
-# valid.
-# All other lines should have three fields, each separated by a tab. The
-# first field is the name of a pod; the second field is an error message
-# generated by this program; and the third field is a count of how many
-# known instances of that message there are in the pod. -1 means that the
-# program can expect any number of this type of message.
-END
+ print $copy_fh $HEADER;
}
# Move to the directory above us, but have to adjust @INC to account for