[Lldb-commits] [lldb] [lldb] Ignore trailing spaces on quit confirmation (PR #162263)

Ebuka Ezike via lldb-commits lldb-commits at lists.llvm.org
Tue Oct 7 04:34:34 PDT 2025


https://github.com/da-viper created https://github.com/llvm/llvm-project/pull/162263

None

>From d443c3f8906345beb4dcce5065befbbd9b030153 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimyah1 at gmail.com>
Date: Tue, 7 Oct 2025 12:16:02 +0100
Subject: [PATCH] [lldb] Ignore trailing spaces on quit confirmation

---
 lldb/source/Core/IOHandler.cpp | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/lldb/source/Core/IOHandler.cpp b/lldb/source/Core/IOHandler.cpp
index 57819eeade6e8..e97a730287cdc 100644
--- a/lldb/source/Core/IOHandler.cpp
+++ b/lldb/source/Core/IOHandler.cpp
@@ -152,15 +152,16 @@ void IOHandlerConfirm::IOHandlerComplete(IOHandler &io_handler,
 
 void IOHandlerConfirm::IOHandlerInputComplete(IOHandler &io_handler,
                                               std::string &line) {
-  if (line.empty()) {
+  const llvm::StringRef input = llvm::StringRef(line).rtrim();
+  if (input.empty()) {
     // User just hit enter, set the response to the default
     m_user_response = m_default_response;
     io_handler.SetIsDone(true);
     return;
   }
 
-  if (line.size() == 1) {
-    switch (line[0]) {
+  if (input.size() == 1) {
+    switch (input[0]) {
     case 'y':
     case 'Y':
       m_user_response = true;
@@ -176,10 +177,10 @@ void IOHandlerConfirm::IOHandlerInputComplete(IOHandler &io_handler,
     }
   }
 
-  if (line == "yes" || line == "YES" || line == "Yes") {
+  if (input.compare_insensitive("yes")) {
     m_user_response = true;
     io_handler.SetIsDone(true);
-  } else if (line == "no" || line == "NO" || line == "No") {
+  } else if (input.compare_insensitive("no")) {
     m_user_response = false;
     io_handler.SetIsDone(true);
   }



More information about the lldb-commits mailing list