diff --git a/include/prism/defines.h b/include/prism/defines.h index 80db39bc77..f7bb2120c4 100644 --- a/include/prism/defines.h +++ b/include/prism/defines.h @@ -138,10 +138,14 @@ /** * isinf on POSIX systems it accepts a float, a double, or a long double. - * But Windows didn't provide isinf, so we need to use _finite instead. + * But mingw didn't provide an isinf macro, only an isinf function that only + * accepts floats, so we need to use _finite instead. */ -#ifdef _WIN32 -# include +#ifdef __MINGW64__ + #include + #define PRISM_ISINF(x) (!_finite(x)) +#else + #define PRISM_ISINF(x) isinf(x) #endif /** diff --git a/src/prism.c b/src/prism.c index 45ac021840..b0180dbeca 100644 --- a/src/prism.c +++ b/src/prism.c @@ -4142,14 +4142,7 @@ 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 && -#ifdef _WIN32 - !_finite(value) -#else - isinf(value) -#endif - ) { + if (errno == ERANGE && PRISM_ISINF(value)) { int warn_width; const char *ellipsis; diff --git a/src/static_literals.c b/src/static_literals.c index a2935db86e..9fa37b999a 100644 --- a/src/static_literals.c +++ b/src/static_literals.c @@ -501,13 +501,7 @@ 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 ( -#ifdef _WIN32 - !_finite(value) -#else - isinf(value) -#endif - ) { + if (PRISM_ISINF(value)) { if (*node->location.start == '-') { pm_buffer_append_byte(buffer, '-'); }