OSDN Git Service

Improve compare+display of last lines in files (1)
authorGreyMerlin <GreyMerlin7@gmail.com>
Sun, 17 Jun 2018 00:11:17 +0000 (17:11 -0700)
committerGreyMerlin <GreyMerlin7@gmail.com>
Sun, 17 Jun 2018 00:12:10 +0000 (17:12 -0700)
commit51519fc848e23494510d8c8268f7a734c1de3e97
treee0b2204d7fdef9d51c056baffa6cf96ac8cf85a1
parent57714130d7368a0c5d16494f88256113a0358408
Improve compare+display of last lines in files (1)

Symptoms ...

ASSERT could occur (with Debug build), and possibly a fault could
occur with Release builds, if longest file was the Left File and that
file did not have an explicit EOL marking after the last line of the
file, and there were visible differences at the very end of the file.

Discussion ...

The internal `m_ptBuf[]->m_aLines[]` buffers could end up with
different numbers of line entries in situations where the last line of
a file had no explicit EOL marking.  Normally, the two (or three)
`m_aLines[]` buffers would have "ghost" line entries to represent
"missing" lines, so that all `m_aLines[]` buffers would be of the same
length.  The lack of a final EOL could confuse that logic.  At some
points in the comparison logic, the length used for processing the two
(or three) buffers is determined simply by the length of `m_aLines[0]`

Solution ...

By the end of the `PrimeTextBuffers()` procedure, the two (or
three) `m_ptBuf[]->m_aLines[]` buffers will now **always** have the same
length.  Furthermore, there will no longer be <null> entries at the end
of the `m_aLines[]` arrays.  These will now be deleted (if **all**
`m_aLines[]` buffers have them), or they will be replaced with
appropriate "ghost" lines (if only **some** of the buffers have final
<null> entries)

Also, a number of comments are improved.
Externals/crystaledit/editlib/ccrystaltextbuffer.cpp
Src/DiffList.cpp
Src/DiffList.h
Src/DiffWrapper.cpp
Src/GhostTextBuffer.cpp
Src/MergeDoc.cpp
Src/MergeLineFlags.h