From ea508635deaeeceb5629d0b09e17b03f8b767ade Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Tue, 18 Nov 2014 00:43:17 +0000 Subject: [PATCH] Have CommandObjectCommandsAddRegex inherit from IOHandlerDelegateMultiline so it will not immediately terminate after the first regular expression in "command regex " commands. Fixed the prompt to not include non-printable characters as it was hosing up the prompt when you ran "command regex foo" and entered multi-line editing mode. Fixed error strings to include more complete descriptions when bad regular expressions are entered. Removed the old IOHandlerLinesUpdated function as it is no longer needed (inheriting from IOHandlerDelegateMultiline takes care of what this function used to do). llvm-svn: 222207 --- .../source/Commands/CommandObjectCommands.cpp | 74 ++++--------------- 1 file changed, 16 insertions(+), 58 deletions(-) diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index 22cfc653edfa..a1a63cfd898a 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -873,7 +873,7 @@ protected: class CommandObjectCommandsAddRegex : public CommandObjectParsed, - public IOHandlerDelegate + public IOHandlerDelegateMultiline { public: CommandObjectCommandsAddRegex (CommandInterpreter &interpreter) : @@ -881,7 +881,7 @@ public: "command regex", "Allow the user to create a regular expression command.", "command regex [s/// ...]"), - IOHandlerDelegate(IOHandlerDelegate::Completion::LLDBCommand), + IOHandlerDelegateMultiline ("", IOHandlerDelegate::Completion::LLDBCommand), m_options (interpreter) { SetHelpLong( @@ -918,8 +918,8 @@ public: protected: - virtual void - IOHandlerActivated (IOHandler &io_handler) + void + IOHandlerActivated (IOHandler &io_handler) override { StreamFileSP output_sp(io_handler.GetOutputStreamFile()); if (output_sp) @@ -929,8 +929,8 @@ protected: } } - virtual void - IOHandlerInputComplete (IOHandler &io_handler, std::string &data) + void + IOHandlerInputComplete (IOHandler &io_handler, std::string &data) override { io_handler.SetIsDone(true); if (m_regex_cmd_ap.get()) @@ -942,7 +942,6 @@ protected: bool check_only = false; for (size_t i=0; i ", // Prompt and clear line + "> ", // Prompt NULL, // Continuation prompt multiple_lines, color_prompt, @@ -1112,21 +1066,25 @@ protected: if (second_separator_char_pos == std::string::npos) { - error.SetErrorStringWithFormat("missing second '%c' separator char after '%.*s'", + error.SetErrorStringWithFormat("missing second '%c' separator char after '%.*s' in '%.*s'", separator_char, (int)(regex_sed.size() - first_separator_char_pos - 1), - regex_sed.data() + (first_separator_char_pos + 1)); - return error; + regex_sed.data() + (first_separator_char_pos + 1), + (int)regex_sed.size(), + regex_sed.data()); + return error; } const size_t third_separator_char_pos = regex_sed.find (separator_char, second_separator_char_pos + 1); if (third_separator_char_pos == std::string::npos) { - error.SetErrorStringWithFormat("missing third '%c' separator char after '%.*s'", + error.SetErrorStringWithFormat("missing third '%c' separator char after '%.*s' in '%.*s'", separator_char, (int)(regex_sed.size() - second_separator_char_pos - 1), - regex_sed.data() + (second_separator_char_pos + 1)); + regex_sed.data() + (second_separator_char_pos + 1), + (int)regex_sed.size(), + regex_sed.data()); return error; }