diff options
author | jdp <jdp@FreeBSD.org> | 1998-03-01 22:58:51 +0000 |
---|---|---|
committer | jdp <jdp@FreeBSD.org> | 1998-03-01 22:58:51 +0000 |
commit | 2cbd0590cd191c81b59e94970f4c40c371f9e415 (patch) | |
tree | b7676f996414b979dcbb7de92a3e86b97320d023 /contrib/binutils/libiberty/basename.c | |
download | FreeBSD-src-2cbd0590cd191c81b59e94970f4c40c371f9e415.zip FreeBSD-src-2cbd0590cd191c81b59e94970f4c40c371f9e415.tar.gz |
Initial import of GNU binutils version 2.8.1. Believe it or not,
this is heavily stripped down.
Diffstat (limited to 'contrib/binutils/libiberty/basename.c')
-rw-r--r-- | contrib/binutils/libiberty/basename.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/contrib/binutils/libiberty/basename.c b/contrib/binutils/libiberty/basename.c new file mode 100644 index 0000000..689b0c2 --- /dev/null +++ b/contrib/binutils/libiberty/basename.c @@ -0,0 +1,43 @@ +/* Return the basename of a pathname. + This file is in the public domain. */ + +/* +NAME + basename -- return pointer to last component of a pathname + +SYNOPSIS + char *basename (const char *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). + +BUGS + Presumes a UNIX style path with UNIX style separators. +*/ + +#include "ansidecl.h" +#include "libiberty.h" + +#include "config.h" + +#ifdef NEED_basename + +char * +basename (name) + const char *name; +{ + const char *base = name; + + while (*name) + { + if (*name++ == '/') + { + base = name; + } + } + return (char *) base; +} + +#endif |