2 #***************************************************************************
4 # Project ___| | | | _ \| |
6 # | (__| |_| | _ <| |___
7 # \___|\___/|_| \_\_____|
9 # Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
11 # This software is licensed as described in the file COPYING, which
12 # you should have received as part of this distribution. The terms
13 # are also available at https://curl.se/docs/copyright.html.
15 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
16 # copies of the Software, and permit persons to whom the Software is
17 # furnished to do so, under the terms of the COPYING file.
19 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 # KIND, either express or implied.
22 # SPDX-License-Identifier: curl
24 ###########################################################################
26 # scan nroff pages to find basic syntactic problems such as unbalanced \f
27 # codes or references to non-existing curl man pages.
29 my $docsroot = $ARGV[0];
31 if(!$docsroot || ($docsroot eq "-g")) {
32 print "Usage: nroff-scan.pl <docs root dir> [nroff files]\n";
48 elsif(-r "$docsroot/$man" ||
49 -r "$docsroot/libcurl/$man" ||
50 -r "$docsroot/libcurl/opts/$man") {
59 open(my $fh, "<", "$f") ||
65 while($l =~ s/\\f(.)([^ ]*)\\f(.)//) {
66 my ($pre, $str, $post)=($1, $2, $3);
67 if($str =~ /^\\f[ib]/i) {
68 print "error: $f:$line: double-highlight\n";
72 print "error: $f:$line: missing \\fP after $str\n";
75 if($str =~ /((libcurl|curl)([^ ]*))\(3\)/i) {
77 if(!manpresent($man)) {
78 print "error: $f:$line: referring to non-existing man page $man\n";
82 print "error: $f:$line: use \\fI before $str\n";
87 if($l =~ /(curl([^ ]*)\(3\))/i) {
88 print "error: $f:$line: non-referencing $1\n";
91 if($l =~ /^\.BR (.*)/) {
93 while($i =~ s/((lib|)curl([^ ]*)) *\"\(3\)(,|) *\" *//i ) {
95 if(!manpresent($man)) {
96 print "error: $f:$line: referring to non-existing man page $man\n";
110 print "OK\n" if(!$errors);