find-undoc-api.pl 1.7 KB
Newer Older
R
Rich Salz 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
#! /usr/bin/env perl
# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the OpenSSL license (the "License").  You may not use
# this file except in compliance with the License.  You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html

use strict;
use warnings;

use File::Spec::Functions;
use File::Basename;
#use File::Copy;
#use File::Path;
use lib catdir(dirname($0), "perl");
use OpenSSL::Util::Pod;

my %dups;

sub parsenum()
{
    my $file = shift;
    my @apis;

    open my $IN, '<', $file
        or die "Can't open $file, $!, stopped";

    while ( <$IN> ) {
        next if /\sNOEXIST/;
        next if /EXPORT_VAR_AS_FUNC/;
        push @apis, $1 if /([^\s]+).\s/;
    }

    close $IN;

    print "# Found ", scalar(@apis), " in $file\n";
    return sort @apis;
}

sub getdocced()
{
    my $dir = shift;
    my %return;

    foreach my $pod ( glob("$dir/*.pod") ) {
        my %podinfo = extract_pod_info($pod);
        foreach my $n ( @{$podinfo{names}} ) {
            $return{$n} = $pod;
            print "# Duplicate $n in $pod and $dups{$n}\n"
R
Rich Salz 已提交
51
                if defined $dups{$n} && $dups{$n} ne $pod;
R
Rich Salz 已提交
52 53 54 55 56 57 58
            $dups{$n} = $pod;
        }
    }

    return %return;
}

R
Rich Salz 已提交
59 60
my %docced = &getdocced('doc/man3');

R
Rich Salz 已提交
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
sub printem()
{
    my $numfile = shift;
    my $count = 0;

    foreach my $func ( &parsenum($numfile) ) {
        next if $docced{$func};

        # Skip ASN1 utilities
        next if $func =~ /^ASN1_/;

        print $func, "\n";
        $count++;
    }
    print "# Found $count missing from $numfile\n\n";
}

R
Rich Salz 已提交
78 79
&printem('util/libcrypto.num');
&printem('util/libssl.num');