forked from pool/yaml-cpp
Accepting request 359135 from devel:libraries:c_c++
1 OBS-URL: https://build.opensuse.org/request/show/359135 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/yaml-cpp?expand=0&rev=9
This commit is contained in:
@@ -1,119 +0,0 @@
|
|||||||
From b426fafff6238dda8d86fa668f585cba732dd272 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Jonathan Hamilton <jtrhamilton@gmail.com>
|
|
||||||
Date: Mon, 1 Jun 2015 13:33:59 -0700
|
|
||||||
Subject: [PATCH] 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 | 10 +++++-----
|
|
||||||
test/node/node_test.cpp | 32 ++++++++++++++++++++++++++++++++
|
|
||||||
2 files changed, 37 insertions(+), 5 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/include/yaml-cpp/node/impl.h b/include/yaml-cpp/node/impl.h
|
|
||||||
index 26cccbd..69db1b7 100644
|
|
||||||
--- a/include/yaml-cpp/node/impl.h
|
|
||||||
+++ b/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();
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/test/node/node_test.cpp b/test/node/node_test.cpp
|
|
||||||
index 03ad782..b00c69d 100644
|
|
||||||
--- a/test/node/node_test.cpp
|
|
||||||
+++ b/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,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:6fb92f6f5925e0af918ffbb90acf19b7b88706ebcd40fc186b7caa76609b6350
|
|
||||||
size 2015873
|
|
||||||
3
yaml-cpp-0.5.3.tar.gz
Normal file
3
yaml-cpp-0.5.3.tar.gz
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:ac50a27a201d16dc69a881b80ad39a7be66c4d755eda1f76c3a68781b922af8f
|
||||||
|
size 2016737
|
||||||
@@ -1,3 +1,12 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Fri Feb 12 21:14:16 UTC 2016 - mpluskal@suse.com
|
||||||
|
|
||||||
|
- Update to 0.5.3
|
||||||
|
* Bugfix release.
|
||||||
|
* This will be the last release that does not require C++11.
|
||||||
|
- Drop upstreamed fix-node-regression.patch
|
||||||
|
- Small spec file cleanups
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Fri Nov 13 09:51:23 UTC 2015 - tchvatal@suse.com
|
Fri Nov 13 09:51:23 UTC 2015 - tchvatal@suse.com
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# spec file for package yaml-cpp
|
# spec file for package yaml-cpp
|
||||||
#
|
#
|
||||||
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
|
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||||
#
|
#
|
||||||
# All modifications and additions to the file contributed by third parties
|
# All modifications and additions to the file contributed by third parties
|
||||||
# remain the property of their copyright owners, unless otherwise agreed
|
# remain the property of their copyright owners, unless otherwise agreed
|
||||||
@@ -17,16 +17,14 @@
|
|||||||
|
|
||||||
|
|
||||||
%define library_name libyaml-cpp0_5
|
%define library_name libyaml-cpp0_5
|
||||||
|
|
||||||
Name: yaml-cpp
|
Name: yaml-cpp
|
||||||
Version: 0.5.2
|
Version: 0.5.3
|
||||||
Release: 0
|
Release: 0
|
||||||
Summary: YAML parser and emitter in C++
|
Summary: YAML parser and emitter in C++
|
||||||
License: MIT
|
License: MIT
|
||||||
Group: Development/Libraries/C and C++
|
Group: Development/Libraries/C and C++
|
||||||
Url: https://github.com/jbeder/yaml-cpp/
|
Url: https://github.com/jbeder/yaml-cpp/
|
||||||
Source: https://github.com/jbeder/yaml-cpp/archive/release-%{version}/%{name}-%{version}.tar.gz
|
Source: https://github.com/jbeder/yaml-cpp/archive/release-%{version}/%{name}-%{version}.tar.gz
|
||||||
Patch0: fix-node-regression.patch
|
|
||||||
BuildRequires: boost-devel
|
BuildRequires: boost-devel
|
||||||
BuildRequires: cmake
|
BuildRequires: cmake
|
||||||
BuildRequires: gcc
|
BuildRequires: gcc
|
||||||
@@ -55,30 +53,28 @@ Requires: boost-devel
|
|||||||
Development files for %{name} library.
|
Development files for %{name} library.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -qn %{name}-release-%{version}
|
%setup -q -n %{name}-release-%{version}
|
||||||
%patch0 -p1
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
%cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ../
|
%cmake \
|
||||||
make VERBOSE=1 %{?_smp_mflags}
|
-DCMAKE_BUILD_TYPE=RelWithDebInfo
|
||||||
|
make %{?_smp_mflags}
|
||||||
|
|
||||||
%install
|
%install
|
||||||
cd build
|
%cmake_install
|
||||||
%makeinstall
|
|
||||||
|
|
||||||
%post -n %{library_name} -p /sbin/ldconfig
|
%post -n %{library_name} -p /sbin/ldconfig
|
||||||
|
|
||||||
%postun -n %{library_name} -p /sbin/ldconfig
|
%postun -n %{library_name} -p /sbin/ldconfig
|
||||||
|
|
||||||
%files -n %{library_name}
|
%files -n %{library_name}
|
||||||
%defattr(-,root,root,-)
|
%defattr(-,root,root,-)
|
||||||
%doc license.txt
|
%doc LICENSE
|
||||||
%{_libdir}/lib*.so.*
|
%{_libdir}/libyaml-cpp.so.*
|
||||||
|
|
||||||
%files devel
|
%files devel
|
||||||
%defattr(-,root,root,-)
|
%defattr(-,root,root,-)
|
||||||
%{_includedir}/yaml-cpp/
|
%{_includedir}/yaml-cpp/
|
||||||
%{_libdir}/lib*.so
|
%{_libdir}/libyaml-cpp.so
|
||||||
%{_libdir}/pkgconfig/*.pc
|
%{_libdir}/pkgconfig/yaml-cpp.pc
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
|||||||
Reference in New Issue
Block a user