Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/pkg
Path: blob/main/external/curl/tests/test1140.pl
2650 views
1
#!/usr/bin/env perl
2
#***************************************************************************
3
# _ _ ____ _
4
# Project ___| | | | _ \| |
5
# / __| | | | |_) | |
6
# | (__| |_| | _ <| |___
7
# \___|\___/|_| \_\_____|
8
#
9
# Copyright (C) Daniel Stenberg, <[email protected]>, et al.
10
#
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.
14
#
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.
18
#
19
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20
# KIND, either express or implied.
21
#
22
# SPDX-License-Identifier: curl
23
#
24
###########################################################################
25
#
26
# scan manpages to find basic syntactic problems such as unbalanced \f
27
# codes or references to non-existing curl manpages.
28
29
use strict;
30
use warnings;
31
32
my $docsroot = $ARGV[0] || '.';
33
34
if(!$docsroot || ($docsroot eq "-g")) {
35
print "Usage: test1140.pl <docs root dir> [manpages]\n";
36
exit;
37
}
38
39
40
shift @ARGV;
41
42
my @f = @ARGV;
43
44
my %manp;
45
46
my $errors = 0;
47
48
sub manpresent {
49
my ($man) = @_;
50
if($manp{$man}) {
51
return 1;
52
}
53
elsif(-r "$docsroot/$man" ||
54
-r "$docsroot/libcurl/$man" ||
55
-r "$docsroot/libcurl/opts/$man") {
56
$manp{$man}=1;
57
return 1;
58
}
59
return 0;
60
}
61
62
sub file {
63
my ($f) = @_;
64
open(my $fh, "<", "$f") ||
65
die "test1140.pl could not open $f";
66
my $line = 1;
67
while(<$fh>) {
68
chomp;
69
my $l = $_;
70
while($l =~ s/\\f(.)([^ ]*)\\f(.)//) {
71
my ($pre, $str, $post)=($1, $2, $3);
72
if($str =~ /^\\f[ib]/i) {
73
print "error: $f:$line: double-highlight\n";
74
$errors++;
75
}
76
if($post ne "P") {
77
print "error: $f:$line: missing \\fP after $str\n";
78
$errors++;
79
}
80
if($str =~ /((libcurl|curl)([^ ]*))\(3\)/i) {
81
my $man = "$1.3";
82
$man =~ s/\\//g; # cut off backslashes
83
if(!manpresent($man)) {
84
print "error: $f:$line: referring to non-existing manpage $man\n";
85
$errors++;
86
}
87
if($pre ne "I") {
88
print "error: $f:$line: use \\fI before $str\n";
89
$errors++;
90
}
91
}
92
}
93
if($l =~ /(curl([^ ]*)\(3\))/i) {
94
print "error: $f:$line: non-referencing $1\n";
95
$errors++;
96
}
97
if($l =~ /^\.BR (.*)/) {
98
my $i= $1;
99
while($i =~ s/((lib|)curl([^ ]*)) *\"\(3\)(,|) *\" *//i ) {
100
my $man = "$1.3";
101
$man =~ s/\\//g; # cut off backslashes
102
if(!manpresent($man)) {
103
print "error: $f:$line: referring to non-existing manpage $man\n";
104
$errors++;
105
}
106
}
107
}
108
$line++;
109
}
110
close($fh);
111
}
112
113
foreach my $f (@f) {
114
file($f);
115
}
116
117
print "OK\n" if(!$errors);
118
119
exit ($errors ? 1 : 0);
120
121