summaryrefslogtreecommitdiffhomepage
path: root/main
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-03-19 11:01:14 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-03-19 11:02:04 +0100
commit1eef324dc9ffcd0bc115b283a038cc175f64deb5 (patch)
tree104b76f9e8d246b246322b97ce6a9c25b05cb260 /main
parentaadd93718a851ac36a6eefbfec273c81ebf7cc14 (diff)
editor, main: assert StringView null termination
Diffstat (limited to 'main')
-rw-r--r--main/debug.cpp8
1 files changed, 4 insertions, 4 deletions
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<double>;
const auto t = std::chrono::duration_cast<seconds>(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