From 938809f9411ca770cd11d6e96fb384050a52f7d8 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Thu, 28 Jul 2016 16:20:27 +0000 Subject: 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. --- include/libgen.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/libgen.h b/include/libgen.h index 28c0067a27d2..5edf19e34a66 100644 --- a/include/libgen.h +++ b/include/libgen.h @@ -34,9 +34,9 @@ #include __BEGIN_DECLS -char *basename(const char *); +char *basename(char *); char *basename_r(const char *, char *); -char *dirname(const char *); +char *dirname(char *); __END_DECLS #endif /* !_LIBGEN_H_ */ -- cgit v1.3