SF.net SVN: geany:[3652] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Wed Mar 25 19:00:35 UTC 2009


Revision: 3652
          http://geany.svn.sourceforge.net/geany/?rev=3652&view=rev
Author:   eht16
Date:     2009-03-25 19:00:34 +0000 (Wed, 25 Mar 2009)

Log Message:
-----------
Check whether skipping the root element of a document's filename succeeded and use the filename itself if not (e.g. on relative filenames, #2702844).
Use the locale encoded filename when saving session files.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/keyfile.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-03-25 18:52:17 UTC (rev 3651)
+++ trunk/ChangeLog	2009-03-25 19:00:34 UTC (rev 3652)
@@ -4,6 +4,11 @@
    Delete the geany_run_script.sh immediately after execution
    to prevent leaking old copies when the script was quit unexpectedly
    (closes #2710482, patch by Martin Olsson, thanks).
+ * src/keyfile.c:
+   Check whether skipping the root element of a document's filename
+   succeeded and use the filename itself if not (e.g. on relative
+   filenames, #2702844).
+   Use the locale encoded filename when saving session files.
 
 
 2009-03-24  Frank Lanitz  <frank(at)frank(dot)uvena(dot)de>

Modified: trunk/src/keyfile.c
===================================================================
--- trunk/src/keyfile.c	2009-03-25 18:52:17 UTC (rev 3651)
+++ trunk/src/keyfile.c	2009-03-25 19:00:34 UTC (rev 3652)
@@ -230,19 +230,23 @@
 static gchar *get_session_file_string(GeanyDocument *doc)
 {
 	gchar *fname;
-	gchar *doc_filename;
+	gchar *locale_filename;
+	gchar *rootless_filename;
 	GeanyFiletype *ft = doc->file_type;
 
 	if (ft == NULL)	/* can happen when saving a new file when quitting */
 		ft = filetypes[GEANY_FILETYPES_NONE];
 
-	doc_filename = g_strdup(doc->file_name);
+	locale_filename = utils_get_locale_from_utf8(doc->file_name);
 	/* If the filename contains any ';' (semi-colons) we need to escape them otherwise
 	 * g_key_file_get_string_list() would fail reading them, so we replace them before
 	 * writing with usual colons which must never appear in a filename and replace them
 	 * back when we read the file again from the file.
 	 * (g_path_skip_root() to skip C:\... on Windows) */
-	g_strdelimit((gchar *) g_path_skip_root(doc_filename), ";", ':');
+	rootless_filename = (gchar *) g_path_skip_root(locale_filename);
+	if (locale_filename == NULL)
+		rootless_filename = locale_filename;
+	g_strdelimit(rootless_filename, ";", ':');
 
 	fname = g_strdup_printf("%d;%s;%d;%d;%d;%d;%d;%s;%d",
 		sci_get_current_position(doc->editor->sci),
@@ -252,9 +256,9 @@
 		doc->editor->indent_type,
 		doc->editor->auto_indent,
 		doc->editor->line_wrapping,
-		doc_filename,
+		locale_filename,
 		doc->editor->line_breaking);
-	g_free(doc_filename);
+	g_free(locale_filename);
 	return fname;
 }
 
@@ -890,6 +894,7 @@
 	guint pos;
 	const gchar *ft_name;
 	gchar *locale_filename;
+	gchar *rootless_filename;
 	gint enc_idx, indent_type;
 	gboolean ro, auto_indent, line_wrapping;
 	/** TODO when we have a global pref for line breaking, use its value */
@@ -906,7 +911,11 @@
 	/* try to get the locale equivalent for the filename */
 	locale_filename = utils_get_locale_from_utf8(tmp[7]);
 	/* replace ':' back with ';' (see get_session_file_string for details) */
-	g_strdelimit((gchar *) g_path_skip_root(locale_filename), ":", ';');
+	rootless_filename = (gchar *) g_path_skip_root(locale_filename);
+	if (locale_filename == NULL)
+		rootless_filename = locale_filename;
+	g_strdelimit(rootless_filename, ":", ';');
+
 	if (len > 8)
 		line_breaking = atoi(tmp[8]);
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list