Skip to content

Commit d443c3f

Browse files
committed
[lldb] Ignore trailing spaces on quit confirmation
1 parent bc39a8f commit d443c3f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lldb/source/Core/IOHandler.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,16 @@ void IOHandlerConfirm::IOHandlerComplete(IOHandler &io_handler,
152152

153153
void IOHandlerConfirm::IOHandlerInputComplete(IOHandler &io_handler,
154154
std::string &line) {
155-
if (line.empty()) {
155+
const llvm::StringRef input = llvm::StringRef(line).rtrim();
156+
if (input.empty()) {
156157
// User just hit enter, set the response to the default
157158
m_user_response = m_default_response;
158159
io_handler.SetIsDone(true);
159160
return;
160161
}
161162

162-
if (line.size() == 1) {
163-
switch (line[0]) {
163+
if (input.size() == 1) {
164+
switch (input[0]) {
164165
case 'y':
165166
case 'Y':
166167
m_user_response = true;
@@ -176,10 +177,10 @@ void IOHandlerConfirm::IOHandlerInputComplete(IOHandler &io_handler,
176177
}
177178
}
178179

179-
if (line == "yes" || line == "YES" || line == "Yes") {
180+
if (input.compare_insensitive("yes")) {
180181
m_user_response = true;
181182
io_handler.SetIsDone(true);
182-
} else if (line == "no" || line == "NO" || line == "No") {
183+
} else if (input.compare_insensitive("no")) {
183184
m_user_response = false;
184185
io_handler.SetIsDone(true);
185186
}

0 commit comments

Comments
 (0)