X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=gtk%2Fsrc%2Fplist.c;h=05d6fdd8ea62d09dbd8c7d27d5fa942aab79a650;hb=9460d9624a5cf24126bc39605bc47d43330fcdf4;hp=93178b370d8cd4bada54d2ac02253c20d92389eb;hpb=271235d4e92f31bcd7455db1d4226000ac629131;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/gtk/src/plist.c b/gtk/src/plist.c index 93178b37..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,28 +377,36 @@ 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); - buffer = g_malloc(size); + buffer = g_malloc(size+1); size = fread(buffer, 1, size, 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);