svn commit: r201604 - head/lib/libc/gen
brde at optusnet.com.au
Thu Jan 7 16:29:11 UTC 2010
On Thu, 7 Jan 2010, Andrey Chernov wrote:
> On Tue, Jan 05, 2010 at 08:20:31PM +0000, Konstantin Belousov wrote:
>> * Alphabetic order comparison routine for those who want it.
>> + *
>> + * XXXKIB POSIX 2008 requires the alphasort() to use strcoll(). Keep
>> + * strcmp() for now, since environment locale settings could have no
>> + * relevance for the byte sequence of the file name. Moreover, it
>> + * might be even invalid sequence in current locale, and then
>> + * behaviour of alphasort would be undefined.
> This is wrong turn.
Nothing has turned here yet. We just didn't want to risk changing
> Exact the same can be said about text files: "environment locale
> settings could have no relevance for the byte sequence of the text.
> Moreover, it might be even invalid sequence in current locale, and then
> behaviour of sort would be undefined". Despite of this, we use
> localized sort in the system.
> You made result of something like 'ls | sort' and alphasort() differs.
alphasort() has always used strcmp(). It became inconsistent with plain
ls when you changed ls to use strcoll() in 2006. (ls has never used
scandir() or alphasort() in FreeBSD; it uses fts). "| sort" might be
useable to give the same ordering for both ls and utilities using
POSIX adds an EINVAL error and a requirement that errno no be modified
if there is no error, so that errors from strcoll() can be detected
(still messily -- you have to set errno to != EINVAL before the call).
Maybe falling back to strcmp() is good enough for the errnor handling.
More information about the svn-src-head