diff options
author | Alasdair G Kergon <agk@redhat.com> | 2013-04-13 02:26:37 +0100 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2013-04-13 02:26:37 +0100 |
commit | 9495a3d807b890f7a639e5761b2b37ba495b5d9b (patch) | |
tree | 86b2e3c9ecbe7f66b1b28d508a30e1584da97b06 /tools/lvm.c | |
parent | c363c74a251a5745e8ac6e274d1f7a1e32fa1843 (diff) | |
download | lvm2-9495a3d807b890f7a639e5761b2b37ba495b5d9b.tar.gz |
Revert "cleanup: simplify option matching function"
This reverts commit 0396ade38b88431d959ce02fac689306a2c47786.
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.
Diffstat (limited to 'tools/lvm.c')
-rw-r--r-- | tools/lvm.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/tools/lvm.c b/tools/lvm.c index 9b66516e0..ebce811bc 100644 --- a/tools/lvm.c +++ b/tools/lvm.c @@ -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 */ |