History log of /freebsd-current/lib/libc/gen/basename.c
Revision Date Author Comments
# 559a218c 01-Nov-2023 Warner Losh <imp@FreeBSD.org>

libc: Purge unneeded cdefs.h

These sys/cdefs.h are not needed. Purge them. They are mostly left-over
from the $FreeBSD$ removal. A few in libc are still required for macros
that cdefs.h defines. Keep those.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D42385


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 34168b28 03-Nov-2016 Ed Schouten <ed@FreeBSD.org>

Replace basename(3) by a thread-safe implementation.

Now that the changes to the dirname(3) function had some time to settle,
let's go ahead and use the same approach for replacing basename(3) by a
simple implementation that modifies the input string, thereby making it
thread-safe and guaranteed to succeed.

Unlike dirname(3), this function already had a thread-safe variant
basename_r(3). This function had its own set of problems, like having an
upper bound on the pathname length. Keep this function around for
compatibility, but remove most references from the man page. Make the
man page more similar to that of dirname(3).

As the basename_r(3) function is only provided by FreeBSD (and Bionic),
depending on its use is even more implementation defined than assuming
that basename(3) is thread-safe.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D8382


# 938809f9 28-Jul-2016 Ed Schouten <ed@FreeBSD.org>

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.


# 488d6e0c 17-Jun-2011 Xin LI <delphij@FreeBSD.org>

Sync with OpenBSD, primarily make the code easier to read, and a license
change to standard OpenBSD ISC license.

Obtained from: OpenBSD
MFC after: 2 weeks


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# a502a84d 06-Oct-2009 Robert Watson <rwatson@FreeBSD.org>

Add basename_r(3) to complement basename(3). basename_r(3) which accepts
a caller-allocated buffer of at least MAXPATHLEN, rather than using a
global buffer.

MFC after: 1 month
Sponsored by: Google


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 2bc46a64 29-Dec-2002 Marcel Moolenaar <marcel@FreeBSD.org>

Fix LP64 architectures and especially ia64. Functions that return
a pointer and lack a prototype will have the return value (assumed
to be an integer) zero-extended to a pointer. On ia64 this is
unconditionally fatal as it zeroes-out the region bits, forming an
invalid pointer. Fix the sigsegv by including <stdlib.h>.

Pointy hat: bbraun


# 5fb691be 21-Dec-2002 Rob Braun <bbraun@FreeBSD.org>

Reduce libc.so's memory footprint by lazily allocating memory used internally
by basename() and dirname().
Reviewed by: eric


# 22626efa 31-Jan-2002 David E. O'Brien <obrien@FreeBSD.org>

* Remove 'register'. (some functions had 7+ register functions...)
* Fix SCM ID's.


# 56bcbf00 30-Jan-2002 Bruce Evans <bde@FreeBSD.org>

Fixed world breakage due to missing include of <sys/cdefs.h> in previous
commit.

Fixed related style bugs:
basename.c: misplaced '#if 0'
dirname.c: misplaced '#if 0'
getgrent.c: missing '#if 0', and tab lossage in vendor id (the previous
commit fixed the complete corruption of the vendor id but
lost a tab)
getpwent.c: missing '#if 0'


# 135b57f9 30-Jan-2002 David E. O'Brien <obrien@FreeBSD.org>

Fix FreeBSD IDs.


# ff5f0dbc 28-Jun-2001 Dima Dorfman <dd@FreeBSD.org>

Fix a one-byte overrun.

PR: 28472
Submitted by: David Xu <davidx@viasoft.com.cn>
Obtained from: OpenBSD


# 1250db81 31-Aug-2000 Dag-Erling Smørgrav <des@FreeBSD.org>

Import XPG4-compliant basename(3) and dirname(3) from OpenBSD.
The man pages need some adjustments.

PR: 12960, 12962
Submitted by: James Howard <howardjp@wam.umd.edu>
Obtained from: OpenBSD