summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim.muller@collabora.co.uk>2010-06-17 11:24:06 +0100
committerTim-Philipp Müller <tim.muller@collabora.co.uk>2010-06-17 11:24:06 +0100
commita2664ab4d335ec690039f4abdaaba3891c62da0f (patch)
tree352e5bc6281f19d03112a5b5165185d665656966
parent35617c2306d19c6d2460ea3dc9fcdabfc5dd1677 (diff)
gstdoc-scangobj: maintain previous XML formatting
Maintain the previous XML formatting, ie. add newlines after each xml item. Also make sure file does not end with a newline character. Simplify xmlprint() function a little to not use home-baked xml escaping - there's a GLib function for that, so we may just as well do it properly.
-rwxr-xr-xgstdoc-scangobj39
1 files changed, 14 insertions, 25 deletions
diff --git a/gstdoc-scangobj b/gstdoc-scangobj
index b017740..8b38d64 100755
--- a/gstdoc-scangobj
+++ b/gstdoc-scangobj
@@ -136,41 +136,30 @@ $includes
#ifdef GTK_IS_WIDGET_CLASS
#include <gtk/gtkversion.h>
#endif
-GType *object_types = NULL;
-GString *xmlstr = NULL;
+static GType *object_types = NULL;
+
+static GString *xmlstr = NULL;
static const gchar*
xmlprint (gint indent, const gchar *tag, const gchar *data)
{
- /* 20 spaces */
- gchar indent_str[] = " ";
-
+ const gchar indent_str[] = " ";
+
/* reset */
g_string_truncate (xmlstr, 0);
- g_string_append_printf (xmlstr, "%s<%s>", &indent_str[20-indent], tag);
+ g_string_append_len (xmlstr, indent_str, MIN (indent, strlen (indent_str)));
+ g_string_append_printf (xmlstr, "<%s>", tag);
if (data) {
- const gchar *s = data;
- while (*s) {
- switch (*s) {
- case '<':
- g_string_append (xmlstr, "&lt;");
- break;
- case '>':
- g_string_append (xmlstr, "&gt;");
- break;
- case '&':
- g_string_append (xmlstr, "&amp;");
- break;
- default:
- g_string_append_c (xmlstr, *s);
- }
- s++;
- }
+ gchar *s;
+
+ s = g_markup_escape_text (data, -1);
+ g_string_append (xmlstr, s);
+ g_free (s);
}
- g_string_append_printf (xmlstr, "</%s>", tag);
+ g_string_append_printf (xmlstr, "</%s>\\n", tag);
return xmlstr->str;
}
@@ -283,7 +272,7 @@ get_object_types (void)
features = g_list_next (features);
}
- fputs (" </elements>\\n</plugin>\\n", inspect);
+ fputs (" </elements>\\n</plugin>", inspect);
fclose (inspect);
}