our($opt_h);
our($opt_n);
our($opt_l);
+our($opt_p);
sub help()
{
-l Print bogus links
-n Print nits in POD pages
-s Also print missing sections in POD pages (implies -n)
+ -p Warn if non-public name documented (implies -n)
-u List undocumented functions
-h Print this help message
EOF
my $temp = '/tmp/docnits.txt';
my $OUT;
+my %public;
my %mandatory_sections =
( '*' => [ 'NAME', 'DESCRIPTION', 'COPYRIGHT' ],
print "$id the following exist as other .pod files:\n",
join(" ", sort keys %foundfilenames), "\n"
if %foundfilenames;
- print "$id $simplename (filename) missing from NAME section\n",
+ print "$id $simplename (filename) missing from NAME section\n"
unless $foundfilename;
+ foreach my $n ( keys %names ) {
+ print "$id $n is not public\n"
+ if $opt_p and !defined $public{$n};
+ }
# Find all functions in SYNOPSIS
return unless $contents =~ /=head1 SYNOPSIS(.*)=head1 DESCRIPTION/ms;
print "$id Bad =over $1\n"
if $contents =~ /=over([^ ][^24])/;
- # Look for multiple consecutive openssl #include lines.
- # Consecutive because of files like md5.pod. Sometimes it's okay
- # or necessary, as in ssl/SSL_set1_host.pod
if ( $contents !~ /=for comment multiple includes/ ) {
+ # Look for multiple consecutive openssl #include lines
+ # (non-consecutive lines are okay; see man3/MD5.pod).
if ( $contents =~ /=head1 SYNOPSIS(.*)=head1 DESCRIPTION/ms ) {
my $count = 0;
foreach my $line ( split /\n+/, $1 ) {
if ( $line =~ m@include <openssl/@ ) {
- if ( ++$count == 2 ) {
- print "$id has multiple includes\n";
- }
+ print "$id has multiple includes\n" if ++$count == 2;
} else {
$count = 0;
}
}
}
- return unless $opt_s;
-
- # Find what section this page is in. If run from "." assume
- # section 3.
- my $section = 3;
- $section = $1 if $dirname =~ /man([1-9])/;
-
- foreach ((@{$mandatory_sections{'*'}}, @{$mandatory_sections{$section}})) {
- print "$id: missing $_ head1 section\n"
- if $contents !~ /^=head1\s+${_}\s*$/m;
- }
-
open my $OUT, '>', $temp
or die "Can't open $temp, $!";
podchecker($filename, $OUT);
}
close $OUT;
unlink $temp || warn "Can't remove $temp, $!";
+
+ # Find what section this page is in; assume 3.
+ my $section = 3;
+ $section = $1 if $dirname =~ /man([1-9])/;
+
+ foreach ((@{$mandatory_sections{'*'}}, @{$mandatory_sections{$section}})) {
+ # Skip "return values" if not -s
+ next if $_ eq 'RETURN VALUES' and not $opt_s;
+ print "$id: missing $_ head1 section\n"
+ if $contents !~ /^=head1\s+${_}\s*$/m;
+ }
}
my %dups;
or die "Can't open $file, $!, stopped";
while ( <$IN> ) {
+ next if /^#/;
next if /\bNOEXIST\b/;
next if /\bEXPORT_VAR_AS_FUNC\b/;
- push @apis, $1 if /([^\s]+).\s/;
+ my @fields = split();
+ die "Malformed line $_"
+ if scalar @fields != 2 && scalar @fields != 4;
+ push @apis, $fields[0];
}
close $IN;
- print "# Found ", scalar(@apis), " in $file\n";
+ print "# Found ", scalar(@apis), " in $file\n" unless $opt_p;
return sort @apis;
}
my %docced;
+sub checkmacros()
+{
+ my $count = 0;
+
+ print "# Checking macros (approximate)\n";
+ foreach my $f ( glob('include/openssl/*.h') ) {
+ # Skip some internals we don't want to document yet.
+ next if $f eq 'include/openssl/asn1.h';
+ next if $f eq 'include/openssl/asn1t.h';
+ next if $f eq 'include/openssl/err.h';
+ open(IN, $f) || die "Can't open $f, $!";
+ while ( <IN> ) {
+ next unless /^#\s*define\s*(\S+)\(/;
+ my $macro = $1;
+ next if $docced{$macro};
+ next if $macro =~ /i2d_/
+ || $macro =~ /d2i_/
+ || $macro =~ /DEPRECATEDIN/
+ || $macro =~ /IMPLEMENT_/
+ || $macro =~ /DECLARE_/;
+ print "$f:$macro\n";
+ $count++;
+ }
+ close(IN);
+ }
+ print "# Found $count macros missing (not all should be documnted)\n"
+}
+
sub printem()
{
my $libname = shift;
}
}
-getopts('lnshu');
+sub publicize() {
+ foreach my $name ( &parsenum('util/libcrypto.num') ) {
+ $public{$name} = 1;
+ }
+ foreach my $name ( &parsenum('util/libssl.num') ) {
+ $public{$name} = 1;
+ }
+ foreach my $name ( &parsenum('util/private.num') ) {
+ $public{$name} = 1;
+ }
+}
+
+getopts('lnsphu');
+
+&help() if $opt_h;
-&help() if ( $opt_h );
+die "Need one of -l -n -s -p or -u flags.\n"
+ unless $opt_l or $opt_n or $opt_s or $opt_p or $opt_u;
-die "Need one of -l -n -s or -u flags.\n"
- unless $opt_l or $opt_n or $opt_s or $opt_u;
+$opt_n = 1 if $opt_s or $opt_p;
-if ( $opt_n or $opt_s ) {
+if ( $opt_n ) {
+ &publicize() if $opt_p;
foreach (@ARGV ? @ARGV : glob('doc/*/*.pod')) {
&check($_);
}
}
&printem('crypto', 'util/libcrypto.num');
&printem('ssl', 'util/libssl.num');
+ &checkmacros();
}
exit;