]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/config.cpp
mingw32 doesn't define _tsystem so provide one ourselves (bug 1726904)
[wxWidgets.git] / src / common / config.cpp
index dadcf71c56b30704bde14df50d43f01ff9af6d72..e7e62a34bb7897ee5a56f3621265c224f08a8355 100644 (file)
@@ -37,6 +37,7 @@
 
 #if wxUSE_CONFIG && ((wxUSE_FILE && wxUSE_TEXTFILE) || wxUSE_CONFIG_NATIVE)
 
+#include "wx/apptrait.h"
 #include "wx/file.h"
 
 #include <stdlib.h>
@@ -54,6 +55,22 @@ bool          wxConfigBase::ms_bAutoCreate = true;
 // implementation
 // ============================================================================
 
+// ----------------------------------------------------------------------------
+// wxAppTraitsBase
+// ----------------------------------------------------------------------------
+
+wxConfigBase *wxAppTraitsBase::CreateConfig()
+{
+    return new
+    #if defined(__WXMSW__) && wxUSE_CONFIG_NATIVE
+        wxRegConfig(wxTheApp->GetAppName(), wxTheApp->GetVendorName());
+    #elif defined(__WXPALMOS__) && wxUSE_CONFIG_NATIVE
+        wxPrefConfig(wxTheApp->GetAppName());
+    #else // either we're under Unix or wish to use files even under Windows
+        wxFileConfig(wxTheApp->GetAppName());
+    #endif
+}
+
 // ----------------------------------------------------------------------------
 // wxConfigBase
 // ----------------------------------------------------------------------------
@@ -87,14 +104,10 @@ wxConfigBase *wxConfigBase::Set(wxConfigBase *pConfig)
 wxConfigBase *wxConfigBase::Create()
 {
   if ( ms_bAutoCreate && ms_pConfig == NULL ) {
-    ms_pConfig =
-    #if defined(__WXMSW__) && wxUSE_CONFIG_NATIVE
-        new wxRegConfig(wxTheApp->GetAppName(), wxTheApp->GetVendorName());
-    #elif defined(__WXPALMOS__) && wxUSE_CONFIG_NATIVE
-        new wxPrefConfig(wxTheApp->GetAppName());
-    #else // either we're under Unix or wish to use files even under Windows
-      new wxFileConfig(wxTheApp->GetAppName());
-    #endif
+    wxAppTraits * const traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
+    wxCHECK_MSG( traits, NULL, _T("create wxApp before calling this") );
+
+    ms_pConfig = traits->CreateConfig();
   }
 
   return ms_pConfig;
@@ -346,7 +359,7 @@ wxString wxExpandEnvVars(const wxString& str)
 
   size_t m;
   for ( size_t n = 0; n < str.length(); n++ ) {
-    switch ( str[n] ) {
+    switch ( str[n].GetValue() ) {
 #ifdef  __WXMSW__
       case wxT('%'):
 #endif  //WINDOWS
@@ -362,7 +375,7 @@ wxString wxExpandEnvVars(const wxString& str)
             bracket = Bracket_None;
           }
           else {
-            switch ( str[n + 1] ) {
+            switch ( str[n + 1].GetValue() ) {
               case wxT('('):
                 bracket = Bracket_Normal;
                 n++;                   // skip the bracket
@@ -382,7 +395,7 @@ wxString wxExpandEnvVars(const wxString& str)
 
           while ( m < str.length() && (wxIsalnum(str[m]) || str[m] == wxT('_')) )
             m++;
-
           wxString strVarName(str.c_str() + n + 1, m - n - 1);
 
 #ifdef __WXWINCE__
@@ -425,7 +438,7 @@ wxString wxExpandEnvVars(const wxString& str)
             else {
               // skip closing bracket unless the variables wasn't expanded
               if ( pszValue == NULL )
-                strResult << (char)bracket;
+                strResult << (wxChar)bracket;
               m++;
             }
           }
@@ -434,7 +447,7 @@ wxString wxExpandEnvVars(const wxString& str)
         }
         break;
 
-      case '\\':
+      case wxT('\\'):
         // backslash can be used to suppress special meaning of % and $
         if ( n != str.length() - 1 &&
                 (str[n + 1] == wxT('%') || str[n + 1] == wxT('$')) ) {