From: Richard Levitte Date: Wed, 15 Jul 2020 06:42:18 +0000 (+0200) Subject: util/find-doc-nits: relax some SYNOPSIS checks X-Git-Tag: openssl-3.0.0-alpha6~103 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=93e32043cbf75d0802bca9782e61a241acb1ec2d;p=thirdparty%2Fopenssl.git util/find-doc-nits: relax some SYNOPSIS checks - The check that disallowed space before the argument list in a function typedef is tentatively removed, allowing this kind of construction: typedef int (fantastically_long_name_breaks_80char_limit) (fantastically_long_name_breaks_80char_limit *something); - Accept the following style of function signature: typedef TYPE (NAME)(args...) - Accept space between '#' and 'defined' / 'undef' - Accept other spaces than SPC in argument list comma check, allowing declaration with line breaks. Reviewed-by: Tomas Mraz Reviewed-by: Shane Lontis (Merged from https://github.com/openssl/openssl/pull/12452) --- diff --git a/util/find-doc-nits b/util/find-doc-nits index bcae76e4834..c82e647bf5e 100755 --- a/util/find-doc-nits +++ b/util/find-doc-nits @@ -332,16 +332,26 @@ sub name_synopsis { $line =~ s/STACK_OF\([^)]+\)/int/g; $line =~ s/SPARSE_ARRAY_OF\([^)]+\)/int/g; $line =~ s/__declspec\([^)]+\)//; - if ( $line =~ /typedef.*\(\*\S+\)\s+\(/ ) { - # a callback function with whitespace before the argument list: - # typedef ... (*NAME) (... - err($id, "Function typedef has space before arg list: $line"); - } + + ## We don't prohibit that space, to allow typedefs looking like + ## this: + ## + ## typedef int (fantastically_long_name_breaks_80char_limit) + ## (fantastically_long_name_breaks_80char_limit *something); + ## + #if ( $line =~ /typedef.*\(\*?\S+\)\s+\(/ ) { + # # a callback function with whitespace before the argument list: + # # typedef ... (*NAME) (... + # # typedef ... (NAME) (... + # err($id, "Function typedef has space before arg list: $line"); + #} + if ( $line =~ /env (\S*)=/ ) { # environment variable env NAME=... $sym = $1; - } elsif ( $line =~ /typedef.*\(\*(\S+)\)\s*\(/ ) { + } elsif ( $line =~ /typedef.*\(\*?(\S+)\)\s*\(/ ) { # a callback function pointer: typedef ... (*NAME)(... + # a callback function signature: typedef ... (NAME)(... $sym = $1; } elsif ( $line =~ /typedef.* (\S+)\(/ ) { # a callback function signature: typedef ... NAME(... @@ -353,7 +363,7 @@ sub name_synopsis { } elsif ( $line =~ /enum (\S*) \{/ ) { # an enumeration: enum ... { $sym = $1; - } elsif ( $line =~ /#(?:define|undef) ([A-Za-z0-9_]+)/ ) { + } elsif ( $line =~ /#\s*(?:define|undef) ([A-Za-z0-9_]+)/ ) { $is_prototype = 0; $sym = $1; } elsif ( $line =~ /([A-Za-z0-9_]+)\(/ ) { @@ -368,7 +378,7 @@ sub name_synopsis { # Do some sanity checks on the prototype. err($id, "Prototype missing spaces around commas: $line") - if $is_prototype && $line =~ /[a-z0-9],[^ ]/; + if $is_prototype && $line =~ /[a-z0-9],[^\s]/; } foreach my $n ( keys %names ) {