1
1
mirror of https://github.com/tstack/lnav.git synced 2024-08-16 08:20:29 +03:00

[coverity] some more fixes

This commit is contained in:
Tim Stack 2024-06-11 06:25:10 -07:00
parent 97f12cf4aa
commit 2610a8eac4
35 changed files with 175 additions and 164 deletions

View File

@ -51,13 +51,13 @@ snippet::from_content_with_offset(intern_string_t src,
size_t offset,
const std::string& errmsg)
{
auto content_sf = string_fragment::from_str(content.get_string());
auto line_with_error = content_sf.find_boundaries_around(
const auto content_sf = string_fragment::from_str(content.get_string());
const auto line_with_error = content_sf.find_boundaries_around(
offset, string_fragment::tag1{'\n'});
auto line_with_context = content_sf.find_boundaries_around(
const auto line_with_context = content_sf.find_boundaries_around(
offset, string_fragment::tag1{'\n'}, 3);
auto line_number = content_sf.sub_range(0, offset).count('\n');
auto erroff_in_line = offset - line_with_error.sf_begin;
const auto line_number = content_sf.sub_range(0, offset).count('\n');
const auto erroff_in_line = offset - line_with_error.sf_begin;
attr_line_t pointer;

View File

@ -94,6 +94,13 @@ struct user_message {
static user_message ok(const attr_line_t& al);
user_message() = default;
user_message(user_message&&) = default;
user_message(const user_message&) = default;
user_message& operator=(user_message&&) = default;
user_message& operator=(const user_message&) = default;
user_message& with_reason(const attr_line_t& al)
{
this->um_reason = al;

View File

@ -65,7 +65,7 @@ connect(const char* hostname, const char* servname)
return Err(fmt::format(FMT_STRING("unable to connect to {}:{} -- {}"),
hostname,
servname,
strerror(rc)));
strerror(errno)));
}
return Ok(std::move(retval));

View File

@ -156,7 +156,7 @@ safe_read(const std::string& str, std::string::size_type index)
}
void
regex_highlighter(attr_line_t& al, int x, line_range sub)
regex_highlighter(attr_line_t& al, std::optional<int> x, line_range sub)
{
static const char* brackets[] = {
"[]",
@ -336,7 +336,8 @@ regex_highlighter(attr_line_t& al, int x, line_range sub)
}
for (int lpc = 0; brackets[lpc]; lpc++) {
find_matching_bracket(al, x, sub, brackets[lpc][0], brackets[lpc][1]);
find_matching_bracket(
al, x.value_or(0), sub, brackets[lpc][0], brackets[lpc][1]);
}
}

View File

@ -35,7 +35,7 @@
namespace lnav {
namespace snippets {
void regex_highlighter(attr_line_t& al, int x, line_range sub);
void regex_highlighter(attr_line_t& al, std::optional<int> x, line_range sub);
} // namespace snippets
} // namespace lnav

View File

@ -385,7 +385,7 @@ field_overlay_source::build_field_lines(const listview_curses& lv,
al.append(jget_str.in());
hl_range.lr_end = al.get_string().length();
}
readline_sqlite_highlighter_int(al, -1, hl_range);
readline_sqlite_highlighter_int(al, std::nullopt, hl_range);
al.append(" = ").append(scrub_ws(value_str.c_str()));
@ -420,7 +420,7 @@ field_overlay_source::build_field_lines(const listview_curses& lv,
auto key_line = attr_line_t(" jget(log_raw_text, ")
.append(qname.in())
.append(")");
readline_sqlite_highlighter(key_line, 0);
readline_sqlite_highlighter(key_line, std::nullopt);
auto key_size = key_line.length();
key_line.append(" = ").append(scrub_ws(extra_pair.second));
this->fos_lines.emplace_back(key_line);
@ -433,7 +433,7 @@ field_overlay_source::build_field_lines(const listview_curses& lv,
for (size_t lpc = 0; lpc < jpairs.size(); lpc++) {
auto key_line = attr_line_t(" ").append(
this->fos_log_helper.format_json_getter(jpairs_map.first, lpc));
readline_sqlite_highlighter(key_line, 0);
readline_sqlite_highlighter(key_line, std::nullopt);
auto key_size = key_line.length();
key_line.append(" = ").append(scrub_ws(jpairs[lpc].wt_value));
this->fos_lines.emplace_back(key_line);
@ -453,7 +453,7 @@ field_overlay_source::build_field_lines(const listview_curses& lv,
this->fos_log_helper.ldh_file->get_format()->get_name().c_str(),
qname.in());
auto key_line = attr_line_t(" ").append(xp_call.in());
readline_sqlite_highlighter(key_line, 0);
readline_sqlite_highlighter(key_line, std::nullopt);
auto key_size = key_line.length();
key_line.append(" = ").append(scrub_ws(xml_pair.second));
this->fos_lines.emplace_back(key_line);

View File

@ -42,7 +42,8 @@
using namespace lnav::roles::literals;
filter_sub_source::filter_sub_source(std::shared_ptr<readline_curses> editor)
filter_sub_source::
filter_sub_source(std::shared_ptr<readline_curses> editor)
: fss_editor(editor)
{
this->fss_editor->set_x(25);
@ -377,10 +378,10 @@ filter_sub_source::text_value_for_line(textview_curses& tc,
attr_line_t content{tf->get_id()};
switch (tf->get_lang()) {
case filter_lang_t::REGEX:
readline_regex_highlighter(content, content.length());
readline_regex_highlighter(content, std::nullopt);
break;
case filter_lang_t::SQL:
readline_sqlite_highlighter(content, content.length());
readline_sqlite_highlighter(content, std::nullopt);
break;
case filter_lang_t::NONE:
break;

View File

@ -593,7 +593,7 @@ format_example_text_for_term(const help_text& ht,
case help_context_t::HC_SQL_TABLE_VALUED_FUNCTION:
case help_context_t::HC_PRQL_TRANSFORM:
case help_context_t::HC_PRQL_FUNCTION:
readline_sqlite_highlighter(ex_line, 0);
readline_sqlite_highlighter(ex_line, std::nullopt);
prompt = ";";
break;
default:

View File

@ -1423,7 +1423,7 @@ line_buffer::enable_cache()
auto guard = lnav::filesystem::file_lock::guard(&fl);
if (std::filesystem::exists(cached_done_path)) {
log_info("%d:using existing cache file");
log_info("%d:using existing cache file", this->lb_fd.get());
auto open_res = lnav::filesystem::open_file(cached_file_path, O_RDWR);
if (open_res.isOk()) {
this->lb_cached_fd = open_res.unwrap();
@ -1444,7 +1444,7 @@ line_buffer::enable_cache()
auto write_fd = create_res.unwrap();
auto done = false;
static const ssize_t FILL_LENGTH = 1024 * 1024;
static constexpr ssize_t FILL_LENGTH = 1024 * 1024;
auto off = file_off_t{0};
while (!done) {
log_debug("%d: caching file content at %d", this->lb_fd.get(), off);

View File

@ -101,7 +101,7 @@ struct subcmd_config_t {
| lnav::itertools::fold(
subcmd_reducer, attr_line_t{"the available operations are:"}));
return {um};
return {std::move(um)};
}
static perform_result_t get_action(const subcmd_config_t&)
@ -109,7 +109,7 @@ struct subcmd_config_t {
auto config_str = dump_config();
auto um = console::user_message::raw(config_str);
return {um};
return {std::move(um)};
}
static perform_result_t blame_action(const subcmd_config_t&)
@ -125,7 +125,7 @@ struct subcmd_config_t {
auto um = console::user_message::raw(blame.rtrim());
return {um};
return {std::move(um)};
}
static perform_result_t file_options_action(const subcmd_config_t& sc)
@ -137,7 +137,7 @@ struct subcmd_config_t {
auto um = lnav::console::user_message::error(
"Expecting a file path to check for options");
return {um};
return {std::move(um)};
}
safe::ReadAccess<lnav::safe_file_options_hier> options_hier(
@ -150,7 +150,7 @@ struct subcmd_config_t {
.append(lnav::roles::file(sc.sc_path)))
.with_reason(realpath_res.unwrapErr());
return {um};
return {std::move(um)};
}
auto full_path = realpath_res.unwrap();
auto file_opts = options_hier->match(full_path);
@ -176,7 +176,7 @@ struct subcmd_config_t {
" command to set the zone for messages in files "
"that do not include a zone in the timestamp"));
return {um};
return {std::move(um)};
}
subcmd_config_t& set_action(action_t act)
@ -339,7 +339,7 @@ struct subcmd_format_t {
| lnav::itertools::fold(
subcmd_reducer, attr_line_t{"the available operations are:"}));
return {um};
return {std::move(um)};
}
static perform_result_t default_regex_action(const subcmd_format_t& sf)
@ -359,7 +359,7 @@ struct subcmd_format_t {
sf.sf_regex_app->get_subcommands({})
| lnav::itertools::fold(subcmd_reducer, attr_line_t{})));
return {um};
return {std::move(um)};
}
static perform_result_t get_action(const subcmd_format_t& sf)
@ -378,7 +378,7 @@ struct subcmd_format_t {
.append(": ")
.append(on_blank(format->lf_description, "<no description>")));
return {um};
return {std::move(um)};
}
static perform_result_t source_action(const subcmd_format_t& sf)
@ -401,7 +401,7 @@ struct subcmd_format_t {
auto um = console::user_message::raw(
format->elf_format_source_order[0].string());
return {um};
return {std::move(um)};
}
static perform_result_t sources_action(const subcmd_format_t& sf)
@ -426,7 +426,7 @@ struct subcmd_format_t {
VC_ROLE.value(role_t::VCR_TEXT),
"\n"));
return {um};
return {std::move(um)};
}
static perform_result_t regex101_pull_action(const subcmd_format_t& sf)
@ -557,7 +557,7 @@ struct subcmd_format_t {
.string())));
}
return {um};
return {std::move(um)};
});
});
}
@ -590,7 +590,7 @@ struct subcmd_format_t {
sf.sf_regex101_app->get_subcommands({})
| lnav::itertools::fold(subcmd_reducer, attr_line_t{})));
return {um};
return {std::move(um)};
}
static perform_result_t regex101_push_action(const subcmd_format_t& sf)
@ -769,7 +769,7 @@ struct subcmd_piper_t {
| lnav::itertools::fold(
subcmd_reducer, attr_line_t{"the available operations are:"}));
return {um};
return {std::move(um)};
}
static perform_result_t list_action(const subcmd_piper_t&)
@ -892,7 +892,7 @@ struct subcmd_piper_t {
.append(lnav::roles::file(
lnav::piper::storage_path().string())))
.with_reason(ec.message());
return {um};
return {std::move(um)};
}
if (items.empty()) {
@ -909,7 +909,7 @@ struct subcmd_piper_t {
.append(" or using the ")
.append_quoted(lnav::roles::symbol(":sh"))
.append(" command"));
return {um};
return {std::move(um)};
}
return {};
@ -1049,7 +1049,7 @@ struct subcmd_regex101_t {
| lnav::itertools::fold(
subcmd_reducer, attr_line_t{"the available operations are:"}));
return {um};
return {std::move(um)};
}
static perform_result_t list_action(const subcmd_regex101_t&)
@ -1081,7 +1081,7 @@ struct subcmd_regex101_t {
entries.add_header("the following regex101 entries were found:\n")
.with_default("no regex101 entries found"));
return {um};
return {std::move(um)};
}
static perform_result_t import_action(const subcmd_regex101_t& sr)
@ -1135,7 +1135,7 @@ struct subcmd_crash_t {
| lnav::itertools::fold(
subcmd_reducer, attr_line_t{"the available operations are:"}));
return {um};
return {std::move(um)};
}
static perform_result_t upload_action(const subcmd_crash_t&)
@ -1150,11 +1150,11 @@ struct subcmd_crash_t {
auto glob_rc = glob(path.c_str(), 0, nullptr, gl.inout());
if (glob_rc == GLOB_NOMATCH) {
auto um = console::user_message::info("no crash logs to upload");
return {um};
return {std::move(um)};
}
if (glob_rc != 0) {
auto um = console::user_message::error("unable to find crash logs");
return {um};
return {std::move(um)};
}
for (size_t lpc = 0; lpc < gl->gl_pathc; lpc++) {
@ -1462,7 +1462,7 @@ perform(std::shared_ptr<operations> opts)
subcmd_reducer,
attr_line_t{"the available operations are:"}));
return {um};
return {std::move(um)};
},
[](const subcmd_config_t& sc) { return sc.sc_action(sc); },
[](const subcmd_format_t& sf) { return sf.sf_action(sf); },

