From: Vadim Zeitlin Date: Sun, 27 May 2001 02:23:16 +0000 (+0000) Subject: fixed 'patch' #422993 (Error in wxConfigBase::Write for doubles) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/0da25f69ba98bcc60629d873820edacc17686e92 fixed 'patch' #422993 (Error in wxConfigBase::Write for doubles) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10343 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/config.cpp b/src/common/config.cpp index be417c4243..5ec9090807 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -134,8 +134,7 @@ bool wxConfigBase::Read(const wxString& key, double* val) const wxString str; if (Read(key, & str)) { - *val = wxAtof(str); - return TRUE; + return wxSscanf(str, _T("%g"), val) == 1; } return FALSE; @@ -190,14 +189,15 @@ bool wxConfigBase::Read(const wxString& key, int *pi, int defVal) const { long l; bool ret = Read(key, &l, (long) defVal); - *pi = (int) l; + if (ret) + *pi = (int) l; return ret; } bool wxConfigBase::Write(const wxString& key, double val) { wxString str; - str.Printf(wxT("%f"), val); + str.Printf(wxT("%g"), val); return Write(key, str); } @@ -209,8 +209,7 @@ bool wxConfigBase::Write(const wxString& key, bool value) bool wxConfigBase::Write( const wxString &key, const wxChar *text ) { - wxString str( text ) ; - return Write( key, str ) ; + return Write(key, str) ; } wxString wxConfigBase::ExpandEnvVars(const wxString& str) const {