Package: lintian
Version: 2.80.0
Severity: normal
Tags: patch
Hi,
I found a lintian limitation while working with a manpage that refers to
two different binaries. In this scenario, lintian will mistakenly
consider the name of the second binary as the man section number, and
will issue a "manpage-section-mismatch" warning.
Consider a manpage whose header looks like:
.TH MOUNT.CIFS, MOUNT.SMB3 8 "" "" ""
.SH NAME
mount.cifs, mount.smb3 \- mount using the Common Internet File System (CIFS)
.
.nr rst2man-indent-level 0
When we run lintian, we will see:
W: cifs-utils: manpage-section-mismatch usr/share/man/man8/mount.cifs.8.gz:3 8 != MOUNT.SMB3
However, according to lexgrog(1) and other sources, it is possible to
specify multiple programs in the .TH directive, as long as they are
separated by a comma and a whitespace, which is the case here.
I'd like to propose the following patch to address the problem. The
idea is simple: after calling Text::ParseWords::parse_line, we check to
see if the first package name has a comma as the last char. If it does,
then we assume that there will be at least one other package name
listed, and advance an index. When we reach a package name whose last
char is not a comma, we then assume that the next field is the manpage
section number.
I tested with the problematic manpage I have here, and it works. I also
tested with other non-problematic manpages, and they still work as well.
Thanks,
--
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
https://sergiodj.net/
From d8cbe8d82733178589c30adff2335b37b26b3c8a Mon Sep 17 00:00:00 2001
From: Sergio Durigan Junior <sergiodj@debian.org>
Date: Wed, 10 Jun 2020 12:49:53 -0400
Subject: [PATCH] Adjust manpage-section-mismatch to accept manpages referring
to more than one program
---
checks/documentation/man.pm | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/checks/documentation/man.pm b/checks/documentation/man.pm
index 8092e023d..371552b6f 100644
--- a/checks/documentation/man.pm
+++ b/checks/documentation/man.pm
@@ -296,8 +296,20 @@ sub files {
chomp $line;
next if $line =~ /^\.\\\"/; # comments .\"
if ($line =~ /^\.TH\s/) { # header
- my (undef, undef, $th_section, undef)
+ my @th_fields
= Text::ParseWords::parse_line('\s+', 0, $line);
+ my $pkgname_idx = 1;
+ # Iterate over possible package names. If there is
+ # more than one, they will be separated by a comma and
+ # a whitespace. In case we find the comma, we advance
+ # $pkgname_idx.
+ while (substr($th_fields[$pkgname_idx], -1) eq ',') {
+ $pkgname_idx++;
+ }
+ # We're now at the last package, so we should be able
+ # to obtain the manpage section number by incrementing
+ # 1 to the index.
+ my $th_section = $th_fields[++$pkgname_idx];
if ($th_section && (lc($fn_section) ne lc($th_section))) {
$self->tag('manpage-section-mismatch',
"$file:$lc $fn_section != $th_section");
--
2.26.2
Attachment:
signature.asc
Description: PGP signature