Annotation of researchv10no/libc/gen/actol.c, revision 1.1.1.1

1.1       root        1: long
                      2: atol(s)
                      3: register char *s;
                      4: {
                      5:        register long n;
                      6:        int f;
                      7: 
                      8:        n = 0;
                      9:        f = 0;
                     10:        while((*s == ' ') || (*s == '\t'))
                     11:                s++;
                     12:        if(*s == '-') {
                     13:                f = 1;
                     14:                s++;
                     15:        }
                     16:        if(s[0]=='0' && s[1]){
                     17:                if(s[1]=='x' || s[1]=='X'){
                     18:                        s += 2;
                     19:                        for(;;){
                     20:                                if(*s >= '0' && *s <= '9')
                     21:                                        n = n*16 + *s++ - '0';
                     22:                                else if(*s >= 'a' && *s <= 'f')
                     23:                                        n = n*16 + *s++ - 'a' + 10;
                     24:                                else if(*s >= 'A' && *s <= 'F')
                     25:                                        n = n*16 + *s++ - 'A' + 10;
                     26:                                else
                     27:                                        break;
                     28:                        }
                     29:                } else
                     30:                        while(*s >= '0' && *s <= '7')
                     31:                                n = n*8 + *s++ - '0';
                     32:        } else
                     33:                while(*s >= '0' && *s <= '9')
                     34:                        n = n*10 + *s++ - '0';
                     35:        if(f)
                     36:                n = -n;
                     37:        return n;
                     38: }

unix.superglobalmegacorp.com

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