Skip to content

Commit

Permalink
lib/basename.c: Basename(): Use stprcspn() instead of its pattern
Browse files Browse the repository at this point in the history
Signed-off-by: Alejandro Colomar <[email protected]>
  • Loading branch information
alejandro-colomar committed Dec 5, 2024
1 parent 46535f6 commit c9514aa
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions lib/basename.c
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
// SPDX-License-Identifier: BSD-3-Clause

/*
* basename.c - not worth copyrighting :-). Some versions of Linux libc
Expand All @@ -15,17 +13,19 @@

#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, "/");
}

0 comments on commit c9514aa

Please sign in to comment.