From 66897d577ac5c587bb5b2b43bfb98e6c52be963c Mon Sep 17 00:00:00 2001 From: tildearrow Date: Fri, 28 Jun 2024 17:48:25 -0500 Subject: [PATCH] copy the locale somewhere --- src/main.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index d2ae385e0..de6a2f045 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -112,6 +112,7 @@ bool infoMode=false; std::vector params; #ifdef HAVE_LOCALE +char reqLocaleCopy[64]; char localeDir[4096]; const char* localeDirs[]={ @@ -557,20 +558,21 @@ int main(int argc, char** argv) { reqLocale+=".UTF-8"; } } + strncpy(reqLocaleCopy,reqLocale.c_str(),63); if (reqLocale!="en_US.UTF-8") { const char* localeRet=NULL; #ifdef HAVE_SETLOCALE - if ((localeRet=setlocale(LC_CTYPE,reqLocale.c_str()))==NULL) { + if ((localeRet=setlocale(LC_CTYPE,reqLocaleCopy))==NULL) { logE("could not set locale (CTYPE)!"); displayLocaleFailError=true; } else { logV("locale: %s",localeRet); } - if ((localeRet=setlocale(LC_MESSAGES,reqLocale.c_str()))==NULL) { + if ((localeRet=setlocale(LC_MESSAGES,reqLocaleCopy))==NULL) { logE("could not set locale (MESSAGES)!"); displayLocaleFailError=true; #ifdef HAVE_MOMO - if (momo_setlocale(LC_MESSAGES,reqLocale.c_str())==NULL) { + if (momo_setlocale(LC_MESSAGES,reqLocaleCopy)==NULL) { logV("Momo: could not set locale!"); } #endif @@ -583,7 +585,7 @@ int main(int argc, char** argv) { #endif } #else - if ((localeRet=momo_setlocale(LC_MESSAGES,reqLocale.c_str()))==NULL) { + if ((localeRet=momo_setlocale(LC_MESSAGES,reqLocaleCopy))==NULL) { logV("Momo: could not set locale!"); } else { logV("locale: %s",localeRet);