|
|
1.1 ! root 1: static char *sccsid = "@(#)basename.c 4.2 (Berkeley) 10/20/82"; ! 2: ! 3: #include <stdio.h> ! 4: ! 5: main(argc, argv) ! 6: char **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: } ! 28: output: ! 29: puts(p2, stdout); ! 30: exit(0); ! 31: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.