X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8907154c1a8a6882c6797d1f16393ddfb23e7f3a..8a3f03ffce938a24ecc154b614072457b3900ed0:/src/common/textbuf.cpp?ds=sidebyside diff --git a/src/common/textbuf.cpp b/src/common/textbuf.cpp index 97178aeb6e..b6e8362c85 100644 --- a/src/common/textbuf.cpp +++ b/src/common/textbuf.cpp @@ -3,6 +3,7 @@ // Purpose: implementation of wxTextBuffer class // Created: 14.11.01 // Author: Morten Hanssen, Vadim Zeitlin +// RCS-ID: $Id$ // Copyright: (c) 1998-2001 wxWidgets team // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -45,7 +46,7 @@ const wxTextFileType wxTextBuffer::typeDefault = wxTextFileType_Unix; #elif defined(__WXMAC__) wxTextFileType_Mac; -#elif defined(__WXPM__) +#elif defined(__OS2__) wxTextFileType_Os2; #else wxTextFileType_None; @@ -79,14 +80,14 @@ 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'): // Dos/Unix line termination @@ -131,6 +132,8 @@ wxString wxTextBuffer::Translate(const wxString& text, wxTextFileType type) #if wxUSE_TEXTBUFFER +wxString wxTextBuffer::ms_eof; + // ---------------------------------------------------------------------------- // ctors & dtor // ---------------------------------------------------------------------------- @@ -178,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() ); @@ -215,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) \ @@ -223,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(_T("unknown line terminator")); \ } size_t n; @@ -247,9 +250,7 @@ wxTextFileType wxTextBuffer::GuessType() const ? wxTextFileType_##t1 \ : wxTextFileType_##t2 - // Watcom C++ doesn't seem to be able to handle the macro - // VS: Watcom 11 doesn't have a problem... -#if !(defined(__WATCOMC__) && (__WATCOMC__ < 1100)) +#if !defined(__WATCOMC__) || wxCHECK_WATCOM_VERSION(1,4) if ( nDos > nUnix ) return GREATER_OF(Dos, Mac); else if ( nDos < nUnix ) @@ -269,18 +270,15 @@ wxTextFileType wxTextBuffer::GuessType() const bool wxTextBuffer::Close() { - m_aTypes.Clear(); - m_aLines.Clear(); - m_nCurLine = 0; + Clear(); m_isOpened = false; return true; } -bool wxTextBuffer::Write(wxTextFileType typeNew, wxMBConv& conv) +bool wxTextBuffer::Write(wxTextFileType typeNew, const wxMBConv& conv) { return OnWrite(typeNew, conv); } #endif // wxUSE_TEXTBUFFER -