From 3f59046dd12a3489fc4ed7d2f8318d4466590825 Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Thu, 15 Jun 2023 21:33:19 +0200 Subject: [PATCH] Some off-by-ones --- clink/core/include/core/str.h | 6 +++--- clink/terminal/include/terminal/printer.h | 2 +- clink/terminal/include/terminal/terminal_out.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/clink/core/include/core/str.h b/clink/core/include/core/str.h index c8248e06..95d05491 100644 --- a/clink/core/include/core/str.h +++ b/clink/core/include/core/str.h @@ -324,7 +324,7 @@ StrImpl& StrImpl::operator << (const TYPE* rhs) template template StrImpl& StrImpl::operator << (const TYPE (&rhs)[I]) { - concat(rhs, I); + concat(rhs, I - 1); return *this; } @@ -357,7 +357,7 @@ int32 to_utf16(wchar_t* out, int32 max_count, StrIterImpl& iter); class StrBase : public StrImpl { public: - template StrBase(char (&data)[I]) : StrImpl(data, I) {} + template StrBase(char (&data)[I]) : StrImpl(data, I - 1) {} StrBase(char* data, int32 size) : StrImpl(data, size) {} StrBase(const StrBase&) = delete; StrBase(const StrBase&&) = delete; @@ -370,7 +370,7 @@ class StrBase : public StrImpl class WstrBase : public StrImpl { public: - template WstrBase(char (&data)[I]) : StrImpl(data, I) {} + template WstrBase(char (&data)[I]) : StrImpl(data, I - 1) {} WstrBase(wchar_t* data, int32 size) : StrImpl(data, size) {} WstrBase(const WstrBase&) = delete; WstrBase(const WstrBase&&) = delete; diff --git a/clink/terminal/include/terminal/printer.h b/clink/terminal/include/terminal/printer.h index 78ceca91..7422e402 100644 --- a/clink/terminal/include/terminal/printer.h +++ b/clink/terminal/include/terminal/printer.h @@ -44,5 +44,5 @@ template void Printer::print(const char (&data)[S]) //------------------------------------------------------------------------------ template void Printer::print(const Attributes attr, const char (&data)[S]) { - print(attr, data, S); + print(attr, data, S - 1); } diff --git a/clink/terminal/include/terminal/terminal_out.h b/clink/terminal/include/terminal/terminal_out.h index c49c6945..d2bf2347 100644 --- a/clink/terminal/include/terminal/terminal_out.h +++ b/clink/terminal/include/terminal/terminal_out.h @@ -22,5 +22,5 @@ class TerminalOut //------------------------------------------------------------------------------ template void TerminalOut::write(const char (&chars)[S]) { - write(chars, S); + write(chars, S - 1); }