From 21945f95fcdd5bedfdb2f7c9632011480927fb5e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 19 Jun 2022 03:02:56 +0200 Subject: [PATCH] Check that _NL_LOCALE_NAME is available before using it This symbol is not portable, so check for its availability before using it. Also avoid using wxLocaleIdent::GetName() uselessly if we're going to overwrite it anyhow. --- src/unix/uilocale.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/unix/uilocale.cpp b/src/unix/uilocale.cpp index 9c40e153fa..dc32d81522 100644 --- a/src/unix/uilocale.cpp +++ b/src/unix/uilocale.cpp @@ -349,8 +349,6 @@ wxUILocaleImplUnix::Use() void wxUILocaleImplUnix::InitLocaleNameAndCodeset() const { - m_name = m_locId.GetName(); - // We need to temporarily switch the locale, do it using extended locale // support if available as this doesn't affect any other threads or by // changing the global locale otherwise because we don't have any other @@ -363,7 +361,14 @@ wxUILocaleImplUnix::InitLocaleNameAndCodeset() const TempDefautLocaleSetter setDefautLocale(LC_CTYPE); #endif +#ifdef _NL_LOCALE_NAME m_name = GetLangInfo(_NL_LOCALE_NAME(LC_CTYPE)); +#else + // This won't work for the default or "C" locale, but we can't really get + // its name without nl_langinfo() support for this. + m_name = m_locId.GetName(); +#endif + m_codeset = GetLangInfo(CODESET); #endif // HAVE_LANGINFO_H }