00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "ansidecl.h"
00016 #include "libiberty.h"
00017 #include "safe-ctype.h"
00018
00019 #ifndef DIR_SEPARATOR
00020 #define DIR_SEPARATOR '/'
00021 #endif
00022
00023 #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
00024 defined (__OS2__)
00025 #define HAVE_DOS_BASED_FILE_SYSTEM
00026 #ifndef DIR_SEPARATOR_2
00027 #define DIR_SEPARATOR_2 '\\'
00028 #endif
00029 #endif
00030
00031
00032 #ifndef DIR_SEPARATOR_2
00033 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
00034 #else
00035 # define IS_DIR_SEPARATOR(ch) \
00036 (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
00037 #endif
00038
00039 char *
00040 basename (name)
00041 const char *name;
00042 {
00043 const char *base;
00044
00045 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
00046
00047 if (ISALPHA (name[0]) && name[1] == ':')
00048 name += 2;
00049 #endif
00050
00051 for (base = name; *name; name++)
00052 {
00053 if (IS_DIR_SEPARATOR (*name))
00054 {
00055 base = name + 1;
00056 }
00057 }
00058 return (char *) base;
00059 }
00060