diff options
author | Ed Schouten <ed@FreeBSD.org> | 2016-07-28 16:20:27 +0000 |
---|---|---|
committer | Ed Schouten <ed@FreeBSD.org> | 2016-07-28 16:20:27 +0000 |
commit | 938809f9411ca770cd11d6e96fb384050a52f7d8 (patch) | |
tree | 8a40844965209129571014428aa3b890f7bf6abe /lib | |
parent | 491cb043bdf337a6b4889f4b9803c6f188b351b6 (diff) | |
download | src-938809f9411ca770cd11d6e96fb384050a52f7d8.tar.gz src-938809f9411ca770cd11d6e96fb384050a52f7d8.zip |
Fix up prototypes of basename(3) and dirname(3) to comply to POSIX.
POSIX allows these functions to be implemented in a way that the
resulting string is stored in the input buffer. Though some may find
this annoying, this has the advantage that it makes it possible to
implement this function in a thread-safe way. It also means that they
can be implemented in a way that they work for paths of arbitrary
length, as the output string of these functions is never longer than
max(1, len(input)).
Portable code already needs to be written with this in mind, so in my
opinion it makes very little sense to allow the existing behaviour.
Prevent the base system from falling back to this by switching over to
POSIX prototypes.
I'm not going to bump the __FreeBSD_version for this. The reason is that
it's possible to account for this change in a portable way, without
depending on a specific version of FreeBSD. An exp-run was done some
time ago. As far as I know, all regressions as a result of this have
already been fixed.
I'll give this change some time to settle. In the long run I want to
replace our copies by ones that are thread-safe and don't depend on
PATH_MAX/MAXPATHLEN.
Notes
Notes:
svn path=/head/; revision=303451
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/gen/basename.3 | 4 | ||||
-rw-r--r-- | lib/libc/gen/basename.c | 2 | ||||
-rw-r--r-- | lib/libc/gen/dirname.3 | 4 | ||||
-rw-r--r-- | lib/libc/gen/dirname.c | 2 |
4 files changed, 6 insertions, 6 deletions
diff --git a/lib/libc/gen/basename.3 b/lib/libc/gen/basename.3 index bcdd99e30a88..859f1047f84e 100644 --- a/lib/libc/gen/basename.3 +++ b/lib/libc/gen/basename.3 @@ -16,7 +16,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 31, 2010 +.Dd July 28, 2016 .Dt BASENAME 3 .Os .Sh NAME @@ -25,7 +25,7 @@ .Sh SYNOPSIS .In libgen.h .Ft char * -.Fn basename "const char *path" +.Fn basename "char *path" .Ft char * .Fn basename_r "const char *path" "char *bname" .Sh DESCRIPTION diff --git a/lib/libc/gen/basename.c b/lib/libc/gen/basename.c index f2bfe5f3e7ce..7e21ca4aa307 100644 --- a/lib/libc/gen/basename.c +++ b/lib/libc/gen/basename.c @@ -66,7 +66,7 @@ basename_r(const char *path, char *bname) } char * -basename(const char *path) +basename(char *path) { static char *bname = NULL; diff --git a/lib/libc/gen/dirname.3 b/lib/libc/gen/dirname.3 index ba5cce35c40c..19e45add0ad5 100644 --- a/lib/libc/gen/dirname.3 +++ b/lib/libc/gen/dirname.3 @@ -16,7 +16,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 12, 2006 +.Dd July 28, 2016 .Dt DIRNAME 3 .Os .Sh NAME @@ -25,7 +25,7 @@ .Sh SYNOPSIS .In libgen.h .Ft char * -.Fn dirname "const char *path" +.Fn dirname "char *path" .Sh DESCRIPTION The .Fn dirname diff --git a/lib/libc/gen/dirname.c b/lib/libc/gen/dirname.c index 5a94c1aee59c..5e0042fd2d10 100644 --- a/lib/libc/gen/dirname.c +++ b/lib/libc/gen/dirname.c @@ -26,7 +26,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> char * -dirname(const char *path) +dirname(char *path) { static char *dname = NULL; size_t len; |