1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

cleanup: simplify option matching function

Avoid using sprintf and strncmp call, when
we really want to compare just one character.
This commit is contained in:
Zdenek Kabelac 2012-12-14 16:41:24 +01:00
parent a266154e1f
commit 0396ade38b

View File

@ -91,18 +91,11 @@ static char *_list_args(const char *text, int state)
return NULL; return NULL;
/* Short form arguments */ /* Short form arguments */
if (len < 3) { if (len == 2 && text[0] == '-') {
while (match_no < com->num_args) { while (match_no < com->num_args)
char s[3]; if (text[1] == (_cmdline->arg_props +
char c; com->valid_args[match_no++])->short_arg)
if (!(c = (_cmdline->arg_props + return strdup(text);
com->valid_args[match_no++])->short_arg))
continue;
sprintf(s, "-%c", c);
if (!strncmp(text, s, len))
return strdup(s);
}
} }
/* Long form arguments */ /* Long form arguments */