diff options
author | Vic Yang <victoryang@chromium.org> | 2013-06-05 14:16:35 +0800 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-06-05 11:25:09 -0700 |
commit | 3e0e15d185f6a324451992a7c2bfc5000c4f15c8 (patch) | |
tree | f4cd4ed447113243a23fbf8f7fef8326056564fc | |
parent | 127b0531099f1a4ccc3dab333fdb44e792f13e74 (diff) | |
download | chrome-ec-3e0e15d185f6a324451992a7c2bfc5000c4f15c8.tar.gz |
Accept a command if it's a full match
On Spring, we now have commands 'i2c' and 'i2cscan'. Currently if we
type 'i2c', it's rejected as it's also the prefix of 'i2cscan'. Since
'i2c' is a full match of a legal command, we should accept it.
BUG=None
TEST=On Spring, check 'i2c' invokes 'i2c' command, and 'i2cs'/'i2cscan'
invokes 'i2cscan' command. Also check 'i2' is still rejected.
BRANCH=all
Change-Id: I65c4c148a5a3e9b025554fa8165ba76da7bc312f
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/57576
Reviewed-by: Randall Spangler <rspangler@chromium.org>
-rw-r--r-- | common/console.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/common/console.c b/common/console.c index e59760237d..077bd28b13 100644 --- a/common/console.c +++ b/common/console.c @@ -80,6 +80,12 @@ static const struct console_command *find_command(char *name) if (!strncasecmp(name, cmd->name, match_length)) { if (match) return NULL; + /* + * Check if 'cmd->name' is of the same length as + * 'name'. If yes, then we have a full match. + */ + if (cmd->name[match_length] == '\0') + return cmd; match = cmd; } } |