Home | History | Annotate | Download | only in basename
      1 /*
      2  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
      3  * Use is subject to license terms.
      4  */
      5 
      6 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
      7 /*	  All Rights Reserved  	*/
      8 
      9 
     10 /*
     11  * Copyright (c) 1980 Regents of the University of California.
     12  * All rights reserved. The Berkeley software License Agreement
     13  * specifies the terms and conditions for redistribution.
     14  */
     15 
     16 #pragma ident	"%Z%%M%	%I%	%E% SMI"
     17 
     18 #include <stdio.h>
     19 #include <stdlib.h>
     20 
     21 int
     22 main(int argc, char **argv)
     23 {
     24 	char *p1, *p2, *p3;
     25 
     26 	if (argc < 2) {
     27 		(void) putchar('\n');
     28 		exit(1);
     29 	}
     30 	p1 = argv[1];
     31 	p2 = p1;
     32 	while (*p1) {
     33 		if (*p1++ == '/')
     34 			p2 = p1;
     35 	}
     36 	if (argc > 2) {
     37 		p3 = argv[2];
     38 		while (*p3)
     39 			p3++;
     40 
     41 		while (p3 > argv[2])
     42 			if (p1 <= p2 || *--p3 != *--p1)
     43 				goto output;
     44 		*p1 = '\0';
     45 	}
     46 output:
     47 
     48 	(void) fputs(p2, stdout);
     49 	(void) putc('\n', stdout);
     50 	return (0);
     51 }
     52