commit:     1c2a6e7fb4fb1d9205bca1556dd1a63b398d2244
Author:     Michael Orlitzky <mjo <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 29 16:36:57 2024 +0000
Commit:     Michael Orlitzky <mjo <AT> gentoo <DOT> org>
CommitDate: Thu Aug 29 17:30:59 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1c2a6e7f

sci-mathematics/gfan: fix startup crash, other improvements

AKA steal a few Debian patches.

Bug: https://bugs.gentoo.org/717112
Signed-off-by: Michael Orlitzky <mjo <AT> gentoo.org>

 .../gfan/files/gfan-0.6.2-find-name.patch          | 18 +++++
 ...gfan-0.6.2-fix-0602ResultantFanProjection.patch | 27 ++++++++
 .../files/gfan-0.6.2-fix-spelling-errors.patch     | 50 ++++++++++++++
 sci-mathematics/gfan/gfan-0.6.2-r5.ebuild          | 78 ++++++++++++++++++++++
 4 files changed, 173 insertions(+)

diff --git a/sci-mathematics/gfan/files/gfan-0.6.2-find-name.patch 
b/sci-mathematics/gfan/files/gfan-0.6.2-find-name.patch
new file mode 100644
index 000000000000..5e6718e70ed2
--- /dev/null
+++ b/sci-mathematics/gfan/files/gfan-0.6.2-find-name.patch
@@ -0,0 +1,18 @@
+Description: Properly terminate while loop when finding application name.
+Author: Anders Nedergaard Jensen <[email protected]>
+Origin: https://bugs.debian.org/950008#17
+Bug-Debian: https://bugs.debian.org/950008
+Forwarded: yes
+Last-Update: 2021-11-21
+
+--- a/src/application.cpp
++++ b/src/application.cpp
+@@ -26,7 +26,7 @@
+     {
+       l--;
+     }
+-  while(p[l]!=0 && p[l]!='/');
++  while(l >= 0 && p[l]!='/');
+ 
+   return p+l+1;
+ }

diff --git 
a/sci-mathematics/gfan/files/gfan-0.6.2-fix-0602ResultantFanProjection.patch 
b/sci-mathematics/gfan/files/gfan-0.6.2-fix-0602ResultantFanProjection.patch
new file mode 100644
index 000000000000..99fe8167398e
--- /dev/null
+++ b/sci-mathematics/gfan/files/gfan-0.6.2-fix-0602ResultantFanProjection.patch
@@ -0,0 +1,27 @@
+Description: Use int64_t instead of signed long int for 64-bit integer typedef
+ On 32-bit architectures, longs are only 32 bits.  The resulting overflow
+ was causing an infinite loop in the 0602ResultantFanProjection test.
+Bug-Debian: https://bugs.debian.org/905300
+Bug-Debian: https://bugs.debian.org/974558
+Author: Doug Torrance <[email protected]>
+Last-Update: 2020-11-12
+
+(mjo: added missing include)
+
+--- a/src/vektor.h
++++ b/src/vektor.h
+@@ -6,11 +6,12 @@
+ #include <assert.h>
+ #include <algorithm>
+ #include <complex>
++#include <cstdint>
+ #include <stdio.h>
+ 
+ using namespace std;
+ 
+-typedef signed long int int64;
++typedef int64_t int64;
+ 
+ void outOfRange(int i, int n);
+ 
+

