From 4cfc71cd836d73b15254f73f58d8fd5f85fcc1f6 Mon Sep 17 00:00:00 2001 From: Maarten Bosmans Date: Mon, 10 Jan 2011 14:35:16 +0200 Subject: [PATCH] parsing: improve parsing of arguments The 'const' in a 'const unsigned char *xxx' parameter was dropped. Add test-case as well. Fixes #638330. --- gtkdoc-common.pl.in | 28 ++++++++++++++-------------- tests/bugs/docs/tester-sections.txt | 1 + tests/bugs/src/tester.c | 26 +++++++++++++++++++------- tests/bugs/src/tester.h | 10 +++++++--- 4 files changed, 41 insertions(+), 24 deletions(-) diff --git a/gtkdoc-common.pl.in b/gtkdoc-common.pl.in index 23d851c..4e5670d 100644 --- a/gtkdoc-common.pl.in +++ b/gtkdoc-common.pl.in @@ -128,7 +128,7 @@ sub ParseStructDeclaration { if (!scalar($declaration =~ m/(?:struct|union)\s+\w*\s*\{/msg)) { die "Declaration '$declaration' does not begin with struct/union [NAME] {\n"; } - + #print "DEBUG: public fields in struct/union: $declaration\n"; # Treat lines in sequence, allowing singly nested anonymous structs @@ -140,7 +140,7 @@ sub ParseStructDeclaration { # FIXME: Just ignore nested structs and unions for now next if $line =~ /{/; - + # ignore preprocessor directives while ($line =~ /^#.*?\n\s*(.*)/msg) { $line=$1; @@ -252,7 +252,7 @@ sub ParseEnumDeclaration { if ($declaration =~ m/enum\s+\S+\s*;/msg) { return (); } - + # Remove private symbols # Assume end of declaration if line begins with '}' $declaration =~ s!\n?[ \t]*/\*\s*<\s*(private|protected)\s*>\s*\*/.*?(?:/\*\s*<\s*public\s*>\s*\*/|(?=^\}))!!msgx; @@ -274,7 +274,7 @@ sub ParseEnumDeclaration { $declaration =~ s/\([^)]+\)//g; # Remove comma from comma - possible whitespace - closing brace sequence - # since it is legal in GNU C and C99 to have a trailing comma but doesn't + # since it is legal in GNU C and C99 to have a trailing comma but doesn't # result in an actual enum member $declaration =~ s/,(\s*})/$1/g; @@ -293,7 +293,7 @@ sub ParseEnumDeclaration { while ($line =~ /^#.*?\n\s*(.*)/msg) { $line=$1; } - + if ($line =~ m/^(\w+)\s*(=.*)?$/msg) { push @result, $1; @@ -332,9 +332,9 @@ sub ParseEnumDeclaration { sub ParseFunctionDeclaration { my ($declaration, $typefunc, $namefunc) = @_; - + my @result = (); - + my ($param_num) = 0; while ($declaration ne "") { #print "$declaration"; @@ -360,8 +360,8 @@ sub ParseFunctionDeclaration { # allow alphanumerics, '_', '[' & ']' in param names # Try to match a standard parameter - # $1 $2 $3 $4 $5 - } elsif ($declaration =~ s/^\s*((?:G_CONST_RETURN|G_GNUC_[A-Z_]+\s+|unsigned long|unsigned short|signed long|signed short|unsigned|signed|long|short|volatile|const)\s+)*((?:struct\b|enum\b)?\s*\w+)\s*((?:(?:const\b|restrict\b|G_GNUC_[A-Z_]+\b)?\s*\*?\s*(?:const\b|restrict\b|G_GNUC_[A-Z_]+\b)?\s*)*)(\w+)?\s*((?:\[\S*\])*)\s*[,\n]//) { + # $1 $2 $3 $4 $5 + } elsif ($declaration =~ s/^\s*((?:(?:G_CONST_RETURN|G_GNUC_[A-Z_]+\s+|unsigned long|unsigned short|signed long|signed short|unsigned|signed|long|short|volatile|const)\s+)*)((?:struct\b|enum\b)?\s*\w+)\s*((?:(?:const\b|restrict\b|G_GNUC_[A-Z_]+\b)?\s*\*?\s*(?:const\b|restrict\b|G_GNUC_[A-Z_]+\b)?\s*)*)(\w+)?\s*((?:\[\S*\])*)\s*[,\n]//) { my $pre = defined($1) ? $1 : ""; my $type = $2; my $ptr = defined($3) ? $3 : ""; @@ -407,7 +407,7 @@ sub ParseFunctionDeclaration { my $func_ptr = $6; my $name = $7; my $func_params = defined($8) ? $8 : ""; - + #if (!defined($type)) { print "## no type\n"; }; #if (!defined($ptr1)) { print "## no ptr1\n"; }; #if (!defined($func_ptr)) { print "## no func_ptr\n"; }; @@ -445,12 +445,12 @@ sub ParseFunctionDeclaration { sub ParseMacroDeclaration { my ($declaration, $namefunc) = @_; - + my @result = (); if ($declaration =~ m/^\s*#\s*define\s+\w+\(([^\)]*)\)/) { my $params = $1; - + $params =~ s/\\\n//g; foreach $param (split (/,/, $params)) { $param =~ s/^\s+//; @@ -476,10 +476,10 @@ sub ParseMacroDeclaration { sub LogWarning { my ($file, $line, $message) = @_; - + $file="unknown" if !defined($file); $line="0" if !defined($line); - + print "$file:$line: warning: $message\n" } diff --git a/tests/bugs/docs/tester-sections.txt b/tests/bugs/docs/tester-sections.txt index fcf5a67..2733769 100644 --- a/tests/bugs/docs/tester-sections.txt +++ b/tests/bugs/docs/tester-sections.txt @@ -46,6 +46,7 @@ bug_623968b bug_623968c bug_624200a bug_624200b +bug_638330 GTKDOC_GNUC_CONST diff --git a/tests/bugs/src/tester.c b/tests/bugs/src/tester.c index cde05da..01f3d52 100644 --- a/tests/bugs/src/tester.c +++ b/tests/bugs/src/tester.c @@ -253,11 +253,11 @@ bug_610257(const unsigned char *der, int *len) /** * bug_623968a: - * + * * test * * subsect - * test + * test * **/ void @@ -267,12 +267,12 @@ bug_623968a(void) /** * bug_623968b: - * + * * test * * * subsect - * test + * test * **/ void @@ -282,7 +282,7 @@ bug_623968b(void) /** * bug_623968c: - * + * * test **/ void @@ -295,7 +295,7 @@ bug_623968c(void) * bug_624200a: * * http://bugzilla.gnome.org/show_bug.cgi?id=624200 - * + * * Returns: result */ const char * const * @@ -308,7 +308,7 @@ bug_624200a(void) * bug_624200b: * * http://bugzilla.gnome.org/show_bug.cgi?id=624200 - * + * * Returns: result */ const char ** const @@ -317,6 +317,18 @@ bug_624200b(void) return NULL; } +/** + * bug_638330: + * @arg1: arg1 + * @data: data + * @length: length + * + * http://bugzilla.gnome.org/show_bug.cgi?id=638330 + */ +void (*bug_638330) (void *arg1, + const unsigned char *data, + unsigned int length) = NULL; + /* internal function */ gchar * diff --git a/tests/bugs/src/tester.h b/tests/bugs/src/tester.h index 92aba94..a61b051 100644 --- a/tests/bugs/src/tester.h +++ b/tests/bugs/src/tester.h @@ -21,7 +21,7 @@ typedef enum { -/** +/** * bug_481811: * @x: argument * @@ -169,7 +169,7 @@ typedef int (*bug_512155c_function_pointer_t) (unsigned int arg1, * BUG_530758: * * - * + * * Test */ #define BUG_530758 "dummy" @@ -262,7 +262,7 @@ unsigned int bug_602518c(void); */ union _Bug165425a { int i; - float f; + float f; }; typedef union _Bug165425a Bug165425a; @@ -334,5 +334,9 @@ gchar *_bug_000000a (const gchar *name); extern int bug_512565(void); #endif +void (*bug_638330) (void *arg1, + const unsigned char *data, + unsigned int length); + #endif // GTKDOC_TESTER_H -- 2.11.4.GIT