OSDN Git Service
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.