yaml-cpp: update to 0.5.3.
This commit is contained in:
parent
a8f8fd3c06
commit
d353f443fe
2 changed files with 9 additions and 117 deletions
|
@ -1,112 +0,0 @@
|
|||
commit b426fafff6238dda8d86fa668f585cba732dd272
|
||||
Author: Jonathan Hamilton <jtrhamilton@gmail.com>
|
||||
Date: Mon Jun 1 13:33:59 2015 -0700
|
||||
|
||||
Fix some Node::operator[] regressions from 0.5.1
|
||||
|
||||
"const Node Node::operator[](const Key& key) const" changed from
|
||||
returning new empty node if the key was missing in 0.5.1 to returning
|
||||
a shared 'zombie' node in 0.5.2 to resolve a memory leak.
|
||||
|
||||
(Specifically 1025f76df1b32b6ec3571ca928d7797a768a3341 was where this
|
||||
was introduced)
|
||||
|
||||
This caused some regressions where this 'zombie' object threw exceptions
|
||||
in some functions where the 'empty' object would not.
|
||||
|
||||
This change fixes the Node::as(fallback) method (to return the
|
||||
'fallback' instead of throwing an exception) and the
|
||||
Node::begin()/Node::end() methods to return default-constructed
|
||||
iterators (so begin() == end() in such cases) instead of another
|
||||
exception.
|
||||
|
||||
--- include/yaml-cpp/node/impl.h.orig
|
||||
+++ include/yaml-cpp/node/impl.h
|
||||
@@ -149,7 +149,7 @@ inline const T Node::as() const {
|
||||
template <typename T, typename S>
|
||||
inline const T Node::as(const S& fallback) const {
|
||||
if (!m_isValid)
|
||||
- throw InvalidNode();
|
||||
+ return fallback;
|
||||
return as_if<T, S>(*this)(fallback);
|
||||
}
|
||||
|
||||
@@ -282,26 +282,26 @@ inline std::size_t Node::size() const {
|
||||
|
||||
inline const_iterator Node::begin() const {
|
||||
if (!m_isValid)
|
||||
- throw InvalidNode();
|
||||
+ return const_iterator();
|
||||
return m_pNode ? const_iterator(m_pNode->begin(), m_pMemory)
|
||||
: const_iterator();
|
||||
}
|
||||
|
||||
inline iterator Node::begin() {
|
||||
if (!m_isValid)
|
||||
- throw InvalidNode();
|
||||
+ return iterator();
|
||||
return m_pNode ? iterator(m_pNode->begin(), m_pMemory) : iterator();
|
||||
}
|
||||
|
||||
inline const_iterator Node::end() const {
|
||||
if (!m_isValid)
|
||||
- throw InvalidNode();
|
||||
+ return const_iterator();
|
||||
return m_pNode ? const_iterator(m_pNode->end(), m_pMemory) : const_iterator();
|
||||
}
|
||||
|
||||
inline iterator Node::end() {
|
||||
if (!m_isValid)
|
||||
- throw InvalidNode();
|
||||
+ return iterator();
|
||||
return m_pNode ? iterator(m_pNode->end(), m_pMemory) : iterator();
|
||||
}
|
||||
|
||||
--- test/node/node_test.cpp.orig
|
||||
+++ test/node/node_test.cpp
|
||||
@@ -80,6 +80,12 @@ TEST(NodeTest, MapWithUndefinedValues) {
|
||||
EXPECT_EQ(2, node.size());
|
||||
}
|
||||
|
||||
+TEST(NodeTest, UndefinedConstNodeWithFallback) {
|
||||
+ Node node;
|
||||
+ const Node& cn = node;
|
||||
+ EXPECT_EQ(cn["undefined"].as<int>(3), 3);
|
||||
+}
|
||||
+
|
||||
TEST(NodeTest, MapIteratorWithUndefinedValues) {
|
||||
Node node;
|
||||
node["key"] = "value";
|
||||
@@ -91,6 +97,32 @@ TEST(NodeTest, MapIteratorWithUndefinedValues) {
|
||||
EXPECT_EQ(1, count);
|
||||
}
|
||||
|
||||
+TEST(NodeTest, ConstIteratorOnConstUndefinedNode) {
|
||||
+ Node node;
|
||||
+ const Node& cn = node;
|
||||
+ const Node& undefinedCn = cn["undefined"];
|
||||
+
|
||||
+ std::size_t count = 0;
|
||||
+ for (const_iterator it = undefinedCn.begin(); it != undefinedCn.end(); ++it) {
|
||||
+ count++;
|
||||
+ }
|
||||
+ EXPECT_EQ(0, count);
|
||||
+}
|
||||
+
|
||||
+TEST(NodeTest, IteratorOnConstUndefinedNode) {
|
||||
+ Node node;
|
||||
+ const Node& cn = node;
|
||||
+ const Node& undefinedCn = cn["undefined"];
|
||||
+
|
||||
+ Node& nonConstUndefinedNode = const_cast<Node&>(undefinedCn);
|
||||
+
|
||||
+ std::size_t count = 0;
|
||||
+ for (iterator it = nonConstUndefinedNode.begin(); it != nonConstUndefinedNode.end(); ++it) {
|
||||
+ count++;
|
||||
+ }
|
||||
+ EXPECT_EQ(0, count);
|
||||
+}
|
||||
+
|
||||
TEST(NodeTest, SimpleSubkeys) {
|
||||
Node node;
|
||||
node["device"]["udid"] = "12345";
|
|
@ -1,18 +1,22 @@
|
|||
# Template file for 'yaml-cpp'
|
||||
pkgname=yaml-cpp
|
||||
version=0.5.2
|
||||
revision=2
|
||||
version=0.5.3
|
||||
revision=1
|
||||
wrksrc=${pkgname}-release-${version}
|
||||
build_style=cmake
|
||||
configure_args="-DBUILD_SHARED_LIBS=ON"
|
||||
configure_args="-DBUILD_SHARED_LIBS=ON -DYAML_CPP_BUILD_TOOLS=OFF"
|
||||
hostmakedepends="cmake"
|
||||
makedepends="boost-devel"
|
||||
short_desc="A YAML parser and emitter in C++"
|
||||
maintainer="Duncaen <mail@duncano.de>"
|
||||
maintainer="Duncaen <duncaen@voidlinux.eu>"
|
||||
license="MIT"
|
||||
homepage="https://github.com/jbeder/yaml-cpp"
|
||||
distfiles="https://github.com/jbeder/${pkgname}/archive/release-${version}.tar.gz"
|
||||
checksum=6fb92f6f5925e0af918ffbb90acf19b7b88706ebcd40fc186b7caa76609b6350
|
||||
checksum=ac50a27a201d16dc69a881b80ad39a7be66c4d755eda1f76c3a68781b922af8f
|
||||
|
||||
post_install() {
|
||||
vlicense LICENSE
|
||||
}
|
||||
|
||||
yaml-cpp-devel_package() {
|
||||
depends="yaml-cpp-${version}_${revision}"
|
||||
|
|
Loading…
Reference in a new issue