|
|
1.1 ! root 1: static char *sccsid = "@(#)basename.c 4.1 (Berkeley) 10/1/80"; ! 2: #include "stdio.h" ! 3: ! 4: main(argc, argv) ! 5: char **argv; ! 6: { ! 7: register char *p1, *p2, *p3; ! 8: ! 9: if (argc < 2) { ! 10: putchar('\n'); ! 11: exit(1); ! 12: } ! 13: p1 = argv[1]; ! 14: p2 = p1; ! 15: while (*p1) { ! 16: if (*p1++ == '/') ! 17: p2 = p1; ! 18: } ! 19: if (argc>2) { ! 20: for(p3=argv[2]; *p3; p3++) ! 21: ; ! 22: while(p1>p2 && p3>argv[2]) ! 23: if(*--p3 != *--p1) ! 24: goto output; ! 25: *p1 = '\0'; ! 26: } ! 27: output: ! 28: puts(p2, stdout); ! 29: exit(0); ! 30: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.