diff options
-rw-r--r-- | configmgr/source/pad.cxx | 21 | ||||
-rw-r--r-- | configmgr/source/pad.hxx | 4 | ||||
-rw-r--r-- | configmgr/source/xmlreader.cxx | 2 |
3 files changed, 22 insertions, 5 deletions
diff --git a/configmgr/source/pad.cxx b/configmgr/source/pad.cxx index b2b639f0dd7c..5bd5c6e5a9f9 100644 --- a/configmgr/source/pad.cxx +++ b/configmgr/source/pad.cxx @@ -43,10 +43,7 @@ void Pad::add(char const * begin, sal_Int32 length) { OSL_ASSERT( begin != 0 && length >= 0 && !(span_.is() && buffer_.getLength() != 0)); if (length != 0) { - if (span_.is()) { - buffer_.append(span_.begin, span_.length); - span_.clear(); - } + flushSpan(); if (buffer_.getLength() == 0) { span_ = Span(begin, length); } else { @@ -55,6 +52,15 @@ void Pad::add(char const * begin, sal_Int32 length) { } } +void Pad::addEphemeral(char const * begin, sal_Int32 length) { + OSL_ASSERT( + begin != 0 && length >= 0 && !(span_.is() && buffer_.getLength() != 0)); + if (length != 0) { + flushSpan(); + buffer_.append(begin, length); + } +} + void Pad::clear() { OSL_ASSERT(!(span_.is() && buffer_.getLength() != 0)); span_.clear(); @@ -77,4 +83,11 @@ Span Pad::get() const { } } +void Pad::flushSpan() { + if (span_.is()) { + buffer_.append(span_.begin, span_.length); + span_.clear(); + } +} + } diff --git a/configmgr/source/pad.hxx b/configmgr/source/pad.hxx index 2d0ff6bfecc0..e941d68a4342 100644 --- a/configmgr/source/pad.hxx +++ b/configmgr/source/pad.hxx @@ -43,6 +43,8 @@ class Pad { public: void add(char const * begin, sal_Int32 length); + void addEphemeral(char const * begin, sal_Int32 length); + void clear(); bool is() const; @@ -50,6 +52,8 @@ public: Span get() const; private: + void flushSpan(); + Span span_; rtl::OStringBuffer buffer_; }; diff --git a/configmgr/source/xmlreader.cxx b/configmgr/source/xmlreader.cxx index 2bac273610fb..9ddbb64bb13a 100644 --- a/configmgr/source/xmlreader.cxx +++ b/configmgr/source/xmlreader.cxx @@ -531,7 +531,7 @@ char const * XmlReader::handleReference(char const * position, char const * end) buf[3] = static_cast< char >((val & 0x3F) | 0x80); len = 4; } - pad_.add(buf, len); + pad_.addEphemeral(buf, len); return position; } else { struct EntityRef { |