From 3bddb98de91ef48d481ab0b2da02d4111c40909b Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Tue, 4 Jun 2013 09:44:21 -0500 Subject: [PATCH] Fix wierd ConfigBaseWriteDouble's Printf( wxT("%12f"), aValue ); format string which was creating silly strings like PcbTextThickness=" 0.300000" in kicad.pro files. --- common/projet_config.cpp | 16 ++++++++++++++-- include/param_config.h | 20 +++----------------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/common/projet_config.cpp b/common/projet_config.cpp index 901eb2b1fd..2d50a29b5f 100644 --- a/common/projet_config.cpp +++ b/common/projet_config.cpp @@ -19,8 +19,20 @@ #include -#define CONFIG_VERSION 1 -#define FORCE_LOCAL_CONFIG true +#define CONFIG_VERSION 1 +#define FORCE_LOCAL_CONFIG true + + +void ConfigBaseWriteDouble( wxConfigBase* aConfig, const wxString& aKey, double aValue ) +{ + // Use a single strategy, regardless of wx version. + // Want C locale float string. + + LOCALE_IO toggle; + wxString tnumber = wxString::Format( wxT( "%.16g" ), aValue ); + + aConfig->Write( aKey, tnumber ); +} bool EDA_APP::ReCreatePrjConfig( const wxString& fileName, diff --git a/include/param_config.h b/include/param_config.h index cc27089349..fdb98fc18f 100644 --- a/include/param_config.h +++ b/include/param_config.h @@ -15,28 +15,14 @@ /** - * inline ConfigBaseWriteDouble - * This is a helper funvtion tor write doubles in config + * Function ConfigBaseWriteDouble + * This is a helper function to write doubles in config * We cannot use wxConfigBase->Write for a double, because * this function uses a format with very few digits in mantissa, * and truncation issues are frequent. * We use here a better floating format. - * - * Note: prior to 2.9.1, the separator was localized, and after, uses - * the "C" notation */ - void inline ConfigBaseWriteDouble( wxConfigBase* aConfig, - const wxString& aKey, double aValue ) - { - wxString tnumber; - -#if wxCHECK_VERSION(2,9,1) - tnumber = wxString::FromCDouble( aValue, 12 ); -#else - tnumber.Printf( wxT("%12f"), aValue ); -#endif - aConfig->Write( aKey, tnumber ); -} +void ConfigBaseWriteDouble( wxConfigBase* aConfig, const wxString& aKey, double aValue ); /** Type of parameter in the configuration file */