From 838631bc7d6d242ea168f3ed4206cf3c51b63733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Thu, 11 Sep 2014 18:23:49 +0200 Subject: Be stricter on what commands to accept at the ':'- prompt --- vis.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'vis.c') diff --git a/vis.c b/vis.c index 8ca33bd..88cefd2 100644 --- a/vis.c +++ b/vis.c @@ -993,6 +993,11 @@ static bool exec_command(char *cmdline) { init = true; } + /* regex should only apply to command name */ + char *s = strchr(cmdline, ' '); + if (s) + *s++ = '\0'; + Command *cmd = NULL; for (Command *c = cmds; c->name; c++) { if (!regexec(&c->regex, cmdline, 0, NULL, 0)) { @@ -1005,15 +1010,12 @@ static bool exec_command(char *cmdline) { return false; const char *argv[32] = { cmdline }; - char *s = cmdline; for (int i = 1; i < LENGTH(argv); i++) { - if (s) { - if ((s = strchr(s, ' '))) - *s++ = '\0'; - } while (s && *s && *s == ' ') s++; - argv[i] = s ? s : NULL; + argv[i] = s; + if (s && (s = strchr(s, ' '))) + *s++ = '\0'; } cmd->cmd(argv); -- cgit v1.2.3