aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2020-07-20 17:10:44 +0200
committerRichard Levitte <levitte@openssl.org>2020-07-21 18:52:29 +0200
commit8eca461731feb25b94ccf181e76ec2723e27769a (patch)
treedad96bce52be16415249ede2839db2d9d4793c6b /util
parent904f42509f8d5e6210113e49a7e41ed2b1dd5a81 (diff)
downloadopenssl-8eca461731feb25b94ccf181e76ec2723e27769a.zip
openssl-8eca461731feb25b94ccf181e76ec2723e27769a.tar.gz
openssl-8eca461731feb25b94ccf181e76ec2723e27769a.tar.bz2
util/find-doc-nits: Relax check of function declarations in name_synopsis()
The relaxation allows spaces between function name and argument list, to allow line breaks like this when there are very long names: int (fantastically_long_name_breaks_80char_limit) (fantastically_long_name_breaks_80char_limit *something); This revealed some other intricaties, such as documented internal structures with function pointers inside, so a check of open structures was also added, and they are now simply skipped over. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/12494)
Diffstat (limited to 'util')
-rwxr-xr-xutil/find-doc-nits25
1 files changed, 23 insertions, 2 deletions
diff --git a/util/find-doc-nits b/util/find-doc-nits
index c82e647..3558180 100755
--- a/util/find-doc-nits
+++ b/util/find-doc-nits
@@ -311,6 +311,7 @@ sub name_synopsis {
# Find all functions in SYNOPSIS
return unless $contents =~ /=head1 SYNOPSIS(.*)=head1 DESCRIPTION/ms;
my $syn = $1;
+ my $ignore_until = undef; # If defined, this is a regexp
# Remove all non-code lines
$syn =~ s/^(?:\s*?|\S.*?)$//msg;
# Remove all comments
@@ -327,6 +328,19 @@ sub name_synopsis {
my $line = $1;
$syn = $';
+ print STDERR "DEBUG[name_synopsis] \$line = '$line'\n" if $debug;
+
+ # Special code to skip over documented structures
+ if ( defined $ignore_until) {
+ next if $line !~ /$ignore_until/;
+ $ignore_until = undef;
+ next;
+ }
+ if ( $line =~ /^\s*(?:typedef\s+)?struct(?:\s+\S+)\s*\{/ ) {
+ $ignore_until = qr/\}.*?;/;
+ next;
+ }
+
my $sym;
my $is_prototype = 1;
$line =~ s/STACK_OF\([^)]+\)/int/g;
@@ -353,7 +367,7 @@ sub name_synopsis {
# a callback function pointer: typedef ... (*NAME)(...
# a callback function signature: typedef ... (NAME)(...
$sym = $1;
- } elsif ( $line =~ /typedef.* (\S+)\(/ ) {
+ } elsif ( $line =~ /typedef.* (\S+)\s*\(/ ) {
# a callback function signature: typedef ... NAME(...
$sym = $1;
} elsif ( $line =~ /typedef.* (\S+);/ ) {
@@ -366,12 +380,19 @@ sub name_synopsis {
} elsif ( $line =~ /#\s*(?:define|undef) ([A-Za-z0-9_]+)/ ) {
$is_prototype = 0;
$sym = $1;
- } elsif ( $line =~ /([A-Za-z0-9_]+)\(/ ) {
+ } elsif ( $line =~ /^[^\(]*?\(\*([A-Za-z0-9_]+)\s*\(/ ) {
+ # a function returning a function pointer: TYPE (*NAME(args))(args)
+ $sym = $1;
+ } elsif ( $line =~ /^[^\(]*?([A-Za-z0-9_]+)\s*\(/ ) {
+ # a simple function declaration
$sym = $1;
}
else {
next;
}
+
+ print STDERR "DEBUG[name_synopsis] \$sym = '$sym'\n" if $debug;
+
err($id, "$sym missing from NAME section")
unless defined $names{$sym};
$names{$sym} = 2;