Annotation of 43BSDTahoe/ucb/pascal/src/ato.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1980 Regents of the University of California.
                      3:  * All rights reserved.  The Berkeley software License Agreement
                      4:  * specifies the terms and conditions for redistribution.
                      5:  */
                      6: 
                      7: #ifndef lint
                      8: static char sccsid[] = "@(#)ato.c      5.1 (Berkeley) 6/4/85";
                      9: #endif not lint
                     10: 
                     11: #include "whoami.h"
                     12: #include "0.h"
                     13: 
                     14: long
                     15: a8tol(cp)
                     16:        char *cp;
                     17: {
                     18:        int err;
                     19:        long l;
                     20:        register CHAR c;
                     21: 
                     22:        l = 0;
                     23:        err = 0;
                     24:        while ((c = *cp++) != '\0') {
                     25:                if (c == '8' || c == '9')
                     26:                        if (err == 0) {
                     27:                                error("8 or 9 in octal number");
                     28:                                err++;
                     29:                        }
                     30:                c -= '0';
                     31:                if ((l & 016000000000L) != 0)
                     32:                        if (err == 0) {
                     33:                                error("Number too large for this implementation");
                     34:                                err++;
                     35:                        }
                     36:                l = (l << 3) | c;
                     37:        }
                     38:        return (l);
                     39: }
                     40: 
                     41: /*
                     42:  * Note that the version of atof
                     43:  * used in this compiler does not
                     44:  * (sadly) complain when floating
                     45:  * point numbers are too large.
                     46:  */

unix.superglobalmegacorp.com

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