diff options
author | ache <ache@FreeBSD.org> | 2010-01-18 10:17:51 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2010-01-18 10:17:51 +0000 |
commit | 630da6fd8a0f711d519e37a59877d72fce80412c (patch) | |
tree | 2cef498b0bfea870dffe17565165756ef03b06fb /lib/libc/gen/scandir.c | |
parent | cf3f3cdea63c866b330c4caf9f8559ab072f1347 (diff) | |
download | FreeBSD-src-630da6fd8a0f711d519e37a59877d72fce80412c.zip FreeBSD-src-630da6fd8a0f711d519e37a59877d72fce80412c.tar.gz |
a) Use strcoll() in opendir() and alphasort() as POSIX 2008 requires.
It also matches now how our 'ls' works for years.
b) Remove comment expressed 2 fears:
1) One just simple describe how strcoll() works in _any_ context,
not for directories only. Are we plan to remove strcoll() from everything
just because it is little more complex than strcmp()? I doubt, and
directories give nothing different here. Moreover, strcoll() used
in 'ls' for years and nobody complaints yet.
2) Plain wrong statement about undefined strcoll() behaviour. strcoll()
always gives predictable results, falling back to strcmp() on any
trouble, see strcoll(3).
No objections from -current list discussion.
Diffstat (limited to 'lib/libc/gen/scandir.c')
-rw-r--r-- | lib/libc/gen/scandir.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/lib/libc/gen/scandir.c b/lib/libc/gen/scandir.c index b6f76ba..2c86aa5 100644 --- a/lib/libc/gen/scandir.c +++ b/lib/libc/gen/scandir.c @@ -127,17 +127,13 @@ fail: /* * 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. + * POSIX 2008 requires the alphasort() to use strcoll(). */ int alphasort(const struct dirent **d1, const struct dirent **d2) { - return (strcmp((*d1)->d_name, (*d2)->d_name)); + return (strcoll((*d1)->d_name, (*d2)->d_name)); } static int |