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