diff options
author | David 'Digit' Turner <digit@android.com> | 2012-10-29 15:32:54 +0100 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2012-10-29 07:44:27 -0700 |
commit | c30396f5f225e0b5a83a35432e2d82a7063cfdb9 (patch) | |
tree | 84df04116350a6895e76c26490bbcf499a3e3099 /libc/include/dirent.h | |
parent | 8f9a1eb108f22fc2ce7283ef184d909ec0ca1152 (diff) | |
download | android_bionic-c30396f5f225e0b5a83a35432e2d82a7063cfdb9.tar.gz android_bionic-c30396f5f225e0b5a83a35432e2d82a7063cfdb9.tar.bz2 android_bionic-c30396f5f225e0b5a83a35432e2d82a7063cfdb9.zip |
libc: Fix alphasort() signature (and implementation).
The declaration for alphasort() in <dirent.h> 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
Diffstat (limited to 'libc/include/dirent.h')
-rw-r--r-- | libc/include/dirent.h | 2 |
1 files changed, 1 insertions, 1 deletions
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**, |