]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/config.cpp
Add #if checks fixing minimal wxGTK build.
[wxWidgets.git] / src / common / config.cpp
index 7ecc5d5778db1cafaa76532f8ff70a45fd58b500..636b490e3914dfd07372d87567059ed78b90d28f 100644 (file)
@@ -233,7 +233,14 @@ bool wxConfigBase::DoReadDouble(const wxString& key, double* val) const
     wxString str;
     if ( Read(key, &str) )
     {
-        return str.ToDouble(val);
+        if ( str.ToCDouble(val) )
+            return true;
+
+        // Previous versions of wxFileConfig wrote the numbers out using the
+        // current locale and not the C one as now, so attempt to parse the
+        // string as a number in the current locale too, for compatibility.
+        if ( str.ToDouble(val) )
+            return true;
     }
 
     return false;
@@ -256,7 +263,10 @@ wxString wxConfigBase::ExpandEnvVars(const wxString& str) const
 
 bool wxConfigBase::DoWriteDouble(const wxString& key, double val)
 {
-    return DoWriteString(key, wxString::Format(wxT("%g"), val));
+    // Notice that we always write out the numbers in C locale and not the
+    // current one. This makes the config files portable between machines using
+    // different locales.
+    return DoWriteString(key, wxString::FromCDouble(val));
 }
 
 bool wxConfigBase::DoWriteBool(const wxString& key, bool value)
@@ -272,10 +282,11 @@ wxConfigPathChanger::wxConfigPathChanger(const wxConfigBase *pContainer,
                                          const wxString& strEntry)
 {
   m_bChanged = false;
-  m_pContainer = (wxConfigBase *)pContainer;
+  m_pContainer = const_cast<wxConfigBase *>(pContainer);
 
-  // the path is everything which precedes the last slash
-  wxString strPath = strEntry.BeforeLast(wxCONFIG_PATH_SEPARATOR);
+  // the path is everything which precedes the last slash and the name is
+  // everything after it -- and this works correctly if there is no slash too
+  wxString strPath = strEntry.BeforeLast(wxCONFIG_PATH_SEPARATOR, &m_strName);
 
   // except in the special case of "/keyname" when there is nothing before "/"
   if ( strPath.empty() &&
@@ -307,13 +318,6 @@ wxConfigPathChanger::wxConfigPathChanger(const wxConfigBase *pContainer,
           m_strOldPath += wxCONFIG_PATH_SEPARATOR;
         m_pContainer->SetPath(strPath);
     }
-
-    // in any case, use the just the name, not full path
-    m_strName = strEntry.AfterLast(wxCONFIG_PATH_SEPARATOR);
-  }
-  else {
-    // it's a name only, without path - nothing to do
-    m_strName = strEntry;
   }
 }