]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
play: Convert com_jmp() to lopsub.
authorAndre Noll <maan@tuebingen.mpg.de>
Mon, 28 Mar 2016 16:55:58 +0000 (16:55 +0000)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 26 Mar 2017 09:02:28 +0000 (11:02 +0200)
The command handler needs to check that there is a single argument
which is an integer between 0 and 100. This check needs to be modified
to use the lopsub primitives rather than accessing the argument
vector directly.

Unfortunately we can not perform the conversion of the string argument
into an int value with lopsub since the given percentage is an unnamed
option rather than an argument of an option.

The patch also rewords the summary and the help text of the jmp
subcommand slightly to be more clear.

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

index d2f12a05921b5e2904eb891034a646efd8d029a9..744e7931e8cb4c16213c8ab2b57177814d34e9cf 100644 (file)
@@ -33,3 +33,10 @@ caption = list of commands
                key bindings map the colon key to this command, so pressing : in
                command mode activates insert mode.
        [/description]
                key bindings map the colon key to this command, so pressing : in
                command mode activates insert mode.
        [/description]
+
+[subcommand jmp]
+       purpose = change playback position
+       non-opts-name = percent
+       [description]
+               The percent argument must be an integer between 0 and 100, inclusively.
+       [/description]
diff --git a/play.c b/play.c
index 2b43f3552a96c270b454a5b59e88f66061f9d98a..952707545813c5af3613b3742603b5c78317682b 100644 (file)
--- a/play.c
+++ b/play.c
@@ -955,14 +955,20 @@ static int com_bg(struct play_task *pt,
 }
 EXPORT_PLAY_CMD_HANDLER(bg);
 
 }
 EXPORT_PLAY_CMD_HANDLER(bg);
 
-static int com_jmp(struct play_task *pt, int argc, char **argv)
+static int com_jmp(struct play_task *pt, struct lls_parse_result *lpr)
 {
        int32_t percent;
        int ret;
 {
        int32_t percent;
        int ret;
+       char *errctx;
 
 
-       if (argc != 2)
-               return -E_PLAY_SYNTAX;
-       ret = para_atoi32(argv[1], &percent);
+       ret = lls(lls_check_arg_count(lpr, 1, 1, &errctx));
+       if (ret < 0) {
+               if (errctx)
+                       PARA_ERROR_LOG("%s\n", errctx);
+               free(errctx);
+               return ret;
+       }
+       ret = para_atoi32(lls_input(0, lpr), &percent);
        if (ret < 0)
                return ret;
        if (percent < 0 || percent > 100)
        if (ret < 0)
                return ret;
        if (percent < 0 || percent > 100)
@@ -978,6 +984,7 @@ static int com_jmp(struct play_task *pt, int argc, char **argv)
        kill_stream(pt);
        return 0;
 }
        kill_stream(pt);
        return 0;
 }
+EXPORT_PLAY_CMD_HANDLER(jmp);
 
 static int com_ff(struct play_task *pt, int argc, char **argv)
 {
 
 static int com_ff(struct play_task *pt, int argc, char **argv)
 {
index d6b1396fd2a73b74246bef37eb89700f8889ba20..8e2fb6ac4823cd01460496282635df23059243f6 100644 (file)
--- a/play.cmd
+++ b/play.cmd
@@ -2,11 +2,6 @@ BN: play
 SF: play.c
 SN: list of commands
 ---
 SF: play.c
 SN: list of commands
 ---
-N: jmp
-D: Jump to position in current file.
-U: jmp <percent>
-H: The <percent> argument should be an integer between 0 and 100.
----
 N: ff
 D: Jump forwards or backwards.
 U: ff <seconds>
 N: ff
 D: Jump forwards or backwards.
 U: ff <seconds>