View File

@ -1059,7 +1059,7 @@ com_mark_expr(exec_context& ec,
const char* errmsg = sqlite3_errmsg(lnav_data.ld_db);
auto expr_al = attr_line_t(expr).with_attr_for_all(
VC_ROLE.value(role_t::VCR_QUOTED_CODE));
readline_sqlite_highlighter(expr_al, -1);
readline_sqlite_highlighter(expr_al, std::nullopt);
auto um
= lnav::console::user_message::error(
attr_line_t("invalid mark expression: ").append(expr_al))
@ -2620,7 +2620,7 @@ com_filter_expr(exec_context& ec,
const char* errmsg = sqlite3_errmsg(lnav_data.ld_db);
auto expr_al = attr_line_t(expr).with_attr_for_all(
VC_ROLE.value(role_t::VCR_QUOTED_CODE));
readline_sqlite_highlighter(expr_al, -1);
readline_sqlite_highlighter(expr_al, std::nullopt);
auto um = lnav::console::user_message::error(
attr_line_t("invalid filter expression: ")
.append(expr_al))

View File

@ -466,7 +466,7 @@ install_extra_formats()
}
}
if (yajl_complete_parse(jhandle) != yajl_status_ok) {
auto* msg = yajl_get_error(jhandle, 1, buffer, rc);
auto* msg = yajl_get_error(jhandle, 0, nullptr, 0);
fprintf(stderr, "Unable to parse remote-config.json -- %s", msg);
yajl_free_error(jhandle, msg);

View File

@ -92,7 +92,7 @@ struct expressions : public lnav_config_listener {
.with_attr_for_all(SA_PREFORMATTED.value())
.with_attr_for_all(
VC_ROLE.value(role_t::VCR_QUOTED_CODE));
readline_sqlite_highlighter(sql_al, -1);
readline_sqlite_highlighter(sql_al, std::nullopt);
intern_string_t cond_expr_path = intern_string::lookup(
fmt::format(FMT_STRING("/log/annotations/{}/condition"),
pair.first));

View File

@ -81,7 +81,7 @@ struct expressions : public lnav_config_listener {
.with_attr_for_all(SA_PREFORMATTED.value())
.with_attr_for_all(
VC_ROLE.value(role_t::VCR_QUOTED_CODE));
readline_sqlite_highlighter(sql_al, -1);
readline_sqlite_highlighter(sql_al, std::nullopt);
intern_string_t watch_expr_path = intern_string::lookup(
fmt::format(FMT_STRING("/log/watch-expressions/{}/expr"),
pair.first));

View File

@ -2995,7 +2995,7 @@ external_log_format::build(std::vector<lnav::console::user_message>& errors)
.with_attr_for_all(SA_PREFORMATTED.value())
.with_attr_for_all(
VC_ROLE.value(role_t::VCR_QUOTED_CODE));
readline_sqlite_highlighter(sql_al, -1);
readline_sqlite_highlighter(sql_al, std::nullopt);
intern_string_t watch_expr_path = intern_string::lookup(
fmt::format(FMT_STRING("/{}/converter/header/expr/{}"),
this->elf_name,

View File

@ -1892,8 +1892,6 @@ logfile_sub_source::eval_sql_filter(sqlite3_stmt* stmt,
default:
return Err(sqlite3_error_to_user_message(sqlite3_db_handle(stmt)));
}
return Ok(true);
}
bool

View File

@ -159,7 +159,7 @@ format_sql_example(const char* sql_example_fmt)
const auto* format_name = lf->get_format()->get_name().get();
retval.with_ansi_string(sql_example_fmt, format_name, format_name);
readline_sqlite_highlighter(retval, 0);
readline_sqlite_highlighter(retval, std::nullopt);
}
return retval;
}

View File

@ -44,7 +44,8 @@
class attr_line_t;
struct exec_context;
using readline_highlighter_t = void (*)(attr_line_t& line, int x);
using readline_highlighter_t
= void (*)(attr_line_t& line, std::optional<int> x);
/**
* Container for information related to different readline contexts. Since

View File

@ -1472,6 +1472,8 @@ readline_curses::focus(int context,
char cwd[MAXPATHLEN + 1024];
char buffer[8 + sizeof(cwd)];
require(this->rc_contexts.count(context) > 0);
curs_set(1);
this->rc_active_context = context;

View File

@ -36,7 +36,6 @@
#include <exception>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <utility>
@ -54,8 +53,6 @@
#include "base/auto_fd.hh"
#include "base/enum_util.hh"
#include "base/func_util.hh"
#include "base/result.h"
#include "help_text_formatter.hh"
#include "log_format.hh"
#include "pollable.hh"
@ -100,7 +97,7 @@ public:
template<typename T,
typename... Args,
std::enable_if_t<std::is_enum<T>::value, bool> = true>
std::enable_if_t<std::is_enum_v<T>, bool> = true>
void add_context(T context, Args&... args)
{
this->add_context(lnav::enums::to_underlying(context), args...);
@ -161,7 +158,7 @@ public:
template<typename T,
typename... Args,
std::enable_if_t<std::is_enum<T>::value, bool> = true>
std::enable_if_t<std::is_enum_v<T>, bool> = true>
void focus(T context, const Args&... args)
{
this->focus(lnav::enums::to_underlying(context), args...);
@ -204,13 +201,13 @@ public:
template<typename T,
typename... Args,
std::enable_if_t<std::is_enum<T>::value, bool> = true>
std::enable_if_t<std::is_enum_v<T>, bool> = true>
void add_prefix(T context, const Args&... args)
{
this->add_prefix(lnav::enums::to_underlying(context), args...);
}
template<typename T, std::enable_if_t<std::is_enum<T>::value, bool> = true>
template<typename T, std::enable_if_t<std::is_enum_v<T>, bool> = true>
void clear_prefixes(T context)
{
this->clear_prefixes(lnav::enums::to_underlying(context));
@ -220,7 +217,7 @@ public:
const std::string& type,
const std::string& value);
void add_possibility(int context,
void add_possibility(const int context,
const std::string& type,
const char* values[])
{
@ -229,7 +226,7 @@ public:
}
}
void add_possibility(int context,
void add_possibility(const int context,
const std::string& type,
const char** first,
const char** last)
@ -256,7 +253,7 @@ public:
template<typename T,
typename... Args,
std::enable_if_t<std::is_enum<T>::value, bool> = true>
std::enable_if_t<std::is_enum_v<T>, bool> = true>
void add_possibility(T context, Args... args)
{
this->add_possibility(lnav::enums::to_underlying(context), args...);
@ -264,7 +261,7 @@ public:
template<typename T,
typename... Args,
std::enable_if_t<std::is_enum<T>::value, bool> = true>
std::enable_if_t<std::is_enum_v<T>, bool> = true>
void rem_possibility(T context, const Args&... args)
{
this->rem_possibility(lnav::enums::to_underlying(context), args...);
@ -272,7 +269,7 @@ public:
template<typename T,
typename... Args,
std::enable_if_t<std::is_enum<T>::value, bool> = true>
std::enable_if_t<std::is_enum_v<T>, bool> = true>
void clear_possibilities(T context, Args... args)
{
this->clear_possibilities(lnav::enums::to_underlying(context), args...);

View File

@ -57,7 +57,7 @@ static void
find_matching_bracket(
attr_line_t& al, int x, line_range sub, char left, char right)
{
bool is_lit = (left == 'Q');
const auto is_lit = left == 'Q';
attr_line_builder alb(al);
const auto& line = al.get_string();
int depth = 0;
@ -132,14 +132,16 @@ find_matching_bracket(
}
void
readline_regex_highlighter(attr_line_t& al, int x)
readline_regex_highlighter(attr_line_t& al, std::optional<int> x)
{
lnav::snippets::regex_highlighter(
al, x, line_range{1, (int) al.get_string().size()});
}
void
readline_command_highlighter_int(attr_line_t& al, int x, line_range sub)
readline_command_highlighter_int(attr_line_t& al,
std::optional<int> x,
line_range sub)
{
static const auto RE_PREFIXES = lnav::pcre2pp::code::from_const(
R"(^:(filter-in|filter-out|delete-filter|enable-filter|disable-filter|highlight|clear-highlight|create-search-table\s+[^\s]+\s+))");
@ -209,7 +211,9 @@ readline_command_highlighter_int(attr_line_t& al, int x, line_range sub)
(int) start, (int) last
};
if (lr.length() > 0 && !lr.contains(x) && !lr.contains(x - 1)) {
if (x && lr.length() > 0 && !lr.contains(x.value())
&& !lr.contains(x.value() - 1))
{
std::string value(lr.substr(line), lr.sublen(line));
if ((command == ":tag" || command == ":untag"
@ -227,21 +231,21 @@ readline_command_highlighter_int(attr_line_t& al, int x, line_range sub)
}
void
readline_command_highlighter(attr_line_t& al, int x)
readline_command_highlighter(attr_line_t& al, std::optional<int> x)
{
readline_command_highlighter_int(
al, x, line_range{0, (int) al.get_string().length()});
}
void
readline_sqlite_highlighter_int(attr_line_t& al, int x, line_range sub)
readline_sqlite_highlighter_int(attr_line_t& al,
std::optional<int> x,
line_range sub)
{
static const char* brackets[] = {
"[]",
"()",
"{}",
nullptr,
};
attr_line_builder alb(al);
@ -265,7 +269,9 @@ readline_sqlite_highlighter_int(attr_line_t& al, int x, line_range sub)
} else if (attr.sa_type == &SQL_IDENTIFIER_ATTR
|| attr.sa_type == &lnav::sql::PRQL_IDENTIFIER_ATTR)
{
if (!attr.sa_range.contains(x) && attr.sa_range.lr_end != x) {
if (x && !attr.sa_range.contains(x.value())
&& attr.sa_range.lr_end != x.value())
{
alb.overlay_attr(lr, VC_ROLE.value(role_t::VCR_IDENTIFIER));
}
} else if (attr.sa_type == &SQL_FUNCTION_ATTR) {
@ -298,20 +304,23 @@ readline_sqlite_highlighter_int(attr_line_t& al, int x, line_range sub)
}
}
for (int lpc = 0; brackets[lpc]; lpc++) {
find_matching_bracket(al, x, sub, brackets[lpc][0], brackets[lpc][1]);
for (const auto& bracket : brackets) {
find_matching_bracket(
al, x.value_or(al.length()), sub, bracket[0], bracket[1]);
}
}
void
readline_sqlite_highlighter(attr_line_t& al, int x)
readline_sqlite_highlighter(attr_line_t& al, std::optional<int> x)
{
readline_sqlite_highlighter_int(
al, x, line_range{0, (int) al.get_string().length()});
}
void
readline_shlex_highlighter_int(attr_line_t& al, int x, line_range sub)
readline_shlex_highlighter_int(attr_line_t& al,
std::optional<int> x,
line_range sub)
{
attr_line_builder alb(al);
const auto& str = al.get_string();
@ -397,14 +406,16 @@ readline_shlex_highlighter_int(attr_line_t& al, int x, line_range sub)
}
void
readline_shlex_highlighter(attr_line_t& al, int x)
readline_shlex_highlighter(attr_line_t& al, std::optional<int> x)
{
readline_shlex_highlighter_int(
al, x, line_range{0, (int) al.al_string.length()});
}
static void
readline_lnav_highlighter_int(attr_line_t& al, int x, line_range sub)
readline_lnav_highlighter_int(attr_line_t& al,
std::optional<int> x,
line_range sub)
{
switch (al.al_string[sub.lr_start]) {
case ':':
@ -432,7 +443,7 @@ readline_lnav_highlighter_int(attr_line_t& al, int x, line_range sub)
}
void
readline_lnav_highlighter(attr_line_t& al, int x)
readline_lnav_highlighter(attr_line_t& al, std::optional<int> x)
{
static const auto COMMENT_RE = lnav::pcre2pp::code::from_const(R"(^\s*#)");

View File

@ -34,16 +34,20 @@
#include "base/attr_line.hh"
void readline_regex_highlighter(attr_line_t& line, int x);
void readline_regex_highlighter(attr_line_t& line, std::optional<int> x);
void readline_command_highlighter(attr_line_t& line, int x);
void readline_command_highlighter(attr_line_t& line, std::optional<int> x);
void readline_sqlite_highlighter_int(attr_line_t& line, int x, line_range sub);
void readline_sqlite_highlighter(attr_line_t& line, int x);
void readline_sqlite_highlighter_int(attr_line_t& line,
std::optional<int> x,
line_range sub);
void readline_sqlite_highlighter(attr_line_t& line, std::optional<int> x);
void readline_shlex_highlighter_int(attr_line_t& al, int x, line_range sub);
void readline_shlex_highlighter(attr_line_t& line, int x);
void readline_shlex_highlighter_int(attr_line_t& al,
std::optional<int> x,
line_range sub);
void readline_shlex_highlighter(attr_line_t& line, std::optional<int> x);
void readline_lnav_highlighter(attr_line_t& line, int x);
void readline_lnav_highlighter(attr_line_t& line, std::optional<int> x);
#endif

View File

@ -51,7 +51,7 @@ void add_view_text_possibilities(readline_curses* rlc,
template<typename T,
typename... Args,
std::enable_if_t<std::is_enum<T>::value, bool> = true>
std::enable_if_t<std::is_enum_v<T>, bool> = true>
void
add_view_text_possibilities(readline_curses* rlc, T context, Args... args)
{
@ -65,7 +65,7 @@ void add_filter_expr_possibilities(readline_curses* rlc,
template<typename T,
typename... Args,
std::enable_if_t<std::is_enum<T>::value, bool> = true>
std::enable_if_t<std::is_enum_v<T>, bool> = true>
void
add_filter_expr_possibilities(readline_curses* rlc, T context, Args... args)
{

View File

@ -155,7 +155,7 @@ find_container_dir(std::filesystem::path file_path)
static std::string
replace_home_dir(std::string path)
{
auto home_dir_opt = getenv_opt("HOME");
const auto home_dir_opt = getenv_opt("HOME");
if (!home_dir_opt) {
return path;
@ -280,7 +280,7 @@ SELECT content_id, format, time_offset FROM lnav_file
continue;
}
auto file_path_str = name_pair.first;
const auto& file_path_str = name_pair.first;
auto file_path = std::filesystem::path(file_path_str);
auto container_path_opt = find_container_dir(file_path);
if (container_path_opt) {

View File

@ -961,7 +961,7 @@ load_session()
}
session_data = complete_res.unwrap();
bool log_changes = false, text_changes = false;
bool log_changes = false;
for (auto& lf : lnav_data.ld_active_files.fc_files) {
auto iter = session_data.sd_file_states.find(lf->get_filename());
@ -987,9 +987,6 @@ load_session()
if (log_changes) {
lnav_data.ld_log_source.text_filters_changed();
}
if (text_changes) {
lnav_data.ld_text_source.text_filters_changed();
}
};
lnav::events::publish(lnav_data.ld_db.in(),

View File

@ -1277,7 +1277,7 @@ textfile_sub_source::adjacent_anchor(vis_line_t vl, text_anchors::direction dir)
}
log_debug(" path for line: %s", fmt::to_string(path_for_line).c_str());
auto last_key = path_for_line.back();
const auto& last_key = path_for_line.back();
path_for_line.pop_back();
auto parent_opt = lnav::document::hier_node::lookup_path(

View File

@ -881,11 +881,10 @@ update_hits(textview_curses* tc)
lnav_data.ld_bottom_source.update_hits(tc);
if (lnav_data.ld_mode == ln_mode_t::SEARCH) {
const auto MAX_MATCH_COUNT = 10_vl;
constexpr auto MAX_MATCH_COUNT = 10_vl;
const auto PREVIEW_SIZE = MAX_MATCH_COUNT + 1_vl;
int preview_count = 0;
auto& bm = tc->get_bookmarks();
const auto& bv = bm[&textview_curses::BM_SEARCH];
auto vl = tc->get_top();
@ -917,9 +916,6 @@ update_hits(textview_curses* tc)
attr_line_t al;
tc->textview_value_for_row(prev_vl.value(), al);
if (preview_count > 0) {
all_matches.append("\n");
}
snprintf(linebuf,
sizeof(linebuf),
"L%*d: ",

View File

@ -202,7 +202,7 @@ struct json_path_handler_base {
struct enum_value_t {
template<typename T>
enum_value_t(const char* name, T value)
: first(name), second((unsigned int) value)
: first(name), second((int) value)
{
}

View File

@ -329,14 +329,14 @@ struct json_path_handler : public json_path_handler_base {
struct LastIsEnum<U T::*> {
using value_type = U;
static constexpr bool value = std::is_enum<U>::value;
static constexpr bool value = std::is_enum_v<U>;
};
template<typename T, typename U>
struct LastIsEnum<std::optional<U> T::*> {
using value_type = U;
static constexpr bool value = std::is_enum<U>::value;
static constexpr bool value = std::is_enum_v<U>;
};
template<typename T, typename... Args>
@ -347,13 +347,13 @@ struct json_path_handler : public json_path_handler_base {
template<typename T, typename U>
struct LastIsInteger<U T::*> {
static constexpr bool value
= std::is_integral<U>::value && !std::is_same<U, bool>::value;
= std::is_integral_v<U> && !std::is_same_v<U, bool>;
};
template<typename T, typename U>
struct LastIsInteger<std::optional<U> T::*> {
static constexpr bool value
= std::is_integral<U>::value && !std::is_same<U, bool>::value;
= std::is_integral_v<U> && !std::is_same_v<U, bool>;
};
template<typename T, typename... Args>
@ -363,12 +363,12 @@ struct json_path_handler : public json_path_handler_base {
template<typename T, typename U>
struct LastIsFloat<U T::*> {
static constexpr bool value = std::is_same<U, double>::value;
static constexpr bool value = std::is_same_v<U, double>;
};
template<typename T, typename U>
struct LastIsFloat<std::optional<U> T::*> {
static constexpr bool value = std::is_same<U, double>::value;
static constexpr bool value = std::is_same_v<U, double>;
};
template<typename T, typename... Args>
@ -405,7 +405,7 @@ struct json_path_handler : public json_path_handler_base {
struct LastIsIntegerVector<std::vector<U> T::*> {
using value_type = U;
static constexpr bool value
= std::is_integral<U>::value && !std::is_same<U, bool>::value;
= std::is_integral_v<U> && !std::is_same_v<U, bool>;
};
template<typename T, typename U>
@ -547,8 +547,8 @@ struct json_path_handler : public json_path_handler_base {
template<typename... Args,
std::enable_if_t<LastIsVector<Args...>::value, bool> = true,
std::enable_if_t<
!std::is_same<typename LastIsVector<Args...>::value_type,
std::string>::value
!std::is_same_v<typename LastIsVector<Args...>::value_type,
std::string>
&& !LastIsIntegerVector<Args...>::value,
bool>
= true>
@ -675,13 +675,13 @@ struct json_path_handler : public json_path_handler_base {
return *this;
}
template<typename... Args,
std::enable_if_t<LastIsMap<Args...>::value, bool> = true,
std::enable_if_t<
std::is_same<intern_string_t,
typename LastIsMap<Args...>::key_type>::value,
bool>
= true>
template<
typename... Args,
std::enable_if_t<LastIsMap<Args...>::value, bool> = true,
std::enable_if_t<std::is_same_v<intern_string_t,
typename LastIsMap<Args...>::key_type>,
bool>
= true>
json_path_handler& for_field(Args... args)
{
this->jph_path_provider =
@ -729,18 +729,15 @@ struct json_path_handler : public json_path_handler_base {
typename... Args,
std::enable_if_t<LastIsMap<Args...>::value, bool> = true,
std::enable_if_t<
std::is_same<std::string,
typename LastIsMap<Args...>::key_type>::value,
std::is_same_v<std::string, typename LastIsMap<Args...>::key_type>,
bool>
= true,
std::enable_if_t<
!std::is_same<json_any_t,
typename LastIsMap<Args...>::value_type>::value
&& !std::is_same<std::string,
typename LastIsMap<Args...>::value_type>::value
&& !std::is_same<
std::optional<std::string>,
typename LastIsMap<Args...>::value_type>::value,
!std::is_same_v<json_any_t, typename LastIsMap<Args...>::value_type>
&& !std::is_same_v<std::string,
typename LastIsMap<Args...>::value_type>
&& !std::is_same_v<std::optional<std::string>,
typename LastIsMap<Args...>::value_type>,
bool>
= true>
json_path_handler& for_field(Args... args)

View File

@ -1,4 +1,4 @@
✘ error: invalid filter expression: :sc_bytes # ff
✘ error: invalid filter expression: :sc_bytes # ff
reason: unrecognized token: "#"
 --> command-option:1
 | :filter-expr :sc_bytes # ff 

View File

@ -1933,7 +1933,7 @@ For support questions, email:
Example
#1 To cast the value 1.23 as an integer:
;SELECT CAST(1.23 AS INTEGER) 
;SELECT CAST(1.23 AS INTEGER) 
@ -2125,12 +2125,12 @@ For support questions, email:
total()
Examples
#1 To get the average of the column 'ex_duration' from the table 'lnav_example_log':
;SELECT avg(ex_duration) FROM lnav_example_log 
;SELECT avg(ex_duration) FROM lnav_example_log 
#2 To get the average of the column 'ex_duration' from the table 'lnav_example_log'
when grouped by 'ex_procname':
;SELECT ex_procname, avg(ex_duration) FROM lnav_example_log GROUP BY ex_procname
;SELECT ex_procname, avg(ex_duration) FROM lnav_example_log GROUP BY ex_procname
@ -2265,11 +2265,11 @@ For support questions, email:
Examples
#1 To get the count of the non-NULL rows of 'lnav_example_log':
;SELECT count(*) FROM lnav_example_log 
;SELECT count(*) FROM lnav_example_log 
#2 To get the count of the non-NULL values of 'log_part' from 'lnav_example_log':
;SELECT count(log_part) FROM lnav_example_log 
;SELECT count(log_part) FROM lnav_example_log 
@ -2574,7 +2574,7 @@ For support questions, email:
Example
#1 To read a file and raise an error if there is a problem:
;SELECT ifnull(data, raise_error('cannot read: ' || st_name, error)) FROM
;SELECT ifnull(data, raise_error('cannot read: ' || st_name, error)) FROM
 fstat('/non-existent')
@ -2592,15 +2592,15 @@ For support questions, email:
Examples
#1 To generate the numbers in the range [10, 14]:
;SELECT value FROM generate_series(10, 14) 
;SELECT value FROM generate_series(10, 14) 
#2 To generate every other number in the range [10, 14]:
;SELECT value FROM generate_series(10, 14, 2) 
;SELECT value FROM generate_series(10, 14, 2) 
#3 To count down from five to 1:
;SELECT value FROM generate_series(1, 5, -1) 
;SELECT value FROM generate_series(1, 5, -1) 
@ -2663,16 +2663,16 @@ For support questions, email:
Examples
#1 To concatenate the values of the column 'ex_procname' from the table
'lnav_example_log':
;SELECT group_concat(ex_procname) FROM lnav_example_log
;SELECT group_concat(ex_procname) FROM lnav_example_log
#2 To join the values of the column 'ex_procname' using the string ', ':
;SELECT group_concat(ex_procname, ', ') FROM lnav_example_log
;SELECT group_concat(ex_procname, ', ') FROM lnav_example_log
#3 To concatenate the distinct values of the column 'ex_procname' from the table
'lnav_example_log':
;SELECT group_concat(DISTINCT ex_procname) FROM lnav_example_log
;SELECT group_concat(DISTINCT ex_procname) FROM lnav_example_log
@ -2693,7 +2693,7 @@ For support questions, email:
unicode(), unparse_url(), upper(), xpath()
Example
#1 To produce a hash of all of the values of 'column1':
;SELECT group_spooky_hash(column1) FROM (VALUES ('abc'), ('123'))
;SELECT group_spooky_hash(column1) FROM (VALUES ('abc'), ('123'))
@ -3084,7 +3084,7 @@ For support questions, email:
#2 To create an array from a column of values:
;SELECT json_group_array(column1) FROM (VALUES (1), (2), (3))
;SELECT json_group_array(column1) FROM (VALUES (1), (2), (3))
@ -3106,7 +3106,7 @@ For support questions, email:
#2 To create an object from a pair of columns:
;SELECT json_group_object(column1, column2) FROM (VALUES ('a', 1), ('b', 2))
;SELECT json_group_object(column1, column2) FROM (VALUES ('a', 1), ('b', 2))
@ -3282,7 +3282,7 @@ For support questions, email:
yaml_to_json()
Example
#1 To iterate over an array:
;SELECT key,value,type,atom,fullkey,path FROM
;SELECT key,value,type,atom,fullkey,path FROM
 json_tree('[null,1,"two",{"three":4.5}]')
@ -3647,7 +3647,7 @@ For support questions, email:
#2 To get the largest value from an aggregate:
;SELECT max(status) FROM http_status_codes 
;SELECT max(status) FROM http_status_codes 
@ -3669,7 +3669,7 @@ For support questions, email:
#2 To get the smallest value from an aggregate:
;SELECT min(status) FROM http_status_codes 
;SELECT min(status) FROM http_status_codes 
@ -3985,7 +3985,7 @@ For support questions, email:
Example
#1 To raise an error if a variable is not set:
;SELECT ifnull($val, raise_error('please set $val', 'because'))
;SELECT ifnull($val, raise_error('please set $val', 'because'))
@ -4308,8 +4308,8 @@ For support questions, email:
nth_value(), ntile(), percent_rank(), rank()
Example
#1 To number messages from a process:
;SELECT row_number() OVER (PARTITION BY ex_procname ORDER BY log_line) AS msg_num,
 ex_procname, log_body FROM lnav_example_log
;SELECT row_number() OVER (PARTITION BY ex_procname ORDER BY log_line) AS msg_num,
 ex_procname, log_body FROM lnav_example_log
@ -4405,7 +4405,7 @@ For support questions, email:
#2 To chart the values in a JSON array:
;SELECT sparkline(value) FROM json_each('[0, 1, 2, 3, 4, 5, 6, 7, 8]')
;SELECT sparkline(value) FROM json_each('[0, 1, 2, 3, 4, 5, 6, 7, 8]')
@ -4628,7 +4628,7 @@ For support questions, email:
Example
#1 To sum all of the values in the column 'ex_duration' from the table
'lnav_example_log':
;SELECT sum(ex_duration) FROM lnav_example_log 
;SELECT sum(ex_duration) FROM lnav_example_log 
@ -4691,13 +4691,13 @@ For support questions, email:
#2 To group log messages into five minute buckets and count them:
;SELECT timeslice(log_time_msecs, '5m') AS slice, count(1)
  FROM lnav_example_log GROUP BY slice
;SELECT timeslice(log_time_msecs, '5m') AS slice, count(1)
  FROM lnav_example_log GROUP BY slice
#3 To group log messages by those before 4:30am and after:
;SELECT timeslice(log_time_msecs, 'before 4:30am') AS slice, count(1) FROM
 lnav_example_log GROUP BY slice
;SELECT timeslice(log_time_msecs, 'before 4:30am') AS slice, count(1) FROM
 lnav_example_log GROUP BY slice
@ -4738,7 +4738,7 @@ For support questions, email:
Example
#1 To total all of the values in the column 'ex_duration' from the table
'lnav_example_log':
;SELECT total(ex_duration) FROM lnav_example_log 
;SELECT total(ex_duration) FROM lnav_example_log 
@ -4942,7 +4942,7 @@ For support questions, email:
Example
#1 To attach the database file '/tmp/customers.db' with the name customers:
;ATTACH DATABASE '/tmp/customers.db' AS customers 
;ATTACH DATABASE '/tmp/customers.db' AS customers 
@ -4995,7 +4995,7 @@ For support questions, email:
Example
#1 To detach the database named 'customers':
;DETACH DATABASE customers 
;DETACH DATABASE customers 
@ -5013,7 +5013,7 @@ For support questions, email:
Example
#1 To insert the pair containing 'MSG' and 'HELLO, WORLD!' into the
'environ' table:
;INSERT INTO environ VALUES ('MSG', 'HELLO, WORLD!')
;INSERT INTO environ VALUES ('MSG', 'HELLO, WORLD!')
@ -5042,7 +5042,7 @@ For support questions, email:
Example
#1 To select all of the columns from the table 'syslog_log':
;SELECT * FROM syslog_log 
;SELECT * FROM syslog_log 
@ -5059,7 +5059,7 @@ For support questions, email:
Example
#1 To mark the syslog message at line 40:
;UPDATE syslog_log SET log_mark = 1 WHERE log_line = 40
;UPDATE syslog_log SET log_mark = 1 WHERE log_line = 40

View File

@ -1,4 +1,4 @@
✘ error: invalid mark expression: :log_procname lik
✘ error: invalid mark expression: :log_procname lik
reason: near "lik": syntax error
 --> command-option:1
 | :mark-expr :log_procname lik 

View File

@ -2,7 +2,7 @@
reason: SQL expression is invalid
 |  reason: no such column: sc_status
 |   --> /log/watch-expressions/http-errors/expr
 |   | sc_status >= 400 AND bad 
 |   | sc_status >= 400 AND bad 
 --> command-option:1
 = help: Property Synopsis
/log/watch-expressions/http-errors/expr <SQL-expression>

View File

@ -107,7 +107,7 @@
✘ error: SQL expression is invalid
reason: unrecognized token: "'foobar"
 --> /bad_file_format1/converter/header/expr/default
 | :header REGEXP 'foobar 
 | :header REGEXP 'foobar 
✘ error: A command is required when a converter is defined
 --> {test_dir}/bad-config/formats/invalid-file-format/format.json:3
 = help: The converter command transforms the file into a format that can be consumed by lnav

View File

@ -163,7 +163,6 @@ EOF
run_test ${lnav_test} -n \
-c ";SELECT * FROM access_log LIMIT 0" \
-c ':switch-to-view db' \
${test_dir}/logfile_access_log.0
check_output "output generated for empty result set?" <<EOF