From c30396f5f225e0b5a83a35432e2d82a7063cfdb9 Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Mon, 29 Oct 2012 15:32:54 +0100 Subject: libc: Fix alphasort() signature (and implementation). The declaration for alphasort() in used the deprecated: int alphasort(const void*, const void*); while both Posix and GLibc use instead: int alphasort(const struct dirent** a, const struct dirent** b); See: http://pubs.opengroup.org/onlinepubs/9699919799/functions/alphasort.html This patch does the following: - Update the declaration to match Posix/GLibc - Get rid of the upstream BSD code which isn't compatible with the new signature. - Implement a new trivial alphasort() with the right signature, and ensure that it uses strcoll() instead of strcmp(). - Remove Bionic-specific #ifdef .. #else .. #endif block in dirent_test.cpp which uses alphasort(). Even through strcoll() currently uses strcmp(), this does the right thing in the case where we decide to update strcoll() to properly implement locale-specific ordered comparison. Change-Id: I4fd45604d8a940aaf2eb0ecd7d73e2f11c9bca96 --- libc/include/dirent.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libc/include/dirent.h') diff --git a/libc/include/dirent.h b/libc/include/dirent.h index 78c3a5a7e..3bd7a0fae 100644 --- a/libc/include/dirent.h +++ b/libc/include/dirent.h @@ -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**, -- cgit v1.2.3