Guido van Rossum | 753e2bf | 1991-04-16 08:45:40 +0000 | [diff] [blame] | 1 | /* This is not a proper strtod() implementation, but sufficient for Python. |
2 | Python won't detect floating point constant overflow, though. */ | ||||
3 | |||||
Guido van Rossum | 5afc747 | 1991-12-31 13:15:19 +0000 | [diff] [blame] | 4 | extern int errno; |
5 | |||||
Guido van Rossum | 54a41d6 | 1991-12-24 13:29:10 +0000 | [diff] [blame] | 6 | extern int strlen(); |
Guido van Rossum | 753e2bf | 1991-04-16 08:45:40 +0000 | [diff] [blame] | 7 | extern double atof(); |
8 | |||||
Guido van Rossum | 753e2bf | 1991-04-16 08:45:40 +0000 | [diff] [blame] | 9 | double |
10 | strtod(p, pp) | ||||
11 | char *p; | ||||
12 | char **pp; | ||||
13 | { | ||||
Guido van Rossum | 5afc747 | 1991-12-31 13:15:19 +0000 | [diff] [blame] | 14 | double res; |
15 | |||||
Guido van Rossum | 753e2bf | 1991-04-16 08:45:40 +0000 | [diff] [blame] | 16 | if (pp) |
Guido van Rossum | 54a41d6 | 1991-12-24 13:29:10 +0000 | [diff] [blame] | 17 | *pp = p + strlen(p); |
Guido van Rossum | 5afc747 | 1991-12-31 13:15:19 +0000 | [diff] [blame] | 18 | res = atof(p); |
19 | errno = 0; | ||||
20 | return res; | ||||
21 | |||||
Guido van Rossum | 753e2bf | 1991-04-16 08:45:40 +0000 | [diff] [blame] | 22 | } |