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

1.1     ! root        1: #include <stdio.h>
        !             2: /*
        !             3: COLRM removes unwanted columns from a file
        !             4:        Jeff Schriebman  UC Berkeley 11-74
        !             5: */
        !             6: 
        !             7: 
        !             8: main(argc,argv)
        !             9: char **argv;
        !            10: {
        !            11:        int first;
        !            12:        register ct,last;
        !            13:        register char c;
        !            14:        char buffer[512];
        !            15: 
        !            16:        setbuf(stdout, buffer);
        !            17:        first = 20000;
        !            18:        last  = -1;
        !            19:        if (argc>1) {
        !            20:                first = getn(*++argv);
        !            21:                last = 20000;
        !            22:        }
        !            23:        if (argc>2)
        !            24:                last = getn(*++argv);
        !            25: 
        !            26: start:
        !            27:        ct = 0;
        !            28: loop1:
        !            29:        if ((c=getc(stdin))<0)
        !            30:                goto fin;
        !            31:        ct++;
        !            32:        if (c=='\n') {
        !            33:                putc(c,stdout);
        !            34:                goto start;
        !            35:        }
        !            36:        if (ct<first) {
        !            37:                putc(c,stdout);
        !            38:                goto loop1;
        !            39:        }
        !            40: 
        !            41: /* Loop getting rid of characters */
        !            42:        for (;ct<last;ct++) {
        !            43:                if ((c=getc(stdin))<0)
        !            44:                        goto fin;
        !            45:                if (c=='\n') {
        !            46:                        putc(c,stdout);
        !            47:                        goto start;
        !            48:                }
        !            49:        }
        !            50: 
        !            51: /* Output last of the line */
        !            52:        while ((c=getc(stdin))>0) {
        !            53:                putc(c,stdout);
        !            54:                if (c=='\n')
        !            55:                        goto start;
        !            56:        }
        !            57: fin:
        !            58:        fflush(stdout);
        !            59: }
        !            60: 
        !            61: getn(ap)
        !            62: char *ap;
        !            63: {
        !            64:        register int n,c;
        !            65:        register char *p;
        !            66: 
        !            67:        p = ap;
        !            68:        n = 0;
        !            69:        while ((c = *p++) >= '0' && c <= '9')
        !            70:                n = n*10 + c - '0';
        !            71:        return(n);
        !            72: }

unix.superglobalmegacorp.com

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