diff options
author | Greg Clayton <gclayton@apple.com> | 2013-04-04 20:35:24 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2013-04-04 20:35:24 +0000 |
commit | b7ad58a0dfe2a3db177472dacadc474a608e9bc0 (patch) | |
tree | 70e9c446c7e28b8b945c37d2665b027f9e8e67ea /lldb/source | |
parent | 563d9dc1b2ad4b7622575f7fbfdb99c84400d442 (diff) | |
download | bcm5719-llvm-b7ad58a0dfe2a3db177472dacadc474a608e9bc0.tar.gz bcm5719-llvm-b7ad58a0dfe2a3db177472dacadc474a608e9bc0.zip |
<rdar://problem/13457391>
LLDB now can use a single dash for all long options for all commands form the command line and from the command interpreter. This involved just switching all calls from getopt_long() to getopt_long_only().
llvm-svn: 178789
Diffstat (limited to 'lldb/source')
-rw-r--r-- | lldb/source/Interpreter/Args.cpp | 35 | ||||
-rw-r--r-- | lldb/source/Interpreter/CommandObject.cpp | 4 | ||||
-rw-r--r-- | lldb/source/Interpreter/Options.cpp | 6 |
3 files changed, 24 insertions, 21 deletions
diff --git a/lldb/source/Interpreter/Args.cpp b/lldb/source/Interpreter/Args.cpp index c3f32c3ed1f..23d10bedb52 100644 --- a/lldb/source/Interpreter/Args.cpp +++ b/lldb/source/Interpreter/Args.cpp @@ -655,11 +655,11 @@ Args::ParseOptions (Options &options) while (1) { int long_options_index = -1; - val = ::getopt_long(GetArgumentCount(), - GetArgumentVector(), - sstr.GetData(), - long_options, - &long_options_index); + val = ::getopt_long_only(GetArgumentCount(), + GetArgumentVector(), + sstr.GetData(), + long_options, + &long_options_index); if (val == -1) break; @@ -1314,8 +1314,11 @@ Args::ParseAliasOptions (Options &options, while (1) { int long_options_index = -1; - val = ::getopt_long (GetArgumentCount(), GetArgumentVector(), sstr.GetData(), long_options, - &long_options_index); + val = ::getopt_long_only (GetArgumentCount(), + GetArgumentVector(), + sstr.GetData(), + long_options, + &long_options_index); if (val == -1) break; @@ -1492,8 +1495,8 @@ Args::ParseArgsForCompletion int val; const OptionDefinition *opt_defs = options.GetDefinitions(); - // Fooey... getopt_long permutes the GetArgumentVector to move the options to the front. - // So we have to build another Arg and pass that to getopt_long so it doesn't + // Fooey... getopt_long_only permutes the GetArgumentVector to move the options to the front. + // So we have to build another Arg and pass that to getopt_long_only so it doesn't // change the one we have. std::vector<const char *> dummy_vec (GetArgumentVector(), GetArgumentVector() + GetArgumentCount() + 1); @@ -1507,11 +1510,11 @@ Args::ParseArgsForCompletion int parse_start = optind; int long_options_index = -1; - val = ::getopt_long (dummy_vec.size() - 1, - (char *const *) &dummy_vec.front(), - sstr.GetData(), - long_options, - &long_options_index); + val = ::getopt_long_only (dummy_vec.size() - 1, + (char *const *) &dummy_vec.front(), + sstr.GetData(), + long_options, + &long_options_index); if (val == -1) { @@ -1525,7 +1528,7 @@ Args::ParseArgsForCompletion // Handling the "--" is a little tricky, since that may mean end of options or arguments, or the // user might want to complete options by long name. I make this work by checking whether the // cursor is in the "--" argument, and if so I assume we're completing the long option, otherwise - // I let it pass to getopt_long which will terminate the option parsing. + // I let it pass to getopt_long_only which will terminate the option parsing. // Note, in either case we continue parsing the line so we can figure out what other options // were passed. This will be useful when we come to restricting completions based on what other // options we've seen on the line. @@ -1641,7 +1644,7 @@ Args::ParseArgsForCompletion } // Finally we have to handle the case where the cursor index points at a single "-". We want to mark that in - // the option_element_vector, but only if it is not after the "--". But it turns out that getopt_long just ignores + // the option_element_vector, but only if it is not after the "--". But it turns out that getopt_long_only just ignores // an isolated "-". So we have to look it up by hand here. We only care if it is AT the cursor position. if ((dash_dash_pos == -1 || cursor_index < dash_dash_pos) diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp index 96e0ef92316..d2b2ce54875 100644 --- a/lldb/source/Interpreter/CommandObject.cpp +++ b/lldb/source/Interpreter/CommandObject.cpp @@ -169,7 +169,7 @@ CommandObject::ParseOptions Error error; options->NotifyOptionParsingStarting(); - // ParseOptions calls getopt_long, which always skips the zero'th item in the array and starts at position 1, + // ParseOptions calls getopt_long_only, which always skips the zero'th item in the array and starts at position 1, // so we need to push a dummy value into position zero. args.Unshift("dummy_string"); error = args.ParseOptions (*options); @@ -416,7 +416,7 @@ CommandObject::HandleCompletion // I stick an element on the end of the input, because if the last element is - // option that requires an argument, getopt_long will freak out. + // option that requires an argument, getopt_long_only will freak out. input.AppendArgument ("<FAKE-VALUE>"); diff --git a/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp index 95b7078cdd8..6b509d40ef8 100644 --- a/lldb/source/Interpreter/Options.cpp +++ b/lldb/source/Interpreter/Options.cpp @@ -310,7 +310,7 @@ Options::GetLongOptions () } } - //getopt_long requires a NULL final entry in the table: + //getopt_long_only requires a NULL final entry in the table: m_getopt_table[i].name = NULL; m_getopt_table[i].has_arg = 0; @@ -796,7 +796,7 @@ Options::HandleOptionCompletion } else if (opt_defs_index != OptionArgElement::eUnrecognizedArg) { - // We recognized it, if it an incomplete long option, complete it anyway (getopt_long is + // We recognized it, if it an incomplete long option, complete it anyway (getopt_long_only is // happy with shortest unique string, but it's still a nice thing to do.) Otherwise return // The string so the upper level code will know this is a full match and add the " ". if (cur_opt_str && strlen (cur_opt_str) > 2 @@ -819,7 +819,7 @@ Options::HandleOptionCompletion // FIXME - not handling wrong options yet: // Check to see if they are writing a long option & complete it. // I think we will only get in here if the long option table has two elements - // that are not unique up to this point. getopt_long does shortest unique match + // that are not unique up to this point. getopt_long_only does shortest unique match // for long options already. if (cur_opt_str && strlen (cur_opt_str) > 2 |