diff options
author | Zachary Turner <zturner@google.com> | 2016-11-18 23:22:42 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2016-11-18 23:22:42 +0000 |
commit | 53877afcb023523d1468240400400d376d1a85e6 (patch) | |
tree | 07af32873fb4862501b4757d6b2c0c48e8bb1475 /lldb/source/Interpreter/CommandInterpreter.cpp | |
parent | 47e577eb92194d6c0851c118eca75e010ae5f1af (diff) | |
download | bcm5719-llvm-53877afcb023523d1468240400400d376d1a85e6.tar.gz bcm5719-llvm-53877afcb023523d1468240400400d376d1a85e6.zip |
Convert CommandHistory functions to StringRef.
llvm-svn: 287401
Diffstat (limited to 'lldb/source/Interpreter/CommandInterpreter.cpp')
-rw-r--r-- | lldb/source/Interpreter/CommandInterpreter.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 320214df233..251f591ec9c 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -1564,17 +1564,18 @@ bool CommandInterpreter::HandleCommand(const char *command_line, else if (command_string[non_space] == m_comment_char) comment_command = true; else if (command_string[non_space] == CommandHistory::g_repeat_char) { - const char *history_string = - m_command_history.FindString(command_string.c_str() + non_space); - if (history_string == nullptr) { + llvm::StringRef search_str(command_string); + search_str = search_str.drop_front(non_space); + if (auto hist_str = m_command_history.FindString(search_str)) { + add_to_history = false; + command_string = *hist_str; + original_command_string = *hist_str; + } else { result.AppendErrorWithFormat("Could not find entry: %s in history", command_string.c_str()); result.SetStatus(eReturnStatusFailed); return false; } - add_to_history = false; - command_string = history_string; - original_command_string = history_string; } } @@ -1794,10 +1795,9 @@ int CommandInterpreter::HandleCompletion( if (first_arg[0] == m_comment_char) return 0; else if (first_arg[0] == CommandHistory::g_repeat_char) { - const char *history_string = m_command_history.FindString(first_arg); - if (history_string != nullptr) { + if (auto hist_str = m_command_history.FindString(first_arg)) { matches.Clear(); - matches.InsertStringAtIndex(0, history_string); + matches.InsertStringAtIndex(0, *hist_str); return -2; } else return 0; |