From 9c70b4b91c37e4ee1504cc7cc89b33f76900cc97 Mon Sep 17 00:00:00 2001 From: Takashi Sawanaka Date: Thu, 14 Mar 2019 13:53:37 +0900 Subject: [PATCH] word level diff dit not work if the text contains NUL characters --- Src/MergeDoc.cpp | 6 +++--- Src/MergeDocLineDiffs.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Src/MergeDoc.cpp b/Src/MergeDoc.cpp index fd56b9309..41dc4a06a 100644 --- a/Src/MergeDoc.cpp +++ b/Src/MergeDoc.cpp @@ -1286,9 +1286,9 @@ bool CMergeDoc::WordListCopy(int srcPane, int dstPane, int nDiff, int firstWordD int srcEnd = nSrcOffsets[worddiffs[i].endline[srcPane] - ptSrcStart.y] + worddiffs[i].end[srcPane]; int dstBegin = nDstOffsets[worddiffs[i].beginline[dstPane] - ptDstStart.y] + worddiffs[i].begin[dstPane]; int dstEnd = nDstOffsets[worddiffs[i].endline[dstPane] - ptDstStart.y] + worddiffs[i].end[dstPane]; - CString text = srcText.Mid(srcBegin - ptSrcStart.x, srcEnd - srcBegin); - dstText.Delete(dstBegin - ptDstStart.x, dstEnd - dstBegin); - dstText.Insert(dstBegin - ptDstStart.x, text); + dstText = dstText.Mid(0, dstBegin - ptDstStart.x) + + srcText.Mid(srcBegin - ptSrcStart.x, srcEnd - srcBegin) + + dstText.Mid(dstEnd - ptDstStart.x); } dbuf.DeleteText(pSource, ptDstStart.y, ptDstStart.x, ptDstEnd.y, ptDstEnd.x, CE_ACTION_MERGE); diff --git a/Src/MergeDocLineDiffs.cpp b/Src/MergeDocLineDiffs.cpp index 8078faa61..4b23e6d69 100644 --- a/Src/MergeDocLineDiffs.cpp +++ b/Src/MergeDocLineDiffs.cpp @@ -194,7 +194,7 @@ void CMergeDoc::GetWordDiffArray(int nLineIndex, vector *pWordDiffs) if (nLineBegin != nLineEnd || m_ptBuf[file]->GetLineLength(nLineEnd) > 0) m_ptBuf[file]->GetTextWithoutEmptys(nLineBegin, 0, nLineEnd, m_ptBuf[file]->GetLineLength(nLineEnd), strText); strText += m_ptBuf[file]->GetLineEol(nLineEnd); - str[file] = strText; + str[file].assign(strText, strText.GetLength()); nOffsets[file][0] = 0; for (int nLine = nLineBegin; nLine < nLineEnd; nLine++) -- 2.11.0