diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-26 16:18:39 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-26 16:18:39 +0000 |
commit | 5242eef8fc54636a41701fd9d7083ba6e4a4e0b3 (patch) | |
tree | e6a0980092957865a937cc0f34446df3d5194e99 /lib/basename.c | |
parent | Releasing progress-linux version 1:4.13+dfsg1-5~progress7.99u1. (diff) | |
download | shadow-5242eef8fc54636a41701fd9d7083ba6e4a4e0b3.tar.xz shadow-5242eef8fc54636a41701fd9d7083ba6e4a4e0b3.zip |
Merging upstream version 1:4.15.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/basename.c')
-rw-r--r-- | lib/basename.c | 31 |
1 files changed, 31 insertions, 0 deletions
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 <config.h> + +#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; +} |