Commit 5c1b76da authored by pugixml Upstream's avatar pugixml Upstream Committed by Atkins, Charles Vernon
Browse files

pugixml 2022-02-15 (363ebdde)

Code extracted from:

    https://github.com/zeux/pugixml.git

at commit 363ebdde91214e456943822ddf422860af8bb54d (master).

Upstream Shortlog
-----------------

Arseny Kapoulkine (32):
      df42668e Cleanup code and feature detection
      5f97d5d6 Fix -Wshadow in remove_children()
      8afc1239 tests: Fix test fallout for MSVC6
      70bd6a6b Update version to 1.11 and update documentation
      fe4bc946 Update copyright year to 2020 everywhere
      a3ae05cc scripts: Remove deprecated iconUrl from NuGet package
      7a9da11d scripts: Convert archive.py to Python 3
      5a0fd5d8 docs: Rebuild HTML documentation
      e2bc4f4a Fix compatibility issue with CMake 3.10
      06868c8f Don't define pugixml import target if it already exists
      56c9afa7 XPath: Improve recursion limit for deep chains of //
      8cece4b9 Fix a bug in move construction when move source is empty
      5c4225b5 tests: Fix wchar_t build
      0b793a31 Add GitHub Actions based build
      8bd9a19a Change badge to GHA badge.
      3097a2c7 Switch to export and GH vars
      e7b545b2 Remove custom job name for unix
      0de58015 Don't run GHA workflow on push to branches
      5cff00e5 Fix coverage build to include CXX define
      a6a63a1b gcov crashes on LLVM-produced coverage on Linux
      37eddaa0 Update .codecov.yml
      8bd209fb docs: Update manual to be more explicit about save_file return
      c624c7a8 Update CMakeLists.txt
      f1fbd707 Set CMP0091 CMake policy
      428606b3 Create SECURITY.md
      9ba92a7f Restore compatibility with WinCE
      c9e219c1 Update version to 1.12
      25c4fb74 Update copyright year to 2022
      eb918f20 docs: Update manual with 1.12 changelog
      314baf66 docs: Regenerate HTML documentation
      dd50fa5b Fix PUGIXML_VERSION macro
      c60ca94c tests: Fix MSVC 2022 build

Ben Boeckel (3):
      5063e874 cmake: provide a compatibility target for users
      d1d415e6 docs: add a note about the new imported target name for CMake
      4feab60b cmake: avoid ALIAS target

Björn Blissing (13):
      91fde92f Add PUGIXML as prefix to CMake options
      0f1e75a9 Re-introduced the custom build defines
      fc7928a4 Use target_compile_definitions for custom defines
      7b1b7ee1 Reverted to use of global BUILD_SHARED_LIBS option
      986b7ffd Add Cmake options for pugiconfig.hpp
      5f49f2c6 Mark advanced options and removed redundant ones
      e2ba4f40 Add options to build targets
      f1946432 Check for existence of long long
      1cd65c7e Move advanced memory settings into target defs.
      50b103f1 Fix generator expressions
      92ac6ac1 Update github action to trigger defines via CMake
      52a7981b Make some compile definitions public
      e7eae035 Store definitions in variable to avoid duplication

Lior Lahav (1):
      c258fba6 Replaced fopen and _wfopen deprecated functions with the safer fopen_s and _wfopen_s

Paul Mulders (1):
      81274bb0 Fix include in test_document.cpp when building against libc++

Rosen Penev (3):
      ef257796 remove const from operator++/--
      c167259e add empty method
      e672b1c9 fix cygwin compilation

tobias (4):
      bc2448af Add support for Visual Studio 2022 with Platform Toolset v143.
      16a4f382 Add missing appveyor test config for Visual Studio 2022.
      bd905797 Add missing build script and test script entries for appveyor.
      64de196b Fix path.
