Commit b7c4b788 authored by Max Kellermann's avatar Max Kellermann

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.
parent 6f0781f0
...@@ -390,7 +390,7 @@ handle_currentsong(struct client *client, ...@@ -390,7 +390,7 @@ handle_currentsong(struct client *client,
if (song < 0) if (song < 0)
return COMMAND_RETURN_OK; return COMMAND_RETURN_OK;
result = playlistInfo(client, song, song); result = playlistInfo(client, song, song + 1);
return print_playlist_result(client, result); return print_playlist_result(client, result);
} }
......
...@@ -425,7 +425,7 @@ enum playlist_result playlistInfo(struct client *client, int song, int max) ...@@ -425,7 +425,7 @@ enum playlist_result playlistInfo(struct client *client, int song, int max)
if (song >= (int)playlist.length) if (song >= (int)playlist.length)
return PLAYLIST_RESULT_BAD_RANGE; return PLAYLIST_RESULT_BAD_RANGE;
if (max > 0) { if (max > 0) {
end = MIN((unsigned)(max + 1), playlist.length); end = MIN((unsigned)max, playlist.length);
if (end <= begin) if (end <= begin)
return PLAYLIST_RESULT_BAD_RANGE; return PLAYLIST_RESULT_BAD_RANGE;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment