summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ccc7cf8)
raw | patch | inline | side by side (parent: ccc7cf8)
author | Max Kellermann <max@duempel.org> | |
Fri, 3 Oct 2008 09:51:32 +0000 (11:51 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Fri, 3 Oct 2008 09:51:32 +0000 (11:51 +0200) |
g_basename() is always available, no need to implement a fallback.
Also use g_path_get_dirname(), g_path_get_basename().
Also use g_path_get_dirname(), g_path_get_basename().
configure.ac | patch | blob | history | |
src/screen_browser.c | patch | blob | history | |
src/screen_file.c | patch | blob | history | |
src/strfsong.c | patch | blob | history | |
src/support.c | patch | blob | history | |
src/support.h | patch | blob | history |
diff --git a/configure.ac b/configure.ac
index 8ea3461c8b28c6f2cf8d2324bd88904fd3a27044..732b36f1e93647e1e9aa710b86611e17f0d10be4 100644 (file)
--- a/configure.ac
+++ b/configure.ac
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 1350a56b4b7c134460be439c401cde6dc28c83be..da0dc897c088093376c289f856a3399fe065da56 100644 (file)
--- a/src/screen_browser.c
+++ b/src/screen_browser.c
#include "i18n.h"
#include "options.h"
#include "charset.h"
-#include "support.h"
#include "strfsong.h"
#include "screen_utils.h"
#include "gcc.h"
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);
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);
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 baec535df502522b4738dc7a2252d306fdd04497..95510a516759dfd466a2f8f072bf617886c0d123 100644 (file)
--- a/src/screen_file.c
+++ b/src/screen_file.c
#include "i18n.h"
#include "options.h"
#include "charset.h"
-#include "support.h"
#include "mpdclient.h"
#include "command.h"
#include "screen.h"
}
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));
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;
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 fcaf4ada1673cbef53401b91f3527eb2186ea11c..cef2056c8b89b9d5e6bb49d85921f0d677ae6b7e 100644 (file)
--- a/src/strfsong.c
+++ b/src/strfsong.c
*/
#include "strfsong.h"
-#include "support.h"
#include "charset.h"
#include <string.h>
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 ca0266c1be28da9816a65ae6bf2a12c8badb429b..3ceac5a3a0d294450663497148fb6537ac584bfa 100644 (file)
--- a/src/support.c
+++ b/src/support.c
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 68f746dd3590af88ef8a65e8e31b148cb2428fd5..305ecbcf19d3fde468f3ea1cfe2d48a0aecbe97a 100644 (file)
--- a/src/support.h
+++ b/src/support.h
#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);