From owner-svn-src-all@FreeBSD.ORG Mon Jan 18 10:17:51 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EE76F106566B; Mon, 18 Jan 2010 10:17:51 +0000 (UTC) (envelope-from ache@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B57038FC08; Mon, 18 Jan 2010 10:17:51 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o0IAHpDA028524; Mon, 18 Jan 2010 10:17:51 GMT (envelope-from ache@svn.freebsd.org) Received: (from ache@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o0IAHpbs028521; Mon, 18 Jan 2010 10:17:51 GMT (envelope-from ache@svn.freebsd.org) Message-Id: <201001181017.o0IAHpbs028521@svn.freebsd.org> From: "Andrey A. Chernov" Date: Mon, 18 Jan 2010 10:17:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r202556 - head/lib/libc/gen X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jan 2010 10:17:52 -0000 Author: ache Date: Mon Jan 18 10:17:51 2010 New Revision: 202556 URL: http://svn.freebsd.org/changeset/base/202556 Log: 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. Modified: head/lib/libc/gen/opendir.c head/lib/libc/gen/scandir.c Modified: head/lib/libc/gen/opendir.c ============================================================================== --- head/lib/libc/gen/opendir.c Mon Jan 18 09:41:54 2010 (r202555) +++ head/lib/libc/gen/opendir.c Mon Jan 18 10:17:51 2010 (r202556) @@ -94,13 +94,13 @@ __opendir2(const char *name, int flags) /* * POSIX 2008 and XSI 7 require alphasort() to call strcoll() for - * directory entries ordering. Use local copy that uses strcmp(). + * directory entries ordering. */ static int opendir_alphasort(const void *p1, const void *p2) { - return (strcmp((*(const struct dirent **)p1)->d_name, + return (strcoll((*(const struct dirent **)p1)->d_name, (*(const struct dirent **)p2)->d_name)); } Modified: head/lib/libc/gen/scandir.c ============================================================================== --- head/lib/libc/gen/scandir.c Mon Jan 18 09:41:54 2010 (r202555) +++ head/lib/libc/gen/scandir.c Mon Jan 18 10:17:51 2010 (r202556) @@ -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