[glib/glib-2-36] Don't show help options when help is disabled
- From: Marek KaÅ¡Ãk <mkasik src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/glib-2-36] Don't show help options when help is disabled
- Date: Fri, 12 Apr 2013 15:06:30 +0000 (UTC)
commit 3e3fe296e5c5bda7a6376428616b50515ad4a93c
Author: Marek Kasik <mkasik redhat com>
Date: Tue Apr 9 18:03:53 2013 +0200
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
glib/goption.c | 26 ++++++++++++++++----------
1 files changed, 16 insertions(+), 10 deletions(-)
---
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-<groupname> 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-<groupname> 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]