]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/fileconf.cpp
Added configure patch for DEC
[wxWidgets.git] / src / common / fileconf.cpp
index 4b44249b6eb6eb3755d8cd4da98744884536d883..83e3659140b4197e20f31398909a2960c00932f0 100644 (file)
@@ -78,6 +78,9 @@ static wxString FilterOutValue(const wxString& str);
 static wxString FilterInEntryName(const wxString& str);
 static wxString FilterOutEntryName(const wxString& str);
 
+// get the name to use in wxFileConfig ctor
+static wxString GetAppName(const wxString& appname);
+
 // ============================================================================
 // implementation
 // ============================================================================
@@ -198,9 +201,9 @@ void wxFileConfig::Init()
 wxFileConfig::wxFileConfig(const wxString& appName, const wxString& vendorName,
                            const wxString& strLocal, const wxString& strGlobal,
                            long style)
-            : wxConfigBase(!appName && wxTheApp ? wxTheApp->GetAppName()
-                                                : appName,
-                           vendorName, strLocal, strGlobal, style),
+            : wxConfigBase(::GetAppName(appName), vendorName,
+                           strLocal, strGlobal,
+                           style),
               m_strLocalFile(strLocal), m_strGlobalFile(strGlobal)
 {
   // Make up names for files if empty
@@ -607,8 +610,6 @@ bool wxFileConfig::Write(const wxString& key, const wxString& szValue)
       return FALSE;
     }
 
-    strName = FilterOutEntryName(strName);
-
     ConfigEntry *pEntry = m_pCurrentGroup->FindEntry(strName);
     if ( pEntry == NULL )
       pEntry = m_pCurrentGroup->AddEntry(strName);
@@ -903,7 +904,10 @@ LineList *ConfigGroup::GetGroupLine()
     // this group wasn't present in local config file, add it now
     if ( pParent != NULL ) {
       wxString strFullName;
-      strFullName << _T("[") << (GetFullName().c_str() + 1) << _T("]"); // +1: no '/'
+      strFullName << _T("[")
+                  // +1: no '/'
+                  << FilterOutEntryName(GetFullName().c_str() + 1)
+                  << _T("]");
       m_pLine = m_pConfig->LineListInsert(strFullName,
                                           pParent->GetLastGroupLine());
       pParent->SetLastGroup(this);  // we're surely after all the others
@@ -1270,7 +1274,7 @@ void ConfigEntry::SetValue(const wxString& strValue, bool bUser)
   if ( bUser ) {
     wxString strVal = FilterOutValue(strValue);
     wxString strLine;
-    strLine << m_strName << _T(" = ") << strVal;
+    strLine << FilterOutEntryName(m_strName) << _T(" = ") << strVal;
 
     if ( m_pLine != NULL ) {
       // entry was read from the local config file, just modify the line
@@ -1467,3 +1471,12 @@ static wxString FilterOutEntryName(const wxString& str)
   return strResult;
 }
 
+// we can't put ?: in the ctor initializer list because it confuses some
+// broken compilers (Borland C++)
+static wxString GetAppName(const wxString& appName)
+{
+    if ( !appName && wxTheApp )
+        return wxTheApp->GetAppName();
+    else
+        return appName;
+}