Fix a side effect of our LOCALE_IO by using setlocale( LC_NUMERIC, "C" ) instead of setlocale( LC_ALL, "C" ) LC_NUMERIC is the right option to use in LOCALE_IO because only the floating point separator must be modified When using LC_ALL, the Env var expansion wxGetEnv() was not working when the env var contains non ascii7 codes after a call to LOCALE_IO. When using setlocale( LC_NUMERIC, "C" ) in LOCALE_IO, wxGetEnv() works fine.

Fixes: lp:1795990
https://bugs.launchpad.net/kicad/+bug/1795990
This commit is contained in:
jean-pierre charras 2018-10-07 16:07:10 +02:00
parent 99f25b0895
commit 39c38fb386
2 changed files with 4 additions and 4 deletions

View File

@ -66,9 +66,9 @@ LOCALE_IO::LOCALE_IO()
if( m_c_count++ == 0 ) if( m_c_count++ == 0 )
{ {
// Store the user locale name, to restore this locale later, in dtor // Store the user locale name, to restore this locale later, in dtor
m_user_locale = setlocale( LC_ALL, 0 ); m_user_locale = setlocale( LC_NUMERIC, nullptr );
// Switch the locale to C locale, to read/write files with fp numbers // Switch the locale to C locale, to read/write files with fp numbers
setlocale( LC_ALL, "C" ); setlocale( LC_NUMERIC, "C" );
} }
} }
@ -79,7 +79,7 @@ LOCALE_IO::~LOCALE_IO()
if( --m_c_count == 0 ) if( --m_c_count == 0 )
{ {
// revert to the user locale // revert to the user locale
setlocale( LC_ALL, m_user_locale.c_str() ); setlocale( LC_NUMERIC, m_user_locale.c_str() );
} }
} }

View File

@ -831,7 +831,7 @@ bool PGM_BASE::SetLanguage( bool first_time )
if( result != dtst ) if( result != dtst )
// string to double encode/decode does not work! Bug detected: // string to double encode/decode does not work! Bug detected:
// Disable floating point localization: // Disable floating point localization:
setlocale( LC_ALL, "C" ); setlocale( LC_NUMERIC, "C" );
if( !m_locale->IsLoaded( dictionaryName ) ) if( !m_locale->IsLoaded( dictionaryName ) )
m_locale->AddCatalog( dictionaryName ); m_locale->AddCatalog( dictionaryName );