-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The documentation promises that the output is sorted first by either priority or depth, then by either depth or priority, and finally by name. This derives from the fact that we store nodes in a name-indexed balanced search tree in the input phase. However, in the output phase, after calculating the depths and priorities of all nodes, we sort them using quicksort, which is not stable, breaking our promise. Moreover, different implementations of quicksort will choose different pivots, resulting in different outcomes for equally-ranked nodes. This is illustrated by the `t_dp_red` test case, which passed on FreeBSD but failed on Ubuntu due to different internal ordering within each priority group. To address this, replace `qsort(3)` with `mergesort(3)` if it is available, and our own implementation of insertion sort otherwise. Also correct the expected output of the `t_dp_red` test case.
- Loading branch information
1 parent
29f045d
commit 694f5fa
Showing
3 changed files
with
48 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,6 @@ | |
2 2 a1 | ||
1 1 b2 | ||
1 1 a2 | ||
0 0 a3 | ||
0 0 c1 | ||
0 0 b3 | ||
0 0 a3 |