aboutsummaryrefslogtreecommitdiff
path: root/butl
diff options
context:
space:
mode:
Diffstat (limited to 'butl')
-rw-r--r--butl/diagnostics9
-rw-r--r--butl/diagnostics.cxx25
2 files changed, 21 insertions, 13 deletions
diff --git a/butl/diagnostics b/butl/diagnostics
index 694fae7..56219ce 100644
--- a/butl/diagnostics
+++ b/butl/diagnostics
@@ -71,14 +71,13 @@ namespace butl
void
append (diag_epilogue* e) const
{
- if (e != nullptr)
+ // Ignore subsequent epilogues (e.g., from nested marks, etc).
+ //
+ if (empty_)
{
- assert (epilogue_ == nullptr); // No multiple epilogues support.
epilogue_ = e;
- }
-
- if (empty_)
empty_ = false;
+ }
else
os << "\n ";
}
diff --git a/butl/diagnostics.cxx b/butl/diagnostics.cxx
index 4cd8515..7dc8bd0 100644
--- a/butl/diagnostics.cxx
+++ b/butl/diagnostics.cxx
@@ -17,14 +17,23 @@ namespace butl
{
if (!empty_)
{
- os.put ('\n');
- *diag_stream << os.str ();
- diag_stream->flush ();
-
- empty_ = true;
-
- if (epilogue_ != nullptr)
- epilogue_ (*this); // Can throw.
+ if (epilogue_ == nullptr)
+ {
+ os.put ('\n');
+ *diag_stream << os.str ();
+ diag_stream->flush ();
+
+ empty_ = true;
+ }
+ else
+ {
+ // Clear the epilogue in case it calls us back.
+ //
+ auto e (epilogue_);
+ epilogue_ = nullptr;
+ e (*this); // Can throw.
+ flush (); // Call ourselves to write the data in case it returns.
+ }
}
}