diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2010-04-17 11:41:01 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2010-04-17 11:41:01 +0000 |
commit | bc18c894344dc3a74c2a71fc13e114b500cf18c1 (patch) | |
tree | f473f00108b9c606f78cc718b68e517c65b37c7c /apps/gui/skin_engine/skin_display.c | |
parent | c7815abb5239b00b4a23a63676abac15e455e617 (diff) |
use strlcat() instead of snprintf in the playlist viewer, and fix it so it will show the whole playlist if it would fit in the viewport (instead of missing the last item)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25660 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/gui/skin_engine/skin_display.c')
-rw-r--r-- | apps/gui/skin_engine/skin_display.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/apps/gui/skin_engine/skin_display.c b/apps/gui/skin_engine/skin_display.c index e991ba9aa0..5aa4d78cad 100644 --- a/apps/gui/skin_engine/skin_display.c +++ b/apps/gui/skin_engine/skin_display.c @@ -196,10 +196,9 @@ static void draw_playlist_viewer_list(struct gui_wps *gwps, struct mp3entry id3; #endif char buf[MAX_PATH*2], tempbuf[MAX_PATH]; - unsigned int buf_used = 0; gwps->display->set_viewport(viewer->vp); - for(i=start_item; (i-start_item)<lines && i<playlist_amount(); i++) + for(i=start_item; (i-start_item)<lines && i<=playlist_amount(); i++) { if (i == cur_playlist_pos) { @@ -223,9 +222,9 @@ static void draw_playlist_viewer_list(struct gui_wps *gwps, int line = pid3 ? TRACK_HAS_INFO : TRACK_HAS_NO_INFO; int j = 0, cur_string = 0; char *filename = playlist_peek(i-cur_playlist_pos); + unsigned int line_len = 0; buf[0] = '\0'; - buf_used = 0; - while (j < viewer->lines[line].count && (buf_used<sizeof(buf))) + while (j < viewer->lines[line].count && line_len < sizeof(buf)) { const char *out = NULL; token.type = viewer->lines[line].tokens[j]; @@ -234,8 +233,7 @@ static void draw_playlist_viewer_list(struct gui_wps *gwps, out = get_id3_token(&token, pid3, tempbuf, sizeof(tempbuf), -1, NULL); if (out) { - snprintf(&buf[buf_used], sizeof(buf)-buf_used, "%s", out); - buf_used += strlen(out); + line_len = strlcat(buf, out, sizeof(buf)); j++; continue; } @@ -270,8 +268,7 @@ static void draw_playlist_viewer_list(struct gui_wps *gwps, } if (tempbuf[0]) { - snprintf(&buf[buf_used], sizeof(buf)-buf_used, "%s", tempbuf); - buf_used += strlen(tempbuf); + line_len = strlcat(buf, tempbuf, sizeof(buf)); } j++; } |