Commit 4376f6bc authored by pugixml Upstream's avatar pugixml Upstream Committed by Atkins, Charles Vernon
Browse files

pugixml 2019-01-01 (9fcae40b)

Code extracted from:

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

at commit 9fcae40bb5577381a37c493a34633f7948fab208 (master).

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

Alexander Straub (1):
      4c791586 Suffixes for different build types (#191)

Arseny Kapoulkine (38):
      951f1ed4 Add a comment to clarify subtle branch in node_copy_tree
      cb0e8937 docs: Update v1.9 release date to 04.04
      4f9af798 Work around gcc-8 warning
      cff1933e docs: Update changelog
      a3258528 tests: Fix PUGIXML_NO_STL build
      0c74e117 Update version to 1.9
      be260a09 docs: Regenerate HTML documentation
      62728d9c tests: Fix PUGIXML_NO_EXCEPTIONS tests
      5f4afe3b tests: Fix PUGIXML_NO_XPATH build
      474a4a3f tests: Fix PUGIXML_NO_XPATH,PUGIXML_COMPACT build
      8436f2a6 tests: Fix PUGIXML_COMPACT build on some platforms
      341cea5a docs: Fix changelog formatting
      55277326 Add brief license information back to README.md
      e6dde9cf scripts: Use LICENSE file in pugixml.podspec
      24a7064e Update README.md
      43b0a6a0 Clarify comment in get_strconv_attribute
      c53fdab9 Clarify comment in get_strconv_pcdata as well
      51322cff Move CMake build postfix setup behind an off-by-default USE_POSTFIX
      e584ea33 docs: Mention that node is a container of children in ranged for section
      699143c5 scripts: Set file permissions when building .zip archive
      f3139f4c Add .gitattributes file
      514478d1 Fix version comment; 190 = 1.9.0 (major.minor.patch)
      6b9c07e6 tests: Allow document_load_file_special_folder to load empty document
      cb4a74d5 Minor CMakeLists.txt cleanup
      1a96777b tests: Fix XPath denorm tests on Intel compiler
      e3b5e9ce XPath: Refactor xpath_node_set short buffer optimization
      81c82588 Work around clang --analyze warnings
      d9fadc74 XPath: Workaround Coverity false positive
      fa686f00 Update all URLs to pugixml.org to https://
      aac75cd2 Escape TAB character in attribute values with 	
      f9a2a7d1 Fix Wdouble-promotion warnings
      1a9c3f66 Enable config=sanitize in Travis CI
      7664bbf9 tests: Only use load_file_special_folder test on macOS
      4b57d098 Add support for MinGW builds on AppVeyor
      7d0d8ee7 Update .travis.yml
      2da15249 Add PUGIXML_WCHAR_MODE configuration to MinGW tests
      ba84465d Move unreachable line handling to Makefile
      9fcae40b Happy New Year!

Bernd Amend (1):
      12139f58 fix cmake warning "Policy CMP0048 is not set" (#214)

Bruno Pagani (1):
      61f2180d Split LICENSE to a separate file for easier distribution

Dan Lipsa (1):
      273fa0ab Remove warning in Visual Studio (#235)

Eli Schwartz (1):
      daeb8013 cmake: always install the pkg-config file (#193)

Millian Poquet (1):
      b3db08ff pkg-config: Use CMake GnuInstallDirs FULL vars

Vyacheslav Egorov (1):
      c51214f2 Visual Studio Natvis visualization (#227)

Wolfgang Stöggl (2):
      c12889f7 Use CMAKE_INSTALL_LIBDIR for pugixml.pc (#215)
      d3dd79d5 Update URL to https in pugixml.pc.in

cecilios (1):
      7d2436ec Add coverity annotations
parent 2a81a516
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
/**
 * pugixml parser - version 1.8
 * pugixml parser - version 1.9
 * --------------------------------------------------------
 * Copyright (C) 2006-2018, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
 * Report bugs and download new versions at http://pugixml.org/
 * Copyright (C) 2006-2019, 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
 * of this file.
@@ -49,7 +49,7 @@
#endif

/**
 * Copyright (c) 2006-2018 Arseny Kapoulkine
 * Copyright (c) 2006-2019 Arseny Kapoulkine
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
+52 −56
Original line number Diff line number Diff line
/**
 * pugixml parser - version 1.8
 * pugixml parser - version 1.9
 * --------------------------------------------------------
 * Copyright (C) 2006-2018, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
 * Report bugs and download new versions at http://pugixml.org/
 * Copyright (C) 2006-2019, 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
 * of this file.
@@ -106,8 +106,8 @@
#	define PUGI__DMC_VOLATILE
#endif

// Integer sanitizer workaround
#ifdef __has_attribute
// Integer sanitizer workaround; we only apply this for clang since gcc8 has no_sanitize but not unsigned-integer-overflow and produces "attribute directive ignored" warnings
#if defined(__clang__) && defined(__has_attribute)
#	if __has_attribute(no_sanitize)
#		define PUGI__UNSIGNED_OVERFLOW __attribute__((no_sanitize("unsigned-integer-overflow")))
#	else
@@ -1861,7 +1861,7 @@ PUGI__NS_BEGIN
	enum chartypex_t
	{
		ctx_special_pcdata = 1,   // Any symbol >= 0 and < 32 (except \t, \r, \n), &, <, >
		ctx_special_attr = 2,     // Any symbol >= 0 and < 32 (except \t), &, <, >, "
		ctx_special_attr = 2,     // Any symbol >= 0 and < 32, &, <, >, "
		ctx_start_symbol = 4,	  // Any symbol > 127, a-z, A-Z, _
		ctx_digit = 8,			  // 0-9
		ctx_symbol = 16			  // Any symbol > 127, a-z, A-Z, 0-9, _, -, .
@@ -1869,7 +1869,7 @@ PUGI__NS_BEGIN

	static const unsigned char chartypex_table[256] =
	{
		3,  3,  3,  3,  3,  3,  3,  3,     3,  0,  2,  3,  3,  2,  3,  3,     // 0-15
		3,  3,  3,  3,  3,  3,  3,  3,     3,  2,  2,  3,  3,  2,  3,  3,     // 0-15
		3,  3,  3,  3,  3,  3,  3,  3,     3,  3,  3,  3,  3,  3,  3,  3,     // 16-31
		0,  0,  2,  0,  0,  0,  3,  0,     0,  0,  0,  0,  0, 16, 16,  0,     // 32-47
		24, 24, 24, 24, 24, 24, 24, 24,    24, 24, 0,  0,  3,  0,  3,  0,     // 48-63
@@ -2709,7 +2709,7 @@ PUGI__NS_BEGIN
	{
		PUGI__STATIC_ASSERT(parse_escapes == 0x10 && parse_eol == 0x20 && parse_trim_pcdata == 0x0800);

		switch (((optmask >> 4) & 3) | ((optmask >> 9) & 4)) // get bitmask for flags (eol escapes trim)
		switch (((optmask >> 4) & 3) | ((optmask >> 9) & 4)) // get bitmask for flags (trim eol escapes); this simultaneously checks 3 options from assertion above
		{
		case 0: return strconv_pcdata_impl<opt_false, opt_false, opt_false>::parse;
		case 1: return strconv_pcdata_impl<opt_false, opt_false, opt_true>::parse;
@@ -2878,7 +2878,7 @@ PUGI__NS_BEGIN
	{
		PUGI__STATIC_ASSERT(parse_escapes == 0x10 && parse_eol == 0x20 && parse_wconv_attribute == 0x40 && parse_wnorm_attribute == 0x80);

		switch ((optmask >> 4) & 15) // get bitmask for flags (wconv wnorm eol escapes)
		switch ((optmask >> 4) & 15) // get bitmask for flags (wnorm wconv eol escapes); this simultaneously checks 4 options from assertion above
		{
		case 0:  return strconv_attribute_impl<opt_false>::parse_simple;
		case 1:  return strconv_attribute_impl<opt_true>::parse_simple;
@@ -4423,6 +4423,7 @@ PUGI__NS_BEGIN

		while (sit && sit != sn)
		{
			// when a tree is copied into one of the descendants, we need to skip that subtree to avoid an infinite loop
			if (sit != dn)
			{
				xml_node_struct* copy = append_new_node(dit, alloc, PUGI__NODETYPE(sit));
@@ -4655,7 +4656,7 @@ PUGI__NS_BEGIN
	PUGI__FN bool set_value_convert(String& dest, Header& header, uintptr_t header_mask, float value)
	{
		char buf[128];
		PUGI__SNPRINTF(buf, "%.9g", value);
		PUGI__SNPRINTF(buf, "%.9g", double(value));

		return set_value_ascii(dest, header, header_mask, buf);
	}
@@ -4687,6 +4688,7 @@ PUGI__NS_BEGIN
		char_t* buffer = 0;
		size_t length = 0;

		// coverity[var_deref_model]
		if (!impl::convert_buffer(buffer, length, buffer_encoding, contents, size, is_mutable)) return impl::make_parse_result(status_out_of_memory);

		// delete original buffer if we performed a conversion
@@ -8068,7 +8070,7 @@ PUGI__NS_BEGIN
		typedef uint32_t UI; // BCC5 workaround
		union { float f; UI i; } u;
		u.i = 0x7fc00000;
		return u.f;
		return double(u.f);
	#else
		// fallback
		const volatile double zero = 0.0;
@@ -10082,6 +10084,7 @@ PUGI__NS_BEGIN
			bool once =
				(axis == axis_attribute && _test == nodetest_name) ||
				(!_right && eval_once(axis_type, eval)) ||
			    // coverity[mixed_enums]
				(_right && !_right->_next && _right->_test == predicate_constant_one);

			xpath_node_set_raw ns;
@@ -10862,6 +10865,7 @@ PUGI__NS_BEGIN
			if (_next)
				_next->optimize(alloc);

			// coverity[var_deref_model]
			optimize_self(alloc);
		}

@@ -10870,13 +10874,14 @@ PUGI__NS_BEGIN
			// Rewrite [position()=expr] with [expr]
			// Note that this step has to go before classification to recognize [position()=1]
			if ((_type == ast_filter || _type == ast_predicate) &&
				_right && // workaround for clang static analyzer (_right is never null for ast_filter/ast_predicate)
				_right->_type == ast_op_equal && _right->_left->_type == ast_func_position && _right->_right->_rettype == xpath_type_number)
			{
				_right = _right->_right;
			}

			// Classify filter/predicate ops to perform various optimizations during evaluation
			if (_type == ast_filter || _type == ast_predicate)
			if ((_type == ast_filter || _type == ast_predicate) && _right) // workaround for clang static analyzer (_right is never null for ast_filter/ast_predicate)
			{
				assert(_test == predicate_default);

@@ -10892,8 +10897,8 @@ PUGI__NS_BEGIN
			// The former is a full form of //foo, the latter is much faster since it executes the node test immediately
			// Do a similar kind of rewrite for self/descendant/descendant-or-self axes
			// Note that we only rewrite positionally invariant steps (//foo[1] != /descendant::foo[1])
			if (_type == ast_step && (_axis == axis_child || _axis == axis_self || _axis == axis_descendant || _axis == axis_descendant_or_self) && _left &&
				_left->_type == ast_step && _left->_axis == axis_descendant_or_self && _left->_test == nodetest_type_node && !_left->_right &&
			if (_type == ast_step && (_axis == axis_child || _axis == axis_self || _axis == axis_descendant || _axis == axis_descendant_or_self) &&
				_left && _left->_type == ast_step && _left->_axis == axis_descendant_or_self && _left->_test == nodetest_type_node && !_left->_right &&
				is_posinv_step())
			{
				if (_axis == axis_child || _axis == axis_descendant)
@@ -10905,7 +10910,9 @@ PUGI__NS_BEGIN
			}

			// Use optimized lookup table implementation for translate() with constant arguments
			if (_type == ast_func_translate && _right->_type == ast_string_constant && _right->_next->_type == ast_string_constant)
			if (_type == ast_func_translate &&
				_right && // workaround for clang static analyzer (_right is never null for ast_func_translate)
				_right->_type == ast_string_constant && _right->_next->_type == ast_string_constant)
			{
				unsigned char* table = translate_table_generate(alloc, _right->_data.string, _right->_next->_data.string);

@@ -10918,6 +10925,8 @@ PUGI__NS_BEGIN

			// Use optimized path for @attr = 'value' or @attr = $value
			if (_type == ast_op_equal &&
				_left && _right && // workaround for clang static analyzer and Coverity (_left and _right are never null for ast_op_equal)
                // coverity[mixed_enums]
				_left->_type == ast_step && _left->_axis == axis_attribute && _left->_test == nodetest_name && !_left->_left && !_left->_right &&
				(_right->_type == ast_string_constant || (_right->_type == ast_variable && _right->_rettype == xpath_type_string)))
			{
@@ -12012,22 +12021,8 @@ namespace pugi

		size_t size_ = static_cast<size_t>(end_ - begin_);

		if (size_ <= 1)
		{
			// deallocate old buffer
			if (_begin != &_storage) impl::xml_memory::deallocate(_begin);

			// use internal buffer
			if (begin_ != end_) _storage = *begin_;

			_begin = &_storage;
			_end = &_storage + size_;
			_type = type_;
		}
		else
		{
			// make heap copy
			xpath_node* storage = static_cast<xpath_node*>(impl::xml_memory::allocate(size_ * sizeof(xpath_node)));
		// use internal buffer for 0 or 1 elements, heap buffer otherwise
		xpath_node* storage = (size_ <= 1) ? _storage : static_cast<xpath_node*>(impl::xml_memory::allocate(size_ * sizeof(xpath_node)));

		if (!storage)
		{
@@ -12038,48 +12033,49 @@ namespace pugi
		#endif
		}

			memcpy(storage, begin_, size_ * sizeof(xpath_node));

		// deallocate old buffer
			if (_begin != &_storage) impl::xml_memory::deallocate(_begin);
		if (_begin != _storage)
			impl::xml_memory::deallocate(_begin);

		// size check is necessary because for begin_ = end_ = nullptr, memcpy is UB
		if (size_)
			memcpy(storage, begin_, size_ * sizeof(xpath_node));

			// finalize
		_begin = storage;
		_end = storage + size_;
		_type = type_;
	}
	}

#ifdef PUGIXML_HAS_MOVE
	PUGI__FN void xpath_node_set::_move(xpath_node_set& rhs) PUGIXML_NOEXCEPT
	{
		_type = rhs._type;
		_storage = rhs._storage;
		_begin = (rhs._begin == &rhs._storage) ? &_storage : rhs._begin;
		_storage[0] = rhs._storage[0];
		_begin = (rhs._begin == rhs._storage) ? _storage : rhs._begin;
		_end = _begin + (rhs._end - rhs._begin);

		rhs._type = type_unsorted;
		rhs._begin = &rhs._storage;
		rhs._end = rhs._begin;
		rhs._begin = rhs._storage;
		rhs._end = rhs._storage;
	}
#endif

	PUGI__FN xpath_node_set::xpath_node_set(): _type(type_unsorted), _begin(&_storage), _end(&_storage)
	PUGI__FN xpath_node_set::xpath_node_set(): _type(type_unsorted), _begin(_storage), _end(_storage)
	{
	}

	PUGI__FN xpath_node_set::xpath_node_set(const_iterator begin_, const_iterator end_, type_t type_): _type(type_unsorted), _begin(&_storage), _end(&_storage)
	PUGI__FN xpath_node_set::xpath_node_set(const_iterator begin_, const_iterator end_, type_t type_): _type(type_unsorted), _begin(_storage), _end(_storage)
	{
		_assign(begin_, end_, type_);
	}

	PUGI__FN xpath_node_set::~xpath_node_set()
	{
		if (_begin != &_storage)
		if (_begin != _storage)
			impl::xml_memory::deallocate(_begin);
	}

	PUGI__FN xpath_node_set::xpath_node_set(const xpath_node_set& ns): _type(type_unsorted), _begin(&_storage), _end(&_storage)
	PUGI__FN xpath_node_set::xpath_node_set(const xpath_node_set& ns): _type(type_unsorted), _begin(_storage), _end(_storage)
	{
		_assign(ns._begin, ns._end, ns._type);
	}
@@ -12094,7 +12090,7 @@ namespace pugi
	}

#ifdef PUGIXML_HAS_MOVE
	PUGI__FN xpath_node_set::xpath_node_set(xpath_node_set&& rhs) PUGIXML_NOEXCEPT: _type(type_unsorted), _begin(&_storage), _end(&_storage)
	PUGI__FN xpath_node_set::xpath_node_set(xpath_node_set&& rhs) PUGIXML_NOEXCEPT: _type(type_unsorted), _begin(_storage), _end(_storage)
	{
		_move(rhs);
	}
@@ -12103,7 +12099,7 @@ namespace pugi
	{
		if (this == &rhs) return *this;

		if (_begin != &_storage)
		if (_begin != _storage)
			impl::xml_memory::deallocate(_begin);

		_move(rhs);
@@ -12770,7 +12766,7 @@ namespace pugi
#endif

/**
 * Copyright (c) 2006-2018 Arseny Kapoulkine
 * Copyright (c) 2006-2019 Arseny Kapoulkine
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
+16 −7
Original line number Diff line number Diff line
/**
 * pugixml parser - version 1.8
 * pugixml parser - version 1.9
 * --------------------------------------------------------
 * Copyright (C) 2006-2018, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com)
 * Report bugs and download new versions at http://pugixml.org/
 * Copyright (C) 2006-2019, 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
 * of this file.
@@ -12,8 +12,8 @@
 */

#ifndef PUGIXML_VERSION
// Define version macro; evaluates to major * 100 + minor so that it's safe to use in less-than comparisons
#	define PUGIXML_VERSION 180
// Define version macro; evaluates to major * 100 + minor * 10 + patch so that it's safe to use in less-than comparisons
#	define PUGIXML_VERSION 190
#endif

// Include user configuration file (this can define various configuration macros)
@@ -1251,6 +1251,12 @@ namespace pugi
	};

	#ifndef PUGIXML_NO_EXCEPTIONS
        #if defined(_MSC_VER)
          // C4275 can be ignored in Visual C++ if you are deriving
          // from a type in the Standard C++ Library
          #pragma warning(push)
          #pragma warning(disable: 4275)
        #endif
	// XPath exception class
	class PUGIXML_CLASS xpath_exception: public std::exception
	{
@@ -1267,6 +1273,9 @@ namespace pugi
		// Get parse result
		const xpath_parse_result& result() const;
	};
        #if defined(_MSC_VER)
          #pragma warning(pop)
        #endif
	#endif

	// XPath node class (either xml_node or xml_attribute)
@@ -1372,7 +1381,7 @@ namespace pugi
	private:
		type_t _type;

		xpath_node _storage;
		xpath_node _storage[1];

		xpath_node* _begin;
		xpath_node* _end;
@@ -1436,7 +1445,7 @@ namespace std
#endif

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