ap

An audio player suited to my tastes
Log | Files | Refs | README | LICENSE

commit c2ae9384b581171be968e1408f4e4bea7724e379
parent 92735563632fd8a49f4bda93cdf39899902ceaee
Author: Jacob R. Edwards <jacobouno@protonmail.com>
Date:   Wed, 25 Aug 2021 15:25:33 -0700

Fix list command

Since they had little use and also broke the list command, numeric
patterns are no more.

Diffstat:
Maps/TODO | 2--
Maps/command.c | 8+++-----
Maps/find.c | 33++-------------------------------
3 files changed, 5 insertions(+), 38 deletions(-)

diff --git a/aps/TODO b/aps/TODO @@ -4,5 +4,3 @@ quoting and escaping - Use regular expressions instead of fnmatch(1) (maybe limiting find to a single pattern for simplicity) -- Fix list command with number patterns (since list increments items - 1 returns every other item instead of each one) diff --git a/aps/command.c b/aps/command.c @@ -101,13 +101,11 @@ aps_list(struct aps *aps, int s, int argc, char **argv) argc = arglen(argv); } - item = aps->queue; - while ((item = finddir(findnext, item, aps->queue, argv, argc, 0))) { + item = find(aps->queue, aps->queue, argv, argc, 0); + while (item) { if (respadd(aps, s, item->path)) return errstr; - item = findnext(item); - if (item == aps->queue) - return NULL; + item = find(item, aps->queue, argv, argc, FIND_NEXT); } return NULL; diff --git a/aps/find.c b/aps/find.c @@ -40,24 +40,6 @@ findprev(struct item *item) } struct item * -findnum(struct item *(*incr)(struct item *), struct item *item, struct item *end, - int num) -{ - if (num < 0) { - incr = REV(incr); - num = -num; - } - - while (item && num--) { - if ((item = incr(item)) == end) { - errno = ENOENT; - return NULL; - } - } - return item; -} - -struct item * finddir(struct item *(*incr)(struct item *), struct item *item, struct item *end, char **patterns, unsigned int len, unsigned int flags) { @@ -66,22 +48,11 @@ finddir(struct item *(*incr)(struct item *), struct item *item, struct item *end if (flags & FIND_REVERSE) incr = REV(incr); - - if (len == 1) { - nth = strtol(patterns[0], &ep, 10); - if (*ep == '\0') { - if (nth < INT_MIN || nth > INT_MAX) { - errno = EDOM; - return NULL; - } - return findnum(incr, item, end, nth); - } - } - if (flags & FIND_NEXT) - item = incr(item); + goto next; while (item && !multimatch(item->path, patterns, len)) { +next: if ((item = incr(item)) == end) { errno = ENOENT; return NULL;