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 163331 - glibmm's g_option-wrapping doesn't respect set short_name
glibmm's g_option-wrapping doesn't respect set short_name
Status: RESOLVED FIXED
Product: glibmm
Classification: Bindings
Component: object
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2005-01-08 13:58 UTC by Daniel Holbach
Modified: 2005-01-09 16:26 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Daniel Holbach 2005-01-08 13:58:53 UTC
Hi,

I'm still a bit confused by the code of glibmm/glib/src/option*, but from my
example code
(http://cvs.berlios.de/cgi-bin/viewcvs.cgi/protosquared/protosquared/src/CmdLine.cc?rev=1.6&content-type=text/vnd.viewcvs-markup)
I can see, that, short-options aren't neither displayed (in --help) nor parsed
at any rate, although I did specify them.

Here are the differences, I spotted by using a simple grep:
Code concerning  long  options:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
glib/src/optionentry.ccg:36:  g_free(const_cast<char*>(gobject_->long_name));
glib/src/optionentry.ccg:53:    if(gobject_->long_name)
glib/src/optionentry.ccg:54:      g_free(const_cast<char*>(gobject_->long_name));
glib/src/optionentry.ccg:56:    gobject_->long_name =
g_strdup(src.gobject_->long_name);
glib/src/optionentry.hg:55:  _MEMBER_GET(long_name, long_name, Glib::ustring,
const char*)
glib/src/optionentry.hg:56:  _MEMBER_SET(long_name, long_name, Glib::ustring,
const char*)
glib/src/optiongroup.ccg:113:  //g_option_group_add_entries takes an array, with
the last item in the array having a null long_name.
glib/src/optiongroup.ccg:151:  const Glib::ustring name = entry.get_long_name();

Code concerning  short  options:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
glib/src/optionentry.ccg:58:    if(gobject_->short_name)
glib/src/optionentry.ccg:59:      gobject_->short_name = gobject_->short_name;
//It's just one char.
glib/src/optionentry.hg:58:  _MEMBER_GET(short_name, short_name, gchar, gchar)
glib/src/optionentry.hg:59:  _MEMBER_SET(short_name, short_name, gchar, gchar)

The strange thing is: glib/glib/goption.c's g_option_context_parse() itself
calls parse_long_option and parse_short_option, so everything should be fine.

I hope, you can find out, what's going wrong.

Bye,
 Daniel
Comment 1 Murray Cumming 2005-01-09 16:26:04 UTC
This was the problem;
glib/src/optionentry.ccg:59:      gobject_->short_name = gobject_->short_name;

It should have been 
  gobject_->short_name = src.gobject_->short_name;

Thanks.