X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=gtk%2Fsrc%2Fplist.c;h=05d6fdd8ea62d09dbd8c7d27d5fa942aab79a650;hb=f78e4458ad5918c9c65bf658982b9997d966f113;hp=b0a39c31b87996f8e00a14f3e7c4deb5247267df;hpb=aa299768662a9a133650087a5f8653593eca4347;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/gtk/src/plist.c b/gtk/src/plist.c index b0a39c31..05d6fdd8 100644 --- a/gtk/src/plist.c +++ b/gtk/src/plist.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include "plist.h" @@ -250,7 +251,7 @@ end_element( } break; case P_STRING: { - gval = ghb_string_value_new(g_strdup(pd->value)); + gval = ghb_string_value_new(pd->value); } break; case P_DATE: { @@ -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);