pmc: prefer exact matches for command names

Previously if a command's full name was a prefix of another command
then parse_id would return AMBIGUOUS_ID. This was a problem for the
TIME and various TIME_* messages.
master
Geoff Salmon 2012-12-28 16:51:14 -05:00 committed by Richard Cochran
parent c8952c20c5
commit 8b40f4305b
1 changed files with 7 additions and 0 deletions

7
pmc.c
View File

@ -388,6 +388,13 @@ static int parse_action(char *s)
static int parse_id(char *s)
{
int i, index = BAD_ID, len = strlen(s);
/* check for exact match */
for (i = 0; i < ARRAY_SIZE(idtab); i++) {
if (strcasecmp(s, idtab[i].name) == 0) {
return i;
}
}
/* look for a unique prefix match */
for (i = 0; i < ARRAY_SIZE(idtab); i++) {
if (0 == strncasecmp(s, idtab[i].name, len)) {
if (index == BAD_ID)