Skip to content

Commit

Permalink
Merge pull request #116 from jcorporation/search_window_open_end
Browse files Browse the repository at this point in the history
Support open end for mpd_search_add_window
  • Loading branch information
jcorporation authored Apr 23, 2024
2 parents 58936a5 + 712cd28 commit 606cf6e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ libmpdclient 2.23 (not yet released)
* support MPD protocol 0.24.0
- allow window for listplaylist and listplaylistinfo
- command "playlistlength"
* Support open end for mpd_search_add_window

libmpdclient 2.22 (2023/12/22)
* drop the unmaintained Vala bindings
Expand Down
1 change: 1 addition & 0 deletions include/mpd/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ mpd_search_add_sort_tag(struct mpd_connection *connection,
* @param connection a #mpd_connection
* @param start the start offset (including)
* @param end the end offset (not including)
* value "UINT_MAX" makes the end of the range open
* @return true on success, false on error
*
* @since libmpdclient 2.10
Expand Down
8 changes: 7 additions & 1 deletion src/search.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "iso8601.h"

#include <assert.h>
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
Expand Down Expand Up @@ -348,7 +349,12 @@ mpd_search_add_window(struct mpd_connection *connection,
if (dest == NULL)
return false;

snprintf(dest, size, " window %u:%u", start, end);
if (end == UINT_MAX)
/* the special value -1 means "open end" */
snprintf(dest, size, " window %u:", start);
else
snprintf(dest, size, " window %u:%u", start, end);

return true;
}

Expand Down

0 comments on commit 606cf6e

Please sign in to comment.