gnucash master: One more empty check when handling trailing '/' in a KVP key.
John Ralls
jralls at code.gnucash.org
Fri Jul 24 20:17:08 EDT 2015
Updated via https://github.com/Gnucash/gnucash/commit/54c9e836 (commit)
from https://github.com/Gnucash/gnucash/commit/b3bc68dc (commit)
commit 54c9e836d4fcde320b2b3a32914b82c0eb54bb65
Author: John Ralls <jralls at ceridwen.us>
Date: Fri Jul 24 17:10:34 2015 -0700
One more empty check when handling trailing '/' in a KVP key.
Also fix a unit test error.
diff --git a/src/libqof/qof/kvp_frame.cpp b/src/libqof/qof/kvp_frame.cpp
index db033f4..5a5b6be 100644
--- a/src/libqof/qof/kvp_frame.cpp
+++ b/src/libqof/qof/kvp_frame.cpp
@@ -78,7 +78,8 @@ make_vector(std::string key)
key = key.substr(length + 1);
length = key.find(delim);
}
- path.push_back(key);
+ if (!key.empty())
+ path.push_back(key);
return path;
}
@@ -139,6 +140,8 @@ walk_path_and_create(KvpFrameImpl* frame, Path path)
{
for(auto key:path)
{
+ if (key.empty())
+ continue;
if (key.find(delim) != std::string::npos)
{
frame = walk_path_and_create(frame, make_vector(key));
diff --git a/src/libqof/qof/test/test-kvp-frame.cpp b/src/libqof/qof/test/test-kvp-frame.cpp
index 4ee2c98..bbe4894 100644
--- a/src/libqof/qof/test/test-kvp-frame.cpp
+++ b/src/libqof/qof/test/test-kvp-frame.cpp
@@ -109,7 +109,7 @@ TEST_F (KvpFrameTest, SetPathIgnoreBeginEndSlash)
Path path2 {"top", "second", "twenty-first"};
auto v1 = new KvpValueImpl {15.0};
- EXPECT_EQ (nullptr, t_root.set(path1, v1));
+ EXPECT_EQ (nullptr, t_root.set_path(path1, v1));
EXPECT_EQ (v1, t_root.get_slot(path2));
}
Summary of changes:
src/libqof/qof/kvp_frame.cpp | 5 ++++-
src/libqof/qof/test/test-kvp-frame.cpp | 2 +-
2 files changed, 5 insertions(+), 2 deletions(-)
More information about the gnucash-changes
mailing list