[glib/gvariant] Add gvariant-printer.
- From: Ryan Lortie <ryanl src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glib/gvariant] Add gvariant-printer.
- Date: Fri, 14 Aug 2009 03:12:34 +0000 (UTC)
commit e2b57ab26739282e987a9a3b5413fc875cf9821f
Author: Sam Thursfield <ssssam gmail com>
Date: Thu Aug 13 23:11:09 2009 -0400
Add gvariant-printer.
docs/reference/glib/glib-sections.txt | 5 +
glib/Makefile.am | 1 +
glib/glib.symbols | 6 +
glib/gvariant-markup.c | 57 +++++--
glib/gvariant-printer.c | 303 +++++++++++++++++++++++++++++++++
glib/gvariant.h | 13 ++-
glib/tests/Makefile.am | 3 +
glib/tests/gvariant-endian.c | 8 +-
glib/tests/gvariant-fuzz.c | 18 +-
glib/tests/gvariant-markup.c | 8 +-
glib/tests/gvariant-printer-parser.c | 76 ++++++++
glib/tests/gvariant-random.c | 2 +-
glib/tests/gvariant-serialiser.c | 8 +-
13 files changed, 467 insertions(+), 41 deletions(-)
---
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index 361a48b..b517490 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -2827,6 +2827,10 @@ g_variant_new_va
g_variant_format_string_scan
<SUBSECTION>
+g_variant_print
+g_variant_print_string
+
+<SUBSECTION>
GVariantIter
g_variant_iter_cancel
g_variant_iter_init
@@ -2853,6 +2857,7 @@ g_variant_markup_parse
g_variant_markup_parse_context_end
g_variant_markup_parse_context_new
g_variant_markup_print
+g_variant_markup_print_string
g_variant_markup_subparser_end
g_variant_markup_subparser_start
diff --git a/glib/Makefile.am b/glib/Makefile.am
index 7c7de7d..52be679 100644
--- a/glib/Makefile.am
+++ b/glib/Makefile.am
@@ -167,6 +167,7 @@ libglib_2_0_la_SOURCES = \
gvariant-private.h \
gvariant-core.c \
gvariant-parser.c \
+ gvariant-printer.c \
gvariant-markup.c \
gvariant-serialiser.h \
gvariant-serialiser.c \
diff --git a/glib/glib.symbols b/glib/glib.symbols
index fe36f66..53d32a8 100644
--- a/glib/glib.symbols
+++ b/glib/glib.symbols
@@ -1712,8 +1712,14 @@ g_variant_parsef
g_variant_parsef_va
#endif
+#if IN_FILE(_gvariant_printer_c_)
+g_variant_print
+g_variant_print_string
+#endif
+
#if IN_FILE(_gvariant_markup_c_)
g_variant_markup_print
+g_variant_markup_print_string
g_variant_markup_subparser_start
g_variant_markup_subparser_end
g_variant_markup_parse_context_new
diff --git a/glib/gvariant-markup.c b/glib/gvariant-markup.c
index 03356c8..7314d77 100644
--- a/glib/gvariant-markup.c
+++ b/glib/gvariant-markup.c
@@ -48,20 +48,17 @@ has_no_evil_characters (const gchar *str)
return TRUE;
}
+
/**
* g_variant_markup_print:
* @value: a #GVariant
- * @string: a #GString, or %NULL
* @newlines: %TRUE if newlines should be printed
* @indentation: the current indentation level
* @tabstop: the number of spaces per indentation level
- * @returns: a #GString containing the XML fragment
+ * @returns: a newly-allocated string containing the XML fragment
*
* Pretty-prints @value as an XML document fragment.
*
- * If @string is non-%NULL then it is appended to and returned. Else,
- * a new empty #GString is allocated and it is returned.
- *
* The @newlines, @indentation and @tabstop parameters control the
* whitespace that is emitted as part of the document.
*
@@ -73,13 +70,39 @@ has_no_evil_characters (const gchar *str)
* then this is the number of additional spaces that are added for
* each level of nesting.
**/
-GString *
+gchar *
g_variant_markup_print (GVariant *value,
- GString *string,
gboolean newlines,
gint indentation,
gint tabstop)
{
+ GString *string = g_variant_markup_print_string (value, NULL, newlines,
+ indentation, tabstop);
+ return g_string_free (string, FALSE);
+};
+
+/**
+ * g_variant_markup_print:
+ * @value: a #GVariant
+ * @string: a #GString, or %NULL
+ * @newlines: %TRUE if newlines should be printed
+ * @indentation: the current indentation level
+ * @tabstop: the number of spaces per indentation level
+ * @returns: a #GString containing the XML fragment
+ *
+ * Pretty-prints @value as an XML document fragment, behaving in the
+ * same way as g_variant_markup_print().
+ *
+ * If @string is non-%NULL then it is appended to and returned. Else,
+ * a new empty #GString is allocated and it is returned.
+ **/
+GString *
+g_variant_markup_print_string (GVariant *value,
+ GString *string,
+ gboolean newlines,
+ gint indentation,
+ gint tabstop)
+{
const GVariantType *type;
type = g_variant_get_type (value);
@@ -100,8 +123,8 @@ g_variant_markup_print (GVariant *value,
g_variant_markup_newline (string, newlines);
child = g_variant_get_variant (value);
- g_variant_markup_print (child, string,
- newlines, indentation, tabstop);
+ g_variant_markup_print_string (child, string,
+ newlines, indentation, tabstop);
g_variant_unref (child);
g_variant_markup_indent (string, indentation - tabstop);
@@ -120,8 +143,8 @@ g_variant_markup_print (GVariant *value,
g_variant_markup_newline (string, newlines);
element = g_variant_get_child_value (value, 0);
- g_variant_markup_print (element, string,
- newlines, indentation, tabstop);
+ g_variant_markup_print_string (element, string,
+ newlines, indentation, tabstop);
g_variant_unref (element);
g_variant_markup_indent (string, indentation - tabstop);
@@ -146,8 +169,8 @@ g_variant_markup_print (GVariant *value,
g_variant_markup_newline (string, newlines);
while ((element = g_variant_iter_next_value (&iter)))
- g_variant_markup_print (element, string,
- newlines, indentation, tabstop);
+ g_variant_markup_print_string (element, string,
+ newlines, indentation, tabstop);
g_variant_markup_indent (string, indentation - tabstop);
g_string_append (string, "</array>");
@@ -171,8 +194,8 @@ g_variant_markup_print (GVariant *value,
g_variant_markup_newline (string, newlines);
while ((element = g_variant_iter_next_value (&iter)))
- g_variant_markup_print (element, string,
- newlines, indentation, tabstop);
+ g_variant_markup_print_string (element, string,
+ newlines, indentation, tabstop);
g_variant_markup_indent (string, indentation - tabstop);
g_string_append (string, "</struct>");
@@ -193,8 +216,8 @@ g_variant_markup_print (GVariant *value,
g_variant_iter_init (&iter, value);
while ((element = g_variant_iter_next_value (&iter)))
- g_variant_markup_print (element, string,
- newlines, indentation, tabstop);
+ g_variant_markup_print_string (element, string,
+ newlines, indentation, tabstop);
g_variant_markup_indent (string, indentation - tabstop);
g_string_append (string, "</dictionary-entry>");
diff --git a/glib/gvariant-printer.c b/glib/gvariant-printer.c
new file mode 100644
index 0000000..05e4679
--- /dev/null
+++ b/glib/gvariant-printer.c
@@ -0,0 +1,303 @@
+/*
+ * Copyright © 2009, Sam Thursfield
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of version 3 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * See the included COPYING file for more information.
+ *
+ * Authors: Sam Thursfield <ssssam gmail com>
+ */
+
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <glib.h>
+
+#include "galias.h"
+
+/**
+ * g_variant_print:
+ * @value: a #GVariant
+ * @type_annotate: %TRUE if type information should be included in
+ * the output
+ * @returns: a newly-allocated string holding the result.
+ *
+ * Pretty-prints @value in the format understood by g_variant_parse().
+ *
+ * If @type_annotate is %TRUE, then type information is included in
+ * the output.
+ */
+gchar *
+g_variant_print (GVariant *value,
+ gboolean type_annotate)
+{
+ return g_string_free (g_variant_print_string (value, NULL, type_annotate),
+ FALSE);
+};
+
+/**
+ * g_variant_print_string:
+ * @value: a #GVariant
+ * @string: a #GString, or %NULL
+ * @type_annotate: %TRUE if type information should be included in
+ * the output
+ * @returns: a #GString containing the string
+ *
+ * Behaves as g_variant_print(), but operates on a #GString.
+ *
+ * If @string is non-%NULL then it is appended to and returned. Else,
+ * a new empty #GString is allocated and it is returned.
+ **/
+GString *
+g_variant_print_string (GVariant *value,
+ GString *string,
+ gboolean type_annotate)
+{
+ const GVariantType *type;
+
+ type = g_variant_get_type (value);
+
+ if G_UNLIKELY (string == NULL)
+ string = g_string_new (NULL);
+
+ switch (g_variant_get_type_class (value))
+ {
+ case G_VARIANT_TYPE_CLASS_ARRAY:
+ {
+ GVariantIter iter;
+
+ if (type_annotate)
+ g_string_append_printf (string, "@%s",
+ g_variant_get_type_string (value));
+ g_string_append_c (string, '[');
+ if (g_variant_iter_init (&iter, value))
+ {
+ GVariant *element;
+
+ /* Array elements are all of the same type which we already
+ * printed, so further type annotation is pointless. */
+ while ((element = g_variant_iter_next_value (&iter)))
+ {
+ g_variant_print_string (element, string, FALSE);
+ g_string_append (string, ", ");
+ }
+ g_string_truncate (string, string->len - 2);
+ }
+
+ g_string_append_c (string, ']');
+ break;
+ }
+
+ case G_VARIANT_TYPE_CLASS_VARIANT:
+ {
+ GVariant *child = g_variant_get_variant (value);
+
+ /* Always annotate types in nested variants, because they are
+ * (by nature) of variable type.
+ */
+ g_string_append_c (string, '<');
+ g_variant_print_string (child, string, TRUE);
+ g_string_append_c (string, '>');
+
+ g_variant_unref (child);
+ break;
+ }
+
+ case G_VARIANT_TYPE_CLASS_STRUCT:
+ {
+ GVariantIter iter;
+
+ g_string_append_c (string, '(');
+ if (g_variant_iter_init (&iter, value))
+ {
+ GVariant *element;
+
+ while ((element = g_variant_iter_next_value (&iter)))
+ {
+ g_variant_print_string (element, string, type_annotate);
+ g_string_append (string, ", ");
+ }
+ g_string_truncate (string, string->len - 2);
+ }
+ g_string_append_c (string, ')');
+
+ break;
+ }
+
+ case G_VARIANT_TYPE_CLASS_DICT_ENTRY:
+ {
+ GVariantIter iter;
+ GVariant *element;
+
+ g_string_append_c (string, '{');
+
+ if (g_variant_iter_init (&iter, value))
+ {
+ while ((element = g_variant_iter_next_value (&iter)))
+ {
+ g_variant_print_string (element, string, type_annotate);
+
+ g_string_append_c (string, ':');
+
+ element = g_variant_iter_next_value (&iter);
+ g_variant_print_string (element, string, type_annotate);
+ g_string_append (string, ", ");
+ }
+ g_string_truncate (string, string->len - 2);
+
+ g_string_append_c (string, '}');
+ }
+
+ break;
+ }
+
+ case G_VARIANT_TYPE_CLASS_BOOLEAN:
+ if (g_variant_get_boolean (value))
+ g_string_append (string, "true");
+ else
+ g_string_append (string, "false");
+ break;
+
+ /*case G_VARIANT_TYPE_CLASS_MAYBE:
+ {
+ if (g_variant_n_children (value))
+ {
+ GVariant *element;
+
+ g_string_append (string, "<maybe>");
+ g_variant_markup_newline (string, newlines);
+
+ element = g_variant_get_child_value (value, 0);
+ g_variant_markup_print (element, string,
+ newlines, indentation, tabstop);
+ g_variant_unref (element);
+
+ g_variant_markup_indent (string, indentation - tabstop);
+ g_string_append (string, "</maybe>");
+ }
+ else
+ g_string_append_printf (string, "<nothing type='%s'/>",
+ g_variant_get_type_string (value));
+
+ break;
+ }*/
+
+ case G_VARIANT_TYPE_CLASS_STRING:
+ {
+ const gchar *str = g_variant_get_string (value, NULL);
+ gchar *escaped = g_strescape (str, NULL);
+
+ g_string_append_printf (string, "\"%s\"", escaped);
+
+ g_free (escaped);
+ break;
+ }
+
+ case G_VARIANT_TYPE_CLASS_BYTE:
+ if (type_annotate)
+ g_string_append (string, "@y");
+ g_string_append_printf (string, "0x%02x",
+ g_variant_get_byte (value));
+ break;
+
+ case G_VARIANT_TYPE_CLASS_INT16:
+ if (type_annotate)
+ g_string_append (string, "@n");
+ g_string_append_printf (string, "%"G_GINT16_FORMAT,
+ g_variant_get_int16 (value));
+ break;
+
+ case G_VARIANT_TYPE_CLASS_UINT16:
+ if (type_annotate)
+ g_string_append (string, "@q");
+ g_string_append_printf (string, "%"G_GUINT16_FORMAT,
+ g_variant_get_uint16 (value));
+ break;
+
+ case G_VARIANT_TYPE_CLASS_INT32:
+ /* Never annotate this type because it is the default for numbers
+ * (and this is a *pretty* printer)
+ */
+ g_string_append_printf (string, "%"G_GINT32_FORMAT,
+ g_variant_get_int32 (value));
+ break;
+
+ case G_VARIANT_TYPE_CLASS_UINT32:
+ if (type_annotate)
+ g_string_append (string, "@u");
+ g_string_append_printf (string, "%"G_GUINT32_FORMAT,
+ g_variant_get_uint32 (value));
+ break;
+
+ case G_VARIANT_TYPE_CLASS_INT64:
+ if (type_annotate)
+ g_string_append (string, "@x");
+ g_string_append_printf (string, "%"G_GINT64_FORMAT,
+ g_variant_get_int64 (value));
+ break;
+
+ case G_VARIANT_TYPE_CLASS_UINT64:
+ if (type_annotate)
+ g_string_append (string, "@t");
+ g_string_append_printf (string, "%"G_GUINT64_FORMAT,
+ g_variant_get_uint64 (value));
+ break;
+
+ case G_VARIANT_TYPE_CLASS_DOUBLE:
+ {
+ gint i;
+ gchar *repr = NULL;
+
+ /* No need to type-annotate here, because we always use at least 1dp - and
+ * any number with a decimal point is clearly a double.
+ */
+
+ /* print float at the minimum precision to maintain its value.
+ * FIXME: this is a ridiculous algorithm.
+ */
+ for (i=1; i<255; i++)
+ {
+ GVariant *variant; gdouble value_repr;
+ GError *error = NULL;
+ g_free (repr);
+ repr = g_strdup_printf ("%.*f", i, g_variant_get_double (value));
+ variant = g_variant_parse (repr, -1, G_VARIANT_TYPE_DOUBLE, &error);
+ g_assert_no_error (error);
+ g_return_val_if_fail (variant != NULL, string);
+ value_repr = g_variant_get_double (variant);
+ g_variant_unref (variant);
+ if (value_repr == g_variant_get_double (value))
+ break;
+ }
+ g_string_append_printf (string, "%s", repr);
+ g_free (repr);
+ break;
+ }
+
+ case G_VARIANT_TYPE_CLASS_OBJECT_PATH:
+ if (type_annotate)
+ g_string_append (string, "@o");
+ g_string_append_printf (string, "\"%s\"",
+ g_variant_get_string (value, NULL));
+ break;
+
+ case G_VARIANT_TYPE_CLASS_SIGNATURE:
+ if (type_annotate)
+ g_string_append (string, "@g");
+ g_string_append_printf (string, "\"%s\"",
+ g_variant_get_string (value, NULL));
+ break;
+
+ default:
+ g_error ("g_variant_print: sorry... not handled yet: %s",
+ g_variant_get_type_string (value));
+ }
+
+ return string;
+};
+
+#define _gvariant_printer_c_
+#include "galiasdef.c"
diff --git a/glib/gvariant.h b/glib/gvariant.h
index 958da3c..0056a61 100644
--- a/glib/gvariant.h
+++ b/glib/gvariant.h
@@ -145,7 +145,12 @@ GVariantBuilder *g_variant_builder_new (GVarian
GVariant *g_variant_builder_end (GVariantBuilder *builder);
void g_variant_builder_cancel (GVariantBuilder *builder);
-/* text parsing */
+/* text printing/parsing */
+gchar *g_variant_print (GVariant *value,
+ gboolean type_annotate);
+GString *g_variant_print_string (GVariant *value,
+ GString *string,
+ gboolean type_annotate);
GVariant * g_variant_parse (const gchar *text,
gint text_length,
const GVariantType *type,
@@ -156,7 +161,11 @@ GVariant * g_variant_parsef_va (const g
va_list *app);
/* markup printing/parsing */
-GString *g_variant_markup_print (GVariant *value,
+gchar *g_variant_markup_print (GVariant *value,
+ gboolean newlines,
+ gint indentation,
+ gint tabstop);
+GString *g_variant_markup_print_string (GVariant *value,
GString *string,
gboolean newlines,
gint indentation,
diff --git a/glib/tests/Makefile.am b/glib/tests/Makefile.am
index 90b6ca1..659337a 100644
--- a/glib/tests/Makefile.am
+++ b/glib/tests/Makefile.am
@@ -56,6 +56,9 @@ gvariant_fuzz_LDADD = $(progs_ldadd)
TEST_PROGS += gvariant-markup
gvariant_markup_LDADD = $(progs_ldadd)
+TEST_PROGS += gvariant-printer-parser
+gvariant_printer_parser_LDADD = $(progs_ldadd)
+
TEST_PROGS += gvariant-random
gvariant_random_LDADD = $(progs_ldadd)
diff --git a/glib/tests/gvariant-endian.c b/glib/tests/gvariant-endian.c
index 6101349..3200852 100644
--- a/glib/tests/gvariant-endian.c
+++ b/glib/tests/gvariant-endian.c
@@ -12,15 +12,15 @@ test_byteswap (void)
'\0', '(', 't', 'u', 'q', 'y', 'b', ')'
};
GVariant *value;
- GString *string;
+ gchar *string;
value = g_variant_load (NULL, data, sizeof data,
G_BIG_ENDIAN | G_VARIANT_LAZY_BYTESWAP);
- string = g_variant_markup_print (value, NULL, FALSE, 0, 0);
+ string = g_variant_markup_print (value, FALSE, 0, 0);
g_variant_unref (value);
- g_assert_cmpstr (string->str, ==, "<struct><uint64>8</uint64><uint32>1</uint32><uint16>2</uint16><byte>0x01</byte><false/></struct>");
- g_string_free (string, TRUE);
+ g_assert_cmpstr (string, ==, "<struct><uint64>8</uint64><uint32>1</uint32><uint16>2</uint16><byte>0x01</byte><false/></struct>");
+ g_free (string);
}
int
diff --git a/glib/tests/gvariant-fuzz.c b/glib/tests/gvariant-fuzz.c
index df45988..3fb778d 100644
--- a/glib/tests/gvariant-fuzz.c
+++ b/glib/tests/gvariant-fuzz.c
@@ -356,24 +356,24 @@ fuzz_iteration (gdouble fuzziness)
if (g_variant_is_normal_ (fuzzed_value))
{
- GString *different;
+ gchar *different;
- different = g_variant_markup_print (fuzzed_value, NULL, 0, 0, 0);
- g_assert_cmpstr (markup->str, !=, different->str);
- g_string_free (different, TRUE);
+ different = g_variant_markup_print (fuzzed_value, 0, 0, 0);
+ g_assert_cmpstr (markup->str, !=, different);
+ g_free (different);
}
else
{
GVariant *reconstructed;
- GString *fuzzy_markup;
+ gchar *fuzzy_markup;
- fuzzy_markup = g_variant_markup_print (fuzzed_value, NULL, 0, 0, 0);
- reconstructed = g_variant_markup_parse (fuzzy_markup->str,
+ fuzzy_markup = g_variant_markup_print (fuzzed_value, 0, 0, 0);
+ reconstructed = g_variant_markup_parse (fuzzy_markup,
-1, NULL, &error);
if (reconstructed == NULL)
g_error ("parsing reconstructed document '%s': %s\n",
- fuzzy_markup->str, error->message);
+ fuzzy_markup, error->message);
if (g_variant_get_size (reconstructed) == size)
{
@@ -383,7 +383,7 @@ fuzz_iteration (gdouble fuzziness)
g_assert (memcmp (reconstructed_data, slice, size) != 0);
}
- g_string_free (fuzzy_markup, TRUE);
+ g_free (fuzzy_markup);
g_variant_unref (reconstructed);
}
diff --git a/glib/tests/gvariant-markup.c b/glib/tests/gvariant-markup.c
index 16c9a2d..1fe8aa8 100644
--- a/glib/tests/gvariant-markup.c
+++ b/glib/tests/gvariant-markup.c
@@ -82,7 +82,7 @@ check_verbatim (gconstpointer data)
const char *markup = data;
GError *error = NULL;
GVariant *value;
- GString *out;
+ gchar *out;
value = g_variant_markup_parse (markup, -1, NULL, &error);
@@ -96,9 +96,9 @@ check_verbatim (gconstpointer data)
g_variant_flatten (value);
- out = g_variant_markup_print (value, NULL, FALSE, 0, 0);
- g_assert_cmpstr (markup, ==, out->str);
- g_string_free (out, TRUE);
+ out = g_variant_markup_print (value, FALSE, 0, 0);
+ g_assert_cmpstr (markup, ==, out);
+ g_free (out);
g_variant_unref (value);
}
diff --git a/glib/tests/gvariant-printer-parser.c b/glib/tests/gvariant-printer-parser.c
new file mode 100644
index 0000000..0099cde
--- /dev/null
+++ b/glib/tests/gvariant-printer-parser.c
@@ -0,0 +1,76 @@
+#include <glib.h>
+
+#define add_tests(func, basename, array) \
+ G_STMT_START { \
+ int __add_tests_i; \
+ \
+ for (__add_tests_i = 0; \
+ __add_tests_i < G_N_ELEMENTS (array); \
+ __add_tests_i++) \
+ { \
+ char *testname; \
+ \
+ testname = g_strdup_printf ("%s/%d", basename, __add_tests_i); \
+ g_test_add_data_func (testname, array[__add_tests_i], func); \
+ g_free (testname); \
+ } \
+ } G_STMT_END
+
+const char *verbatim_tests[] = {
+ "-34",
+
+ /* Floats are printed at the minimum precision to lose no accuracy. */
+ "4.3",
+
+ /* FIXME: use sf when it makes sense */
+ /*"4.3e16",*/
+
+ "3.141592653589793",
+
+ "\"Hello\"",
+
+ "[[3, 4], [5, 6]]",
+
+ "<(@y0x04, @x-16, 6.0, 3.141, \"Hello\", <<<<<5>>>>>)>",
+
+ "([true, false, false, true, false], [(), ()])",
+
+ "<@ai[]>",
+
+ "<@an[1, -1, 2, -3, -1, -2, 1, -3, 4, -7, 3, -10, 13, -23, 26]>"
+};
+
+static void
+check_verbatim (gconstpointer data)
+{
+ const char *string = data;
+ GError *error = NULL;
+ GVariant *value;
+ gchar *out;
+
+ value = g_variant_parse (string, -1, NULL, &error);
+
+ if (value == NULL)
+ {
+ g_assert (error != NULL);
+ g_error ("%s", error->message);
+ }
+ else
+ g_assert (error == NULL);
+
+ //g_variant_flatten (value);
+
+ out = g_variant_print (value, FALSE);
+ g_assert_cmpstr (string, ==, out);
+ g_free (out);
+ g_variant_unref (value);
+}
+
+int
+main (int argc, char **argv)
+{
+ g_test_init (&argc, &argv, NULL);
+
+ add_tests (check_verbatim, "/gvariant/parse/verbatim", verbatim_tests);
+ return g_test_run ();
+}
diff --git a/glib/tests/gvariant-random.c b/glib/tests/gvariant-random.c
index c5414ab..7aa080e 100644
--- a/glib/tests/gvariant-random.c
+++ b/glib/tests/gvariant-random.c
@@ -316,7 +316,7 @@ test (void)
else
g_assert (error == NULL);
- markup2 = g_variant_markup_print (variant, NULL, FALSE, 0, 0);
+ markup2 = g_variant_markup_print_string (variant, NULL, FALSE, 0, 0);
g_assert_cmpstr (markup1->str, ==, markup2->str);
g_string_free (markup1, TRUE);
g_string_free (markup2, TRUE);
diff --git a/glib/tests/gvariant-serialiser.c b/glib/tests/gvariant-serialiser.c
index 858c025..2784622 100644
--- a/glib/tests/gvariant-serialiser.c
+++ b/glib/tests/gvariant-serialiser.c
@@ -71,14 +71,14 @@ test (gconstpointer data)
{
const struct test_case *tc = data;
GVariant *variant;
- GString *markup;
+ gchar *markup;
variant = g_variant_load (G_VARIANT_TYPE (tc->type), tc->data, tc->size, 0);
- markup = g_variant_markup_print (variant, NULL, FALSE, 0, 0);
+ markup = g_variant_markup_print (variant, FALSE, 0, 0);
g_variant_unref (variant);
- g_assert_cmpstr (tc->markup, ==, markup->str);
- g_string_free (markup, TRUE);
+ g_assert_cmpstr (tc->markup, ==, markup);
+ g_free (markup);
}
int
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]