summaryrefslogtreecommitdiff
path: root/basename.c
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@suse.de>2009-03-12 15:13:11 +0100
committerAndreas Gruenbacher <agruen@suse.de>2009-03-12 15:13:11 +0100
commitbcce1233902dc7a94623b3a90cd7920c44f22474 (patch)
tree35098589ae46a13ab212e74fc6b0b710a44bbcb3 /basename.c
parent068f401ee314e2274b58adbc1256286ae7a56f9f (diff)
downloadpatch-2.2.tar.gz
Import of patch-2.2.tar.gzv2.2
Diffstat (limited to 'basename.c')
-rw-r--r--basename.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/basename.c b/basename.c
new file mode 100644
index 0000000..1cc7854
--- /dev/null
+++ b/basename.c
@@ -0,0 +1,24 @@
+/* basename.c -- return the last element in a path */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <backupfile.h>
+
+/* 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;
+
+ while (*name)
+ if (*name++ == '/')
+ base = name;
+
+ return (char *) base;
+}