]> git.ipfire.org Git - thirdparty/glibc.git/commit
Fix bsearch, qsort doc to match POSIX better
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 6 Apr 2024 15:44:01 +0000 (08:44 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 6 Apr 2024 17:10:32 +0000 (10:10 -0700)
commit57581acd9559217e859fdac693145ce6399f4d70
tree2d266e839ec76af12f055ac5114ea8f2548fce5a
parent9e1f4aef865ddeffeb4b5f6578fefab606783120
Fix bsearch, qsort doc to match POSIX better

* manual/search.texi (Array Search Function):
Correct the statement about lfind’s mean runtime:
it is proportional to a number (not that number),
and this is true only if random elements are searched for.
Relax the constraint on bsearch’s array argument:
POSIX says it need not be sorted, only partially sorted.
Say that the first arg passed to bsearch’s comparison function
is the key, and the second arg is an array element, as
POSIX requires.  For bsearch and qsort, say that the
comparison function should not alter the array, as POSIX
requires.  For qsort, say that the comparison function
must define a total order, as POSIX requires, that
it should not depend on element addresses, that
the original array index can be used for stable sorts,
and that if qsort still works if memory allocation fails.
Be more consistent in calling the array elements
“elements” rather than “objects”.

Co-authored-by: Zack Weinberg <zack@owlfolio.org>
manual/search.texi