From f94d6a222965350b61542d180c17108216afd480 Mon Sep 17 00:00:00 2001 From: tastytea Date: Wed, 22 May 2019 12:25:06 +0200 Subject: [PATCH] Set locale globally. --- src/adoc.cpp | 18 ++++++------------ src/main.cpp | 3 +++ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/adoc.cpp b/src/adoc.cpp index 7fbba92..f1392e6 100644 --- a/src/adoc.cpp +++ b/src/adoc.cpp @@ -124,20 +124,14 @@ void export_adoc(const vector &entries, ostream &out) } else { // Sort by tag names otherwise. - std::locale loc(""); + std::locale loc; const std::collate &coll = std::use_facet>(loc); - if (coll.compare(a.first.data(), a.first.data() - + a.first.length(), - b.first.data(), b.first.data() - + b.first.length()) == -1) - { // -1 == less than - return true; - } - else - { - return false; - } + return (coll.compare( + a.first.data(), a.first.data() + + a.first.length(), + b.first.data(), b.first.data() + + b.first.length()) == -1); } }); diff --git a/src/main.cpp b/src/main.cpp index dcd92ad..a611c4a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "sqlite.hpp" #include "parse_options.hpp" #include "uri.hpp" @@ -33,6 +34,8 @@ using std::chrono::system_clock; int main(const int argc, const char *argv[]) { + std::locale::global(std::locale("")); // Set locale globally. + options opts = parse_options(argc, argv); if (opts.status_code != 0) {