Bug#891788: stretch-pu: package starplot/0.95.5-8.2+deb9u1
Package: release.debian.org
Severity: normal
Tags: stretch
User: release.debian.org@packages.debian.org
Usertags: pu
* Add patch from Bernhard Übelacker to fix startup crash.
(Closes: #862065)
diff -Nru starplot-0.95.5/debian/changelog starplot-0.95.5/debian/changelog
--- starplot-0.95.5/debian/changelog 2016-12-24 23:59:59.000000000 +0200
+++ starplot-0.95.5/debian/changelog 2018-02-28 22:37:50.000000000 +0200
@@ -1,3 +1,11 @@
+starplot (0.95.5-8.2+deb9u1) stretch; urgency=medium
+
+ * Non-maintainer upload.
+ * Add patch from Bernhard Übelacker to fix startup crash.
+ (Closes: #862065)
+
+ -- Adrian Bunk <bunk@debian.org> Wed, 28 Feb 2018 22:37:50 +0200
+
starplot (0.95.5-8.2) unstable; urgency=low
* Non-maintainer upload to fix RC bug.
diff -Nru starplot-0.95.5/debian/patches/05-startup-crash.diff starplot-0.95.5/debian/patches/05-startup-crash.diff
--- starplot-0.95.5/debian/patches/05-startup-crash.diff 1970-01-01 02:00:00.000000000 +0200
+++ starplot-0.95.5/debian/patches/05-startup-crash.diff 2018-02-28 22:37:38.000000000 +0200
@@ -0,0 +1,84 @@
+From f603ddfa6a0eb6fc90bc8f14d0bb010efef975fa Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Bernhard=20=C3=9Cbelacker?= <bernhardu@mailbox.org>
+Date: Mon, 8 May 2017 23:05:28 +0200
+Subject: Replace c-like qsort with c++-like std::sort.
+
+https://bugs.debian.org/862065
+---
+ src/classes/stararray.cc | 49 +++++++++++++++++-------------------------------
+ 1 file changed, 17 insertions(+), 32 deletions(-)
+
+diff --git a/src/classes/stararray.cc b/src/classes/stararray.cc
+index 26cc6a0..72cc856 100644
+--- a/src/classes/stararray.cc
++++ b/src/classes/stararray.cc
+@@ -26,6 +26,7 @@
+
+ #define NEED_FULL_NAMES
+ #include "constellations.h"
++#include <algorithm>
+
+ using std::string;
+ using std::vector;
+@@ -167,42 +168,26 @@ typedef struct {
+
+ // Next, the function to compare for qsort().
+
+-int compare_function(const void *p, const void *q)
+-{
+- double x1 = ((const sortable *)p)->xposition;
+- double x2 = ((const sortable *)q)->xposition;
+- return (x1 - x2 >= 0.0) ? 1 : -1;
+-}
++struct sort_class {
++ Rules &rules;
++ sort_class(Rules &r) : rules(r) {};
++ bool operator() (const Star &p, const Star &q)
++ {
++ SolidAngle orientation = rules.ChartOrientation;
++ Vector3 relativeLocation;
++ relativeLocation = p.GetStarXYZ() - rules.ChartLocation;
++ double x1 = relativeLocation.getX() * cos(orientation.getPhi()) + relativeLocation.getY() * sin(orientation.getPhi());
++ relativeLocation = q.GetStarXYZ() - rules.ChartLocation;
++ double x2 = relativeLocation.getX() * cos(orientation.getPhi()) + relativeLocation.getY() * sin(orientation.getPhi());
++ return (x1 - x2 >= 0.0) ? 1 : -1;
++ }
++};
+
+-// Finally, the main function which calls qsort()
++// Finally, the main function which calls std::sort()
+
+ void StarArray::Sort()
+ {
+- size_t size = Array.size();
+- Vector3 relativeLocation;
+- SolidAngle orientation = ArrayRules.ChartOrientation;
+- sortable *temparray = new sortable[size];
+-
+- // Make a temporary array for qsort(), consisting of "sortable" structs
+- // which each contain a Star and a position in local coordinates.
+- for (size_t i = 0; i < size; i++) {
+- relativeLocation = Array[i].GetStarXYZ() - ArrayRules.ChartLocation;
+- temparray[i].xposition =
+- relativeLocation.getX() * cos(orientation.getPhi())
+- + relativeLocation.getY() * sin(orientation.getPhi());
+- temparray[i].star = Array[i];
+- }
+-
+- qsort(temparray, size, sizeof(sortable), compare_function);
+-
+- // Put the sorted temporary array back into the vector
+- Array.clear();
+- for (size_t i = 0; i < size; i++) {
+- temparray[i].star.SetPlace(i+1); // label stars starting at 1
+- Array.push_back(temparray[i].star);
+- }
+-
+- delete [] temparray;
++ std::sort(Array.begin(), Array.end(), sort_class(ArrayRules));
+ return;
+ }
+
+--
+2.11.0
+
diff -Nru starplot-0.95.5/debian/patches/series starplot-0.95.5/debian/patches/series
--- starplot-0.95.5/debian/patches/series 2016-12-24 23:59:40.000000000 +0200
+++ starplot-0.95.5/debian/patches/series 2018-02-28 22:37:47.000000000 +0200
@@ -1,3 +1,4 @@
01-starplot_desktop_file.diff
02-fix-ftbfs-and-hrdiagram-opts.diff
03-fix-ftbfs-convert.diff
+05-startup-crash.diff
Reply to: