GNOME Bugzilla – Bug 746118
gtkdoc-scan: fix regex for get_type() functions
Last modified: 2015-04-17 18:51:06 UTC
This regexp was apparently looking for "(void)" or "()" but in fact, due to improper order of operations, would match any declaration with either of "(void" or ")" in it (ie: everything). Since nobody is really doing '()' anyway, just make it match '(void)'. This fixes the inappropriate matching of g_io_extension_get_type().
Created attachment 299247 [details] [review] gtkdoc-scan: fix regex for get_type() functions
If nobody is doing '()', why is g_io_extension_get_type() doing it then? Do you have an example where this was causing trouble?
GIOExtensionType is not a GObject. It has this function: GType g_io_extension_get_type (GIOExtension *extension); which (trivially) matches the right side of /(void|)/, ie: ")". If you like, I can do another patch for (void)|(). but as mentioned, I'm not sure anyone is using ().
Lets go with (void)|() as that was the original intend. I agree that people probably don't use (), but you never know.
Created attachment 299303 [details] [review] 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().
The following fix has been pushed: e8adef5 gtkdoc-scan: fix regex for get_type() functions
Created attachment 301869 [details] [review] 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().