diff options
author | Seonah Moon <seonah1.moon@samsung.com> | 2016-09-23 13:49:53 +0900 |
---|---|---|
committer | Seonah Moon <seonah1.moon@samsung.com> | 2016-09-23 13:50:15 +0900 |
commit | 3e62527ed71a7a362d7ec321e7f026edab35f8e2 (patch) | |
tree | 7f3b26146600554e22d60afbe69035821056f299 /tests/nroff-scan.pl | |
parent | 0a710b32648c435f792f5993fdefa2d96f802580 (diff) | |
download | curl-3e62527ed71a7a362d7ec321e7f026edab35f8e2.tar.gz curl-3e62527ed71a7a362d7ec321e7f026edab35f8e2.tar.bz2 curl-3e62527ed71a7a362d7ec321e7f026edab35f8e2.zip |
Imported Upstream version 7.50.2upstream/7.50.2
Change-Id: I91c6040940a21b2bebab9d6cab11d50767b7bac4
Diffstat (limited to 'tests/nroff-scan.pl')
-rw-r--r-- | tests/nroff-scan.pl | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/tests/nroff-scan.pl b/tests/nroff-scan.pl new file mode 100644 index 000000000..393068cd3 --- /dev/null +++ b/tests/nroff-scan.pl @@ -0,0 +1,104 @@ +#!/usr/bin/env perl +#*************************************************************************** +# _ _ ____ _ +# Project ___| | | | _ \| | +# / __| | | | |_) | | +# | (__| |_| | _ <| |___ +# \___|\___/|_| \_\_____| +# +# Copyright (C) 2016, Daniel Stenberg, <daniel@haxx.se>, et al. +# +# This software is licensed as described in the file COPYING, which +# you should have received as part of this distribution. The terms +# are also available at https://curl.haxx.se/docs/copyright.html. +# +# You may opt to use, copy, modify, merge, publish, distribute and/or sell +# copies of the Software, and permit persons to whom the Software is +# furnished to do so, under the terms of the COPYING file. +# +# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY +# KIND, either express or implied. +# +########################################################################### +# +# scan nroff pages to find basic syntactic problems such as unbalanced \f +# codes or references to non-existing curl man pages. + +my $docsroot = $ARGV[0]; + +if(!$docsroot || ($docsroot eq "-g")) { + print "Usage: nroff-scan.pl <docs root dir> [nroff files]\n"; + exit; +} + + +shift @ARGV; + +my @f = @ARGV; + +my %manp; + +sub manpresent { + my ($man) = @_; + if($manp{$man}) { + return 1; + } + elsif(-r "$docsroot/$man" || + -r "$docsroot/libcurl/$man" || + -r "$docsroot/libcurl/opts/$man") { + $manp{$man}=1; + return 1; + } + return 0; +} + +sub file { + my ($f) = @_; + open(F, "<$f") || + die "no file"; + my $line = 1; + while(<F>) { + chomp; + my $l = $_; + while($l =~ s/\\f(.)([^ ]*)\\f(.)//) { + my ($pre, $str, $post)=($1, $2, $3); + if($post ne "P") { + print STDERR "error: $f:$line: missing \\fP after $str\n"; + $errors++; + } + if($str =~ /((libcurl|curl)([^ ]*))\(3\)/i) { + my $man = "$1.3"; + if(!manpresent($man)) { + print STDERR "error: $f:$line: refering to non-existing man page $man\n"; + $errors++; + } + if($pre ne "I") { + print STDERR "error: $f:$line: use \\fI before $str\n"; + $errors++; + } + } + } + if($l =~ /(curl([^ ]*)\(3\))/i) { + print STDERR "error: $f:$line: non-referencing $1\n"; + $errors++; + } + if($l =~ /^\.BR (.*)/) { + my $i= $1; + while($i =~ s/((lib|)curl([^ ]*)) *\"\(3\)(,|) *\" *//i ) { + my $man = "$1.3"; + if(!manpresent($man)) { + print STDERR "error: $f:$line: refering to non-existing man page $man\n"; + $errors++; + } + } + } + $line++; + } + close(F); +} + +foreach my $f (@f) { + file($f); +} + +exit $errors?1:0; |