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

Revert "cleanup: simplify option matching function"

This reverts commit 0396ade38b.

The original code also handled len==1, which the new code doesn't.
Press <TAB> in the lvm shell to get a list of the possible
flag completions for a single hyphen.
This commit is contained in:
Alasdair G Kergon 2013-04-13 02:26:37 +01:00
parent c363c74a25
commit 9495a3d807

View File

@ -91,11 +91,18 @@ static char *_list_args(const char *text, int state)
return NULL;
/* Short form arguments */
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);
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);
}
}
/* Long form arguments */