From 1eef324dc9ffcd0bc115b283a038cc175f64deb5 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 19 Mar 2023 11:01:14 +0100 Subject: editor, main: assert StringView null termination --- main/debug.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'main') diff --git a/main/debug.cpp b/main/debug.cpp index eaac17b7..b464b49a 100644 --- a/main/debug.cpp +++ b/main/debug.cpp @@ -20,9 +20,8 @@ void main_impl::debug_callback(unsigned src, unsigned type, unsigned id, unsigne #endif (void)src; (void)type; - const char* p = str.data(); - if (str.hasPrefix("Buffer detailed info: "_s)) - p += sizeof("Buffer detailed info: ") - 1; + if (auto pfx = "Buffer detailed info: "_s; str.hasPrefix(pfx)) + str = str.exceptPrefix(pfx.size()); using seconds = std::chrono::duration; const auto t = std::chrono::duration_cast(clock.now() - t0).count(); @@ -39,7 +38,8 @@ void main_impl::debug_callback(unsigned src, unsigned type, unsigned id, unsigne } printf("%6u ", id); - std::puts(p); + std::fwrite(str.data(), str.size(), 1, stdout); + std::fputc('\n', stdout); std::fflush(stdout); std::fputs("", stdout); // put breakpoint here -- cgit v1.2.3