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') 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 ++++++++++++++++- src/pugixml.hpp | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'src') 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(); diff --git a/src/pugixml.hpp b/src/pugixml.hpp index 917ef4a..8a332e1 100644 --- a/src/pugixml.hpp +++ b/src/pugixml.hpp @@ -693,6 +693,7 @@ namespace pugi // Set text with type conversion (numbers are converted to strings, boolean is converted to "true"/"false") bool set(int rhs); bool set(unsigned int rhs); + bool set(float rhs); bool set(double rhs); bool set(bool rhs); -- cgit v1.2.3 From f3e42969a5118247de548c059e9bed69cdf208bb Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Fri, 9 Jan 2015 19:29:23 -0800 Subject: Simplify header-only mode usage It's sufficient to define PUGIXML_HEADER_ONLY anywhere now, source is included automatically. This is a second attempt; this time it includes a workaround for QMake bug that caused it to generate incorrect Makefile. --- src/pugiconfig.hpp | 1 - src/pugixml.hpp | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pugiconfig.hpp b/src/pugiconfig.hpp index 1c216e3..6219dbe 100644 --- a/src/pugiconfig.hpp +++ b/src/pugiconfig.hpp @@ -39,7 +39,6 @@ // Uncomment this to switch to header-only version // #define PUGIXML_HEADER_ONLY -// #include "pugixml.cpp" // Uncomment this to enable long long support // #define PUGIXML_HAS_LONG_LONG diff --git a/src/pugixml.hpp b/src/pugixml.hpp index 917ef4a..2432a3f 100644 --- a/src/pugixml.hpp +++ b/src/pugixml.hpp @@ -1329,6 +1329,13 @@ namespace std #endif +// Make sure implementation is included in header-only mode +// Use macro expansion in #include to work around QMake (QTBUG-11923) +#if defined(PUGIXML_HEADER_ONLY) && !defined(PUGIXML_SOURCE) +# define PUGIXML_SOURCE "pugixml.cpp" +# include PUGIXML_SOURCE +#endif + /** * Copyright (c) 2006-2014 Arseny Kapoulkine * -- 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 +++++++ src/pugixml.hpp | 1 + 2 files changed, 8 insertions(+) (limited to 'src') 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; diff --git a/src/pugixml.hpp b/src/pugixml.hpp index 8a332e1..2076426 100644 --- a/src/pugixml.hpp +++ b/src/pugixml.hpp @@ -352,6 +352,7 @@ namespace pugi bool set_value(int rhs); bool set_value(unsigned int rhs); bool set_value(double rhs); + bool set_value(float rhs); bool set_value(bool rhs); #ifdef PUGIXML_HAS_LONG_LONG -- 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 ++++++++++++ src/pugixml.hpp | 2 ++ 2 files changed, 14 insertions(+) (limited to 'src') 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); diff --git a/src/pugixml.hpp b/src/pugixml.hpp index 2076426..163059d 100644 --- a/src/pugixml.hpp +++ b/src/pugixml.hpp @@ -365,6 +365,7 @@ namespace pugi xml_attribute& operator=(int rhs); xml_attribute& operator=(unsigned int rhs); xml_attribute& operator=(double rhs); + xml_attribute& operator=(float rhs); xml_attribute& operator=(bool rhs); #ifdef PUGIXML_HAS_LONG_LONG @@ -708,6 +709,7 @@ namespace pugi xml_text& operator=(int rhs); xml_text& operator=(unsigned int rhs); xml_text& operator=(double rhs); + xml_text& operator=(float rhs); xml_text& operator=(bool rhs); #ifdef PUGIXML_HAS_LONG_LONG -- 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 ++-- src/pugixml.hpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') 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); diff --git a/src/pugixml.hpp b/src/pugixml.hpp index 240b5aa..91e1f2e 100644 --- a/src/pugixml.hpp +++ b/src/pugixml.hpp @@ -352,7 +352,7 @@ namespace pugi bool set_value(int rhs); bool set_value(unsigned int rhs); bool set_value(double rhs); - bool set_value(float rhs); + bool set_value(float rhs); bool set_value(bool rhs); #ifdef PUGIXML_HAS_LONG_LONG @@ -433,7 +433,7 @@ namespace pugi const char_t* name() const; // Get node value, or "" if node is empty or it has no value - // Note: For text node.value() does not return "text"! Use child_value() or text() methods to access text inside nodes. + // Note: For text node.value() does not return "text"! Use child_value() or text() methods to access text inside nodes. const char_t* value() const; // Get attribute list @@ -695,7 +695,7 @@ namespace pugi // Set text with type conversion (numbers are converted to strings, boolean is converted to "true"/"false") bool set(int rhs); bool set(unsigned int rhs); - bool set(float rhs); + bool set(float rhs); bool set(double rhs); bool set(bool rhs); -- cgit v1.2.3 From 8e95f0d88947631162f5ed1fc5427b414425604b Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Fri, 16 Jan 2015 21:43:57 -0800 Subject: docs: Add missing float setters to reference Also fix the float/double member order in the header file. --- src/pugixml.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/pugixml.hpp b/src/pugixml.hpp index 91e1f2e..9798b46 100644 --- a/src/pugixml.hpp +++ b/src/pugixml.hpp @@ -695,8 +695,8 @@ namespace pugi // Set text with type conversion (numbers are converted to strings, boolean is converted to "true"/"false") bool set(int rhs); bool set(unsigned int rhs); - bool set(float rhs); bool set(double rhs); + bool set(float rhs); bool set(bool rhs); #ifdef PUGIXML_HAS_LONG_LONG -- cgit v1.2.3