Skip to content

Commit 05f4633

Browse files
committed
Refactoring AddDupWrap() via StrSizeOfCells()
1 parent 55861be commit 05f4633

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

far2l/src/message.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -574,8 +574,13 @@ Messager &FN_NOINLINE ExMessager::AddDupWrap(const wchar_t *v)
574574
return AddDup(v);
575575

576576
FARString fs = v;
577-
for(size_t pos = 0; pos < maxlen; pos+=MAX_WIDTH_MESSAGE)
578-
AddDup( fs.SubStr(pos, pos+MAX_WIDTH_MESSAGE).CPtr() );
577+
for(size_t chars_pos = 0, chars_len, cells_n; chars_pos < maxlen; chars_pos += chars_len) {
578+
cells_n = MAX_WIDTH_MESSAGE;
579+
chars_len = StrSizeOfCells(&v[chars_pos], maxlen - chars_pos, cells_n, false);
580+
if (cells_n <= 0)
581+
break;
582+
AddDup( fs.SubStr(chars_pos, chars_len).CPtr() );
583+
}
579584
return *this;
580585
}
581586

0 commit comments

Comments
 (0)