summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/util/corefile.cpp
diff options
context:
space:
mode:
author Nathan Woods <npwoods@mess.org>2016-07-11 10:20:56 -0400
committer Nathan Woods <npwoods@mess.org>2016-07-11 10:20:56 -0400
commit0e4cb93bc58d8b598bee9ff4ea6e5949853fadeb (patch)
tree371287647271bc3afd4e4ede5098c1548f7c71ed /src/lib/util/corefile.cpp
parent2bd5932b42b56741dee27bf25bdac4158aaa6696 (diff)
Adopting std::find() and std::find_if() in core_filename_extract_base()
Diffstat (limited to 'src/lib/util/corefile.cpp')
-rw-r--r--src/lib/util/corefile.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/lib/util/corefile.cpp b/src/lib/util/corefile.cpp
index 725316b0dff..0fe87f15982 100644
--- a/src/lib/util/corefile.cpp
+++ b/src/lib/util/corefile.cpp
@@ -1273,20 +1273,18 @@ core_file::core_file()
std::string core_filename_extract_base(const std::string &name, bool strip_extension)
{
// find the start of the basename
- auto start = name.end();
- while (start != name.begin() && !util::is_directory_separator(start[-1]))
- start--;
+ auto const start = std::find_if(name.rbegin(), name.rend(), [](char c) { return util::is_directory_separator(c); });
// find the end of the basename
- auto chop_position = strip_extension
- ? name.find_last_of('.')
- : std::string::npos;
- auto end = chop_position != std::string::npos
- ? name.begin() + chop_position
- : name.end();
+ auto const chop_position = strip_extension
+ ? std::find(name.rbegin(), start, '.')
+ : start;
+ auto const end = (chop_position != start)
+ ? chop_position + 1
+ : name.rbegin();
// copy the result into an string
- std::string result(start, end);
+ std::string result(start.base(), end.base());
return result;
}