diff --git a/sci-mathematics/gfan/files/gfan-0.6.2-fix-spelling-errors.patch 
b/sci-mathematics/gfan/files/gfan-0.6.2-fix-spelling-errors.patch
new file mode 100644
index 000000000000..08b78c6efcaa
--- /dev/null
+++ b/sci-mathematics/gfan/files/gfan-0.6.2-fix-spelling-errors.patch
@@ -0,0 +1,50 @@
+Descriptions: Fix some spelling errors in output text of the programs
+Author: Cédric Boutillier <[email protected]>
+Author: Doug Torrance <[email protected]>
+Forwarded: yes
+Last-Update: 2020-11-13
+
+--- a/src/app_scarfisgeneric.cpp
++++ b/src/app_scarfisgeneric.cpp
+@@ -24,7 +24,7 @@
+   }
+   const char *helpText()
+   {
+-    return "This program takes a matrix as input and checks if it satisfies 
Scarf's generality conditions. The rows of the matrix are listed on the input. 
The A1 condition is that there exists a strictly poistive vector in the 
co-kernel of the matrix. The A2 condition is that te maximal minors of the 
matrix are non-zero. A3\n";
++    return "This program takes a matrix as input and checks if it satisfies 
Scarf's generality conditions. The rows of the matrix are listed on the input. 
The A1 condition is that there exists a strictly poistive vector in the 
co-kernel of the matrix. The A2 condition is that the maximal minors of the 
matrix are non-zero. A3\n";
+   }
+   ScarfIsGenericApplication()
+   {
+--- a/src/app_symmetries.cpp
++++ b/src/app_symmetries.cpp
+@@ -35,7 +35,7 @@
+   }
+   SymmetriesApplication():
+     optionSymmetry("--symmetry","Specify subgroup to be searched for 
permutations keeping the ideal fixed."),
+-    optionTorusSymmetry("--symsigns","Specify for each generator of the group 
specified wiht --symmetry an element of ${-1,+1}^n$ which by its multiplication 
on the variables together with the permutation is expected to keep the ideal 
fixed.")
++    optionTorusSymmetry("--symsigns","Specify for each generator of the group 
specified with --symmetry an element of ${-1,+1}^n$ which by its multiplication 
on the variables together with the permutation is expected to keep the ideal 
fixed.")
+   {
+     registerOptions();
+   }
+--- a/src/app_representatives.cpp
++++ b/src/app_representatives.cpp
+@@ -24,7 +24,7 @@
+   }
+   const char *helpText()
+   {
+-    return "This program computes takes generaters for a subgroup of S_n and 
a list of n-dimensional integer vectors. The output is a list of vectors, one 
from each orbit of elements of the list. \n";
++    return "This program computes takes generators for a subgroup of S_n and 
a list of n-dimensional integer vectors. The output is a list of vectors, one 
from each orbit of elements of the list. \n";
+   }
+   RepresentativesApplication()
+   {
+--- a/src/tropical2.cpp
++++ b/src/tropical2.cpp
+@@ -271,7 +271,7 @@
+   PolynomialSet r(theRing);
+   if(theRing.getNumberOfVariables()!=weight.size())
+     {
+-      cerr << "Error: Number of varaibles in polynomial ring 
"<<theRing.getNumberOfVariables()<< " length of weight vector " << 
weight.size() <<endl;
++      cerr << "Error: Number of variables in polynomial ring 
"<<theRing.getNumberOfVariables()<< " length of weight vector " << 
weight.size() <<endl;
+       assert(0);
+     }
+ 

diff --git a/sci-mathematics/gfan/gfan-0.6.2-r5.ebuild 
b/sci-mathematics/gfan/gfan-0.6.2-r5.ebuild
new file mode 100644
index 000000000000..47fbcc3b8e1d
--- /dev/null
+++ b/sci-mathematics/gfan/gfan-0.6.2-r5.ebuild
@@ -0,0 +1,78 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit flag-o-matic toolchain-funcs
+
+DESCRIPTION="Compute Groebner fans and tropical varieties"
+HOMEPAGE="https://users-math.au.dk/~jensen/software/gfan/gfan.html";
+SRC_URI="https://users-math.au.dk/~jensen/software/${PN}/${PN}${PV}.tar.gz";
+
+S="${WORKDIR}/${PN}${PV}"
+
+LICENSE="GPL-2+"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~riscv ~x86 ~amd64-linux ~x86-linux"
+IUSE="doc"
+
+BDEPEND="doc? ( virtual/latex-base )"
+DEPEND="dev-libs/gmp:0=[cxx(+)]
+       sci-libs/cddlib:0="
+RDEPEND="${DEPEND}"
+
+PATCHES=(
+       "${FILESDIR}/${PN}-0.6.2-testsuite.patch"
+       "${FILESDIR}/${PN}-0.6.2-Makefile.patch"
+       "${FILESDIR}/${PN}-0.6.2-fix-0602ResultantFanProjection.patch"
+       "${FILESDIR}/${PN}-0.6.2-fix-spelling-errors.patch"
+       "${FILESDIR}/${PN}-0.6.2-find-name.patch"
+)
+
+pkg_setup() {
+       tc-export CC CXX
+
+       # This should really go in cppflags, but that doesn't work with
+       # gfan's hand-written Makefile.
+       append-cxxflags -DNOCDDPREFIX -I"${EPREFIX}"/usr/include/cddlib
+}
+
+src_prepare() {
+       default
+
+       # And this one fails (harmlessly) on x86, bug 818397.
+       rm -r testsuite/0009RenderStairCase || \
+               die "unable to disable test 0009RenderStairCase"
+}
+
+src_configure() {
+       # -Werror=odr
+       # https://bugs.gentoo.org/863044
+       # Only contact method is email. I have sent one detailing the issue.
+       filter-lto
+
+       # The upstream Makefile says that GCC produces bad code with -O3.
+       replace-flags "-O3" "-O2"
+       default
+}
+
+src_compile() {
+       default
+       if use doc; then
+               pushd doc > /dev/null || die
+               # The LaTeX build commands need to be repeated until the
+               # document "stops changing," which is not as easy as it
+               # sounds to detect. Running it twice seems to work here.
+               for iteration in 1 2; do
+                       latex manual.tex && \
+                               bibtex manual && \
+                               dvipdf manual.dvi manual.pdf || die
+               done
+               popd > /dev/null || die
+       fi
+}
+
+src_install() {
+       emake PREFIX="${ED}/usr" install
+       use doc && dodoc doc/manual.pdf
+}

Reply via email to