mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
lvm: fix shell completion
Previous commit 82617852a4
introduce bug in complession - as the rl_completion_matches()
needs to always advance to next element where the index
is held in static variable.
Add comment about this usage.
This commit is contained in:
parent
47f8bda051
commit
73298635b9
13
tools/lvm.c
13
tools/lvm.c
@ -52,7 +52,8 @@ static char *_list_cmds(const char *text, int state)
|
|||||||
|
|
||||||
for (;i < _cmdline->num_command_names;++i)
|
for (;i < _cmdline->num_command_names;++i)
|
||||||
if (!strncmp(text, _cmdline->command_names[i].name, len))
|
if (!strncmp(text, _cmdline->command_names[i].name, len))
|
||||||
return strdup(_cmdline->command_names[i].name);
|
/* increase position for next iteration */
|
||||||
|
return strdup(_cmdline->command_names[i++].name);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -102,9 +103,10 @@ static char *_list_args(const char *text, int state)
|
|||||||
|
|
||||||
/* Short form arguments */
|
/* Short form arguments */
|
||||||
if (len < 3) {
|
if (len < 3) {
|
||||||
for (;match_no < cna->num_args; ++match_no) {
|
while (match_no < cna->num_args) {
|
||||||
char s[3];
|
char s[3];
|
||||||
char c = (_cmdline->opt_names + cna->valid_args[match_no])->short_opt;
|
/* increase position for next iteration */
|
||||||
|
char c = _cmdline->opt_names[cna->valid_args[match_no++]].short_opt;
|
||||||
if (c) {
|
if (c) {
|
||||||
sprintf(s, "-%c", c);
|
sprintf(s, "-%c", c);
|
||||||
if (!strncmp(text, s, len))
|
if (!strncmp(text, s, len))
|
||||||
@ -117,8 +119,9 @@ static char *_list_args(const char *text, int state)
|
|||||||
if (match_no < cna->num_args)
|
if (match_no < cna->num_args)
|
||||||
match_no = cna->num_args;
|
match_no = cna->num_args;
|
||||||
|
|
||||||
for (;match_no - cna->num_args < cna->num_args; ++match_no) {
|
while ((match_no - cna->num_args) < cna->num_args) {
|
||||||
const char *l = (_cmdline->opt_names + cna->valid_args[match_no - cna->num_args])->long_opt;
|
/* increase position for next iteration */
|
||||||
|
const char *l = _cmdline->opt_names[cna->valid_args[match_no++ - cna->num_args]].long_opt;
|
||||||
if (*(l + 2) && !strncmp(text, l, len))
|
if (*(l + 2) && !strncmp(text, l, len))
|
||||||
return strdup(l);
|
return strdup(l);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user