diff options
author | Thomas Munro | 2022-08-07 00:42:11 +0000 |
---|---|---|
committer | Thomas Munro | 2022-08-07 00:42:41 +0000 |
commit | cbf4403134738245db48b306c62eb1258f2b2bd0 (patch) | |
tree | 8701627bd54d0a1fc23ac0180dc3608d019044f5 /src | |
parent | 24c3ce8f1c707f9eeb1f68cebd44c2516ff799c2 (diff) |
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 <[email protected]>
Discussion: https://postgr.es/m/152683.1659830125%40sss.pgh.pa.us
Diffstat (limited to 'src')
-rw-r--r-- | src/include/pg_config.h.in | 3 | ||||
-rw-r--r-- | src/include/port.h | 4 | ||||
-rw-r--r-- | src/port/strtof.c | 38 | ||||
-rw-r--r-- | src/tools/msvc/Solution.pm | 1 |
4 files changed, 0 insertions, 46 deletions
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in index 2d9a1cdc8ab..c243a906c9b 100644 --- a/src/include/pg_config.h.in +++ b/src/include/pg_config.h.in @@ -460,9 +460,6 @@ /* Define to 1 if you have the `strsignal' function. */ #undef HAVE_STRSIGNAL -/* Define to 1 if you have the `strtof' function. */ -#undef HAVE_STRTOF - /* Define to 1 if the system has the type `struct addrinfo'. */ #undef HAVE_STRUCT_ADDRINFO diff --git a/src/include/port.h b/src/include/port.h index ad76384fb19..cec41eae713 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -387,10 +387,6 @@ extern int getpeereid(int sock, uid_t *uid, gid_t *gid); extern void explicit_bzero(void *buf, size_t len); #endif -#ifndef HAVE_STRTOF -extern float strtof(const char *nptr, char **endptr); -#endif - #ifdef HAVE_BUGGY_STRTOF extern float pg_strtof(const char *nptr, char **endptr); #define strtof(a,b) (pg_strtof((a),(b))) diff --git a/src/port/strtof.c b/src/port/strtof.c index 314fcc9851f..21b3f8f7122 100644 --- a/src/port/strtof.c +++ b/src/port/strtof.c @@ -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 diff --git a/src/tools/msvc/Solution.pm b/src/tools/msvc/Solution.pm index 4916a86f5cf..caacb965bbd 100644 --- a/src/tools/msvc/Solution.pm +++ b/src/tools/msvc/Solution.pm @@ -349,7 +349,6 @@ sub GenerateFiles HAVE_STRLCPY => undef, HAVE_STRNLEN => 1, HAVE_STRSIGNAL => undef, - HAVE_STRTOF => 1, HAVE_STRUCT_ADDRINFO => 1, HAVE_STRUCT_CMSGCRED => undef, HAVE_STRUCT_OPTION => undef, |