]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/basename.c: Basename(): Use stprcspn() instead of its pattern
authorAlejandro Colomar <alx@kernel.org>
Sat, 16 Nov 2024 14:48:23 +0000 (15:48 +0100)
committerSerge Hallyn <serge@hallyn.com>
Sun, 16 Feb 2025 19:22:51 +0000 (13:22 -0600)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/basename.c

index 95a2f85dd6ce5d30361f86b435770b65e8c43ebf..7a0e4ad2445bde543ee5ee06c0c70089e73abd41 100644 (file)
@@ -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 <alx@kernel.org>
+// SPDX-License-Identifier: BSD-3-Clause
 
 /*
  * basename.c - not worth copyrighting :-).  Some versions of Linux libc
 
 #include <config.h>
 
-#ident "$Id$"
+#include <stddef.h>
+#include <stdlib.h>
 
-#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, "/");
 }