svn commit: r202572 - head/lib/libc/gen
Andrey Chernov
ache at nagual.pp.ru
Wed Jan 20 12:18:33 UTC 2010
On Wed, Jan 20, 2010 at 09:33:08PM +1100, Bruce Evans wrote:
> > But there is
> > nothing said about opendir() & strcoll() relation in the mentioned
> > standards. The only word I found is that opendir() returns "ordered"
> > sequence, but nowhere mentioned ordered by what criteria, so perhaps they
> > mean "stable":
>
> As I said before, sorting in opendir() has nothing to do with POSIX! It
> is an implementation detail for union file systems/mounts.
Moreover, even sorting itself is not required here. We sort just to remove
dups.
> It should also give the FreeBSD
> extension of POSIX. POSIX says: "If the strcoll() function fails,
> then the return value of alphasort() is unspecified.", but this makes
> alphasort() unusable since a qsort() comparison function must return
> a specified value.
To be used in practice, strcoll() should never fails, doing fallback to
strcmp() instead, not only in that, but in lots of other cases too (it may
set errno like EILSEQ, but not fails). The next important thing is to
return 0 only for true binary equals, additionaly ranking (f.e. by
strcmp()) anything inside classes of equality to stabilize result.
I hope our strcoll() will be kept in that state after implementing
UCA too.
--
http://ache.pp.ru/
More information about the svn-src-all
mailing list