1
1
mirror of https://github.com/tstack/lnav.git synced 2024-09-11 13:05:51 +03:00

[cmds] :goto was not handling timestamps with spaces

This commit is contained in:
Tim Stack 2022-08-18 13:27:49 -07:00
parent 8e734eaf07
commit 9c8cc04a99
5 changed files with 15 additions and 6 deletions

View File

@ -396,7 +396,7 @@ com_goto(exec_context& ec, std::string cmdline, std::vector<std::string>& args)
r, R, "to move forward/backward the same amount of time"));
}
} else if ((scan_end = dts.scan(
args[1].c_str(), args[1].size(), nullptr, &tm, tv))
all_args.c_str(), all_args.size(), nullptr, &tm, tv))
!= nullptr)
{
if (ttt == nullptr) {
@ -404,11 +404,11 @@ com_goto(exec_context& ec, std::string cmdline, std::vector<std::string>& args)
"time values only work in a time-indexed view");
}
size_t matched_size = scan_end - args[1].c_str();
if (matched_size != args[1].size()) {
size_t matched_size = scan_end - all_args.c_str();
if (matched_size != all_args.size()) {
auto um
= lnav::console::user_message::error(
attr_line_t("invalid timestamp: ").append(args[1]))
attr_line_t("invalid timestamp: ").append(all_args))
.with_reason(
attr_line_t("the leading part of the timestamp "
"was matched, however, the trailing "
@ -423,12 +423,12 @@ com_goto(exec_context& ec, std::string cmdline, std::vector<std::string>& args)
.with_help(
"fix the timestamp or remove the trailing text");
auto unmatched_size = args[1].size() - matched_size;
auto unmatched_size = all_args.size() - matched_size;
auto& snippet_copy = um.um_snippets.back();
attr_line_builder alb(snippet_copy.s_content);
alb.append("\n")
.append(1 + cmdline.find(args[1]), ' ')
.append(1 + cmdline.find(all_args), ' ')
.append(matched_size, ' ');
{
auto attr_guard

View File

@ -130,6 +130,8 @@ EXPECTED_FILES = \
$(srcdir)/%reldir%/test_cmds.sh_968dac54dc80d91a5da2322890c6c26dfa0d8462.out \
$(srcdir)/%reldir%/test_cmds.sh_a00943ef715598c7554b85de8502454e41bb9e28.err \
$(srcdir)/%reldir%/test_cmds.sh_a00943ef715598c7554b85de8502454e41bb9e28.out \
$(srcdir)/%reldir%/test_cmds.sh_a0e6214b2a85c90d31aee12efde850441cca7eb3.err \
$(srcdir)/%reldir%/test_cmds.sh_a0e6214b2a85c90d31aee12efde850441cca7eb3.out \
$(srcdir)/%reldir%/test_cmds.sh_a1123427c31c022433d66d05ee5d5e1c8ab415e4.err \
$(srcdir)/%reldir%/test_cmds.sh_a1123427c31c022433d66d05ee5d5e1c8ab415e4.out \
$(srcdir)/%reldir%/test_cmds.sh_a190bfc279fa046a823864f1484f899d27d22953.err \

View File

@ -0,0 +1,2 @@
log_top_line() 
51

View File

@ -6,6 +6,11 @@ run_cap_test ${lnav_test} -n \
-c ":switch-to-view help" \
${test_dir}/logfile_access_log.0
run_cap_test ${lnav_test} -n \
-c ":goto 2011-11-02 17:19:39" \
-c ";SELECT log_top_line()" \
${test_dir}/logfile_bro_http.log.0
run_cap_test ${lnav_test} -n \
-c ":goto 1" \
-c ":mark" \