diff --git a/editors/diamond/Makefile b/editors/diamond/Makefile index 58562eaf6d2c..e36385cee66a 100644 --- a/editors/diamond/Makefile +++ b/editors/diamond/Makefile @@ -1,27 +1,34 @@ PORTNAME= diamond -DISTVERSIONPREFIX= diamond- -DISTVERSION= 1.3.6 -PORTREVISION= 1 +DISTVERSION= 1.3.7 +DISTNAME= Diamond-${DISTVERSION} CATEGORIES= editors PKGNAMESUFFIX= -cs +MASTER_SITES= https://download.copperspice.com/${PORTNAME}/source/ MAINTAINER= adridg@FreeBSD.org COMMENT= Compact programmers editor LICENSE= GPLv2 LICENSE_FILE= ${WRKSRC}/LICENSE LIB_DEPENDS= libhunspell-1.7.so:textproc/hunspell BUILD_DEPENDS= copperspice>=1.7:x11-toolkits/copperspice RUN_DEPENDS= copperspice>=1.7:x11-toolkits/copperspice -USES= compiler:c++17-lang cmake gl gnome iconv jpeg pkgconfig ssl xorg +USES= compiler:c++17-lang cmake dos2unix gl gnome iconv jpeg pkgconfig ssl tar:bz2 xorg USE_GL= gl USE_GNOME= cairo glib20 libxml2 USE_XORG= ice sm x11 xau xcb xcursor xext xfixes xi xinerama xrandr xrender -USE_GITHUB= yes -GH_ACCOUNT= copperspice -GH_PROJECT= diamond +# It's a bit up-in-the-air if the GitHub tarballs are less fragile +# than the upstream source tarballs, which have their own peculiarities +# (e.g. CRLF, no subdir). We dos2unix the files that need patching. +# +# USE_GITHUB= yes +# GH_ACCOUNT= copperspice +# GH_PROJECT= diamond +# +NO_WRKSUBDIR= yes +DOS2UNIX_FILES= CMakeLists.txt src/CMakeLists.txt src/json.cpp src/recent_tabs.cpp .include diff --git a/editors/diamond/distinfo b/editors/diamond/distinfo index d907474b1d5a..ce6e462b4c0d 100644 --- a/editors/diamond/distinfo +++ b/editors/diamond/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP = 1645301383 -SHA256 (copperspice-diamond-diamond-1.3.6_GH0.tar.gz) = e1b85890a870236370207c5d6b7aa7d44d7414a090723ecea513f8b5cec4fb67 -SIZE (copperspice-diamond-diamond-1.3.6_GH0.tar.gz) = 4626624 +TIMESTAMP = 1646082059 +SHA256 (Diamond-1.3.7.tar.bz2) = 1b104df02b0f4dd9debc9286776d7c202bcda64cb84d3cb2b20b161e34e918f1 +SIZE (Diamond-1.3.7.tar.bz2) = 4629796 diff --git a/editors/diamond/files/patch-e8f0d274471cf0a50a78aec102ffa87541887f2e.patch b/editors/diamond/files/patch-e8f0d274471cf0a50a78aec102ffa87541887f2e.patch new file mode 100644 index 000000000000..52ae0371df30 --- /dev/null +++ b/editors/diamond/files/patch-e8f0d274471cf0a50a78aec102ffa87541887f2e.patch @@ -0,0 +1,47 @@ +From e8f0d274471cf0a50a78aec102ffa87541887f2e Mon Sep 17 00:00:00 2001 +From: Adriaan de Groot +Date: Sun, 20 Feb 2022 16:23:53 +0100 +Subject: [PATCH] Fix crash when passing filenames on command-line + +Consider running `diamond file.txt`. If previously there +was an untitled tab open and nothing else, we arrive +here with 2 tabs, `cnt==2`. The first for-loop finds +an untitled tab at index `k==0` and decrements `cnt`, +then the for-loop increments `k` and the for-loop terminates +(because `1 < 1` is false). We have `cnt==1` but an **empty** +list `m_openedFiles`. This crashes with an out-of-bounds access +in the second for-loop, because `cnt` doesn't match the length +of the list anymore. + +As a fix: +- do not modify `cnt` in the first for-loop, always check + all of the current tabs, +- re-calculate the `cnt` based on the files that are actually + opened, before the second loop. +--- + src/recent_tabs.cpp | 8 +++----- + 1 file changed, 3 insertions(+), 5 deletions(-) + +diff --git a/src/recent_tabs.cpp b/src/recent_tabs.cpp +index b3359ac..3eef680 100644 +--- src/recent_tabs.cpp ++++ src/recent_tabs.cpp +@@ -31,15 +31,13 @@ void MainWindow::openTab_CreateMenus() + for (int k = 0; k < cnt; ++k) { + fullName = this->get_curFileName(k); + +- if (fullName.isEmpty()) { +- --cnt; +- +- } else { ++ if (!fullName.isEmpty()) { + m_openedFiles.append(fullName); + m_openedModified.append(false); + } + } +- ++ // How many were really opened ++ cnt = m_openedFiles.count(); + // + QMenu *windowMenu = m_ui->menuWindow; + windowMenu->addSeparator();