Commit 3b9297a7 authored by Atkins, Charles Vernon's avatar Atkins, Charles Vernon
Browse files

Merge branch 'upstream-pugixml' into update-third-party

# By pugixml Upstream
* upstream-pugixml:
  pugixml 2022-02-15 (363ebdde)
parents 4d2da587 5c1b76da
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