File:  [Research Unix] / researchv10no / cmd / basename.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 17:21:34 2018 UTC (8 years, 1 month ago) by root
Branches: belllabs, MAIN
CVS tags: researchv10, HEAD
researchv10 Norman

main(argc,argv)
char **argv;
{
	char *p, *q;
	if(argc < 2) {
		printf("\n");
		return 0;
	}
	for(p = argv[1]; *p; ) 
		if(*p++ == '/')
			argv[1] = p;
	if(argc > 2) {
		for(q = argv[2]; *q; q++) ;
		while(--q>=argv[2] && --p>=argv[1] && *p==*q) ;
		if(q < argv[2])
			*p = 0;
	}
	printf("%s\n", argv[1]);
	return 0;
}

unix.superglobalmegacorp.com

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