[Lldb-commits] [lldb] r120484 - in /lldb/trunk: lldb.xcodeproj/project.pbxproj source/Commands/CommandObjectHelp.cpp
Jim Ingham
jingham at apple.com
Tue Nov 30 14:59:38 PST 2010
Author: jingham
Date: Tue Nov 30 16:59:37 2010
New Revision: 120484
URL: http://llvm.org/viewvc/llvm-project?rev=120484&view=rev
Log:
Fix completion for multi-word commands in the "help" command.
Modified:
lldb/trunk/lldb.xcodeproj/project.pbxproj
lldb/trunk/source/Commands/CommandObjectHelp.cpp
Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=120484&r1=120483&r2=120484&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Tue Nov 30 16:59:37 2010
@@ -2459,6 +2459,7 @@
isa = PBXProject;
buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "lldb" */;
compatibilityVersion = "Xcode 3.1";
+ developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
en,
Modified: lldb/trunk/source/Commands/CommandObjectHelp.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectHelp.cpp?rev=120484&r1=120483&r2=120484&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectHelp.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectHelp.cpp Tue Nov 30 16:59:37 2010
@@ -74,6 +74,7 @@
if (cmd_obj != NULL)
{
+ StringList matches;
bool all_okay = true;
CommandObject *sub_cmd_obj = cmd_obj;
// Loop down through sub_command dictionaries until we find the command object that corresponds
@@ -81,17 +82,22 @@
for (int i = 1; i < argc && all_okay; ++i)
{
std::string sub_command = command.GetArgumentAtIndex(i);
+ matches.Clear();
if (! sub_cmd_obj->IsMultiwordObject ())
{
all_okay = false;
}
else
{
- pos = ((CommandObjectMultiword *) sub_cmd_obj)->m_subcommand_dict.find (sub_command);
- if (pos != ((CommandObjectMultiword *) sub_cmd_obj)->m_subcommand_dict.end())
- sub_cmd_obj = pos->second.get();
- else
+ CommandObject *found_cmd;
+ found_cmd = ((CommandObjectMultiword *) sub_cmd_obj)->GetSubcommandObject(sub_command.c_str(),
+ &matches);
+ if (found_cmd == NULL)
+ all_okay = false;
+ else if (matches.GetSize() != 1)
all_okay = false;
+ else
+ sub_cmd_obj = found_cmd;
}
}
@@ -99,9 +105,25 @@
{
std::string cmd_string;
command.GetCommandString (cmd_string);
- result.AppendErrorWithFormat
- ("'%s' is not a known command.\nTry 'help' to see a current list of commands.\n",
- cmd_string.c_str());
+ if (matches.GetSize() < 2)
+ {
+ result.AppendErrorWithFormat("'%s' is not a known command.\n"
+ "Try 'help' to see a current list of commands.\n",
+ cmd_string.c_str());
+ }
+ else
+ {
+ StreamString s;
+ s.Printf ("ambiguous command %s", cmd_string.c_str());
+ size_t num_matches = matches.GetSize();
+ for (size_t match_idx = 0; match_idx < num_matches; match_idx++)
+ {
+ s.Printf ("\n\t%s", matches.GetStringAtIndex(match_idx));
+ }
+ s.Printf ("\n");
+ result.AppendError(s.GetData());
+ }
+
result.SetStatus (eReturnStatusFailed);
}
else
More information about the lldb-commits
mailing list