aboutsummaryrefslogtreecommitdiffstats
path: root/tests/dirent_test.cpp
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@android.com>2012-10-29 15:32:54 +0100
committerElliott Hughes <enh@google.com>2012-10-29 07:44:27 -0700
commitc30396f5f225e0b5a83a35432e2d82a7063cfdb9 (patch)
tree84df04116350a6895e76c26490bbcf499a3e3099 /tests/dirent_test.cpp
parent8f9a1eb108f22fc2ce7283ef184d909ec0ca1152 (diff)
downloadandroid_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 'tests/dirent_test.cpp')
-rw-r--r--tests/dirent_test.cpp10
1 files changed, 0 insertions, 10 deletions
diff --git a/tests/dirent_test.cpp b/tests/dirent_test.cpp
index 4e364d304..8f3c24902 100644
--- a/tests/dirent_test.cpp
+++ b/tests/dirent_test.cpp
@@ -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.