From aaa9d2d377c4c73632803378a0a71ff1fdbc6e85 Mon Sep 17 00:00:00 2001 From: Akash Levy Date: Thu, 16 Jan 2025 15:32:53 -0800 Subject: [PATCH] Report json fixes (#181) * Move "No paths found." reporting * delete ends * Smallfix --- search/ReportPath.cc | 6 +++++- search/Search.i | 9 ++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/search/ReportPath.cc b/search/ReportPath.cc index 6ddf90bc..1661591d 100644 --- a/search/ReportPath.cc +++ b/search/ReportPath.cc @@ -335,7 +335,7 @@ void ReportPath::reportPathEnds(PathEndSeq *ends) { reportPathEndHeader(); - if (ends) { + if (ends && !ends->empty()) { PathEndSeq::Iterator end_iter(ends); PathEnd *prev_end = nullptr; while (end_iter.hasNext()) { @@ -344,6 +344,10 @@ ReportPath::reportPathEnds(PathEndSeq *ends) prev_end = end; } } + else { + if (format_ != ReportPathFormat::json) + report_->reportLine("No paths found."); + } reportPathEndFooter(); } diff --git a/search/Search.i b/search/Search.i index 72c5ce52..b740da2f 100644 --- a/search/Search.i +++ b/search/Search.i @@ -512,13 +512,8 @@ report_path_cmd(PathRef *path) void report_path_ends(PathEndSeq *ends) { - Sta *sta = Sta::sta(); - Report *report = sta->report(); - ReportPathFormat path_format = sta->reportPath()->pathFormat(); - if (path_format == ReportPathFormat::json || (ends && ends->size() > 0)) - sta->reportPathEnds(ends); - else - report->reportLine("No paths found."); + Sta::sta()->reportPathEnds(ends); + delete ends; } ////////////////////////////////////////////////////////////////