# HG changeset patch # User William Pitcock # Date 1183515601 18000 # Node ID f4971c7d6384c8e0bf722a05605c291e673f7a5b # Parent 54081d5cbd760fec28c58caf885f41019db58f79 Remove inlined urldecoding functions and use g_filename_from_uri() instead where appropriate. diff -r 54081d5cbd76 -r f4971c7d6384 src/audacious/playlist.c --- a/src/audacious/playlist.c Tue Jul 03 19:45:35 2007 -0500 +++ b/src/audacious/playlist.c Tue Jul 03 21:20:01 2007 -0500 @@ -897,49 +897,6 @@ return playlist_ins_url(playlist, url, -1); } -static gchar * -_playlist_urldecode_basic_path(const gchar * encoded_path) -{ - const gchar *cur, *ext; - gchar *path, *tmp; - gint realchar; - - if (!encoded_path) - return NULL; - - if (!str_has_prefix_nocase(encoded_path, "file:")) - return NULL; - - cur = encoded_path + 5; - - if (str_has_prefix_nocase(cur, "//localhost")) - cur += 11; - - if (*cur == '/') - while (cur[1] == '/') - cur++; - - tmp = g_malloc0(strlen(cur) + 1); - - while ((ext = strchr(cur, '%')) != NULL) { - strncat(tmp, cur, ext - cur); - ext++; - cur = ext + 2; - if (!sscanf(ext, "%2x", &realchar)) { - /* Assume it is a literal '%'. Several file - * managers send unencoded file: urls on drag - * and drop. */ - realchar = '%'; - cur -= 2; - } - tmp[strlen(tmp)] = realchar; - } - - path = g_strconcat(tmp, cur, NULL); - g_free(tmp); - return path; -} - guint playlist_ins_dir(Playlist * playlist, const gchar * path, gint pos, @@ -948,7 +905,7 @@ guint entries = 0; GList *list, *node; GHashTable *htab; - gchar *path2 = _playlist_urldecode_basic_path(path); + gchar *path2 = g_filename_from_uri(path, NULL, NULL); if (path2 == NULL) path2 = g_strdup(path); diff -r 54081d5cbd76 -r f4971c7d6384 src/audacious/vfs.c --- a/src/audacious/vfs.c Tue Jul 03 19:45:35 2007 -0500 +++ b/src/audacious/vfs.c Tue Jul 03 21:20:01 2007 -0500 @@ -339,49 +339,6 @@ return NULL; } -static gchar * -_vfs_urldecode_basic_path(const gchar * encoded_path) -{ - const gchar *cur, *ext; - gchar *path, *tmp; - gint realchar; - - if (!encoded_path) - return NULL; - - if (!str_has_prefix_nocase(encoded_path, "file:")) - return NULL; - - cur = encoded_path + 5; - - if (str_has_prefix_nocase(cur, "//localhost")) - cur += 11; - - if (*cur == '/') - while (cur[1] == '/') - cur++; - - tmp = g_malloc0(strlen(cur) + 1); - - while ((ext = strchr(cur, '%')) != NULL) { - strncat(tmp, cur, ext - cur); - ext++; - cur = ext + 2; - if (!sscanf(ext, "%2x", &realchar)) { - /* Assume it is a literal '%'. Several file - * managers send unencoded file: urls on drag - * and drop. */ - realchar = '%'; - cur -= 2; - } - tmp[strlen(tmp)] = realchar; - } - - path = g_strconcat(tmp, cur, NULL); - g_free(tmp); - return path; -} - /** * vfs_file_test: * @path: A path to test. @@ -397,7 +354,7 @@ gchar *path2; gboolean ret; - path2 = _vfs_urldecode_basic_path(path); + path2 = g_filename_from_uri(path, NULL, NULL); if (path2 == NULL) path2 = g_strdup(path);