]> git.saurik.com Git - wxWidgets.git/commitdiff
don't process previously read characters twice in OnRead()
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 30 Mar 2006 14:04:46 +0000 (14:04 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 30 Mar 2006 14:04:46 +0000 (14:04 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38449 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/textfile.cpp

index 9bf2947f4346965f5ce9b655c672dd178a12ddfa..f9cd34077d22b650c94051aa1933a030f51822b1 100644 (file)
@@ -116,6 +116,10 @@ bool wxTextFile::OnRead(wxMBConv& conv)
         if ( nRead == 0 )
             break;
 
+        // save the number characters which we already processed during the
+        // last loop iteration
+        const size_t lenOld = str.length();
+
 #if wxUSE_UNICODE
         // we have to properly NUL-terminate the string for any encoding it may
         // use -- 4 NULs should be enough for everyone (this is why we add 4
@@ -144,7 +148,7 @@ bool wxTextFile::OnRead(wxMBConv& conv)
         // the beginning of the current line, changes inside the loop
         wxString::const_iterator lineStart = str.begin();
         const wxString::const_iterator end = str.end();
-        for ( wxString::const_iterator p = lineStart; p != end; p++ )
+        for ( wxString::const_iterator p = lineStart + lenOld; p != end; p++ )
         {
             const wxChar ch = *p;
             switch ( ch )