git: efda9660cc81 - main - textproc/kdiff3: fix output of merged file
Adriaan de Groot
adridg at FreeBSD.org
Mon Jun 14 23:03:18 UTC 2021
The branch main has been updated by adridg:
URL: https://cgit.FreeBSD.org/ports/commit/?id=efda9660cc81115e5b149426287b09e44a25f388
commit efda9660cc81115e5b149426287b09e44a25f388
Author: Adriaan de Groot <adridg at FreeBSD.org>
AuthorDate: 2021-06-14 23:00:52 +0000
Commit: Adriaan de Groot <adridg at FreeBSD.org>
CommitDate: 2021-06-14 23:03:16 +0000
textproc/kdiff3: fix output of merged file
Fix spurious newlines and missing newline at the end of file.
Upstream report: https://bugs.kde.org/show_bug.cgi?id=437570
Upstream merge request: https://invent.kde.org/sdk/kdiff3/-/merge_requests/31
PR: 256606
Reported by: emaste
---
textproc/kdiff3/Makefile | 1 +
.../kdiff3/files/patch-src_mergeresultwindow.cpp | 50 ++++++++++++++++++++++
2 files changed, 51 insertions(+)
diff --git a/textproc/kdiff3/Makefile b/textproc/kdiff3/Makefile
index 68a2f869c05d..91bb00835f44 100644
--- a/textproc/kdiff3/Makefile
+++ b/textproc/kdiff3/Makefile
@@ -1,5 +1,6 @@
PORTNAME= kdiff3
DISTVERSION= 1.9.2
+PORTREVISION= 1
CATEGORIES= textproc kde
MASTER_SITES= KDE/stable/${PORTNAME}
diff --git a/textproc/kdiff3/files/patch-src_mergeresultwindow.cpp b/textproc/kdiff3/files/patch-src_mergeresultwindow.cpp
new file mode 100644
index 000000000000..508fc50cc56f
--- /dev/null
+++ b/textproc/kdiff3/files/patch-src_mergeresultwindow.cpp
@@ -0,0 +1,50 @@
+See https://invent.kde.org/sdk/kdiff3/-/merge_requests/31
+
+When writing out files, don't treat removed lines as real lines,
+and append a newline to the whole output file.
+--- src/mergeresultwindow.cpp.orig 2021-05-17 17:26:58 UTC
++++ src/mergeresultwindow.cpp
+@@ -2964,6 +2964,9 @@ bool MergeResultWindow::saveDocument(const QString& fi
+ textOutStream.setGenerateByteOrderMark(true); // Only for UTF-16
+ textOutStream.setCodec(pEncoding);
+
++ // Determine the line feed for this file
++ const QString lineFeed(eLineEndStyle == eLineEndStyleDos ? QString("\r\n") : QString("\n"));
++
+ int line = 0;
+ MergeLineList::iterator mlIt = m_mergeLineList.begin();
+ for(mlIt = m_mergeLineList.begin(); mlIt != m_mergeLineList.end(); ++mlIt)
+@@ -2976,18 +2979,14 @@ bool MergeResultWindow::saveDocument(const QString& fi
+
+ if(mel.isEditableText())
+ {
+- QString str = mel.getString(m_pldA, m_pldB, m_pldC);
++ const QString str = mel.getString(m_pldA, m_pldB, m_pldC);
+
+- if(line > 0) // Prepend line feed, but not for first line
++ if(line > 0 && !mel.isRemoved())
+ {
+- if(eLineEndStyle == eLineEndStyleDos)
+- {
+- str.prepend("\r\n");
+- }
+- else
+- {
+- str.prepend("\n");
+- }
++ // Put line feed between lines, but not for the first line
++ // or between lines that have been removed (because there
++ // isn't a line there).
++ textOutStream << lineFeed;
+ }
+
+ textOutStream << str;
+@@ -2995,6 +2994,8 @@ bool MergeResultWindow::saveDocument(const QString& fi
+ }
+ }
+ }
++ // At the end of the stream, needs a newline
++ textOutStream << lineFeed;
+ textOutStream.flush();
+ bool bSuccess = file.writeFile(dataArray.data(), dataArray.size());
+ if(!bSuccess)
More information about the dev-commits-ports-all
mailing list