--- /dev/null
+/*
+libgen.h
+*/
+
+#include <ansi.h>
+
+/* Open Group Base Specifications Issue 6 (not complete) */
+_PROTOTYPE( char *basename, (char *_path) );
+
$(LIBRARY)(_devctl.o) \
$(LIBRARY)(_findproc.o) \
$(LIBRARY)(asynchio.o) \
+ $(LIBRARY)(basename.o) \
$(LIBRARY)(configfile.o) \
$(LIBRARY)(crypt.o) \
$(LIBRARY)(ctermid.o) \
$(LIBRARY)(asynchio.o): asynchio.c
$(CC1) asynchio.c
+$(LIBRARY)(basename.o): basename.c
+ $(CC1) basename.c
+
$(LIBRARY)(bcmp.o): bcmp.c
$(CC1) bcmp.c
--- /dev/null
+/*
+basename.c
+*/
+
+#include <libgen.h>
+#include <string.h>
+
+char *basename(path)
+char *path;
+{
+ size_t len;
+ char *cp;
+
+ if (path == NULL)
+ return ".";
+ len= strlen(path);
+ if (len == 0)
+ return ".";
+ while (path[len-1] == '/')
+ {
+ if (len == 1)
+ return path; /* just "/" */
+ len--;
+ path[len]= '\0';
+ }
+ cp= strrchr(path, '/');
+ if (cp != NULL)
+ return cp+1;
+ return path;
+}