pass c strings to fmt (found some more)
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
tastytea 2022-08-16 17:59:03 +02:00
parent d438e2292f
commit c16265683f
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
3 changed files with 26 additions and 19 deletions

View File

@ -126,7 +126,9 @@ int main(int argc, char *argv[])
} }
LOG(log::sev::error) LOG(log::sev::error)
<< format(translate("Could not open {0:s}: {1:s}").str(), << format(translate("Could not open {0:s}: {1:s}")
.str()
.c_str(),
e.path1(), e.what()); e.path1(), e.what());
return_code = EXIT_FAILURE; return_code = EXIT_FAILURE;
} }
@ -176,8 +178,10 @@ int main(int argc, char *argv[])
{ {
LOG(log::sev::error) LOG(log::sev::error)
<< std::strerror(errno) // FIXME: Not thread safe. << std::strerror(errno) // FIXME: Not thread safe.
<< format(translate(" (while opening {0:s})").str(), << format(translate(" (while opening {0:s})")
filepath); .str()
.c_str(),
filepath.c_str());
return EXIT_FAILURE; return EXIT_FAILURE;
} }
catch (const boost::regex_error &e) catch (const boost::regex_error &e)
@ -233,8 +237,9 @@ int main(int argc, char *argv[])
while (cancel.wait_for(std::chrono::seconds(opts.status_interval)) while (cancel.wait_for(std::chrono::seconds(opts.status_interval))
!= std::future_status::ready) != std::future_status::ready)
{ {
std::cerr std::cerr << format(translate("{0:d} of {1:d} books searched.")
<< format(translate("{0:d} of {1:d} books searched.").str(), .str()
.c_str(),
books_searched, input_files.size()) books_searched, input_files.size())
<< '\n'; << '\n';
} }

View File

@ -169,17 +169,18 @@ void html_all(const std::vector<std::vector<search::match>> &matches_all,
if (!opts.no_fn_epub) if (!opts.no_fn_epub)
{ {
cout << format(R"( <th id="file_path_{0:d}">{1:s}</th>)", cout << format(R"( <th id="file_path_{0:d}">{1:s}</th>)",
count, translate("File path (in EPUB file)")) count,
translate("File path (in EPUB file)").str().c_str())
<< '\n'; << '\n';
} }
cout << format(R"( <th id="headline_{0:d}">{1:s}</th>)", count, cout << format(R"( <th id="headline_{0:d}">{1:s}</th>)", count,
translate("Last headline")) translate("Last headline").str().c_str())
<< '\n' << '\n'
<< format(R"( <th id="page_{0:d}">{1:s}</th>)", count, << format(R"( <th id="page_{0:d}">{1:s}</th>)", count,
translate("Page number")) translate("Page number").str().c_str())
<< '\n' << '\n'
<< format(R"( <th id="match_{0:d}">{1:s}</th>)", count, << format(R"( <th id="match_{0:d}">{1:s}</th>)", count,
translate("Match")) translate("Match").str().c_str())
<< "\n </tr>\n"; << "\n </tr>\n";
for (const auto &match : matches) for (const auto &match : matches)

View File

@ -84,7 +84,7 @@ std::string read_file(const fs::path &filepath, std::string_view entry_path)
"Skipping in-EPUB file.\n") "Skipping in-EPUB file.\n")
.str() .str()
.data(), .data(),
filepath); filepath.c_str());
continue; continue;
} }
if (std::strcmp(path, entry_path.data()) == 0) if (std::strcmp(path, entry_path.data()) == 0)
@ -99,8 +99,8 @@ std::string read_file(const fs::path &filepath, std::string_view entry_path)
{ {
close_file(zipfile, filepath); close_file(zipfile, filepath);
throw exception{ throw exception{format(
format(translate("Could not read {0:s} in {1:s}.").str(), translate("Could not read {0:s} in {1:s}.").str().c_str(),
entry_path, filepath.string())}; entry_path, filepath.string())};
} }
@ -115,7 +115,7 @@ std::string read_file(const fs::path &filepath, std::string_view entry_path)
if (entry_path == "META-INF/container.xml") if (entry_path == "META-INF/container.xml")
{ // File is probably not an EPUB. { // File is probably not an EPUB.
exception e{format(translate("{0:s} not found in {1:s}.").str(), exception e{format(translate("{0:s} not found in {1:s}.").str().c_str(),
entry_path, filepath.string())}; entry_path, filepath.string())};
e.code = 1; e.code = 1;
throw exception{e}; throw exception{e};
@ -145,7 +145,7 @@ struct archive *open_file(const fs::path &filepath)
{ {
close_file(zipfile, filepath); close_file(zipfile, filepath);
exception e{format(translate("Could not open {0:s}.").str(), exception e{format(translate("Could not open {0:s}.").str().c_str(),
filepath.string())}; filepath.string())};
e.code = 1; e.code = 1;
throw exception{e}; throw exception{e};
@ -159,7 +159,8 @@ void close_file(struct archive *zipfile, const fs::path &filepath)
auto result{archive_read_free(zipfile)}; auto result{archive_read_free(zipfile)};
if (result != ARCHIVE_OK) if (result != ARCHIVE_OK)
{ {
throw exception{format(translate("Could not close {0:s}.").str(), throw exception{
format(translate("Could not close {0:s}.").str().c_str(),
filepath.string())}; filepath.string())};
} }
} }