X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/3ae00f5b5756cb67631400628acc94dd23fe03d7..51ec29ea5d1d1093bafbae27a8483211a90d9659:/src/common/textbuf.cpp?ds=sidebyside diff --git a/src/common/textbuf.cpp b/src/common/textbuf.cpp index 1891af5b1b..542e19db1e 100644 --- a/src/common/textbuf.cpp +++ b/src/common/textbuf.cpp @@ -80,35 +80,35 @@ wxString wxTextBuffer::Translate(const wxString& text, wxTextFileType type) wxString eol = GetEOL(type), result; // optimization: we know that the length of the new string will be about - // the same as the length of the old one, so prealloc memory to aviod + // the same as the length of the old one, so prealloc memory to avoid // unnecessary relocations result.Alloc(text.Len()); wxChar chLast = 0; - for ( const wxChar *pc = text.c_str(); *pc; pc++ ) + for ( wxString::const_iterator i = text.begin(); i != text.end(); ++i ) { - wxChar ch = *pc; + wxChar ch = *i; switch ( ch ) { - case _T('\n'): + case wxT('\n'): // Dos/Unix line termination result += eol; chLast = 0; break; - case _T('\r'): - if ( chLast == _T('\r') ) { + case wxT('\r'): + if ( chLast == wxT('\r') ) { // Mac empty line result += eol; } else { // just remember it: we don't know whether it is just "\r" // or "\r\n" yet - chLast = _T('\r'); + chLast = wxT('\r'); } break; default: - if ( chLast == _T('\r') ) { + if ( chLast == wxT('\r') ) { // Mac line termination result += eol; @@ -132,6 +132,8 @@ wxString wxTextBuffer::Translate(const wxString& text, wxTextFileType type) #if wxUSE_TEXTBUFFER +wxString wxTextBuffer::ms_eof; + // ---------------------------------------------------------------------------- // ctors & dtor // ---------------------------------------------------------------------------- @@ -179,14 +181,14 @@ bool wxTextBuffer::Create() return true; } -bool wxTextBuffer::Open(const wxString& strBufferName, wxMBConv& conv) +bool wxTextBuffer::Open(const wxString& strBufferName, const wxMBConv& conv) { m_strBufferName = strBufferName; return Open(conv); } -bool wxTextBuffer::Open(wxMBConv& conv) +bool wxTextBuffer::Open(const wxMBConv& conv) { // buffer name must be either given in ctor or in Open(const wxString&) wxASSERT( !m_strBufferName.empty() ); @@ -216,7 +218,7 @@ wxTextFileType wxTextBuffer::GuessType() const // we take MAX_LINES_SCAN in the beginning, middle and the end of buffer #define MAX_LINES_SCAN (10) - size_t nCount = m_aLines.Count() / 3, + size_t nCount = m_aLines.GetCount() / 3, nScan = nCount > 3*MAX_LINES_SCAN ? MAX_LINES_SCAN : nCount / 3; #define AnalyseLine(n) \ @@ -224,7 +226,7 @@ wxTextFileType wxTextBuffer::GuessType() const case wxTextFileType_Unix: nUnix++; break; \ case wxTextFileType_Dos: nDos++; break; \ case wxTextFileType_Mac: nMac++; break; \ - default: wxFAIL_MSG(_("unknown line terminator")); \ + default: wxFAIL_MSG(wxT("unknown line terminator")); \ } size_t n; @@ -274,7 +276,7 @@ bool wxTextBuffer::Close() return true; } -bool wxTextBuffer::Write(wxTextFileType typeNew, wxMBConv& conv) +bool wxTextBuffer::Write(wxTextFileType typeNew, const wxMBConv& conv) { return OnWrite(typeNew, conv); }