X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/968b44d37b9fcdc5232fb68312a65e4fc6b5f4ab..931d6a47c32a5b4c283243cb553ce71ee2b535d5:/src/common/intl.cpp diff --git a/src/common/intl.cpp b/src/common/intl.cpp index 5d7cb3e38d..f8b011a917 100644 --- a/src/common/intl.cpp +++ b/src/common/intl.cpp @@ -5,7 +5,6 @@ // Modified by: Michael N. Filippov // (2003/09/30 - PluralForms support) // Created: 29/01/98 -// RCS-ID: $Id$ // Copyright: (c) 1998 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -206,7 +205,11 @@ wxLanguageInfoArray *wxLocale::ms_languagesDB = NULL; void wxLocale::DoCommonInit() { - m_pszOldLocale = NULL; + // Store the current locale in order to be able to restore it in the dtor. + m_pszOldLocale = wxSetlocale(LC_ALL, NULL); + if ( m_pszOldLocale ) + m_pszOldLocale = wxStrdup(m_pszOldLocale); + m_pOldLocale = wxSetLocale(this); @@ -285,13 +288,7 @@ bool wxLocale::DoInit(const wxString& name, wxS("no locale to set in wxLocale::Init()") ); } - const char *oldLocale = wxSetlocale(LC_ALL, szLocale); - if ( oldLocale ) - m_pszOldLocale = wxStrdup(oldLocale); - else - m_pszOldLocale = NULL; - - if ( m_pszOldLocale == NULL ) + if ( !wxSetlocale(LC_ALL, szLocale) ) { wxLogError(_("locale '%s' cannot be set."), szLocale); } @@ -573,12 +570,14 @@ bool wxLocale::Init(int language, int flags) namespace { +#ifndef __WXOSX__ // Small helper function: get the value of the given environment variable and // return true only if the variable was found and has non-empty value. inline bool wxGetNonEmptyEnvVar(const wxString& name, wxString* value) { return wxGetEnv(name, value) && !value->empty(); } +#endif } // anonymous namespace @@ -593,7 +592,7 @@ inline bool wxGetNonEmptyEnvVar(const wxString& name, wxString* value) #if defined(__UNIX__) // first get the string identifying the language from the environment wxString langFull; -#ifdef __WXMAC__ +#ifdef __WXOSX__ wxCFRef userLocaleRef(CFLocaleCopyCurrent()); // because the locale identifier (kCFLocaleIdentifier) is formatted a little bit differently, eg @@ -1444,10 +1443,10 @@ wxString wxLocale::GetInfo(wxLocaleInfo index, wxLocaleCategory cat) // this were not the case. wxASSERT_MSG( strcmp(setlocale(LC_ALL, NULL), "C") == 0, wxS("You probably called setlocale() directly instead ") - wxS("of calling wxSetLocale() and now there is a ") + wxS("of using wxLocale and now there is a ") wxS("mismatch between C/C++ and Windows locale.\n") - wxS("Things are going to break, use wxSetLocale() to ") - wxS("avoid this!") ); + wxS("Things are going to break, please only change ") + wxS("locale by creating wxLocale objects to avoid this!") ); // Return the hard coded values for C locale. This is really the right