summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJos Dehaes <jos.dehaes@gmail.com>2021-09-29 08:30:05 +0200
committerGitHub <noreply@github.com>2021-09-29 08:30:05 +0200
commit4c70c5bdd98bfcc0ae9d9d9e8e3713dc8af71d03 (patch)
treeda1bcf3bfe7ca518540c51d5134e7b5d1be614b5
parent84a974695afaadc53d1d8576ea66255166ede482 (diff)
parentc70667e9e588336288c38d8bfef5da7cbb940ddb (diff)
Merge branch 'aristocratos:main' into main
-rw-r--r--src/btop.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/btop.cpp b/src/btop.cpp
index 945df32..656cff3 100644
--- a/src/btop.cpp
+++ b/src/btop.cpp
@@ -716,20 +716,20 @@ int main(int argc, char **argv) {
}
//? Try to find and set a UTF-8 locale
- if (bool found = false; std::setlocale(LC_ALL, NULL) == NULL or not str_to_upper(s_replace((string)std::setlocale(LC_ALL, NULL), "-", "")).ends_with("UTF8")) {
+ if (bool found = false; std::setlocale(LC_ALL, "") == NULL or not str_to_upper(s_replace((string)std::setlocale(LC_ALL, ""), "-", "")).ends_with("UTF8")) {
if (std::getenv("LANG") != NULL and str_to_upper(s_replace((string)std::getenv("LANG"), "-", "")).ends_with("UTF8") and std::setlocale(LC_ALL, std::getenv("LANG")) != NULL) {
found = true;
}
else {
- if (setenv("LANG", "", 1) == 0) {
+ if (setenv("LC_ALL", "", 1) == 0 and setenv("LANG", "", 1) == 0) {
try {
if (const auto loc = std::locale("").name(); not loc.empty() and loc != "*") {
for (auto& l : ssplit(loc, ';')) {
if (str_to_upper(s_replace(l, "-", "")).ends_with("UTF8")) {
if (std::setlocale(LC_ALL, l.substr(l.find('=') + 1).c_str()) != NULL) {
found = true;
+ break;
}
- break;
}
}
}
@@ -742,16 +742,16 @@ int main(int argc, char **argv) {
Logger::warning("No UTF-8 locale detected! Forcing start with --utf-force argument.");
else if (not found) {
Global::exit_error_msg = "No UTF-8 locale detected!\nUse --utf-force argument to force start if you're sure your terminal can handle it.";
- exit(1);
+ clean_quit(1);
}
else
- Logger::debug("Setting LC_ALL=" + (string)std::setlocale(LC_ALL, NULL));
+ Logger::debug("Setting LC_ALL=" + (string)std::setlocale(LC_ALL, ""));
}
//? Initialize terminal and set options
if (not Term::init()) {
Global::exit_error_msg = "No tty detected!\nbtop++ needs an interactive shell to run.";
- exit(1);
+ clean_quit(1);
}
if (Term::current_tty != "unknown") Logger::info("Running on " + Term::current_tty);
@@ -772,7 +772,7 @@ int main(int argc, char **argv) {
Term::refresh();
if (++t_count == 100) {
Global::exit_error_msg = "Failed to get size of terminal!";
- exit(1);
+ clean_quit(1);
}
}
}
@@ -783,7 +783,7 @@ int main(int argc, char **argv) {
}
catch (const std::exception& e) {
Global::exit_error_msg = "Exception in Shared::init() -> " + (string)e.what();
- exit(1);
+ clean_quit(1);
}
//? Update list of available themes and generate the selected theme