]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/config.cpp
applied tons of wxGrid patches
[wxWidgets.git] / src / common / config.cpp
index feccd99ab00c66508a97aac4ce8a70e376d6098a..da8e5b0901a0cbfa5d7a66088d7d2c5bf8858ec5 100644 (file)
@@ -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);
 }
 
@@ -207,11 +207,11 @@ bool wxConfigBase::Write(const wxString& key, bool value)
     return Write(key, l);
 }
 
-bool wxConfigBase::Write( const wxString &key, const wxChar *text )
+bool wxConfigBase::Write(const wxString &key, const wxChar *text)
 {
-       wxString str( text ) ;
-       return Write( key, str ) ;
+    return Write(key, text);
 }
+
 wxString wxConfigBase::ExpandEnvVars(const wxString& str) const
 {
     wxString tmp; // Required for BC++
@@ -246,7 +246,9 @@ wxConfigPathChanger::wxConfigPathChanger(const wxConfigBase *pContainer,
     m_bChanged = TRUE;
     m_strName = strEntry.AfterLast(wxCONFIG_PATH_SEPARATOR);
     m_strOldPath = m_pContainer->GetPath();
-    m_strOldPath += wxCONFIG_PATH_SEPARATOR;
+    if ( m_strOldPath.Len() == 0 || 
+         m_strOldPath.Last() != wxCONFIG_PATH_SEPARATOR )
+        m_strOldPath += wxCONFIG_PATH_SEPARATOR;
     m_pContainer->SetPath(strPath);
   }
   else {