Compare commits
No commits in common. "main" and "0.6.1" have entirely different histories.
|
@ -1,3 +1,4 @@
|
|||
# -*- mode: conf; fill-column: 100; -*-
|
||||
# Written for clang-tidy 14.
|
||||
|
||||
---
|
||||
|
@ -45,10 +46,6 @@ CheckOptions: # ↓ Clashes with static private member prefix. (static int _va
|
|||
- { key: readability-identifier-naming.EnumCase, value: lower_case }
|
||||
- { key: readability-identifier-naming.FunctionCase, value: lower_case }
|
||||
- { key: readability-identifier-naming.ParameterCase, value: lower_case }
|
||||
|
||||
- { key: readability-function-cognitive-complexity.Threshold, value: 30 }
|
||||
- { key: readability-identifier-length.MinimumVariableNameLength, value: 2 }
|
||||
...
|
||||
|
||||
# -*- mode: yaml; fill-column: 100; -*-
|
||||
# vim: set fenc=utf-8 tw=100 et ft=yaml:
|
||||
# vim: set et tw=100:
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"format": {
|
||||
"disable": true
|
||||
}
|
||||
}
|
14
.drone.yml
14
.drone.yml
|
@ -155,7 +155,7 @@ steps:
|
|||
- rm /etc/apt/apt.conf.d/docker-clean
|
||||
- alias apt-get='rm -f /var/cache/apt/archives/lock && apt-get'
|
||||
- apt-get update -q
|
||||
- apt-get install -qq build-essential cmake clang locales lsb-release file
|
||||
- apt-get install -qq build-essential cmake clang locales lsb-release
|
||||
- apt-get install -qq libboost-program-options-dev libboost-locale-dev libboost-regex-dev libboost-log-dev gettext libarchive-dev libfmt-dev libpugixml-dev nlohmann-json3-dev
|
||||
- apt-get install -qq --no-install-recommends asciidoc xsltproc
|
||||
- rm -rf build_deb && mkdir -p build_deb && cd build_deb
|
||||
|
@ -181,7 +181,7 @@ steps:
|
|||
- rm /etc/apt/apt.conf.d/docker-clean
|
||||
- alias apt-get='rm -f /var/cache/apt/archives/lock && apt-get'
|
||||
- apt-get update -q
|
||||
- apt-get install -qq build-essential cmake clang locales lsb-release file
|
||||
- apt-get install -qq build-essential cmake clang locales lsb-release
|
||||
- apt-get install -qq libboost-program-options-dev libboost-locale-dev libboost-regex-dev libboost-log-dev gettext libarchive-dev libfmt-dev libpugixml-dev nlohmann-json-dev
|
||||
- apt-get install -qq --no-install-recommends asciidoc xsltproc
|
||||
- rm -rf build_deb && mkdir -p build_deb && cd build_deb
|
||||
|
@ -208,7 +208,7 @@ steps:
|
|||
- rm /etc/apt/apt.conf.d/docker-clean
|
||||
- alias apt-get='rm -f /var/cache/apt/archives/lock && apt-get'
|
||||
- apt-get update -q
|
||||
- apt-get install -qq build-essential cmake clang locales lsb-release file
|
||||
- apt-get install -qq build-essential cmake clang locales lsb-release
|
||||
- apt-get install -qq libboost-program-options-dev libboost-locale-dev libboost-regex-dev libboost-log-dev gettext libarchive-dev libfmt-dev libpugixml-dev nlohmann-json3-dev
|
||||
- apt-get install -qq --no-install-recommends asciidoc xsltproc
|
||||
- rm -rf build_deb && mkdir -p build_deb && cd build_deb
|
||||
|
@ -246,7 +246,7 @@ steps:
|
|||
- rm /etc/apt/apt.conf.d/docker-clean
|
||||
- alias apt-get='rm -f /var/cache/apt/archives/lock && apt-get'
|
||||
- apt-get update -q
|
||||
- apt-get install -qq g++-8 build-essential clang locales lsb-release file
|
||||
- apt-get install -qq g++-8 build-essential clang locales lsb-release
|
||||
- apt-get install -qq libboost-program-options-dev libboost-locale-dev libboost-regex-dev libboost-log-dev gettext libarchive-dev libfmt-dev libpugixml-dev nlohmann-json-dev
|
||||
- apt-get install -qq --no-install-recommends asciidoc xsltproc
|
||||
- sh cmake_installer.sh --skip-license --exclude-subdir --prefix=/usr/local
|
||||
|
@ -304,12 +304,6 @@ steps:
|
|||
- epubgrep-${DRONE_TAG}-0.x86_64.opensuse-$(lsb_release --release --short).rpm
|
||||
checksum:
|
||||
- sha512
|
||||
depends_on:
|
||||
- Debian bullseye
|
||||
- Debian buster
|
||||
- Ubuntu focal
|
||||
- Ubuntu bionic
|
||||
- openSUSE Leap 15
|
||||
|
||||
- name: notification
|
||||
image: drillster/drone-email
|
||||
|
|
|
@ -5,7 +5,7 @@ set(CMAKE_BUILD_TYPE "Release" CACHE STRING "The type of build.")
|
|||
set(XGETTEXT_CMD "xgettext" CACHE STRING "The command for xgettext.")
|
||||
|
||||
project(epubgrep
|
||||
VERSION 0.6.2
|
||||
VERSION 0.6.0
|
||||
DESCRIPTION "Search tool for EPUB e-books"
|
||||
HOMEPAGE_URL "https://schlomp.space/tastytea/epubgrep"
|
||||
LANGUAGES CXX)
|
||||
|
|
21
README.adoc
21
README.adoc
|
@ -169,25 +169,4 @@ install ./epubgrep-*.rpm+++` or `+++dnf install ./epubgrep-*.rpm+++`.
|
|||
* zipgrep from link:http://infozip.sourceforge.net/[unzip] can search EPUB files
|
||||
but does not strip HTML and does not display page numbers or headings.
|
||||
|
||||
== Performance
|
||||
|
||||
A test with a directory containing 3333 EPUBs and 6269 files in total showed
|
||||
this difference between epubgrep-0.6.2 and ripgrep-all-0.9.6:
|
||||
|
||||
[source,shellsession]
|
||||
--------------------------------------------------------------------------------
|
||||
% hyperfine "epubgrep 'floor' ~/Books" "rga 'floor' ~/Books"
|
||||
Benchmark #1: epubgrep 'floor' ~/Books
|
||||
Time (mean ± σ): 167.246 s ± 3.848 s [User: 176.251 s, System: 79.107 s]
|
||||
Range (min … max): 161.533 s … 173.647 s 10 runs
|
||||
|
||||
Benchmark #2: rga 'floor' ~/Books
|
||||
Time (mean ± σ): 9.219 s ± 0.506 s [User: 17.540 s, System: 12.773 s]
|
||||
Range (min … max): 8.571 s … 9.923 s 10 runs
|
||||
|
||||
Summary
|
||||
'rga 'floor' ~/Books' ran
|
||||
18.14 ± 1.08 times faster than 'epubgrep 'floor' ~/Books'
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
include::{uri-base}/raw/branch/main/CONTRIBUTING.adoc[]
|
||||
|
|
|
@ -295,8 +295,8 @@ std::vector<string> list_spine(const fs::path &filepath)
|
|||
<< format(translate("{0:s} is damaged. Could not read spine. "
|
||||
"Skipping file.\n")
|
||||
.str()
|
||||
.c_str(),
|
||||
filepath.c_str());
|
||||
.data(),
|
||||
filepath);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
21
src/main.cpp
21
src/main.cpp
|
@ -126,10 +126,8 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
LOG(log::sev::error)
|
||||
<< format(translate("Could not open {0:s}: {1:s}")
|
||||
.str()
|
||||
.c_str(),
|
||||
e.path1().c_str(), e.what());
|
||||
<< format(translate("Could not open {0:s}: {1:s}").str(),
|
||||
e.path1(), e.what());
|
||||
return_code = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
@ -178,10 +176,8 @@ int main(int argc, char *argv[])
|
|||
{
|
||||
LOG(log::sev::error)
|
||||
<< std::strerror(errno) // FIXME: Not thread safe.
|
||||
<< format(translate(" (while opening {0:s})")
|
||||
.str()
|
||||
.c_str(),
|
||||
filepath.c_str());
|
||||
<< format(translate(" (while opening {0:s})").str(),
|
||||
filepath);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
catch (const boost::regex_error &e)
|
||||
|
@ -237,11 +233,10 @@ int main(int argc, char *argv[])
|
|||
while (cancel.wait_for(std::chrono::seconds(opts.status_interval))
|
||||
!= std::future_status::ready)
|
||||
{
|
||||
std::cerr << format(translate("{0:d} of {1:d} books searched.")
|
||||
.str()
|
||||
.c_str(),
|
||||
books_searched, input_files.size())
|
||||
<< '\n';
|
||||
std::cerr
|
||||
<< format(translate("{0:d} of {1:d} books searched.").str(),
|
||||
books_searched, input_files.size())
|
||||
<< '\n';
|
||||
}
|
||||
std::cerr << translate("All books searched.") << '\n';
|
||||
}};
|
||||
|
|
|
@ -45,7 +45,7 @@ void print_matches(const std::vector<search::match> &matches,
|
|||
cout << termcolor::yellow;
|
||||
}
|
||||
cout << format(translate(" In {0:s}: \n").str().c_str(),
|
||||
fs::relative(matches[0].filepath_epub).c_str());
|
||||
fs::relative(matches[0].filepath_epub));
|
||||
if (!opts.nocolor)
|
||||
{
|
||||
cout << termcolor::reset;
|
||||
|
@ -169,18 +169,17 @@ void html_all(const std::vector<std::vector<search::match>> &matches_all,
|
|||
if (!opts.no_fn_epub)
|
||||
{
|
||||
cout << format(R"( <th id="file_path_{0:d}">{1:s}</th>)",
|
||||
count,
|
||||
translate("File path (in EPUB file)").str().c_str())
|
||||
count, translate("File path (in EPUB file)"))
|
||||
<< '\n';
|
||||
}
|
||||
cout << format(R"( <th id="headline_{0:d}">{1:s}</th>)", count,
|
||||
translate("Last headline").str().c_str())
|
||||
translate("Last headline"))
|
||||
<< '\n'
|
||||
<< format(R"( <th id="page_{0:d}">{1:s}</th>)", count,
|
||||
translate("Page number").str().c_str())
|
||||
translate("Page number"))
|
||||
<< '\n'
|
||||
<< format(R"( <th id="match_{0:d}">{1:s}</th>)", count,
|
||||
translate("Match").str().c_str())
|
||||
translate("Match"))
|
||||
<< "\n </tr>\n";
|
||||
|
||||
for (const auto &match : matches)
|
||||
|
|
19
src/zip.cpp
19
src/zip.cpp
|
@ -56,7 +56,7 @@ std::vector<std::string> list(const fs::path &filepath)
|
|||
"Skipping in-EPUB file.\n")
|
||||
.str()
|
||||
.c_str(),
|
||||
filepath.c_str());
|
||||
filepath);
|
||||
continue;
|
||||
}
|
||||
toc.emplace_back(in_epub_filepath);
|
||||
|
@ -84,7 +84,7 @@ std::string read_file(const fs::path &filepath, std::string_view entry_path)
|
|||
"Skipping in-EPUB file.\n")
|
||||
.str()
|
||||
.data(),
|
||||
filepath.c_str());
|
||||
filepath);
|
||||
continue;
|
||||
}
|
||||
if (std::strcmp(path, entry_path.data()) == 0)
|
||||
|
@ -99,9 +99,9 @@ std::string read_file(const fs::path &filepath, std::string_view entry_path)
|
|||
{
|
||||
close_file(zipfile, filepath);
|
||||
|
||||
throw exception{format(
|
||||
translate("Could not read {0:s} in {1:s}.").str().c_str(),
|
||||
entry_path, filepath.string())};
|
||||
throw exception{
|
||||
format(translate("Could not read {0:s} in {1:s}.").str(),
|
||||
entry_path, filepath.string())};
|
||||
}
|
||||
|
||||
close_file(zipfile, filepath);
|
||||
|
@ -115,7 +115,7 @@ std::string read_file(const fs::path &filepath, std::string_view entry_path)
|
|||
|
||||
if (entry_path == "META-INF/container.xml")
|
||||
{ // File is probably not an EPUB.
|
||||
exception e{format(translate("{0:s} not found in {1:s}.").str().c_str(),
|
||||
exception e{format(translate("{0:s} not found in {1:s}.").str(),
|
||||
entry_path, filepath.string())};
|
||||
e.code = 1;
|
||||
throw exception{e};
|
||||
|
@ -145,7 +145,7 @@ struct archive *open_file(const fs::path &filepath)
|
|||
{
|
||||
close_file(zipfile, filepath);
|
||||
|
||||
exception e{format(translate("Could not open {0:s}.").str().c_str(),
|
||||
exception e{format(translate("Could not open {0:s}.").str(),
|
||||
filepath.string())};
|
||||
e.code = 1;
|
||||
throw exception{e};
|
||||
|
@ -159,9 +159,8 @@ void close_file(struct archive *zipfile, const fs::path &filepath)
|
|||
auto result{archive_read_free(zipfile)};
|
||||
if (result != ARCHIVE_OK)
|
||||
{
|
||||
throw exception{
|
||||
format(translate("Could not close {0:s}.").str().c_str(),
|
||||
filepath.string())};
|
||||
throw exception{format(translate("Could not close {0:s}.").str(),
|
||||
filepath.string())};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,16 +5,11 @@ file(COPY "test.epub3" DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
|||
|
||||
find_package(Catch2 CONFIG)
|
||||
|
||||
if(Catch2_FOUND) # Catch 2.x / 3.x
|
||||
if(Catch2_FOUND) # Catch 2.x
|
||||
include(Catch)
|
||||
add_executable(all_tests main.cpp ${sources_tests})
|
||||
if(TARGET Catch2::Catch2WithMain) # Catch 3.x
|
||||
target_link_libraries(all_tests
|
||||
PRIVATE Catch2::Catch2WithMain ${PROJECT_NAME}_lib)
|
||||
else() # Catch 2.x
|
||||
target_link_libraries(all_tests
|
||||
PRIVATE Catch2::Catch2 ${PROJECT_NAME}_lib)
|
||||
endif()
|
||||
target_link_libraries(all_tests
|
||||
PRIVATE Catch2::Catch2 ${PROJECT_NAME}_lib)
|
||||
target_include_directories(all_tests PRIVATE "/usr/include/catch2")
|
||||
catch_discover_tests(all_tests EXTRA_ARGS "${EXTRA_TEST_ARGS}")
|
||||
else() # Catch 1.x
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
#define CATCH_CONFIG_MAIN
|
||||
|
||||
// catch 3 does not have catch.hpp anymore
|
||||
#if __has_include(<catch.hpp>)
|
||||
# include <catch.hpp>
|
||||
#else
|
||||
# include <catch_all.hpp>
|
||||
#endif
|
||||
#include <catch.hpp>
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
#include "fs-compat.hpp"
|
||||
#include "helpers.hpp"
|
||||
|
||||
// catch 3 does not have catch.hpp anymore
|
||||
#if __has_include(<catch.hpp>)
|
||||
# include <catch.hpp>
|
||||
#else
|
||||
# include <catch_all.hpp>
|
||||
#endif
|
||||
#include <catch.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <exception>
|
||||
|
|
|
@ -2,12 +2,7 @@
|
|||
#include "options.hpp"
|
||||
#include "search.hpp"
|
||||
|
||||
// catch 3 does not have catch.hpp anymore
|
||||
#if __has_include(<catch.hpp>)
|
||||
# include <catch.hpp>
|
||||
#else
|
||||
# include <catch_all.hpp>
|
||||
#endif
|
||||
#include <catch.hpp>
|
||||
|
||||
#include <clocale>
|
||||
#include <exception>
|
||||
|
|
|
@ -2,12 +2,7 @@
|
|||
#include "fs-compat.hpp"
|
||||
#include "search.hpp"
|
||||
|
||||
// catch 3 does not have catch.hpp anymore
|
||||
#if __has_include(<catch.hpp>)
|
||||
# include <catch.hpp>
|
||||
#else
|
||||
# include <catch_all.hpp>
|
||||
#endif
|
||||
#include <catch.hpp>
|
||||
|
||||
#include <clocale>
|
||||
#include <exception>
|
||||
|
|
|
@ -2,12 +2,7 @@
|
|||
#include "options.hpp"
|
||||
#include "search.hpp"
|
||||
|
||||
// catch 3 does not have catch.hpp anymore
|
||||
#if __has_include(<catch.hpp>)
|
||||
# include <catch.hpp>
|
||||
#else
|
||||
# include <catch_all.hpp>
|
||||
#endif
|
||||
#include <catch.hpp>
|
||||
|
||||
#include <clocale>
|
||||
#include <exception>
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
#include "fs-compat.hpp"
|
||||
#include "zip.hpp"
|
||||
|
||||
// catch 3 does not have catch.hpp anymore
|
||||
#if __has_include(<catch.hpp>)
|
||||
# include <catch.hpp>
|
||||
#else
|
||||
# include <catch_all.hpp>
|
||||
#endif
|
||||
#include <catch.hpp>
|
||||
|
||||
#include <clocale>
|
||||
#include <exception>
|
||||
|
|
Loading…
Reference in New Issue
Block a user