X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/76a5e5d21ee1a6230d777ce0209b2df4c6075f0f..44ba8f0ea92f65d9893ce0780971745a5d8e80ea:/src/common/fileconf.cpp?ds=sidebyside diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index a90cad6a76..5ef534169b 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -50,10 +50,8 @@ #include "wx/mac/private.h" // includes mac headers #endif -// _WINDOWS_ is defined when windows.h is included, -// __WXMSW__ is defined for MS Windows compilation -#if defined(__WXMSW__) && !defined(_WINDOWS_) - #include +#if defined(__WXMSW__) + #include "wx/msw/private.h" #endif //windows.h #if defined(__WXPM__) #define INCL_DOS @@ -342,11 +340,11 @@ wxString wxFileConfig::GetLocalFileName(const wxChar *szFile) #ifdef __VMS__ // On VMS I saw the problem that the home directory was appended // twice for the configuration file. Does that also happen for other // platforms? - wxString str = wxT( '.' ); + wxString str = wxT( '.' ); #else wxString str = GetLocalDir(); #endif - + #if defined( __UNIX__ ) && !defined( __VMS ) && !defined( __WXMAC__ ) str << wxT('.'); #endif @@ -678,7 +676,11 @@ void wxFileConfig::Parse(wxTextBuffer& buffer, bool bLocal) while ( wxIsspace(*pEnd) ) pEnd++; - pEntry->SetValue(FilterInValue(pEnd), FALSE /* read from file */); + wxString value = pEnd; + if ( !(GetStyle() & wxCONFIG_USE_NO_ESCAPE_CHARACTERS) ) + value = FilterInValue(value); + + pEntry->SetValue(value, FALSE); } } } @@ -844,8 +846,7 @@ bool wxFileConfig::DoReadLong(const wxString& key, long *pl) const { return FALSE; } - - return str.ToLong(pl); + return str.ToLong(pl) ; } bool wxFileConfig::DoWriteString(const wxString& key, const wxString& szValue) @@ -904,14 +905,24 @@ bool wxFileConfig::Flush(bool /* bCurrentOnly */) wxTempFile file(m_strLocalFile); - if ( !file.IsOpened() ) { + if ( !file.IsOpened() ) + { wxLogError(_("can't open user configuration file.")); return FALSE; } // write all strings to file - for ( wxFileConfigLineList *p = m_linesHead; p != NULL; p = p->Next() ) { - if ( !file.Write(p->Text() + wxTextFile::GetEOL()) ) { + for ( wxFileConfigLineList *p = m_linesHead; p != NULL; p = p->Next() ) + { + wxString line = p->Text(); + line += wxTextFile::GetEOL(); +#if wxUSE_UNICODE + wxCharBuffer buf = wxConvLocal.cWX2MB( line ); + if ( !file.Write( (const char*)buf, strlen( (const char*) buf ) ) ) +#else + if ( !file.Write( line.c_str(), line.Len() ) ) +#endif + { wxLogError(_("can't write user configuration file.")); return FALSE; } @@ -923,7 +934,7 @@ bool wxFileConfig::Flush(bool /* bCurrentOnly */) if ( ret ) { FSSpec spec ; - + wxMacFilename2FSSpec( m_strLocalFile , &spec ) ; FInfo finfo ; if ( FSpGetFInfo( &spec , &finfo ) == noErr ) @@ -1570,9 +1581,16 @@ void wxFileConfigEntry::SetValue(const wxString& strValue, bool bUser) m_strValue = strValue; if ( bUser ) { - wxString strVal = FilterOutValue(strValue); + wxString strValFiltered; + if ( Group()->Config()->GetStyle() & wxCONFIG_USE_NO_ESCAPE_CHARACTERS ) { + strValFiltered = strValue; + } + else { + strValFiltered = FilterOutValue(strValue); + } + wxString strLine; - strLine << FilterOutEntryName(m_strName) << wxT('=') << strVal; + strLine << FilterOutEntryName(m_strName) << wxT('=') << strValFiltered; if ( m_pLine != NULL ) { // entry was read from the local config file, just modify the line