From 73926ef5e5dbe1a3bfd627a016c3a975cf673327 Mon Sep 17 00:00:00 2001 From: Robert Hak Date: Thu, 17 Oct 2002 09:34:48 +0000 Subject: %pn now allows for conditional checking git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2698 a1c6a512-1295-4272-9138-f99709370657 --- apps/playlist.c | 21 ++++++++++++--------- apps/playlist.h | 2 +- apps/wps-display.c | 3 +-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/apps/playlist.c b/apps/playlist.c index 3cd40deb45..ce812c7c67 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -111,18 +111,21 @@ int playlist_first_index(void) return playlist.first_index; } -void playlist_name(char *name, int name_size) +char *playlist_name(char *buf, int buf_size) { - char buf[MAX_PATH+1]; - int i = 0; + char *sep; + + snprintf(buf, buf_size, "%s", playlist.filename+playlist.dirlen); - snprintf(buf, sizeof(buf), "%s", playlist.filename+playlist.dirlen); - while((buf[i] != '.') && (buf[i] != 0)) - i++; - buf[i] = 0; + if (0 == buf[0]) + return NULL; - snprintf(name, name_size, "%s", buf); - return; + /* Remove extension */ + sep = strrchr(buf, '.'); + if (NULL != sep) + *sep = 0; + + return buf; } int playlist_next(int steps) diff --git a/apps/playlist.h b/apps/playlist.h index 39ed3a568d..47422a40a5 100644 --- a/apps/playlist.h +++ b/apps/playlist.h @@ -45,13 +45,13 @@ int play_list(char *dir, char *file, int start_index, bool shuffled_index, int start_offset, int random_seed, int first_index); char* playlist_peek(int steps); +char* playlist_name(char *name, int name_size); int playlist_next(int steps); void randomise_playlist( unsigned int seed ); void sort_playlist(bool start_current); void empty_playlist(void); void add_indices_to_playlist(void); void playlist_clear(void); -void playlist_name(char *name, int name_size); int playlist_add(char *filename); int playlist_amount(void); int playlist_first_index(void); diff --git a/apps/wps-display.c b/apps/wps-display.c index 88bfa73687..f095fe5c58 100644 --- a/apps/wps-display.c +++ b/apps/wps-display.c @@ -319,8 +319,7 @@ static char* get_tag(struct mp3entry* id3, return buf; case 'n': /* Playlist Name (without path) */ - playlist_name(buf, buf_size); - return buf; + return playlist_name(buf, buf_size); case 'e': /* Playlist Total Entries */ snprintf(buf, buf_size, "%d", playlist_amount()); -- cgit v1.2.3