diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-07 04:48:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-07 04:48:35 +0000 |
commit | 207df6fc406e81bfeebdff7f404bd242ff3f099f (patch) | |
tree | a1a796b056909dd0a04ffec163db9363a8757808 /src/base/is_utf8.cc | |
parent | Releasing progress-linux version 0.11.2-1~progress7.99u1. (diff) | |
download | lnav-207df6fc406e81bfeebdff7f404bd242ff3f099f.tar.xz lnav-207df6fc406e81bfeebdff7f404bd242ff3f099f.zip |
Merging upstream version 0.12.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/base/is_utf8.cc')
-rw-r--r-- | src/base/is_utf8.cc | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/base/is_utf8.cc b/src/base/is_utf8.cc index f55dfe0..b8fbab0 100644 --- a/src/base/is_utf8.cc +++ b/src/base/is_utf8.cc @@ -64,7 +64,7 @@ is_utf8(string_fragment str, nonstd::optional<unsigned char> terminator) { const auto* ustr = str.udata(); utf8_scan_result retval; - ssize_t i = 0; + ssize_t i = 0, valid_end = 0; while (i < str.length()) { if (ustr[i] == '\x1b') { @@ -72,20 +72,21 @@ is_utf8(string_fragment str, nonstd::optional<unsigned char> terminator) } if (terminator && ustr[i] == terminator.value()) { - if (retval.usr_message == nullptr) { - retval.usr_valid_frag = str.sub_range(0, i); - } retval.usr_remaining = str.substr(i + 1); break; } + retval.usr_column_width_guess += 1; if (retval.usr_message != nullptr) { i += 1; continue; } - retval.usr_valid_frag = str.sub_range(0, i); + valid_end = i; if (ustr[i] <= 0x7F) /* 00..7F */ { + if (ustr[i] == '\t') { + retval.usr_column_width_guess += 7; + } i += 1; } else if (ustr[i] >= 0xC2 && ustr[i] <= 0xDF) /* C2..DF 80..BF */ { if (i + 1 < str.length()) /* Expect a 2nd byte */ { @@ -308,6 +309,8 @@ is_utf8(string_fragment str, nonstd::optional<unsigned char> terminator) } if (retval.usr_message == nullptr) { retval.usr_valid_frag = str.sub_range(0, i); + } else { + retval.usr_valid_frag = str.sub_range(0, valid_end); } return retval; } |