From 6c3ea4f47ea280811a7fe53a22f7832e4533c9ec Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 26 Jun 2024 18:18:36 +0200 Subject: Adding upstream version 1:4.15.2. Signed-off-by: Daniel Baumann --- lib/basename.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lib/basename.c (limited to 'lib/basename.c') diff --git a/lib/basename.c b/lib/basename.c new file mode 100644 index 0000000..95a2f85 --- /dev/null +++ b/lib/basename.c @@ -0,0 +1,31 @@ +/* + * SPDX-FileCopyrightText: 1990 - 1994, Julianne Frances Haugh + * SPDX-FileCopyrightText: 1996 - 1997, Marek Michałkiewicz + * SPDX-FileCopyrightText: 2003 - 2005, Tomasz Kłoczko + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * basename.c - not worth copyrighting :-). Some versions of Linux libc + * already have basename(), other versions don't. To avoid confusion, + * we will not use the function from libc and use a different name here. + * --marekm + */ + +#include + +#ident "$Id$" + +#include "defines.h" +#include "prototypes.h" +/*@observer@*/const char *Basename (const char *str) +{ + if (str == NULL) { + abort (); + } + + char *cp = strrchr (str, '/'); + + return (NULL != cp) ? cp + 1 : str; +} -- cgit v1.2.3