Annotation of 3BSD/cmd/basename.c, revision 1.1

1.1     ! root        1: #include       "stdio.h"
        !             2: 
        !             3: main(argc, argv)
        !             4: char **argv;
        !             5: {
        !             6:        register char *p1, *p2, *p3;
        !             7: 
        !             8:        if (argc < 2) {
        !             9:                putchar('\n');
        !            10:                exit(1);
        !            11:        }
        !            12:        p1 = argv[1];
        !            13:        p2 = p1;
        !            14:        while (*p1) {
        !            15:                if (*p1++ == '/')
        !            16:                        p2 = p1;
        !            17:        }
        !            18:        if (argc>2) {
        !            19:                for(p3=argv[2]; *p3; p3++) 
        !            20:                        ;
        !            21:                while(p1>p2 && p3>argv[2])
        !            22:                        if(*--p3 != *--p1)
        !            23:                                goto output;
        !            24:                *p1 = '\0';
        !            25:        }
        !            26: output:
        !            27:        puts(p2, stdout);
        !            28:        exit(0);
        !            29: }

unix.superglobalmegacorp.com

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