From: Marek Kasik Date: Tue, 9 Apr 2013 16:03:53 +0000 (+0200) Subject: Don't show help options when help is disabled X-Git-Tag: 2.37.0~48 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d20336130d08978c5e7e7f12df29d6cb6f7bbef5;p=platform%2Fupstream%2Fglib.git Don't show help options when help is disabled Check whether help is enabled when creating help text in g_option_context_get_help(). https://bugzilla.gnome.org/show_bug.cgi?id=697652 --- diff --git a/glib/goption.c b/glib/goption.c index e33f992..0a22f6f 100644 --- a/glib/goption.c +++ b/glib/goption.c @@ -723,7 +723,7 @@ g_option_context_get_help (GOptionContext *context, GOptionGroup *group) { GList *list; - gint max_length, len; + gint max_length = 0, len; gint i; GOptionEntry *entry; GHashTable *shadow_map; @@ -822,12 +822,15 @@ g_option_context_get_help (GOptionContext *context, list = context->groups; - max_length = _g_utf8_strwidth ("-?, --help"); - - if (list) + if (context->help_enabled) { - len = _g_utf8_strwidth ("--help-all"); - max_length = MAX (max_length, len); + max_length = _g_utf8_strwidth ("-?, --help"); + + if (list) + { + len = _g_utf8_strwidth ("--help-all"); + max_length = MAX (max_length, len); + } } if (context->main_group) @@ -840,9 +843,12 @@ g_option_context_get_help (GOptionContext *context, { GOptionGroup *g = list->data; - /* First, we check the --help- options */ - len = _g_utf8_strwidth ("--help-") + _g_utf8_strwidth (g->name); - max_length = MAX (max_length, len); + if (context->help_enabled) + { + /* First, we check the --help- options */ + len = _g_utf8_strwidth ("--help-") + _g_utf8_strwidth (g->name); + max_length = MAX (max_length, len); + } /* Then we go through the entries */ len = calculate_max_length (g, aliases); @@ -854,7 +860,7 @@ g_option_context_get_help (GOptionContext *context, /* Add a bit of padding */ max_length += 4; - if (!group) + if (!group && context->help_enabled) { list = context->groups;