GNOME Bugzilla – Bug 163331
glibmm's g_option-wrapping doesn't respect set short_name
Last modified: 2005-01-09 16:26:04 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
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.