parent 9633b243
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
/**
 * pugixml parser - version 1.10
 * pugixml parser - version 1.12
 * --------------------------------------------------------
 * Copyright (C) 2006-2019, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
 * Copyright (C) 2006-2022, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
 * Report bugs and download new versions at https://pugixml.org/
 *
 * This library is distributed under the MIT License. See notice at the end
@@ -52,7 +52,7 @@
#endif

/**
 * Copyright (c) 2006-2019 Arseny Kapoulkine
 * Copyright (c) 2006-2022 Arseny Kapoulkine
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
+48 −24
Original line number Diff line number Diff line
/**
 * pugixml parser - version 1.10
 * pugixml parser - version 1.12
 * --------------------------------------------------------
 * Copyright (C) 2006-2019, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
 * Copyright (C) 2006-2022, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
 * Report bugs and download new versions at https://pugixml.org/
 *
 * This library is distributed under the MIT License. See notice at the end
@@ -132,8 +132,10 @@ using std::memset;
#endif

// In some environments MSVC is a compiler but the CRT lacks certain MSVC-specific features
#if defined(_MSC_VER) && !defined(__S3E__)
#if defined(_MSC_VER) && !defined(__S3E__) && !defined(_WIN32_WCE)
#	define PUGI__MSVC_CRT_VERSION _MSC_VER
#elif defined(_WIN32_WCE)
#	define PUGI__MSVC_CRT_VERSION 1310 // MSVC7.1
#endif

// Not all platforms have snprintf; we define a wrapper that uses snprintf if possible. This only works with buffers with a known size.
@@ -526,7 +528,8 @@ PUGI__NS_BEGIN
			xml_memory_page* page = xml_memory_page::construct(memory);
			assert(page);

			page->allocator = _root->allocator;
			assert(this == _root->allocator);
			page->allocator = this;

			return page;
		}
@@ -4732,7 +4735,7 @@ PUGI__NS_BEGIN
	// we need to get length of entire file to load it in memory; the only (relatively) sane way to do it is via seek/tell trick
	PUGI__FN xml_parse_status get_file_size(FILE* file, size_t& out_result)
	{
	#if defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400 && !defined(_WIN32_WCE)
	#if defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400
		// there are 64-bit versions of fseek/ftell, let's use them
		typedef __int64 length_type;

@@ -4981,7 +4984,12 @@ PUGI__NS_BEGIN
#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)
	{
#if defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400
		FILE* file = 0;
		return _wfopen_s(&file, path, mode) == 0 ? file : 0;
#else
		return _wfopen(path, mode);
#endif
	}
#else
	PUGI__FN char* convert_path_heap(const wchar_t* str)
@@ -5025,6 +5033,16 @@ PUGI__NS_BEGIN
	}
#endif

	PUGI__FN FILE* open_file(const char* path, const char* mode)
	{
#if defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400
		FILE* file = 0;
		return fopen_s(&file, path, mode) == 0 ? file : 0;
#else
		return fopen(path, mode);
#endif
	}

	PUGI__FN bool save_file_impl(const xml_document& doc, FILE* file, const char_t* indent, unsigned int flags, xml_encoding encoding)
	{
		if (!file) return false;
@@ -6127,13 +6145,13 @@ namespace pugi
		impl::xml_allocator& alloc = impl::get_allocator(_root);
		if (!alloc.reserve()) return false;

		for (xml_node_struct* child = _root->first_child; child; )
		for (xml_node_struct* cur = _root->first_child; cur; )
		{
			xml_node_struct* next = child->next_sibling;
			xml_node_struct* next = cur->next_sibling;

			impl::destroy_node(child, alloc);
			impl::destroy_node(cur, alloc);

			child = next;
			cur = next;
		}

		_root->first_child = 0;
@@ -6720,7 +6738,7 @@ namespace pugi
		return const_cast<xml_node*>(&_wrap); // BCC5 workaround
	}

	PUGI__FN const xml_node_iterator& xml_node_iterator::operator++()
	PUGI__FN xml_node_iterator& xml_node_iterator::operator++()
	{
		assert(_wrap._root);
		_wrap._root = _wrap._root->next_sibling;
@@ -6734,7 +6752,7 @@ namespace pugi
		return temp;
	}

	PUGI__FN const xml_node_iterator& xml_node_iterator::operator--()
	PUGI__FN xml_node_iterator& xml_node_iterator::operator--()
	{
		_wrap = _wrap._root ? _wrap.previous_sibling() : _parent.last_child();
		return *this;
@@ -6781,7 +6799,7 @@ namespace pugi
		return const_cast<xml_attribute*>(&_wrap); // BCC5 workaround
	}

	PUGI__FN const xml_attribute_iterator& xml_attribute_iterator::operator++()
	PUGI__FN xml_attribute_iterator& xml_attribute_iterator::operator++()
	{
		assert(_wrap._attr);
		_wrap._attr = _wrap._attr->next_attribute;
@@ -6795,7 +6813,7 @@ namespace pugi
		return temp;
	}

	PUGI__FN const xml_attribute_iterator& xml_attribute_iterator::operator--()
	PUGI__FN xml_attribute_iterator& xml_attribute_iterator::operator--()
	{
		_wrap = _wrap._attr ? _wrap.previous_attribute() : _parent.last_attribute();
		return *this;
@@ -6842,7 +6860,7 @@ namespace pugi
		return const_cast<xml_node*>(&_wrap); // BCC5 workaround
	}

	PUGI__FN const xml_named_node_iterator& xml_named_node_iterator::operator++()
	PUGI__FN xml_named_node_iterator& xml_named_node_iterator::operator++()
	{
		assert(_wrap._root);
		_wrap = _wrap.next_sibling(_name);
@@ -6856,7 +6874,7 @@ namespace pugi
		return temp;
	}

	PUGI__FN const xml_named_node_iterator& xml_named_node_iterator::operator--()
	PUGI__FN xml_named_node_iterator& xml_named_node_iterator::operator--()
	{
		if (_wrap._root)
			_wrap = _wrap.previous_sibling(_name);
@@ -7076,8 +7094,12 @@ namespace pugi
	#endif

		// move allocation state
		// note that other->_root may point to the embedded document page, in which case we should keep original (empty) state
		if (other->_root != PUGI__GETPAGE(other))
		{
			doc->_root = other->_root;
			doc->_busy_size = other->_busy_size;
		}

		// move buffer state
		doc->buffer = other->buffer;
@@ -7187,7 +7209,7 @@ namespace pugi
		reset();

		using impl::auto_deleter; // MSVC7 workaround
		auto_deleter<FILE> file(fopen(path_, "rb"), impl::close_file);
		auto_deleter<FILE> file(impl::open_file(path_, "rb"), impl::close_file);

		return impl::load_file_impl(static_cast<impl::xml_document_struct*>(_root), file.data, options, encoding, &_buffer);
	}
@@ -7270,7 +7292,7 @@ namespace pugi
	PUGI__FN bool xml_document::save_file(const char* path_, const char_t* indent, unsigned int flags, xml_encoding encoding) const
	{
		using impl::auto_deleter; // MSVC7 workaround
		auto_deleter<FILE> file(fopen(path_, (flags & format_save_file_text) ? "w" : "wb"), impl::close_file);
		auto_deleter<FILE> file(impl::open_file(path_, (flags & format_save_file_text) ? "w" : "wb"), impl::close_file);

		return impl::save_file_impl(*this, file.data, indent, flags, encoding);
	}
@@ -8250,7 +8272,7 @@ PUGI__NS_BEGIN
	}

	// gets mantissa digits in the form of 0.xxxxx with 0. implied and the exponent
#if defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400 && !defined(_WIN32_WCE)
#if defined(PUGI__MSVC_CRT_VERSION) && PUGI__MSVC_CRT_VERSION >= 1400
	PUGI__FN void convert_number_to_mantissa_exponent(double value, char (&buffer)[32], char** out_mantissa, int* out_exponent)
	{
		// get base values
@@ -11807,15 +11829,17 @@ PUGI__NS_BEGIN
				lexeme_t l = _lexer.current();
				_lexer.next();

				if (++_depth > xpath_ast_depth_limit)
					return error_rec();

				if (l == lex_double_slash)
				{
					n = alloc_node(ast_step, n, axis_descendant_or_self, nodetest_type_node, 0);
					if (!n) return 0;

					++_depth;
				}

				if (++_depth > xpath_ast_depth_limit)
					return error_rec();

				n = parse_step(n);
				if (!n) return 0;
			}
@@ -12980,7 +13004,7 @@ namespace pugi
#endif

/**
 * Copyright (c) 2006-2019 Arseny Kapoulkine
 * Copyright (c) 2006-2022 Arseny Kapoulkine
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
+13 −11
Original line number Diff line number Diff line
/**
 * pugixml parser - version 1.10
 * pugixml parser - version 1.12
 * --------------------------------------------------------
 * Copyright (C) 2006-2019, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
 * Copyright (C) 2006-2022, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
 * Report bugs and download new versions at https://pugixml.org/
 *
 * This library is distributed under the MIT License. See notice at the end
@@ -11,10 +11,10 @@
 * Copyright (C) 2003, by Kristen Wegner (kristen@tima.net)
 */

