git: abdd4cf0e5ab - main - japanese/zinnia: fix build with clang 16
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 12 Jun 2023 18:37:51 UTC
The branch main has been updated by dim:
URL: https://cgit.FreeBSD.org/ports/commit/?id=abdd4cf0e5ab5f26b366d9ab86644ebaacd85624
commit abdd4cf0e5ab5f26b366d9ab86644ebaacd85624
Author: Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-06-11 17:01:12 +0000
Commit: Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-06-12 18:36:01 +0000
japanese/zinnia: fix build with clang 16
Since clang 16 (and gcc 11) the default C++ standard is now gnu++17.
Because japanese/zinnia's build infrastructure does not explicitly set
its C++ standard, this leads to an error:
svm.cpp:50:10: error: no member named 'random_shuffle' in namespace 'std'
std::random_shuffle(index.begin(), index.begin() + active_size);
~~~~~^
This is because std::random_shuffle has been removed from C++17. An
suitable replacement is std::shuffle, using a std::random_device in
combination with std::mt19937 as the random number engine.
PR: 271953
Approved by: fernape
MFH: 2023Q2
---
japanese/zinnia/Makefile | 2 +-
japanese/zinnia/files/patch-svm.cpp | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/japanese/zinnia/Makefile b/japanese/zinnia/Makefile
index 6eb5bcfa93e3..99b677574cde 100644
--- a/japanese/zinnia/Makefile
+++ b/japanese/zinnia/Makefile
@@ -1,6 +1,6 @@
PORTNAME= zinnia
PORTVERSION= 0.06
-PORTREVISION= 1
+PORTREVISION= 2
CATEGORIES= japanese
MASTER_SITES= SF
diff --git a/japanese/zinnia/files/patch-svm.cpp b/japanese/zinnia/files/patch-svm.cpp
new file mode 100644
index 000000000000..d37a3003bab6
--- /dev/null
+++ b/japanese/zinnia/files/patch-svm.cpp
@@ -0,0 +1,24 @@
+--- svm.cpp.orig 2009-04-05 11:40:29 UTC
++++ svm.cpp
+@@ -10,6 +10,7 @@
+ #include <vector>
+ #include <cmath>
+ #include <algorithm>
++#include <random>
+ #include "feature.h"
+
+ namespace zinnia {
+@@ -44,10 +45,12 @@ bool svm_train(size_t l,
+ }
+
+ static const size_t kMaxIteration = 2000;
++ std::random_device device;
++ std::mt19937 engine(device());
+ for (size_t iter = 0; iter < kMaxIteration; ++iter) {
+ double PGmax_new = -kINF;
+ double PGmin_new = kINF;
+- std::random_shuffle(index.begin(), index.begin() + active_size);
++ std::shuffle(index.begin(), index.begin() + active_size, engine);
+
+ for (size_t s = 0; s < active_size; ++s) {
+ const size_t i = index[s];