summaryrefslogtreecommitdiff
path: root/src/port/strtof.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/port/strtof.c')
-rw-r--r--src/port/strtof.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/port/strtof.c b/src/port/strtof.c
index 2a5553bc5fe..acd833267a0 100644
--- a/src/port/strtof.c
+++ b/src/port/strtof.c
@@ -76,15 +76,18 @@ pg_strtof(const char *nptr, char **endptr)
{
int caller_errno = errno;
float fresult;
+ char *myendptr;
errno = 0;
- fresult = (strtof) (nptr, endptr);
+ fresult = (strtof) (nptr, &myendptr);
+ if (endptr)
+ *endptr = myendptr;
if (errno)
{
/* On error, just return the error to the caller. */
return fresult;
}
- else if ((*endptr == nptr) || isnan(fresult) ||
+ else if ((myendptr == nptr) || isnan(fresult) ||
((fresult >= FLT_MIN || fresult <= -FLT_MIN) && !isinf(fresult)))
{
/*
@@ -98,7 +101,8 @@ pg_strtof(const char *nptr, char **endptr)
else
{
/*
- * Try again. errno is already 0 here.
+ * Try again. errno is already 0 here, and we assume that the endptr
+ * won't be any different.
*/
double dresult = strtod(nptr, NULL);