Bug 562639 – g_parse_debug_flags() parsing "help"

2008-11-28  Behdad Esfahbod  <behdad@gnome.org>

        Bug 562639 – g_parse_debug_flags() parsing "help"

        * glib/gutils.c (g_parse_debug_string): Print available keys if
        string is "help".


svn path=/trunk/; revision=7710
This commit is contained in:
Behdad Esfahbod 2008-11-29 01:40:38 +00:00 committed by Behdad Esfahbod
parent 6d0e4aa2cf
commit 5d5526c1a3
2 changed files with 20 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2008-11-28 Behdad Esfahbod <behdad@gnome.org>
Bug 562639 g_parse_debug_flags() parsing "help"
* glib/gutils.c (g_parse_debug_string): Print available keys if
string is "help".
2008-11-28 Behdad Esfahbod <behdad@gnome.org> 2008-11-28 Behdad Esfahbod <behdad@gnome.org>
Bug 562638 GDebugKey key member should be const Bug 562638 GDebugKey key member should be const

View File

@ -615,7 +615,7 @@ debug_key_matches (const gchar *key,
/** /**
* g_parse_debug_string: * g_parse_debug_string:
* @string: a list of debug options separated by colons, spaces, or * @string: a list of debug options separated by colons, spaces, or
* commas; or the string "all" to set all flags, or %NULL. * commas, or %NULL.
* @keys: pointer to an array of #GDebugKey which associate * @keys: pointer to an array of #GDebugKey which associate
* strings with bit flags. * strings with bit flags.
* @nkeys: the number of #GDebugKey<!-- -->s in the array. * @nkeys: the number of #GDebugKey<!-- -->s in the array.
@ -625,6 +625,10 @@ debug_key_matches (const gchar *key,
* within GDK and GTK+ to parse the debug options passed on the * within GDK and GTK+ to parse the debug options passed on the
* command line or through environment variables. * command line or through environment variables.
* *
* If @string is equal to "all", all flags are set. If @string
* is equal to "help", all the available keys in @keys are printed
* out to standard error.
*
* Returns: the combined set of bit flags. * Returns: the combined set of bit flags.
*/ */
guint guint
@ -648,6 +652,14 @@ g_parse_debug_string (const gchar *string,
for (i=0; i<nkeys; i++) for (i=0; i<nkeys; i++)
result |= keys[i].value; result |= keys[i].value;
} }
else if (!g_ascii_strcasecmp (string, "help"))
{
/* using stdio directly for the reason stated above */
fprintf (stderr, "Supported debug values: ");
for (i=0; i<nkeys; i++)
fprintf (stderr, " %s", keys[i].key);
fprintf (stderr, "\n");
}
else else
{ {
const gchar *p = string; const gchar *p = string;