diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2017-07-03 11:21:24 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2017-07-03 11:21:24 +0000 |
commit | c0e0f83154d85418ce8d627804c92ed9732cb25c (patch) | |
tree | daafc519950a2eb59abf7b0fdf4d199c190aa761 /regress/usr.bin | |
parent | c73c51b8ef944d03454f5f190a11dadf0ac020b2 (diff) |
Remove mdoclint(1) from the tree.
All functionality is now covered by mandoc -Tlint.
OK jmc@ wiz@
Diffstat (limited to 'regress/usr.bin')
-rw-r--r-- | regress/usr.bin/mdoclint/Makefile | 9 | ||||
-rw-r--r-- | regress/usr.bin/mdoclint/mdoclint | 273 | ||||
-rw-r--r-- | regress/usr.bin/mdoclint/mdoclint.1 | 93 |
3 files changed, 0 insertions, 375 deletions
diff --git a/regress/usr.bin/mdoclint/Makefile b/regress/usr.bin/mdoclint/Makefile deleted file mode 100644 index bc2c96ea3dc..00000000000 --- a/regress/usr.bin/mdoclint/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# $OpenBSD: Makefile,v 1.1 2008/10/31 14:11:04 jmc Exp $ - -MAN= mdoclint.1 - -afterinstall: - install -c -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ - ${.CURDIR}/mdoclint ${DESTDIR}/usr/bin/mdoclint - -.include <bsd.prog.mk> diff --git a/regress/usr.bin/mdoclint/mdoclint b/regress/usr.bin/mdoclint/mdoclint deleted file mode 100644 index 8d0aa5da82e..00000000000 --- a/regress/usr.bin/mdoclint/mdoclint +++ /dev/null @@ -1,273 +0,0 @@ -#!/usr/bin/perl -# -# $OpenBSD: mdoclint,v 1.75 2017/07/01 13:17:09 schwarze Exp $ -# $NetBSD: mdoclint,v 1.77 2017/06/08 10:19:56 wiz Exp $ -# -# Copyright (c) 2001-2017 Thomas Klausner -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR, THOMAS KLAUSNER, -# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -use strict; -use warnings; - -$| = 1; - -package Parser; -use Getopt::Std; - -use constant { - OPENBSD => 1, - NETBSD => 0, -}; - -use vars qw($opt_F $opt_h $opt_m $opt_v $opt_x); - -my $arch=`uname -m`; -chomp($arch); -my $options="Fhmvx"; - -sub usage -{ - print STDERR <<"EOF"; -mdoclint: verify man page correctness -usage: mdoclint [-$options] file ... - -F fix whitespace problems (asks before overwriting) - -h display this help text - -m warn about man pages that are not in mdoc(7) format - -v verbose output - -x warn about cross-references with missing targets -Default is -mx if no flag is specified. -EOF - exit(0); -} - -# constants to build -my $sections_re; -my $esections_re; - -# and the code that builds them -{ - if (OPENBSD) { - $sections_re = qr{(?:3p|[1-9])}o; - $esections_re = qr{(?:3p|[0-9])}o; - } - if (NETBSD) { - $sections_re = qr{[1-9](?:lua)?}o; - $esections_re = qr{[0-9](?:lua)?}o; - } -} - -sub debug -{ - my $self = shift; - print STDOUT "debug: $self->{fn}:$self->{ln}: @_\n" if $opt_v; -} - -sub warning -{ - my $self = shift; - print STDOUT "$self->{fn}:$self->{ln}: ", join('', @_), "\n"; -} - -sub handle_options -{ - getopts($options); - $opt_h and usage(); - - # default to all warnings if no flag is set - $opt_m = $opt_x = 1 unless $opt_m or $opt_x; -} - -sub verify_xref -{ - my ($self, $page, $section, $pre, $post) = @_; - if ($self->{names}{$page.$section}) { - $self->warning("Xref to itself (use .Nm instead)") if $opt_x; - } - # try to find corresponding man page - if (OPENBSD) { - open my $saveout, '>&', STDOUT; - open my $saveerr, '>&', STDERR; - open STDOUT, '>', '/dev/null'; - open STDERR, '>', '/dev/null'; - my $irc = system 'man', '-M', '/usr/share/man:/usr/X11R6/man', - '-s', $section, '-f', $page; - open STDOUT, '>&', $saveout; - open STDERR, '>&', $saveerr; - return 1 unless $irc; - } else { - for my $dir ('/usr/share/man', '/usr/X11R7/man') { - for my $a ('', $arch) { - for my $page ("man$section/$a/$page.$section") { - return 1 if -f "$dir/$page"; - } - } - } - } - return 1 if -f "./$page.$section"; - return 1 if -f "./$page.mdoc"; - - $self->warning($pre."trailing Xref to $page($section)$post") if $opt_x; - return 0; -} - -sub new -{ - my ($class, $fn) = @_; - - my $o = { - mandoc_p => 1, - all => [], - changes => 0, - in_name => 0, - sec => '0', - names => { $fn => 1 }, - fn => $fn - }; - $o->{sec} = $1 if $fn =~ /\.(.+?)$/; - open my $input, '<', $fn or die "can't open input file $fn"; - $o->{file} = $input; - $o->{ln} = 0; - bless $o, $class; -} - -sub next_line -{ - my ($self) = @_; - - my $l = readline($self->{file}); - if (defined $l) { - $self->{ln}++; - } - return $l; -} - -sub close -{ - my ($self) = @_; - - close($self->{file}); -} - -sub process_and_save_line -{ - my ($s, $input) = @_; - my $result = $s->process_line($input); - # note that process_line chomps \n, then re-adds it, - # so we detect a change on last lines without a \n. - if ($result ne "$input") { - $s->{changes} = 1; - } - push(@{$s->{all}}, $result); -} - -sub process_line -{ - my $s; - ($s, $_) = @_; - chomp; - # always cut trailing spaces - s/\s+$//o; - # comments - if (/^\.\\\"/) { - return "$_\n"; - } - if (/^\.TH\s+/o) { - $s->warning("not mandoc") if $opt_m; - $s->{mandoc_p} = 0; - return "$_\n"; - } - if (/^\.Dt\s+\S+\s+([1-9])/o) { - $s->{sec} = $1; - } - if ($s->{mandoc_p}) { - if (/^\.Sh\s+"?(.*?)"?\s*$/o) { - my $line = $_; - $s->{in_name} = $1 eq 'NAME'; - return "$line\n"; - } - } else { - if (/^\.SH\s+"?(.*?)"?\s*$/o) { - my $line = $_; - $s->{in_name} = $1 eq 'NAME'; - return "$line\n"; - } - } - if ($s->{in_name}) { - if (/^\.Nm\s+(\S+)/o) { - $s->{names}{$1.$s->{sec}} = 1; - } - } - my $destruct = $_; - if ($s->{mandoc_p}) { - $destruct =~ s/\\\&([\w\.])/$1/o; - if ($destruct =~ /^\.Xr\s+([\w\:\.\-\+\/]+)\s+($esections_re)(.*)/o) { - $s->debug("Xref to $1($2) found: `$_'"); - $s->verify_xref($1, $2, "", ""); - if ($3 =~ /^\S/o) { - $s->warning("No space after section number in Xref: `$_'") if $opt_x; - } - } elsif ($destruct =~ /^\.Xr/o) { - $s->warning("Weird Xref found: `$_'") if $opt_x; - } - } else { - $destruct =~ s/\\f.//go; - if ($destruct !~ /^\.\\\"/o) { - while ($destruct =~ s/([-\w.]+)\s*\(($esections_re)\)//o) { - $s->debug("possible Xref to $1($2) found: `$_'"); - $s->verify_xref($1, $2, "possible ", ": `$_'"); - # so that we have a chance to find more than one - # per line - $destruct =~ s/(\w+)\s*\(($sections_re)\)//o; - } - } - } - return "$_\n"; -} - -package main; - -sub handle_file -{ - my $parser = Parser->new($_[0]); - - while ($_ = $parser->next_line) { - $parser->process_and_save_line($_); - } - $parser->close; - if ($Parser::opt_F and $parser->{changes}) { - open OUT, ">$_[0].new" or - die "can't open output file `$_[0].new'"; - for my $l (@{$parser->{all}}) { - print OUT $l - } - close OUT; - system("mv -i $_[0].new $_[0]"); - } -} - -Parser->handle_options; -foreach my $file (@ARGV) { - handle_file($file); -} diff --git a/regress/usr.bin/mdoclint/mdoclint.1 b/regress/usr.bin/mdoclint/mdoclint.1 deleted file mode 100644 index 80001a93c73..00000000000 --- a/regress/usr.bin/mdoclint/mdoclint.1 +++ /dev/null @@ -1,93 +0,0 @@ -.\" $OpenBSD: mdoclint.1,v 1.32 2017/07/01 13:17:09 schwarze Exp $ -.\" $NetBSD: mdoclint.1,v 1.23 2017/06/08 10:19:56 wiz Exp $ -.\" -.\" Copyright (c) 2001-2013 Thomas Klausner -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR, THOMAS KLAUSNER, -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd $Mdocdate: July 1 2017 $ -.Dt MDOCLINT 1 -.Os -.Sh NAME -.Nm mdoclint -.Nd man page verifier -.Sh SYNOPSIS -.Nm -.Op Fl Fhmvx -.Ar -.Sh DESCRIPTION -.Nm -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 mx -is assumed (that is, everything except -.Fl Fhv ) . -.Pp -The options are as follows: -.Bl -tag -width Ds -.It Fl F -Delete whitespace at the end of input lines. -.It Fl h -Display usage. -.It Fl m -Warn if man page is not in -.Xr mdoc 7 -format. -.It Fl v -Verbose output. -.It Fl x -Warn about cross-references whose target is missing, cross-references -to itself, or plain bogus cross-references. -.Pp -For -.Dq .Xr name X , -the following files are checked: -.Pa /usr/share/man/manX/name.X , -.Pa /usr/share/man/manX/`uname -m`/name.X , -.Pa ./name.X , -and -.Pa /usr/X11R6/man/manX/name.X . -.El -.Sh SEE ALSO -.Xr mdoc 7 -.Sh HISTORY -The -.Nm -utility first appeared in -.Ox 4.5 . -.Sh AUTHORS -.An Thomas Klausner -.Aq Mt wiz@NetBSD.org -.An Marc Espie -.Aq Mt espie@OpenBSD.org -.An Ingo Schwarze -.Aq Mt schwarze@OpenBSD.org -.Sh BUGS -The -.Fl x -flag sometimes erroneously warns about xrefs to man pages for -machine-dependent drivers that are not for the architecture -.Nm -is running on. |