[gtk-doc/wip/desrt/fixes-for-glib: 5/5] gtkdoc-scan: fix regex for get_type() functions
- From: Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk-doc/wip/desrt/fixes-for-glib: 5/5] gtkdoc-scan: fix regex for get_type() functions
- Date: Fri, 13 Mar 2015 11:39:45 +0000 (UTC)
commit 6dccb41de945bd7b3521e1e0b651516356d67c57
Author: Ryan Lortie <desrt desrt ca>
Date: Thu Mar 12 18:50:50 2015 -0400
gtkdoc-scan: fix regex for get_type() functions
The regexp /(void|)/ was apparently trying to look for "(void)" or "()",
but in fact, the parens here were only acting as (redundant) grouping,
so the expression would match any string containing either "void" or "",
which is every string.
It turns out that we don't want to look for parens anyway, since they
are already stripped out above. We do want to look for exactly "void"
or "", however, so add ^ and $.
Unfortunately, some code above also replaces all whitespace surrounding
newlines with a single space character, and a trailing newline is left
at the end of the declaration by another regular expression above,
resulting in seeing "void " at this point. Fix that expression up to
also clean up the newline at the end, by adding /s as a regexp flag.
This fixes the inappropriate matching of non-void functions, such as
g_io_extension_get_type().
https://bugzilla.gnome.org/show_bug.cgi?id=746118
gtkdoc-scan.in | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/gtkdoc-scan.in b/gtkdoc-scan.in
index a45744a..567b5b0 100755
--- a/gtkdoc-scan.in
+++ b/gtkdoc-scan.in
@@ -774,7 +774,7 @@ sub ScanHeader {
# Note that sometimes functions end in ') G_GNUC_PRINTF (2, 3);' or
# ') __attribute__ (...);'.
if ($in_declaration eq 'function') {
- if ($decl =~
s/\)\s*(G_GNUC_.*|.*DEPRECATED.*|${IGNORE_DECORATORS}\s*|__attribute__\s*\(.*\)\s*)*;.*$//) {
+ if ($decl =~
s/\)\s*(G_GNUC_.*|.*DEPRECATED.*|${IGNORE_DECORATORS}\s*|__attribute__\s*\(.*\)\s*)*;.*$//s) {
if ($internal == 0) {
$decl =~ s%/\*.*?\*/%%gs; # remove comments.
#$decl =~ s/^\s+//; # remove leading whitespace.
@@ -786,7 +786,7 @@ sub ScanHeader {
print DECL
"<FUNCTION>\n<NAME>$symbol</NAME>\n$deprecated<RETURNS>$ret_type</RETURNS>\n$decl\n</FUNCTION>\n";
if ($REBUILD_TYPES) {
# check if this looks like a get_type function and if so remember
- if (($symbol =~ m/_get_type$/) && ($ret_type =~ m/GType/) && ($decl =~
m/(void|)/)) {
+ if (($symbol =~ m/_get_type$/) && ($ret_type =~ m/GType/) && ($decl =~
m/^(void|)$/)) {
@TRACE@("Adding get-type: [$ret_type] [$symbol] [$decl]\tfrom $input_file");
push (@get_types, $symbol);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]