From 09db24c18659c90feb9ca99366cf10d0c7b047c5 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 30 Mar 2011 21:39:01 -0700 Subject: [PATCH] gui: Always convert file names to UTF-8 for use in syntax. Syntax as understood by the lexer is always in UTF-8, so file names have to be in UTF-8 too. (The PSPP code that opens files based on strings from syntax is already using utf8_to_filename() to convert them properly before opening.) Before commit 9ade26c8349 "lexer: Reimplement for better testability and internationalization", the encoding of syntax files was not well-defined. It was reasonable, then, to put file names in generated syntax in the file name encoding. Commit 9ade26c8349 changed the encoding of syntax so that it was always in UTF-8. This meant that file names in syntax had to be converted back into the file name encoding before trying to open the files, and I made that change (you can see, for example, the call to utf8_to_filename in do_insert() in src/language/utilities/include.c). But I forgot that the GUI needs to convert its file names into UTF-8 when it is generating syntax, so this commit fixes that up. --- src/ui/gui/psppire-data-window.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/ui/gui/psppire-data-window.c b/src/ui/gui/psppire-data-window.c index 9a3470ae..72f8abbb 100644 --- a/src/ui/gui/psppire-data-window.c +++ b/src/ui/gui/psppire-data-window.c @@ -351,19 +351,18 @@ dump_rm (GtkRecentManager *rm) static gboolean load_file (PsppireWindow *de, const gchar *file_name) { - gchar *native_file_name; + gchar *utf8_file_name; struct string filename; gchar *syntax; bool ok; ds_init_empty (&filename); - native_file_name = - convert_glib_filename_to_system_filename (file_name, NULL); + utf8_file_name = g_filename_to_utf8 (file_name, -1, NULL, NULL, NULL); - syntax_gen_string (&filename, ss_cstr (native_file_name)); + syntax_gen_string (&filename, ss_cstr (utf8_file_name)); - g_free (native_file_name); + g_free (utf8_file_name); syntax = g_strdup_printf ("GET FILE=%s.", ds_cstr (&filename)); ds_destroy (&filename); @@ -496,7 +495,7 @@ name_has_suffix (const gchar *name) static void save_file (PsppireWindow *w) { - gchar *native_file_name = NULL; + gchar *utf8_file_name = NULL; gchar *file_name = NULL; GString *fnx; struct string filename ; @@ -517,13 +516,12 @@ save_file (PsppireWindow *w) ds_init_empty (&filename); - native_file_name = - convert_glib_filename_to_system_filename (fnx->str, NULL); + utf8_file_name = g_filename_to_utf8 (fnx->str, -1, NULL, NULL, NULL); g_string_free (fnx, TRUE); - syntax_gen_string (&filename, ss_cstr (native_file_name)); - g_free (native_file_name); + syntax_gen_string (&filename, ss_cstr (utf8_file_name)); + g_free (utf8_file_name); syntax = g_strdup_printf ("%s OUTFILE=%s.", de->save_as_portable ? "EXPORT" : "SAVE", @@ -565,16 +563,16 @@ sysfile_info (PsppireDataWindow *de) gchar *file_name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); - gchar *native_file_name = - convert_glib_filename_to_system_filename (file_name, NULL); + gchar *utf8_file_name = g_filename_to_utf8 (file_name, -1, NULL, NULL, + NULL); gchar *syntax; ds_init_empty (&filename); - syntax_gen_string (&filename, ss_cstr (native_file_name)); + syntax_gen_string (&filename, ss_cstr (utf8_file_name)); - g_free (native_file_name); + g_free (utf8_file_name); syntax = g_strdup_printf ("SYSFILE INFO %s.", ds_cstr (&filename)); g_free (execute_syntax_string (syntax)); -- 2.30.2