pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/textproc/mdoclint Update to 1.2:



details:   https://anonhg.NetBSD.org/pkgsrc/rev/dcfbcba2fe88
branches:  trunk
changeset: 557358:dcfbcba2fe88
user:      wiz <wiz%pkgsrc.org@localhost>
date:      Mon Apr 13 22:18:13 2009 +0000

description:
Update to 1.2:
Fix -F; add -w to show section in warnings, default off (was new in
1.1 with default on).

Functional diff provided by Marc Espie, man page by Jason McIntyre.

diffstat:

 textproc/mdoclint/Makefile         |    5 +-
 textproc/mdoclint/files/mdoclint   |  364 ++++++++++++++++++------------------
 textproc/mdoclint/files/mdoclint.1 |   18 +-
 3 files changed, 200 insertions(+), 187 deletions(-)

diffs (truncated from 632 to 300 lines):

diff -r 603d195de95e -r dcfbcba2fe88 textproc/mdoclint/Makefile
--- a/textproc/mdoclint/Makefile        Mon Apr 13 21:58:26 2009 +0000
+++ b/textproc/mdoclint/Makefile        Mon Apr 13 22:18:13 2009 +0000
@@ -1,7 +1,6 @@
-# $NetBSD: Makefile,v 1.6 2009/04/09 00:48:17 joerg Exp $
+# $NetBSD: Makefile,v 1.7 2009/04/13 22:18:13 wiz Exp $
 
-DISTNAME=      mdoclint-1.1
-PKGREVISION=   1
+DISTNAME=      mdoclint-1.2
 CATEGORIES=    textproc
 MASTER_SITES=  # none
 DISTFILES=     # none
diff -r 603d195de95e -r dcfbcba2fe88 textproc/mdoclint/files/mdoclint
--- a/textproc/mdoclint/files/mdoclint  Mon Apr 13 21:58:26 2009 +0000
+++ b/textproc/mdoclint/files/mdoclint  Mon Apr 13 22:18:13 2009 +0000
@@ -1,7 +1,7 @@
 #!@PERL5@
 #
-# $OpenBSD: mdoclint,v 1.13 2008/12/31 10:55:11 espie Exp $
-# $NetBSD: mdoclint,v 1.2 2009/03/02 10:24:54 wiz Exp $
+# $OpenBSD: mdoclint,v 1.14 2009/04/13 12:40:05 espie Exp $
+# $NetBSD: mdoclint,v 1.3 2009/04/13 22:18:13 wiz Exp $
 #
 # Copyright (c) 2001-2009 Thomas Klausner
 # All rights reserved.
@@ -43,14 +43,14 @@
 
 use vars qw(
        $opt_a $opt_D $opt_d $opt_e $opt_F $opt_f $opt_H $opt_h $opt_m
-       $opt_n $opt_o $opt_P $opt_p $opt_r $opt_S $opt_s $opt_v
+       $opt_n $opt_o $opt_P $opt_p $opt_r $opt_S $opt_s $opt_v $opt_w
        $opt_X $opt_x
 );
 
 
 my $arch=`uname -m`;
 chomp($arch);
