X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=gtk%2Fsrc%2Fplist.c;h=05d6fdd8ea62d09dbd8c7d27d5fa942aab79a650;hb=0884cb45aeeb60a46effe1d1056a61fe68300ea7;hp=d3dcf2af02049cab9edf0f6fcd68c7d29dd6eae6;hpb=bdde3661fa516f965cc9d8e12fbc965929d94ac6;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/gtk/src/plist.c b/gtk/src/plist.c index d3dcf2af..05d6fdd8 100644 --- a/gtk/src/plist.c +++ b/gtk/src/plist.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "plist.h" @@ -348,7 +349,7 @@ parse_error(GMarkupParseContext *ctx, GError *error, gpointer ud) static void destroy_notify(gpointer data) { // Do nothing - g_debug("destroy parser"); + //g_debug("destroy parser"); } GValue* @@ -376,20 +377,27 @@ ghb_plist_parse(const gchar *buf, gssize len) g_markup_parse_context_parse(ctx, buf, len, &err); g_markup_parse_context_end_parse(ctx, &err); g_markup_parse_context_free(ctx); + if (pd.key) g_free(pd.key); + if (pd.value) g_free(pd.value); g_queue_free(pd.stack); g_queue_free(pd.tag_stack); return pd.plist; } GValue* -ghb_plist_parse_file(FILE *fd) +ghb_plist_parse_file(const gchar *filename) { gchar *buffer; size_t size; GValue *gval; + FILE *fd; + fd = g_fopen(filename, "r"); if (fd == NULL) + { + g_warning("Plist parse: failed to open %s", filename); return NULL; + } fseek(fd, 0, SEEK_END); size = ftell(fd); fseek(fd, 0, SEEK_SET); @@ -398,6 +406,7 @@ ghb_plist_parse_file(FILE *fd) buffer[size] = 0; gval = ghb_plist_parse(buffer, (gssize)size); g_free(buffer); + fclose(fd); return gval; } @@ -516,6 +525,11 @@ gval_write(FILE *file, GValue *gval) gint val = g_value_get_int64(gval); indent_fprintf(file, indent, "%d\n", val); } + else if (gtype == G_TYPE_INT) + { + gint val = g_value_get_int(gval); + indent_fprintf(file, indent, "%d\n", val); + } else if (gtype == G_TYPE_STRING) { const gchar *str = g_value_get_string(gval);