editors/diamond: update to 1.3.7, latest upstream

This version is just a copyright-year update. I'm taking advantage
to follow Daniel Engberg's advice to use the upstream tarballs
rather than GitHub tarballs, even though the upstream tarballs
are, IMO, terrible.

While here, pull in a patch I wrote to avoid crashes on startup.
This commit is contained in:
Adriaan de Groot 2022-03-01 11:17:16 +01:00
parent 759b69bb6b
commit e0e4186db9
3 changed files with 64 additions and 10 deletions

View file

@ -1,9 +1,9 @@
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
@ -15,13 +15,20 @@ 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 <bsd.port.mk>

View file

@ -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

View file

@ -0,0 +1,47 @@
From e8f0d274471cf0a50a78aec102ffa87541887f2e Mon Sep 17 00:00:00 2001
From: Adriaan de Groot <groot@kde.org>
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();