From ff16dbdd4c63fa46cc1f38eda4cfb66f38047657 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Sat, 13 Dec 2014 20:34:10 -0800 Subject: Don't use off64_t/_wfopen on MinGW32 in C++11 mode Unfortunately, standard headers on MinGW32 insist on undefining off64_t and _wfopen extensions if __STRICT_ANSI__ is true (e.g. C++11 mode). This leads to compilation errors since b7a1fec started to use _wfopen in strict mode. That change erroneously checked GCC version - however, the version itself is irrelevant; the actual criteria is whether mingw64 runtime is used. off64_t is not useful on MinGW32 since we only need it to open large files on 64-bit platforms; unfortunately, the lack of _wfopen means we won't be able to support wide-char paths on Windows for MinGW32. Fixes #24. --- src/pugixml.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/pugixml.cpp') diff --git a/src/pugixml.cpp b/src/pugixml.cpp index b8847a4..dd3f427 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -3995,7 +3995,7 @@ PUGI__NS_BEGIN _fseeki64(file, 0, SEEK_END); length_type length = _ftelli64(file); _fseeki64(file, 0, SEEK_SET); - #elif defined(__MINGW32__) && !defined(__NO_MINGW_LFS) && !(defined(__STRICT_ANSI__) && __GNUC__ * 100 + __GNUC_MINOR__ <= 405) + #elif defined(__MINGW32__) && !defined(__NO_MINGW_LFS) && (!defined(__STRICT_ANSI__) || defined(__MINGW64_VERSION_MAJOR)) // there are 64-bit versions of fseek/ftell, let's use them typedef off64_t length_type; @@ -4240,7 +4240,7 @@ PUGI__NS_BEGIN } #endif -#if defined(PUGI__MSVC_CRT_VERSION) || defined(__BORLANDC__) || (defined(__MINGW32__) && !(defined(__STRICT_ANSI__) && __GNUC__ * 100 + __GNUC_MINOR__ <= 405)) +#if defined(PUGI__MSVC_CRT_VERSION) || defined(__BORLANDC__) || (defined(__MINGW32__) && (!defined(__STRICT_ANSI__) || defined(__MINGW64_VERSION_MAJOR))) PUGI__FN FILE* open_file_wide(const wchar_t* path, const wchar_t* mode) { return _wfopen(path, mode); -- cgit v1.2.3 From 32f0a8bd3a5c9f3c454164f4d23289851b0de3e7 Mon Sep 17 00:00:00 2001 From: Steve Doiel Date: Tue, 6 Jan 2015 15:33:56 -0800 Subject: Add xml_text::set for float Make float/double round-trip --- src/pugixml.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/pugixml.cpp') diff --git a/src/pugixml.cpp b/src/pugixml.cpp index dd3f427..6608d8d 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -3954,10 +3954,18 @@ PUGI__NS_BEGIN return set_value_buffer(dest, header, header_mask, buf); } + PUGI__FN bool set_value_convert(char_t*& dest, uintptr_t& header, uintptr_t header_mask, float value) + { + char buf[128]; + sprintf(buf, "%.9g", value); + + return set_value_buffer(dest, header, header_mask, buf); + } + PUGI__FN bool set_value_convert(char_t*& dest, uintptr_t& header, uintptr_t header_mask, double value) { char buf[128]; - sprintf(buf, "%g", value); + sprintf(buf, "%.17g", value); return set_value_buffer(dest, header, header_mask, buf); } @@ -5603,6 +5611,13 @@ namespace pugi return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs) : false; } + PUGI__FN bool xml_text::set(float rhs) + { + xml_node_struct* dn = _data_new(); + + return dn ? impl::set_value_convert(dn->value, dn->header, impl::xml_memory_page_value_allocated_mask, rhs) : false; + } + PUGI__FN bool xml_text::set(double rhs) { xml_node_struct* dn = _data_new(); -- cgit v1.2.3 From 4ae1940065c415223445efb23d3200d1b0b1d4a1 Mon Sep 17 00:00:00 2001 From: Steve Doiel Date: Fri, 16 Jan 2015 14:55:10 -0800 Subject: Fix attribute round trip for float as well --- src/pugixml.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/pugixml.cpp') diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 6608d8d..2ed94f3 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -4608,6 +4608,13 @@ namespace pugi return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs); } + PUGI__FN bool xml_attribute::set_value(float rhs) + { + if (!_attr) return false; + + return impl::set_value_convert(_attr->value, _attr->header, impl::xml_memory_page_value_allocated_mask, rhs); + } + PUGI__FN bool xml_attribute::set_value(bool rhs) { if (!_attr) return false; -- cgit v1.2.3 From 53525a037b45ecf4dc29bf6700ad384647541da2 Mon Sep 17 00:00:00 2001 From: Steve Doiel Date: Fri, 16 Jan 2015 15:20:28 -0800 Subject: Add a couple of more overloads for floats --- src/pugixml.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/pugixml.cpp') diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 2ed94f3..9760e9f 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -4553,6 +4553,12 @@ namespace pugi return *this; } + PUGI__FN xml_attribute& xml_attribute::operator=(float rhs) + { + set_value(rhs); + return *this; + } + PUGI__FN xml_attribute& xml_attribute::operator=(bool rhs) { set_value(rhs); @@ -5679,6 +5685,12 @@ namespace pugi return *this; } + PUGI__FN xml_text& xml_text::operator=(float rhs) + { + set(rhs); + return *this; + } + PUGI__FN xml_text& xml_text::operator=(bool rhs) { set(rhs); -- cgit v1.2.3 From f07018f7e70d39bcfdd71882c2b8b6c510ba1955 Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Fri, 16 Jan 2015 21:00:09 -0800 Subject: Convert spaces to tabs --- src/pugixml.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/pugixml.cpp') diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 9760e9f..265337a 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -8681,7 +8681,7 @@ PUGI__NS_BEGIN bool step_push(xpath_node_set_raw& ns, xml_attribute_struct* a, xml_node_struct* parent, xpath_allocator* alloc) { - assert(a); + assert(a); const char_t* name = a->name ? a->name : PUGIXML_TEXT(""); @@ -8721,7 +8721,7 @@ PUGI__NS_BEGIN bool step_push(xpath_node_set_raw& ns, xml_node_struct* n, xpath_allocator* alloc) { - assert(n); + assert(n); xml_node_type type = PUGI__NODETYPE(n); -- cgit v1.2.3