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:
parent
a266154e1f
commit
0396ade38b
17
tools/lvm.c
17
tools/lvm.c
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user