Mercurial > cpython-lru_cache-weakref
diff Objects/floatobject.c @ 32305:13656d58d450 legacy-trunk
Patch #774665: Make Python LC_NUMERIC agnostic.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Tue, 08 Jun 2004 18:52:54 +0000 |
| parents | 65f9ad9bc829 |
| children | 201986d6d9d6 |
line wrap: on
line diff
--- a/Objects/floatobject.c Tue Jun 08 18:25:48 2004 +0000 +++ b/Objects/floatobject.c Tue Jun 08 18:52:54 2004 +0000 @@ -132,7 +132,7 @@ * key off errno. */ PyFPE_START_PROTECT("strtod", return NULL) - x = strtod(s, (char **)&end); + x = PyOS_ascii_strtod(s, (char **)&end); PyFPE_END_PROTECT(x) errno = 0; /* Believe it or not, Solaris 2.6 can move end *beyond* the null @@ -164,7 +164,7 @@ /* See above -- may have been strtod being anal about denorms. */ PyFPE_START_PROTECT("atof", return NULL) - x = atof(s); + x = PyOS_ascii_atof(s); PyFPE_END_PROTECT(x) errno = 0; /* whether atof ever set errno is undefined */ } @@ -223,6 +223,7 @@ format_float(char *buf, size_t buflen, PyFloatObject *v, int precision) { register char *cp; + char format[32]; /* Subroutine for float_repr and float_print. We want float numbers to be recognizable as such, i.e., they should contain a decimal point or an exponent. @@ -230,7 +231,8 @@ in such cases, we append ".0" to the string. */ assert(PyFloat_Check(v)); - PyOS_snprintf(buf, buflen, "%.*g", precision, v->ob_fval); + PyOS_snprintf(format, 32, "%%.%ig", precision); + PyOS_ascii_formatd(buf, buflen, format, v->ob_fval); cp = buf; if (*cp == '-') cp++;
