1 /* Return the basename of a pathname.
2 This file is in the public domain. */
6 @deftypefn Supplemental char* basename (const char *@var{name})
8 Returns a pointer to the last component of pathname @var{name}.
9 Behavior is undefined if the pathname ends in a directory separator.
19 #include "libiberty.h"
20 #include "safe-ctype.h"
23 #define DIR_SEPARATOR '/'
26 #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
28 #define HAVE_DOS_BASED_FILE_SYSTEM
29 #ifndef DIR_SEPARATOR_2
30 #define DIR_SEPARATOR_2 '\\'
34 /* Define IS_DIR_SEPARATOR. */
35 #ifndef DIR_SEPARATOR_2
36 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
37 #else /* DIR_SEPARATOR_2 */
38 # define IS_DIR_SEPARATOR(ch) \
39 (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
40 #endif /* DIR_SEPARATOR_2 */
43 basename (const char *name
)
47 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
48 /* Skip over the disk name in MSDOS pathnames. */
49 if (ISALPHA (name
[0]) && name
[1] == ':')
53 for (base
= name
; *name
; name
++)
55 if (IS_DIR_SEPARATOR (*name
))
This page took 0.030315 seconds and 4 git commands to generate.