BSD 4 release
[unix-history] / usr / src / cmd / pi / ato.c
CommitLineData
b1d508ab
PK
1/* Copyright (c) 1979 Regents of the University of California */
2
31cef89c 3static char sccsid[] = "@(#)ato.c 1.1 8/27/80";
b1d508ab
PK
4
5#include "whoami.h"
6#include "0.h"
7
8long
9a8tol(cp)
10 char *cp;
11{
12 int err;
13 long l;
14 register CHAR c;
15
16 l = 0;
17 err = 0;
18 while ((c = *cp++) != '\0') {
19 if (c == '8' || c == '9')
20 if (err == 0) {
21 error("8 or 9 in octal number");
22 err++;
23 }
24 c -= '0';
25 if ((l & 0160000000000L) != 0)
26 if (err == 0) {
27 error("Number too large for this implementation");
28 err++;
29 }
30 l = (l << 3) | c;
31 }
32 return (l);
33}
34
35/*
36 * Note that the version of atof
37 * used in this compiler does not
38 * (sadly) complain when floating
39 * point numbers are too large.
40 */