X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2825b3f502d4ae3be76027d033aa18d57cd28bb1..3ca1bf5add01419ba173f0567b060fdd9fd605f9:/src/common/fileconf.cpp diff --git a/src/common/fileconf.cpp b/src/common/fileconf.cpp index 1c0337284e..ef5c6c6d13 100644 --- a/src/common/fileconf.cpp +++ b/src/common/fileconf.cpp @@ -494,21 +494,21 @@ wxFileConfig::wxFileConfig(wxInputStream &inStream, wxMBConv& conv) wxString strTmp; char buf[1024]; - for ( ;; ) + do { inStream.Read(buf, WXSIZEOF(buf)); - if ( !inStream.IsOk() ) + const wxStreamError err = inStream.GetLastError(); + + if ( err != wxSTREAM_NO_ERROR && err != wxSTREAM_EOF ) { wxLogError(_("Error reading config options.")); break; } strTmp.append(wxConvertMB2WX(buf), inStream.LastRead()); - - if ( inStream.Eof() ) - break; } + while ( !inStream.Eof() ); strTrans = wxTextBuffer::Translate(strTmp); } @@ -663,7 +663,7 @@ void wxFileConfig::Parse(wxTextBuffer& buffer, bool bLocal) } else { // a key const wxChar *pEnd = pStart; - while ( *pEnd && *pEnd != wxT('=') && !wxIsspace(*pEnd) ) { + while ( *pEnd && *pEnd != wxT('=') /* && !wxIsspace(*pEnd)*/ ) { if ( *pEnd == wxT('\\') ) { // next character may be space or not - still take it because it's // quoted (unless there is nothing) @@ -677,7 +677,7 @@ void wxFileConfig::Parse(wxTextBuffer& buffer, bool bLocal) pEnd++; } - wxString strKey(FilterInEntryName(wxString(pStart, pEnd))); + wxString strKey(FilterInEntryName(wxString(pStart, pEnd).Trim())); // skip whitespace while ( wxIsspace(*pEnd) ) @@ -997,19 +997,23 @@ bool wxFileConfig::Flush(bool /* bCurrentOnly */) bool ret = file.Commit(); #if defined(__WXMAC__) - if ( ret ) - { - FSSpec spec ; - - wxMacFilename2FSSpec( m_strLocalFile , &spec ) ; - FInfo finfo ; - if ( FSpGetFInfo( &spec , &finfo ) == noErr ) - { - finfo.fdType = 'TEXT' ; - finfo.fdCreator = 'ttxt' ; - FSpSetFInfo( &spec , &finfo ) ; - } - } + if ( ret ) + { + FSRef fsRef ; + FSCatalogInfo catInfo; + FileInfo *finfo ; + + if ( wxMacPathToFSRef( m_strLocalFile , &fsRef ) == noErr ) + { + if ( FSGetCatalogInfo (&fsRef, kFSCatInfoFinderInfo, &catInfo, NULL, NULL, NULL) == noErr ) + { + finfo = (FileInfo*)&catInfo.finderInfo; + finfo->fileType = 'TEXT' ; + finfo->fileCreator = 'ttxt' ; + FSSetCatalogInfo( &fsRef, kFSCatInfoFinderInfo, &catInfo ) ; + } + } + } #endif // __WXMAC__ #ifdef __UNIX__ @@ -2021,14 +2025,22 @@ static wxString FilterOutEntryName(const wxString& str) strResult.Alloc(str.Len()); for ( const wxChar *pc = str.c_str(); *pc != wxT('\0'); pc++ ) { - wxChar c = *pc; + const wxChar c = *pc; // we explicitly allow some of "safe" chars and 8bit ASCII characters - // which will probably never have special meaning + // which will probably never have special meaning and with which we can't + // use isalnum() anyhow (in ASCII built, in Unicode it's just fine) + // // NB: note that wxCONFIG_IMMUTABLE_PREFIX and wxCONFIG_PATH_SEPARATOR // should *not* be quoted - if ( !wxIsalnum(c) && !wxStrchr(wxT("@_/-!.*%"), c) && ((c & 0x80) == 0) ) + if ( +#if !wxUSE_UNICODE + ((unsigned char)c < 127) && +#endif // ANSI + !wxIsalnum(c) && !wxStrchr(wxT("@_/-!.*%"), c) ) + { strResult += wxT('\\'); + } strResult += c; }