X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/442d08ce743780b40895848a7d07c083e327aa2f..d21d2e5adf7a5acf3b496a9c4e87eab220bd75d8:/src/msw/regconf.cpp?ds=sidebyside diff --git a/src/msw/regconf.cpp b/src/msw/regconf.cpp index 5d8d70f97a..c63a563d6a 100644 --- a/src/msw/regconf.cpp +++ b/src/msw/regconf.cpp @@ -274,6 +274,7 @@ void wxRegConfig::SetPath(const wxString& strPath) // check the boundary condition below // this is more efficient than strrchr() + dst--; while ( *dst != wxCONFIG_PATH_SEPARATOR ) { dst--; @@ -288,10 +289,13 @@ void wxRegConfig::SetPath(const wxString& strPath) posLastSlash = -1; } - // this shouldn't happen + // we must have found a slash one way or another! wxASSERT_MSG( *dst == wxCONFIG_PATH_SEPARATOR, _T("error in wxRegConfig::SetPath") ); + // stay at the same position + dst--; + // we killed one totalSlashes--; } @@ -309,8 +313,12 @@ void wxRegConfig::SetPath(const wxString& strPath) totalSlashes++; } - //else: nothing to do, we squeeze several subseuquent - // slashes into one + else // previous char was a slash too + { + // squeeze several subsequent slashes into one: i.e. + // just ignore this one + dst--; + } } } else // normal character @@ -547,44 +555,10 @@ wxConfigBase::EntryType wxRegConfig::GetEntryType(const wxString& key) const // reading/writing // ---------------------------------------------------------------------------- -bool wxRegConfig::Read(const wxString& key, wxString *pStr) const +bool wxRegConfig::DoReadString(const wxString& key, wxString *pStr) const { - wxConfigPathChanger path(this, key); - - bool bQueryGlobal = TRUE; - - // if immutable key exists in global key we must check that it's not - // overriden by the local key with the same name - if ( IsImmutable(path.Name()) ) { - if ( TryGetValue(m_keyGlobal, path.Name(), *pStr) ) { - if ( m_keyLocal.Exists() && LocalKey().HasValue(path.Name()) ) { - wxLogWarning(wxT("User value for immutable key '%s' ignored."), - path.Name().c_str()); - } - *pStr = wxConfigBase::ExpandEnvVars(*pStr); - return TRUE; - } - else { - // don't waste time - it's not there anyhow - bQueryGlobal = FALSE; - } - } - - // first try local key - if ( (m_keyLocal.Exists() && TryGetValue(LocalKey(), path.Name(), *pStr)) || - (bQueryGlobal && TryGetValue(m_keyGlobal, path.Name(), *pStr)) ) { - // nothing to do - - *pStr = wxConfigBase::ExpandEnvVars(*pStr); - return TRUE; - } - - return FALSE; -} + wxCHECK_MSG( pStr, FALSE, _T("wxRegConfig::Read(): NULL param") ); -bool wxRegConfig::Read(const wxString& key, wxString *pStr, - const wxString& szDefault) const -{ wxConfigPathChanger path(this, key); bool bQueryGlobal = TRUE; @@ -609,25 +583,19 @@ bool wxRegConfig::Read(const wxString& key, wxString *pStr, // first try local key if ( (m_keyLocal.Exists() && TryGetValue(LocalKey(), path.Name(), *pStr)) || (bQueryGlobal && TryGetValue(m_keyGlobal, path.Name(), *pStr)) ) { - *pStr = wxConfigBase::ExpandEnvVars(*pStr); return TRUE; } - else { - if ( IsRecordingDefaults() ) { - ((wxRegConfig*)this)->Write(key, szDefault); - } - - // default value - *pStr = szDefault; - } - - *pStr = wxConfigBase::ExpandEnvVars(*pStr); return FALSE; } -bool wxRegConfig::Read(const wxString& key, long *plResult) const +// this exactly reproduces the string version above except for ExpandEnvVars(), +// we really should avoid this code duplication somehow... + +bool wxRegConfig::DoReadLong(const wxString& key, long *plResult) const { + wxCHECK_MSG( plResult, FALSE, _T("wxRegConfig::Read(): NULL param") ); + wxConfigPathChanger path(this, key); bool bQueryGlobal = TRUE; @@ -654,10 +622,11 @@ bool wxRegConfig::Read(const wxString& key, long *plResult) const (bQueryGlobal && TryGetValue(m_keyGlobal, path.Name(), plResult)) ) { return TRUE; } + return FALSE; } -bool wxRegConfig::Write(const wxString& key, const wxString& szValue) +bool wxRegConfig::DoWriteString(const wxString& key, const wxString& szValue) { wxConfigPathChanger path(this, key); @@ -669,7 +638,7 @@ bool wxRegConfig::Write(const wxString& key, const wxString& szValue) return LocalKey().SetValue(path.Name(), szValue); } -bool wxRegConfig::Write(const wxString& key, long lValue) +bool wxRegConfig::DoWriteLong(const wxString& key, long lValue) { wxConfigPathChanger path(this, key);