summaryrefslogtreecommitdiffstats
path: root/input/cmd_parse.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-05-25 21:59:44 +0200
committerwm4 <wm4@nowhere>2015-05-25 21:59:44 +0200
commit289705daaf2986cedd0a1ae994aeda73c4b4249e (patch)
treeb1062e4a31fc7f8b734046e7cd9c54697193de7a /input/cmd_parse.c
parent6bfbd4ebdcadd5c94e4e47ba9712bf550293274f (diff)
downloadmpv-289705daaf2986cedd0a1ae994aeda73c4b4249e.tar.bz2
mpv-289705daaf2986cedd0a1ae994aeda73c4b4249e.tar.xz
input: allow - as separator between commands, instead of _
Wnile it seems quite logical to me that commands use _ as word separator, while properties use -, I can't really explain the difference, and it tends to confuse users as well. So always prefer - as separator for everything. Using _ still works, and will probably forever. Not doing so would probably create too much chaos and confusion.
Diffstat (limited to 'input/cmd_parse.c')
-rw-r--r--input/cmd_parse.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/input/cmd_parse.c b/input/cmd_parse.c
index f588bb7cf9..206bd4171f 100644
--- a/input/cmd_parse.c
+++ b/input/cmd_parse.c
@@ -69,8 +69,16 @@ static bool find_cmd(struct mp_log *log, struct mp_cmd *cmd, bstr name)
mp_err(log, "Command name missing.\n");
return false;
}
+
+ char nname[80];
+ snprintf(nname, sizeof(nname), "%.*s", BSTR_P(name));
+ for (int n = 0; nname[n]; n++) {
+ if (nname[n] == '_')
+ nname[n] = '-';
+ }
+
for (int n = 0; mp_cmds[n].name; n++) {
- if (bstr_equals0(name, mp_cmds[n].name)) {
+ if (strcmp(nname, mp_cmds[n].name) == 0) {
cmd->def = &mp_cmds[n];
cmd->name = (char *)cmd->def->name;
cmd->id = cmd->def->id;