Annotation of coherent/b/lib/libc/gen/atol.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * C general utilities library.
        !             3:  * atol()
        !             4:  * ANSI 4.10.1.3.
        !             5:  * Convert ASCII to long (the old fashioned way).
        !             6:  */
        !             7: 
        !             8: #include <stdlib.h>
        !             9: #include <ctype.h>
        !            10: 
        !            11: long
        !            12: atol(nptr) register char *nptr;
        !            13: {
        !            14:        register long   val;
        !            15:        register int    c;
        !            16:        register int    sign;
        !            17: 
        !            18:        val = sign = 0;
        !            19: 
        !            20:        /* Leading whitespace. */
        !            21:        while (isspace(c = *nptr++))
        !            22:                ;
        !            23: 
        !            24:        /* Optional sign. */
        !            25:        if (c == '-') {
        !            26:                sign = 1;
        !            27:                c = *nptr++;
        !            28:        } else if (c == '+')
        !            29:                c = *nptr++;
        !            30: 
        !            31:        /* Process digit string. */
        !            32:        for ( ; isdigit(c); c = *nptr++)
        !            33:                val = val * 10 + c - '0';
        !            34:        return (sign ? -val : val);
        !            35: }
        !            36: 
        !            37: /* end of atol.c */

unix.superglobalmegacorp.com

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