1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-03 15:22:11 +03:00

Simplify replacement code for strtof.

strtof() is in C99 and all targeted systems have it.  We can remove the
configure probe and some dead code, but we still need replacement code
for a couple of systems that have known buggy implementations selected
via platform template.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/152683.1659830125%40sss.pgh.pa.us
This commit is contained in:
Thomas Munro
2022-08-07 12:42:11 +12:00
parent 24c3ce8f1c
commit cbf4403134
6 changed files with 2 additions and 64 deletions

View File

@@ -16,43 +16,7 @@
#include <float.h>
#include <math.h>
#ifndef HAVE_STRTOF
/*
* strtof() is part of C99; this version is only for the benefit of obsolete
* platforms. As such, it is known to return incorrect values for edge cases,
* which have to be allowed for in variant files for regression test results
* for any such platform.
*/
float
strtof(const char *nptr, char **endptr)
{
int caller_errno = errno;
double dresult;
float fresult;
errno = 0;
dresult = strtod(nptr, endptr);
fresult = (float) dresult;
if (errno == 0)
{
/*
* Value might be in-range for double but not float.
*/
if (dresult != 0 && fresult == 0)
caller_errno = ERANGE; /* underflow */
if (!isinf(dresult) && isinf(fresult))
caller_errno = ERANGE; /* overflow */
}
else
caller_errno = errno;
errno = caller_errno;
return fresult;
}
#elif HAVE_BUGGY_STRTOF
/*
* Cygwin has a strtof() which is literally just (float)strtod(), which means
* we can't avoid the double-rounding problem; but using this wrapper does get
@@ -119,5 +83,3 @@ pg_strtof(const char *nptr, char **endptr)
}
}
}
#endif