SF.net SVN: geany:[3663] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Fri Mar 27 15:40:20 UTC 2009


Revision: 3663
          http://geany.svn.sourceforge.net/geany/?rev=3663&view=rev
Author:   eht16
Date:     2009-03-27 15:40:19 +0000 (Fri, 27 Mar 2009)

Log Message:
-----------
Add utils_path_skip_root(), a relative path safe variant of g_path_skip_root (forgotten patch by Colomban Wendling, #2518658).

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

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-03-27 15:39:36 UTC (rev 3662)
+++ trunk/ChangeLog	2009-03-27 15:40:19 UTC (rev 3663)
@@ -1,6 +1,13 @@
+2009-03-27  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
+
+ * src/keyfile.c, src/utils.c, src/utils.h:
+   Add utils_path_skip_root(), a relative path safe variant of
+   g_path_skip_root (forgotten patch by Colomban Wendling, #2518658).
+
+
 2009-03-26  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
 
- * src\main.c, src\plugins.c, src\win32.c, src\win32.h:
+ * src/main.c, src/plugins.c, src/win32.c, src/win32.h:
    Use g_win32_get_package_installation_directory_of_module() on Windows
    with newer GLib versions instead of deprecated API.
  * src/keybindings.c:

Modified: trunk/src/keyfile.c
===================================================================
--- trunk/src/keyfile.c	2009-03-27 15:39:36 UTC (rev 3662)
+++ trunk/src/keyfile.c	2009-03-27 15:40:19 UTC (rev 3663)
@@ -231,7 +231,6 @@
 {
 	gchar *fname;
 	gchar *locale_filename;
-	gchar *rootless_filename;
 	GeanyFiletype *ft = doc->file_type;
 
 	if (ft == NULL)	/* can happen when saving a new file when quitting */
@@ -243,10 +242,7 @@
 	 * 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) */
-	rootless_filename = (gchar *) g_path_skip_root(locale_filename);
-	if (locale_filename == NULL)
-		rootless_filename = locale_filename;
-	g_strdelimit(rootless_filename, ";", ':');
+	g_strdelimit((gchar*) utils_path_skip_root(locale_filename), ";", ':');
 
 	fname = g_strdup_printf("%d;%s;%d;%d;%d;%d;%d;%s;%d",
 		sci_get_current_position(doc->editor->sci),
@@ -894,7 +890,6 @@
 	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 */
@@ -911,10 +906,7 @@
 	/* 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) */
-	rootless_filename = (gchar *) g_path_skip_root(locale_filename);
-	if (locale_filename == NULL)
-		rootless_filename = locale_filename;
-	g_strdelimit(rootless_filename, ":", ';');
+	g_strdelimit((gchar*) utils_path_skip_root(locale_filename), ":", ';');
 
 	if (len > 8)
 		line_breaking = atoi(tmp[8]);

Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c	2009-03-27 15:39:36 UTC (rev 3662)
+++ trunk/src/utils.c	2009-03-27 15:40:19 UTC (rev 3663)
@@ -319,6 +319,19 @@
 }
 
 
+/* Skips root if path is absolute, do nothing otherwise.
+ * This is a relative-safe version of g_path_skip_root().
+ */
+const gchar *utils_path_skip_root(const gchar *path)
+{
+	const gchar *path_relative;
+
+	path_relative = g_path_skip_root(path);
+
+	return (path_relative != NULL) ? path_relative : path;
+}
+
+
 gdouble utils_scale_round(gdouble val, gdouble factor)
 {
 	/*val = floor(val * factor + 0.5);*/

Modified: trunk/src/utils.h
===================================================================
--- trunk/src/utils.h	2009-03-27 15:39:36 UTC (rev 3662)
+++ trunk/src/utils.h	2009-03-27 15:40:19 UTC (rev 3663)
@@ -76,6 +76,8 @@
 
 gboolean utils_is_absolute_path(const gchar *path);
 
+const gchar *utils_path_skip_root(const gchar *path);
+
 gdouble utils_scale_round(gdouble val, gdouble factor);
 
 gboolean utils_str_equal(const gchar *a, const gchar *b);


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