OSDN Git Service

BUG: [ 829306 ] Fix unifile code to append last line
authorPerry Rapp <elsapo@users.sourceforge.net>
Thu, 23 Oct 2003 23:39:38 +0000 (23:39 +0000)
committerPerry Rapp <elsapo@users.sourceforge.net>
Thu, 23 Oct 2003 23:39:38 +0000 (23:39 +0000)
Src/MergeDoc.cpp
Src/readme.txt

index 413faac..9ac788e 100644 (file)
@@ -1114,14 +1114,21 @@ int CMergeDoc::CDiffTextBuffer::LoadFromFile(LPCTSTR pszFileNameInit, PackingInf
        {
                pufile->ReadBom();
                UINT lineno = 0;
-               CString line, eol;
+               CString line, eol, preveol;
+               bool done = false;
 
                // Manually grow line array exponentially
                int arraysize = 500;
                m_aLines.SetSize(arraysize);
                
-               while (pufile->ReadString(line, eol))
-               {
+               do {
+                       done = !pufile->ReadString(line, eol);
+
+                       // if last line had no eol, we can quit
+                       if (done && preveol.IsEmpty())
+                               break;
+                       // but if last line had eol, we add an extra (empty) line to buffer
+
                        // Manually grow line array exponentially
                        if (lineno == arraysize)
                        {
@@ -1133,7 +1140,9 @@ int CMergeDoc::CDiffTextBuffer::LoadFromFile(LPCTSTR pszFileNameInit, PackingInf
                        line += eol;
                        AppendLine(lineno, line, line.GetLength());
                        ++lineno;
-               }
+                       preveol = eol;
+               } while (!done);
+
                // fix array size (due to our manual exponential growth
                m_aLines.SetSize(lineno);
        
index 36c3f7c..dcb2e8c 100644 (file)
@@ -1,6 +1,8 @@
 2003-10-23 Perry
  BUG: [ 828619 ] Prevent closing dir doc whilst scanning
   WinMerge: DirDoc.cpp DirDoc.h
+ BUG: [ 829306 ] Fix unifile code to append last line
+  WinMerge: MergeDoc.cpp
 
 2003-10-23 Kimmo
  BUG: [ 815147 ] Scrollwheel scrolls too far at end of file