Skip to content

Commit

Permalink
Fix logic in TCellChar methods
Browse files Browse the repository at this point in the history
  • Loading branch information
magiblot committed Sep 24, 2024
1 parent 966226d commit 8fb188f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions include/tvision/scrncell.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,17 @@ inline void TCellChar::moveInt(uint32_t mbc, bool wide)
inline void TCellChar::moveStr(TStringView mbc, bool wide)
{
static_assert(sizeof(_text) >= 4, "");
if (mbc.size() <= 4)
memset(this, 0, sizeof(*this));
if (0 < mbc.size() && mbc.size() <= 4)
{
memset(this, 0, sizeof(*this));
_flags |= -int(wide) & fWide;
switch (mbc.size())
{
case 4: _text[3] = mbc[3];
case 3: _text[2] = mbc[2];
case 2: _text[1] = mbc[1];
case 1: _text[0] = mbc[0];
}
_flags |= -int(wide) & fWide;
}
}

Expand All @@ -127,7 +127,7 @@ constexpr inline void TCellChar::appendZeroWidth(TStringView mbc)
size_t sz = size();
if (mbc.size() <= sizeof(_text) - sz)
{
if (!mbc[0])
if (_text[0] == '\0')
_text[0] = ' ';
switch (mbc.size())
{
Expand Down

0 comments on commit 8fb188f

Please sign in to comment.