Skip to content

Commit

Permalink
Support open end for mpd_search_add_window
Browse files Browse the repository at this point in the history
  • Loading branch information
jcorporation committed Dec 23, 2023
1 parent 714b5d6 commit 33bdde2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
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 33bdde2

Please sign in to comment.