From b7c4b78846cf2eba35517a1a0c435a3a056636f5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 10 Jan 2009 17:05:03 +0100 Subject: playlist: exclude end of range In a range "start:end", "end" itself should not be included. Use the same semantics as other languages implementing ranges, e.g. Python. --- src/command.c | 2 +- src/playlist.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/command.c b/src/command.c index 076bc2055..a00607fce 100644 --- a/src/command.c +++ b/src/command.c @@ -390,7 +390,7 @@ handle_currentsong(struct client *client, if (song < 0) return COMMAND_RETURN_OK; - result = playlistInfo(client, song, song); + result = playlistInfo(client, song, song + 1); return print_playlist_result(client, result); } diff --git a/src/playlist.c b/src/playlist.c index e6dd1cac0..f2cbf161f 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -425,7 +425,7 @@ enum playlist_result playlistInfo(struct client *client, int song, int max) if (song >= (int)playlist.length) return PLAYLIST_RESULT_BAD_RANGE; if (max > 0) { - end = MIN((unsigned)(max + 1), playlist.length); + end = MIN((unsigned)max, playlist.length); if (end <= begin) return PLAYLIST_RESULT_BAD_RANGE; } -- cgit v1.2.3