play: Convert com_ls() to lopsub.
authorAndre Noll <maan@tuebingen.mpg.de>
Mon, 28 Mar 2016 03:47:55 +0000 (03:47 +0000)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 26 Mar 2017 09:02:28 +0000 (11:02 +0200)
This also gets rid of the undocumented pattern matching. The command
now takes no arguments and always lists all files.

m4/lls/play_cmd.suite.m4
play.c
play.cmd

index 466468086ad8bd00ec9737967b51a5cf25ab1ed6..1c71e71e192294ae0ba53f6e3edc6f9712ef954d 100644 (file)
@@ -47,3 +47,10 @@ caption = list of commands
        [description]
                Negative values mean to jump backwards the given amount of seconds.
        [/description]
+
+[subcommand ls]
+       purpose = list the playlist
+       [description]
+               This prints all paths of the playlist. The currently
+               active file is marked with an asterisk.
+       [/description]
diff --git a/play.c b/play.c
index 4545502bcf86c9042bfbfee5535b4b6b0fecc682..1c1d809a8cd292798fbb138dc677c6467293d39d 100644 (file)
--- a/play.c
+++ b/play.c
@@ -7,7 +7,6 @@
 /** \file play.c Paraslash's standalone player. */
 
 #include <regex.h>
-#include <fnmatch.h>
 #include <signal.h>
 #include <inttypes.h>
 #include <lopsub.h>
@@ -837,24 +836,16 @@ static int com_tasks(struct play_task *pt, int argc, __a_unused char **argv)
        return 0;
 }
 
-static int com_ls(struct play_task *pt, int argc, char **argv)
+static int com_ls(struct play_task *pt,
+       __a_unused struct lls_parse_result *lpr)
 {
-       int i, j, ret;
+       int i;
 
-       if (argc == 1) {
-               FOR_EACH_PLAYLIST_FILE(i)
-                       list_file(pt, i);
-               return 0;
-       }
-       for (j = 1; j < argc; j++) {
-               FOR_EACH_PLAYLIST_FILE(i) {
-                       ret = fnmatch(argv[j], conf.inputs[i], 0);
-                       if (ret == 0) /* match */
-                               list_file(pt, i);
-               }
-       }
+       FOR_EACH_PLAYLIST_FILE(i)
+               list_file(pt, i);
        return 0;
 }
+EXPORT_PLAY_CMD_HANDLER(ls);
 
 static int com_play(struct play_task *pt, int argc, char **argv)
 {
index 595d0f4aa49fee237e5889f8d8699a67e068188c..799abbfd5600c2711e4f3550fbb1b2e8552adf17 100644 (file)
--- a/play.cmd
+++ b/play.cmd
@@ -2,12 +2,6 @@ BN: play
 SF: play.c
 SN: list of commands
 ---
-N: ls
-D: List playlist.
-U: ls
-H: This prints all paths of the playlist. The currently active file is
-H: marked with an asterisk.
----
 N: info
 D: Print information about the current file.
 U: info