diff options
Diffstat (limited to 'diff.cpp')
-rw-r--r-- | diff.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -21,9 +21,10 @@ std::string Diff::apply(const std::string& old_version) const { std::string result{old_version}; - result.erase(m_pos0, m_pos1 - m_pos0); - - result.insert(m_pos0, m_data); + if (m_pos0 <= m_pos1 && m_pos1 <= old_version.size()) { + result.erase(m_pos0, m_pos1 - m_pos0); + result.insert(m_pos0, m_data); + } return result; } @@ -143,6 +144,11 @@ void Diff::create(const std::string& xml) create(ptree); } +bool Diff::empty() const +{ + return m_pos0 == m_pos1 && m_data.empty(); +} + boost::property_tree::ptree Diff::get_structure() const { pt::ptree ptree; |