summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVic Yang <victoryang@chromium.org>2013-06-05 14:16:35 +0800
committerChromeBot <chrome-bot@google.com>2013-06-06 19:53:08 -0700
commit072bec3b2536568b3a63f10acb412286ae1cb33d (patch)
tree3b2968bc86f08a9babe23fb08d033f17a22abf60
parentc9caf9da43c4f21192b67f3cdf77e3b95c3386ec (diff)
downloadchrome-ec-072bec3b2536568b3a63f10acb412286ae1cb33d.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 Original-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> (cherry picked from commit 3e0e15d185f6a324451992a7c2bfc5000c4f15c8) Change-Id: I420ce6f2a1f50c484d395b383cbcf052090f210e Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/57696 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--common/console.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/common/console.c b/common/console.c
index bdf2a55737..f31a132b32 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;
}
}