From b856cd9657d520c8813f475377d87b7b2342708e Mon Sep 17 00:00:00 2001 From: Timothy Stack Date: Mon, 28 Mar 2022 22:00:49 -0700 Subject: [PATCH] [build] silence some warnings --- src/archive_manager.cc | 36 ++++++++++-------- src/base/auto_pid.cc | 3 +- src/base/fs_util.cc | 7 ++-- src/base/humanize.time.cc | 4 +- src/base/lnav.gzip.cc | 17 +++++---- src/base/network.tcp.cc | 4 +- src/base/paths.cc | 2 +- src/command_executor.cc | 3 +- src/field_overlay_source.cc | 6 +-- src/file_collection.cc | 4 +- src/file_vtab.cc | 11 ++++-- src/files_sub_source.cc | 72 +++++++++++++++++------------------ src/filter_sub_source.cc | 6 ++- src/help_text_formatter.cc | 4 +- src/line_buffer.cc | 4 +- src/lnav.cc | 6 ++- src/lnav_commands.cc | 17 +++++---- src/lnav_config.cc | 33 ++++++++-------- src/log_actions.cc | 5 ++- src/log_data_helper.cc | 10 +++-- src/log_format.cc | 18 ++++----- src/log_format_loader.cc | 45 ++++++++++++---------- src/log_vtab_impl.cc | 10 +++-- src/logfile.cc | 20 ++++++---- src/logfile_sub_source.cc | 7 ++-- src/logfile_sub_source.hh | 4 +- src/readline_callbacks.cc | 2 +- src/readline_curses.cc | 5 ++- src/readline_possibilities.cc | 2 +- src/styling.cc | 9 +++-- src/sysclip.cc | 8 ++-- src/tailer/tailer.looper.cc | 48 +++++++++++++---------- src/tailer/tailer.main.c | 32 ++++++++++++---- src/tailer/tailerpp.hh | 25 ++++++------ src/textview_curses.cc | 7 ++-- src/textview_curses.hh | 4 +- src/views_vtab.cc | 5 ++- src/vtab_module.hh | 2 +- src/xml_util.cc | 4 +- src/yajlpp/yajlpp.cc | 53 +++++++++++++++----------- test/scripty.cc | 2 +- 41 files changed, 317 insertions(+), 249 deletions(-) diff --git a/src/archive_manager.cc b/src/archive_manager.cc index b7344a7e..a80df201 100644 --- a/src/archive_manager.cc +++ b/src/archive_manager.cc @@ -193,7 +193,7 @@ filename_to_tmp_path(const std::string& filename) h.update(buffer, rc); } } - basename = fmt::format("arc-{}-{}", h.to_string(), basename); + basename = fmt::format(FMT_STRING("arc-{}-{}"), h.to_string(), basename); return archive_cache_path() / basename; } @@ -235,14 +235,15 @@ copy_data(const std::string& filename, return Ok(); } if (r != ARCHIVE_OK) { - return Err(fmt::format("failed to read file: {} >> {} -- {}", - filename, - archive_entry_pathname_utf8(entry), - archive_error_string(ar))); + return Err( + fmt::format(FMT_STRING("failed to read file: {} >> {} -- {}"), + filename, + archive_entry_pathname_utf8(entry), + archive_error_string(ar))); } r = archive_write_data_block(aw, buff, size, offset); if (r != ARCHIVE_OK) { - return Err(fmt::format("failed to write file: {} -- {}", + return Err(fmt::format(FMT_STRING("failed to write file: {} -- {}"), entry_path.string(), archive_error_string(aw))); } @@ -298,7 +299,7 @@ extract(const std::string& filename, const extract_cb& cb) archive_write_disk_set_standard_lookup(ext); if (archive_read_open_filename(arc, filename.c_str(), 10240) != ARCHIVE_OK) { - return Err(fmt::format("unable to open archive: {} -- {}", + return Err(fmt::format(FMT_STRING("unable to open archive: {} -- {}"), filename, archive_error_string(arc))); } @@ -312,9 +313,10 @@ extract(const std::string& filename, const extract_cb& cb) break; } if (r != ARCHIVE_OK) { - return Err(fmt::format("unable to read entry header: {} -- {}", - filename, - archive_error_string(arc))); + return Err( + fmt::format(FMT_STRING("unable to read entry header: {} -- {}"), + filename, + archive_error_string(arc))); } auto format_name = archive_format_name(arc); @@ -337,18 +339,20 @@ extract(const std::string& filename, const extract_cb& cb) wentry, S_IRUSR | (S_ISDIR(entry_mode) ? S_IXUSR | S_IWUSR : 0)); r = archive_write_header(ext, wentry); if (r < ARCHIVE_OK) { - return Err(fmt::format("unable to write entry: {} -- {}", - entry_path.string(), - archive_error_string(ext))); + return Err( + fmt::format(FMT_STRING("unable to write entry: {} -- {}"), + entry_path.string(), + archive_error_string(ext))); } else if (!archive_entry_size_is_set(entry) || archive_entry_size(entry) > 0) { TRY(copy_data(filename, arc, entry, ext, entry_path, prog)); } r = archive_write_finish_entry(ext); if (r != ARCHIVE_OK) { - return Err(fmt::format("unable to finish entry: {} -- {}", - entry_path.string(), - archive_error_string(ext))); + return Err( + fmt::format(FMT_STRING("unable to finish entry: {} -- {}"), + entry_path.string(), + archive_error_string(ext))); } } archive_read_close(arc); diff --git a/src/base/auto_pid.cc b/src/base/auto_pid.cc index 300a4741..27016192 100644 --- a/src/base/auto_pid.cc +++ b/src/base/auto_pid.cc @@ -43,7 +43,8 @@ from_fork() auto pid = ::fork(); if (pid == -1) { - return Err(fmt::format("fork() failed: {}", strerror(errno))); + return Err( + fmt::format(FMT_STRING("fork() failed: {}"), strerror(errno))); } if (pid != 0) { diff --git a/src/base/fs_util.cc b/src/base/fs_util.cc index 1136f028..d12d24ae 100644 --- a/src/base/fs_util.cc +++ b/src/base/fs_util.cc @@ -45,9 +45,10 @@ open_temp_file(const ghc::filesystem::path& pattern) strcpy(pattern_copy, pattern_str.c_str()); if ((fd = mkstemp(pattern_copy)) == -1) { - return Err(fmt::format("unable to create temporary file: {} -- {}", - pattern.string(), - strerror(errno))); + return Err( + fmt::format(FMT_STRING("unable to create temporary file: {} -- {}"), + pattern.string(), + strerror(errno))); } return Ok(std::make_pair(ghc::filesystem::path(pattern_copy), fd)); diff --git a/src/base/humanize.time.cc b/src/base/humanize.time.cc index 6a56f3d7..e9a35de4 100644 --- a/src/base/humanize.time.cc +++ b/src/base/humanize.time.cc @@ -109,13 +109,13 @@ point::as_precise_time_ago() const return "a second ago"; } else if (diff.tv_sec < (10 * 60)) { if (diff.tv_sec < 60) { - return fmt::format("{:2} seconds ago", diff.tv_sec); + return fmt::format(FMT_STRING("{:2} seconds ago"), diff.tv_sec); } time_t seconds = diff.tv_sec % 60; time_t minutes = diff.tv_sec / 60; - return fmt::format("{:2} minute{} and {:2} second{} ago", + return fmt::format(FMT_STRING("{:2} minute{} and {:2} second{} ago"), minutes, minutes > 1 ? "s" : "", seconds, diff --git a/src/base/lnav.gzip.cc b/src/base/lnav.gzip.cc index 1413bace..baa5d8d9 100644 --- a/src/base/lnav.gzip.cc +++ b/src/base/lnav.gzip.cc @@ -62,17 +62,18 @@ compress(const void* input, size_t len) auto rc = deflateInit2( &zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 15 | 16, 8, Z_DEFAULT_STRATEGY); if (rc != Z_OK) { - return Err( - fmt::format("unable to initialize compressor -- {}", zError(rc))); + return Err(fmt::format( + FMT_STRING("unable to initialize compressor -- {}"), zError(rc))); } rc = deflate(&zs, Z_FINISH); if (rc != Z_STREAM_END) { - return Err(fmt::format("unable to compress data -- {}", zError(rc))); + return Err(fmt::format(FMT_STRING("unable to compress data -- {}"), + zError(rc))); } rc = deflateEnd(&zs); if (rc != Z_OK) { - return Err( - fmt::format("unable to finalize compression -- {}", zError(rc))); + return Err(fmt::format( + FMT_STRING("unable to finalize compression -- {}"), zError(rc))); } return Ok(std::move(retval.shrink_to(zs.total_out))); } @@ -91,7 +92,7 @@ uncompress(const std::string& src, const void* buffer, size_t size) strm.zfree = Z_NULL; if ((err = inflateInit2(&strm, (16 + MAX_WBITS))) != Z_OK) { - return Err(fmt::format("invalid gzip data: {} -- {}", + return Err(fmt::format(FMT_STRING("invalid gzip data: {} -- {}"), src, strm.msg ? strm.msg : zError(err))); } @@ -112,14 +113,14 @@ uncompress(const std::string& src, const void* buffer, size_t size) done = true; } else if (err != Z_OK) { inflateEnd(&strm); - return Err(fmt::format("unable to uncompress: {} -- {}", + return Err(fmt::format(FMT_STRING("unable to uncompress: {} -- {}"), src, strm.msg ? strm.msg : zError(err))); } } if (inflateEnd(&strm) != Z_OK) { - return Err(fmt::format("unable to uncompress: {} -- {}", + return Err(fmt::format(FMT_STRING("unable to uncompress: {} -- {}"), src, strm.msg ? strm.msg : zError(err))); } diff --git a/src/base/network.tcp.cc b/src/base/network.tcp.cc index 6a0ed08e..5eede974 100644 --- a/src/base/network.tcp.cc +++ b/src/base/network.tcp.cc @@ -50,7 +50,7 @@ connect(const char* hostname, const char* servname) auto rc = getaddrinfo(hostname, servname, &hints, &ai); if (rc != 0) { - return Err(fmt::format("unable to resolve {}:{} -- {}", + return Err(fmt::format(FMT_STRING("unable to resolve {}:{} -- {}"), hostname, servname, gai_strerror(rc))); @@ -60,7 +60,7 @@ connect(const char* hostname, const char* servname) rc = ::connect(retval, ai->ai_addr, ai->ai_addrlen); if (rc != 0) { - return Err(fmt::format("unable to connect to {}:{} -- {}", + return Err(fmt::format(FMT_STRING("unable to connect to {}:{} -- {}"), hostname, servname, strerror(rc))); diff --git a/src/base/paths.cc b/src/base/paths.cc index 159f4edd..ca53a070 100644 --- a/src/base/paths.cc +++ b/src/base/paths.cc @@ -120,7 +120,7 @@ dotlnav() ghc::filesystem::path workdir() { - auto subdir_name = fmt::format("lnav-user-{}-work", getuid()); + auto subdir_name = fmt::format(FMT_STRING("lnav-user-{}-work"), getuid()); auto tmp_path = ghc::filesystem::temp_directory_path(); return tmp_path / ghc::filesystem::path(subdir_name); diff --git a/src/command_executor.cc b/src/command_executor.cc index 157c91b8..0282601a 100644 --- a/src/command_executor.cc +++ b/src/command_executor.cc @@ -862,7 +862,8 @@ exec_context::get_error_prefix() std::pair source = this->ec_source.top(); - return fmt::format("{}:{}: error: ", source.first, source.second); + return fmt::format( + FMT_STRING("{}:{}: error: "), source.first, source.second); } void diff --git a/src/field_overlay_source.cc b/src/field_overlay_source.cc index 4b308876..7084f92c 100644 --- a/src/field_overlay_source.cc +++ b/src/field_overlay_source.cc @@ -232,7 +232,7 @@ field_overlay_source::build_field_lines(const listview_curses& lv) continue; } - auto emsg = fmt::format(" Invalid log message: {}", + auto emsg = fmt::format(FMT_STRING(" Invalid log message: {}"), (const char*) sattr.sa_value.sav_ptr); auto al = attr_line_t(emsg) .with_attr(string_attr(line_range{1, 2}, @@ -518,7 +518,7 @@ field_overlay_source::build_field_lines(const listview_curses& lv) xp_call = sqlite3_mprintf( "xpath(%Q, %s)", xml_pair.first.second.c_str(), qname.in()); this->fos_lines.emplace_back( - fmt::format(" {} = {}", xp_call, xml_pair.second)); + fmt::format(FMT_STRING(" {} = {}"), xp_call, xml_pair.second)); this->add_key_line_attrs(0); } @@ -551,7 +551,7 @@ field_overlay_source::build_field_lines(const listview_curses& lv) auto& name = this->fos_log_helper.ldh_namer->cn_names[lpc]; auto val = this->fos_log_helper.ldh_parser->get_element_string( iter->e_sub_elements->back()); - attr_line_t al(fmt::format(" {} = {}", name, val)); + attr_line_t al(fmt::format(FMT_STRING(" {} = {}"), name, val)); al.with_attr(string_attr(line_range(3, 3 + name.length()), &view_curses::VC_STYLE, diff --git a/src/file_collection.cc b/src/file_collection.cc index 77efef09..c33c1b01 100644 --- a/src/file_collection.cc +++ b/src/file_collection.cc @@ -337,7 +337,7 @@ file_collection::watch_logfile(const std::string& filename, file_error_info{ st.st_mtime, fmt::format( - "{}", + FMT_STRING("{}"), fmt::join(*error_queue, "\n")), }); }, @@ -519,7 +519,7 @@ file_collection::expand_filename( retval.fc_other_files[path] = file_format_t::REMOTE; { this->fc_progress->writeAccess() - ->sp_tailers[fmt::format("{}", rp.home())] + ->sp_tailers[fmt::to_string(rp.home())] .tp_message = "Initializing..."; } diff --git a/src/file_vtab.cc b/src/file_vtab.cc index fb888ffd..c71051eb 100644 --- a/src/file_vtab.cc +++ b/src/file_vtab.cc @@ -94,7 +94,7 @@ CREATE TABLE lnav_file ( to_sqlite(ctx, name); break; case 3: - to_sqlite(ctx, fmt::format("{}", lf->get_text_format())); + to_sqlite(ctx, fmt::to_string(lf->get_text_format())); break; case 4: to_sqlite(ctx, format_name); @@ -122,14 +122,17 @@ CREATE TABLE lnav_file ( auto rc = pread(fd, buf, lf_stat.st_size, 0); if (rc == -1) { - auto errmsg = fmt::format("unable to read file: {}", - strerror(errno)); + auto errmsg + = fmt::format(FMT_STRING("unable to read file: {}"), + strerror(errno)); sqlite3_result_error( ctx, errmsg.c_str(), errmsg.length()); } else if (rc != lf_stat.st_size) { auto errmsg = fmt::format( - "short read of file: {} < {}", rc, lf_stat.st_size); + FMT_STRING("short read of file: {} < {}"), + rc, + lf_stat.st_size); sqlite3_result_error( ctx, errmsg.c_str(), errmsg.length()); diff --git a/src/files_sub_source.cc b/src/files_sub_source.cc index a732eaac..c2b95b3f 100644 --- a/src/files_sub_source.cc +++ b/src/files_sub_source.cc @@ -159,42 +159,42 @@ files_sub_source::list_input_handle_key(listview_curses& lv, int ch) case 'X': { auto sel = files_model::from_selection(lv.get_selection()); - sel.match([](files_model::no_selection) {}, - [&](files_model::error_selection& es) { - auto& fc = lnav_data.ld_active_files; - - fc.fc_file_names.erase(es.sb_iter->first); - - auto name_iter = fc.fc_file_names.begin(); - while (name_iter != fc.fc_file_names.end()) { - if (name_iter->first == es.sb_iter->first) { - name_iter = fc.fc_file_names.erase(name_iter); - continue; - } - - auto rp_opt = humanize::network::path::from_str( - name_iter->first); - - if (rp_opt) { - auto rp = *rp_opt; - - if (fmt::format("{}", rp.home()) - == es.sb_iter->first) { - fc.fc_other_files.erase(name_iter->first); - name_iter - = fc.fc_file_names.erase(name_iter); - continue; - } - } - ++name_iter; - } - - fc.fc_name_to_errors.erase(es.sb_iter); - fc.fc_invalidate_merge = true; - lv.reload_data(); - }, - [](files_model::other_selection) {}, - [](files_model::file_selection) {}); + sel.match( + [](files_model::no_selection) {}, + [&](files_model::error_selection& es) { + auto& fc = lnav_data.ld_active_files; + + fc.fc_file_names.erase(es.sb_iter->first); + + auto name_iter = fc.fc_file_names.begin(); + while (name_iter != fc.fc_file_names.end()) { + if (name_iter->first == es.sb_iter->first) { + name_iter = fc.fc_file_names.erase(name_iter); + continue; + } + + auto rp_opt = humanize::network::path::from_str( + name_iter->first); + + if (rp_opt) { + auto rp = *rp_opt; + + if (fmt::to_string(rp.home()) == es.sb_iter->first) + { + fc.fc_other_files.erase(name_iter->first); + name_iter = fc.fc_file_names.erase(name_iter); + continue; + } + } + ++name_iter; + } + + fc.fc_name_to_errors.erase(es.sb_iter); + fc.fc_invalidate_merge = true; + lv.reload_data(); + }, + [](files_model::other_selection) {}, + [](files_model::file_selection) {}); return true; } } diff --git a/src/filter_sub_source.cc b/src/filter_sub_source.cc index 27543828..7503af89 100644 --- a/src/filter_sub_source.cc +++ b/src/filter_sub_source.cc @@ -463,7 +463,8 @@ filter_sub_source::rl_change(readline_curses* rc) break; } case filter_lang_t::SQL: { - auto full_sql = fmt::format("SELECT 1 WHERE {}", new_value); + auto full_sql + = fmt::format(FMT_STRING("SELECT 1 WHERE {}"), new_value); auto_mem stmt(sqlite3_finalize); #ifdef SQLITE_PREPARE_PERSISTENT auto retcode = sqlite3_prepare_v3(lnav_data.ld_db.in(), @@ -544,7 +545,8 @@ filter_sub_source::rl_perform(readline_curses* rc) break; } case filter_lang_t::SQL: { - auto full_sql = fmt::format("SELECT 1 WHERE {}", new_value); + auto full_sql + = fmt::format(FMT_STRING("SELECT 1 WHERE {}"), new_value); auto_mem stmt(sqlite3_finalize); #ifdef SQLITE_PREPARE_PERSISTENT auto retcode = sqlite3_prepare_v3(lnav_data.ld_db.in(), diff --git a/src/help_text_formatter.cc b/src/help_text_formatter.cc index 95f55c72..bcff631c 100644 --- a/src/help_text_formatter.cc +++ b/src/help_text_formatter.cc @@ -670,12 +670,12 @@ format_help_text_for_rst(const help_text& ht, for (const auto* related : get_related(ht)) { related_refs.emplace_back( - fmt::format(":ref:`{}`", link_name(*related))); + fmt::format(FMT_STRING(":ref:`{}`"), link_name(*related))); } stable_sort(related_refs.begin(), related_refs.end()); fmt::print(rst_file, - " **See Also**\n {}\n", + FMT_STRING(" **See Also**\n {}\n"), fmt::join(related_refs, ", ")); } diff --git a/src/line_buffer.cc b/src/line_buffer.cc index 6e141043..bb087a0b 100644 --- a/src/line_buffer.cc +++ b/src/line_buffer.cc @@ -789,8 +789,8 @@ line_buffer::read_range(const file_range fr) line_start = this->get_range(fr.fr_offset, avail); if (fr.fr_size > avail) { - return Err( - fmt::format("short-read (need: {}; avail: {})", fr.fr_size, avail)); + return Err(fmt::format( + FMT_STRING("short-read (need: {}; avail: {})"), fr.fr_size, avail)); } retval.share(this->lb_share_manager, line_start, fr.fr_size); diff --git a/src/lnav.cc b/src/lnav.cc index 184924f0..628c39df 100644 --- a/src/lnav.cc +++ b/src/lnav.cc @@ -2593,8 +2593,10 @@ SELECT tbl_name FROM sqlite_master WHERE sql LIKE 'CREATE VIRTUAL TABLE%' done = true; break; case SQLITE_ROW: - tables_to_drop.emplace_back(fmt::format( - "DROP TABLE {}", sqlite3_column_text(stmt.in(), 0))); + tables_to_drop.emplace_back( + fmt::format(FMT_STRING("DROP TABLE {}"), + reinterpret_cast( + sqlite3_column_text(stmt.in(), 0)))); break; } } while (!done); diff --git a/src/lnav_commands.cc b/src/lnav_commands.cc index 658fb27b..c87f5577 100644 --- a/src/lnav_commands.cc +++ b/src/lnav_commands.cc @@ -50,12 +50,12 @@ #include "base/paths.hh" #include "base/string_util.hh" #include "bound_tags.hh" -#include "fmt/printf.h" #include "command_executor.hh" #include "config.h" #include "curl_looper.hh" #include "db_sub_source.hh" #include "field_overlay_source.hh" +#include "fmt/printf.h" #include "lnav_commands.hh" #include "lnav_config.hh" #include "lnav_util.hh" @@ -507,7 +507,7 @@ com_mark_expr(exec_context& ec, string cmdline, vector& args) return ec.make_error(":mark-expr is only supported for the LOG view"); } else { auto expr = remaining_args(cmdline, args); - auto stmt_str = fmt::format("SELECT 1 WHERE {}", expr); + auto stmt_str = fmt::format(FMT_STRING("SELECT 1 WHERE {}"), expr); auto_mem stmt(sqlite3_finalize); #ifdef SQLITE_PREPARE_PERSISTENT @@ -562,7 +562,7 @@ com_mark_expr_prompt(exec_context& ec, const string& cmdline) return ""; } - return fmt::format("{} {}", + return fmt::format(FMT_STRING("{} {}"), trim(cmdline), trim(lnav_data.ld_log_source.get_sql_marker_text())); } @@ -1800,7 +1800,7 @@ com_filter_expr(exec_context& ec, string cmdline, vector& args) } auto expr = remaining_args(cmdline, args); - args[1] = fmt::format("SELECT 1 WHERE {}", expr); + args[1] = fmt::format(FMT_STRING("SELECT 1 WHERE {}"), expr); auto_mem stmt(sqlite3_finalize); #ifdef SQLITE_PREPARE_PERSISTENT @@ -1861,7 +1861,7 @@ com_filter_expr_prompt(exec_context& ec, const string& cmdline) return ""; } - return fmt::format("{} {}", + return fmt::format(FMT_STRING("{} {}"), trim(cmdline), trim(lnav_data.ld_log_source.get_sql_filter_text())); } @@ -2549,7 +2549,7 @@ com_file_visibility(exec_context& ec, string cmdline, vector& args) [make_visible](auto ld) { ld->set_visibility(make_visible); }; tc->get_sub_source()->text_filters_changed(); } - retval = fmt::format("info: {} file -- {}", + retval = fmt::format(FMT_STRING("info: {} file -- {}"), make_visible ? "showing" : "hiding", lf->get_filename()); } else { @@ -3539,7 +3539,7 @@ com_toggle_field(exec_context& ec, string cmdline, vector& args) if (missing_fields.empty()) { auto visibility = hide ? "hiding" : "showing"; - retval = fmt::format("info: {} field(s) -- {}", + retval = fmt::format(FMT_STRING("info: {} field(s) -- {}"), visibility, fmt::join(found_fields, ", ")); } else { @@ -3957,7 +3957,8 @@ com_config(exec_context& ec, string cmdline, vector& args) retval = help_text; } else { - retval = fmt::format("{} = {}", option, trim(old_value)); + retval = fmt::format( + FMT_STRING("{} = {}"), option, trim(old_value)); } } else { string value = remaining_args(cmdline, args, 2); diff --git a/src/lnav_config.cc b/src/lnav_config.cc index 39b4a266..99ad0783 100644 --- a/src/lnav_config.cc +++ b/src/lnav_config.cc @@ -1176,7 +1176,7 @@ detect_config_file_type(const ghc::filesystem::path& path) auto read_res = lnav::filesystem::read_file(path); if (read_res.isErr()) { - return Err(fmt::format("unable to open file: {} -- {}", + return Err(fmt::format(FMT_STRING("unable to open file: {} -- {}"), path.string(), read_res.unwrapErr())); } @@ -1191,22 +1191,23 @@ detect_config_file_type(const ghc::filesystem::path& path) yajl_tree_parse(content.c_str(), error_buffer, sizeof(error_buffer)), yajl_tree_free); if (content_tree == nullptr) { - return Err(fmt::format( - "unable to parse file: {} -- {}", path.string(), error_buffer)); + return Err(fmt::format(FMT_STRING("unable to parse file: {} -- {}"), + path.string(), + error_buffer)); } - auto id_val = yajl_tree_get(content_tree.get(), id_path, yajl_t_string); + auto* id_val = yajl_tree_get(content_tree.get(), id_path, yajl_t_string); if (id_val != nullptr) { if (SUPPORTED_CONFIG_SCHEMAS.count(id_val->u.string)) { return Ok(config_file_type::CONFIG); - } else if (SUPPORTED_FORMAT_SCHEMAS.count(id_val->u.string)) { + } + if (SUPPORTED_FORMAT_SCHEMAS.count(id_val->u.string)) { return Ok(config_file_type::FORMAT); - } else { - return Err(fmt::format( - "unsupported configuration version in file: {} -- {}", - path.string(), - id_val->u.string)); } + return Err(fmt::format( + FMT_STRING("unsupported configuration version in file: {} -- {}"), + path.string(), + id_val->u.string)); } else { return Ok(config_file_type::FORMAT); } @@ -1311,7 +1312,7 @@ load_config(const vector& extra_paths, for (auto& bsf : lnav_config_json) { auto sample_path = lnav::paths::dotlnav() / "configs" / "default" - / fmt::format("{}.sample", bsf.get_name()); + / fmt::format(FMT_STRING("{}.sample"), bsf.get_name()); auto fd = auto_fd(lnav::filesystem::openp( sample_path, O_WRONLY | O_TRUNC | O_CREAT, 0644)); @@ -1383,7 +1384,7 @@ string save_config() { yajlpp_gen gen; - auto filename = fmt::format("config.json.{}.tmp", getpid()); + auto filename = fmt::format(FMT_STRING("config.json.{}.tmp"), getpid()); auto user_config_tmp = lnav::paths::dotlnav() / filename; auto user_config = lnav::paths::dotlnav() / "config.json"; @@ -1403,11 +1404,11 @@ save_config() { return "error: unable to save configuration -- " + string(strerror(errno)); - } else { - string_fragment bits = gen.to_string_fragment(); - - log_perror(write(fd, bits.data(), bits.length())); } + + string_fragment bits = gen.to_string_fragment(); + + log_perror(write(fd, bits.data(), bits.length())); } rename(user_config_tmp.c_str(), user_config.c_str()); diff --git a/src/log_actions.cc b/src/log_actions.cc index 13e92a09..fc55f9e6 100644 --- a/src/log_actions.cc +++ b/src/log_actions.cc @@ -135,8 +135,9 @@ action_delegate::execute_action(const string& action_name) }) .expect("Cannot create temporary file for action") .second); - auto desc = fmt::format( - "[{}] Output of {}", exec_count++, action.ad_cmdline[0]); + auto desc = fmt::format(FMT_STRING("[{}] Output of {}"), + exec_count++, + action.ad_cmdline[0]); this->ad_piper_cb(desc, pp); } diff --git a/src/log_data_helper.cc b/src/log_data_helper.cc index 96da0724..0b2ae2d6 100644 --- a/src/log_data_helper.cc +++ b/src/log_data_helper.cc @@ -132,8 +132,10 @@ log_data_helper::parse_line(content_line_t line, bool allow_middle) auto node_path = lnav::pugixml::get_actual_path( xpath_node.node()); for (auto& attr : xpath_node.node().attributes()) { - auto attr_path = fmt::format( - "{}/@{}", node_path, attr.name()); + auto attr_path + = fmt::format(FMT_STRING("{}/@{}"), + node_path, + attr.name()); this->ldh_xml_pairs[std::make_pair(col_name, attr_path)] @@ -144,8 +146,8 @@ log_data_helper::parse_line(content_line_t line, bool allow_middle) continue; } - auto text_path - = fmt::format("{}/text()", node_path); + auto text_path = fmt::format( + FMT_STRING("{}/text()"), node_path); this->ldh_xml_pairs[std::make_pair(col_name, text_path)] = trim(xpath_node.node().text().get()); diff --git a/src/log_format.cc b/src/log_format.cc index 8a35465f..eeb4eb30 100644 --- a/src/log_format.cc +++ b/src/log_format.cc @@ -1339,10 +1339,10 @@ external_log_format::get_subline(const logline& ll, handle, 1, (const unsigned char*) sbr.get_data(), sbr.length()); if (msg != nullptr) { full_msg = fmt::format( - "[offset: {}] {}\n{}", + FMT_STRING("[offset: {}] {}\n{}"), ll.get_offset(), fmt::string_view{sbr.get_data(), sbr.length()}, - msg); + reinterpret_cast(msg)); yajl_free_error(handle, msg); } @@ -2125,12 +2125,12 @@ external_log_format::register_vtabs(log_vtab_manager* vtab_manager, log_search_table::pattern_options()); if (re_res.isErr()) { - errors.push_back( - fmt::format("error:{}:{}:unable to compile regex '{}': {}", - this->elf_name.get(), - search_iter->first.get(), - search_iter->second, - re_res.unwrapErr().ce_msg)); + errors.emplace_back(fmt::format( + FMT_STRING("error:{}:{}:unable to compile regex '{}': {}"), + this->elf_name.get(), + search_iter->first.get(), + search_iter->second, + re_res.unwrapErr().ce_msg)); continue; } @@ -2382,7 +2382,7 @@ std::string log_format::get_pattern_name(uint64_t line_number) const { int pat_index = this->pattern_index_for_line(line_number); - return fmt::format("builtin ({})", pat_index); + return fmt::format(FMT_STRING("builtin ({})"), pat_index); } log_format::pattern_for_lines::pattern_for_lines(uint32_t pfl_line, diff --git a/src/log_format_loader.cc b/src/log_format_loader.cc index 9d7c0441..baaeb50b 100644 --- a/src/log_format_loader.cc +++ b/src/log_format_loader.cc @@ -251,11 +251,12 @@ read_format_field(yajlpp_parse_context* ypc, ypc->ypc_error_reporter( *ypc, lnav_log_level_t::ERROR, - fmt::format("error:{}:{}:invalid regular expression for " - "level-pointer -- {}", - ypc->ypc_source, - ypc->get_line_number(), - pcre_res.unwrapErr().ce_msg) + fmt::format( + FMT_STRING("error:{}:{}:invalid regular expression for " + "level-pointer -- {}"), + ypc->ypc_source, + ypc->get_line_number(), + pcre_res.unwrapErr().ce_msg) .c_str()); } else { elf->elf_level_pointer = pcre_res.unwrap(); @@ -847,7 +848,8 @@ write_sample_file() { for (const auto& bsf : lnav_format_json) { auto sample_path = lnav::paths::dotlnav() - / fmt::format("formats/default/{}.sample", bsf.get_name()); + / fmt::format(FMT_STRING("formats/default/{}.sample"), + bsf.get_name()); auto sf = bsf.to_string_fragment(); auto_fd sample_fd; @@ -865,7 +867,7 @@ write_sample_file() for (const auto& bsf : lnav_sh_scripts) { auto sh_path = lnav::paths::dotlnav() - / fmt::format("formats/default/{}", bsf.get_name()); + / fmt::format(FMT_STRING("formats/default/{}"), bsf.get_name()); auto sf = bsf.to_string_fragment(); auto_fd sh_fd; @@ -939,10 +941,10 @@ load_format_file(const ghc::filesystem::path& filename, ypc.ypc_userdata = &ud; ypc.with_obj(ud); if ((fd = lnav::filesystem::openp(filename, O_RDONLY)) == -1) { - errors.emplace_back( - fmt::format("error: unable to open format file '{}' -- {}", - filename.string(), - strerror(errno))); + errors.emplace_back(fmt::format( + FMT_STRING("error: unable to open format file '{}' -- {}"), + filename.string(), + strerror(errno))); } else { auto_mem handle(yajl_free); char buffer[2048]; @@ -957,10 +959,10 @@ load_format_file(const ghc::filesystem::path& filename, if (rc == 0) { break; } else if (rc == -1) { - errors.push_back( - fmt::format("error:{}:unable to read file -- {}", - filename.string(), - strerror(errno))); + errors.emplace_back(fmt::format( + FMT_STRING("error:{}:unable to read file -- {}"), + filename.string(), + strerror(errno))); break; } if (offset == 0 && (rc > 2) && (buffer[0] == '#') @@ -1042,8 +1044,9 @@ load_formats(const std::vector& extra_paths, unsigned char* msg = yajl_get_error( handle, 1, (const unsigned char*) sf.data(), sf.length()); - errors.push_back( - fmt::format(FMT_STRING("builtin: invalid json -- {}"), msg)); + errors.emplace_back( + fmt::format(FMT_STRING("builtin: invalid json -- {}"), + reinterpret_cast(msg))); yajl_free_error(handle, msg); } ypc_builtin.complete_parse(); @@ -1171,10 +1174,10 @@ exec_sql_in_path(sqlite3* db, sql_execute_script( db, filename.c_str(), content.c_str(), errors); } else { - errors.push_back( - fmt::format("error:unable to read file '{}' -- {}", - filename.string(), - read_res.unwrapErr())); + errors.emplace_back(fmt::format( + FMT_STRING("error:unable to read file '{}' -- {}"), + filename.string(), + read_res.unwrapErr())); } } } diff --git a/src/log_vtab_impl.cc b/src/log_vtab_impl.cc index dd62884f..05e3b3b4 100644 --- a/src/log_vtab_impl.cc +++ b/src/log_vtab_impl.cc @@ -578,8 +578,9 @@ vt_column(sqlite3_vtab_cursor* cur, sqlite3_context* ctx, int col) auto read_res = lf->read_raw_message(ll); if (read_res.isErr()) { - auto msg = fmt::format("unable to read line -- {}", - read_res.unwrapErr()); + auto msg = fmt::format( + FMT_STRING("unable to read line -- {}"), + read_res.unwrapErr()); sqlite3_result_error( ctx, msg.c_str(), msg.length()); } else { @@ -1002,7 +1003,8 @@ vt_update(sqlite3_vtab* tab, ypc.parse(log_tags, strlen((const char*) log_tags)); ypc.complete_parse(); if (!errors.empty()) { - auto all_errors = fmt::format("{}", fmt::join(errors, "\n")); + auto all_errors + = fmt::format(FMT_STRING("{}"), fmt::join(errors, "\n")); tab->zErrMsg = sqlite3_mprintf("%s", all_errors.c_str()); return SQLITE_ERROR; } @@ -1157,7 +1159,7 @@ log_vtab_manager::unregister_vtab(intern_string_t name) string retval; if (this->vm_impls.find(name) == this->vm_impls.end()) { - retval = fmt::format("unknown log line table -- {}", name); + retval = fmt::format(FMT_STRING("unknown log line table -- {}"), name); } else { auto_mem sql; __attribute((unused)) int rc; diff --git a/src/logfile.cc b/src/logfile.cc index 9cb835b5..f5fa6035 100644 --- a/src/logfile.cc +++ b/src/logfile.cc @@ -70,24 +70,27 @@ logfile::open(std::string filename, logfile_open_options& loo) errno = 0; if (realpath(lf->lf_filename.c_str(), resolved_path) == nullptr) { - return Err(fmt::format("realpath({}) failed with: {}", + return Err(fmt::format(FMT_STRING("realpath({}) failed with: {}"), lf->lf_filename, strerror(errno))); } if (stat(resolved_path, &lf->lf_stat) == -1) { - return Err(fmt::format( - "stat({}) failed with: {}", lf->lf_filename, strerror(errno))); + return Err(fmt::format(FMT_STRING("stat({}) failed with: {}"), + lf->lf_filename, + strerror(errno))); } if (!S_ISREG(lf->lf_stat.st_mode)) { - return Err(fmt::format( - "{} is not a regular file", lf->lf_filename, strerror(errno))); + return Err(fmt::format(FMT_STRING("{} is not a regular file"), + lf->lf_filename, + strerror(errno))); } if ((lf->lf_options.loo_fd = ::open(resolved_path, O_RDONLY)) == -1) { - return Err(fmt::format( - "open({}) failed with: {}", lf->lf_filename, strerror(errno))); + return Err(fmt::format(FMT_STRING("open({}) failed with: {}"), + lf->lf_filename, + strerror(errno))); } lf->lf_options.loo_fd.close_on_exec(); @@ -794,5 +797,6 @@ logfile::mark_as_duplicate(const string& name) this->lf_indexing = false; this->lf_options.loo_is_visible = false; this->lf_notes.writeAccess()->emplace( - note_type::duplicate, fmt::format("hiding duplicate of {}", name)); + note_type::duplicate, + fmt::format(FMT_STRING("hiding duplicate of {}"), name)); } diff --git a/src/logfile_sub_source.cc b/src/logfile_sub_source.cc index 9cde0899..0b6573a2 100644 --- a/src/logfile_sub_source.cc +++ b/src/logfile_sub_source.cc @@ -591,7 +591,8 @@ logfile_sub_source::text_attrs_for_line(textview_curses& lv, this->lss_token_line); if (eval_res.isErr()) { auto msg = fmt::format( - "filter expression evaluation failed with -- {}", + FMT_STRING( + "filter expression evaluation failed with -- {}"), eval_res.unwrapErr()); auto color = COLOR_YELLOW; value_out.emplace_back(line_range{0, -1}, &SA_ERROR, msg); @@ -1821,9 +1822,9 @@ sql_filter::matches(const logfile& lf, } std::string -sql_filter::to_command() +sql_filter::to_command() const { - return fmt::format("filter-expr {}", this->lf_id); + return fmt::format(FMT_STRING("filter-expr {}"), this->lf_id); } bool diff --git a/src/logfile_sub_source.hh b/src/logfile_sub_source.hh index 5041e9b5..88aaabfb 100644 --- a/src/logfile_sub_source.hh +++ b/src/logfile_sub_source.hh @@ -97,7 +97,7 @@ public: return this->pf_pcre.match(pc, pi); }; - std::string to_command() override + std::string to_command() const override { return (this->lf_type == text_filter::INCLUDE ? "filter-in " : "filter-out ") @@ -123,7 +123,7 @@ public: logfile::const_iterator ll, shared_buffer_ref& line) override; - std::string to_command() override; + std::string to_command() const override; auto_mem sf_filter_stmt{sqlite3_finalize}; logfile_sub_source& sf_log_source; diff --git a/src/readline_callbacks.cc b/src/readline_callbacks.cc index 360a2804..f1353f45 100644 --- a/src/readline_callbacks.cc +++ b/src/readline_callbacks.cc @@ -468,7 +468,7 @@ rl_search_internal(readline_curses* rc, ln_mode_t mode, bool complete = false) const char* errmsg = sqlite3_errmsg(lnav_data.ld_db); lnav_data.ld_bottom_source.grep_error( - fmt::format("sql error: {}", errmsg)); + fmt::format(FMT_STRING("sql error: {}"), errmsg)); } else { lnav_data.ld_bottom_source.grep_error(""); } diff --git a/src/readline_curses.cc b/src/readline_curses.cc index 601fdc91..cfd38d19 100644 --- a/src/readline_curses.cc +++ b/src/readline_curses.cc @@ -384,7 +384,8 @@ readline_context::attempted_completion(const char* text, int start, int end) arg_possibilities = nullptr; rl_completion_append_character = 0; if (lexer.split(prefix, scope)) { - auto prefix2 = fmt::format("{}", fmt::join(prefix, "\x1f")); + auto prefix2 + = fmt::format(FMT_STRING("{}"), fmt::join(prefix, "\x1f")); auto prefix_iter = loaded_context->rc_prefixes.find(prefix2); if (prefix_iter != loaded_context->rc_prefixes.end()) { @@ -1276,7 +1277,7 @@ readline_curses::add_prefix(int context, const string& value) { char buffer[1024]; - auto prefix_wire = fmt::format("{}", fmt::join(prefix, "\x1f")); + auto prefix_wire = fmt::format(FMT_STRING("{}"), fmt::join(prefix, "\x1f")); snprintf(buffer, sizeof(buffer), diff --git a/src/readline_possibilities.cc b/src/readline_possibilities.cc index 7cabaae2..b142ea1d 100644 --- a/src/readline_possibilities.cc +++ b/src/readline_possibilities.cc @@ -253,7 +253,7 @@ add_filter_expr_possibilities(readline_curses* rlc, auto_mem ident(sqlite3_free); ident = sql_quote_ident(lv.lv_meta.lvm_name.get()); - auto bound_name = fmt::format(":{}", ident); + auto bound_name = fmt::format(FMT_STRING(":{}"), ident); rlc->add_possibility(context, type, bound_name); switch (lv.lv_meta.lvm_kind) { case value_kind_t::VALUE_BOOLEAN: diff --git a/src/styling.cc b/src/styling.cc index b811a3e9..e782b33c 100644 --- a/src/styling.cc +++ b/src/styling.cc @@ -118,7 +118,7 @@ rgb_color::from_str(const string_fragment& sf) break; } - return Err(fmt::format("Could not parse color: {}", sf)); + return Err(fmt::format(FMT_STRING("Could not parse color: {}"), sf)); } for (const auto& xc : xterm_colors()->tc_palette) { @@ -128,9 +128,10 @@ rgb_color::from_str(const string_fragment& sf) } return Err(fmt::format( - "Unknown color: '{}'. " - "See https://jonasjacek.github.io/colors/ for a list of supported " - "color names", + FMT_STRING( + "Unknown color: '{}'. " + "See https://jonasjacek.github.io/colors/ for a list of supported " + "color names"), sf)); } diff --git a/src/sysclip.cc b/src/sysclip.cc index c1792eb7..fb2b5658 100644 --- a/src/sysclip.cc +++ b/src/sysclip.cc @@ -47,8 +47,8 @@ get_commands() auto& cfg = injector::get(); for (const auto& pair : cfg.c_clipboard_impls) { - const auto full_cmd - = fmt::format("{} > /dev/null 2>&1", pair.second.c_test_command); + const auto full_cmd = fmt::format(FMT_STRING("{} > /dev/null 2>&1"), + pair.second.c_test_command); log_debug("testing clipboard impl %s using: %s", pair.first.c_str(), @@ -86,10 +86,10 @@ open(type_t type, op_t op) switch (op) { case op_t::WRITE: - cmd = fmt::format("{} > /dev/null 2>&1", cmd); + cmd = fmt::format(FMT_STRING("{} > /dev/null 2>&1"), cmd); break; case op_t::READ: - cmd = fmt::format("{} < /dev/null 2>/dev/null", cmd); + cmd = fmt::format(FMT_STRING("{} < /dev/null 2>/dev/null"), cmd); break; } diff --git a/src/tailer/tailer.looper.cc b/src/tailer/tailer.looper.cc index c666caa4..71862ace 100644 --- a/src/tailer/tailer.looper.cc +++ b/src/tailer/tailer.looper.cc @@ -114,7 +114,8 @@ update_tailer_description( std::vector paths; for (const auto& des_pair : desired_paths) { - paths.emplace_back(fmt::format("{}{}", netloc, des_pair.first)); + paths.emplace_back( + fmt::format(FMT_STRING("{}{}"), netloc, des_pair.first)); } isc::to().send( [paths, remote_uname](auto& mlooper) { @@ -200,7 +201,7 @@ void tailer::looper::add_remote(const network::path& path, logfile_open_options options) { - auto netloc_str = fmt::format("{}", path.home()); + auto netloc_str = fmt::to_string(path.home()); this->l_netlocs_to_paths[netloc_str].rpq_new_paths[path.p_path] = std::move(options); } @@ -208,7 +209,7 @@ tailer::looper::add_remote(const network::path& path, void tailer::looper::load_preview(int64_t id, const network::path& path) { - auto netloc_str = fmt::format("{}", path.home()); + auto netloc_str = fmt::to_string(path.home()); auto iter = this->l_remotes.find(netloc_str); if (iter == this->l_remotes.end()) { @@ -243,7 +244,7 @@ tailer::looper::load_preview(int64_t id, const network::path& path) void tailer::looper::complete_path(const network::path& path) { - auto netloc_str = fmt::format("{}", path.home()); + auto netloc_str = fmt::to_string(path.home()); auto iter = this->l_remotes.find(netloc_str); if (iter == this->l_remotes.end()) { @@ -273,21 +274,23 @@ create_ssh_args_from_config(const std::string& dest) if (startswith(cfg.c_ssh_flags, "-")) { retval.emplace_back(cfg.c_ssh_flags); } else { - retval.emplace_back(fmt::format("-{}", cfg.c_ssh_flags)); + retval.emplace_back( + fmt::format(FMT_STRING("-{}"), cfg.c_ssh_flags)); } } for (const auto& pair : cfg.c_ssh_options) { if (pair.second.empty()) { continue; } - retval.emplace_back(fmt::format("-{}", pair.first)); + retval.emplace_back(fmt::format(FMT_STRING("-{}"), pair.first)); retval.emplace_back(pair.second); } for (const auto& pair : cfg.c_ssh_config) { if (pair.second.empty()) { continue; } - retval.emplace_back(fmt::format("-o{}={}", pair.first, pair.second)); + retval.emplace_back( + fmt::format(FMT_STRING("-o{}={}"), pair.first, pair.second)); } retval.emplace_back(dest); @@ -302,12 +305,12 @@ tailer::looper::host_tailer::for_host(const std::string& netloc) update_tailer_progress(netloc, "Transferring tailer..."); auto& cfg = injector::get(); - auto tailer_bin_name = fmt::format("tailer.bin.{}", getpid()); + auto tailer_bin_name = fmt::format(FMT_STRING("tailer.bin.{}"), getpid()); auto rp = humanize::network::path::from_str(netloc).value(); auto ssh_dest = rp.p_locality.l_hostname; if (rp.p_locality.l_username.has_value()) { - ssh_dest = fmt::format("{}@{}", + ssh_dest = fmt::format(FMT_STRING("{}@{}"), rp.p_locality.l_username.value(), rp.p_locality.l_hostname); } @@ -347,7 +350,8 @@ tailer::looper::host_tailer::for_host(const std::string& netloc) std::thread err_reader([netloc, err = std::move(err_pipe.read_end()), &error_queue]() mutable { - log_set_thread_prefix(fmt::format("tailer({})", netloc)); + log_set_thread_prefix( + fmt::format(FMT_STRING("tailer({})"), netloc)); read_err_pipe(netloc, err, error_queue); }); @@ -393,7 +397,8 @@ tailer::looper::host_tailer::for_host(const std::string& netloc) { auto error_msg = error_queue.empty() ? "unknown" : error_queue.back(); - return Err(fmt::format("failed to ssh to host: {}", error_msg)); + return Err(fmt::format(FMT_STRING("failed to ssh to host: {}"), + error_msg)); } } @@ -415,7 +420,7 @@ tailer::looper::host_tailer::for_host(const std::string& netloc) arg_strs.emplace_back(fmt::format(cfg.c_start_cmd, tailer_bin_name)); fmt::print(stderr, - "tailer({}): executing -- {}\n", + FMT_STRING("tailer({}): executing -- {}\n"), netloc, fmt::join(arg_strs, " ")); for (const auto& arg : arg_strs) { @@ -520,8 +525,8 @@ tailer::looper::host_tailer::load_preview(int64_t id, const std::string& path) log_warning("disconnected from host, cannot preview: %s", path.c_str()); - auto msg - = fmt::format("error: disconnected from {}", this->ht_netloc); + auto msg = fmt::format(FMT_STRING("error: disconnected from {}"), + this->ht_netloc); isc::to().send([=](auto& mlooper) { if (lnav_data.ld_preview_generation != id) { return; @@ -958,8 +963,8 @@ tailer::looper::host_tailer::loop_body() }, [&](const tailer::packet_possible_path& ppp) { log_debug("possible path: %s", ppp.ppp_path.c_str()); - auto full_path - = fmt::format("{}{}", this->ht_netloc, ppp.ppp_path); + auto full_path = fmt::format( + FMT_STRING("{}{}"), this->ht_netloc, ppp.ppp_path); isc::to().send( [full_path](auto& mlooper) { @@ -996,13 +1001,14 @@ std::string tailer::looper::host_tailer::get_display_path( const std::string& remote_path) const { - return fmt::format("{}{}", this->ht_netloc, remote_path); + return fmt::format(FMT_STRING("{}{}"), this->ht_netloc, remote_path); } void* tailer::looper::host_tailer::run() { - log_set_thread_prefix(fmt::format("tailer({})", this->ht_netloc)); + log_set_thread_prefix( + fmt::format(FMT_STRING("tailer({})"), this->ht_netloc)); return service_base::run(); } @@ -1051,12 +1057,14 @@ tailer::looper::remote_path_queue::send_synced_to_main( for (const auto& pair : this->rpq_new_paths) { if (!pair.second.loo_tail) { - synced_files.emplace(fmt::format("{}{}", netloc, pair.first)); + synced_files.emplace( + fmt::format(FMT_STRING("{}{}"), netloc, pair.first)); } } for (const auto& pair : this->rpq_existing_paths) { if (!pair.second.loo_tail) { - synced_files.emplace(fmt::format("{}{}", netloc, pair.first)); + synced_files.emplace( + fmt::format(FMT_STRING("{}{}"), netloc, pair.first)); } } diff --git a/src/tailer/tailer.main.c b/src/tailer/tailer.main.c index 02699213..445d24cb 100644 --- a/src/tailer/tailer.main.c +++ b/src/tailer/tailer.main.c @@ -545,17 +545,27 @@ int poll_paths(struct list *path_list, struct client_path_state *root_cps) } else if (curr->cps_client_state == CS_INIT && (curr->cps_client_file_offset < 0 || bytes_read > 0)) { - static unsigned char HASH_BUFFER[4 * 1024 * 1024]; + static unsigned char + HASH_BUFFER[4 * 1024 * 1024]; BYTE hash[SHA256_BLOCK_SIZE]; size_t remaining = 0; - int64_t remaining_offset = file_offset + bytes_read; + int64_t remaining_offset + = file_offset + bytes_read; SHA256_CTX shactx; - if (curr->cps_client_file_size > 0 && file_offset < curr->cps_client_file_size) { - remaining = curr->cps_client_file_size - file_offset - bytes_read; + if (curr->cps_client_file_size > 0 + && file_offset < curr->cps_client_file_size) + { + remaining = curr->cps_client_file_size + - file_offset - bytes_read; } - fprintf(stderr, "info: prepping offer: init=%ld; remaining=%zu; %s\n", bytes_read, remaining, curr->cps_path); + fprintf(stderr, + "info: prepping offer: init=%d; " + "remaining=%zu; %s\n", + bytes_read, + remaining, + curr->cps_path); sha256_init(&shactx); sha256_update(&shactx, buffer, bytes_read); while (remaining > 0) { @@ -563,8 +573,11 @@ int poll_paths(struct list *path_list, struct client_path_state *root_cps) if (remaining < nbytes) { nbytes = remaining; } - ssize_t remaining_bytes_read = pread( - fd, HASH_BUFFER, nbytes, remaining_offset); + ssize_t remaining_bytes_read + = pread(fd, + HASH_BUFFER, + nbytes, + remaining_offset); if (remaining_bytes_read < 0) { set_client_path_state_error(curr, "pread"); break; @@ -1023,7 +1036,10 @@ int main(int argc, char *argv[]) fprintf(stderr, "info: client is tailing: %s\n", path); cps->cps_client_state = CS_TAILING; } else if (type == TPT_ACK_BLOCK) { - fprintf(stderr, "info: client acked: %s %zu\n", path, client_size); + fprintf(stderr, + "info: client acked: %s %lld\n", + path, + client_size); if (ack_len == 0) { cps->cps_client_state = CS_TAILING; } else { diff --git a/src/tailer/tailerpp.hh b/src/tailer/tailerpp.hh index 8f021e3b..a9cf43eb 100644 --- a/src/tailer/tailerpp.hh +++ b/src/tailer/tailerpp.hh @@ -184,15 +184,16 @@ struct protocol_recv { tailer_packet_payload_type_t payload_type; if (readall(this->pr_fd, &payload_type, sizeof(payload_type)) == -1) { - return Err(fmt::format("unable to read payload type: {}", - strerror(errno))); + return Err( + fmt::format(FMT_STRING("unable to read payload type: {}"), + strerror(errno))); } if (payload_type != PAYLOAD_TYPE) { - return Err( - fmt::format("payload-type mismatch, got: {}; expected: {}", - payload_type, - PAYLOAD_TYPE)); + return Err(fmt::format( + FMT_STRING("payload-type mismatch, got: {}; expected: {}"), + payload_type, + PAYLOAD_TYPE)); } return Ok(protocol_recv(this->pr_fd)); @@ -207,15 +208,16 @@ struct protocol_recv { if (readall(this->pr_fd, &this->pr_length, sizeof(this->pr_length)) == -1) { - return Err(fmt::format("unable to read content length: {}", - strerror(errno))); + return Err( + fmt::format(FMT_STRING("unable to read content length: {}"), + strerror(errno))); } try { data.resize(this->pr_length); } catch (...) { - return Err( - fmt::format("unable to resize data to {}", this->pr_length)); + return Err(fmt::format(FMT_STRING("unable to resize data to {}"), + this->pr_length)); } return Ok(protocol_recv( @@ -234,7 +236,8 @@ struct protocol_recv { } if (readall(this->pr_fd, details::get_data(data), this->pr_length) == -1) { - return Err(fmt::format("unable to read ")); + return Err(fmt::format(FMT_STRING("unable to read content -- {}"), + strerror(errno))); } return Ok(); diff --git a/src/textview_curses.cc b/src/textview_curses.cc index ae188263..ccbb8fa1 100644 --- a/src/textview_curses.cc +++ b/src/textview_curses.cc @@ -189,8 +189,9 @@ textview_curses::reload_config(error_reporter& reporter) { reporter( &hl_pair.second.hc_regex, - fmt::format( - "invalid highlight regex: {} at {}", errptr, eoff)); + fmt::format(FMT_STRING("invalid highlight regex: {} at {}"), + errptr, + eoff)); continue; } @@ -799,7 +800,7 @@ empty_filter::matches(const logfile& lf, } string -empty_filter::to_command() +empty_filter::to_command() const { return ""; } diff --git a/src/textview_curses.hh b/src/textview_curses.hh index 6c86ce0f..cb8681b7 100644 --- a/src/textview_curses.hh +++ b/src/textview_curses.hh @@ -214,7 +214,7 @@ public: shared_buffer_ref& line) = 0; - virtual std::string to_command() = 0; + virtual std::string to_command() const = 0; bool operator==(const std::string& rhs) { @@ -242,7 +242,7 @@ public: logfile_const_iterator ll, shared_buffer_ref& line) override; - std::string to_command() override; + std::string to_command() const override; }; class filter_stack { diff --git a/src/views_vtab.cc b/src/views_vtab.cc index ed26c608..928f2856 100644 --- a/src/views_vtab.cc +++ b/src/views_vtab.cc @@ -557,7 +557,8 @@ CREATE TABLE lnav_view_filters ( "SQL filters are only supported in the log view"); } auto clause = from_sqlite()(1, &pattern_str, 0); - auto expr = fmt::format("SELECT 1 WHERE {}", clause); + auto expr + = fmt::format(FMT_STRING("SELECT 1 WHERE {}"), clause); auto_mem stmt(sqlite3_finalize); #ifdef SQLITE_PREPARE_PERSISTENT auto retcode = sqlite3_prepare_v3(lnav_data.ld_db.in(), @@ -654,7 +655,7 @@ CREATE TABLE lnav_view_filters ( "SQL filters are only supported in the log view"); } auto clause = from_sqlite()(1, &pattern_val, 0); - auto expr = fmt::format("SELECT 1 WHERE {}", clause); + auto expr = fmt::format(FMT_STRING("SELECT 1 WHERE {}"), clause); auto_mem stmt(sqlite3_finalize); #ifdef SQLITE_PREPARE_PERSISTENT auto retcode = sqlite3_prepare_v3(lnav_data.ld_db.in(), diff --git a/src/vtab_module.hh b/src/vtab_module.hh index 423d5a1a..7bef184a 100644 --- a/src/vtab_module.hh +++ b/src/vtab_module.hh @@ -828,7 +828,7 @@ struct vtab_module : public vtab_module_base { db, impl_name.c_str(), &this->vm_module, this); ensure(rc == SQLITE_OK); auto create_stmt = fmt::format( - "CREATE VIRTUAL TABLE {} USING {}()", name, impl_name); + FMT_STRING("CREATE VIRTUAL TABLE {} USING {}()"), name, impl_name); return sqlite3_exec(db, create_stmt.c_str(), nullptr, nullptr, nullptr); }; diff --git a/src/xml_util.cc b/src/xml_util.cc index cc74153a..a294def2 100644 --- a/src/xml_util.cc +++ b/src/xml_util.cc @@ -61,12 +61,12 @@ get_actual_path(const pugi::xml_node& node) sibling = sibling.previous_sibling(curr.name()); } - name = fmt::format("{}[{}]", name, index); + name = fmt::format(FMT_STRING("{}[{}]"), name, index); } if (retval.empty()) { retval = name; } else { - retval = fmt::format("{}/{}", name, retval); + retval = fmt::format(FMT_STRING("{}/{}"), name, retval); } break; } diff --git a/src/yajlpp/yajlpp.cc b/src/yajlpp/yajlpp.cc index 871abb67..ce0e1628 100644 --- a/src/yajlpp/yajlpp.cc +++ b/src/yajlpp/yajlpp.cc @@ -169,14 +169,15 @@ json_path_handler_base::gen_schema(yajlpp_gen_context& ygc) const schema.gen(this->jph_description); } if (this->jph_is_pattern_property) { - ygc.ygc_path.emplace_back( - fmt::format("<{}>", this->jph_regex.name_for_capture(0))); + ygc.ygc_path.emplace_back(fmt::format( + FMT_STRING("<{}>"), this->jph_regex.name_for_capture(0))); } else { ygc.ygc_path.emplace_back(this->jph_property); } if (this->jph_children->jpc_definition_id.empty()) { schema.gen("title"); - schema.gen(fmt::format("/{}", fmt::join(ygc.ygc_path, "/"))); + schema.gen(fmt::format(FMT_STRING("/{}"), + fmt::join(ygc.ygc_path, "/"))); schema.gen("type"); if (this->jph_is_array) { if (this->jph_regex.p_pattern.find("#?") == string::npos) { @@ -203,7 +204,8 @@ json_path_handler_base::gen_schema(yajlpp_gen_context& ygc) const } } else { schema.gen("title"); - schema.gen(fmt::format("/{}", fmt::join(ygc.ygc_path, "/"))); + schema.gen(fmt::format(FMT_STRING("/{}"), + fmt::join(ygc.ygc_path, "/"))); this->jph_children->gen_schema(ygc); } ygc.ygc_path.pop_back(); @@ -212,14 +214,15 @@ json_path_handler_base::gen_schema(yajlpp_gen_context& ygc) const yajlpp_map schema(ygc.ygc_handle); if (this->jph_is_pattern_property) { - ygc.ygc_path.emplace_back( - fmt::format("<{}>", this->jph_regex.name_for_capture(0))); + ygc.ygc_path.emplace_back(fmt::format( + FMT_STRING("<{}>"), this->jph_regex.name_for_capture(0))); } else { ygc.ygc_path.emplace_back(this->jph_property); } schema.gen("title"); - schema.gen(fmt::format("/{}", fmt::join(ygc.ygc_path, "/"))); + schema.gen( + fmt::format(FMT_STRING("/{}"), fmt::join(ygc.ygc_path, "/"))); if (this->jph_description && this->jph_description[0]) { schema.gen("description"); schema.gen(this->jph_description); @@ -803,15 +806,16 @@ yajlpp_parse_context::parse(const unsigned char* jsonText, size_t jsonTextLen) this->ypc_json_text = nullptr; if (retval != yajl_status_ok && this->ypc_error_reporter) { - auto msg = yajl_get_error(this->ypc_handle, 1, jsonText, jsonTextLen); - - this->ypc_error_reporter(*this, - lnav_log_level_t::ERROR, - fmt::format("error:{}:{}:invalid json -- {}", - this->ypc_source, - this->get_line_number(), - msg) - .c_str()); + auto* msg = yajl_get_error(this->ypc_handle, 1, jsonText, jsonTextLen); + + this->ypc_error_reporter( + *this, + lnav_log_level_t::ERROR, + fmt::format(FMT_STRING("error:{}:{}:invalid json -- {}"), + this->ypc_source, + this->get_line_number(), + reinterpret_cast(msg)) + .c_str()); yajl_free_error(this->ypc_handle, msg); } @@ -824,12 +828,14 @@ yajlpp_parse_context::complete_parse() yajl_status retval = yajl_complete_parse(this->ypc_handle); if (retval != yajl_status_ok && this->ypc_error_reporter) { - auto msg = yajl_get_error(this->ypc_handle, 0, nullptr, 0); + auto* msg = yajl_get_error(this->ypc_handle, 0, nullptr, 0); this->ypc_error_reporter( *this, lnav_log_level_t::ERROR, - fmt::format("error:{}:invalid json -- {}", this->ypc_source, msg) + fmt::format(FMT_STRING("error:{}:invalid json -- {}"), + this->ypc_source, + reinterpret_cast(msg)) .c_str()); yajl_free_error(this->ypc_handle, msg); } @@ -1001,7 +1007,8 @@ yajlpp_gen_context::gen_schema(const json_path_container* handlers) def.gen("type"); def.gen("object"); def.gen("$$target"); - def.gen(fmt::format("#/definitions/{}", container.first)); + def.gen(fmt::format(FMT_STRING("#/definitions/{}"), + container.first)); container.second->gen_properties(*this); } } @@ -1035,9 +1042,9 @@ json_path_container::gen_schema(yajlpp_gen_context& ygc) const ygc.ygc_schema_definitions[this->jpc_definition_id] = this; yajl_gen_string(ygc.ygc_handle, "$ref"); - yajl_gen_string( - ygc.ygc_handle, - fmt::format("#/definitions/{}", this->jpc_definition_id)); + yajl_gen_string(ygc.ygc_handle, + fmt::format(FMT_STRING("#/definitions/{}"), + this->jpc_definition_id)); return; } @@ -1099,7 +1106,7 @@ dump_schema_to(const json_path_container& jpc, { yajlpp_gen genner; yajlpp_gen_context ygc(genner, jpc); - auto schema_path = fmt::format("{}/{}", internals_dir, name); + auto schema_path = fmt::format(FMT_STRING("{}/{}"), internals_dir, name); auto file = unique_ptr( fopen(schema_path.c_str(), "w+"), fclose); diff --git a/test/scripty.cc b/test/scripty.cc index 878fce20..476da055 100644 --- a/test/scripty.cc +++ b/test/scripty.cc @@ -419,7 +419,7 @@ struct term_machine { if (this->tm_new_data || !this->tm_line_attrs.empty()) { // fprintf(scripty_data.sd_from_child, "flush %d\n", // this->tm_flush_count); - fprintf(stderr, "%s:flush %d\n", tstamp(), this->tm_flush_count++); + fprintf(stderr, "%s:flush %zu\n", tstamp(), this->tm_flush_count++); fprintf( scripty_data.sd_from_child, "S % 3d \u250B", this->tm_cursor_y); for (auto uch : this->tm_line) {