* commit '40e467ec668b59be25491bd44bf348a884d6a68d': libc: Fix alphasort() signature (and implementation).
This commit is contained in:
commit
d4834a217e
5 changed files with 6 additions and 72 deletions
|
@ -279,13 +279,13 @@ libc_common_src_files := \
|
|||
|
||||
libc_bionic_src_files := \
|
||||
bionic/assert.cpp \
|
||||
bionic/dirent.cpp \
|
||||
bionic/eventfd.cpp \
|
||||
bionic/__fgets_chk.cpp \
|
||||
bionic/getcwd.cpp \
|
||||
bionic/__memcpy_chk.cpp \
|
||||
bionic/__memmove_chk.cpp \
|
||||
bionic/__memset_chk.cpp \
|
||||
bionic/opendir.cpp \
|
||||
bionic/setlocale.cpp \
|
||||
bionic/__strcat_chk.cpp \
|
||||
bionic/__strcpy_chk.cpp \
|
||||
|
@ -309,7 +309,6 @@ libc_upstream_netbsd_src_files := \
|
|||
upstream-netbsd/common/lib/libc/hash/sha1/sha1.c \
|
||||
upstream-netbsd/common/lib/libc/inet/inet_addr.c \
|
||||
upstream-netbsd/libc/compat-43/creat.c \
|
||||
upstream-netbsd/libc/gen/alphasort.c \
|
||||
upstream-netbsd/libc/gen/ftw.c \
|
||||
upstream-netbsd/libc/gen/nftw.c \
|
||||
upstream-netbsd/libc/gen/nice.c \
|
||||
|
|
|
@ -190,3 +190,7 @@ int scandir(const char* path, dirent*** namelist,
|
|||
*namelist = de_list;
|
||||
return n_elem;
|
||||
}
|
||||
|
||||
int alphasort(const struct dirent** a, const struct dirent** b) {
|
||||
return strcoll((*a)->d_name, (*b)->d_name);
|
||||
}
|
|
@ -62,7 +62,7 @@ extern int readdir_r(DIR* dirp, struct dirent* entry, struct dire
|
|||
extern int closedir(DIR* dirp);
|
||||
extern void rewinddir(DIR* dirp);
|
||||
extern int dirfd(DIR* dirp);
|
||||
extern int alphasort(const void* a, const void* b);
|
||||
extern int alphasort(const struct dirent** a, const struct dirent** b);
|
||||
extern int scandir(const char* dir, struct dirent*** namelist,
|
||||
int(*filter)(const struct dirent*),
|
||||
int(*compar)(const struct dirent**,
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
/* $NetBSD: alphasort.c,v 1.2 2009/03/01 19:59:55 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)scandir.c 8.3 (Berkeley) 1/2/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: alphasort.c,v 1.2 2009/03/01 19:59:55 christos Exp $");
|
||||
#endif
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
* Alphabetic order comparison routine for those who want it.
|
||||
*/
|
||||
int
|
||||
alphasort(const void *d1, const void *d2)
|
||||
{
|
||||
|
||||
_DIAGASSERT(d1 != NULL);
|
||||
_DIAGASSERT(d2 != NULL);
|
||||
|
||||
return (strcmp((*(const struct dirent *const *)d1)->d_name,
|
||||
(*(const struct dirent *const *)d2)->d_name));
|
||||
}
|
|
@ -28,12 +28,6 @@
|
|||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#ifdef __BIONIC__
|
||||
static int my_alphasort(const dirent** lhs, const dirent** rhs) {
|
||||
return alphasort(lhs, rhs);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void CheckProcSelf(std::set<std::string>& names) {
|
||||
// We have a good idea of what should be in /proc/self.
|
||||
ASSERT_TRUE(names.find(".") != names.end());
|
||||
|
@ -46,11 +40,7 @@ static void CheckProcSelf(std::set<std::string>& names) {
|
|||
TEST(dirent, scandir) {
|
||||
// Get everything from /proc/self...
|
||||
dirent** entries;
|
||||
#ifdef __BIONIC__
|
||||
int entry_count = scandir("/proc/self", &entries, NULL, my_alphasort);
|
||||
#else
|
||||
int entry_count = scandir("/proc/self", &entries, NULL, alphasort);
|
||||
#endif
|
||||
ASSERT_GE(entry_count, 0);
|
||||
|
||||
// Turn the directory entries into a set and vector of the names.
|
||||
|
|
Loading…
Reference in a new issue