File:  [Research Unix] / researchv10no / cmd / dirname.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;
	if(argc<2 || *argv[1]==0)
		fini(".");
	for(p=argv[1]; *p; p++)
		continue;
	while(p>=argv[1] && *--p=='/')
		;
	if(p < argv[1])
		fini("/");
	while(p>=argv[1] && *p!='/')
		p--;
	if(p < argv[1])
		fini(".");
	while(p>=argv[1] && *p=='/')
		p--;
	if(p < argv[1])
		fini("/");
	p[1] = 0;
	fini(argv[1]);
}

fini(s)
char *s;
{
	printf("%s\n",s);
	exit(0);
}

unix.superglobalmegacorp.com

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