Fix linux argument completion with for "--" options (llvm.org/bugs/pr14425)
Patch by Yacine Belkadi!
When __GLIBC__ is defined, optind gets initialized to 0. So for the first parsed
option, parse_start is 0, too. If this option has no argument (Like "--continue"
of "process attach"), then the position stored is 0, instead of 1. This prevents
the completion later on in Options::HandleOptionCompletion() because the opt_pos
doesn't match the cursor_index.
Fix that by getting the option's position from the value of optind, as it's done
for the other types of options.
Re-enable test_process_attach_dash_dash_con() on Linux.
No regressions detected on Mac OS X (in TestCompletion.py)
llvm-svn: 180114
diff --git a/lldb/source/Interpreter/Args.cpp b/lldb/source/Interpreter/Args.cpp
index 23d10be..0807de9 100644
--- a/lldb/source/Interpreter/Args.cpp
+++ b/lldb/source/Interpreter/Args.cpp
@@ -1507,7 +1507,6 @@
while (1)
{
bool missing_argument = false;
- int parse_start = optind;
int long_options_index = -1;
val = ::getopt_long_only (dummy_vec.size() - 1,
@@ -1601,7 +1600,7 @@
switch (long_options[long_options_index].has_arg)
{
case no_argument:
- option_element_vector.push_back (OptionArgElement (opt_defs_index, parse_start, 0));
+ option_element_vector.push_back (OptionArgElement (opt_defs_index, optind - 1, 0));
break;
case required_argument:
if (optarg != NULL)