From: Vadim Zeitlin Date: Tue, 20 Aug 2002 14:29:22 +0000 (+0000) Subject: added support for wxCONFIG_USE_NO_ESCAPE_CHARACTERS flag to wxFileConfig (patch 591381) X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/8dce54c9e632e0abd820498346e90aff0ae45d70?ds=sidebyside;hp=33293a32fe18ff90ed0154092554b089ef84c71b added support for wxCONFIG_USE_NO_ESCAPE_CHARACTERS flag to wxFileConfig (patch 591381) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16622 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/docs/latex/wx/config.tex b/docs/latex/wx/config.tex index 0a44bd3fd2..9d8c865fba 100644 --- a/docs/latex/wx/config.tex +++ b/docs/latex/wx/config.tex @@ -369,7 +369,23 @@ the parameter is empty, the parameter will be set to a default. If the parameter is present but the style flag not, the relevant flag will be added to the style. For wxFileConfig you can also add wxCONFIG\_USE\_RELATIVE\_PATH by logicaly or'ing it to either of the \_FILE options to tell wxFileConfig to -use relative instead of absolute paths. } +use relative instead of absolute paths. For wxFileConfig, you can also +add wxCONFIG\_USE\_NO\_ESCAPE\_CHARACTERS which will turn off character +escaping for the values of entries stored in the config file: for example +a {\it foo} key with some backslash characters will be stored as +\begin{verbatim} + foo=C:\mydir +\end{verbatim} +instead of the usual storage of +\begin{verbatim} + foo=C:\\mydir +\end{verbatim} +The wxCONFIG\_USE\_NO\_ESCAPE\_CHARACTERS style can be helpful if your config +file must be read or written to by a non-wxWindows program (which might not +understand the escape characters). Note, however, that if +wxCONFIG\_USE\_NO\_ESCAPE\_CHARACTERS style is used, it is is now +your application's responsibility to ensure that there is no newline or +other illegal characters in a value, before writing that value to the file.} \wxheading{Remarks} diff --git a/include/wx/confbase.h b/include/wx/confbase.h index 28abf293c4..b2a576c858 100644 --- a/include/wx/confbase.h +++ b/include/wx/confbase.h @@ -58,7 +58,8 @@ enum { wxCONFIG_USE_LOCAL_FILE = 1, wxCONFIG_USE_GLOBAL_FILE = 2, - wxCONFIG_USE_RELATIVE_PATH = 4 + wxCONFIG_USE_RELATIVE_PATH = 4, + wxCONFIG_USE_NO_ESCAPE_CHARACTERS = 8 }; // ---------------------------------------------------------------------------- diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index e635c6aaf7..5ef534169b 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -340,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 @@ -676,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); } } } @@ -930,7 +934,7 @@ bool wxFileConfig::Flush(bool /* bCurrentOnly */) if ( ret ) { FSSpec spec ; - + wxMacFilename2FSSpec( m_strLocalFile , &spec ) ; FInfo finfo ; if ( FSpGetFInfo( &spec , &finfo ) == noErr ) @@ -1577,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