summaryrefslogtreecommitdiff
path: root/data/reg2xml.c
diff options
context:
space:
mode:
authorAkira TAGOH <akira@tagoh.org>2012-08-16 15:41:53 +0900
committerAkira TAGOH <akira@tagoh.org>2012-08-16 15:41:53 +0900
commit71e2b41a366ecd150700025058364c7dbf3576a7 (patch)
tree03d8699602a40a3aa15118f4fb2444ecb8bfe6db /data/reg2xml.c
parente41b87790ccc953b2cb52363d391bd9affeeeb59 (diff)
Fix the broken output
I'm not sure what's wrong. but using xmlSaveFormatFileEnc() instead of xmlDocDumpFormatMemory() seems fixing this issue. (closes #5)
Diffstat (limited to 'data/reg2xml.c')
-rw-r--r--data/reg2xml.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/data/reg2xml.c b/data/reg2xml.c
index 5bd3b31..d6e5dcf 100644
--- a/data/reg2xml.c
+++ b/data/reg2xml.c
@@ -135,9 +135,8 @@ _parse(const gchar *filename,
}
static gboolean
-_output_xml(const gchar *filename,
- xmlChar **output,
- int *size)
+_output_xml(const gchar *filename,
+ const gchar *out_filename)
{
xmlDocPtr doc;
xmlNodePtr root;
@@ -153,7 +152,8 @@ _output_xml(const gchar *filename,
if (!(retval = _parse(filename, root)))
goto bail;
- xmlDocDumpFormatMemory(doc, output, size, 1);
+ xmlSaveFormatFileEnc(out_filename && out_filename[0] != '-' ? out_filename : "-",
+ doc, "UTF-8", 1);
bail:
xmlFreeDoc(doc);
@@ -165,16 +165,11 @@ int
main(int argc,
char **argv)
{
- xmlChar *xml;
- int size;
-
- if (argc < 2)
+ if (argc < 3)
return 1;
- if (!_output_xml(argv[1], &xml, &size))
+ if (!_output_xml(argv[1], argv[2]))
return 1;
- g_print("%s\n", xml);
-
return 0;
}