summaryrefslogtreecommitdiff
path: root/Python/pystrtod.c
diff options
context:
space:
mode:
authorTerry Jan Reedy <tjreedy@udel.edu>2013-03-13 21:35:07 -0400
committerTerry Jan Reedy <tjreedy@udel.edu>2013-03-13 21:35:07 -0400
commit6e1f43c7134a81fa559ae0958d257de28337ab6f (patch)
tree6d1e53c5b5637f60f96fddad23ec2072daa0ef60 /Python/pystrtod.c
parent8c41e21d39e424334a15a2e9ac922f0ac0f59a39 (diff)
parent3a12ade6e1b2a96e92348ed851c8fa66d20dfa99 (diff)
downloadcpython-6e1f43c7134a81fa559ae0958d257de28337ab6f.tar.gz
Merge with 3.2: Issue #17386
Diffstat (limited to 'Python/pystrtod.c')
-rw-r--r--Python/pystrtod.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/Python/pystrtod.c b/Python/pystrtod.c
index 75e3032fb7..4ab8f08d22 100644
--- a/Python/pystrtod.c
+++ b/Python/pystrtod.c
@@ -22,6 +22,43 @@ case_insensitive_match(const char *s, const char *t)
the successfully parsed portion of the string. On failure, return -1.0 and
set *endptr to point to the start of the string. */
+#ifndef PY_NO_SHORT_FLOAT_REPR
+
+double
+_Py_parse_inf_or_nan(const char *p, char **endptr)
+{
+ double retval;
+ const char *s;
+ int negate = 0;
+
+ s = p;
+ if (*s == '-') {
+ negate = 1;
+ s++;
+ }
+ else if (*s == '+') {
+ s++;
+ }
+ if (case_insensitive_match(s, "inf")) {
+ s += 3;
+ if (case_insensitive_match(s, "inity"))
+ s += 5;
+ retval = _Py_dg_infinity(negate);
+ }
+ else if (case_insensitive_match(s, "nan")) {
+ s += 3;
+ retval = _Py_dg_stdnan(negate);
+ }
+ else {
+ s = p;
+ retval = -1.0;
+ }
+ *endptr = (char *)s;
+ return retval;
+}
+
+#else
+
double
_Py_parse_inf_or_nan(const char *p, char **endptr)
{
@@ -57,6 +94,8 @@ _Py_parse_inf_or_nan(const char *p, char **endptr)
return retval;
}
+#endif
+
/**
* _PyOS_ascii_strtod:
* @nptr: the string to convert to a numeric value.
@@ -954,7 +993,7 @@ format_float_short(double d, char format_code,
/* shouldn't get here: Gay's code should always return
something starting with a digit, an 'I', or 'N' */
strncpy(p, "ERR", 3);
- p += 3;
+ /* p += 3; */
assert(0);
}
goto exit;