[glibmm] gmmproc: Protect documentation with m4 quotes.
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] gmmproc: Protect documentation with m4 quotes.
- Date: Fri, 27 May 2011 11:23:00 +0000 (UTC)
commit 46bda0f6b9f3528d772429118928824dd60fc9e3
Author: Kjell Ahlstedt <kjellahl src gnome org>
Date: Fri May 27 13:15:12 2011 +0200
gmmproc: Protect documentation with m4 quotes.
* tools/pm/DocsParser.pm:
* tools/pm/Output.pm: Method documentation read from xxx_docs.xml, and
property documentation read from xxx_signals.defs are better protected with
m4 quotes and __BT__ and __FT__ macros in the input to the m4 macro
processor. Bug #603930
ChangeLog | 10 +++++++++
tools/pm/DocsParser.pm | 22 ++++++++++++++------
tools/pm/Output.pm | 49 ++++++++++++++++++++++++++---------------------
3 files changed, 52 insertions(+), 29 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d201ed8..04345a1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-05-27 Kjell Ahlstedt <kjellahl src gnome org>
+
+ gmmproc: Protect documentation with m4 quotes.
+
+ * tools/pm/DocsParser.pm:
+ * tools/pm/Output.pm: Method documentation read from xxx_docs.xml, and
+ property documentation read from xxx_signals.defs are better protected with
+ m4 quotes and __BT__ and __FT__ macros in the input to the m4 macro
+ processor. Bug #603930
+
2.28.1:
2011-05-05 José Alburquerque <jaalburqu svn gnome org>
diff --git a/tools/pm/DocsParser.pm b/tools/pm/DocsParser.pm
index 02caa44..e368b5f 100644
--- a/tools/pm/DocsParser.pm
+++ b/tools/pm/DocsParser.pm
@@ -249,7 +249,6 @@ sub lookup_documentation($$)
print "DocsParser.pm: Warning: No C docs for function: \"$functionName\"\n";
}
-
DocsParser::convert_docs_to_cpp($objFunction, \$text);
#Add note about deprecation if we have specified that in our _WRAP_METHOD() call:
@@ -260,7 +259,7 @@ sub lookup_documentation($$)
DocsParser::append_parameter_docs($objFunction, \$text);
DocsParser::append_return_docs($objFunction, \$text);
-
+ DocsParser::add_m4_quotes(\$text);
# Escape the space after "i.e." or "e.g." in the brief description.
$text =~ s/^([^.]*\b(?:i\.e\.|e\.g\.))\s/$1\\ /;
@@ -273,6 +272,20 @@ sub lookup_documentation($$)
return $text;
}
+sub add_m4_quotes($)
+{
+ my ($text) = @_;
+
+ # __BT__ and __FT__ are M4 macros defined in the base.m4 file that produce
+ # a "`" and a "'" resp. without M4 errors.
+ my %m4_quotes = (
+ "`" => "'__BT__`",
+ "'" => "'__FT__`",
+ );
+
+ $$text =~ s/([`'])/$m4_quotes{$1}/g;
+ $$text = "`" . $$text . "'";
+}
sub append_parameter_docs($$)
{
@@ -335,11 +348,6 @@ sub convert_docs_to_cpp($$)
$$text =~ s/\bX\s+Window\b/X \%Window/g;
$$text =~ s/\bWindow\s+manager/\%Window manager/g;
-
- # This is so that if there is a '`' in the docs it doesn't cause a
- # problem when M4 processing occurs. __BT__ is a variable defined in the
- # base.m4 file that produces a '`' without M4 errors.
- $$text =~ s/`/__BT__/g;
# }
}
diff --git a/tools/pm/Output.pm b/tools/pm/Output.pm
index 31fbf07..1cbd896 100644
--- a/tools/pm/Output.pm
+++ b/tools/pm/Output.pm
@@ -149,7 +149,7 @@ sub output_wrap_vfunc_cc($$$$$$$)
#Use a different macro for Interfaces, to generate an extra convenience method.
- if ($custom_vfunc eq 0)
+ if (!$custom_vfunc)
{
my $refreturn = "";
$refreturn = "refreturn" if($$objCppfunc{rettype_needs_ref});
@@ -170,7 +170,7 @@ sub output_wrap_vfunc_cc($$$$$$$)
# e.g. Gtk::ButtonClass::draw_indicator():
- if ($custom_vfunc_callback eq 0)
+ if (!$custom_vfunc_callback)
{
my $refreturn_ctype = "";
$refreturn_ctype = "refreturn_ctype" if($$objCFunc{rettype_needs_ref});
@@ -588,46 +588,51 @@ sub output_wrap_property($$$$$$)
my $name_underscored = $name;
$name_underscored =~ tr/-/_/;
- # For the docs of the property (the final argument of the sprintf), the
- # m4 quotes are changed, the new quotes are then used to quote the docs
- # and then the quotes are changed back to the standard quotes. This is
- # done so that if there are commas in the docs, the contents after the
- # docs are not lost (m4 thinks the contents after the comma is another
- # agument to the macro). Using the standard quotes leaves a trailing
- # single quote for some undetermined reason.
- my $str = sprintf("_PROPERTY_PROXY(%s,%s,%s,%s,changequote([,])[%s]changequote(`,'))dnl\n",
+ # Get the property documentation, if any, and add m4 quotes.
+ my $documentation = $objProperty->get_docs();
+ add_m4_quotes(\$documentation) if ($documentation ne "");
+
+ my $str = sprintf("_PROPERTY_PROXY(%s,%s,%s,%s,`%s')dnl\n",
$name,
$name_underscored,
$cpp_type,
$proxy_suffix,
- $objProperty->get_docs()
+ $documentation
);
$self->append($str);
$self->append("\n");
- # If the property is not already read-only, and the property can be read, then add a second const accessor for a read-only propertyproxy:
+ # If the property is not already read-only, and the property can be read,
+ # then add a second const accessor for a read-only propertyproxy:
if( ($proxy_suffix ne "_ReadOnly") && ($objProperty->get_readable()) )
{
-
- # For the docs of the property (the final argument of the sprintf), the
- # m4 quotes are changed, the new quotes are then used to quote the docs
- # and then the quotes are changed back to the standard quotes. This is
- # done so that if there are commas in the docs, the contents after the
- # docs are not lost (m4 thinks the contents after the comma is another
- # agument to the macro). Using the standard quotes leaves a trailing
- # single quote for some undetermined reason.
- my $str = sprintf("_PROPERTY_PROXY(%s,%s,%s,%s,changequote([,])[%s]changequote(`,'))dnl\n",
+ my $str = sprintf("_PROPERTY_PROXY(%s,%s,%s,%s,`%s')dnl\n",
$name,
$name_underscored,
$cpp_type,
"_ReadOnly",
- $objProperty->get_docs()
+ $documentation
);
$self->append($str);
}
}
}
+sub add_m4_quotes($)
+{
+ my ($text) = @_;
+
+ # __BT__ and __FT__ are M4 macros defined in the base.m4 file that produce
+ # a "`" and a "'" resp. without M4 errors.
+ my %m4_quotes = (
+ "`" => "'__BT__`",
+ "'" => "'__FT__`",
+ );
+
+ $$text =~ s/([`'])/$m4_quotes{$1}/g;
+ $$text = "`" . $$text . "'";
+}
+
# vpod output_temp_g1($filename, $section) e.g. output_temp_g1(button, gtk)
sub output_temp_g1($$)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]