X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=libiberty%2Fbasename.c;h=0f2c069f0ccf5a7d91e4913548e068c247e12efb;hb=4636b7db71d4ca8ccf999a837e932ee1d009ad42;hp=7698f06f8ae4675ab99c4a29866c40c56c39b689;hpb=e2eaf477991014a67bc122c3225f6a3fe6d1a8e6;p=deliverable%2Fbinutils-gdb.git diff --git a/libiberty/basename.c b/libiberty/basename.c index 7698f06f8a..0f2c069f0c 100644 --- a/libiberty/basename.c +++ b/libiberty/basename.c @@ -2,25 +2,22 @@ This file is in the public domain. */ /* -NAME - basename -- return pointer to last component of a pathname -SYNOPSIS - char *basename (const char *name) +@deftypefn Supplemental char* basename (const char *@var{name}) -DESCRIPTION - Given a pointer to a string containing a typical pathname - (/usr/src/cmd/ls/ls.c for example), returns a pointer to the - last component of the pathname ("ls.c" in this case). +Returns a pointer to the last component of pathname @var{name}. +Behavior is undefined if the pathname ends in a directory separator. + +@end deftypefn -BUGS - Presumes a UNIX or DOS/Windows style path with UNIX or DOS/Windows - style separators. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include "ansidecl.h" #include "libiberty.h" -#include +#include "safe-ctype.h" #ifndef DIR_SEPARATOR #define DIR_SEPARATOR '/' @@ -43,14 +40,13 @@ BUGS #endif /* DIR_SEPARATOR_2 */ char * -basename (name) - const char *name; +basename (const char *name) { const char *base; #if defined (HAVE_DOS_BASED_FILE_SYSTEM) /* Skip over the disk name in MSDOS pathnames. */ - if (isalpha (name[0]) && name[1] == ':') + if (ISALPHA (name[0]) && name[1] == ':') name += 2; #endif