]> git.ipfire.org Git - thirdparty/openssl.git/blame - util/find-doc-nits.pl
Document the issue with threads and dlopen()
[thirdparty/openssl.git] / util / find-doc-nits.pl
CommitLineData
1bc74519 1#! /usr/bin/env perl
05ea606a
RS
2# Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
3#
4# Licensed under the OpenSSL license (the "License"). You may not use
5# this file except in compliance with the License. You can obtain a copy
6# in the file LICENSE in the source distribution or at
7# https://www.openssl.org/source/license.html
8
1bc74519
RS
9
10require 5.10.0;
11use warnings;
12use strict;
13use Pod::Checker;
14use File::Find;
169a8e39 15use File::Basename;
1bc74519 16
05ea606a
RS
17my $temp = '/tmp/docnits.txt';
18my $OUT;
19
169a8e39
RL
20my %mandatory_sections =
21 ( '*' => [ 'NAME', 'DESCRIPTION', 'COPYRIGHT' ],
22 1 => [ 'SYNOPSIS', '(COMMAND\s+)?OPTIONS' ],
23 3 => [ 'SYNOPSIS', 'RETURN\s+VALUES' ],
24 5 => [ ],
25 7 => [ ] );
26my %default_sections =
27 ( apps => 1,
28 crypto => 3,
29 ssl => 3 );
30
1bc74519
RS
31sub check()
32{
169a8e39
RL
33 my $filename = shift;
34 my $dirname = basename(dirname($filename));
843666ff 35
1bc74519
RS
36 my $contents = '';
37 {
38 local $/ = undef;
169a8e39 39 open POD, $filename or die "Couldn't open $filename, $!";
1bc74519
RS
40 $contents = <POD>;
41 close POD;
42 }
843666ff
RS
43
44 my $id = "${filename}:1:";
45 print $OUT "$id doesn't start with =pod\n"
05ea606a 46 if $contents !~ /^=pod/;
843666ff 47 print $OUT "$id doesn't end with =cut\n"
05ea606a 48 if $contents !~ /=cut\n$/;
843666ff 49 print $OUT "$id more than one cut line.\n"
05ea606a 50 if $contents =~ /=cut.*=cut/ms;
843666ff 51 print $OUT "$id missing copyright\n"
05ea606a 52 if $contents !~ /Copyright .* The OpenSSL Project Authors/;
843666ff 53 print $OUT "$id copyright not last\n"
05ea606a 54 if $contents =~ /head1 COPYRIGHT.*=head/ms;
843666ff
RS
55 print $OUT "$id head2 in All uppercase\n"
56 if $contents =~ /head2\s+[A-Z ]+\n/;
bb9ad09e
RS
57 print $OUT "$id period in NAME section\n"
58 if $contents =~ /NAME.*\.\n.*SYNOPSIS/ms;
59 print $OUT "$id POD markup in NAME section\n"
60 if $contents =~ /NAME.*[<>].*SYNOPSIS/ms;
843666ff
RS
61
62 # Look for multiple consecutive openssl #include lines.
63 # Consecutive because of files like md5.pod. Sometimes it's okay
64 # or necessary, as in ssl/SSL_set1_host.pod
65 if ( $contents !~ /=for comment multiple includes/ ) {
66 if ( $contents =~ /=head1 SYNOPSIS(.*)=head1 DESCRIPTION/ms ) {
67 my $count = 0;
68 foreach my $line ( split /\n+/, $1 ) {
69 if ( $line =~ m@include <openssl/@ ) {
70 if ( ++$count == 2 ) {
71 print $OUT "$id has multiple includes\n";
72 }
73 } else {
74 $count = 0;
75 }
76 }
77 }
78 }
05ea606a 79
843666ff
RS
80 # Find what section this page is in. If run from "." assume
81 # section 3.
82 my $section = $default_sections{$dirname} || 3;
169a8e39
RL
83 if ($contents =~ /^=for\s+comment\s+openssl_manual_section:\s*(\d+)\s*$/m) {
84 $section = $1;
85 }
86
87 foreach ((@{$mandatory_sections{'*'}}, @{$mandatory_sections{$section}})) {
843666ff 88 print $OUT "$id doesn't have a head1 section matching $_\n"
169a8e39
RL
89 if $contents !~ /^=head1\s+${_}\s*$/m;
90 }
91
92 podchecker($filename, $OUT);
05ea606a 93}
1bc74519 94
05ea606a
RS
95open $OUT, '>', $temp
96 or die "Can't open $temp, $!";
97foreach (@ARGV ? @ARGV : glob('*/*.pod')) {
98 &check($_);
1bc74519 99}
05ea606a 100close $OUT;
1bc74519 101
05ea606a
RS
102my $count = 0;
103open $OUT, '<', $temp
104 or die "Can't read $temp, $!";
105while ( <$OUT> ) {
106 next if /\(section\) in.*deprecated/;
107 $count++;
108 print;
1bc74519 109}
05ea606a
RS
110close $OUT;
111unlink $temp || warn "Can't remove $temp, $!";
112
113exit $count;