From 6a8d15d923068d483eb61b07b326172187dc6f5e Mon Sep 17 00:00:00 2001 From: schwarze Date: Wed, 24 Sep 2025 13:08:34 +0000 Subject: [PATCH] When sorting page names (without section numbers) in the mandoc database, after sorting by name type in descending order (to put the most important names first), use the same sort order that is conventional in SEE ALSO sections: first case-insensitively in ascending alphabetic order, and if that results in a tie because two names differ only in case (like OSSL_TRACE_END and OSSL_trace_end, which are *different* names that, in FreeBSD, are documented in the same manual page - why am i unsurprised that such madness occurs with "OSSL" of all APIs?), break the tie by sorting case-sensitively in ascending alphabetic order, i.e. put capitals before lowercase letters, rather than allowing the tie to result in a random order. This very minor issue was found by Mark Johnston when he worked on reproducible builds in FreeBSD. --- usr.bin/mandoc/dba.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/usr.bin/mandoc/dba.c b/usr.bin/mandoc/dba.c index bbeea426aee..eb85aa924b9 100644 --- a/usr.bin/mandoc/dba.c +++ b/usr.bin/mandoc/dba.c @@ -1,6 +1,6 @@ -/* $OpenBSD: dba.c,v 1.7 2017/02/09 18:26:17 schwarze Exp $ */ +/* $OpenBSD: dba.c,v 1.8 2025/09/24 13:08:34 schwarze Exp $ */ /* - * Copyright (c) 2016, 2017 Ingo Schwarze + * Copyright (c) 2016, 2017, 2025 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -310,7 +310,8 @@ compare_names(const void *vp1, const void *vp2) cp1 = *(const char * const *)vp1; cp2 = *(const char * const *)vp2; return (diff = *cp2 - *cp1) ? diff : - strcasecmp(cp1 + 1, cp2 + 1); + (diff = strcasecmp(cp1 + 1, cp2 + 1)) ? diff : + strcmp(cp1 + 1, cp2 + 1); } static int