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 symbols-in-version (which is verified to be correct by test 1119), then
27 # verify that each option mention in there that should have its own man page
30 # In addition, make sure that every current option to curl_easy_setopt,
31 # curl_easy_getinfo and curl_multi_setopt are also mentioned in their
32 # corresponding main (index) man page.
34 # src/tool_getparam.c lists all options curl can parse
35 # docs/curl.1 documents all command line options
36 # src/tool_listhelp.c outputs all options with curl -h
37 # - make sure they're all in sync
39 # Output all deviances to stderr.
44 # we may get the dir roots pointed out
45 my $root=$ARGV[0] || ".";
46 my $buildroot=$ARGV[1] || ".";
47 my $syms = "$root/docs/libcurl/symbols-in-versions";
48 my $curlh = "$root/include/curl/curl.h";
51 # the prepopulated alias list is the CURLINFO_* defines that are used for the
52 # debug function callback and the fact that they use the same prefix as the
53 # curl_easy_getinfo options was a mistake.
55 'CURLINFO_DATA_IN' => 'none',
56 'CURLINFO_DATA_OUT' => 'none',
57 'CURLINFO_END' => 'none',
58 'CURLINFO_HEADER_IN' => 'none',
59 'CURLINFO_HEADER_OUT' => 'none',
60 'CURLINFO_LASTONE' => 'none',
61 'CURLINFO_NONE' => 'none',
62 'CURLINFO_SSL_DATA_IN' => 'none',
63 'CURLINFO_SSL_DATA_OUT' => 'none',
64 'CURLINFO_TEXT' => 'none'
68 my ($file, @words) = @_;
70 open(my $mh, "<", "$file");
73 if($_ =~ /^\.IP (.*)/) {
82 foreach my $m (@words) {
83 my @g = grep(/$m/, @m);
85 print STDERR "Missing mention of $m in $file\n";
93 # check for define aliases
94 open($r, "<", "$curlh") ||
97 if(/^\#define (CURL(OPT|INFO|MOPT)_\w+) (.*)/) {
106 open($r, "<", "$syms") ||
111 if($l =~ /(CURL(OPT|INFO|MOPT)_\w+) *([0-9.]*) *([0-9.-]*) *([0-9.]*)/) {
112 my ($opt, $type, $add, $dep, $rem) = ($1, $2, $3, $4, $5);
115 #print "$opt => $alias{$opt}\n";
118 # $opt was removed in $rem
119 # so don't check for that
125 elsif($type eq "INFO") {
126 push @curlinfo, $opt,
128 elsif($type eq "MOPT") {
129 push @curlmopt, $opt,
131 if(! -f "$root/docs/libcurl/opts/$opt.3") {
132 print STDERR "Missing $opt.3\n";
140 scanmanpage("$root/docs/libcurl/curl_easy_setopt.3", @curlopt);
141 scanmanpage("$root/docs/libcurl/curl_easy_getinfo.3", @curlinfo);
142 scanmanpage("$root/docs/libcurl/curl_multi_setopt.3", @curlmopt);
144 # using this hash array, we can skip specific options
146 # pretend these --no options exists in tool_getparam.c
149 '-N, --no-buffer' => 1,
150 '--no-sessionid' => 1,
151 '--no-keepalive' => 1,
152 '--no-progress-meter' => 1,
155 # pretend these options without -no exist in curl.1 and tool_listhelp.c
163 '--progress-meter' => 6,
166 # deprecated options do not need to be in tool_help.c nor curl.1
169 '--ftp-ssl-reqd' => 6,
171 # for tests and debug only, can remain hidden
177 #########################################################################
178 # parse the curl code that parses the command line arguments!
179 open($r, "<", "$root/src/tool_getparam.c") ||
182 my @getparam; # store all parsed parameters
187 if(/struct LongShort aliases/) {
191 if( /^ \{([^,]*), *([^ ]*)/) {
192 my ($s, $l)=($1, $2);
196 if($l =~ /\"(.*)\"/) {
201 if($s =~ /\"(.)\"/) {
204 $title="-$sh, $title";
206 push @getparam, $title;
213 #########################################################################
214 # parse the curl.1 man page, extract all documented command line options
215 # The man page may or may not be rebuilt, so check both possible locations
216 open($r, "<", "$buildroot/docs/curl.1") || open($r, "<", "$root/docs/curl.1") ||
218 my @manpage; # store all parsed parameters
223 if($l =~ /^\.IP \"(-[^\"]*)\"/) {
226 if($str =~ /^-(.), --([a-z0-9.-]*)/) {
227 # figure out the -short, --long combo
228 $combo = "-$1, --$2";
230 elsif($str =~ /^--([a-z0-9.-]*)/) {
231 # figure out the --long name
235 push @manpage, $combo;
243 #########################################################################
244 # parse the curl code that outputs the curl -h list
245 open($r, "<", "$root/src/tool_listhelp.c") ||
247 my @toolhelp; # store all parsed parameters
254 if($str =~ /^-(.), --([a-z0-9.-]*)/) {
255 # figure out the -short, --long combo
256 $combo = "-$1, --$2";
258 elsif($str =~ /^--([a-z0-9.-]*)/) {
259 # figure out the --long name
263 push @toolhelp, $combo;
272 # Now we have three arrays with options to cross-reference.
274 foreach my $o (keys %opts) {
275 my $where = $opts{$o};
278 # this is not in all three places
283 $exists=" tool_getparam.c";
286 $missing=" tool_getparam.c";
292 $missing.= " curl.1";
295 $exists .= " tool_listhelp.c";
298 $missing .= " tool_listhelp.c";
301 print STDERR "$o is not in$missing (but in$exists)\n";
305 print STDERR "$errors\n";