mirror of
https://github.com/tstack/lnav
synced 2024-11-01 21:40:34 +00:00
parent
5ad75f156a
commit
db1fc92fdd
@ -610,7 +610,7 @@ logfile::rebuild_index(nonstd::optional<ui_clock::time_point> deadline)
|
||||
auto tmp_line = sbr.to_string_fragment().to_string();
|
||||
|
||||
scrub_ansi_string(tmp_line, nullptr);
|
||||
memcpy(sbr.get_writable_data(),
|
||||
memcpy(sbr.get_writable_data(tmp_line.length()),
|
||||
tmp_line.c_str(),
|
||||
tmp_line.length());
|
||||
sbr.narrow(0, tmp_line.length());
|
||||
|
@ -112,16 +112,18 @@ shared_buffer_ref::shared_buffer_ref(shared_buffer_ref&& other) noexcept
|
||||
}
|
||||
|
||||
bool
|
||||
shared_buffer_ref::take_ownership()
|
||||
shared_buffer_ref::take_ownership(size_t length)
|
||||
{
|
||||
if (this->sb_owner != nullptr && this->sb_data != nullptr) {
|
||||
char* new_data;
|
||||
|
||||
if ((new_data = (char*) malloc(this->sb_length)) == nullptr) {
|
||||
if ((this->sb_owner != nullptr && this->sb_data != nullptr)
|
||||
|| this->sb_length != length)
|
||||
{
|
||||
auto* new_data = (char*) malloc(length);
|
||||
if (new_data == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(new_data, this->sb_data, this->sb_length);
|
||||
memcpy(new_data, this->sb_data, std::min(length, this->sb_length));
|
||||
this->sb_length = length;
|
||||
this->sb_data = new_data;
|
||||
this->sb_owner->sb_refs.erase(find(this->sb_owner->sb_refs.begin(),
|
||||
this->sb_owner->sb_refs.end(),
|
||||
|
@ -112,15 +112,20 @@ public:
|
||||
|
||||
file_range::metadata& get_metadata() { return this->sb_metadata; }
|
||||
|
||||
char* get_writable_data()
|
||||
char* get_writable_data(size_t length)
|
||||
{
|
||||
if (this->take_ownership()) {
|
||||
if (this->take_ownership(length)) {
|
||||
return const_cast<char*>(this->sb_data);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char* get_writable_data()
|
||||
{
|
||||
return this->get_writable_data(this->sb_length);
|
||||
}
|
||||
|
||||
string_fragment to_string_fragment(off_t offset, size_t len) const
|
||||
{
|
||||
return string_fragment{
|
||||
@ -151,7 +156,9 @@ public:
|
||||
|
||||
void erase_ansi();
|
||||
|
||||
bool take_ownership();
|
||||
bool take_ownership(size_t length);
|
||||
|
||||
bool take_ownership() { return this->take_ownership(this->sb_length); }
|
||||
|
||||
void disown();
|
||||
|
||||
|
@ -354,6 +354,7 @@ dist_noinst_DATA = \
|
||||
mvwattrline_output.0 \
|
||||
textfile_0.md \
|
||||
textfile_ansi.0 \
|
||||
textfile_ansi_expanding.0 \
|
||||
textfile_json_indented.0 \
|
||||
textfile_json_one_line.0 \
|
||||
textfile_quoted_json.0 \
|
||||
|
@ -0,0 +1,10 @@
|
||||
[32m * [0mPackage: sys-libs/glibc-2.36-r7:2.2
|
||||
[32m * [0mRepository: gentoo
|
||||
[32m * [0mMaintainer: toolchain@gentoo.org
|
||||
[32m * [0mUSE: abi_x86_64 amd64 caps elibc_glibc kernel_linux multiarch ssp static-libs test userland_GNU
|
||||
[32m * [0mFEATURES: network-sandbox preserve-libs sandbox test userpriv usersandbox
|
||||
[32m*[0m Checking whether python3_11 is suitable ...
|
||||
[32m*[0m >=dev-lang/python-3.11.1-r1:3.11 ...
|
||||
[1m[34m[ [0m[1m[32mok[0m[1m[34m ][0m
|
||||
[32m*[0m Using python3.11 to build (via PYTHON_COMPAT iteration)
|
||||
>>> Unpacking source...
|
@ -31,3 +31,6 @@ run_cap_test ${lnav_test} -n \
|
||||
run_cap_test ${lnav_test} -n \
|
||||
-c ';SELECT * FROM lnav_file_metadata' \
|
||||
${test_dir}/textfile_0.md
|
||||
|
||||
run_cap_test ${lnav_test} -n \
|
||||
${test_dir}/textfile_ansi_expanding.0
|
||||
|
10
test/textfile_ansi_expanding.0
Normal file
10
test/textfile_ansi_expanding.0
Normal file
@ -0,0 +1,10 @@
|
||||
[32m * [39;49;00mPackage: sys-libs/glibc-2.36-r7:2.2
|
||||
[32m * [39;49;00mRepository: gentoo
|
||||
[32m * [39;49;00mMaintainer: toolchain@gentoo.org
|
||||
[32m * [39;49;00mUSE: abi_x86_64 amd64 caps elibc_glibc kernel_linux multiarch ssp static-libs test userland_GNU
|
||||
[32m * [39;49;00mFEATURES: network-sandbox preserve-libs sandbox test userpriv usersandbox
|
||||
[32m*[0m Checking whether python3_11 is suitable ...
|
||||
[32m*[0m >=dev-lang/python-3.11.1-r1:3.11 ...
|
||||
[A[230C [34;01m[ [32;01mok[34;01m ][0m
|
||||
[32m*[0m Using python3.11 to build (via PYTHON_COMPAT iteration)
|
||||
>>> Unpacking source...
|
Loading…
Reference in New Issue
Block a user