Skip to content

Commit

Permalink
Fix pugixml float parsing local dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
gvollant committed Mar 2, 2022
1 parent df76dfe commit c18935d
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion OpenXLSX/external/pugixml/pugixml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
#include <assert.h>
#include <limits.h>

#if (!defined(PUGIXML_HAS_CXX17)) && ((__cplusplus >= 201703L) || \
(defined(_MSC_VER) && _MSC_VER >= 1911 && _MSVC_LANG >= 201703L))
# define PUGIXML_HAS_CXX17
#endif

#if defined(PUGIXML_HAS_CXX17)
# include <charconv>
#endif

#ifdef PUGIXML_WCHAR_MODE
# include <wchar.h>
#endif
Expand Down Expand Up @@ -4591,7 +4600,13 @@ class xml_buffered_writer
#ifdef PUGIXML_WCHAR_MODE
return wcstod(value, 0);
#else
#if defined(PUGIXML_HAS_CXX17)
double result_double = 0.0;
std::from_chars(value, (value + strlen(value)), result_double);
return result_double;
#else
return strtod(value, 0);
#endif
#endif
}

Expand All @@ -4600,7 +4615,13 @@ class xml_buffered_writer
#ifdef PUGIXML_WCHAR_MODE
return static_cast<float>(wcstod(value, 0));
#else
#if defined(PUGIXML_HAS_CXX17)
double result_double = 0.0;
std::from_chars(value, value + strlen(value), result_double);
return static_cast<float>(result_double);
#else
return static_cast<float>(strtod(value, 0));
#endif
#endif
}

Expand Down Expand Up @@ -8415,7 +8436,13 @@ PUGI__FN double convert_string_to_number(const char_t* string)
#ifdef PUGIXML_WCHAR_MODE
return wcstod(string, 0);
#else
return strtod(string, 0);
#if defined(PUGIXML_HAS_CXX17)
double result_double = 0.0;
std::from_chars(string, string + strlen(string), result_double);
return static_cast<float>(result_double);
#else
return strtod(string, 0);
#endif
#endif
}

Expand Down

0 comments on commit c18935d

Please sign in to comment.