svn commit: r201604 - head/lib/libc/gen
ache at nagual.pp.ru
Thu Jan 7 05:04:15 UTC 2010
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.
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.
Please use strcoll() as POSIX said. It is user responsibility to set
correct locale for non-suid programs, and for suid ones locale can't be
set by user.
More information about the svn-src-head