diff options
author | kib <kib@FreeBSD.org> | 2010-01-04 15:40:17 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2010-01-04 15:40:17 +0000 |
commit | d061de008ac2d14466eefecb47b69b59e5e79408 (patch) | |
tree | b365b59af8b0b68bad0041e490012bdb8c25eace /usr.bin | |
parent | 16db58ba54bd23cade57dc720cf9bd57f5487f3e (diff) | |
download | FreeBSD-src-d061de008ac2d14466eefecb47b69b59e5e79408.zip FreeBSD-src-d061de008ac2d14466eefecb47b69b59e5e79408.tar.gz |
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
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/catman/catman.c | 10 | ||||
-rw-r--r-- | usr.bin/makewhatis/makewhatis.c | 4 |
2 files changed, 10 insertions, 4 deletions
diff --git a/usr.bin/catman/catman.c b/usr.bin/catman/catman.c index ba3ad24..c17a091 100644 --- a/usr.bin/catman/catman.c +++ b/usr.bin/catman/catman.c @@ -589,9 +589,15 @@ process_section(char *mandir, char *section) } static int -select_sections(struct dirent *entry) +select_sections(const struct dirent *entry) { - return directory_type(entry->d_name) == MAN_SECTION_DIR; + char *name; + int ret; + + name = strdup(entry->d_name); + ret = directory_type(name) == MAN_SECTION_DIR; + free(name); + return (ret); } /* diff --git a/usr.bin/makewhatis/makewhatis.c b/usr.bin/makewhatis/makewhatis.c index 6b2dce4..f2ae370 100644 --- a/usr.bin/makewhatis/makewhatis.c +++ b/usr.bin/makewhatis/makewhatis.c @@ -879,9 +879,9 @@ process_section(char *section_dir) * Returns whether the directory entry is a man page section. */ static int -select_sections(struct dirent *entry) +select_sections(const struct dirent *entry) { - char *p = &entry->d_name[3]; + const char *p = &entry->d_name[3]; if (strncmp(entry->d_name, "man", 3) != 0) return 0; |