From 72748488addd651beb7b60da462c721f3e175357 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Tue, 13 Jul 2021 12:37:53 +0200 Subject: [PATCH] [lldb] Fix editline unicode on Linux Based on: [lldb-dev] proposed change to remove conditional WCHAR support in libedit wrapper https://lists.llvm.org/pipermail/lldb-dev/2021-July/016961.html There is already setlocale in lldb/source/Core/IOHandlerCursesGUI.cpp but that does not apply for Editline GUI editing. Unaware how to make automated test for this, it requires pty. Reviewed By: teemperor Differential Revision: https://reviews.llvm.org/D105779 --- lldb/source/Core/IOHandlerCursesGUI.cpp | 3 --- lldb/tools/driver/Driver.cpp | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lldb/source/Core/IOHandlerCursesGUI.cpp b/lldb/source/Core/IOHandlerCursesGUI.cpp index d37271bd1e53a..fb18e7d90eaa8 100644 --- a/lldb/source/Core/IOHandlerCursesGUI.cpp +++ b/lldb/source/Core/IOHandlerCursesGUI.cpp @@ -67,7 +67,6 @@ #include #include #include -#include #include #include #include @@ -2627,8 +2626,6 @@ class Application { } void Initialize() { - ::setlocale(LC_ALL, ""); - ::setlocale(LC_CTYPE, ""); m_screen = ::newterm(nullptr, m_out, m_in); ::start_color(); ::curs_set(0); diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp index b8c5aec5fd80b..a6a4a2a1b80b8 100644 --- a/lldb/tools/driver/Driver.cpp +++ b/lldb/tools/driver/Driver.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -867,6 +868,10 @@ static llvm::Optional InitializeReproducer(llvm::StringRef argv0, } int main(int argc, char const *argv[]) { + // Editline uses for example iswprint which is dependent on LC_CTYPE. + std::setlocale(LC_ALL, ""); + std::setlocale(LC_CTYPE, ""); + // Setup LLVM signal handlers and make sure we call llvm_shutdown() on // destruction. llvm::InitLLVM IL(argc, argv, /*InstallPipeSignalExitHandler=*/false);