Make update
[openssl.git] / util / find-undoc-api.pl
1 #! /usr/bin/env perl
2 # Copyright 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
9 use strict;
10 use warnings;
11
12 use File::Spec::Functions;
13 use File::Basename;
14 #use File::Copy;
15 #use File::Path;
16 use lib catdir(dirname($0), "perl");
17 use OpenSSL::Util::Pod;
18
19 my %dups;
20
21 sub parsenum()
22 {
23     my $file = shift;
24     my @apis;
25
26     open my $IN, '<', $file
27         or die "Can't open $file, $!, stopped";
28
29     while ( <$IN> ) {
30         next if /\sNOEXIST/;
31         next if /EXPORT_VAR_AS_FUNC/;
32         push @apis, $1 if /([^\s]+).\s/;
33     }
34
35     close $IN;
36
37     print "# Found ", scalar(@apis), " in $file\n";
38     return sort @apis;
39 }
40
41 sub getdocced()
42 {
43     my $dir = shift;
44     my %return;
45
46     foreach my $pod ( glob("$dir/*.pod") ) {
47         next if $pod eq 'doc/crypto/crypto.pod';
48         next if $pod eq 'doc/ssl/ssl.pod';
49         my %podinfo = extract_pod_info($pod);
50         foreach my $n ( @{$podinfo{names}} ) {
51             $return{$n} = $pod;
52             print "# Duplicate $n in $pod and $dups{$n}\n"
53                 if defined $dups{$n};
54             $dups{$n} = $pod;
55         }
56     }
57
58     return %return;
59 }
60
61 sub printem()
62 {
63     my $docdir = shift;
64     my $numfile = shift;
65     my %docced = &getdocced($docdir);
66     my $count = 0;
67
68     foreach my $func ( &parsenum($numfile) ) {
69         next if $docced{$func};
70
71         # Skip ASN1 utilities
72         next if $func =~ /^ASN1_/;
73
74         print $func, "\n";
75         $count++;
76     }
77     print "# Found $count missing from $numfile\n\n";
78 }
79
80
81 &printem('doc/crypto', 'util/libcrypto.num');
82 &printem('doc/ssl', 'util/libssl.num');