Annotation of 40BSD/cmd/uucp/chksum.c, revision 1.1

1.1     ! root        1: main()
        !             2: {
        !             3:        int i, j;
        !             4:        char buf[300];
        !             5: 
        !             6:        for (i = 0; i < 300; i++)
        !             7:                buf[i] = i;
        !             8:        printf("%o\n", chksum(buf, 300));
        !             9: }
        !            10: 
        !            11: chksum(s,n)
        !            12: register char *s;
        !            13: register n;
        !            14: {
        !            15:        register short sum;
        !            16:        register unsigned t;
        !            17:        register x;
        !            18: 
        !            19:        sum = -1;
        !            20:        x = 0;
        !            21: 
        !            22:        do {
        !            23:                if (sum<0) {
        !            24:                        sum <<= 1;
        !            25:                        sum++;
        !            26:                } else
        !            27:                        sum <<= 1;
        !            28:                t = sum;
        !            29:                sum += (unsigned)*s++;
        !            30:                x += sum^n;
        !            31:                if ((unsigned)sum <= t) {
        !            32:                        sum ^= x;
        !            33:                }
        !            34:        } while (--n > 0);
        !            35: 
        !            36:        return(sum);
        !            37: }

unix.superglobalmegacorp.com

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