From b1415dc1820def1e9e344f9b83ad05c2a352ec56 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Tue, 15 Sep 2020 10:02:34 +0200 Subject: util/find-doc-nits: Add a regexp for C symbols and use it Our matching of C symbols here was inconsistent and could therefore give false negatives when the SYNOPSIS was parsed. Now we have $C_symbol, which is a simple regexp that matches the common C symbol. Reviewed-by: Shane Lontis (Merged from https://github.com/openssl/openssl/pull/12873) --- util/find-doc-nits | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'util') diff --git a/util/find-doc-nits b/util/find-doc-nits index ac661827dd..d614844952 100755 --- a/util/find-doc-nits +++ b/util/find-doc-nits @@ -104,6 +104,9 @@ my $ignored = qr/(?| ^i2d_ | ^DEFINE_LHASH_OF_INTERNAL )/x; +# A common regexp for C symbol names +my $C_symbol = qr/\b[[:alpha:]][_[:alnum:]]*\b/; + # Collect all POD files, both internal and public, and regardless of location # We collect them in a hash table with each file being a key, so we can attach # tags to them. For example, internal docs will have the word "internal" @@ -367,27 +370,27 @@ sub name_synopsis { if ( $line =~ /env (\S*)=/ ) { # environment variable env NAME=... $sym = $1; - } elsif ( $line =~ /typedef.*\(\*?(\S+)\)\s*\(/ ) { + } elsif ( $line =~ /typedef.*\(\*?($C_symbol)\)\s*\(/ ) { # a callback function pointer: typedef ... (*NAME)(... # a callback function signature: typedef ... (NAME)(... $sym = $1; - } elsif ( $line =~ /typedef.* (\S+)\s*\(/ ) { + } elsif ( $line =~ /typedef.*($C_symbol)\s*\(/ ) { # a callback function signature: typedef ... NAME(... $sym = $1; - } elsif ( $line =~ /typedef.* (\S+);/ ) { + } elsif ( $line =~ /typedef.*($C_symbol);/ ) { # a simple typedef: typedef ... NAME; $is_prototype = 0; $sym = $1; - } elsif ( $line =~ /enum (\S*) \{/ ) { + } elsif ( $line =~ /enum ($C_symbol) \{/ ) { # an enumeration: enum ... { $sym = $1; - } elsif ( $line =~ /#\s*(?:define|undef) ([A-Za-z0-9_]+)/ ) { + } elsif ( $line =~ /#\s*(?:define|undef) ($C_symbol)/ ) { $is_prototype = 0; $sym = $1; - } elsif ( $line =~ /^[^\(]*?\(\*([A-Za-z0-9_]+)\s*\(/ ) { + } elsif ( $line =~ /^[^\(]*?\(\*($C_symbol)\s*\(/ ) { # a function returning a function pointer: TYPE (*NAME(args))(args) $sym = $1; - } elsif ( $line =~ /^[^\(]*?([A-Za-z0-9_]+)\s*\(/ ) { + } elsif ( $line =~ /^[^\(]*?($C_symbol)\s*\(/ ) { # a simple function declaration $sym = $1; } -- cgit v1.2.3