Skip to content

Commit c8dd047

Browse files
kddnewtonmatzbot
authored andcommitted
[ruby/prism] _finitef is unavailable on Windows x86
Instead cast it inline to a double on Windows. ruby/prism@9064d872aa
1 parent 05346b1 commit c8dd047

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

prism/defines.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,17 +136,6 @@
136136
# define PRISM_HAS_FILESYSTEM
137137
#endif
138138

139-
/**
140-
* isinf on Windows is defined as accepting a float, but on POSIX systems it
141-
* accepts a float, a double, or a long double. We want to mirror this behavior
142-
* on windows.
143-
*/
144-
#ifdef _WIN32
145-
# include <float.h>
146-
# undef isinf
147-
# define isinf(x) (sizeof(x) == sizeof(float) ? !_finitef(x) : !_finite(x))
148-
#endif
149-
150139
/**
151140
* If you build prism with a custom allocator, configure it with
152141
* "-D PRISM_XALLOCATOR" to use your own allocator that defines xmalloc,

prism/prism.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4142,7 +4142,14 @@ pm_double_parse(pm_parser_t *parser, const pm_token_t *token) {
41424142

41434143
// If errno is set, then it should only be ERANGE. At this point we need to
41444144
// check if it's infinity (it should be).
4145-
if (errno == ERANGE && isinf(value)) {
4145+
if (
4146+
errno == ERANGE &&
4147+
#ifdef _WIN32
4148+
!_finite(value)
4149+
#else
4150+
isinf(value)
4151+
#endif
4152+
) {
41464153
int warn_width;
41474154
const char *ellipsis;
41484155

prism/static_literals.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,13 @@ pm_static_literal_inspect_node(pm_buffer_t *buffer, const pm_static_literals_met
501501
case PM_FLOAT_NODE: {
502502
const double value = ((const pm_float_node_t *) node)->value;
503503

504-
if (isinf(value)) {
504+
if (
505+
#ifdef _WIN32
506+
!_finite(value)
507+
#else
508+
isinf(value)
509+
#endif
510+
) {
505511
if (*node->location.start == '-') {
506512
pm_buffer_append_byte(buffer, '-');
507513
}

0 commit comments

Comments
 (0)