summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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, '-');
}