From 2c55d791282e5a7cbba27f13137037f542855b29 Mon Sep 17 00:00:00 2001 From: Alexandre Gautier Date: Sat, 26 Nov 2016 21:28:56 +0300 Subject: [PATCH] Fix: Function protoyypes with gcc attribute detection --- betty-doc.pl | 11 ++++++++--- tests/doc/doc10.c | 23 +++++++++++++++++++++++ tests/doc/doc10.expected.stderr | 0 tests/doc/doc10.expected.stdout | 3 +++ 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 tests/doc/doc10.c create mode 100644 tests/doc/doc10.expected.stderr create mode 100644 tests/doc/doc10.expected.stdout diff --git a/betty-doc.pl b/betty-doc.pl index ebce5cb..d1dd128 100755 --- a/betty-doc.pl +++ b/betty-doc.pl @@ -2831,7 +2831,9 @@ ($) $_ .= ; } - if ($_ =~ /^(?:typedef\s+)?(?:(?:$Storage|$Inline)\s*)*\s*$Type\s*\(?\**($Ident)\s*\(/s && + my $attr = qr{__attribute__\s*\(\(\w+\)\)}; + + if ($_ =~ /^(?:typedef\s+)?(?:(?:$Storage|$Inline)\s*)*\s*$Type\s*(?:$attr\s*)?\(?\**($Ident)\s*\(/s && $_ !~ /;\s*$/) { # print STDOUT "Function found: $1\n"; @@ -2839,8 +2841,7 @@ ($) print STDERR "${file}:$.: warning: no description found for function $1\n"; ++$warnings; } - elsif ($_ =~ /^(?:(?:$Storage|$Inline)\s*)*\s*($Type)\s*\(\**($Ident)\s*\((.*)\)\)\s*\(/s) - { + elsif ($_ =~ /^(?:(?:$Storage|$Inline)\s*)*\s*($Type)\s*\(\**($Ident)\s*\((.*)\)\)\s*\(/s) { my $type_ = $1; my $func_ = $2; my $params_ = $3; @@ -2848,6 +2849,10 @@ ($) # print "LINE:$_\n"; # print "FUNCTION -> ${type_} ${func_} (${params_})\n"; } + elsif ($_ =~ $attr) { + $_ =~ s/__attribute__\s*\(\(\w+\)\)//; + # print "LINE:$_\n"; + } } if ($_ =~ /^\s*(?:typedef\s+)?(enum|union|struct)(?:\s+($Ident))?\s*.*/s && diff --git a/tests/doc/doc10.c b/tests/doc/doc10.c new file mode 100644 index 0000000..498ff41 --- /dev/null +++ b/tests/doc/doc10.c @@ -0,0 +1,23 @@ +/** + * first - Called before main + */ +void __attribute__((constructor)) first(void) +{ + printf("test\n"); +} + +/** + * first - Called before main + */ +void __attribute__ ((constructor)) first(void) +{ + printf("test\n"); +} + +/** + * first - Called before main + */ +void __attribute__((constructor))first(void) +{ + printf("test\n"); +} diff --git a/tests/doc/doc10.expected.stderr b/tests/doc/doc10.expected.stderr new file mode 100644 index 0000000..e69de29 diff --git a/tests/doc/doc10.expected.stdout b/tests/doc/doc10.expected.stdout new file mode 100644 index 0000000..58c601e --- /dev/null +++ b/tests/doc/doc10.expected.stdout @@ -0,0 +1,3 @@ +first +first +first