Mercurial > gnulib
changeset 38218:5bc20d24ba69
alphasort, scandir: Port to OS/2 kLIBC
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.
author | KO Myung-Hun <komh78@gmail.com> |
---|---|
date | Thu, 01 Dec 2016 19:52:45 +0900 |
parents | d52638985bec |
children | 620120a09469 |
files | ChangeLog lib/alphasort.c lib/scandir.c |
diffstat | 3 files changed, 26 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Dec 01 19:52:44 2016 +0900 +++ b/ChangeLog Thu Dec 01 19:52:45 2016 +0900 @@ -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
--- a/lib/alphasort.c Thu Dec 01 19:52:44 2016 +0900 +++ b/lib/alphasort.c Thu Dec 01 19:52:45 2016 +0900 @@ -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
--- a/lib/scandir.c Thu Dec 01 19:52:44 2016 +0900 +++ b/lib/scandir.c Thu Dec 01 19:52:45 2016 +0900 @@ -89,10 +89,19 @@ 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;