summaryrefslogtreecommitdiff
path: root/textproc/mdoclint/files/mdoclint
diff options
context:
space:
mode:
Diffstat (limited to 'textproc/mdoclint/files/mdoclint')
-rwxr-xr-xtextproc/mdoclint/files/mdoclint58
1 files changed, 39 insertions, 19 deletions
diff --git a/textproc/mdoclint/files/mdoclint b/textproc/mdoclint/files/mdoclint
index 364c2fa2178..4a29a3383d0 100755
--- a/textproc/mdoclint/files/mdoclint
+++ b/textproc/mdoclint/files/mdoclint
@@ -1,7 +1,7 @@
#!@PERL5@
#
# $OpenBSD: mdoclint,v 1.14 2009/04/13 12:40:05 espie Exp $
-# $NetBSD: mdoclint,v 1.33 2013/06/02 11:58:36 wiz Exp $
+# $NetBSD: mdoclint,v 1.34 2013/07/30 18:37:56 wiz Exp $
#
# Copyright (c) 2001-2013 Thomas Klausner
# All rights reserved.
@@ -38,7 +38,9 @@ use Getopt::Std;
use constant {
OPENBSD => 0,
- NETBSD => 1
+ NETBSD => 1,
+ SECTION_SEE_ALSO => 2,
+ SECTION_AUTHORS => 3
};
use vars qw(
@@ -55,7 +57,7 @@ my $options="AaDdeFfHhlmnOoPprSsvwXx";
sub usage
{
- my $default = OPENBSD ? "-aDdfmnoPprSsXx" : "-aDdeflmnoPprSsXx";
+ my $default = OPENBSD ? "-AaDdfmnoPprSsXx" : "-AaDdeflmnoPprSsXx";
print STDERR <<"EOF";
mdoclint: verify man page correctness
@@ -315,7 +317,8 @@ sub new
sasection => 0,
saname => '',
sarest => ',',
- insa => 0,
+ inauthors => 0,
+ in_section => 0,
inliteral => 0,
shseen => {},
last_error_name => '',
@@ -364,22 +367,37 @@ sub parse_macro_args
return @params;
}
+sub end_of_section
+{
+ my ($s) = @_;
+
+ if ($s->{in_section} == SECTION_SEE_ALSO and not $s->{sarest} eq "") {
+ $s->warning("unneeded characters at end of SEE ALSO: ",
+ "`$s->{sarest}'") if $opt_a;
+ # to avoid a second warning at EOF
+ $s->{sarest} = "";
+ }
+
+ if ($s->{in_section} == SECTION_AUTHORS) {
+ if (!$s->{an_found}) {
+ $s->warning("missing .An in AUTHORS section") if $opt_A;
+ }
+ }
+}
+
sub set_section_header
{
my ($s, $section_header) = @_;
$section_header = join(' ', $s->parse_macro_args($section_header));
+ end_of_section($s);
+
if ($section_header eq 'SEE ALSO') {
- $s->{insa} = 1;
- } elsif ($s->{insa} == 1) {
- if (not $s->{sarest} eq "") {
- $s->warning("unneeded characters at end of ",
- "SEE ALSO: ", "`$s->{sarest}'") if $opt_a;
- # to avoid a second warning at EOF
- $s->{sarest} = "";
- }
- # finished SEE ALSO section
- $s->{insa} = 2;
+ $s->{in_section} = SECTION_SEE_ALSO;
+ } elsif ($section_header eq 'AUTHORS') {
+ $s->{in_section} = SECTION_AUTHORS;
+ } else {
+ $s->{in_section} = 0;
}
if (not $sections{$section_header}) {
@@ -471,7 +489,7 @@ sub process_line
}
}
- if ($s->{insa} == 1) {
+ if ($s->{in_section} == SECTION_SEE_ALSO) {
if (/^\.Xr\s+(\S+)\s+($sections_re)\s?(.*)?$/o) {
my ($saname, $sasection, $sarest) = ($1, $2, $3);
$saname =~ s/^\\&//o;
@@ -499,6 +517,11 @@ sub process_line
$s->{sarest} = "";
}
}
+ if ($s->{in_section} == SECTION_AUTHORS) {
+ if (/^\.An / && not /^\.An -(no|)split/) {
+ $s->{an_found} = 1;
+ }
+ }
if (/^\.Fn.*,.+/o) {
$s->warning("possible .Fn misuse: `$_'") if $opt_f;
@@ -647,10 +670,7 @@ sub finish
$s->warning("Paragraph problem: .Pp at EOF") if $opt_P;
}
- if ($s->{insa} > 0 and not $s->{sarest} eq "") {
- $s->warning("unneeded characters at end of SEE ALSO: ",
- "`$s->{sarest}'") if $opt_a;
- }
+ end_of_section($s);
# if (not ($fn =~ /$section$/)) {
# $s->warning("section doesn't match (internal value: $section)");