forked from GPSBabel/gpsbabel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
retire qsort in favor of std::sort, std::stable_sort (GPSBabel#888)
* replace qsort with std::sort or std::stable_sort * add test for duplicate filter using gc_data exported dates. * fix reference file permissions. * fix smplrout sort bug that shows up on macos with std::sort. the compare function has always generated incorrect values when both objects are HUGEVAL. The historic function worked with qsort everywhere, worked with std::sort on linux and windows, but failed with std::sort on macos.
- Loading branch information
Showing
9 changed files
with
47 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
No,Latitude,Longitude,Name,Exported | ||
1,40.0,-105.1,"zero",2015/06/24 00:00:00 | ||
1,40.0,-105.2,"one",2015/06/25 00:00:01 | ||
1,40.0,-105.2,"two",2015/06/25 00:00:00 | ||
1,40.0,-105.1,"three",2015/06/24 00:00:01 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
No,Latitude,Longitude,Name,Exported | ||
1,40.000000,-105.200000,"one","2015/06/25 00:00:01" | ||
2,40.000000,-105.100000,"three","2015/06/24 00:00:01" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
No,Latitude,Longitude,Name,Exported | ||
1,40.0,-105.1,"zero",2015/06/24 00:00:02 | ||
1,40.0,-105.2,"one",2015/06/25 00:00:01 | ||
1,40.0,-105.2,"two",2015/06/25 00:00:02 | ||
1,40.0,-105.1,"three",2015/06/24 00:00:01 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
No,Latitude,Longitude,Name,Exported | ||
1,40.000000,-105.100000,"zero","2015/06/24 00:00:02" | ||
2,40.000000,-105.200000,"two","2015/06/25 00:00:02" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,8 @@ | |
2008/08/20: added "relative" option, (Carsten Allefeld, [email protected]) | ||
*/ | ||
|
||
#include <cstdlib> // for qsort, strtol | ||
#include <algorithm> // for sort | ||
#include <cstdlib> // for strtol | ||
#include <utility> // for swap | ||
|
||
#include <QDateTime> // for QDateTime | ||
|
@@ -158,6 +159,9 @@ int SimplifyRouteFilter::compare_xte(const void* a, const void* b) | |
const auto* xte_b = static_cast<const struct xte*>(b); | ||
|
||
if (HUGEVAL == xte_a->distance) { | ||
if (HUGEVAL == xte_b->distance) { | ||
return 0; | ||
} | ||
return -1; | ||
} | ||
|
||
|
@@ -238,7 +242,11 @@ void SimplifyRouteFilter::routesimple_tail(const route_head* rte) | |
|
||
|
||
/* sort XTE array, lowest XTE last */ | ||
qsort(xte_recs, xte_count, sizeof(struct xte), compare_xte); | ||
auto compare_xte_lambda = [](const xte& a, const xte& b)->bool { | ||
return compare_xte(&a, &b) < 0; | ||
}; | ||
std::sort(xte_recs, xte_recs + xte_count, compare_xte_lambda); | ||
|
||
|
||
for (i = 0; i < xte_count; i++) { | ||
xte_recs[i].intermed->xte_rec = xte_recs+i; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters