]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: s/boost::regex/std::regex/
authorKefu Chai <kchai@redhat.com>
Mon, 8 Jan 2018 16:10:26 +0000 (00:10 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 9 Jan 2018 09:29:08 +0000 (17:29 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mon/HealthMonitor.cc
src/mon/MDSMonitor.cc
src/mon/MonCap.cc

index e5c331714e954db6472c440b9a919049c327eeb3..16e3a069043bde078cf15a22416b9d663353de37 100644 (file)
@@ -15,7 +15,7 @@
 #include <stdlib.h>
 #include <limits.h>
 #include <sstream>
-#include <boost/regex.hpp>
+#include <regex>
 
 #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");
   }
 
index e92538ff6fa99a9b2b2f2794397e2f12c357aad5..53bac5d8ce87b07ce5e9a8905df62d1b1cf0220c 100644 (file)
@@ -12,9 +12,9 @@
  * 
  */
 
+#include <regex>
 #include <sstream>
 #include <boost/utility.hpp>
-#include <boost/regex.hpp>
 
 #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);
index 094a3332248ad2c1ee04b9b6afd67b28f90257aa..f40b9d6669197b42d786bd2a016474ceaf65fda3 100644 (file)
@@ -26,8 +26,8 @@
 #include "common/Formatter.h"
 
 #include <algorithm>
+#include <regex>
 
-#include <boost/regex.hpp>
 #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;