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 | |
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')
-rw-r--r-- | lldb/include/lldb/Interpreter/Options.h | 8 | ||||
-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 | ||||
-rw-r--r-- | lldb/tools/darwin-debug/darwin-debug.cpp | 2 | ||||
-rw-r--r-- | lldb/tools/debugserver/source/debugserver.cpp | 6 | ||||
-rw-r--r-- | lldb/tools/driver/Driver.cpp | 10 | ||||
-rw-r--r-- | lldb/tools/lldb-perf/common/clang/lldb_perf_clang.cpp | 2 | ||||
-rw-r--r-- | lldb/tools/lldb-perf/common/stepping/lldb-perf-stepping.cpp | 2 | ||||
-rw-r--r-- | lldb/tools/lldb-perf/darwin/sketch/sketch.cpp | 2 | ||||
-rw-r--r-- | lldb/tools/lldb-platform/lldb-platform.cpp | 6 |
11 files changed, 43 insertions, 40 deletions
diff --git a/lldb/include/lldb/Interpreter/Options.h b/lldb/include/lldb/Interpreter/Options.h index 7b3e3aa8b57..ac4daa8f579 100644 --- a/lldb/include/lldb/Interpreter/Options.h +++ b/lldb/include/lldb/Interpreter/Options.h @@ -45,10 +45,10 @@ namespace lldb_private { /// \endcode /// /// The options are specified using the format defined for the libc -/// options parsing function getopt_long: +/// options parsing function getopt_long_only: /// \code /// #include <getopt.h> -/// int getopt_long(int argc, char * const *argv, const char *optstring, const struct option *longopts, int *longindex); +/// int getopt_long_only(int argc, char * const *argv, const char *optstring, const struct option *longopts, int *longindex); /// \endcode /// /// Example code: @@ -139,7 +139,7 @@ public: /// Get the option definitions to use when parsing Args options. /// /// @see Args::ParseOptions (Options&) - /// @see man getopt_long + /// @see man getopt_long_only //------------------------------------------------------------------ struct option * GetLongOptions (); @@ -200,7 +200,7 @@ public: /// /// /// @see Args::ParseOptions (Options&) - /// @see man getopt_long + /// @see man getopt_long_only //------------------------------------------------------------------ virtual Error SetOptionValue (uint32_t option_idx, const char *option_arg) = 0; 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 diff --git a/lldb/tools/darwin-debug/darwin-debug.cpp b/lldb/tools/darwin-debug/darwin-debug.cpp index 1fe2e5948ff..dfcb17c8e0d 100644 --- a/lldb/tools/darwin-debug/darwin-debug.cpp +++ b/lldb/tools/darwin-debug/darwin-debug.cpp @@ -184,7 +184,7 @@ int main (int argc, char *const *argv, char *const *envp, const char **apple) int pass_env = 1; std::string unix_socket_name; std::string working_dir; - while ((ch = getopt_long(argc, argv, "a:dehsu:?", g_long_options, NULL)) != -1) + while ((ch = getopt_long_only(argc, argv, "a:dehsu:?", g_long_options, NULL)) != -1) { switch (ch) { diff --git a/lldb/tools/debugserver/source/debugserver.cpp b/lldb/tools/debugserver/source/debugserver.cpp index 4fcc0a18073..c69121ee232 100644 --- a/lldb/tools/debugserver/source/debugserver.cpp +++ b/lldb/tools/debugserver/source/debugserver.cpp @@ -760,7 +760,7 @@ show_usage_and_exit (int exit_code) //---------------------------------------------------------------------- -// option descriptors for getopt_long() +// option descriptors for getopt_long_only() //---------------------------------------------------------------------- static struct option g_long_options[] = { @@ -880,7 +880,7 @@ main (int argc, char *argv[]) } // NULL terminate the short option string. short_options[short_options_idx++] = '\0'; - while ((ch = getopt_long(argc, argv, short_options, g_long_options, &long_option_index)) != -1) + while ((ch = getopt_long_only(argc, argv, short_options, g_long_options, &long_option_index)) != -1) { DNBLogDebug("option: ch == %c (0x%2.2x) --%s%c%s\n", ch, (uint8_t)ch, @@ -1106,7 +1106,7 @@ main (int argc, char *argv[]) // fprintf(stderr, "error: no architecture was specified\n"); // exit (8); // } - // Skip any options we consumed with getopt_long + // Skip any options we consumed with getopt_long_only argc -= optind; argv += optind; diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index 236a2f090bc..ede1e8813e7 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -510,7 +510,7 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exit) return error; } - // Build the option_string argument for call to getopt_long. + // Build the option_string argument for call to getopt_long_only. for (int i = 0; long_options[i].name != NULL; ++i) { @@ -541,7 +541,7 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exit) m_debugger.SkipLLDBInitFiles (false); m_debugger.SkipAppInitFiles (false); - // Prepare for & make calls to getopt_long. + // Prepare for & make calls to getopt_long_only. #if __GLIBC__ optind = 0; #else @@ -552,7 +552,7 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exit) while (1) { int long_options_index = -1; - val = ::getopt_long (argc, const_cast<char **>(argv), option_string.c_str(), long_options, &long_options_index); + val = ::getopt_long_only (argc, const_cast<char **>(argv), option_string.c_str(), long_options, &long_options_index); if (val == -1) break; @@ -738,7 +738,7 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exit) // are arguments for the inferior program. If no file was specified with // -f, then what is left is the program name followed by any arguments. - // Skip any options we consumed with getopt_long + // Skip any options we consumed with getopt_long_only argc -= optind; argv += optind; @@ -755,7 +755,7 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exit) } else { - // Skip any options we consumed with getopt_long + // Skip any options we consumed with getopt_long_only argc -= optind; //argv += optind; // Commented out to keep static analyzer happy diff --git a/lldb/tools/lldb-perf/common/clang/lldb_perf_clang.cpp b/lldb/tools/lldb-perf/common/clang/lldb_perf_clang.cpp index a4eb4c64d30..cab9e57d981 100644 --- a/lldb/tools/lldb-perf/common/clang/lldb_perf_clang.cpp +++ b/lldb/tools/lldb-perf/common/clang/lldb_perf_clang.cpp @@ -333,7 +333,7 @@ GetShortOptionString (struct option *long_options) int main(int argc, const char * argv[]) { - // Prepare for & make calls to getopt_long. + // Prepare for & make calls to getopt_long_only. std::string short_option_string (GetShortOptionString(g_long_options)); diff --git a/lldb/tools/lldb-perf/common/stepping/lldb-perf-stepping.cpp b/lldb/tools/lldb-perf/common/stepping/lldb-perf-stepping.cpp index cf7964be0d8..82cf5eed559 100644 --- a/lldb/tools/lldb-perf/common/stepping/lldb-perf-stepping.cpp +++ b/lldb/tools/lldb-perf/common/stepping/lldb-perf-stepping.cpp @@ -222,7 +222,7 @@ GetShortOptionString (struct option *long_options) int main(int argc, const char * argv[]) { - // Prepare for & make calls to getopt_long. + // Prepare for & make calls to getopt_long_only. std::string short_option_string (GetShortOptionString(g_long_options)); diff --git a/lldb/tools/lldb-perf/darwin/sketch/sketch.cpp b/lldb/tools/lldb-perf/darwin/sketch/sketch.cpp index c92de0add39..361fcda8ac6 100644 --- a/lldb/tools/lldb-perf/darwin/sketch/sketch.cpp +++ b/lldb/tools/lldb-perf/darwin/sketch/sketch.cpp @@ -304,7 +304,7 @@ GetShortOptionString (struct option *long_options) int main(int argc, const char * argv[]) { - // Prepare for & make calls to getopt_long. + // Prepare for & make calls to getopt_long_only. SketchTest test; diff --git a/lldb/tools/lldb-platform/lldb-platform.cpp b/lldb/tools/lldb-platform/lldb-platform.cpp index 24a8f36982c..dd3c537b362 100644 --- a/lldb/tools/lldb-platform/lldb-platform.cpp +++ b/lldb/tools/lldb-platform/lldb-platform.cpp @@ -32,7 +32,7 @@ using namespace lldb; using namespace lldb_private; //---------------------------------------------------------------------- -// option descriptors for getopt_long() +// option descriptors for getopt_long_only() //---------------------------------------------------------------------- int g_debug = 0; @@ -117,7 +117,7 @@ main (int argc, char *argv[]) // return 3; // } - while ((ch = getopt_long(argc, argv, "l:f:L:", g_long_options, &long_option_index)) != -1) + while ((ch = getopt_long_only(argc, argv, "l:f:L:", g_long_options, &long_option_index)) != -1) { // DNBLogDebug("option: ch == %c (0x%2.2x) --%s%c%s\n", // ch, (uint8_t)ch, @@ -177,7 +177,7 @@ main (int argc, char *argv[]) ProcessGDBRemoteLog::EnableLog (log_stream_sp, 0,log_args.GetConstArgumentVector(), log_stream_sp.get()); } - // Skip any options we consumed with getopt_long + // Skip any options we consumed with getopt_long_only argc -= optind; argv += optind; |