From d061de008ac2d14466eefecb47b69b59e5e79408 Mon Sep 17 00:00:00 2001 From: kib Date: Mon, 4 Jan 2010 15:40:17 +0000 Subject: Modernize scandir(3) and alphasort(3) interfaces according to the IEEE Std 1003.1-2008. Both Linux and Solaris conforms to the new definitions, so we better follow too (older glibc used old BSDish alphasort prototype and corresponding type of the comparision function for scandir). While there, change the definitions of the functions to ANSI C and fix several style issues nearby. Remove requirement for "sys/types.h" include for functions from manpage. POSIX also requires that alphasort(3) sorts as if strcoll(3) was used, but leave the strcmp(3) call in the function for now. Adapt in-tree callers of scandir(3) to new declaration. The fact that select_sections() from catman(1) could modify supplied struct dirent is a bug. PR: standards/142255 MFC after: 2 weeks --- include/dirent.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/dirent.h b/include/dirent.h index 63626b5..8d7e5c1 100644 --- a/include/dirent.h +++ b/include/dirent.h @@ -95,7 +95,7 @@ typedef void * DIR; __BEGIN_DECLS #if __BSD_VISIBLE DIR *__opendir2(const char *, int); -int alphasort(const void *, const void *); +int alphasort(const struct dirent **, const struct dirent **); int getdents(int, char *, int); int getdirentries(int, char *, int, long *); #endif @@ -109,7 +109,8 @@ int readdir_r(DIR *, struct dirent *, struct dirent **); void rewinddir(DIR *); #if __BSD_VISIBLE int scandir(const char *, struct dirent ***, - int (*)(struct dirent *), int (*)(const void *, const void *)); + int (*)(const struct dirent *), int (*)(const struct dirent **, + const struct dirent **)); #endif #if __XSI_VISIBLE void seekdir(DIR *, long); -- cgit v1.1