Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2016-12-15 20:23:27 +0300
committerJeff Johnston <jjohnstn@redhat.com>2016-12-15 20:23:27 +0300
commitdd4a4baab02a49993671f1be51be0486e32b2b3c (patch)
tree0aeae915ecaf669a7c171836c94d2b27c9671ae7 /newlib/libc/stdlib/wcstod.c
parent05272960abb77e1c53239683d4adc6077e5549ea (diff)
2016-12-15 Kyrylo Tkachov <kyrylo.tkachov@arm.com>cygwin-2_6_1-release
* libc/stdlib/strtod.c (strtof_l): Set errno to ERANGE when double to float conversion results in infinity. (strtof): Likewise. * libc/stdlib/wcstod.c (wcstof_l): Likewise. (wcstof): Likewise.
Diffstat (limited to 'newlib/libc/stdlib/wcstod.c')
-rw-r--r--newlib/libc/stdlib/wcstod.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/newlib/libc/stdlib/wcstod.c b/newlib/libc/stdlib/wcstod.c
index 43f7b4eec..9b7948e4f 100644
--- a/newlib/libc/stdlib/wcstod.c
+++ b/newlib/libc/stdlib/wcstod.c
@@ -274,9 +274,14 @@ float
wcstof_l (const wchar_t *__restrict nptr, wchar_t **__restrict endptr,
locale_t loc)
{
- double retval = _wcstod_l (_REENT, nptr, endptr, loc);
- if (isnan (retval))
+ double val = _wcstod_l (_REENT, nptr, endptr, loc);
+ if (isnan (val))
return nanf (NULL);
+ float retval = (float) val;
+#ifndef NO_ERRNO
+ if (isinf (retval) && !isinf (val))
+ _REENT->_errno = ERANGE;
+#endif
return (float)retval;
}
@@ -285,9 +290,15 @@ _DEFUN (wcstof, (nptr, endptr),
_CONST wchar_t *__restrict nptr _AND
wchar_t **__restrict endptr)
{
- double retval = _wcstod_l (_REENT, nptr, endptr, __get_current_locale ());
- if (isnan (retval))
+ double val = _wcstod_l (_REENT, nptr, endptr, __get_current_locale ());
+ if (isnan (val))
return nanf (NULL);
+ float retval = (float) val;
+#ifndef NO_ERRNO
+ if (isinf (retval) && !isinf (val))
+ _REENT->_errno = ERANGE;
+#endif
+
return (float)retval;
}