Skip to content

Commit 6fa7e46

Browse files
committed
[:goto] handle zero relative time
Related to #1615
1 parent 4628d12 commit 6fa7e46

File tree

6 files changed

+18
-33
lines changed

6 files changed

+18
-33
lines changed

src/lnav_commands.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ com_goto(exec_context& ec, std::string cmdline, std::vector<std::string>& args)
826826

827827
std::string retval;
828828

829-
std::string all_args = remaining_args(cmdline, args);
829+
std::string all_args = trim(remaining_args(cmdline, args));
830830
auto* tc = *lnav_data.ld_view_stack.top();
831831
std::optional<vis_line_t> dst_vl;
832832
auto is_location = false;
@@ -867,7 +867,7 @@ com_goto(exec_context& ec, std::string cmdline, std::vector<std::string>& args)
867867
}
868868
}
869869

870-
if (dst_vl) {
870+
if (all_args.empty() || dst_vl) {
871871
} else if (parse_res.isOk()) {
872872
if (ttt == nullptr) {
873873
return ec.make_error(
@@ -892,9 +892,13 @@ com_goto(exec_context& ec, std::string cmdline, std::vector<std::string>& args)
892892
}
893893

894894
do {
895+
auto orig_tv = tv;
895896
auto tm = rt.adjust(tv);
896897

897898
tv = tm.to_timeval();
899+
if (tv == orig_tv) {
900+
break;
901+
}
898902
auto new_vl_opt = ttt->row_for_time(tv);
899903
if (!new_vl_opt) {
900904
break;

src/logfile_sub_source.cc

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ struct filtered_logline_cmp {
201201
{
202202
auto cl_lhs = llss_controller.lss_index[lhs].value();
203203
auto cl_rhs = llss_controller.lss_index[rhs].value();
204-
auto ll_lhs = this->llss_controller.find_line(cl_lhs);
205-
auto ll_rhs = this->llss_controller.find_line(cl_rhs);
204+
const auto* ll_lhs = this->llss_controller.find_line(cl_lhs);
205+
const auto* ll_rhs = this->llss_controller.find_line(cl_rhs);
206206

207207
if (ll_lhs == nullptr) {
208208
return true;
@@ -865,36 +865,8 @@ struct logline_cmp {
865865
return (*ll_lhs) < (*ll_rhs);
866866
}
867867

868-
bool operator()(const uint32_t& lhs, const uint32_t& rhs) const
869-
{
870-
auto cl_lhs = llss_controller.lss_index[lhs].value();
871-
auto cl_rhs = llss_controller.lss_index[rhs].value();
872-
const auto* ll_lhs = this->llss_controller.find_line(cl_lhs);
873-
const auto* ll_rhs = this->llss_controller.find_line(cl_rhs);
874-
875-
return (*ll_lhs) < (*ll_rhs);
876-
}
877-
#if 0
878-
bool operator()(const indexed_content &lhs, const indexed_content &rhs)
879-
{
880-
logline *ll_lhs = this->llss_controller.find_line(lhs.ic_value);
881-
logline *ll_rhs = this->llss_controller.find_line(rhs.ic_value);
882-
883-
return (*ll_lhs) < (*ll_rhs);
884-
}
885-
#endif
886-
887-
#if 0
888-
bool operator()(const content_line_t& lhs, const time_t& rhs) const
889-
{
890-
logline* ll_lhs = this->llss_controller.find_line(lhs);
891-
892-
return *ll_lhs < rhs;
893-
}
894-
#endif
895-
896868
bool operator()(const logfile_sub_source::indexed_content& lhs,
897-
const struct timeval& rhs) const
869+
const timeval& rhs) const
898870
{
899871
const auto* ll_lhs = this->llss_controller.find_line(lhs.value());
900872

test/expected/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ dist_noinst_DATA = \
6262
test_cmds.sh_015ffe79a08f4c9f0cd1cb84c6afa4398f879fc7.out \
6363
test_cmds.sh_017b495b95218b7c083951e2dba331cfec6e90be.err \
6464
test_cmds.sh_017b495b95218b7c083951e2dba331cfec6e90be.out \
65+
test_cmds.sh_0205bbf13f286f7f4b700dabcd38f698ed853d0f.err \
66+
test_cmds.sh_0205bbf13f286f7f4b700dabcd38f698ed853d0f.out \
6567
test_cmds.sh_0b1e4b1523dfca71927b1fe721c74490c51361d1.err \
6668
test_cmds.sh_0b1e4b1523dfca71927b1fe721c74490c51361d1.out \
6769
test_cmds.sh_0b41fe57743ba0be088037d9ba29bc465e7c9bf9.err \

test/expected/test_cmds.sh_0205bbf13f286f7f4b700dabcd38f698ed853d0f.err

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
192.168.202.254 - - [20/Jul/2009:22:59:29 +0000] "GET /vmw/vSphere/default/vmkboot.gz HTTP/1.0" 404 46210 "-" "gPXE/0.9.7"
2+
192.168.202.254 - - [20/Jul/2009:22:59:29 +0000] "GET /vmw/vSphere/default/vmkernel.gz HTTP/1.0" 200 78929 "-" "gPXE/0.9.7"

test/test_cmds.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ export TZ=UTC
44
export YES_COLOR=1
55
export DUMP_CRASH=1
66

7+
run_cap_test ${lnav_test} -n \
8+
-c ":goto 1" \
9+
-c ":goto 0s" \
10+
${test_dir}/logfile_access_log.0
11+
712
run_cap_test ${lnav_test} -nN \
813
-c ":goto -1"
914

0 commit comments

Comments
 (0)