removed #ifdef UCBVAX. DLW
[unix-history] / usr / src / usr.bin / basename / basename.c
CommitLineData
38582a33
KM
1static char *sccsid = "@(#)basename.c 4.2 (Berkeley) %G%";
2
3#include <stdio.h>
8c24706b
BJ
4
5main(argc, argv)
6char **argv;
7{
8 register char *p1, *p2, *p3;
9
10 if (argc < 2) {
11 putchar('\n');
12 exit(1);
13 }
14 p1 = argv[1];
15 p2 = p1;
16 while (*p1) {
17 if (*p1++ == '/')
18 p2 = p1;
19 }
20 if (argc>2) {
21 for(p3=argv[2]; *p3; p3++)
22 ;
23 while(p1>p2 && p3>argv[2])
24 if(*--p3 != *--p1)
25 goto output;
26 *p1 = '\0';
27 }
28output:
29 puts(p2, stdout);
30 exit(0);
31}