summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authorJason McIntyre <jmc@cvs.openbsd.org>2013-08-05 07:09:43 +0000
committerJason McIntyre <jmc@cvs.openbsd.org>2013-08-05 07:09:43 +0000
commit8d5cd62a18dc2b13d29426fb68305a6c5bdbac21 (patch)
treeec935fac52e559602e3acd780bd8bdaefacc650f /regress
parentd9f1157ffef195f3712713a072d30a5b50551824 (diff)
integrate support for an -A option, which warns if an AUTHORS section
does not contain any An macros; from wiz@netbsd
Diffstat (limited to 'regress')
-rw-r--r--regress/usr.bin/mdoclint/mdoclint69
-rw-r--r--regress/usr.bin/mdoclint/mdoclint.116
2 files changed, 56 insertions, 29 deletions
diff --git a/regress/usr.bin/mdoclint/mdoclint b/regress/usr.bin/mdoclint/mdoclint
index 3463b2aefa9..1c4fb931f89 100644
--- a/regress/usr.bin/mdoclint/mdoclint
+++ b/regress/usr.bin/mdoclint/mdoclint
@@ -1,7 +1,7 @@
#!/usr/bin/perl
#
-# $OpenBSD: mdoclint,v 1.33 2013/06/02 14:33:18 jmc Exp $
-# $NetBSD: mdoclint,v 1.33 2013/06/02 11:58:36 wiz Exp $
+# $OpenBSD: mdoclint,v 1.34 2013/08/05 07:09:42 jmc Exp $
+# $NetBSD: mdoclint,v 1.34 2013/07/30 18:37:56 wiz Exp $
#
# Copyright (c) 2001-2013 Thomas Klausner
# All rights reserved.
@@ -38,11 +38,13 @@ use Getopt::Std;
use constant {
OPENBSD => 1,
- NETBSD => 0
+ NETBSD => 0,
+ SECTION_SEE_ALSO => 2,
+ SECTION_AUTHORS => 3
};
use vars qw(
- $opt_a $opt_D $opt_d $opt_e $opt_F $opt_f $opt_H $opt_h $opt_l
+ $opt_A $opt_a $opt_D $opt_d $opt_e $opt_F $opt_f $opt_H $opt_h $opt_l
$opt_m
$opt_n $opt_o $opt_P $opt_p $opt_r $opt_S $opt_s $opt_v $opt_w
$opt_X $opt_x
@@ -51,15 +53,16 @@ use vars qw(
my $arch=`uname -m`;
chomp($arch);
-my $options="aDdeFfHhlmnoPprSsvwXx";
+my $options="AaDdeFfHhlmnoPprSsvwXx";
sub usage
{
- my $default = OPENBSD ? "-aDdfmnoPprSsXx" : "-aDdelfmnoPprSsXx";
+ my $default = OPENBSD ? "-AaDdfmnoPprSsXx" : "-AaDdeflmnoPprSsXx";
print STDERR <<"EOF";
mdoclint: verify man page correctness
usage: mdoclint [-$options] file ...
+ -A warn about missing .An in AUTHORS section
-a warn about SEE ALSO section problems
-D warn about bad casing and archs in .Dt
-d warn about bad date strings (in .Dd only)
@@ -247,12 +250,12 @@ sub handle_options
$opt_h and usage();
# default to all warnings if no flag is set
- unless ($opt_a or $opt_D or $opt_d or $opt_e
+ unless ($opt_A or $opt_a or $opt_D or $opt_d or $opt_e
or $opt_f or $opt_H or $opt_l
or $opt_m or $opt_n
or $opt_o or $opt_P or $opt_p or $opt_r
or $opt_S or $opt_s or $opt_X or $opt_x) {
- $opt_a = $opt_D = $opt_d = $opt_f = $opt_m =
+ $opt_A = $opt_a = $opt_D = $opt_d = $opt_f = $opt_m =
$opt_n = $opt_o = $opt_P = $opt_p = $opt_r = $opt_S =
$opt_s = $opt_X = $opt_x = 1;
$opt_e = $opt_l = 1 if NETBSD;
@@ -296,7 +299,8 @@ sub new
sasection => 0,
saname => '',
sarest => ',',
- insa => 0,
+ inauthors => 0,
+ in_section => 0,
inliteral => 0,
shseen => {},
last_error_name => '',
@@ -345,22 +349,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}) {
@@ -452,7 +471,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;
@@ -480,6 +499,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;
@@ -628,10 +652,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)");
diff --git a/regress/usr.bin/mdoclint/mdoclint.1 b/regress/usr.bin/mdoclint/mdoclint.1
index a653c8efd6f..d31862b4136 100644
--- a/regress/usr.bin/mdoclint/mdoclint.1
+++ b/regress/usr.bin/mdoclint/mdoclint.1
@@ -1,5 +1,5 @@
-.\" $OpenBSD: mdoclint.1,v 1.14 2013/07/16 14:18:39 schwarze Exp $
-.\" $NetBSD: mdoclint.1,v 1.2 2009/04/13 22:18:13 wiz Exp $
+.\" $OpenBSD: mdoclint.1,v 1.15 2013/08/05 07:09:42 jmc Exp $
+.\" $NetBSD: mdoclint.1,v 1.10 2013/07/30 18:50:07 wiz Exp $
.\"
.\" Copyright (c) 2001-2013 Thomas Klausner
.\" All rights reserved.
@@ -25,7 +25,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: July 16 2013 $
+.Dd $Mdocdate: August 5 2013 $
.Dt MDOCLINT 1
.Os
.Sh NAME
@@ -33,7 +33,7 @@
.Nd man page verifier
.Sh SYNOPSIS
.Nm
-.Op Fl aDdeFfHhlmnoPprSsvwXx
+.Op Fl AaDdeFfHhlmnoPprSsvwXx
.Ar
.Sh DESCRIPTION
.Nm
@@ -41,12 +41,18 @@ is a man page verifier.
It tries to automatically find as many common
errors that occur when writing man pages as possible.
If no flags are given,
-.Fl aDdfmnoPprSsXx
+.Fl AaDdfmnoPprSsXx
is assumed (that is, everything except
.Fl eFHhlvw ) .
.Pp
The options are as follows:
.Bl -tag -width Ds
+.It Fl A
+Warn if the
+.Dq .An
+macro (author) markup is not used in the
+.Sx AUTHORS
+section.
.It Fl a
Warn about some possible problems in the
.Sx SEE ALSO