Annotation of researchv8dc/libc/gen/rin.c, revision 1.1

1.1     ! root        1: /* @(#)rin.c   4.1 (Berkeley) 12/21/80 */
        !             2: #include <stdio.h>
        !             3: #include <ctype.h>
        !             4: 
        !             5: rin()
        !             6: {
        !             7:        double d;
        !             8:        register n, c, f;
        !             9: 
        !            10:        d = 0.;
        !            11:        f = 0;
        !            12:        n = 0;
        !            13: loop:
        !            14:        c = getchar();
        !            15:        if(c == EOF)
        !            16:                exit();
        !            17:        if(c == '-') {
        !            18:                f++;
        !            19:                goto loop;
        !            20:        }
        !            21:        if(c == '.') {
        !            22:                n++;
        !            23:                goto loop;
        !            24:        }
        !            25:        if(isdigit(c)) {
        !            26:                if(n)
        !            27:                        n++;
        !            28:                d = d*10.+c-'0';
        !            29:                goto loop;
        !            30:        }
        !            31:        if(f)
        !            32:                d = -d;
        !            33:        for(f=1; f<n; f++)
        !            34:                d /= 10.;
        !            35:        n = d;
        !            36:        return(n);
        !            37: }

unix.superglobalmegacorp.com

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