Bug 562639 – g_parse_debug_flags() parsing "help"
authorBehdad Esfahbod <behdad@gnome.org>
Sat, 29 Nov 2008 01:40:38 +0000 (01:40 +0000)
committerBehdad Esfahbod <behdad@src.gnome.org>
Sat, 29 Nov 2008 01:40:38 +0000 (01:40 +0000)
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

ChangeLog
glib/gutils.c

index 031dee6..a154968 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 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>
+
        Bug 562638 – GDebugKey key member should be const
 
        * glib/gutils.h: Change GDebugKey key member from gchar * to
index d5407ca..4ce9654 100644 (file)
@@ -615,7 +615,7 @@ debug_key_matches (const gchar *key,
 /**
  * g_parse_debug_string:
  * @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 
  *     strings with bit flags.
  * @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
  * 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.
  */
 guint       
@@ -648,6 +652,14 @@ g_parse_debug_string  (const gchar     *string,
       for (i=0; i<nkeys; i++)
        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
     {
       const gchar *p = string;