After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 603930 - gmmproc: Property documentation: Loses text after comma
gmmproc: Property documentation: Loses text after comma
Status: RESOLVED FIXED
Product: glibmm
Classification: Bindings
Component: documentation
2.28.x
Other All
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
: 647799 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2009-12-06 22:00 UTC by Jonatan Olofsson
Modified: 2011-05-27 13:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to quote property docs without leaving trailing single quotes (2.22 KB, patch)
2010-05-04 22:58 UTC, José Alburquerque
none Details | Review
gmmproc: Protect documentation with m4 quotes. (glibmm) (6.35 KB, patch)
2011-05-12 12:56 UTC, Kjell Ahlstedt
none Details | Review

Description Jonatan Olofsson 2009-12-06 22:00:42 UTC
The documentation for Gtk::CellRendererCombo::property_has_entry() (on http://library.gnome.org/devel/gtkmm/unstable/classGtk_1_1CellRendererCombo.html#af552c276bbfe5de8ad68765982e7ef1e) contains the text
"
If FALSE.

You rarely need to use properties because there are get_ and set_ methods for almost all of them. 
"

Which is downright impossible to understand.
Comment 1 Murray Cumming 2009-12-30 10:01:06 UTC
glibmm/tools/pmProperty.pm gets the correct text from the gtk_signals.defs file, but m4 seems to lose anything after the comma when parsing the _PROPERTY_PROXY() call, as written here: 
  http://git.gnome.org/browse/glibmm/tree/tools/pm/Output.pm#n621

Adding `' around the $s, as done elsewhere in that file, like so,
  my $str = sprintf("_PROPERTY_PROXY(%s,%s,%s,%s,\`%s\')dnl\n",
partly fixes it, but leaves a trailing ' in the .h file, like so:

  /** If FALSE, dont allow to enter strings other than the chosen ones.'
 
Notice also that don't has changed to dont.

CCing Daniel Elstner in case he knows how to do this properly.
Comment 2 Murray Cumming 2010-04-07 13:19:23 UTC
Any ideas, Daniel?
Comment 3 José Alburquerque 2010-05-04 22:58:56 UTC
Created attachment 160304 [details] [review]
Patch to quote property docs without leaving trailing single quotes

I know the question was addressed to Daniel, but he might be a little busy.  One quick way to solve it could be to change the quotes before and after the docs string so that single quotes are not an issue.  A patch is attached.
Comment 4 Murray Cumming 2010-05-05 07:19:54 UTC
Sure. Many thanks. If that fixes it then please commit. I guess that an explanatory comment next to those lines of code might be useful though.
Comment 5 José Alburquerque 2010-05-05 15:40:23 UTC
Okay.  Committed with the comments:

http://git.gnome.org/browse/glibmm/commit/?id=3b643e509757fb2c15c55bd7a1d0707096fa4506
Comment 6 Daniel Elstner 2010-05-21 16:35:54 UTC
Reopening, as a reminder for me to take a look at the problem again when I find the time, because changequote() is evil (see the M4 and Autoconf manuals for details). Even if it appears to work now, there is at least the problem that it will break again as soon as you use [ or ] in the comment text.

The underlying issue is that M4 cannot handle unbalanced quote characters. If I remember correctly, gmmproc substitutes the dangerous quote characters in source code with special escape sequences, and converts the escapes back as the final step before writing the result to disk. I guess what happens here is that the comment does not count as part of the source code proper, since it is an M4 macro argument and thus parsed as M4 syntax.
Comment 7 Sebastian Dröge (slomo) 2011-04-15 11:55:42 UTC
*** Bug 647799 has been marked as a duplicate of this bug. ***
Comment 8 Kjell Ahlstedt 2011-05-04 16:49:25 UTC
(In reply to comment #1)
> Adding `' around the $s, as done elsewhere in that file, like so,
>   my $str = sprintf("_PROPERTY_PROXY(%s,%s,%s,%s,\`%s\')dnl\n",
> partly fixes it, but leaves a trailing ' in the .h file, like so:
> 
>   /** If FALSE, dont allow to enter strings other than the chosen ones.'
> 
> Notice also that don't has changed to dont.

When m4 removes a level of quotations in

  /** `If FALSE, don't allow to enter strings other than the chosen ones.'

it removes ` and the first ' after that, i.e. the ' in don't, leaving the
trailing ', which lacks a corresponding quote start (`).

(In reply to comment #6)
> If I remember correctly, gmmproc substitutes the dangerous quote characters
> in source code with special escape sequences, and converts the escapes back
> as the final step before writing the result to disk.

Yes Daniel, you remember correctly. E.g. WrapParser::on_comment_c() puts a
level of m4 quotes around a comment, and within the comment it replaces ` and '
by '__BT__` and '__FT__` resp.
__BT__ and __FT__ are m4 macros, defined in glibmm/tools/m4/base.m4.

DocsParser::convert_docs_to_cpp() does something similar, but rather half-
heartedly. It ought to be more like WrapParser::on_comment_c().

Output::output_wrap_property() should also prepare the comment text similarly
to what WrapParser::on_comment_c() does.

There are at least two peculiarities of m4 to be aware of:
- The quote characters (`') are important. In macro calls, also comma (,) and
  parentheses have special significance, unless quoted.
- Every word in unquoted text is a potential macro call. If the word is the
  name of a macro, macro substitution is performed.

It's important to quote at least all comments, and to replace m4's quote
characters in comments the way WrapParser::on_comment_c() and some other
functions do.

Daniel, you said in comment 6 that you plan to take a look at this problem.
If you don't mind, I can make a patch.
Comment 9 Murray Cumming 2011-05-10 07:05:46 UTC
> Daniel, you said in comment 6 that you plan to take a look at this problem.
> If you don't mind, I can make a patch.

I think Daniel is unlikely to find time for this, so a patch would be very welcome.
Comment 10 Kjell Ahlstedt 2011-05-12 12:56:58 UTC
Created attachment 187705 [details] [review]
gmmproc: Protect documentation with m4 quotes. (glibmm)

Here's the patch.
Now it's possible to include in property documentation: m4 quotes (`'), commas,
square brackets, balanced and unbalanced parentheses (bug 647799), names of m4
macros.
In method documentation: names of m4 macros (The other stuff is possible even
without this patch or the patch in comment 3, I think.)
gmmproc has long since protected documentation (comments) read from the .hg
files with m4 quotes before it's sent to the m4 macro processor. No change
needed there.

Note that this is a glibmm patch, although this bug is assigned to gtkmm.
Comment 11 Murray Cumming 2011-05-19 08:06:39 UTC
Please push. Thanks.
Comment 12 Kjell Ahlstedt 2011-05-20 12:23:41 UTC
Is the request to push the patch meant for me? I have no Git account, and then
I can't push anything, can I? Do you think it's about time I apply for a Git
account?
Comment 13 Murray Cumming 2011-05-20 20:47:07 UTC
(In reply to comment #12)
>  Do you think it's about time I apply for a Git account?

Yes, please, you have long since qualified for one.
Comment 14 Kjell Ahlstedt 2011-05-27 11:35:55 UTC
I have pushed the patch in comment 10.
This bug is thus fixed, but I have no permission to close it. I haven't
found any instructions how to apply for extra permissions in Bugzilla.
Comment 15 Murray Cumming 2011-05-27 13:50:35 UTC
Thanks. You probably have to ask the GNOME bugsquad for more permissions.