Skip to content

Commit

Permalink
[lldb] Fix editline unicode on Linux
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jankratochvil committed Jul 13, 2021
1 parent af55335 commit 7274848
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 0 additions & 3 deletions lldb/source/Core/IOHandlerCursesGUI.cpp
Expand Up @@ -67,7 +67,6 @@
#include <cassert>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cstdint>
#include <cstdio>
#include <cstring>
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions lldb/tools/driver/Driver.cpp
Expand Up @@ -31,6 +31,7 @@
#include <algorithm>
#include <atomic>
#include <bitset>
#include <clocale>
#include <csignal>
#include <string>
#include <thread>
Expand Down Expand Up @@ -867,6 +868,10 @@ static llvm::Optional<int> 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);
Expand Down

0 comments on commit 7274848

Please sign in to comment.