[glib] g_strdup_value_contents(): dump GStrv more usefully
- From: Will Thompson <wjt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] g_strdup_value_contents(): dump GStrv more usefully
- Date: Mon, 13 Sep 2010 18:20:03 +0000 (UTC)
commit ba17efc3961b094cc853b66d66e09a3d8b0444a1
Author: Will Thompson <will thompson collabora co uk>
Date: Thu Sep 9 17:24:00 2010 +0100
g_strdup_value_contents(): dump GStrv more usefully
Previously, dumping a GValue holding a GStrv just yielded "((GStrv *)
0xDEADBEEF)". I think it'd be more useful to dump a Python list-style
representation of the GStrv's contents, if it's not NULL.
Fixes: <https://bugzilla.gnome.org/show_bug.cgi?id=629192>
gobject/gvaluetypes.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/gobject/gvaluetypes.c b/gobject/gvaluetypes.c
index 8bd612f..aa22b2d 100644
--- a/gobject/gvaluetypes.c
+++ b/gobject/gvaluetypes.c
@@ -1339,6 +1339,25 @@ g_strdup_value_contents (const GValue *value)
contents = g_strdup_printf ("((%s*) %p)", G_OBJECT_TYPE_NAME (p), p);
else if (G_VALUE_HOLDS_PARAM (value))
contents = g_strdup_printf ("((%s*) %p)", G_PARAM_SPEC_TYPE_NAME (p), p);
+ else if (G_VALUE_HOLDS (value, G_TYPE_STRV))
+ {
+ GStrv strv = g_value_get_boxed (value);
+ GString *tmp = g_string_new ("[");
+
+ while (*strv != NULL)
+ {
+ gchar *escaped = g_strescape (*strv, NULL);
+
+ g_string_append_printf (tmp, "\"%s\"", escaped);
+ g_free (escaped);
+
+ if (*++strv != NULL)
+ g_string_append (tmp, ", ");
+ }
+
+ g_string_append (tmp, "]");
+ contents = g_string_free (tmp, FALSE);
+ }
else if (G_VALUE_HOLDS_BOXED (value))
contents = g_strdup_printf ("((%s*) %p)", g_type_name (G_VALUE_TYPE (value)), p);
else if (G_VALUE_HOLDS_POINTER (value))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]