BSD 3 development
[unix-history] / usr / src / cmd / pi / ato.c
CommitLineData
1bbf66cf
CH
1/* Copyright (c) 1979 Regents of the University of California */
2#
3/*
4 * pi - Pascal interpreter code translator
5 *
6 * Charles Haley, Bill Joy UCB
7 * Version 1.2 November 1978
8 */
9
10#include "whoami"
11#include "0.h"
12
13long
14a8tol(cp)
15 char *cp;
16{
17 int err;
18 long l;
19 register CHAR c;
20
21 l = 0;
22 err = 0;
23 while ((c = *cp++) != '\0') {
24 if (c == '8' || c == '9')
25 if (err == 0) {
26 error("8 or 9 in octal number");
27 err++;
28 }
29 c -= '0';
30 if ((l & 0160000000000L) != 0)
31 if (err == 0) {
32 error("Number too large for this implementation");
33 err++;
34 }
35 l = (l << 3) | c;
36 }
37 return (l);
38}
39
40/*
41 * Note that the version of atof
42 * used in this compiler does not
43 * (sadly) complain when floating
44 * point numbers are too large.
45 */