Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>2010-01-18 13:17:51 +0300
committerSebastian Huber <sebastian.huber@embedded-brains.de>2019-02-01 12:37:00 +0300
commit67613cbbd87b5b3c5b10209e6272fc8ec6405b26 (patch)
tree880743ec993327964751bd666b1e63e5bc44146c
parent2d3c2f4697481dc6df76528c9addabd4c80d3652 (diff)
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.
-rw-r--r--newlib/libc/posix/scandir.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/newlib/libc/posix/scandir.c b/newlib/libc/posix/scandir.c
index 56de1b9e1..c39d9a4c4 100644
--- a/newlib/libc/posix/scandir.c
+++ b/newlib/libc/posix/scandir.c
@@ -142,12 +142,13 @@ fail:
/*
* Alphabetic order comparison routine for those who want it.
+ * POSIX 2008 requires that alphasort() uses strcoll().
*/
int
-alphasort (const struct dirent **d1,
- const struct dirent **d2)
+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));
}
#endif /* ! HAVE_OPENDIR */