bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/4] alphasort, scandir: Port to OS/2 kLIBC


From: KO Myung-Hun
Subject: [PATCH 3/4] alphasort, scandir: Port to OS/2 kLIBC
Date: Thu, 1 Dec 2016 19:52:45 +0900

On OS/2 kLIBC, scandir() declaration is different from POSIX. As a
result, alphasort() declaration is different, too.

* lib/alphasort.c (alphasort): Implement according to OS/2 kLIBC
declaration.
* lib/scandir.c (scandir): Add declaration for OS/2 kLIBC.
---
 lib/alphasort.c | 10 ++++++++++
 lib/scandir.c   |  9 +++++++++
 2 files changed, 19 insertions(+)

diff --git a/lib/alphasort.c b/lib/alphasort.c
index 49f4bd7..9a8c0ea 100644
--- a/lib/alphasort.c
+++ b/lib/alphasort.c
@@ -21,7 +21,17 @@
 #include <string.h>
 
 int
+#ifndef __KLIBC__
 alphasort (const struct dirent **a, const struct dirent **b)
 {
   return strcoll ((*a)->d_name, (*b)->d_name);
 }
+#else
+/* On OS/2 kLIBC, the compare function declaration of scandir() is different
+   from POSIX. See 
<http://trac.netlabs.org/libc/browser/branches/libc-0.6/src/emx/include/dirent.h#L141>.
  */
+alphasort (const void *a, const void *b)
+{
+  return strcoll ((*(const struct dirent **)a)->d_name,
+                  (*(const struct dirent **)b)->d_name);
+}
+#endif
diff --git a/lib/scandir.c b/lib/scandir.c
index d9cb4c4..9da342d 100644
--- a/lib/scandir.c
+++ b/lib/scandir.c
@@ -89,10 +89,19 @@ cancel_handler (void *arg)
 
 
 int
+#ifndef __KLIBC__
 SCANDIR (const char *dir,
          DIRENT_TYPE ***namelist,
          int (*select) (const DIRENT_TYPE *),
          int (*cmp) (const DIRENT_TYPE **, const DIRENT_TYPE **))
+#else
+/* On OS/2 kLIBC, scandir() declaration is different from POSIX. See
+   
<http://trac.netlabs.org/libc/browser/branches/libc-0.6/src/emx/include/dirent.h#L141>.
  */
+SCANDIR (const char *dir,
+         DIRENT_TYPE ***namelist,
+         int (*select) (DIRENT_TYPE *),
+         int (*cmp) (const void *, const void *))
+#endif
 {
   DIR *dp = __opendir (dir);
   DIRENT_TYPE **v = NULL;
-- 
2.9.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]