[gtk-doc] scan: improve reexps to handle more * const * variants. Fixes #624200



commit 2085444674726557e45b251a4768d08e72623598
Author: Stefan Kost <ensonic users sf net>
Date:   Tue Jul 13 11:13:51 2010 +0300

    scan: improve reexps to handle more * const * variants. Fixes #624200
    
    We were handling that correctly for the case of split line declarations. Take
    the same route if all is one one line. Add tests.

 gtkdoc-scan.in                      |   16 ++++++++--------
 tests/bugs/docs/tester-sections.txt |    2 ++
 tests/bugs/src/tester.c             |   24 +++++++++++++++++++++++-
 tests/bugs/src/tester.h             |    4 ++++
 4 files changed, 37 insertions(+), 9 deletions(-)
---
diff --git a/gtkdoc-scan.in b/gtkdoc-scan.in
index f243ce5..c93473f 100755
--- a/gtkdoc-scan.in
+++ b/gtkdoc-scan.in
@@ -524,16 +524,16 @@ sub ScanHeader {
 
 	    # We assume that functions which start with '_' are private, so
 	    # we skip them.
-	    #                                                                       $1                                                                                                                                                             $2
-	    } elsif (m/^\s*(?:\b(?:extern|G_INLINE_FUNC|${IGNORE_DECORATORS})\b\s*)*((?:const\s+|G_CONST_RETURN\s+|signed\s+|unsigned\s+|long\s+|short\s+|struct\s+|union\s+|enum\s+)*_\w+(?:\**\s+\**(?:const|G_CONST_RETURN))?(?:\s+|\s*\*+))\s*\(\s*\*+\s*([A-Za-z]\w*)\s*\)\s*\(/o) {
+	    #                                                                       $1                                                                                                                                                     $2
+	    } elsif (m/^\s*(?:\b(?:extern|G_INLINE_FUNC|${IGNORE_DECORATORS})\b\s*)*((?:const\s+|G_CONST_RETURN\s+|signed\s+|unsigned\s+|long\s+|short\s+|struct\s+|union\s+|enum\s+)*_\w+(?:\s*(?:\*+|\bconst\b|\bG_CONST_RETURN\b))*)\s*\(\s*\*+\s*([A-Za-z]\w*)\s*\)\s*\(/o) {
 		$ret_type = $1;
 		$symbol = $2;
 		$decl = $';
 		#print "DEBUG: internal Function: $symbol, Returns: $ret_type\n";
 		$in_declaration = "function";
 
-	    #                                                                       $1                                                                                                                                                 $2
-	    } elsif (m/^\s*(?:\b(?:extern|G_INLINE_FUNC|${IGNORE_DECORATORS})\b\s*)*((?:const\s+|G_CONST_RETURN\s+|signed\s+|unsigned\s+|long\s+|short\s+|struct\s+|union\s+|enum\s+)*\w+(?:\**\s+\**(?:const|G_CONST_RETURN))?(?:\s+|\s*\*+))\s*([A-Za-z]\w*)\s*\(/o) {
+	    #                                                                       $1                                                                                                                                                   $2
+	    } elsif (m/^\s*(?:\b(?:extern|G_INLINE_FUNC|${IGNORE_DECORATORS})\b\s*)*((?:const\s+|G_CONST_RETURN\s+|signed\s+|unsigned\s+|long\s+|short\s+|struct\s+|union\s+|enum\s+)*\w+(?:\s*(?:\*+|\bconst\b|\bG_CONST_RETURN\b))*)\s*([A-Za-z]\w*)\s*\(/o) {
 		$ret_type = $1;
 		$symbol = $2;
 		$decl = $';
@@ -550,8 +550,8 @@ sub ScanHeader {
 
 		if ($previous_line !~ m/^\s*G_INLINE_FUNC/) {
 		    if ($previous_line !~ m/^\s*static\s+/) {
-                        #                                                                       $1                                                                         $2
-                        if ($previous_line =~ m/^\s*(?:\b(?:extern|${IGNORE_DECORATORS})\b\s*)*((?:const\s+|G_CONST_RETURN\s+|signed\s+|unsigned\s+|struct\s+|union\s+|enum\s+)?\w+)((?:\s*(?:\*+|\bconst\b|\bG_CONST_RETURN\b))*)\s*$/o) {
+                        #                                                                       $1                                                                                                   $2
+                        if ($previous_line =~ m/^\s*(?:\b(?:extern|${IGNORE_DECORATORS})\b\s*)*((?:const\s+|G_CONST_RETURN\s+|signed\s+|unsigned\s+|long\s+|short\s+|struct\s+|union\s+|enum\s+)?\w+)((?:\s*(?:\*+|\bconst\b|\bG_CONST_RETURN\b))*)\s*$/o) {
                             $ret_type = $1;
                             if (defined ($2)) { $ret_type .= " $2"; }
                             #print "DEBUG: Function  (2): $symbol, Returns: $ret_type\n";
@@ -564,8 +564,8 @@ sub ScanHeader {
                         #print "DEBUG: skip block after inline function\n";
                         # now we we need to skip a whole { } block
                         $skip_block = 1;
-                        #                                                                       $1                                                                         $2
-                        if ($previous_line =~ m/^\s*(?:\b(?:extern|G_INLINE_FUNC|${IGNORE_DECORATORS})\b\s*)*((?:const\s+|G_CONST_RETURN\s+|signed\s+|unsigned\s+|struct\s+|union\s+|enum\s+)?\w+)((?:\s*(?:\*+|\bconst\b|\bG_CONST_RETURN\b))*)\s*$/o) {
+                        #                                                                                    $1                                                                                                    $2
+                        if ($previous_line =~ m/^\s*(?:\b(?:extern|G_INLINE_FUNC|${IGNORE_DECORATORS})\b\s*)*((?:const\s+|G_CONST_RETURN\s+|signed\s+|unsigned\s+|long\s+|short\s+|struct\s+|union\s+|enum\s+)?\w+)((?:\s*(?:\*+|\bconst\b|\bG_CONST_RETURN\b))*)\s*$/o) {
                             $ret_type = $1;
                             if (defined ($2)) { $ret_type .= " $2"; }
                             #print "DEBUG: Function (3): $symbol, Returns: $ret_type\n";
diff --git a/tests/bugs/docs/tester-sections.txt b/tests/bugs/docs/tester-sections.txt
index 26f0fd3..ed2910e 100644
--- a/tests/bugs/docs/tester-sections.txt
+++ b/tests/bugs/docs/tester-sections.txt
@@ -41,6 +41,8 @@ bug_607445
 bug_610257
 bug_623968a
 bug_623968b
+bug_624200a
+bug_624200b
 <SUBSECTION Standard>
 <SUBSECTION Private>
 GTKDOC_GNUC_CONST
diff --git a/tests/bugs/src/tester.c b/tests/bugs/src/tester.c
index abadc6e..ca88616 100644
--- a/tests/bugs/src/tester.c
+++ b/tests/bugs/src/tester.c
@@ -181,7 +181,7 @@ void bug_580300c_get_type() { }
  *
  * Returns: result
  */
-int bug_580300d_get_type() { }
+int bug_580300d_get_type() { return 0; }
 
 
 /**
@@ -271,3 +271,25 @@ bug_623968b(void)
 {
 }
 
+
+/**
+ * bug_624200a:
+ * 
+ * Returns: result
+ */
+const char * const *
+bug_624200a(void)
+{
+  return NULL;
+}
+
+/**
+ * bug_624200b:
+ * 
+ * Returns: result
+ */
+const char ** const
+bug_624200b(void)
+{
+  return NULL;
+}
diff --git a/tests/bugs/src/tester.h b/tests/bugs/src/tester.h
index 4327b7c..9aa2897 100644
--- a/tests/bugs/src/tester.h
+++ b/tests/bugs/src/tester.h
@@ -289,5 +289,9 @@ signed long bug_610257(const unsigned char *der, int *len);
 void bug_623968a(void);
 void bug_623968b(void);
 
+
+const char * const * bug_624200a(void);
+const char ** const bug_624200b(void);
+
 #endif // GTKDOC_TESTER_H
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]