[Xfce4-commits] <parole:bluesabre/gtk3> Use g_path_dirname instead of own implementation, fix crash with remember playlist (bug 10166)

Sean Davis noreply at xfce.org
Sun Aug 11 15:18:13 CEST 2013


Updating branch refs/heads/bluesabre/gtk3
         to 034878cebee2aa29d00d259bac53ca1d7181becd (commit)
       from b939f43939d56f7b2060658bbf2ccff3250752cd (commit)

commit 034878cebee2aa29d00d259bac53ca1d7181becd
Author: Sean Davis <smd.seandavis at gmail.com>
Date:   Sun Jul 7 21:45:53 2013 -0400

    Use g_path_dirname instead of own implementation, fix crash with remember playlist (bug 10166)

 src/misc/parole-pl-parser.c |   48 +++++++++++--------------------------------
 1 file changed, 12 insertions(+), 36 deletions(-)

diff --git a/src/misc/parole-pl-parser.c b/src/misc/parole-pl-parser.c
index 70dde3a..4e483ac 100644
--- a/src/misc/parole-pl-parser.c
+++ b/src/misc/parole-pl-parser.c
@@ -58,8 +58,6 @@ typedef struct
 
 gchar *g_substr (const gchar* string, gint start, gint end);
 
-gchar *g_char_dirname (const gchar *filename);
-
 static gchar*
 parole_filename_to_utf8(const gchar* filename)
 {
@@ -320,27 +318,6 @@ g_substr (const gchar* string,
     return g_utf8_strncpy (output, &string[start], len);
 }
 
-gchar *
-g_char_dirname (const gchar *filename)
-{
-    int index;
-    const gchar *ptr;
-    char *find;
-    gchar *f_name;
-    
-    f_name = g_strdup(filename);
-
-    find = "/";
-    ptr = strrchr((char *) f_name, find[0]);
-    
-    if (ptr)
-    {
-        index = ptr - f_name;
-        return g_substr(filename, 0, index);
-    }
-    return NULL;
-}
-
 static GSList *
 parole_pl_parser_parse_m3u (const gchar *filename)
 {
@@ -355,7 +332,7 @@ parole_pl_parser_parse_m3u (const gchar *filename)
     guint i;
     
     file = g_file_new_for_path (filename);
-    path = g_char_dirname(filename);
+    path = g_path_get_dirname(filename);
     
     if ( !g_file_load_contents (file, NULL, &contents, &size, NULL, NULL) )
 	goto out;
@@ -388,27 +365,26 @@ parole_pl_parser_parse_m3u (const gchar *filename)
 
     for ( i = 0; lines[i] != NULL; i++)
     {
-	if ( lines[i][0] == '\0' || lines[i][0] == '#')
-	    continue;
+	    if ( lines[i][0] == '\0' || lines[i][0] == '#')
+	        continue;
 	    
-    if ( lines[i][0] != '/' )
-    {
-        pl_filename = g_strjoin("", path, lines[i], NULL);
-        list = g_slist_append (list, parole_file_new (pl_filename));
-    }
+        if ( lines[i][0] == '/' ) {
+            pl_filename = g_strdup(lines[i]);
+        }
 
-    else {
-	    list = g_slist_append (list, parole_file_new (lines[i]));
-	}
+        else {
+	        pl_filename = g_strjoin("", path, lines[i], NULL);
+        }
+	    
+	    list = g_slist_append (list, parole_file_new (pl_filename));
     }
 
     if (pl_filename)
         g_free(pl_filename);
     g_strfreev (lines);
 out:
-
+    
     g_object_unref (file);
-
     return list;
 }
 


More information about the Xfce4-commits mailing list