#ifndef PUGIXML_VERSION
// Define version macro; evaluates to major * 1000 + minor * 10 + patch so that it's safe to use in less-than comparisons
// Note: pugixml used major * 100 + minor * 10 + patch format up until 1.9 (which had version identifier 190); starting from pugixml 1.10, the minor version number is two digits
#	define PUGIXML_VERSION 1100
#ifndef PUGIXML_VERSION
#	define PUGIXML_VERSION 1120 // 1.12
#endif

// Include user configuration file (this can define various configuration macros)
@@ -312,6 +312,8 @@ namespace pugi
		It begin() const { return _begin; }
		It end() const { return _end; }

		bool empty() const { return _begin == _end; }

	private:
		It _begin, _end;
	};
@@ -851,10 +853,10 @@ namespace pugi
		xml_node& operator*() const;
		xml_node* operator->() const;

		const xml_node_iterator& operator++();
		xml_node_iterator& operator++();
		xml_node_iterator operator++(int);

		const xml_node_iterator& operator--();
		xml_node_iterator& operator--();
		xml_node_iterator operator--(int);
	};

@@ -893,10 +895,10 @@ namespace pugi
		xml_attribute& operator*() const;
		xml_attribute* operator->() const;

		const xml_attribute_iterator& operator++();
		xml_attribute_iterator& operator++();
		xml_attribute_iterator operator++(int);

		const xml_attribute_iterator& operator--();
		xml_attribute_iterator& operator--();
		xml_attribute_iterator operator--(int);
	};

@@ -929,10 +931,10 @@ namespace pugi
		xml_node& operator*() const;
		xml_node* operator->() const;

		const xml_named_node_iterator& operator++();
		xml_named_node_iterator& operator++();
		xml_named_node_iterator operator++(int);

		const xml_named_node_iterator& operator--();
		xml_named_node_iterator& operator--();
		xml_named_node_iterator operator--(int);

	private:
@@ -1474,7 +1476,7 @@ namespace std
#endif

/**
 * Copyright (c) 2006-2019 Arseny Kapoulkine
 * Copyright (c) 2006-2022 Arseny Kapoulkine
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation