From: Alejandro Colomar Date: Sat, 16 Nov 2024 14:48:23 +0000 (+0100) Subject: lib/basename.c: Basename(): Use stprcspn() instead of its pattern X-Git-Tag: 4.17.3~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=887e77d52aaf294fd1fbefb6cc4527828cfd7fcd;p=thirdparty%2Fshadow.git lib/basename.c: Basename(): Use stprcspn() instead of its pattern Signed-off-by: Alejandro Colomar --- diff --git a/lib/basename.c b/lib/basename.c index 95a2f85dd..7a0e4ad24 100644 --- a/lib/basename.c +++ b/lib/basename.c @@ -1,10 +1,8 @@ -/* - * 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 - */ +// SPDX-FileCopyrightText: 1990-1994, Julianne Frances Haugh +// SPDX-FileCopyrightText: 1996-1997, Marek Michałkiewicz +// SPDX-FileCopyrightText: 2003-2005, Tomasz Kłoczko +// SPDX-FileCopyrightText: 2024, Alejandro Colomar +// SPDX-License-Identifier: BSD-3-Clause /* * basename.c - not worth copyrighting :-). Some versions of Linux libc @@ -15,17 +13,19 @@ #include -#ident "$Id$" +#include +#include -#include "defines.h" #include "prototypes.h" -/*@observer@*/const char *Basename (const char *str) +#include "string/strspn/stprcspn.h" + + +/*@observer@*/const char * +Basename(const char *str) { if (str == NULL) { abort (); } - char *cp = strrchr (str, '/'); - - return (NULL != cp) ? cp + 1 : str; + return stprcspn(str, "/"); }