]> Savannah Git Hosting - gnulib.git/commitdiff
alphasort, scandir: Port to OS/2 kLIBC
authorKO Myung-Hun <komh78@gmail.com>
Thu, 1 Dec 2016 10:52:45 +0000 (19:52 +0900)
committerPádraig Brady <P@draigBrady.com>
Thu, 1 Dec 2016 11:36:30 +0000 (11:36 +0000)
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.

ChangeLog
lib/alphasort.c
lib/scandir.c

index 6b4d0d5c9781bcca1bf31bc7fbd22c9331ce1cb7..432be6f1396e0a12f0ac3bf2199ad2333fc1e6e7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2016-12-01  KO Myung-Hun  <komh78@gmail.com>
+
+       alphasort, scandir: Port to OS/2 kLIBC
+       * lib/alphasort.c (alphasort): Implement according to OS/2 kLIBC
+       declaration.
+       * lib/scandir.c (scandir): Add declaration for OS/2 kLIBC.
+
 2016-12-01  KO Myung-Hun  <komh78@gmail.com>
 
        relocatable: Fix that /@unixroot prefix is not working on OS/2 kLIBC
index 49f4bd7fdd8ce37e029da66dd12be7bd97b6f564..9a8c0eac3940871f1eb46ec635443d39db77f943 100644 (file)
 #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
index d9cb4c48feed0d413022ec687d90cb425e549d99..9da342d8bafaf1f0217488f6d5a88a2715824699 100644 (file)
@@ -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;