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.
This commit is contained in:
wm4
2015-05-25 21:59:44 +02:00
parent 6bfbd4ebdc
commit 289705daaf
6 changed files with 127 additions and 119 deletions

View File

@@ -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;