1
1
mirror of https://github.com/tstack/lnav.git synced 2024-09-11 21:07:39 +03:00

[coverity] (more) use move to avoid auto copies

This commit is contained in:
Tim Stack 2024-06-14 09:07:48 -07:00
parent eed8f3871a
commit edc5bf171b
18 changed files with 240 additions and 163 deletions

View File

@ -152,10 +152,12 @@ breadcrumb_curses::reload_data()
} }
} }
auto matches = attr_line_t().join( auto matches = attr_line_t()
this->bc_similar_values .join(this->bc_similar_values
| lnav::itertools::map(&breadcrumb::possibility::p_display_value), | lnav::itertools::map(
"\n"); &breadcrumb::possibility::p_display_value),
"\n")
.move();
this->bc_match_source.replace_with(matches); this->bc_match_source.replace_with(matches);
auto width = this->bc_possible_values auto width = this->bc_possible_values
| lnav::itertools::fold( | lnav::itertools::fold(

View File

@ -293,7 +293,8 @@ sql_jget(sqlite3_context* context, int argc, sqlite3_value** argv)
err = yajl_get_error( err = yajl_get_error(
handle.in(), 1, json_in.udata(), json_in.length()); handle.in(), 1, json_in.udata(), json_in.length());
auto um = lnav::console::user_message::error("invalid JSON") auto um = lnav::console::user_message::error("invalid JSON")
.with_reason((const char*) err); .with_reason((const char*) err)
.move();
to_sqlite(context, um); to_sqlite(context, um);
yajl_free_error(handle.in(), err); yajl_free_error(handle.in(), err);
@ -318,7 +319,8 @@ sql_jget(sqlite3_context* context, int argc, sqlite3_value** argv)
err = yajl_get_error( err = yajl_get_error(
handle.in(), 1, json_in.udata(), json_in.length()); handle.in(), 1, json_in.udata(), json_in.length());
auto um = lnav::console::user_message::error("invalid JSON") auto um = lnav::console::user_message::error("invalid JSON")
.with_reason((const char*) err); .with_reason((const char*) err)
.move();
to_sqlite(context, um); to_sqlite(context, um);
yajl_free_error(handle.in(), err); yajl_free_error(handle.in(), err);

View File

@ -986,11 +986,11 @@ check_for_file_zones()
} }
} }
if (with_tz_count > 0 && !without_tz_files.empty()) { if (with_tz_count > 0 && !without_tz_files.empty()) {
auto note const auto note
= attr_line_t("The file(s) without a zone: ") = attr_line_t("The file(s) without a zone: ")
.join( .join(without_tz_files, VC_ROLE.value(role_t::VCR_FILE), ", ")
without_tz_files, VC_ROLE.value(role_t::VCR_FILE), ", "); .move();
auto um const auto um
= lnav::console::user_message::warning( = lnav::console::user_message::warning(
"Some messages may not be sorted by time correctly") "Some messages may not be sorted by time correctly")
.with_reason( .with_reason(
@ -1003,7 +1003,8 @@ check_for_file_zones()
.append(":set-file-timezone"_symbol) .append(":set-file-timezone"_symbol)
.append( .append(
" command to set the zone for messages in files " " command to set the zone for messages in files "
"that do not include a zone in the timestamp")); "that do not include a zone in the timestamp"))
.move();
lnav_data.ld_exec_context.ec_error_callback_stack.back()(um); lnav_data.ld_exec_context.ec_error_callback_stack.back()(um);
} }
@ -2644,7 +2645,8 @@ SELECT tbl_name FROM sqlite_master WHERE sql LIKE 'CREATE VIRTUAL TABLE%'
"definition " "definition "
"files to install in your lnav " "files to install in your lnav "
"configuration " "configuration "
"directory"); "directory")
.move();
const auto install_help const auto install_help
= attr_line_t( = attr_line_t(
"log format definitions are JSON files that " "log format definitions are JSON files that "
@ -2653,7 +2655,8 @@ SELECT tbl_name FROM sqlite_master WHERE sql LIKE 'CREATE VIRTUAL TABLE%'
.append( .append(
"See: " "See: "
"https://docs.lnav.org/en/latest/" "https://docs.lnav.org/en/latest/"
"formats.html"); "formats.html")
.move();
lnav::console::print(stderr, lnav::console::print(stderr,
lnav::console::user_message::error( lnav::console::user_message::error(
@ -2759,7 +2762,8 @@ SELECT tbl_name FROM sqlite_master WHERE sql LIKE 'CREATE VIRTUAL TABLE%'
auto um = lnav::console::user_message::error( auto um = lnav::console::user_message::error(
attr_line_t("cannot read file to install -- ") attr_line_t("cannot read file to install -- ")
.append(lnav::roles::file(file_path))) .append(lnav::roles::file(file_path)))
.with_reason(read_res.unwrap()); .with_reason(read_res.unwrap())
.move();
lnav::console::print(stderr, um); lnav::console::print(stderr, um);
return EXIT_FAILURE; return EXIT_FAILURE;
@ -2790,7 +2794,8 @@ SELECT tbl_name FROM sqlite_master WHERE sql LIKE 'CREATE VIRTUAL TABLE%'
auto um = lnav::console::user_message::error( auto um = lnav::console::user_message::error(
attr_line_t("failed to install file to -- ") attr_line_t("failed to install file to -- ")
.append(lnav::roles::file(dst_path))) .append(lnav::roles::file(dst_path)))
.with_reason(write_res.unwrapErr()); .with_reason(write_res.unwrapErr())
.move();
lnav::console::print(stderr, um); lnav::console::print(stderr, um);
return EXIT_FAILURE; return EXIT_FAILURE;

View File

@ -457,8 +457,8 @@ update_active_files(file_collection& new_files)
.with_help( .with_help(
attr_line_t("Use ") attr_line_t("Use ")
.append("ulimit -n"_quoted_code) .append("ulimit -n"_quoted_code)
.append( .append(" to increase the limit before running lnav"))
" to increase the limit before running lnav")); .move();
lnav_data.ld_exec_context.ec_error_callback_stack.back()(um); lnav_data.ld_exec_context.ec_error_callback_stack.back()(um);
} }

View File

@ -94,12 +94,15 @@ struct subcmd_config_t {
static perform_result_t default_action(const subcmd_config_t& sc) static perform_result_t default_action(const subcmd_config_t& sc)
{ {
auto um = console::user_message::error( auto um
"expecting an operation related to the regex101.com integration"); = console::user_message::error(
um.with_help( "expecting an operation related to the regex101.com "
sc.sc_config_app->get_subcommands({}) "integration")
| lnav::itertools::fold( .with_help(sc.sc_config_app->get_subcommands({})
subcmd_reducer, attr_line_t{"the available operations are:"})); | lnav::itertools::fold(
subcmd_reducer,
attr_line_t{"the available operations are:"}))
.move();
return {std::move(um)}; return {std::move(um)};
} }
@ -148,7 +151,8 @@ struct subcmd_config_t {
auto um = lnav::console::user_message::error( auto um = lnav::console::user_message::error(
attr_line_t("Unable to get full path for file: ") attr_line_t("Unable to get full path for file: ")
.append(lnav::roles::file(sc.sc_path))) .append(lnav::roles::file(sc.sc_path)))
.with_reason(realpath_res.unwrapErr()); .with_reason(realpath_res.unwrapErr())
.move();
return {std::move(um)}; return {std::move(um)};
} }
@ -176,7 +180,8 @@ struct subcmd_config_t {
.append(":set-file-timezone"_symbol) .append(":set-file-timezone"_symbol)
.append( .append(
" command to set the zone for messages in files " " command to set the zone for messages in files "
"that do not include a zone in the timestamp")); "that do not include a zone in the timestamp"))
.move();
return {std::move(um)}; return {std::move(um)};
} }
@ -212,33 +217,41 @@ struct subcmd_format_t {
const const
{ {
if (this->sf_name.empty()) { if (this->sf_name.empty()) {
auto um = console::user_message::error( auto um
"expecting a format name to operate on"); = console::user_message::error(
um.with_note( "expecting a format name to operate on")
(log_format::get_root_formats() .with_note(
| lnav::itertools::map(&log_format::get_name) (log_format::get_root_formats()
| lnav::itertools::sort_with(intern_string_t::case_lt) | lnav::itertools::map(&log_format::get_name)
| lnav::itertools::map(&intern_string_t::to_string) | lnav::itertools::sort_with(
| lnav::itertools::fold(symbol_reducer, attr_line_t{})) intern_string_t::case_lt)
.add_header("the available formats are: ") | lnav::itertools::map(&intern_string_t::to_string)
.wrap_with(&DEFAULT_WRAPPING)); | lnav::itertools::fold(symbol_reducer,
attr_line_t{}))
.add_header("the available formats are: ")
.wrap_with(&DEFAULT_WRAPPING))
.move();
return Err(um); return Err(um);
} }
auto lformat = log_format::find_root_format(this->sf_name.c_str()); auto lformat = log_format::find_root_format(this->sf_name.c_str());
if (lformat == nullptr) { if (lformat == nullptr) {
auto um = console::user_message::error( auto um
attr_line_t("unknown format: ") = console::user_message::error(
.append(lnav::roles::symbol(this->sf_name))); attr_line_t("unknown format: ")
um.with_note( .append(lnav::roles::symbol(this->sf_name)))
(log_format::get_root_formats() .with_note(
| lnav::itertools::map(&log_format::get_name) (log_format::get_root_formats()
| lnav::itertools::similar_to(this->sf_name) | lnav::itertools::map(&log_format::get_name)
| lnav::itertools::map(&intern_string_t::to_string) | lnav::itertools::similar_to(this->sf_name)
| lnav::itertools::fold(symbol_reducer, attr_line_t{})) | lnav::itertools::map(&intern_string_t::to_string)
.add_header("did you mean one of the following?\n") | lnav::itertools::fold(symbol_reducer,
.wrap_with(&DEFAULT_WRAPPING)); attr_line_t{}))
.add_header(
"did you mean one of the following?\n")
.wrap_with(&DEFAULT_WRAPPING))
.move();
return Err(um); return Err(um);
} }
@ -271,15 +284,18 @@ struct subcmd_format_t {
auto* ext_lformat = TRY(this->validate_external_format()); auto* ext_lformat = TRY(this->validate_external_format());
if (this->sf_regex_name.empty()) { if (this->sf_regex_name.empty()) {
auto um = console::user_message::error( auto um
"expecting a regex name to operate on"); = console::user_message::error(
um.with_note( "expecting a regex name to operate on")
ext_lformat->elf_pattern_order .with_note(
| lnav::itertools::map(&external_log_format::pattern::p_name) ext_lformat->elf_pattern_order
| lnav::itertools::map(&intern_string_t::to_string) | lnav::itertools::map(
| lnav::itertools::fold( &external_log_format::pattern::p_name)
symbol_reducer, | lnav::itertools::map(&intern_string_t::to_string)
attr_line_t{"the available regexes are: "})); | lnav::itertools::fold(
symbol_reducer,
attr_line_t{"the available regexes are: "}))
.move();
return Err(um); return Err(um);
} }
@ -290,16 +306,19 @@ struct subcmd_format_t {
} }
} }
auto um = console::user_message::error( auto um
attr_line_t("unknown regex: ") = console::user_message::error(
.append(lnav::roles::symbol(this->sf_regex_name))); attr_line_t("unknown regex: ")
um.with_note( .append(lnav::roles::symbol(this->sf_regex_name)))
(ext_lformat->elf_pattern_order .with_note(
| lnav::itertools::map(&external_log_format::pattern::p_name) (ext_lformat->elf_pattern_order
| lnav::itertools::map(&intern_string_t::to_string) | lnav::itertools::map(
| lnav::itertools::similar_to(this->sf_regex_name) &external_log_format::pattern::p_name)
| lnav::itertools::fold(symbol_reducer, attr_line_t{})) | lnav::itertools::map(&intern_string_t::to_string)
.add_header("did you mean one of the following?\n")); | lnav::itertools::similar_to(this->sf_regex_name)
| lnav::itertools::fold(symbol_reducer, attr_line_t{}))
.add_header("did you mean one of the following?\n"))
.move();
return Err(um); return Err(um);
} }
@ -327,19 +346,21 @@ struct subcmd_format_t {
", "); ", ");
} }
auto um = console::user_message::error( auto um
attr_line_t("expecting an operation to perform on the ") = console::user_message::error(
.append(lnav::roles::symbol(sf.sf_name)) attr_line_t("expecting an operation to perform on the ")
.append(" format")); .append(lnav::roles::symbol(sf.sf_name))
um.with_note(attr_line_t() .append(" format"))
.append(lnav::roles::symbol(sf.sf_name)) .with_note(attr_line_t()
.append(": ") .append(lnav::roles::symbol(sf.sf_name))
.append(lformat->lf_description) .append(": ")
.append(ext_details)); .append(lformat->lf_description)
um.with_help( .append(ext_details))
sf.sf_format_app->get_subcommands({}) .with_help(sf.sf_format_app->get_subcommands({})
| lnav::itertools::fold( | lnav::itertools::fold(
subcmd_reducer, attr_line_t{"the available operations are:"})); subcmd_reducer,
attr_line_t{"the available operations are:"}))
.move();
return {std::move(um)}; return {std::move(um)};
} }
@ -353,13 +374,15 @@ struct subcmd_format_t {
} }
auto um = console::user_message::error( auto um = console::user_message::error(
attr_line_t("expecting an operation to perform on the ") attr_line_t("expecting an operation to perform on the ")
.append(lnav::roles::symbol(sf.sf_regex_name)) .append(lnav::roles::symbol(sf.sf_regex_name))
.append(" regular expression")); .append(" regular expression"))
.with_help(
um.with_help(attr_line_t{"the available subcommands are:"}.append( attr_line_t{"the available subcommands are:"}.append(
sf.sf_regex_app->get_subcommands({}) sf.sf_regex_app->get_subcommands({})
| lnav::itertools::fold(subcmd_reducer, attr_line_t{}))); | lnav::itertools::fold(subcmd_reducer,
attr_line_t{})))
.move();
return {std::move(um)}; return {std::move(um)};
} }
@ -764,12 +787,14 @@ struct subcmd_piper_t {
static perform_result_t default_action(const subcmd_piper_t& sp) static perform_result_t default_action(const subcmd_piper_t& sp)
{ {
auto um = console::user_message::error( auto um
"expecting an operation related to piper storage"); = console::user_message::error(
um.with_help( "expecting an operation related to piper storage")
sp.sp_app->get_subcommands({}) .with_help(sp.sp_app->get_subcommands({})
| lnav::itertools::fold( | lnav::itertools::fold(
subcmd_reducer, attr_line_t{"the available operations are:"})); subcmd_reducer,
attr_line_t{"the available operations are:"}))
.move();
return {std::move(um)}; return {std::move(um)};
} }
@ -893,7 +918,8 @@ struct subcmd_piper_t {
attr_line_t("unable to access piper directory: ") attr_line_t("unable to access piper directory: ")
.append(lnav::roles::file( .append(lnav::roles::file(
lnav::piper::storage_path().string()))) lnav::piper::storage_path().string())))
.with_reason(ec.message()); .with_reason(ec.message())
.move();
return {std::move(um)}; return {std::move(um)};
} }
@ -910,7 +936,8 @@ struct subcmd_piper_t {
.append(lnav::roles::file("lnav")) .append(lnav::roles::file("lnav"))
.append(" or using the ") .append(" or using the ")
.append_quoted(lnav::roles::symbol(":sh")) .append_quoted(lnav::roles::symbol(":sh"))
.append(" command")); .append(" command"))
.move();
return {std::move(um)}; return {std::move(um)};
} }
@ -1000,7 +1027,8 @@ struct subcmd_piper_t {
"associated metadata.")) "associated metadata."))
.with_help( .with_help(
"You can reopen a capture by passing the piper URL " "You can reopen a capture by passing the piper URL "
"to lnav"); "to lnav")
.move();
retval.emplace_back(extra_um); retval.emplace_back(extra_um);
} }
retval.emplace_back(lnav::console::user_message::raw(txt)); retval.emplace_back(lnav::console::user_message::raw(txt));
@ -1044,12 +1072,15 @@ struct subcmd_regex101_t {
static perform_result_t default_action(const subcmd_regex101_t& sr) static perform_result_t default_action(const subcmd_regex101_t& sr)
{ {
auto um = console::user_message::error( auto um
"expecting an operation related to the regex101.com integration"); = console::user_message::error(
um.with_help( "expecting an operation related to the regex101.com "
sr.sr_app->get_subcommands({}) "integration")
| lnav::itertools::fold( .with_help(sr.sr_app->get_subcommands({})
subcmd_reducer, attr_line_t{"the available operations are:"})); | lnav::itertools::fold(
subcmd_reducer,
attr_line_t{"the available operations are:"}))
.move();
return {std::move(um)}; return {std::move(um)};
} }
@ -1130,12 +1161,14 @@ struct subcmd_crash_t {
static perform_result_t default_action(const subcmd_crash_t& sc) static perform_result_t default_action(const subcmd_crash_t& sc)
{ {
auto um = console::user_message::error( auto um
"expecting an operation related to crash logs"); = console::user_message::error(
um.with_help( "expecting an operation related to crash logs")
sc.sc_app->get_subcommands({}) .with_help(sc.sc_app->get_subcommands({})
| lnav::itertools::fold( | lnav::itertools::fold(
subcmd_reducer, attr_line_t{"the available operations are:"})); subcmd_reducer,
attr_line_t{"the available operations are:"}))
.move();
return {std::move(um)}; return {std::move(um)};
} }
@ -1458,11 +1491,13 @@ perform(std::shared_ptr<operations> opts)
return opts->o_ops.match( return opts->o_ops.match(
[](const no_subcmd_t& ns) -> perform_result_t { [](const no_subcmd_t& ns) -> perform_result_t {
auto um = console::user_message::error( auto um = console::user_message::error(
attr_line_t("expecting an operation to perform")); attr_line_t("expecting an operation to perform"))
um.with_help(ns.ns_root_app->get_subcommands({}) .with_help(
| lnav::itertools::fold( ns.ns_root_app->get_subcommands({})
subcmd_reducer, | lnav::itertools::fold(
attr_line_t{"the available operations are:"})); subcmd_reducer,
attr_line_t{"the available operations are:"}))
.move();
return {std::move(um)}; return {std::move(um)};
}, },

View File

@ -1061,8 +1061,10 @@ com_mark_expr(exec_context& ec,
#endif #endif
if (retcode != SQLITE_OK) { if (retcode != SQLITE_OK) {
const char* errmsg = sqlite3_errmsg(lnav_data.ld_db); const char* errmsg = sqlite3_errmsg(lnav_data.ld_db);
auto expr_al = attr_line_t(expr).with_attr_for_all( auto expr_al
VC_ROLE.value(role_t::VCR_QUOTED_CODE)); = attr_line_t(expr)
.with_attr_for_all(VC_ROLE.value(role_t::VCR_QUOTED_CODE))
.move();
readline_sqlite_highlighter(expr_al, std::nullopt); readline_sqlite_highlighter(expr_al, std::nullopt);
auto um auto um
= lnav::console::user_message::error( = lnav::console::user_message::error(
@ -2626,8 +2628,10 @@ com_filter_expr(exec_context& ec,
#endif #endif
if (retcode != SQLITE_OK) { if (retcode != SQLITE_OK) {
const char* errmsg = sqlite3_errmsg(lnav_data.ld_db); const char* errmsg = sqlite3_errmsg(lnav_data.ld_db);
auto expr_al = attr_line_t(expr).with_attr_for_all( auto expr_al
VC_ROLE.value(role_t::VCR_QUOTED_CODE)); = attr_line_t(expr)
.with_attr_for_all(VC_ROLE.value(role_t::VCR_QUOTED_CODE))
.move();
readline_sqlite_highlighter(expr_al, std::nullopt); readline_sqlite_highlighter(expr_al, std::nullopt);
auto um = lnav::console::user_message::error( auto um = lnav::console::user_message::error(
attr_line_t("invalid filter expression: ") attr_line_t("invalid filter expression: ")

View File

@ -279,7 +279,8 @@ install_from_git(const std::string& repo)
.with_reason( .with_reason(
attr_line_t("git failed to create the local directory ") attr_line_t("git failed to create the local directory ")
.append( .append(
lnav::roles::file(local_staging_path.string()))); lnav::roles::file(local_staging_path.string())))
.move();
lnav::console::print(stderr, um); lnav::console::print(stderr, um);
return false; return false;
} }
@ -330,7 +331,8 @@ install_from_git(const std::string& repo)
auto um = lnav::console::user_message::error( auto um = lnav::console::user_message::error(
attr_line_t("invalid lnav repo: ") attr_line_t("invalid lnav repo: ")
.append(lnav::roles::file(repo))) .append(lnav::roles::file(repo)))
.with_reason("no .json, .sql, or .lnav files were found"); .with_reason("no .json, .sql, or .lnav files were found")
.move();
lnav::console::print(stderr, um); lnav::console::print(stderr, um);
return false; return false;
} }
@ -364,7 +366,8 @@ install_from_git(const std::string& repo)
auto um = lnav::console::user_message::ok( auto um = lnav::console::user_message::ok(
attr_line_t("installed lnav repo at: ") attr_line_t("installed lnav repo at: ")
.append(lnav::roles::file(local_configs_path.string()))) .append(lnav::roles::file(local_configs_path.string())))
.with_note(notes); .with_note(notes)
.move();
lnav::console::print(stdout, um); lnav::console::print(stdout, um);
return true; return true;
@ -2056,7 +2059,8 @@ reload_config(std::vector<lnav::console::user_message>& errors)
um.um_message um.um_message
= attr_line_t() = attr_line_t()
.append("missing value for property ") .append("missing value for property ")
.append_quoted(lnav::roles::symbol(path)); .append_quoted(lnav::roles::symbol(path))
.move();
} }
errors.emplace_back(um); errors.emplace_back(um);

View File

@ -80,7 +80,8 @@ struct expressions : public lnav_config_listener {
auto sql_al = attr_line_t(pair.second.we_expr) auto sql_al = attr_line_t(pair.second.we_expr)
.with_attr_for_all(SA_PREFORMATTED.value()) .with_attr_for_all(SA_PREFORMATTED.value())
.with_attr_for_all( .with_attr_for_all(
VC_ROLE.value(role_t::VCR_QUOTED_CODE)); VC_ROLE.value(role_t::VCR_QUOTED_CODE))
.move();
readline_sqlite_highlighter(sql_al, std::nullopt); readline_sqlite_highlighter(sql_al, std::nullopt);
intern_string_t watch_expr_path = intern_string::lookup( intern_string_t watch_expr_path = intern_string::lookup(
fmt::format(FMT_STRING("/log/watch-expressions/{}/expr"), fmt::format(FMT_STRING("/log/watch-expressions/{}/expr"),
@ -91,7 +92,8 @@ struct expressions : public lnav_config_listener {
auto um = lnav::console::user_message::error( auto um = lnav::console::user_message::error(
"SQL expression is invalid") "SQL expression is invalid")
.with_reason(sqlite3_errmsg(lnav_db)) .with_reason(sqlite3_errmsg(lnav_db))
.with_snippet(snippet); .with_snippet(snippet)
.move();
reporter(&pair.second.we_expr, um); reporter(&pair.second.we_expr, um);
continue; continue;

View File

@ -1287,8 +1287,8 @@ load_format_file(const std::filesystem::path& filename,
.append( .append(
fmt::format(FMT_STRING(" \"$schema\": \"{}\","), fmt::format(FMT_STRING(" \"$schema\": \"{}\","),
*SUPPORTED_FORMAT_SCHEMAS.begin())) *SUPPORTED_FORMAT_SCHEMAS.begin()))
.with_attr_for_all( .with_attr_for_all(VC_ROLE.value(role_t::VCR_QUOTED_CODE))
VC_ROLE.value(role_t::VCR_QUOTED_CODE)); .move();
errors.emplace_back( errors.emplace_back(
lnav::console::user_message::warning( lnav::console::user_message::warning(
@ -1588,14 +1588,14 @@ static void
find_format_in_path(const std::filesystem::path& path, find_format_in_path(const std::filesystem::path& path,
available_scripts& scripts) available_scripts& scripts)
{ {
for (auto format_path : for (const auto& format_path :
{path / "formats/*/*.lnav", path / "configs/*/*.lnav"}) {path / "formats/*/*.lnav", path / "configs/*/*.lnav"})
{ {
static_root_mem<glob_t, globfree> gl; static_root_mem<glob_t, globfree> gl;
log_debug("Searching for script in path: %s", format_path.c_str()); log_debug("Searching for script in path: %s", format_path.c_str());
if (glob(format_path.c_str(), 0, nullptr, gl.inout()) == 0) { if (glob(format_path.c_str(), 0, nullptr, gl.inout()) == 0) {
for (int lpc = 0; lpc < (int) gl->gl_pathc; lpc++) { for (size_t lpc = 0; lpc < gl->gl_pathc; lpc++) {
const char* filename = basename(gl->gl_pathv[lpc]); const char* filename = basename(gl->gl_pathv[lpc]);
auto script_name = std::string(filename, strlen(filename) - 5); auto script_name = std::string(filename, strlen(filename) - 5);
struct script_metadata meta; struct script_metadata meta;
@ -1605,7 +1605,7 @@ find_format_in_path(const std::filesystem::path& path,
extract_metadata_from_file(meta); extract_metadata_from_file(meta);
scripts.as_scripts[script_name].push_back(meta); scripts.as_scripts[script_name].push_back(meta);
log_debug(" found script: %s", meta.sm_path.c_str()); log_info(" found script: %s", meta.sm_path.c_str());
} }
} }
} }

View File

@ -90,7 +90,8 @@ md2attr_line::flush_footnotes()
.append(lnav::roles::footnote_text( .append(lnav::roles::footnote_text(
fmt::format(FMT_STRING("[{}] - "), index))) fmt::format(FMT_STRING("[{}] - "), index)))
.append(foot.pad_to(longest_foot)) .append(foot.pad_to(longest_foot))
.with_attr_for_all(SA_PREFORMATTED.value()); .with_attr_for_all(SA_PREFORMATTED.value())
.move();
block_text.append(footline).append("\n"); block_text.append(footline).append("\n");
} }
@ -165,7 +166,8 @@ md2attr_line::leave_block(const md4cpp::event_handler::block& bl)
} else if (bl.is<block_hr>()) { } else if (bl.is<block_hr>()) {
block_text = attr_line_t() block_text = attr_line_t()
.append(lnav::roles::hr(repeat("\u2501", 70))) .append(lnav::roles::hr(repeat("\u2501", 70)))
.with_attr_for_all(SA_PREFORMATTED.value()); .with_attr_for_all(SA_PREFORMATTED.value())
.move();
last_block.append("\n").append(block_text).append("\n"); last_block.append("\n").append(block_text).append("\n");
} else if (bl.is<MD_BLOCK_UL_DETAIL*>() || bl.is<MD_BLOCK_OL_DETAIL*>()) { } else if (bl.is<MD_BLOCK_UL_DETAIL*>() || bl.is<MD_BLOCK_OL_DETAIL*>()) {
this->ml_list_stack.pop_back(); this->ml_list_stack.pop_back();
@ -287,7 +289,7 @@ md2attr_line::leave_block(const md4cpp::event_handler::block& bl)
new_block_text.append(line).append("\n"); new_block_text.append(line).append("\n");
} }
} }
block_text = new_block_text; block_text = new_block_text.move();
} }
auto code_lines = block_text.rtrim().split_lines(); auto code_lines = block_text.rtrim().split_lines();
@ -753,10 +755,11 @@ md2attr_line::to_attr_line(const pugi::xml_node& doc)
auto href auto href
= attr_line_t() = attr_line_t()
.append(lnav::roles::hyperlink(src_href.value())) .append(lnav::roles::hyperlink(src_href.value()))
.append(" "); .append(" ")
href.with_attr_for_all( .with_attr_for_all(
VC_ROLE.value(role_t::VCR_FOOTNOTE_TEXT)); VC_ROLE.value(role_t::VCR_FOOTNOTE_TEXT))
href.with_attr_for_all(SA_PREFORMATTED.value()); .with_attr_for_all(SA_PREFORMATTED.value())
.move();
this->ml_footnotes.emplace_back(href); this->ml_footnotes.emplace_back(href);
} else { } else {
retval.append(link_label); retval.append(link_label);
@ -1080,10 +1083,12 @@ md2attr_line::append_url_footnote(std::string href_str)
href_str = fmt::format(FMT_STRING("file://{}"), link_path.string()); href_str = fmt::format(FMT_STRING("file://{}"), link_path.string());
} }
auto href auto href = attr_line_t()
= attr_line_t().append(lnav::roles::hyperlink(href_str)).append(" "); .append(lnav::roles::hyperlink(href_str))
href.with_attr_for_all(VC_ROLE.value(role_t::VCR_FOOTNOTE_TEXT)); .append(" ")
href.with_attr_for_all(SA_PREFORMATTED.value()); .with_attr_for_all(VC_ROLE.value(role_t::VCR_FOOTNOTE_TEXT))
.with_attr_for_all(SA_PREFORMATTED.value())
.move();
this->ml_footnotes.emplace_back(href); this->ml_footnotes.emplace_back(href);
return href_str; return href_str;

View File

@ -749,8 +749,8 @@ cleanup()
{ {
(void) std::async(std::launch::async, []() { (void) std::async(std::launch::async, []() {
const auto& cfg = injector::get<const config&>(); const auto& cfg = injector::get<const config&>();
auto now = std::filesystem::file_time_type::clock::now(); const auto now = std::filesystem::file_time_type::clock::now();
auto cache_path = storage_path(); const auto& cache_path = storage_path();
std::vector<std::filesystem::path> to_remove; std::vector<std::filesystem::path> to_remove;
for (const auto& cache_subdir : for (const auto& cache_subdir :

View File

@ -514,9 +514,10 @@ rcjFilter(sqlite3_vtab_cursor* pVtabCursor,
flags_json); flags_json);
if (parse_res.isErr()) { if (parse_res.isErr()) {
auto um = lnav::console::user_message::error( const auto um = lnav::console::user_message::error(
"unable to parse flags") "unable to parse flags")
.with_reason(parse_res.unwrapErr()[0]); .with_reason(parse_res.unwrapErr()[0])
.move();
set_vtable_errmsg(pVtabCursor->pVtab, um); set_vtable_errmsg(pVtabCursor->pVtab, um);
return SQLITE_ERROR; return SQLITE_ERROR;

View File

@ -105,7 +105,8 @@ public:
std::vector<vis_line_t> fss_lines; std::vector<vis_line_t> fss_lines;
}; };
log_spectro_value_source::log_spectro_value_source(intern_string_t colname) log_spectro_value_source::
log_spectro_value_source(intern_string_t colname)
: lsvs_colname(colname) : lsvs_colname(colname)
{ {
this->update_stats(); this->update_stats();
@ -330,7 +331,8 @@ log_spectro_value_source::spectro_mark(textview_curses& tc,
} }
} }
db_spectro_value_source::db_spectro_value_source(std::string colname) db_spectro_value_source::
db_spectro_value_source(std::string colname)
: dsvs_colname(std::move(colname)) : dsvs_colname(std::move(colname))
{ {
this->update_stats(); this->update_stats();
@ -354,7 +356,8 @@ db_spectro_value_source::update_stats()
.append(" ") .append(" ")
.append("log_time"_variable) .append("log_time"_variable)
.append(" ") .append(" ")
.append("ASC"_keyword); .append("ASC"_keyword)
.move();
this->dsvs_error_msg this->dsvs_error_msg
= lnav::console::user_message::error( = lnav::console::user_message::error(
@ -378,7 +381,8 @@ db_spectro_value_source::update_stats()
.append_quoted(order_by_help) .append_quoted(order_by_help)
.append(" clause to your ") .append(" clause to your ")
.append("SELECT"_keyword) .append("SELECT"_keyword)
.append(" statement")); .append(" statement"))
.move();
} else { } else {
this->dsvs_error_msg this->dsvs_error_msg
= lnav::console::user_message::error( = lnav::console::user_message::error(
@ -400,7 +404,8 @@ db_spectro_value_source::update_stats()
.append(" statement. Use an ") .append(" statement. Use an ")
.append("AS"_keyword) .append("AS"_keyword)
.append( .append(
" directive to alias a computed timestamp")); " directive to alias a computed timestamp"))
.move();
} }
return; return;
} }
@ -412,7 +417,8 @@ db_spectro_value_source::update_stats()
.with_reason(attr_line_t("unknown column -- ") .with_reason(attr_line_t("unknown column -- ")
.append_quoted(lnav::roles::variable( .append_quoted(lnav::roles::variable(
this->dsvs_colname))) this->dsvs_colname)))
.with_help("Expecting a numeric column to visualize"); .with_help("Expecting a numeric column to visualize")
.move();
return; return;
} }
@ -424,7 +430,8 @@ db_spectro_value_source::update_stats()
.append_quoted(lnav::roles::variable( .append_quoted(lnav::roles::variable(
this->dsvs_colname)) this->dsvs_colname))
.append(" is not a numeric column")) .append(" is not a numeric column"))
.with_help("Only numeric columns can be visualized"); .with_help("Only numeric columns can be visualized")
.move();
return; return;
} }
@ -432,7 +439,8 @@ db_spectro_value_source::update_stats()
this->dsvs_error_msg this->dsvs_error_msg
= lnav::console::user_message::error( = lnav::console::user_message::error(
"Cannot generate spectrogram for database results") "Cannot generate spectrogram for database results")
.with_reason("Result set is empty"); .with_reason("Result set is empty")
.move();
return; return;
} }

View File

@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#include <filesystem>
#include <map> #include <map>
#include "static_file_vtab.hh" #include "static_file_vtab.hh"
@ -37,7 +38,6 @@
#include "base/fs_util.hh" #include "base/fs_util.hh"
#include "base/lnav_log.hh" #include "base/lnav_log.hh"
#include "config.h" #include "config.h"
#include <filesystem>
#include "lnav.hh" #include "lnav.hh"
#include "vtab_module.hh" #include "vtab_module.hh"
@ -232,7 +232,8 @@ sfvt_column(sqlite3_vtab_cursor* cur, sqlite3_context* ctx, int col)
if (read_res.isErr()) { if (read_res.isErr()) {
auto um = lnav::console::user_message::error( auto um = lnav::console::user_message::error(
"unable to read static file") "unable to read static file")
.with_reason(read_res.unwrapErr()); .with_reason(read_res.unwrapErr())
.move();
to_sqlite(ctx, um); to_sqlite(ctx, um);
} else { } else {

View File

@ -79,7 +79,8 @@ text_overlay_menu::list_overlay_menu(const listview_curses& lv, vis_line_t row)
= attr_line_t(" Link: ") = attr_line_t(" Link: ")
.append(lnav::roles::table_header(sti.sti_href)) .append(lnav::roles::table_header(sti.sti_href))
.with_attr_for_all(VC_ROLE.value(role_t::VCR_STATUS_INFO)) .with_attr_for_all(VC_ROLE.value(role_t::VCR_STATUS_INFO))
.with_attr_for_all(VC_STYLE.value(ta)); .with_attr_for_all(VC_STYLE.value(ta))
.move();
retval.emplace_back(href_al); retval.emplace_back(href_al);
menu_line += 1_vl; menu_line += 1_vl;
} }

View File

@ -1056,16 +1056,16 @@ execute_examples()
auto old_width = dls.dls_max_column_width; auto old_width = dls.dls_max_column_width;
dls.dls_max_column_width = 15; dls.dls_max_column_width = 15;
for (auto help_pair : sqlite_function_help) { for (const auto& help_pair : sqlite_function_help) {
execute_example(*help_pair.second); execute_example(*help_pair.second);
} }
for (auto help_pair : lnav::sql::prql_functions) { for (const auto& help_pair : lnav::sql::prql_functions) {
if (help_pair.second->ht_context != help_context_t::HC_PRQL_FUNCTION) { if (help_pair.second->ht_context != help_context_t::HC_PRQL_FUNCTION) {
continue; continue;
} }
execute_example(*help_pair.second); execute_example(*help_pair.second);
} }
for (auto cmd_pair : *sql_cmd_map) { for (const auto& cmd_pair : *sql_cmd_map) {
if (cmd_pair.second->c_help.ht_context if (cmd_pair.second->c_help.ht_context
!= help_context_t::HC_PRQL_TRANSFORM != help_context_t::HC_PRQL_TRANSFORM
&& cmd_pair.second->c_help.ht_context && cmd_pair.second->c_help.ht_context

View File

@ -588,7 +588,8 @@ CREATE TABLE lnav_views (
.append(" value")) .append(" value"))
.with_reason( .with_reason(
attr_line_t("Unrecognized time value: ") attr_line_t("Unrecognized time value: ")
.append(lnav::roles::string(top_time))); .append(lnav::roles::string(top_time)))
.move();
set_vtable_errmsg(tab, um); set_vtable_errmsg(tab, um);
return SQLITE_ERROR; return SQLITE_ERROR;
} }
@ -620,7 +621,8 @@ CREATE TABLE lnav_views (
.append(" value")) .append(" value"))
.with_reason(attr_line_t("Unknown text file: ") .with_reason(attr_line_t("Unknown text file: ")
.append(lnav::roles::file( .append(lnav::roles::file(
tlm.tlm_file.value()))); tlm.tlm_file.value())))
.move();
set_vtable_errmsg(tab, um); set_vtable_errmsg(tab, um);
return SQLITE_ERROR; return SQLITE_ERROR;
} }
@ -646,7 +648,8 @@ CREATE TABLE lnav_views (
.append(" value")) .append(" value"))
.with_reason( .with_reason(
attr_line_t("Unknown anchor: ") attr_line_t("Unknown anchor: ")
.append(lnav::roles::symbol(req_anchor))); .append(lnav::roles::symbol(req_anchor)))
.move();
set_vtable_errmsg(tab, um); set_vtable_errmsg(tab, um);
return SQLITE_ERROR; return SQLITE_ERROR;
} }

View File

@ -317,7 +317,8 @@ rcFilter(sqlite3_vtab_cursor* pVtabCursor,
auto attr_xmldoc auto attr_xmldoc
= attr_line_t(pCur->c_value) = attr_line_t(pCur->c_value)
.with_attr_for_all(VC_ROLE.value(role_t::VCR_QUOTED_CODE)); .with_attr_for_all(VC_ROLE.value(role_t::VCR_QUOTED_CODE))
.move();
auto um = lnav::console::user_message::error("Invalid XML document") auto um = lnav::console::user_message::error("Invalid XML document")
.with_reason(parse_res.description()) .with_reason(parse_res.description())
.with_snippet( .with_snippet(
@ -325,7 +326,8 @@ rcFilter(sqlite3_vtab_cursor* pVtabCursor,
ARG1, ARG1,
attr_xmldoc, attr_xmldoc,
parse_res.offset, parse_res.offset,
parse_res.description())); parse_res.description()))
.move();
set_vtable_errmsg(pVtabCursor->pVtab, um); set_vtable_errmsg(pVtabCursor->pVtab, um);
return SQLITE_ERROR; return SQLITE_ERROR;
} }
@ -338,12 +340,14 @@ rcFilter(sqlite3_vtab_cursor* pVtabCursor,
const auto& res = pCur->c_query.result(); const auto& res = pCur->c_query.result();
auto attr_xpath auto attr_xpath
= attr_line_t(pCur->c_xpath) = attr_line_t(pCur->c_xpath)
.with_attr_for_all(VC_ROLE.value(role_t::VCR_QUOTED_CODE)); .with_attr_for_all(VC_ROLE.value(role_t::VCR_QUOTED_CODE))
.move();
auto um = lnav::console::user_message::error("Invalid XPath expression") auto um = lnav::console::user_message::error("Invalid XPath expression")
.with_reason(res.description()) .with_reason(res.description())
.with_snippet( .with_snippet(
lnav::console::snippet::from_content_with_offset( lnav::console::snippet::from_content_with_offset(
ARG0, attr_xpath, res.offset, res.description())); ARG0, attr_xpath, res.offset, res.description()))
.move();
set_vtable_errmsg(pVtabCursor->pVtab, um); set_vtable_errmsg(pVtabCursor->pVtab, um);
return SQLITE_ERROR; return SQLITE_ERROR;
} }