aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-03 11:51:32 +0200
committerMax Kellermann <max@duempel.org>2008-10-03 11:51:32 +0200
commit44ecb3b869a8106475b984b4a0d212f9b3b3a219 (patch)
tree5c9cd8001f54341a22ddeecfc2781fa979ce63f2
parentccc7cf81e560025520777118a00a4c041bd7a149 (diff)
downloadmpd-44ecb3b869a8106475b984b4a0d212f9b3b3a219.tar.gz
mpd-44ecb3b869a8106475b984b4a0d212f9b3b3a219.tar.xz
mpd-44ecb3b869a8106475b984b4a0d212f9b3b3a219.zip
use g_basename() instead of basename()
g_basename() is always available, no need to implement a fallback. Also use g_path_get_dirname(), g_path_get_basename().
Diffstat (limited to '')
-rw-r--r--configure.ac2
-rw-r--r--src/screen_browser.c8
-rw-r--r--src/screen_file.c16
-rw-r--r--src/strfsong.c3
-rw-r--r--src/support.c22
-rw-r--r--src/support.h4
6 files changed, 13 insertions, 42 deletions
diff --git a/configure.ac b/configure.ac
index 8ea3461c8..732b36f1e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,7 +44,7 @@ AC_CHECK_HEADER([locale.h],
dnl
dnl Check for functions
dnl
-AC_CHECK_FUNCS([basename strcasestr])
+AC_CHECK_FUNCS([strcasestr])
dnl
diff --git a/src/screen_browser.c b/src/screen_browser.c
index 1350a56b4..da0dc897c 100644
--- a/src/screen_browser.c
+++ b/src/screen_browser.c
@@ -21,7 +21,6 @@
#include "i18n.h"
#include "options.h"
#include "charset.h"
-#include "support.h"
#include "strfsong.h"
#include "screen_utils.h"
#include "gcc.h"
@@ -136,7 +135,7 @@ browser_lw_callback(unsigned idx, int *highlight, void *data)
if( entity->type==MPD_INFO_ENTITY_TYPE_DIRECTORY ) {
mpd_Directory *dir = entity->info.directory;
- char *directory = utf8_to_locale(basename(dir->path));
+ char *directory = utf8_to_locale(g_basename(dir->path));
g_snprintf(buf, BUFSIZE, "[%s]", directory);
g_free(directory);
@@ -148,7 +147,7 @@ browser_lw_callback(unsigned idx, int *highlight, void *data)
return buf;
} else if( entity->type==MPD_INFO_ENTITY_TYPE_PLAYLISTFILE ) {
mpd_PlaylistFile *plf = entity->info.playlistFile;
- char *filename = utf8_to_locale(basename(plf->path));
+ char *filename = utf8_to_locale(g_basename(plf->path));
g_snprintf(buf, BUFSIZE, playlist_format, filename);
g_free(filename);
@@ -213,7 +212,8 @@ load_playlist(mpdclient_t *c, filelist_entry_t *entry)
char *filename = utf8_to_locale(plf->path);
if (mpdclient_cmd_load_playlist_utf8(c, plf->path) == 0)
- screen_status_printf(_("Loading playlist %s..."), basename(filename));
+ screen_status_printf(_("Loading playlist %s..."),
+ g_basename(filename));
g_free(filename);
return 0;
}
diff --git a/src/screen_file.c b/src/screen_file.c
index baec535df..95510a516 100644
--- a/src/screen_file.c
+++ b/src/screen_file.c
@@ -20,7 +20,6 @@
#include "i18n.h"
#include "options.h"
#include "charset.h"
-#include "support.h"
#include "mpdclient.h"
#include "command.h"
#include "screen.h"
@@ -121,7 +120,7 @@ handle_delete(screen_t *screen, mpdclient_t *c)
}
plf = entity->info.playlistFile;
- str = utf8_to_locale(basename(plf->path));
+ str = utf8_to_locale(g_basename(plf->path));
buf = g_strdup_printf(_("Delete playlist %s [%s/%s] ? "), str, YES, NO);
g_free(str);
key = tolower(screen_getch(screen->status_window.w, buf));
@@ -176,12 +175,10 @@ browse_open(mpd_unused screen_t *screen, mpd_unused mpdclient_t *c)
static const char *
browse_title(char *str, size_t size)
{
- char *pathcopy;
- char *parentdir;
+ char *dirname, *parentdir;
- pathcopy = strdup(browser.filelist->path);
- parentdir = dirname(pathcopy);
- parentdir = basename(parentdir);
+ dirname = g_path_get_dirname(browser.filelist->path);
+ parentdir = g_path_get_basename(dirname);
if( parentdir[0] == '.' && strlen(parentdir) == 1 ) {
parentdir = NULL;
@@ -190,8 +187,9 @@ browse_title(char *str, size_t size)
g_snprintf(str, size, _("Browse: %s%s%s"),
parentdir ? parentdir : "",
parentdir ? "/" : "",
- basename(browser.filelist->path));
- free(pathcopy);
+ g_basename(browser.filelist->path));
+ free(dirname);
+ free(parentdir);
return str;
}
diff --git a/src/strfsong.c b/src/strfsong.c
index fcaf4ada1..cef2056c8 100644
--- a/src/strfsong.c
+++ b/src/strfsong.c
@@ -23,7 +23,6 @@
*/
#include "strfsong.h"
-#include "support.h"
#include "charset.h"
#include <string.h>
@@ -171,7 +170,7 @@ _strfsong(gchar *s,
if( strstr(song->file, "://") )
temp = utf8_to_locale(song->file);
else
- temp = utf8_to_locale(basename(song->file));
+ temp = utf8_to_locale(g_basename(song->file));
} else if (strncmp("%time%", p, n) == 0) {
if (song->time != MPD_SONG_NO_TIME) {
if (song->time > 3600) {
diff --git a/src/support.c b/src/support.c
index ca0266c1b..3ceac5a3a 100644
--- a/src/support.c
+++ b/src/support.c
@@ -43,28 +43,6 @@ remove_trailing_slash(char *path)
return path;
}
-#ifndef HAVE_BASENAME
-char *
-basename(char *path)
-{
- char *end;
-
- assert(path != NULL);
-
- path = remove_trailing_slash(path);
- end = path + strlen(path);
-
- while (end > path && *end != '/')
- end--;
-
- if (*end == '/' && end != path)
- return end+1;
-
- return path;
-}
-#endif /* HAVE_BASENAME */
-
-
#ifndef HAVE_STRCASESTR
const char *
strcasestr(const char *haystack, const char *needle)
diff --git a/src/support.h b/src/support.h
index 68f746dd3..305ecbcf1 100644
--- a/src/support.h
+++ b/src/support.h
@@ -7,10 +7,6 @@
#include <libgen.h>
#endif
-#ifndef HAVE_BASENAME
-char *basename(char *path);
-#endif
-
char *remove_trailing_slash(char *path);
const char *strcasestr(const char *haystack, const char *needle);