File:  [MW Coherent from dump] / coherent / g / usr / lib / misc / basename.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed May 29 04:56:35 2019 UTC (7 years ago) by root
Branches: MarkWilliams, MAIN
CVS tags: relic, HEAD
coherent

/*
 * basename.c - find the rightmost component of a pathname.
 */
#include <stdio.h>

/*
 * Return a pointer to the basename of a full path (everthing to the
 * right of the rightmost '/'.
 */
char *
basename(path)
char *path;
{
	char *retval;
	extern char *strrchr();

	if (NULL == path)
		return(NULL);
	return ((NULL == (retval = strrchr(path, '/'))) ? path : (retval + 1));
} /* basename() */

#ifdef TEST

main(argc, argv)
int argc;
char *argv[];
{
	while (--argc > 0)
		printf("%s\n", basename(argv[argc]));
} /* main() */

#endif /* TEST */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.