summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <[email protected]>2024-12-11 19:55:13 -0500
committergit <[email protected]>2024-12-12 01:10:13 +0000
commit29caae9991f08fb386c414f4c6270c68cdf69c30 (patch)
treef0e4a860206c7015bb9d95b06fe0e649acf1f78c
parent36f49eb2b48d855fd168bf5371c9932e35c8029b (diff)
[ruby/prism] Use isinf on non-mingw windowsv3_4_0_rc1
https://github.com/ruby/prism/commit/2f903d7865
-rw-r--r--prism/defines.h10
-rw-r--r--prism/prism.c9
-rw-r--r--prism/static_literals.c8
3 files changed, 9 insertions, 18 deletions
diff --git a/prism/defines.h b/prism/defines.h
index 80db39bc77..f7bb2120c4 100644
--- a/prism/defines.h
+++ b/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 <float.h>
+#ifdef __MINGW64__
+ #include <float.h>
+ #define PRISM_ISINF(x) (!_finite(x))
+#else
+ #define PRISM_ISINF(x) isinf(x)
#endif
/**
diff --git a/prism/prism.c b/prism/prism.c
index bfc420ec00..b85e31621f 100644
--- a/prism/prism.c
+++ b/prism/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/prism/static_literals.c b/prism/static_literals.c
index a2935db86e..9fa37b999a 100644
--- a/prism/static_literals.c
+++ b/prism/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, '-');
}