Skip to content

Commit

Permalink
COMMON: Replace Boost.Regex in FilePath with C++11's regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Nostritius authored and DrMcCoy committed May 26, 2019
1 parent f8ae33c commit 16649f9
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/common/filepath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
*/

#include <list>
#include <regex>

#include <boost/algorithm/string.hpp>
#include <boost/filesystem.hpp>
#include <boost/regex.hpp>

#include "src/common/filepath.h"
#include "src/common/util.h"
Expand Down Expand Up @@ -115,11 +115,12 @@ bool FilePath::isAbsolute(const UString &p) {
}

static path convertToSlash(const path &p) {
const boost::regex bSlash("\\\\");
const std::regex bSlash("\\\\");
const std::string fSlash("/");
const boost::match_flag_type flags(boost::match_default | boost::format_sed);
const std::regex_constants::match_flag_type flags(
std::regex_constants::match_default | std::regex_constants::format_sed);

return path(boost::regex_replace(p.string(), bSlash, fSlash, flags));
return path(std::regex_replace(p.string(), bSlash, fSlash, flags));
}

UString FilePath::absolutize(const UString &p) {
Expand Down Expand Up @@ -348,10 +349,15 @@ bool FilePath::createDirectories(const UString &path) {
}

UString FilePath::escapeStringLiteral(const UString &str) {
const boost::regex esc("[\\^\\.\\$\\|\\(\\)\\[\\]\\*\\+\\?\\/\\\\]");
const std::regex esc("[\\^\\.\\$\\|\\(\\)\\[\\]\\*\\+\\?\\/\\\\]");
const std::string rep("\\\\\\1&");

return boost::regex_replace(std::string(str.c_str()), esc, rep, boost::match_default | boost::format_sed);
return std::regex_replace(
std::string(str.c_str()),
esc,
rep,
std::regex_constants::match_default | std::regex_constants::format_sed
);
}

UString FilePath::getHumanReadableSize(size_t size) {
Expand Down

0 comments on commit 16649f9

Please sign in to comment.