lintian: r139 - in trunk: checks debian
Author: djpig
Date: 2004-04-09 03:49:49 +0200 (Fri, 09 Apr 2004)
New Revision: 139
Modified:
trunk/checks/manpages
trunk/checks/manpages.desc
trunk/debian/changelog
Log:
Parse contents of man page and implement more new checks:
- Section number of file and header differ (Closes: #89488)
- Try to search for hyphens that should be minus signs
(Closes: #205924). First patch by Eduard Bloch, final
regex by Josip Rodin.
- Search for FSSTND directories referenced in man pages. Only
an info tag. (Closes: #111098)
[Note: especially test 2 needs extensive testing and should be
investigated closely. After some first tests I would not be
suprised if it would double the total number of lintian warnings!]
Modified: trunk/checks/manpages
===================================================================
--- trunk/checks/manpages 2004-04-08 20:39:35 UTC (rev 138)
+++ trunk/checks/manpages 2004-04-09 01:49:49 UTC (rev 139)
@@ -127,16 +127,17 @@
print "E: $pkg $type: manpage-not-compressed-with-max-compression $file\n";
}
}
- my $num = pop @pieces;
- if (scalar @pieces && $num =~ s/^(\d).*$/$1/) {
+ my $fn_section = pop @pieces;
+ my $section_num = $fn_section;
+ if (scalar @pieces && $section_num =~ s/^(\d).*$/$1/) {
my $bin = join(".", @pieces);
$manpage{$bin} = $file;
# number of directory and manpage extension equal?
- if ($num != $section) {
+ if ($section_num != $section) {
print "E: $pkg $type: manpage-in-wrong-directory $file\n";
}
- push @{$sect_by_manpage{$bin}}, $num; # array needed for cases like man(1), man(7)
+ push @{$sect_by_manpage{$bin}}, $section_num; # array needed for cases like man(1), man(7)
} else {
print "E: $pkg $type: manpage-has-wrong-extension $file\n";
}
@@ -181,15 +182,17 @@
}
}
} else { # not a symlink
+ open MANFILE, "zcat unpacked/\Q$file\E 2>/dev/null |"
+ or fail("cannot open $file: $!");
+ my @manfile = ();
+ while (<MANFILE>) { push @manfile, $_; }
+ close MANFILE;
# Is it a .so link?
if ($size < 256) {
- open SOTEST, "zcat unpacked/\Q$file\E 2>/dev/null |"
- or fail("cannot open $file: $!");
- my $line = <SOTEST>;
- close SOTEST;
- unless ($line) {
+ my $first = $manfile[0];
+ unless ($first) {
print "E: $pkg $type: empty-manual-page $file\n";
- } elsif ($line =~ /^\.so\s+(.+)?$/) {
+ } elsif ($first =~ /^\.so\s+(.+)?$/) {
my $dest = $1;
if ($dest =~ m,^([^/]+)/(.+)$,) {
my ($manxorlang, $rest) = ($1, $2);
@@ -224,6 +227,34 @@
print "E: $pkg $type: manpage-has-bad-whatis-entry $file\n";
}
}
+ # Now we search through the whole man page for some common errors
+ my $lc = 0;
+ my $hc = 0;
+ foreach my $line (@manfile) {
+ $lc++;
+ chomp $line;
+ next if $line =~ /^\.\\\"/o; # comments .\"
+ if ($line =~ /^\.TH\s/) { # header
+ require Text::ParseWords;
+ my ($th_command, $th_title, $th_section, $th_date ) =
+ Text::ParseWords::parse_line( '\s+', 0, $line);
+ if ($th_section && ($fn_section ne $th_section)) {
+ print "E: $pkg $type: manpage-section-mismatch $file:$lc $fn_section != $th_section\n";
+ }
+ }
+ if ($line =~ /^[^\.][^\\].*\W--?\w+/o) {
+ # hyphen at the begin of a word, probably not!
+ $hc++;
+ print "W: $pkg $type: hyphen-used-as-minus-sign $file:$lc\n" if $hc <= 10 or $ENV{'LINTIAN_DEBUG'};
+ }
+ if (($line =~ m,(/usr/(dict|doc|etc|info|man|adm|preserve)/),o)
+ || ($line =~ m,(/var/(adm|catman|named|nis|preserve)/),o)) {
+ # FSSTND dirs in man pages
+ # regexes taken from checks/files
+ print "I: $pkg $type: FSSTND-dir-in-manual-page $file:$lc $1";
+ }
+ }
+ print "W: $pkg $type: hyphen-used-as-minus-sign $file ".($hc-10)." more occurences not shown\n" if $hc > 10 and ! $ENV{'LINTIAN_DEBUG'};
}
}
close(IN);
Modified: trunk/checks/manpages.desc
===================================================================
--- trunk/checks/manpages.desc 2004-04-08 20:39:35 UTC (rev 138)
+++ trunk/checks/manpages.desc 2004-04-09 01:49:49 UTC (rev 139)
@@ -135,3 +135,34 @@
Tag: empty-manual-page
Type: error
Info: The referenced manual page is empty.
+
+Tag: manpage-section-missmatch
+Type: error
+Info: Most man pages contain a header line (marked .TH) in which
+ among other thing their section number is specified. For this
+ particular man page the section number in the header line isn't
+ equal with the section number specified by the filename. This
+ is most probably an error (In most cases caused by someone
+ renaming the file but not adjusting the content).
+
+Tag: hyphen-used-as-minus-sign
+Type: warning
+Info: Manual page seems to contain a hyphen where a minus sign was intended.
+ '-' chars are interpreted as hyphens by groff, not as minus signs (which
+ you want for options for example). '-' must be escaped ('\-') to be
+ interpreted as minus. See groff(7) for details.
+ .
+ Because this error can occur <em>very</em> often we show only the
+ first 10 occurences for each man page and give the number of
+ suppressed occurences. If you want to see all warnings, run
+ lintian with the -d/--debug option.
+
+Tag: FSSTND-dir-in-manual-page
+Type: info
+Info: The manual page references a directory that is specified
+ in the FSSTND but not in the FHS which is used by Debian.
+ This can be an indicator of a mismatch of the location of
+ files as installed for Debian and as described by the man page.
+ .
+ If you have to change file locations to abide by Debian Policy
+ please also patch the man page to mention these new locations.
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2004-04-08 20:39:35 UTC (rev 138)
+++ trunk/debian/changelog 2004-04-09 01:49:49 UTC (rev 139)
@@ -38,9 +38,17 @@
Dinstall::CutOffPastYear from dak CVS as limit.
(Closes: #204801, #218304)
* checks/manpages:
- + [FL] Two new errors: 1) if section number of directory and file
- differ, 2) if section number of file differs from what is expected
- from the location of the binary. (Closes: #203831)
+ + [FL] New checks:
+ - Section number of directory and file differ
+ - Section number of file differs from what is expected
+ from the location of the binary. (Closes: #203831)
+ + [FL] Parse contents of man page and implement more new checks:
+ - Section number of file and header differ (Closes: #89488)
+ - Try to search for hyphens that should be minus signs
+ (Closes: #205924). First patch by Eduard Bloch, final
+ regex by Josip Rodin.
+ - Search for FSSTND directories referenced in man pages. Only
+ an info tag. (Closes: #111098)
* checks/menu-format:
+ [FL] Only issue one warning about needs=dwww, not two
+ [HE] Check if the command given with command= is in the package
Reply to: