find-doc-nits revision 1.1.1.6 1 1.1 christos #! /usr/bin/env perl
2 1.1.1.6 christos # Copyright 2002-2021 The OpenSSL Project Authors. All Rights Reserved.
3 1.1 christos #
4 1.1.1.6 christos # Licensed under the Apache License 2.0 (the "License"). You may not use
5 1.1 christos # this file except in compliance with the License. You can obtain a copy
6 1.1 christos # in the file LICENSE in the source distribution or at
7 1.1 christos # https://www.openssl.org/source/license.html
8 1.1 christos
9 1.1 christos
10 1.1 christos require 5.10.0;
11 1.1 christos use warnings;
12 1.1 christos use strict;
13 1.1.1.6 christos
14 1.1.1.6 christos use Carp qw(:DEFAULT cluck);
15 1.1 christos use Pod::Checker;
16 1.1 christos use File::Find;
17 1.1 christos use File::Basename;
18 1.1 christos use File::Spec::Functions;
19 1.1 christos use Getopt::Std;
20 1.1.1.6 christos use FindBin;
21 1.1.1.6 christos use lib "$FindBin::Bin/perl";
22 1.1.1.6 christos
23 1.1 christos use OpenSSL::Util::Pod;
24 1.1 christos
25 1.1.1.6 christos use lib '.';
26 1.1.1.6 christos use configdata;
27 1.1.1.6 christos
28 1.1.1.6 christos # Set to 1 for debug output
29 1.1.1.6 christos my $debug = 0;
30 1.1.1.6 christos
31 1.1 christos # Options.
32 1.1 christos our($opt_d);
33 1.1.1.6 christos our($opt_e);
34 1.1.1.6 christos our($opt_s);
35 1.1.1.6 christos our($opt_o);
36 1.1 christos our($opt_h);
37 1.1 christos our($opt_l);
38 1.1.1.6 christos our($opt_m);
39 1.1 christos our($opt_n);
40 1.1 christos our($opt_p);
41 1.1 christos our($opt_u);
42 1.1.1.6 christos our($opt_v);
43 1.1 christos our($opt_c);
44 1.1 christos
45 1.1.1.6 christos # Print usage message and exit.
46 1.1.1.6 christos sub help {
47 1.1 christos print <<EOF;
48 1.1 christos Find small errors (nits) in documentation. Options:
49 1.1.1.6 christos -c List undocumented commands, undocumented options and unimplemented options.
50 1.1 christos -d Detailed list of undocumented (implies -u)
51 1.1.1.6 christos -e Detailed list of new undocumented (implies -v)
52 1.1.1.6 christos -h Print this help message
53 1.1 christos -l Print bogus links
54 1.1.1.6 christos -m Name(s) of manuals to focus on. Default: man1,man3,man5,man7
55 1.1 christos -n Print nits in POD pages
56 1.1.1.6 christos -o Causes -e/-v to count symbols added since 1.1.1 as new (implies -v)
57 1.1.1.5 christos -u Count undocumented functions
58 1.1.1.6 christos -v Count new undocumented functions
59 1.1 christos EOF
60 1.1 christos exit;
61 1.1 christos }
62 1.1 christos
63 1.1.1.6 christos getopts('cdehlm:nouv');
64 1.1.1.6 christos
65 1.1.1.6 christos help() if $opt_h;
66 1.1.1.6 christos $opt_u = 1 if $opt_d;
67 1.1.1.6 christos $opt_v = 1 if $opt_o || $opt_e;
68 1.1.1.6 christos die "Cannot use both -u and -v"
69 1.1.1.6 christos if $opt_u && $opt_v;
70 1.1.1.6 christos die "Cannot use both -d and -e"
71 1.1.1.6 christos if $opt_d && $opt_e;
72 1.1.1.6 christos
73 1.1.1.6 christos # We only need to check c, l, n, u and v.
74 1.1.1.6 christos # Options d, e, o imply one of the above.
75 1.1.1.6 christos die "Need one of -[cdehlnouv] flags.\n"
76 1.1.1.6 christos unless $opt_c or $opt_l or $opt_n or $opt_u or $opt_v;
77 1.1.1.6 christos
78 1.1.1.6 christos
79 1.1 christos my $temp = '/tmp/docnits.txt';
80 1.1 christos my $OUT;
81 1.1.1.6 christos my $status = 0;
82 1.1.1.6 christos
83 1.1.1.6 christos $opt_m = "man1,man3,man5,man7" unless $opt_m;
84 1.1.1.6 christos die "Argument of -m option may contain only man1, man3, man5, and/or man7"
85 1.1.1.6 christos unless $opt_m =~ /^(man[1357][, ]?)*$/;
86 1.1.1.6 christos my @sections = ( split /[, ]/, $opt_m );
87 1.1.1.6 christos
88 1.1.1.6 christos my %mandatory_sections = (
89 1.1.1.6 christos '*' => [ 'NAME', 'DESCRIPTION', 'COPYRIGHT' ],
90 1.1.1.6 christos 1 => [ 'SYNOPSIS', 'OPTIONS' ],
91 1.1.1.6 christos 3 => [ 'SYNOPSIS', 'RETURN VALUES' ],
92 1.1.1.6 christos 5 => [ ],
93 1.1.1.6 christos 7 => [ ]
94 1.1.1.6 christos );
95 1.1.1.6 christos
96 1.1.1.6 christos # Symbols that we ignored.
97 1.1.1.6 christos # They are reserved macros that we currently don't document
98 1.1.1.6 christos my $ignored = qr/(?| ^i2d_
99 1.1.1.6 christos | ^d2i_
100 1.1.1.6 christos | ^DEPRECATEDIN
101 1.1.1.6 christos | ^OSSL_DEPRECATED
102 1.1.1.6 christos | \Q_fnsig(3)\E$
103 1.1.1.6 christos | ^IMPLEMENT_
104 1.1.1.6 christos | ^_?DECLARE_
105 1.1.1.6 christos | ^sk_
106 1.1.1.6 christos | ^SKM_DEFINE_STACK_OF_INTERNAL
107 1.1.1.6 christos | ^lh_
108 1.1.1.6 christos | ^DEFINE_LHASH_OF_INTERNAL
109 1.1.1.6 christos )/x;
110 1.1.1.6 christos
111 1.1.1.6 christos # A common regexp for C symbol names
112 1.1.1.6 christos my $C_symbol = qr/\b[[:alpha:]][_[:alnum:]]*\b/;
113 1.1.1.6 christos
114 1.1.1.6 christos # Collect all POD files, both internal and public, and regardless of location
115 1.1.1.6 christos # We collect them in a hash table with each file being a key, so we can attach
116 1.1.1.6 christos # tags to them. For example, internal docs will have the word "internal"
117 1.1.1.6 christos # attached to them.
118 1.1.1.6 christos my %files = ();
119 1.1.1.6 christos # We collect files names on the fly, on known tag basis
120 1.1.1.6 christos my %collected_tags = ();
121 1.1.1.6 christos # We cache results based on tags
122 1.1.1.6 christos my %collected_results = ();
123 1.1.1.6 christos
124 1.1.1.6 christos # files OPTIONS
125 1.1.1.6 christos #
126 1.1.1.6 christos # Example:
127 1.1.1.6 christos #
128 1.1.1.6 christos # files(TAGS => 'manual');
129 1.1.1.6 christos # files(TAGS => [ 'manual', 'man1' ]);
130 1.1.1.6 christos #
131 1.1.1.6 christos # This function returns an array of files corresponding to a set of tags
132 1.1.1.6 christos # given with the options "TAGS". The value of this option can be a single
133 1.1.1.6 christos # word, or an array of several words, which work as inclusive or exclusive
134 1.1.1.6 christos # selectors. Inclusive selectors are used to add one more set of files to
135 1.1.1.6 christos # the returned array, while exclusive selectors limit the set of files added
136 1.1.1.6 christos # to the array. The recognised tag values are:
137 1.1.1.6 christos #
138 1.1.1.6 christos # 'public_manual' - inclusive selector, adds public manuals to the
139 1.1.1.6 christos # returned array of files.
140 1.1.1.6 christos # 'internal_manual' - inclusive selector, adds internal manuals to the
141 1.1.1.6 christos # returned array of files.
142 1.1.1.6 christos # 'manual' - inclusive selector, adds any manual to the returned
143 1.1.1.6 christos # array of files. This is really a shorthand for
144 1.1.1.6 christos # 'public_manual' and 'internal_manual' combined.
145 1.1.1.6 christos # 'public_header' - inclusive selector, adds public headers to the
146 1.1.1.6 christos # returned array of files.
147 1.1.1.6 christos # 'header' - inclusive selector, adds any header file to the
148 1.1.1.6 christos # returned array of files. Since we currently only
149 1.1.1.6 christos # care about public headers, this is exactly
150 1.1.1.6 christos # equivalent to 'public_header', but is present for
151 1.1.1.6 christos # consistency.
152 1.1.1.6 christos #
153 1.1.1.6 christos # 'man1', 'man3', 'man5', 'man7'
154 1.1.1.6 christos # - exclusive selectors, only applicable together with
155 1.1.1.6 christos # any of the manual selectors. If any of these are
156 1.1.1.6 christos # present, only the manuals from the given sections
157 1.1.1.6 christos # will be included. If none of these are present,
158 1.1.1.6 christos # the manuals from all sections will be returned.
159 1.1.1.6 christos #
160 1.1.1.6 christos # All returned manual files come from configdata.pm.
161 1.1.1.6 christos # All returned header files come from looking inside
162 1.1.1.6 christos # "$config{sourcedir}/include/openssl"
163 1.1.1.6 christos #
164 1.1.1.6 christos sub files {
165 1.1.1.6 christos my %opts = ( @_ ); # Make a copy of the arguments
166 1.1.1.6 christos
167 1.1.1.6 christos $opts{TAGS} = [ $opts{TAGS} ] if ref($opts{TAGS}) eq '';
168 1.1.1.6 christos
169 1.1.1.6 christos croak "No tags given, or not an array"
170 1.1.1.6 christos unless exists $opts{TAGS} && ref($opts{TAGS}) eq 'ARRAY';
171 1.1.1.6 christos
172 1.1.1.6 christos my %tags = map { $_ => 1 } @{$opts{TAGS}};
173 1.1.1.6 christos $tags{public_manual} = 1
174 1.1.1.6 christos if $tags{manual} && ($tags{public} // !$tags{internal});
175 1.1.1.6 christos $tags{internal_manual} = 1
176 1.1.1.6 christos if $tags{manual} && ($tags{internal} // !$tags{public});
177 1.1.1.6 christos $tags{public_header} = 1
178 1.1.1.6 christos if $tags{header} && ($tags{public} // !$tags{internal});
179 1.1.1.6 christos delete $tags{manual};
180 1.1.1.6 christos delete $tags{header};
181 1.1.1.6 christos delete $tags{public};
182 1.1.1.6 christos delete $tags{internal};
183 1.1.1.6 christos
184 1.1.1.6 christos my $tags_as_key = join(':', sort keys %tags);
185 1.1.1.6 christos
186 1.1.1.6 christos cluck "DEBUG[files]: This is how we got here!" if $debug;
187 1.1.1.6 christos print STDERR "DEBUG[files]: tags: $tags_as_key\n" if $debug;
188 1.1.1.6 christos
189 1.1.1.6 christos my %tags_to_collect = ( map { $_ => 1 }
190 1.1.1.6 christos grep { !exists $collected_tags{$_} }
191 1.1.1.6 christos keys %tags );
192 1.1.1.6 christos
193 1.1.1.6 christos if ($tags_to_collect{public_manual}) {
194 1.1.1.6 christos print STDERR "DEBUG[files]: collecting public manuals\n"
195 1.1.1.6 christos if $debug;
196 1.1.1.6 christos
197 1.1.1.6 christos # The structure in configdata.pm is that $unified_info{mandocs}
198 1.1.1.6 christos # contains lists of man files, and in turn, $unified_info{depends}
199 1.1.1.6 christos # contains hash tables showing which POD file each of those man
200 1.1.1.6 christos # files depend on. We use that information to find the POD files,
201 1.1.1.6 christos # and to attach the man section they belong to as tags
202 1.1.1.6 christos foreach my $mansect ( @sections ) {
203 1.1.1.6 christos foreach ( map { @{$unified_info{depends}->{$_}} }
204 1.1.1.6 christos @{$unified_info{mandocs}->{$mansect}} ) {
205 1.1.1.6 christos $files{$_} = { $mansect => 1, public_manual => 1 };
206 1.1.1.6 christos }
207 1.1.1.6 christos }
208 1.1.1.6 christos $collected_tags{public_manual} = 1;
209 1.1.1.6 christos }
210 1.1.1.6 christos
211 1.1.1.6 christos if ($tags_to_collect{internal_manual}) {
212 1.1.1.6 christos print STDERR "DEBUG[files]: collecting internal manuals\n"
213 1.1.1.6 christos if $debug;
214 1.1.1.6 christos
215 1.1.1.6 christos # We don't have the internal docs in configdata.pm. However, they
216 1.1.1.6 christos # are all in the source tree, so they're easy to find.
217 1.1.1.6 christos foreach my $mansect ( @sections ) {
218 1.1.1.6 christos foreach ( glob(catfile($config{sourcedir},
219 1.1.1.6 christos 'doc', 'internal', $mansect, '*.pod')) ) {
220 1.1.1.6 christos $files{$_} = { $mansect => 1, internal_manual => 1 };
221 1.1.1.6 christos }
222 1.1.1.6 christos }
223 1.1.1.6 christos $collected_tags{internal_manual} = 1;
224 1.1.1.6 christos }
225 1.1.1.6 christos
226 1.1.1.6 christos if ($tags_to_collect{public_header}) {
227 1.1.1.6 christos print STDERR "DEBUG[files]: collecting public headers\n"
228 1.1.1.6 christos if $debug;
229 1.1.1.6 christos
230 1.1.1.6 christos foreach ( glob(catfile($config{sourcedir},
231 1.1.1.6 christos 'include', 'openssl', '*.h')) ) {
232 1.1.1.6 christos $files{$_} = { public_header => 1 };
233 1.1.1.6 christos }
234 1.1.1.6 christos }
235 1.1.1.6 christos
236 1.1.1.6 christos my @result = @{$collected_results{$tags_as_key} // []};
237 1.1.1.6 christos
238 1.1.1.6 christos if (!@result) {
239 1.1.1.6 christos # Produce a result based on caller tags
240 1.1.1.6 christos foreach my $type ( ( 'public_manual', 'internal_manual' ) ) {
241 1.1.1.6 christos next unless $tags{$type};
242 1.1.1.6 christos
243 1.1.1.6 christos # If caller asked for specific sections, we care about sections.
244 1.1.1.6 christos # Otherwise, we give back all of them.
245 1.1.1.6 christos my @selected_sections =
246 1.1.1.6 christos grep { $tags{$_} } @sections;
247 1.1.1.6 christos @selected_sections = @sections unless @selected_sections;
248 1.1.1.6 christos
249 1.1.1.6 christos foreach my $section ( ( @selected_sections ) ) {
250 1.1.1.6 christos push @result,
251 1.1.1.6 christos ( sort { basename($a) cmp basename($b) }
252 1.1.1.6 christos grep { $files{$_}->{$type} && $files{$_}->{$section} }
253 1.1.1.6 christos keys %files );
254 1.1.1.6 christos }
255 1.1.1.6 christos }
256 1.1.1.6 christos if ($tags{public_header}) {
257 1.1.1.6 christos push @result,
258 1.1.1.6 christos ( sort { basename($a) cmp basename($b) }
259 1.1.1.6 christos grep { $files{$_}->{public_header} }
260 1.1.1.6 christos keys %files );
261 1.1.1.6 christos }
262 1.1.1.6 christos
263 1.1.1.6 christos if ($debug) {
264 1.1.1.6 christos print STDERR "DEBUG[files]: result:\n";
265 1.1.1.6 christos print STDERR "DEBUG[files]: $_\n" foreach @result;
266 1.1.1.6 christos }
267 1.1.1.6 christos $collected_results{$tags_as_key} = [ @result ];
268 1.1.1.6 christos }
269 1.1.1.6 christos
270 1.1.1.6 christos return @result;
271 1.1.1.6 christos }
272 1.1 christos
273 1.1.1.6 christos # Print error message, set $status.
274 1.1.1.6 christos sub err {
275 1.1.1.6 christos print join(" ", @_), "\n";
276 1.1.1.6 christos $status = 1
277 1.1.1.6 christos }
278 1.1 christos
279 1.1 christos # Cross-check functions in the NAME and SYNOPSIS section.
280 1.1.1.6 christos sub name_synopsis {
281 1.1 christos my $id = shift;
282 1.1 christos my $filename = shift;
283 1.1 christos my $contents = shift;
284 1.1 christos
285 1.1 christos # Get NAME section and all words in it.
286 1.1 christos return unless $contents =~ /=head1 NAME(.*)=head1 SYNOPSIS/ms;
287 1.1 christos my $tmp = $1;
288 1.1 christos $tmp =~ tr/\n/ /;
289 1.1.1.6 christos err($id, "Trailing comma before - in NAME")
290 1.1.1.6 christos if $tmp =~ /, *-/;
291 1.1 christos $tmp =~ s/ -.*//g;
292 1.1.1.6 christos err($id, "POD markup among the names in NAME")
293 1.1.1.6 christos if $tmp =~ /[<>]/;
294 1.1 christos $tmp =~ s/ */ /g;
295 1.1.1.6 christos err($id, "Missing comma in NAME")
296 1.1.1.6 christos if $tmp =~ /[^,] /;
297 1.1 christos
298 1.1 christos my $dirname = dirname($filename);
299 1.1.1.6 christos my $section = basename($dirname);
300 1.1.1.6 christos my $simplename = basename($filename, ".pod");
301 1.1 christos my $foundfilename = 0;
302 1.1 christos my %foundfilenames = ();
303 1.1 christos my %names;
304 1.1.1.6 christos foreach my $n ( split ',', $tmp ) {
305 1.1.1.6 christos $n =~ s/^\s+//;
306 1.1.1.6 christos $n =~ s/\s+$//;
307 1.1.1.6 christos err($id, "The name '$n' contains white-space")
308 1.1.1.6 christos if $n =~ /\s/;
309 1.1 christos $names{$n} = 1;
310 1.1 christos $foundfilename++ if $n eq $simplename;
311 1.1 christos $foundfilenames{$n} = 1
312 1.1.1.6 christos if ( ( grep { basename($_) eq "$n.pod" }
313 1.1.1.6 christos files(TAGS => [ 'manual', $section ]) )
314 1.1.1.6 christos && $n ne $simplename );
315 1.1 christos }
316 1.1.1.6 christos err($id, "The following exist as other .pod files:",
317 1.1.1.6 christos sort keys %foundfilenames)
318 1.1 christos if %foundfilenames;
319 1.1.1.6 christos err($id, "$simplename (filename) missing from NAME section")
320 1.1 christos unless $foundfilename;
321 1.1 christos
322 1.1 christos # Find all functions in SYNOPSIS
323 1.1 christos return unless $contents =~ /=head1 SYNOPSIS(.*)=head1 DESCRIPTION/ms;
324 1.1 christos my $syn = $1;
325 1.1.1.6 christos my $ignore_until = undef; # If defined, this is a regexp
326 1.1.1.6 christos # Remove all non-code lines
327 1.1.1.6 christos $syn =~ s/^(?:\s*?|\S.*?)$//msg;
328 1.1.1.6 christos # Remove all comments
329 1.1.1.6 christos $syn =~ s/\/\*.*?\*\///msg;
330 1.1.1.6 christos while ( $syn ) {
331 1.1.1.6 christos # "env" lines end at a newline.
332 1.1.1.6 christos # Preprocessor lines start with a # and end at a newline.
333 1.1.1.6 christos # Other lines end with a semicolon, and may cover more than
334 1.1.1.6 christos # one physical line.
335 1.1.1.6 christos if ( $syn !~ /^ \s*(env .*?|#.*?|.*?;)\s*$/ms ) {
336 1.1.1.6 christos err($id, "Can't parse rest of synopsis:\n$syn\n(declarations not ending with a semicolon (;)?)");
337 1.1.1.6 christos last;
338 1.1.1.6 christos }
339 1.1.1.6 christos my $line = $1;
340 1.1.1.6 christos $syn = $';
341 1.1.1.6 christos
342 1.1.1.6 christos print STDERR "DEBUG[name_synopsis] \$line = '$line'\n" if $debug;
343 1.1.1.6 christos
344 1.1.1.6 christos # Special code to skip over documented structures
345 1.1.1.6 christos if ( defined $ignore_until) {
346 1.1.1.6 christos next if $line !~ /$ignore_until/;
347 1.1.1.6 christos $ignore_until = undef;
348 1.1.1.6 christos next;
349 1.1.1.6 christos }
350 1.1.1.6 christos if ( $line =~ /^\s*(?:typedef\s+)?struct(?:\s+\S+)\s*\{/ ) {
351 1.1.1.6 christos $ignore_until = qr/\}.*?;/;
352 1.1.1.6 christos next;
353 1.1.1.6 christos }
354 1.1.1.6 christos
355 1.1 christos my $sym;
356 1.1.1.6 christos my $is_prototype = 1;
357 1.1.1.6 christos $line =~ s/LHASH_OF\([^)]+\)/int/g;
358 1.1 christos $line =~ s/STACK_OF\([^)]+\)/int/g;
359 1.1.1.6 christos $line =~ s/SPARSE_ARRAY_OF\([^)]+\)/int/g;
360 1.1 christos $line =~ s/__declspec\([^)]+\)//;
361 1.1.1.6 christos
362 1.1.1.6 christos ## We don't prohibit that space, to allow typedefs looking like
363 1.1.1.6 christos ## this:
364 1.1.1.6 christos ##
365 1.1.1.6 christos ## typedef int (fantastically_long_name_breaks_80char_limit)
366 1.1.1.6 christos ## (fantastically_long_name_breaks_80char_limit *something);
367 1.1.1.6 christos ##
368 1.1.1.6 christos #if ( $line =~ /typedef.*\(\*?\S+\)\s+\(/ ) {
369 1.1.1.6 christos # # a callback function with whitespace before the argument list:
370 1.1.1.6 christos # # typedef ... (*NAME) (...
371 1.1.1.6 christos # # typedef ... (NAME) (...
372 1.1.1.6 christos # err($id, "Function typedef has space before arg list: $line");
373 1.1.1.6 christos #}
374 1.1.1.6 christos
375 1.1 christos if ( $line =~ /env (\S*)=/ ) {
376 1.1 christos # environment variable env NAME=...
377 1.1 christos $sym = $1;
378 1.1.1.6 christos } elsif ( $line =~ /typedef.*\(\*?($C_symbol)\)\s*\(/ ) {
379 1.1 christos # a callback function pointer: typedef ... (*NAME)(...
380 1.1.1.6 christos # a callback function signature: typedef ... (NAME)(...
381 1.1 christos $sym = $1;
382 1.1.1.6 christos } elsif ( $line =~ /typedef.*($C_symbol)\s*\(/ ) {
383 1.1 christos # a callback function signature: typedef ... NAME(...
384 1.1 christos $sym = $1;
385 1.1.1.6 christos } elsif ( $line =~ /typedef.*($C_symbol);/ ) {
386 1.1 christos # a simple typedef: typedef ... NAME;
387 1.1.1.6 christos $is_prototype = 0;
388 1.1 christos $sym = $1;
389 1.1.1.6 christos } elsif ( $line =~ /enum ($C_symbol) \{/ ) {
390 1.1 christos # an enumeration: enum ... {
391 1.1 christos $sym = $1;
392 1.1.1.6 christos } elsif ( $line =~ /#\s*(?:define|undef) ($C_symbol)/ ) {
393 1.1.1.6 christos $is_prototype = 0;
394 1.1.1.6 christos $sym = $1;
395 1.1.1.6 christos } elsif ( $line =~ /^[^\(]*?\(\*($C_symbol)\s*\(/ ) {
396 1.1.1.6 christos # a function returning a function pointer: TYPE (*NAME(args))(args)
397 1.1 christos $sym = $1;
398 1.1.1.6 christos } elsif ( $line =~ /^[^\(]*?($C_symbol)\s*\(/ ) {
399 1.1.1.6 christos # a simple function declaration
400 1.1 christos $sym = $1;
401 1.1 christos }
402 1.1 christos else {
403 1.1 christos next;
404 1.1 christos }
405 1.1.1.6 christos
406 1.1.1.6 christos print STDERR "DEBUG[name_synopsis] \$sym = '$sym'\n" if $debug;
407 1.1.1.6 christos
408 1.1.1.6 christos err($id, "$sym missing from NAME section")
409 1.1 christos unless defined $names{$sym};
410 1.1 christos $names{$sym} = 2;
411 1.1 christos
412 1.1 christos # Do some sanity checks on the prototype.
413 1.1.1.6 christos err($id, "Prototype missing spaces around commas: $line")
414 1.1.1.6 christos if $is_prototype && $line =~ /[a-z0-9],[^\s]/;
415 1.1 christos }
416 1.1 christos
417 1.1 christos foreach my $n ( keys %names ) {
418 1.1 christos next if $names{$n} == 2;
419 1.1.1.6 christos err($id, "$n missing from SYNOPSIS")
420 1.1 christos }
421 1.1 christos }
422 1.1 christos
423 1.1.1.4 christos # Check if SECTION ($3) is located before BEFORE ($4)
424 1.1.1.6 christos sub check_section_location {
425 1.1.1.4 christos my $id = shift;
426 1.1.1.3 christos my $contents = shift;
427 1.1.1.3 christos my $section = shift;
428 1.1.1.3 christos my $before = shift;
429 1.1.1.3 christos
430 1.1.1.6 christos return unless $contents =~ /=head1 $section/
431 1.1.1.6 christos and $contents =~ /=head1 $before/;
432 1.1.1.6 christos err($id, "$section should appear before $before section")
433 1.1.1.3 christos if $contents =~ /=head1 $before.*=head1 $section/ms;
434 1.1.1.3 christos }
435 1.1.1.3 christos
436 1.1.1.6 christos # Check if a =head1 is duplicated, or a =headX is duplicated within a
437 1.1.1.6 christos # =head1. Treats =head2 =head3 as equivalent -- it doesn't reset the head3
438 1.1.1.6 christos # sets if it finds a =head2 -- but that is good enough for now. Also check
439 1.1.1.6 christos # for proper capitalization, trailing periods, etc.
440 1.1.1.6 christos sub check_head_style {
441 1.1.1.6 christos my $id = shift;
442 1.1.1.6 christos my $contents = shift;
443 1.1.1.6 christos my %head1;
444 1.1.1.6 christos my %subheads;
445 1.1.1.6 christos
446 1.1.1.6 christos foreach my $line ( split /\n+/, $contents ) {
447 1.1.1.6 christos next unless $line =~ /^=head/;
448 1.1.1.6 christos if ( $line =~ /head1/ ) {
449 1.1.1.6 christos err($id, "Duplicate section $line")
450 1.1.1.6 christos if defined $head1{$line};
451 1.1.1.6 christos $head1{$line} = 1;
452 1.1.1.6 christos %subheads = ();
453 1.1.1.6 christos } else {
454 1.1.1.6 christos err($id, "Duplicate subsection $line")
455 1.1.1.6 christos if defined $subheads{$line};
456 1.1.1.6 christos $subheads{$line} = 1;
457 1.1.1.6 christos }
458 1.1.1.6 christos err($id, "Period in =head")
459 1.1.1.6 christos if $line =~ /\.[^\w]/ or $line =~ /\.$/;
460 1.1.1.6 christos err($id, "not all uppercase in =head1")
461 1.1.1.6 christos if $line =~ /head1.*[a-z]/;
462 1.1.1.6 christos err($id, "All uppercase in subhead")
463 1.1.1.6 christos if $line =~ /head[234][ A-Z0-9]+$/;
464 1.1.1.6 christos }
465 1.1.1.6 christos }
466 1.1.1.6 christos
467 1.1.1.6 christos # Because we have options and symbols with extra markup, we need
468 1.1.1.6 christos # to take that into account, so we need a regexp that extracts
469 1.1.1.6 christos # markup chunks, including recursive markup.
470 1.1.1.6 christos # please read up on /(?R)/ in perlre(1)
471 1.1.1.6 christos # (note: order is important, (?R) needs to come before .)
472 1.1.1.6 christos # (note: non-greedy is important, or something like 'B<foo> and B<bar>'
473 1.1.1.6 christos # will be captured as one item)
474 1.1.1.6 christos my $markup_re =
475 1.1.1.6 christos qr/( # Capture group
476 1.1.1.6 christos [BIL]< # The start of what we recurse on
477 1.1.1.6 christos (?:(?-1)|.)*? # recurse the whole regexp (referring to
478 1.1.1.6 christos # the last opened capture group, i.e. the
479 1.1.1.6 christos # start of this regexp), or pick next
480 1.1.1.6 christos # character. Do NOT be greedy!
481 1.1.1.6 christos > # The end of what we recurse on
482 1.1.1.6 christos )/x; # (the x allows this sort of split up regexp)
483 1.1.1.6 christos
484 1.1.1.6 christos # Options must start with a dash, followed by a letter, possibly
485 1.1.1.6 christos # followed by letters, digits, dashes and underscores, and the last
486 1.1.1.6 christos # character must be a letter or a digit.
487 1.1.1.6 christos # We do also accept the single -? or -n, where n is a digit
488 1.1.1.6 christos my $option_re =
489 1.1.1.6 christos qr/(?:
490 1.1.1.6 christos \? # Single question mark
491 1.1.1.6 christos |
492 1.1.1.6 christos \d # Single digit
493 1.1.1.6 christos |
494 1.1.1.6 christos - # Single dash (--)
495 1.1.1.6 christos |
496 1.1.1.6 christos [[:alpha:]](?:[-_[:alnum:]]*?[[:alnum:]])?
497 1.1.1.6 christos )/x;
498 1.1.1.6 christos
499 1.1.1.6 christos # Helper function to check if a given $thing is properly marked up
500 1.1.1.6 christos # option. It returns one of these values:
501 1.1.1.6 christos # undef if it's not an option
502 1.1.1.6 christos # "" if it's a malformed option
503 1.1.1.6 christos # $unwrapped the option with the outermost B<> wrapping removed.
504 1.1.1.6 christos sub normalise_option {
505 1.1.1.6 christos my $id = shift;
506 1.1 christos my $filename = shift;
507 1.1.1.6 christos my $thing = shift;
508 1.1.1.6 christos
509 1.1.1.6 christos my $unwrapped = $thing;
510 1.1.1.6 christos my $unmarked = $thing;
511 1.1.1.6 christos
512 1.1.1.6 christos # $unwrapped is the option with the outer B<> markup removed
513 1.1.1.6 christos $unwrapped =~ s/^B<//;
514 1.1.1.6 christos $unwrapped =~ s/>$//;
515 1.1.1.6 christos # $unmarked is the option with *all* markup removed
516 1.1.1.6 christos $unmarked =~ s/[BIL]<|>//msg;
517 1.1.1.6 christos
518 1.1.1.6 christos
519 1.1.1.6 christos # If we found an option, check it, collect it
520 1.1.1.6 christos if ( $unwrapped =~ /^\s*-/ ) {
521 1.1.1.6 christos return $unwrapped # return option with outer B<> removed
522 1.1.1.6 christos if $unmarked =~ /^-${option_re}$/;
523 1.1.1.6 christos return ""; # Malformed option
524 1.1.1.6 christos }
525 1.1.1.6 christos return undef; # Something else
526 1.1.1.6 christos }
527 1.1.1.6 christos
528 1.1.1.6 christos # Checks of command option (man1) formatting. The man1 checks are
529 1.1.1.6 christos # restricted to the SYNOPSIS and OPTIONS sections, the rest is too
530 1.1.1.6 christos # free form, we simply cannot be too strict there.
531 1.1.1.6 christos
532 1.1.1.6 christos sub option_check {
533 1.1.1.6 christos my $id = shift;
534 1.1.1.6 christos my $filename = shift;
535 1.1.1.6 christos my $contents = shift;
536 1.1.1.6 christos
537 1.1.1.6 christos my $synopsis = ($contents =~ /=head1\s+SYNOPSIS(.*?)=head1/s, $1);
538 1.1.1.6 christos
539 1.1.1.6 christos # Some pages have more than one OPTIONS section, let's make sure
540 1.1.1.6 christos # to get them all
541 1.1.1.6 christos my $options = '';
542 1.1.1.6 christos while ( $contents =~ /=head1\s+[A-Z ]*?OPTIONS$(.*?)(?==head1)/msg ) {
543 1.1.1.6 christos $options .= $1;
544 1.1.1.6 christos }
545 1.1.1.6 christos
546 1.1.1.6 christos # Look for options with no or incorrect markup
547 1.1.1.6 christos while ( $synopsis =~
548 1.1.1.6 christos /(?<![-<[:alnum:]])-(?:$markup_re|.)*(?![->[:alnum:]])/msg ) {
549 1.1.1.6 christos err($id, "Malformed option [1] in SYNOPSIS: $&");
550 1.1.1.6 christos }
551 1.1.1.6 christos
552 1.1.1.6 christos my @synopsis;
553 1.1.1.6 christos while ( $synopsis =~ /$markup_re/msg ) {
554 1.1.1.6 christos my $found = $&;
555 1.1.1.6 christos push @synopsis, $found if $found =~ /^B<-/;
556 1.1.1.6 christos print STDERR "$id:DEBUG[option_check] SYNOPSIS: found $found\n"
557 1.1.1.6 christos if $debug;
558 1.1.1.6 christos my $option_uw = normalise_option($id, $filename, $found);
559 1.1.1.6 christos err($id, "Malformed option [2] in SYNOPSIS: $found")
560 1.1.1.6 christos if defined $option_uw && $option_uw eq '';
561 1.1.1.6 christos }
562 1.1.1.6 christos
563 1.1.1.6 christos # In OPTIONS, we look for =item paragraphs.
564 1.1.1.6 christos # (?=^\s*$) detects an empty line.
565 1.1.1.6 christos my @options;
566 1.1.1.6 christos while ( $options =~ /=item\s+(.*?)(?=^\s*$)/msg ) {
567 1.1.1.6 christos my $item = $&;
568 1.1.1.6 christos
569 1.1.1.6 christos while ( $item =~ /(\[\s*)?($markup_re)/msg ) {
570 1.1.1.6 christos my $found = $2;
571 1.1.1.6 christos print STDERR "$id:DEBUG[option_check] OPTIONS: found $&\n"
572 1.1.1.6 christos if $debug;
573 1.1.1.6 christos err($id, "Unexpected bracket in OPTIONS =item: $item")
574 1.1.1.6 christos if ($1 // '') ne '' && $found =~ /^B<\s*-/;
575 1.1.1.6 christos
576 1.1.1.6 christos my $option_uw = normalise_option($id, $filename, $found);
577 1.1.1.6 christos err($id, "Malformed option in OPTIONS: $found")
578 1.1.1.6 christos if defined $option_uw && $option_uw eq '';
579 1.1.1.6 christos if ($found =~ /^B<-/) {
580 1.1.1.6 christos push @options, $found;
581 1.1.1.6 christos err($id, "OPTIONS entry $found missing from SYNOPSIS")
582 1.1.1.6 christos unless (grep /^\Q$found\E$/, @synopsis)
583 1.1.1.6 christos || $id =~ /(openssl|-options)\.pod:1:$/;
584 1.1.1.6 christos }
585 1.1.1.6 christos }
586 1.1.1.6 christos }
587 1.1.1.6 christos foreach (@synopsis) {
588 1.1.1.6 christos my $option = $_;
589 1.1.1.6 christos err($id, "SYNOPSIS entry $option missing from OPTIONS")
590 1.1.1.6 christos unless (grep /^\Q$option\E$/, @options);
591 1.1.1.6 christos }
592 1.1.1.6 christos }
593 1.1.1.6 christos
594 1.1.1.6 christos # Normal symbol form
595 1.1.1.6 christos my $symbol_re = qr/[[:alpha:]_][_[:alnum:]]*?/;
596 1.1.1.6 christos
597 1.1.1.6 christos # Checks of function name (man3) formatting. The man3 checks are
598 1.1.1.6 christos # easier than the man1 checks, we only check the names followed by (),
599 1.1.1.6 christos # and only the names that have POD markup.
600 1.1.1.6 christos sub functionname_check {
601 1.1.1.6 christos my $id = shift;
602 1.1.1.6 christos my $filename = shift;
603 1.1.1.6 christos my $contents = shift;
604 1.1.1.6 christos
605 1.1.1.6 christos while ( $contents =~ /($markup_re)\(\)/msg ) {
606 1.1.1.6 christos print STDERR "$id:DEBUG[functionname_check] SYNOPSIS: found $&\n"
607 1.1.1.6 christos if $debug;
608 1.1.1.6 christos
609 1.1.1.6 christos my $symbol = $1;
610 1.1.1.6 christos my $unmarked = $symbol;
611 1.1.1.6 christos $unmarked =~ s/[BIL]<|>//msg;
612 1.1.1.6 christos
613 1.1.1.6 christos err($id, "Malformed symbol: $symbol")
614 1.1.1.6 christos unless $symbol =~ /^B<.*?>$/ && $unmarked =~ /^${symbol_re}$/
615 1.1.1.6 christos }
616 1.1.1.6 christos
617 1.1.1.6 christos # We can't do the kind of collecting coolness that option_check()
618 1.1.1.6 christos # does, because there are too many things that can't be found in
619 1.1.1.6 christos # name repositories like the NAME sections, such as symbol names
620 1.1.1.6 christos # with a variable part (typically marked up as B<foo_I<TYPE>_bar>
621 1.1.1.6 christos }
622 1.1.1.6 christos
623 1.1.1.6 christos # This is from http://man7.org/linux/man-pages/man7/man-pages.7.html
624 1.1.1.6 christos my %preferred_words = (
625 1.1.1.6 christos '16bit' => '16-bit',
626 1.1.1.6 christos 'a.k.a.' => 'aka',
627 1.1.1.6 christos 'bitmask' => 'bit mask',
628 1.1.1.6 christos 'builtin' => 'built-in',
629 1.1.1.6 christos #'epoch' => 'Epoch', # handled specially, below
630 1.1.1.6 christos 'fall-back' => 'fallback',
631 1.1.1.6 christos 'file name' => 'filename',
632 1.1.1.6 christos 'file system' => 'filesystem',
633 1.1.1.6 christos 'host name' => 'hostname',
634 1.1.1.6 christos 'i-node' => 'inode',
635 1.1.1.6 christos 'lower case' => 'lowercase',
636 1.1.1.6 christos 'lower-case' => 'lowercase',
637 1.1.1.6 christos 'manpage' => 'man page',
638 1.1.1.6 christos 'non-blocking' => 'nonblocking',
639 1.1.1.6 christos 'non-default' => 'nondefault',
640 1.1.1.6 christos 'non-empty' => 'nonempty',
641 1.1.1.6 christos 'non-negative' => 'nonnegative',
642 1.1.1.6 christos 'non-zero' => 'nonzero',
643 1.1.1.6 christos 'path name' => 'pathname',
644 1.1.1.6 christos 'pre-allocated' => 'preallocated',
645 1.1.1.6 christos 'pseudo-terminal' => 'pseudoterminal',
646 1.1.1.6 christos 'real time' => 'real-time',
647 1.1.1.6 christos 'realtime' => 'real-time',
648 1.1.1.6 christos 'reserved port' => 'privileged port',
649 1.1.1.6 christos 'runtime' => 'run time',
650 1.1.1.6 christos 'saved group ID'=> 'saved set-group-ID',
651 1.1.1.6 christos 'saved set-GID' => 'saved set-group-ID',
652 1.1.1.6 christos 'saved set-UID' => 'saved set-user-ID',
653 1.1.1.6 christos 'saved user ID' => 'saved set-user-ID',
654 1.1.1.6 christos 'set-GID' => 'set-group-ID',
655 1.1.1.6 christos 'set-UID' => 'set-user-ID',
656 1.1.1.6 christos 'setgid' => 'set-group-ID',
657 1.1.1.6 christos 'setuid' => 'set-user-ID',
658 1.1.1.6 christos 'sub-system' => 'subsystem',
659 1.1.1.6 christos 'super block' => 'superblock',
660 1.1.1.6 christos 'super-block' => 'superblock',
661 1.1.1.6 christos 'super user' => 'superuser',
662 1.1.1.6 christos 'super-user' => 'superuser',
663 1.1.1.6 christos 'system port' => 'privileged port',
664 1.1.1.6 christos 'time stamp' => 'timestamp',
665 1.1.1.6 christos 'time zone' => 'timezone',
666 1.1.1.6 christos 'upper case' => 'uppercase',
667 1.1.1.6 christos 'upper-case' => 'uppercase',
668 1.1.1.6 christos 'useable' => 'usable',
669 1.1.1.6 christos 'user name' => 'username',
670 1.1.1.6 christos 'userspace' => 'user space',
671 1.1.1.6 christos 'zeroes' => 'zeros'
672 1.1.1.6 christos );
673 1.1.1.6 christos
674 1.1.1.6 christos # Search manpage for words that have a different preferred use.
675 1.1.1.6 christos sub wording {
676 1.1.1.6 christos my $id = shift;
677 1.1.1.6 christos my $contents = shift;
678 1.1.1.6 christos
679 1.1.1.6 christos foreach my $k ( keys %preferred_words ) {
680 1.1.1.6 christos # Sigh, trademark
681 1.1.1.6 christos next if $k eq 'file system'
682 1.1.1.6 christos and $contents =~ /Microsoft Encrypted File System/;
683 1.1.1.6 christos err($id, "Found '$k' should use '$preferred_words{$k}'")
684 1.1.1.6 christos if $contents =~ /\b\Q$k\E\b/i;
685 1.1.1.6 christos }
686 1.1.1.6 christos err($id, "Found 'epoch' should use 'Epoch'")
687 1.1.1.6 christos if $contents =~ /\bepoch\b/;
688 1.1.1.6 christos if ( $id =~ m@man1/@ ) {
689 1.1.1.6 christos err($id, "found 'tool' in NAME, should use 'command'")
690 1.1.1.6 christos if $contents =~ /=head1 NAME.*\btool\b.*=head1 SYNOPSIS/s;
691 1.1.1.6 christos err($id, "found 'utility' in NAME, should use 'command'")
692 1.1.1.6 christos if $contents =~ /NAME.*\butility\b.*=head1 SYNOPSIS/s;
693 1.1 christos
694 1.1 christos }
695 1.1.1.6 christos }
696 1.1.1.6 christos
697 1.1.1.6 christos # Perform all sorts of nit/error checks on a manpage
698 1.1.1.6 christos sub check {
699 1.1.1.6 christos my %podinfo = @_;
700 1.1.1.6 christos my $filename = $podinfo{filename};
701 1.1.1.6 christos my $dirname = basename(dirname($filename));
702 1.1.1.6 christos my $contents = $podinfo{contents};
703 1.1 christos
704 1.1 christos my $id = "${filename}:1:";
705 1.1.1.6 christos check_head_style($id, $contents);
706 1.1 christos
707 1.1.1.4 christos # Check ordering of some sections in man3
708 1.1.1.4 christos if ( $filename =~ m|man3/| ) {
709 1.1.1.6 christos check_section_location($id, $contents, "RETURN VALUES", "EXAMPLES");
710 1.1.1.6 christos check_section_location($id, $contents, "SEE ALSO", "HISTORY");
711 1.1.1.6 christos check_section_location($id, $contents, "EXAMPLES", "SEE ALSO");
712 1.1.1.6 christos }
713 1.1.1.6 christos
714 1.1.1.6 christos # Make sure every link has a section.
715 1.1.1.6 christos while ( $contents =~ /$markup_re/msg ) {
716 1.1.1.6 christos my $target = $1;
717 1.1.1.6 christos next unless $target =~ /^L<(.*)>$/; # Skip if not L<...>
718 1.1.1.6 christos $target = $1; # Peal away L< and >
719 1.1.1.6 christos $target =~ s/\/[^\/]*$//; # Peal away possible anchor
720 1.1.1.6 christos $target =~ s/.*\|//g; # Peal away possible link text
721 1.1.1.6 christos next if $target eq ''; # Skip if links within page, or
722 1.1.1.6 christos next if $target =~ /::/; # links to a Perl module, or
723 1.1.1.6 christos next if $target =~ /^https?:/; # is a URL link, or
724 1.1.1.6 christos next if $target =~ /\([1357]\)$/; # it has a section
725 1.1.1.6 christos err($id, "Section missing in $target")
726 1.1.1.6 christos }
727 1.1.1.6 christos # Check for proper links to commands.
728 1.1.1.6 christos while ( $contents =~ /L<([^>]*)\(1\)(?:\/.*)?>/g ) {
729 1.1.1.6 christos my $target = $1;
730 1.1.1.6 christos next if $target =~ /openssl-?/;
731 1.1.1.6 christos next if ( grep { basename($_) eq "$target.pod" }
732 1.1.1.6 christos files(TAGS => [ 'manual', 'man1' ]) );
733 1.1.1.6 christos next if $target =~ /ps|apropos|sha1sum|procmail|perl/;
734 1.1.1.6 christos err($id, "Bad command link L<$target(1)>") if grep /man1/, @sections;
735 1.1.1.6 christos }
736 1.1.1.6 christos # Check for proper in-man-3 API links.
737 1.1.1.6 christos while ( $contents =~ /L<([^>]*)\(3\)(?:\/.*)?>/g ) {
738 1.1.1.6 christos my $target = $1;
739 1.1.1.6 christos err($id, "Bad L<$target>")
740 1.1.1.6 christos unless $target =~ /^[_[:alpha:]][_[:alnum:]]*$/
741 1.1.1.6 christos }
742 1.1.1.6 christos
743 1.1.1.6 christos unless ( $contents =~ /^=for openssl generic/ms ) {
744 1.1.1.6 christos if ( $filename =~ m|man3/| ) {
745 1.1.1.6 christos name_synopsis($id, $filename, $contents);
746 1.1.1.6 christos functionname_check($id, $filename, $contents);
747 1.1.1.6 christos } elsif ( $filename =~ m|man1/| ) {
748 1.1.1.6 christos option_check($id, $filename, $contents)
749 1.1.1.6 christos }
750 1.1.1.4 christos }
751 1.1.1.4 christos
752 1.1.1.6 christos wording($id, $contents);
753 1.1 christos
754 1.1.1.6 christos err($id, "Doesn't start with =pod")
755 1.1 christos if $contents !~ /^=pod/;
756 1.1.1.6 christos err($id, "Doesn't end with =cut")
757 1.1 christos if $contents !~ /=cut\n$/;
758 1.1.1.6 christos err($id, "More than one cut line.")
759 1.1 christos if $contents =~ /=cut.*=cut/ms;
760 1.1.1.6 christos err($id, "EXAMPLE not EXAMPLES section.")
761 1.1.1.4 christos if $contents =~ /=head1 EXAMPLE[^S]/;
762 1.1.1.6 christos err($id, "WARNING not WARNINGS section.")
763 1.1.1.4 christos if $contents =~ /=head1 WARNING[^S]/;
764 1.1.1.6 christos err($id, "Missing copyright")
765 1.1 christos if $contents !~ /Copyright .* The OpenSSL Project Authors/;
766 1.1.1.6 christos err($id, "Copyright not last")
767 1.1 christos if $contents =~ /head1 COPYRIGHT.*=head/ms;
768 1.1.1.6 christos err($id, "head2 in All uppercase")
769 1.1 christos if $contents =~ /head2\s+[A-Z ]+\n/;
770 1.1.1.6 christos err($id, "Extra space after head")
771 1.1 christos if $contents =~ /=head\d\s\s+/;
772 1.1.1.6 christos err($id, "Period in NAME section")
773 1.1 christos if $contents =~ /=head1 NAME.*\.\n.*=head1 SYNOPSIS/ms;
774 1.1.1.6 christos err($id, "Duplicate $1 in L<>")
775 1.1 christos if $contents =~ /L<([^>]*)\|([^>]*)>/ && $1 eq $2;
776 1.1.1.6 christos err($id, "Bad =over $1")
777 1.1 christos if $contents =~ /=over([^ ][^24])/;
778 1.1.1.6 christos err($id, "Possible version style issue")
779 1.1 christos if $contents =~ /OpenSSL version [019]/;
780 1.1 christos
781 1.1.1.6 christos if ( $contents !~ /=for openssl multiple includes/ ) {
782 1.1 christos # Look for multiple consecutive openssl #include lines
783 1.1.1.2 christos # (non-consecutive lines are okay; see man3/MD5.pod).
784 1.1 christos if ( $contents =~ /=head1 SYNOPSIS(.*)=head1 DESCRIPTION/ms ) {
785 1.1 christos my $count = 0;
786 1.1 christos foreach my $line ( split /\n+/, $1 ) {
787 1.1 christos if ( $line =~ m@include <openssl/@ ) {
788 1.1.1.6 christos err($id, "Has multiple includes")
789 1.1.1.6 christos if ++$count == 2;
790 1.1 christos } else {
791 1.1 christos $count = 0;
792 1.1 christos }
793 1.1 christos }
794 1.1 christos }
795 1.1 christos }
796 1.1 christos
797 1.1 christos open my $OUT, '>', $temp
798 1.1 christos or die "Can't open $temp, $!";
799 1.1.1.6 christos err($id, "POD errors")
800 1.1.1.6 christos if podchecker($filename, $OUT) != 0;
801 1.1 christos close $OUT;
802 1.1 christos open $OUT, '<', $temp
803 1.1 christos or die "Can't read $temp, $!";
804 1.1 christos while ( <$OUT> ) {
805 1.1 christos next if /\(section\) in.*deprecated/;
806 1.1 christos print;
807 1.1 christos }
808 1.1 christos close $OUT;
809 1.1 christos unlink $temp || warn "Can't remove $temp, $!";
810 1.1 christos
811 1.1.1.2 christos # Find what section this page is in; assume 3.
812 1.1.1.2 christos my $section = 3;
813 1.1.1.2 christos $section = $1 if $dirname =~ /man([1-9])/;
814 1.1.1.2 christos
815 1.1.1.6 christos foreach ( (@{$mandatory_sections{'*'}}, @{$mandatory_sections{$section}}) ) {
816 1.1.1.6 christos err($id, "Missing $_ head1 section")
817 1.1 christos if $contents !~ /^=head1\s+${_}\s*$/m;
818 1.1 christos }
819 1.1 christos }
820 1.1 christos
821 1.1.1.6 christos # Information database ###############################################
822 1.1 christos
823 1.1.1.6 christos # Map of links in each POD file; filename => [ "foo(1)", "bar(3)", ... ]
824 1.1.1.6 christos my %link_map = ();
825 1.1.1.6 christos # Map of names in each POD file or from "missing" files; possible values are:
826 1.1.1.6 christos # If found in a POD files, "name(s)" => filename
827 1.1.1.6 christos # If found in a "missing" file or external, "name(s)" => ''
828 1.1.1.6 christos my %name_map = ();
829 1.1.1.6 christos
830 1.1.1.6 christos # State of man-page names.
831 1.1.1.6 christos # %state is affected by loading util/*.num and util/*.syms
832 1.1.1.6 christos # Values may be one of:
833 1.1.1.6 christos # 'crypto' : belongs in libcrypto (loaded from libcrypto.num)
834 1.1.1.6 christos # 'ssl' : belongs in libssl (loaded from libssl.num)
835 1.1.1.6 christos # 'other' : belongs in libcrypto or libssl (loaded from other.syms)
836 1.1.1.6 christos # 'internal' : Internal
837 1.1.1.6 christos # 'public' : Public (generic name or external documentation)
838 1.1.1.6 christos # Any of these values except 'public' may be prefixed with 'missing_'
839 1.1.1.6 christos # to indicate that they are known to be missing.
840 1.1.1.6 christos my %state;
841 1.1.1.6 christos # %missing is affected by loading util/missing*.txt. Values may be one of:
842 1.1.1.6 christos # 'crypto' : belongs in libcrypto (loaded from libcrypto.num)
843 1.1.1.6 christos # 'ssl' : belongs in libssl (loaded from libssl.num)
844 1.1.1.6 christos # 'other' : belongs in libcrypto or libssl (loaded from other.syms)
845 1.1.1.6 christos # 'internal' : Internal
846 1.1.1.6 christos my %missing;
847 1.1.1.6 christos
848 1.1.1.6 christos # Parse libcrypto.num, etc., and return sorted list of what's there.
849 1.1.1.6 christos sub loadnum ($;$) {
850 1.1 christos my $file = shift;
851 1.1.1.6 christos my $type = shift;
852 1.1.1.6 christos my @symbols;
853 1.1 christos
854 1.1.1.6 christos open my $IN, '<', catfile($config{sourcedir}, $file)
855 1.1 christos or die "Can't open $file, $!, stopped";
856 1.1 christos
857 1.1 christos while ( <$IN> ) {
858 1.1 christos next if /^#/;
859 1.1 christos next if /\bNOEXIST\b/;
860 1.1 christos my @fields = split();
861 1.1.1.6 christos die "Malformed line $. in $file: $_"
862 1.1 christos if scalar @fields != 2 && scalar @fields != 4;
863 1.1.1.6 christos $state{$fields[0].'(3)'} = $type // 'internal';
864 1.1 christos }
865 1.1 christos close $IN;
866 1.1 christos }
867 1.1 christos
868 1.1.1.6 christos # Load file of symbol names that we know aren't documented.
869 1.1.1.6 christos sub loadmissing($;$)
870 1.1 christos {
871 1.1.1.6 christos my $missingfile = shift;
872 1.1.1.6 christos my $type = shift;
873 1.1 christos
874 1.1.1.6 christos open FH, catfile($config{sourcedir}, $missingfile)
875 1.1.1.6 christos or die "Can't open $missingfile";
876 1.1.1.6 christos while ( <FH> ) {
877 1.1.1.6 christos chomp;
878 1.1.1.6 christos next if /^#/;
879 1.1.1.6 christos $missing{$_} = $type // 'internal';
880 1.1 christos }
881 1.1.1.6 christos close FH;
882 1.1 christos }
883 1.1 christos
884 1.1.1.6 christos # Check that we have consistent public / internal documentation and declaration
885 1.1.1.6 christos sub checkstate () {
886 1.1.1.6 christos # Collect all known names, no matter where they come from
887 1.1.1.6 christos my %names = map { $_ => 1 } (keys %name_map, keys %state, keys %missing);
888 1.1.1.6 christos
889 1.1.1.6 christos # Check section 3, i.e. functions and macros
890 1.1.1.6 christos foreach ( grep { $_ =~ /\(3\)$/ } sort keys %names ) {
891 1.1.1.6 christos next if ( $name_map{$_} // '') eq '' || $_ =~ /$ignored/;
892 1.1.1.6 christos
893 1.1.1.6 christos # If a man-page isn't recorded public or if it's recorded missing
894 1.1.1.6 christos # and internal, it's declared to be internal.
895 1.1.1.6 christos my $declared_internal =
896 1.1.1.6 christos ($state{$_} // 'internal') eq 'internal'
897 1.1.1.6 christos || ($missing{$_} // '') eq 'internal';
898 1.1.1.6 christos # If a man-page isn't recorded internal or if it's recorded missing
899 1.1.1.6 christos # and not internal, it's declared to be public
900 1.1.1.6 christos my $declared_public =
901 1.1.1.6 christos ($state{$_} // 'internal') ne 'internal'
902 1.1.1.6 christos || ($missing{$_} // 'internal') ne 'internal';
903 1.1.1.6 christos
904 1.1.1.6 christos err("$_ is supposedly public but is documented as internal")
905 1.1.1.6 christos if ( $declared_public && $name_map{$_} =~ /\/internal\// );
906 1.1.1.6 christos err("$_ is supposedly internal (maybe missing from other.syms) but is documented as public")
907 1.1.1.6 christos if ( $declared_internal && $name_map{$_} !~ /\/internal\// );
908 1.1.1.6 christos }
909 1.1.1.6 christos }
910 1.1 christos
911 1.1.1.6 christos # Check for undocumented macros; ignore those in the "missing" file
912 1.1.1.6 christos # and do simple check for #define in our header files.
913 1.1.1.6 christos sub checkmacros {
914 1.1 christos my $count = 0;
915 1.1.1.5 christos my %seen;
916 1.1 christos
917 1.1.1.6 christos foreach my $f ( files(TAGS => 'public_header') ) {
918 1.1 christos # Skip some internals we don't want to document yet.
919 1.1.1.6 christos my $b = basename($f);
920 1.1.1.6 christos next if $b eq 'asn1.h';
921 1.1.1.6 christos next if $b eq 'asn1t.h';
922 1.1.1.6 christos next if $b eq 'err.h';
923 1.1.1.6 christos open(IN, $f)
924 1.1.1.6 christos or die "Can't open $f, $!";
925 1.1 christos while ( <IN> ) {
926 1.1 christos next unless /^#\s*define\s*(\S+)\(/;
927 1.1.1.6 christos my $macro = "$1(3)"; # We know they're all in section 3
928 1.1.1.6 christos next if defined $name_map{$macro}
929 1.1.1.6 christos || defined $missing{$macro}
930 1.1.1.6 christos || defined $seen{$macro}
931 1.1.1.6 christos || $macro =~ /$ignored/;
932 1.1.1.6 christos
933 1.1.1.6 christos err("$f:", "macro $macro undocumented")
934 1.1.1.6 christos if $opt_d || $opt_e;
935 1.1 christos $count++;
936 1.1.1.5 christos $seen{$macro} = 1;
937 1.1 christos }
938 1.1 christos close(IN);
939 1.1 christos }
940 1.1.1.6 christos err("# $count macros undocumented (count is approximate)")
941 1.1.1.6 christos if $count > 0;
942 1.1 christos }
943 1.1 christos
944 1.1.1.6 christos # Find out what is undocumented (filtering out the known missing ones)
945 1.1.1.6 christos # and display them.
946 1.1.1.6 christos sub printem ($) {
947 1.1.1.6 christos my $type = shift;
948 1.1 christos my $count = 0;
949 1.1 christos
950 1.1.1.6 christos foreach my $func ( grep { $state{$_} eq $type } sort keys %state ) {
951 1.1.1.6 christos next if defined $name_map{$func}
952 1.1.1.6 christos || defined $missing{$func};
953 1.1 christos
954 1.1.1.6 christos err("$type:", "function $func undocumented")
955 1.1.1.6 christos if $opt_d || $opt_e;
956 1.1 christos $count++;
957 1.1 christos }
958 1.1.1.6 christos err("# $count lib$type names are not documented")
959 1.1.1.6 christos if $count > 0;
960 1.1 christos }
961 1.1 christos
962 1.1.1.6 christos # Collect all the names in a manpage.
963 1.1 christos sub collectnames {
964 1.1.1.6 christos my %podinfo = @_;
965 1.1.1.6 christos my $filename = $podinfo{filename};
966 1.1 christos $filename =~ m|man(\d)/|;
967 1.1 christos my $section = $1;
968 1.1 christos my $simplename = basename($filename, ".pod");
969 1.1 christos my $id = "${filename}:1:";
970 1.1.1.6 christos my $is_generic = $podinfo{contents} =~ /^=for openssl generic/ms;
971 1.1 christos
972 1.1.1.6 christos unless ( grep { $simplename eq $_ } @{$podinfo{names}} ) {
973 1.1.1.6 christos err($id, "$simplename not in NAME section");
974 1.1.1.6 christos push @{$podinfo{names}}, $simplename;
975 1.1 christos }
976 1.1.1.6 christos foreach my $name ( @{$podinfo{names}} ) {
977 1.1 christos next if $name eq "";
978 1.1.1.6 christos err($id, "'$name' contains whitespace")
979 1.1.1.6 christos if $name =~ /\s/;
980 1.1 christos my $name_sec = "$name($section)";
981 1.1.1.6 christos if ( !defined $name_map{$name_sec} ) {
982 1.1.1.6 christos $name_map{$name_sec} = $filename;
983 1.1.1.6 christos $state{$name_sec} //=
984 1.1.1.6 christos ( $filename =~ /\/internal\// ? 'internal' : 'public' )
985 1.1.1.6 christos if $is_generic;
986 1.1.1.6 christos } elsif ( $filename eq $name_map{$name_sec} ) {
987 1.1.1.6 christos err($id, "$name_sec duplicated in NAME section of",
988 1.1.1.6 christos $name_map{$name_sec});
989 1.1.1.6 christos } elsif ( $name_map{$name_sec} ne '' ) {
990 1.1.1.6 christos err($id, "$name_sec also in NAME section of",
991 1.1.1.6 christos $name_map{$name_sec});
992 1.1 christos }
993 1.1 christos }
994 1.1 christos
995 1.1.1.6 christos if ( $podinfo{contents} =~ /=for openssl foreign manual (.*)\n/ ) {
996 1.1.1.6 christos foreach my $f ( split / /, $1 ) {
997 1.1.1.6 christos $name_map{$f} = ''; # It still exists!
998 1.1.1.6 christos $state{$f} = 'public'; # We assume!
999 1.1.1.6 christos }
1000 1.1.1.6 christos }
1001 1.1 christos
1002 1.1.1.6 christos my @links = ();
1003 1.1.1.6 christos # Don't use this regexp directly on $podinfo{contents}, as it causes
1004 1.1.1.6 christos # a regexp recursion, which fails on really big PODs. Instead, use
1005 1.1.1.6 christos # $markup_re to pick up general markup, and use this regexp to check
1006 1.1.1.6 christos # that the markup that was found is indeed a link.
1007 1.1.1.6 christos my $linkre = qr/L<
1008 1.1.1.6 christos # if the link is of the form L<something|name(s)>,
1009 1.1.1.6 christos # then remove 'something'. Note that 'something'
1010 1.1.1.6 christos # may contain POD codes as well...
1011 1.1.1.6 christos (?:(?:[^\|]|<[^>]*>)*\|)?
1012 1.1.1.6 christos # we're only interested in references that have
1013 1.1.1.6 christos # a one digit section number
1014 1.1.1.6 christos ([^\/>\(]+\(\d\))
1015 1.1.1.6 christos /x;
1016 1.1.1.6 christos while ( $podinfo{contents} =~ /$markup_re/msg ) {
1017 1.1.1.6 christos my $x = $1;
1018 1.1.1.6 christos
1019 1.1.1.6 christos if ($x =~ $linkre) {
1020 1.1.1.6 christos push @links, $1;
1021 1.1 christos }
1022 1.1 christos }
1023 1.1.1.6 christos $link_map{$filename} = [ @links ];
1024 1.1 christos }
1025 1.1 christos
1026 1.1.1.6 christos # Look for L<> ("link") references that point to files that do not exist.
1027 1.1.1.6 christos sub checklinks {
1028 1.1.1.6 christos foreach my $filename ( sort keys %link_map ) {
1029 1.1.1.6 christos foreach my $link ( @{$link_map{$filename}} ) {
1030 1.1.1.6 christos err("${filename}:1:", "reference to non-existing $link")
1031 1.1.1.6 christos unless defined $name_map{$link} || defined $missing{$link};
1032 1.1.1.6 christos err("${filename}:1:", "reference of internal $link in public documentation $filename")
1033 1.1.1.6 christos if ( ( ($state{$link} // '') eq 'internal'
1034 1.1.1.6 christos || ($missing{$link} // '') eq 'internal' )
1035 1.1.1.6 christos && $filename !~ /\/internal\// );
1036 1.1.1.6 christos }
1037 1.1 christos }
1038 1.1 christos }
1039 1.1 christos
1040 1.1.1.6 christos # Cipher/digests to skip if they show up as "not implemented"
1041 1.1.1.6 christos # because they are, via the "-*" construct.
1042 1.1 christos my %skips = (
1043 1.1 christos 'aes128' => 1,
1044 1.1 christos 'aes192' => 1,
1045 1.1 christos 'aes256' => 1,
1046 1.1 christos 'aria128' => 1,
1047 1.1 christos 'aria192' => 1,
1048 1.1 christos 'aria256' => 1,
1049 1.1 christos 'camellia128' => 1,
1050 1.1 christos 'camellia192' => 1,
1051 1.1 christos 'camellia256' => 1,
1052 1.1 christos 'des' => 1,
1053 1.1 christos 'des3' => 1,
1054 1.1 christos 'idea' => 1,
1055 1.1.1.6 christos 'cipher' => 1,
1056 1.1.1.6 christos 'digest' => 1,
1057 1.1 christos );
1058 1.1 christos
1059 1.1.1.6 christos my %genopts; # generic options parsed from apps/include/opt.h
1060 1.1.1.6 christos
1061 1.1.1.6 christos # Check the flags of a command and see if everything is in the manpage
1062 1.1.1.6 christos sub checkflags {
1063 1.1 christos my $cmd = shift;
1064 1.1.1.6 christos my $doc = shift;
1065 1.1.1.6 christos my @cmdopts;
1066 1.1 christos my %docopts;
1067 1.1 christos
1068 1.1.1.6 christos # Get the list of options in the command source file.
1069 1.1.1.6 christos my $active = 0;
1070 1.1.1.6 christos my $expect_helpstr = "";
1071 1.1.1.6 christos open CFH, "apps/$cmd.c"
1072 1.1.1.6 christos or die "Can't open apps/$cmd.c to list options for $cmd, $!";
1073 1.1 christos while ( <CFH> ) {
1074 1.1 christos chop;
1075 1.1.1.6 christos if ($active) {
1076 1.1.1.6 christos last if m/^\s*};/;
1077 1.1.1.6 christos if ($expect_helpstr ne "") {
1078 1.1.1.6 christos next if m/^\s*#\s*if/;
1079 1.1.1.6 christos err("$cmd does not implement help for -$expect_helpstr") unless m/^\s*"/;
1080 1.1.1.6 christos $expect_helpstr = "";
1081 1.1.1.6 christos }
1082 1.1.1.6 christos if (m/\{\s*"([^"]+)"\s*,\s*OPT_[A-Z0-9_]+\s*,\s*('[-\/:<>cEfFlMnNpsuU]'|0)(.*)$/
1083 1.1.1.6 christos && !($cmd eq "s_client" && $1 eq "wdebug")) {
1084 1.1.1.6 christos push @cmdopts, $1;
1085 1.1.1.6 christos $expect_helpstr = $1;
1086 1.1.1.6 christos $expect_helpstr = "" if $3 =~ m/^\s*,\s*"/;
1087 1.1.1.6 christos } elsif (m/[\s,](OPT_[A-Z]+_OPTIONS?)\s*(,|$)/) {
1088 1.1.1.6 christos push @cmdopts, @{ $genopts{$1} };
1089 1.1.1.6 christos }
1090 1.1.1.6 christos } elsif (m/^const\s+OPTIONS\s*/) {
1091 1.1.1.6 christos $active = 1;
1092 1.1.1.6 christos }
1093 1.1 christos }
1094 1.1 christos close CFH;
1095 1.1 christos
1096 1.1 christos # Get the list of flags from the synopsis
1097 1.1.1.6 christos open CFH, "<$doc"
1098 1.1.1.6 christos or die "Can't open $doc, $!";
1099 1.1 christos while ( <CFH> ) {
1100 1.1 christos chop;
1101 1.1 christos last if /DESCRIPTION/;
1102 1.1.1.6 christos my $opt;
1103 1.1.1.6 christos if ( /\[B<-([^ >]+)/ ) {
1104 1.1.1.6 christos $opt = $1;
1105 1.1.1.6 christos } elsif ( /^B<-([^ >]+)/ ) {
1106 1.1.1.6 christos $opt = $1;
1107 1.1.1.6 christos } else {
1108 1.1.1.6 christos next;
1109 1.1.1.6 christos }
1110 1.1.1.6 christos $opt = $1 if $opt =~ /I<(.*)/;
1111 1.1 christos $docopts{$1} = 1;
1112 1.1 christos }
1113 1.1 christos close CFH;
1114 1.1 christos
1115 1.1 christos # See what's in the command not the manpage.
1116 1.1.1.6 christos my @undocced = sort grep { !defined $docopts{$_} } @cmdopts;
1117 1.1.1.6 christos foreach ( @undocced ) {
1118 1.1.1.6 christos err("$doc: undocumented $cmd option -$_");
1119 1.1 christos }
1120 1.1 christos
1121 1.1 christos # See what's in the command not the manpage.
1122 1.1.1.6 christos my @unimpl = sort grep { my $e = $_; !(grep /^\Q$e\E$/, @cmdopts) } keys %docopts;
1123 1.1.1.6 christos foreach ( @unimpl ) {
1124 1.1.1.6 christos next if $_ eq "-"; # Skip the -- end-of-flags marker
1125 1.1.1.6 christos next if defined $skips{$_};
1126 1.1.1.6 christos err("$doc: $cmd does not implement -$_");
1127 1.1 christos }
1128 1.1 christos }
1129 1.1 christos
1130 1.1.1.6 christos ##
1131 1.1.1.6 christos ## MAIN()
1132 1.1.1.6 christos ## Do the work requested by the various getopt flags.
1133 1.1.1.6 christos ## The flags are parsed in alphabetical order, just because we have
1134 1.1.1.6 christos ## to have *some way* of listing them.
1135 1.1.1.6 christos ##
1136 1.1 christos
1137 1.1 christos if ( $opt_c ) {
1138 1.1 christos my @commands = ();
1139 1.1 christos
1140 1.1.1.6 christos # Get the lists of generic options.
1141 1.1.1.6 christos my $active = "";
1142 1.1.1.6 christos open OFH, catdir($config{sourcedir}, "apps/include/opt.h")
1143 1.1.1.6 christos or die "Can't open apps/include/opt.h to list generic options, $!";
1144 1.1.1.6 christos while ( <OFH> ) {
1145 1.1 christos chop;
1146 1.1.1.6 christos push @{ $genopts{$active} }, $1 if $active ne "" && m/^\s+\{\s*"([^"]+)"\s*,\s*OPT_/;
1147 1.1.1.6 christos $active = $1 if m/^\s*#\s*define\s+(OPT_[A-Z]+_OPTIONS?)\s*\\\s*$/;
1148 1.1.1.6 christos $active = "" if m/^\s*$/;
1149 1.1 christos }
1150 1.1.1.6 christos close OFH;
1151 1.1.1.6 christos
1152 1.1.1.6 christos # Get list of commands.
1153 1.1.1.6 christos opendir(DIR, "apps");
1154 1.1.1.6 christos @commands = grep(/\.c$/, readdir(DIR));
1155 1.1.1.6 christos closedir(DIR);
1156 1.1 christos
1157 1.1 christos # See if each has a manpage.
1158 1.1.1.6 christos foreach my $cmd ( @commands ) {
1159 1.1.1.6 christos $cmd =~ s/\.c$//;
1160 1.1.1.6 christos next if $cmd eq 'progs' || $cmd eq 'vms_decc_init';
1161 1.1.1.6 christos my @doc = ( grep { basename($_) eq "openssl-$cmd.pod"
1162 1.1.1.6 christos # For "tsget" and "CA.pl" pod pages
1163 1.1.1.6 christos || basename($_) eq "$cmd.pod" }
1164 1.1.1.6 christos files(TAGS => [ 'manual', 'man1' ]) );
1165 1.1.1.6 christos my $num = scalar @doc;
1166 1.1.1.6 christos if ($num > 1) {
1167 1.1.1.6 christos err("$num manuals for 'openssl $cmd': ".join(", ", @doc));
1168 1.1.1.6 christos } elsif ($num < 1) {
1169 1.1.1.6 christos err("no manual for 'openssl $cmd'");
1170 1.1 christos } else {
1171 1.1.1.6 christos checkflags($cmd, @doc);
1172 1.1 christos }
1173 1.1 christos }
1174 1.1.1.6 christos }
1175 1.1 christos
1176 1.1.1.6 christos # Populate %state
1177 1.1.1.6 christos loadnum('util/libcrypto.num', 'crypto');
1178 1.1.1.6 christos loadnum('util/libssl.num', 'ssl');
1179 1.1.1.6 christos loadnum('util/other.syms', 'other');
1180 1.1.1.6 christos loadnum('util/other-internal.syms');
1181 1.1.1.6 christos if ( $opt_o ) {
1182 1.1.1.6 christos loadmissing('util/missingmacro111.txt', 'crypto');
1183 1.1.1.6 christos loadmissing('util/missingcrypto111.txt', 'crypto');
1184 1.1.1.6 christos loadmissing('util/missingssl111.txt', 'ssl');
1185 1.1.1.6 christos } elsif ( !$opt_u ) {
1186 1.1.1.6 christos loadmissing('util/missingmacro.txt', 'crypto');
1187 1.1.1.6 christos loadmissing('util/missingcrypto.txt', 'crypto');
1188 1.1.1.6 christos loadmissing('util/missingssl.txt', 'ssl');
1189 1.1.1.6 christos loadmissing('util/missingcrypto-internal.txt');
1190 1.1.1.6 christos loadmissing('util/missingssl-internal.txt');
1191 1.1.1.6 christos }
1192 1.1.1.6 christos
1193 1.1.1.6 christos if ( $opt_n || $opt_l || $opt_u || $opt_v ) {
1194 1.1.1.6 christos my @files_to_read = ( $opt_n && @ARGV ) ? @ARGV : files(TAGS => 'manual');
1195 1.1.1.6 christos
1196 1.1.1.6 christos foreach (@files_to_read) {
1197 1.1.1.6 christos my %podinfo = extract_pod_info($_, { debug => $debug });
1198 1.1.1.6 christos
1199 1.1.1.6 christos collectnames(%podinfo)
1200 1.1.1.6 christos if ( $opt_l || $opt_u || $opt_v );
1201 1.1 christos
1202 1.1.1.6 christos check(%podinfo)
1203 1.1.1.6 christos if ( $opt_n );
1204 1.1.1.6 christos }
1205 1.1 christos }
1206 1.1 christos
1207 1.1 christos if ( $opt_l ) {
1208 1.1 christos checklinks();
1209 1.1 christos }
1210 1.1 christos
1211 1.1 christos if ( $opt_n ) {
1212 1.1.1.6 christos # If not given args, check that all man1 commands are named properly.
1213 1.1.1.6 christos if ( scalar @ARGV == 0 && grep /man1/, @sections ) {
1214 1.1.1.6 christos foreach ( files(TAGS => [ 'public_manual', 'man1' ]) ) {
1215 1.1.1.6 christos next if /openssl\.pod/
1216 1.1.1.6 christos || /CA\.pl/ || /tsget\.pod/; # these commands are special cases
1217 1.1.1.6 christos err("$_ doesn't start with openssl-") unless /openssl-/;
1218 1.1.1.6 christos }
1219 1.1 christos }
1220 1.1 christos }
1221 1.1 christos
1222 1.1.1.6 christos checkstate();
1223 1.1.1.6 christos
1224 1.1.1.6 christos if ( $opt_u || $opt_v) {
1225 1.1.1.6 christos printem('crypto');
1226 1.1.1.6 christos printem('ssl');
1227 1.1.1.6 christos checkmacros();
1228 1.1 christos }
1229 1.1 christos
1230 1.1.1.6 christos exit $status;
1231