From 4d3ba6e7a20b05b1aaefe42a7e44d29ccb451d11 Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Tue, 3 Jun 2008 17:26:22 +0000 Subject: [PATCH] Fix using wrong encoding for document filename when doing a directory diff. Replace find_by_filename() with p_document->find_by_filename() (now it does the same job). git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2638 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 7 ++++++- plugins/vcdiff.c | 23 +++++------------------ 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index c1854d704..3222fe1c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,7 +2,7 @@ * src/build.c, src/dialogs.c, src/document.c, src/document.h, src/msgwindow.c, src/navqueue.c, src/plugindata.h, src/plugins.c, - src/symbols.c, src/win32.c, plugins/vcdiff.c: + src/symbols.c, src/win32.c: Note: this breaks the plugin API for plugins using document_find_by_filename(). Make document_find_by_filename() take only a utf8_filename argument, @@ -12,6 +12,11 @@ Add filename argument for document_save_file_as(). Add GeanyDocument::real_path field, which if non-NULL indicates the file once existed on disk (not just as an unsaved document filename). + * plugins/vcdiff.c: + Fix using wrong encoding for document filename when doing a + directory diff. + Replace find_by_filename() with p_document->find_by_filename() (now + it does the same job). 2008-06-03 Enrico Tröger diff --git a/plugins/vcdiff.c b/plugins/vcdiff.c index f0705bf65..6990808df 100644 --- a/plugins/vcdiff.c +++ b/plugins/vcdiff.c @@ -248,22 +248,8 @@ static void* get_cmd_env(gint cmd_type, gboolean cmd, const gchar* filename, int } -static int find_by_filename(const gchar* filename) -{ - guint i; - - for (i = 0; i < documents_array->len; i++) - { - if (documents[i]->is_valid && documents[i]->file_name && - strcmp(documents[i]->file_name, filename) == 0) - return i; - } - return -1; -} - - -/* name_prefix should be in UTF-8, and can have a path. */ -static void show_output(const gchar *std_output, const gchar *name_prefix, +/* utf8_name_prefix can have a path. */ +static void show_output(const gchar *std_output, const gchar *utf8_name_prefix, const gchar *force_encoding) { gchar *text, *detect_enc = NULL; @@ -271,7 +257,7 @@ static void show_output(const gchar *std_output, const gchar *name_prefix, GtkNotebook *book; gchar *filename; - filename = g_path_get_basename(name_prefix); + filename = g_path_get_basename(utf8_name_prefix); setptr(filename, g_strconcat(filename, ".vc.diff", NULL)); /* need to convert input text from the encoding of the original file into @@ -287,7 +273,7 @@ static void show_output(const gchar *std_output, const gchar *name_prefix, } if (text) { - idx = find_by_filename(filename); + idx = p_document->find_by_filename(filename); if ( idx == -1) { GeanyFiletype *ft = p_filetypes->lookup_by_name("Diff"); @@ -416,6 +402,7 @@ static void vcdirectory_activated(GtkMenuItem *menuitem, gpointer gdata) text = make_diff(base_name, VC_COMMAND_DIFF_DIR); if (text) { + setptr(base_name, p_utils->get_utf8_from_locale(base_name)); show_output(text, base_name, NULL); g_free(text); }