Commit | Line | Data |
---|---|---|
0fc6e47b KB |
1 | /*- |
2 | * Copyright (c) 1980 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * %sccs.include.redist.c% | |
b79f4fa9 | 6 | */ |
b1d508ab | 7 | |
72fbef68 | 8 | #ifndef lint |
0fc6e47b KB |
9 | static char sccsid[] = "@(#)ato.c 5.2 (Berkeley) %G%"; |
10 | #endif /* not lint */ | |
b1d508ab PK |
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'; | |
6cbd3a07 | 32 | if ((l & 016000000000L) != 0) |
b1d508ab PK |
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 | */ |