From 9064d872aa61ed13957759626c82b688976f955d Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Mon, 2 Dec 2024 14:40:55 -0500 Subject: [PATCH] _finitef is unavailable on Windows x86 Instead cast it inline to a double on Windows. --- include/prism/defines.h | 11 ----------- src/prism.c | 9 ++++++++- src/static_literals.c | 8 +++++++- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/include/prism/defines.h b/include/prism/defines.h index e78c7dd75ce..785361728e6 100644 --- a/include/prism/defines.h +++ b/include/prism/defines.h @@ -136,17 +136,6 @@ # define PRISM_HAS_FILESYSTEM #endif -/** - * isinf on Windows is defined as accepting a float, but on POSIX systems it - * accepts a float, a double, or a long double. We want to mirror this behavior - * on windows. - */ -#ifdef _WIN32 -# include -# undef isinf -# define isinf(x) (sizeof(x) == sizeof(float) ? !_finitef(x) : !_finite(x)) -#endif - /** * If you build prism with a custom allocator, configure it with * "-D PRISM_XALLOCATOR" to use your own allocator that defines xmalloc, diff --git a/src/prism.c b/src/prism.c index bc516cbf4c6..358cd049560 100644 --- a/src/prism.c +++ b/src/prism.c @@ -4142,7 +4142,14 @@ pm_double_parse(pm_parser_t *parser, const pm_token_t *token) { // If errno is set, then it should only be ERANGE. At this point we need to // check if it's infinity (it should be). - if (errno == ERANGE && isinf(value)) { + if ( + errno == ERANGE && +#ifdef _WIN32 + !_finite(value) +#else + isinf(value) +#endif + ) { int warn_width; const char *ellipsis; diff --git a/src/static_literals.c b/src/static_literals.c index b8604321c98..a2935db86e0 100644 --- a/src/static_literals.c +++ b/src/static_literals.c @@ -501,7 +501,13 @@ pm_static_literal_inspect_node(pm_buffer_t *buffer, const pm_static_literals_met case PM_FLOAT_NODE: { const double value = ((const pm_float_node_t *) node)->value; - if (isinf(value)) { + if ( +#ifdef _WIN32 + !_finite(value) +#else + isinf(value) +#endif + ) { if (*node->location.start == '-') { pm_buffer_append_byte(buffer, '-'); }