diff options
author | steve <steve@FreeBSD.org> | 1997-06-29 06:55:02 +0000 |
---|---|---|
committer | steve <steve@FreeBSD.org> | 1997-06-29 06:55:02 +0000 |
commit | 4b6324645f7223db0870236240d6e99eb4cda757 (patch) | |
tree | b91e93b575aeb975e736e614eaf2a0d0f8ea461a /contrib/patch/basename.c | |
download | FreeBSD-src-4b6324645f7223db0870236240d6e99eb4cda757.zip FreeBSD-src-4b6324645f7223db0870236240d6e99eb4cda757.tar.gz |
Import of GNU patch version 2.4.
Diffstat (limited to 'contrib/patch/basename.c')
-rw-r--r-- | contrib/patch/basename.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/contrib/patch/basename.c b/contrib/patch/basename.c new file mode 100644 index 0000000..8d18a8f --- /dev/null +++ b/contrib/patch/basename.c @@ -0,0 +1,32 @@ +/* basename.c -- return the last element in a path */ + +#if HAVE_CONFIG_H +# include <config.h> +#endif + +#include <backupfile.h> + +#ifndef FILESYSTEM_PREFIX_LEN +#define FILESYSTEM_PREFIX_LEN(f) 0 +#endif + +#ifndef ISSLASH +#define ISSLASH(c) ((c) == '/') +#endif + +/* In general, we can't use the builtin `basename' function if available, + since it has different meanings in different environments. + In some environments the builtin `basename' modifies its argument. */ + +char * +base_name (name) + char const *name; +{ + char const *base = name += FILESYSTEM_PREFIX_LEN (name); + + for (; *name; name++) + if (ISSLASH (*name)) + base = name + 1; + + return (char *) base; +} |