-my $options="aDdeFfHhmnoPprSsvXx";
+my $options="aDdeFfHhmnoPprSsvwXx";
 
 sub usage
        {
@@ -76,6 +76,7 @@
        -S      warn about any .Sh weirdness
        -s      warn about whitespace problems
        -v      verbose output
+       -w      show section header in warnings
        -X      warn about explicit mentions of FreeBSD, NetBSD, or OpenBSD
        -x      warn about cross-references with missing targets
 Default is $default if no flag is specified.
@@ -170,7 +171,11 @@
 sub warning
 {
        my $self = shift;
-       print STDOUT "$self->{fn}:$self->{current_section_header}:$self->{ln}: ", join('', @_), "\n";
+       my $extra = "";
+       if ($opt_w) {
+               $extra = $self->{current_section_header}.":";
+       }
+       print STDOUT "$self->{fn}:$extra$self->{ln}: ", join('', @_), "\n";
 }
 
 sub handle_options
@@ -194,7 +199,7 @@
 {
        my ($self, $page, $section, $pre, $post) = @_;
        if ("$page.$section" eq $self->{fn}) {
-               $self->warning("Xref to itself (use .Nm instead)");
+               $self->warning("Xref to itself (use .Nm instead)") if $opt_x;
        }
        # try to find corresponding man page
        for my $dir ("/usr/share/man",
@@ -208,7 +213,7 @@
        }
        return 1 if -f "./$page.$section";
 
-       $self->warning($pre."trailing Xref to $page($section)$post");
+       $self->warning($pre."trailing Xref to $page($section)$post") if $opt_x;
        return 0;
 }
 
@@ -218,7 +223,7 @@
 
        my $o = {
                mandoc_p => 1,
-               all => '',
+               all => [],
                lastline => '',
                changes => 0,
                oxrcsidseen => 0,
@@ -280,38 +285,52 @@
 {
        my ($s, $section_header) = @_;
        $section_header = join(' ', $s->parse_macro_args($section_header));
+
        if ($section_header eq 'SEE ALSO') {
-                   $s->{insa} = 1;
+               $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;
+               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;
        }
-       if ($opt_S) {
-               if (not $sections{$section_header}) {
-                       $s->warning("unknown section header: ",
-                           "`$section_header'");
-               } else {
-                       if ($s->{lastsh} >= $sections{$section_header}) {
-                               $s->warning("section header ",
-                                   "`$section_header' in wrong order");
-                       }
-                       $s->{shseen}->{$section_header} = 1;
-                       $s->{lastsh} = $sections{$section_header};
+
+       if (not $sections{$section_header}) {
+               $s->warning("unknown section header: ",
+                   "`$section_header'") if $opt_S;
+       } else {
+               if ($s->{lastsh} >= $sections{$section_header}) {
+                       $s->warning("section header ",
+                           "`$section_header' in wrong order") if $opt_S;
                }
+               $s->{shseen}->{$section_header} = 1;
+               $s->{lastsh} = $sections{$section_header};
        }
+
        if ($s->{lastline} =~ /^\.Pp/o) {
-               $s->warning("Paragraph problem: section header after .Pp");
+               $s->warning("Paragraph problem: section header after .Pp") 
+                   if $opt_P;
        }
 
        $s->{current_section_header} = $section_header;
 }
 
+sub process_and_save_line
+{
+       my ($s, $_) = @_;
+       my $result = $s->process_line($_);
+       # note that process_line chomps \n, then re-adds it,
+       # so we detect a change on last lines without a \n.
+       if ($result ne $_) {
+               $s->{changes} = 1;
+       }
+       push(@{$s->{all}}, $result);
+}
+
 sub process_line
 {
        my ($s, $_) = @_;
@@ -320,215 +339,201 @@
        if (/\s+$/o) {
                $s->warning("trailing space: `$_'") if $opt_s;
                s/\s+$//o;
-               $s->{changes} = 1;
        }
        if (/\$OpenBSD\b.*\$/o) {
                $s->{oxrcsidseen} = 1;
                # nothing else to do
-               return;
+               return "$_\n";
        }
        if (/\$NetBSD\b.*\$/o) {
                $s->{nxrcsidseen} = 1;
                # nothing else to do
-               return;
+               return "$_\n";
        }
        # comments
        if (/^\.\\\"/) {
-               return;
+               return "$_\n";
        }
        if (/^\.TH\s+/o) {
                $s->warning("not mandoc") if $opt_m;
                $s->{mandoc_p} = 0;
 #              /^.TH\s*[\w-_".]+\s*([1-9])/;
 #              $section = $1;
-               return;
+               return "$_\n";
        }
 #      if (/^.Dt\s*[\w-_".]+\s*([1-9])/) {
 #              $section = $1;
 #      }
-       if ($opt_D and /^\.Dt\s+/o) {
+       if (/^\.Dt\s+/o) {
            if (! /^\.Dt\s+(?:[A-Z\d._-]+)\s+$sections_re(?:\s+$arches_re)?$/o)  {
-               $s->warning("bad .Dt: `$_'");
+                   $s->warning("bad .Dt: `$_'") if $opt_D;
            }
        }
 
        if ($s->{mandoc_p}) {
                if (/^\.Sh\s+(.*)$/o) {
                        $s->set_section_header($1);
-                       return;
+                       return "$_\n";
                }
        } else {
                if (/^\.SH\s+(.*)$/o) {
                        $s->set_section_header($1);
-                       return;
+                       return "$_\n";
                }
        }
 
-       if ($opt_a) {
-           if ($s->{insa} == 1) {
+       if ($s->{insa} == 1) {
                if (/^\.Xr\s+(\S+)\s+($sections_re)\s?(.*)?$/o) {
-                   my ($saname, $sasection, $sarest) = ($1, $2, $3);
-                   $saname =~ s/^\\&//o;
-                   if ($s->{sasection} gt $sasection
-                       or ($s->{sasection} eq $sasection and
-                           ($s->{saname} cmp $saname) > 0)) {
-                       $s->warning("SEE ALSO: `.Xr $s->{saname} $s->{sasection}' should "
-                               . "be after `.Xr $saname $sasection'");
-                   }
-                   if ($s->{sarest} ne ",") {
-                       $s->warning("SEE ALSO: .Xr not separated by ".
-                               "comma, but `$s->{sarest}'");
-                   }
-                   $s->{saname} = $saname;
-                   $s->{sasection} = $sasection;
-                   $s->{sarest} = $sarest;
+                       my ($saname, $sasection, $sarest) = ($1, $2, $3);
+                       $saname =~ s/^\\&//o;
+                       if ($s->{sasection} gt $sasection
+                           or ($s->{sasection} eq $sasection and
+                           (lc($s->{saname}) gt lc($saname)))) {
+                               $s->warning("SEE ALSO: `.Xr $s->{saname} ",
+                                   "$s->{sasection}' should be after ",
+                                   "`.Xr $saname $sasection'") if $opt_a;
+                       }
+                       if ($s->{sarest} ne ",") {
+                               $s->warning("SEE ALSO: .Xr not separated ",
+                                   "by comma, but `$s->{sarest}'") if $opt_a;
+                       }
+                       $s->{saname} = $saname;
+                       $s->{sasection} = $sasection;
+                       $s->{sarest} = $sarest;
                }
                if (/^\.Rs(?:\s+|$)/o) {
-                   if ($s->{sarest} ne "") {
-                       $s->warning("SEE ALSO: Not necessary to separate".
-                               " .Xr from .Rs by `$s->{sarest}'");
-                   }
-                   $s->{sarest} = "";
+                       if ($s->{sarest} ne "") {
+                               $s->warning("SEE ALSO: Not necessary to ",
+                                   "separate .Xr from .Rs by ",
+                                   "`$s->{sarest}'") if $opt_a;
+                       }
+                       $s->{sarest} = "";
                }
-           }
        }
 
-       if ($opt_f and /^\.Fn.*,.+/o) {
-               $s->warning("possible .Fn misuse: `$_'");
+       if (/^\.Fn.*,.+/o) {
+               $s->warning("possible .Fn misuse: `$_'") if $opt_f;
        }
        if (OPENBSD) {
-               if ($opt_H and (/^(?:[<>])/o or /[^\\][<>]/o)) {
+               if (/^(?:[<>])/o or /[^\\][<>]/o) {
                        $s->warning("use \*(Lt \*(Gt (or .Aq) ",
-                           "instead of < >: `$_'");
+                           "instead of < >: `$_'") if $opt_H;
                }
        }
        if (NETBSD) {
-               if ($opt_H and (/^(?:[<>&])/o or /[^\\][<>&]/o)) {
+               if (/^(?:[<>&])/o or /[^\\][<>&]/o) {
                        $s->warning("use \*[Lt] \*[Gt] (or .Aq) \*[Am] ",
-                           "instead of < > &: `$_'");
-               }
-       }
-
-       if ($opt_X) {
-               if (/\b(Free|Net|Open)BSD\b/o
-                   and not /\b(?:www|ftp)\.(?:Free|Net|Open)BSD\.org\b/o
-                   and not /\bOpenBSD\::.*3p\b/o
-                   and not /\/pub\/OpenBSD\//o
-                   and not /\@(?:Free|Net|Open)BSD\.(?i:org)\b/o) {



Home | Main Index | Thread Index | Old Index