Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions include/prism/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down
9 changes: 1 addition & 8 deletions src/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 1 addition & 7 deletions src/static_literals.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, '-');
}
Expand Down
Loading