From 73681795a46a4a3e4339a8fdb16bb899a8940c10 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 9 Jan 2018 00:10:26 +0800 Subject: [PATCH] mon: s/boost::regex/std::regex/ Signed-off-by: Kefu Chai --- src/mon/HealthMonitor.cc | 18 +++++++++--------- src/mon/MDSMonitor.cc | 18 +++++++++--------- src/mon/MonCap.cc | 14 ++++++++------ 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/mon/HealthMonitor.cc b/src/mon/HealthMonitor.cc index e5c331714e954..16e3a069043bd 100644 --- a/src/mon/HealthMonitor.cc +++ b/src/mon/HealthMonitor.cc @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include "include/assert.h" #include "include/stringify.h" @@ -119,20 +119,20 @@ void HealthMonitor::encode_pending(MonitorDBStore::TransactionRef t) pending_health.merge(p.second); } for (auto &p : pending_health.checks) { - p.second.summary = boost::regex_replace( + p.second.summary = std::regex_replace( p.second.summary, - boost::regex("%hasorhave%"), + std::regex("%hasorhave%"), names[p.first].size() > 1 ? "have" : "has"); - p.second.summary = boost::regex_replace( + p.second.summary = std::regex_replace( p.second.summary, - boost::regex("%names%"), stringify(names[p.first])); - p.second.summary = boost::regex_replace( + std::regex("%names%"), stringify(names[p.first])); + p.second.summary = std::regex_replace( p.second.summary, - boost::regex("%plurals%"), + std::regex("%plurals%"), names[p.first].size() > 1 ? "s" : ""); - p.second.summary = boost::regex_replace( + p.second.summary = std::regex_replace( p.second.summary, - boost::regex("%isorare%"), + std::regex("%isorare%"), names[p.first].size() > 1 ? "are" : "is"); } diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index e92538ff6fa99..53bac5d8ce87b 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -12,9 +12,9 @@ * */ +#include #include #include -#include #include "MDSMonitor.h" #include "FSCommands.h" @@ -232,21 +232,21 @@ void MDSMonitor::encode_pending(MonitorDBStore::TransactionRef t) } pending_fsmap.get_health_checks(&new_checks); for (auto& p : new_checks.checks) { - p.second.summary = boost::regex_replace( + p.second.summary = std::regex_replace( p.second.summary, - boost::regex("%num%"), + std::regex("%num%"), stringify(p.second.detail.size())); - p.second.summary = boost::regex_replace( + p.second.summary = std::regex_replace( p.second.summary, - boost::regex("%plurals%"), + std::regex("%plurals%"), p.second.detail.size() > 1 ? "s" : ""); - p.second.summary = boost::regex_replace( + p.second.summary = std::regex_replace( p.second.summary, - boost::regex("%isorare%"), + std::regex("%isorare%"), p.second.detail.size() > 1 ? "are" : "is"); - p.second.summary = boost::regex_replace( + p.second.summary = std::regex_replace( p.second.summary, - boost::regex("%hasorhave%"), + std::regex("%hasorhave%"), p.second.detail.size() > 1 ? "have" : "has"); } encode_health(new_checks, t); diff --git a/src/mon/MonCap.cc b/src/mon/MonCap.cc index 094a3332248ad..f40b9d6669197 100644 --- a/src/mon/MonCap.cc +++ b/src/mon/MonCap.cc @@ -26,8 +26,8 @@ #include "common/Formatter.h" #include +#include -#include #include "include/assert.h" static inline bool is_not_alnum_space(char c) @@ -340,12 +340,14 @@ mon_rwxa_t MonCapGrant::get_allowed(CephContext *cct, return 0; break; case StringConstraint::MATCH_TYPE_REGEX: - { - boost::regex pattern( - p->second.value, boost::regex::extended | boost::regex::no_except); - if (pattern.empty() || !boost::regex_match(q->second, pattern)) + try { + std::regex pattern( + p->second.value, std::regex::extended); + if (!std::regex_match(q->second, pattern)) return 0; - } + } catch(const std::regex_error&) { + return 0; + } break; default: break; -- 2.39.5