The mandoc search database generation uses each page's inode number as a hash key to index hard linked pages only once. However, it also processed the pages ordered by hash key resulting in effectively non-deterministic output.
Instead:
- provide fts_open() with a comparison function to process directories and files in a deterministic order
- in addition to the hash, insert pages into a linked list which will be sorted (by virtue of 1)
- iterate over pages by the list in 2, instead of hash order
I will work on getting this upstream as well (although the patch is not very invasive)