Only initialize search::options once.

This commit is contained in:
tastytea 2021-05-25 10:02:34 +02:00
parent af58d6e35a
commit ce015954ea
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 27 additions and 27 deletions

View File

@ -76,39 +76,39 @@ int main(int argc, char *argv[])
}
else
{
search::options opts;
if (vm.count("basic-regexp") > 0)
{
opts.regex = search::regex_kind::basic;
}
if (vm.count("extended-regexp") > 0)
{
opts.regex = search::regex_kind::extended;
}
if (vm.count("perl-regexp") > 0)
{
opts.regex = search::regex_kind::perl;
}
if (vm.count("grep") > 0)
{
opts.grep_like = true;
}
if (vm.count("ignore-case") > 0)
{
opts.ignore_case = true;
}
if (vm.count("raw") > 0)
{
opts.raw = true;
}
opts.context = vm["context"].as<std::uint64_t>();
for (const auto &filepath :
vm["input-file"].as<std::vector<std::string>>())
{
for (const auto &regex :
vm["regexp"].as<std::vector<std::string>>())
{
search::options opts;
if (vm.count("basic-regexp") > 0)
{
opts.regex = search::regex_kind::basic;
}
if (vm.count("extended-regexp") > 0)
{
opts.regex = search::regex_kind::extended;
}
if (vm.count("perl-regexp") > 0)
{
opts.regex = search::regex_kind::perl;
}
if (vm.count("grep") > 0)
{
opts.grep_like = true;
}
if (vm.count("ignore-case") > 0)
{
opts.ignore_case = true;
}
if (vm.count("raw") > 0)
{
opts.raw = true;
}
opts.context = vm["context"].as<std::uint64_t>();
try
{
for (const auto &match :