1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +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;
/* Short form arguments */
if (len < 3) {
while (match_no < com->num_args) {
char s[3];
char c;
if (!(c = (_cmdline->arg_props +
com->valid_args[match_no++])->short_arg))
continue;
sprintf(s, "-%c", c);
if (!strncmp(text, s, len))
return strdup(s);
}
if (len == 2 && text[0] == '-') {
while (match_no < com->num_args)
if (text[1] == (_cmdline->arg_props +
com->valid_args[match_no++])->short_arg)
return strdup(text);
}
/* Long form arguments */