summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRosen Penev <rosenp@gmail.com>2020-03-26 19:32:31 -0700
committerRosen Penev <rosenp@gmail.com>2020-03-31 18:05:23 -0700
commit71e551df42fd8d63dccf788c8e17938b4bd96174 (patch)
treee50cbe1e76fa9a52b212cd8425354e742a777bb2
parent3540cf26b1b342f175255f2dc02e615483a1383c (diff)
replace locale.h with clocale
Switch to std:: functions. Changed the meson check. Works locally. Signed-off-by: Rosen Penev <rosenp@gmail.com>
-rw-r--r--meson.build2
-rw-r--r--src/Main.cxx14
2 files changed, 7 insertions, 9 deletions
diff --git a/meson.build b/meson.build
index 80175288c..a9116f90a 100644
--- a/meson.build
+++ b/meson.build
@@ -145,7 +145,7 @@ add_global_arguments(common_cppflags, language: 'cpp')
enable_daemon = not is_windows and not is_android and get_option('daemon')
conf.set('ENABLE_DAEMON', enable_daemon)
-conf.set('HAVE_LOCALE_H', compiler.has_header('locale.h'))
+conf.set('HAVE_CLOCALE', compiler.has_header('clocale'))
conf.set('HAVE_GETPWNAM_R', compiler.has_function('getpwnam_r'))
conf.set('HAVE_GETPWUID_R', compiler.has_function('getpwuid_r'))
diff --git a/src/Main.cxx b/src/Main.cxx
index b43fb14c8..bcba497ba 100644
--- a/src/Main.cxx
+++ b/src/Main.cxx
@@ -109,14 +109,12 @@
#include <systemd/sd-daemon.h>
#endif
-#include <stdlib.h>
+#include <climits>
-#ifdef HAVE_LOCALE_H
-#include <locale.h>
+#ifdef HAVE_CLOCALE
+#include <clocale>
#endif
-#include <climits>
-
static constexpr size_t KILOBYTE = 1024;
static constexpr size_t MEGABYTE = 1024 * KILOBYTE;
@@ -360,10 +358,10 @@ MainConfigured(const struct options &options, const ConfigData &raw_config)
#endif
#ifndef ANDROID
-#ifdef HAVE_LOCALE_H
+#ifdef HAVE_CLOCALE
/* initialize locale */
- setlocale(LC_CTYPE,"");
- setlocale(LC_COLLATE, "");
+ std::setlocale(LC_CTYPE,"");
+ std::setlocale(LC_COLLATE, "");
#endif
#endif