]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/{rbd_nbd,rbd}: s/boost::regex/std::regex/
authorKefu Chai <kchai@redhat.com>
Fri, 24 Jun 2016 02:41:24 +0000 (10:41 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 9 Jan 2018 09:29:08 +0000 (17:29 +0800)
* src/tools/rbd/*: s/boost::regex/std::regex/
* */CMakeLists.txt: do not link against Boost_REGEX_LIBRARY
    anymore.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/test/CMakeLists.txt
src/tools/rbd/Utils.cc
src/tools/rbd/action/MirrorImage.cc
src/tools/rbd/action/MirrorPool.cc
src/tools/rbd_ggate/main.cc
src/tools/rbd_nbd/rbd-nbd.cc

index bc1ff4db087d47e80ad5df9d07515b9fc6a46289..375b8a13f546d6224bddba040f92a22c3b954c9a 100644 (file)
@@ -202,7 +202,6 @@ if(${WITH_RADOSGW})
     cls_rgw_client
     cls_user_client
     cls_lock_client
-    Boost::regex
     ${BLKID_LIBRARIES}
     ${CURL_LIBRARIES}
     ${EXPAT_LIBRARIES}
@@ -232,7 +231,6 @@ if(${WITH_RADOSGW})
     cls_rgw_client
     cls_user_client
     cls_lock_client
-    Boost::regex
     ${BLKID_LIBRARIES}
     ${CURL_LIBRARIES}
     ${EXPAT_LIBRARIES}
index 3728d9da8075f5ecdee28c8c92c6247f2e6717b0..ffae4896f3bed535882251bb3d1a79d320c41219 100644 (file)
@@ -13,7 +13,7 @@
 #include "common/safe_io.h"
 #include "global/global_context.h"
 #include <iostream>
-#include <boost/regex.hpp>
+#include <regex>
 #include <boost/algorithm/string.hpp>
 #include <boost/lexical_cast.hpp>
 
@@ -88,7 +88,7 @@ int extract_spec(const std::string &spec, std::string *pool_name,
     spec_validation = SPEC_VALIDATION_NONE;
   }
 
-  boost::regex pattern;
+  std::regex pattern;
   switch (spec_validation) {
   case SPEC_VALIDATION_FULL:
     // disallow "/" and "@" in image and snap name
@@ -108,8 +108,8 @@ int extract_spec(const std::string &spec, std::string *pool_name,
     break;
   }
 
-  boost::smatch match;
-  if (!boost::regex_match(spec, match, pattern)) {
+  std::smatch match;
+  if (!std::regex_match(spec, match, pattern)) {
     std::cerr << "rbd: invalid spec '" << spec << "'" << std::endl;
     return -EINVAL;
   }
@@ -129,11 +129,11 @@ int extract_spec(const std::string &spec, std::string *pool_name,
 int extract_group_spec(const std::string &spec,
                       std::string *pool_name,
                       std::string *group_name) {
-  boost::regex pattern;
+  std::regex pattern;
   pattern = "^(?:([^/]+)/)?(.+)?$";
 
-  boost::smatch match;
-  if (!boost::regex_match(spec, match, pattern)) {
+  std::smatch match;
+  if (!std::regex_match(spec, match, pattern)) {
     std::cerr << "rbd: invalid spec '" << spec << "'" << std::endl;
     return -EINVAL;
   }
@@ -150,11 +150,11 @@ int extract_group_spec(const std::string &spec,
 
 int extract_image_id_spec(const std::string &spec, std::string *pool_name,
                           std::string *image_id) {
-  boost::regex pattern;
+  std::regex pattern;
   pattern = "^(?:([^/]+)/)?(.+)?$";
 
-  boost::smatch match;
-  if (!boost::regex_match(spec, match, pattern)) {
+  std::smatch match;
+  if (!std::regex_match(spec, match, pattern)) {
     std::cerr << "rbd: invalid spec '" << spec << "'" << std::endl;
     return -EINVAL;
   }
@@ -441,8 +441,8 @@ int get_pool_image_snapshot_names(const po::variables_map &vm,
 
   //Validate pool name while creating/renaming/copying/cloning/importing/etc
   if (spec_validation == SPEC_VALIDATION_FULL) {
-    boost::regex pattern("^[^@/]+?$");
-    if ((pool_name != nullptr) && !boost::regex_match (*pool_name, pattern)) {
+    std::regex pattern("^[^@/]+?$");
+    if ((pool_name != nullptr) && !std::regex_match (*pool_name, pattern)) {
       std::cerr << "rbd: invalid pool name '" << *pool_name << "'" << std::endl;
       return -EINVAL;
     }
@@ -621,8 +621,8 @@ int validate_snapshot_name(at::ArgumentModifier mod,
 
   if (spec_validation == SPEC_VALIDATION_SNAP) {
     // disallow "/" and "@" in snap name
-    boost::regex pattern("^[^@/]*?$");
-    if (!boost::regex_match (snap_name, pattern)) {
+    std::regex pattern("^[^@/]*?$");
+    if (!std::regex_match (snap_name, pattern)) {
       std::cerr << "rbd: invalid snap name '" << snap_name << "'" << std::endl;
       return -EINVAL;
     }
index e5abf701db29979ad546d16bab3a573e99ba6603..11b6668e1367a1bfc1d82445cb9c634c65b5ed63 100644 (file)
@@ -22,7 +22,6 @@
 #include "global/global_context.h"
 #include <iostream>
 #include <boost/program_options.hpp>
-#include <boost/regex.hpp>
 
 namespace rbd {
 namespace action {
index a339687626c0a1838dfe53f589b55fa317191060..6c0968fdc9490c752e6cfe53d95f85bd3cb5844c 100644 (file)
@@ -16,8 +16,8 @@
 #include "global/global_context.h"
 #include <functional>
 #include <iostream>
+#include <regex>
 #include <boost/program_options.hpp>
-#include <boost/regex.hpp>
 #include "include/assert.h"
 
 #include <atomic>
@@ -54,10 +54,10 @@ int validate_mirroring_enabled(librados::IoCtx& io_ctx) {
 }
 
 int validate_uuid(const std::string &uuid) {
-  boost::regex pattern("^[A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12}$",
-                       boost::regex::icase);
-  boost::smatch match;
-  if (!boost::regex_match(uuid, match, pattern)) {
+  std::regex pattern("^[A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12}$",
+                       std::regex::icase);
+  std::smatch match;
+  if (!std::regex_match(uuid, match, pattern)) {
     std::cerr << "rbd: invalid uuid '" << uuid << "'" << std::endl;
     return -EINVAL;
   }
@@ -91,9 +91,9 @@ int get_remote_cluster_spec(const po::variables_map &vm,
   }
 
   if (!spec.empty()) {
-    boost::regex pattern("^(?:(client\\.[^@]+)@)?([^/@]+)$");
-    boost::smatch match;
-    if (!boost::regex_match(spec, match, pattern)) {
+    std::regex pattern("^(?:(client\\.[^@]+)@)?([^/@]+)$");
+    std::smatch match;
+    if (!std::regex_match(spec, match, pattern)) {
       std::cerr << "rbd: invalid spec '" << spec << "'" << std::endl;
       return -EINVAL;
     }
index 9dc501a5d3b63b5155785a10c454fbba1f8a0ea3..2a936930ce50d31f01d84f6ce306174040352963 100644 (file)
@@ -15,7 +15,7 @@
 #include <iostream>
 #include <memory>
 #include <boost/algorithm/string/predicate.hpp>
-#include <boost/regex.hpp>
+#include <regex>
 
 #include "common/Formatter.h"
 #include "common/Preforker.h"
@@ -253,9 +253,10 @@ static int do_unmap()
 
 static int parse_imgpath(const std::string &imgpath, std::string *poolname,
                          std::string *imgname, std::string *snapname) {
-  boost::regex pattern("^(?:([^/@]+)/)?([^/@]+)(?:@([^/@]+))?$");
-  boost::smatch match;
-  if (!boost::regex_match(imgpath, match, pattern)) {
+{
+  std::regex pattern("^(?:([^/@]+)/)?([^/@]+)(?:@([^/@]+))?$");
+  std::smatch match;
+  if (!std::regex_match(imgpath, match, pattern)) {
     std::cerr << "rbd-ggate: invalid spec '" << imgpath << "'" << std::endl;
     return -EINVAL;
   }
index 777d5447f36110be2981a1b5f7a74a5d4978747d..7a097261077dd8abc2f8f35bed850d517122736f 100644 (file)
@@ -35,7 +35,7 @@
 #include <fstream>
 #include <iostream>
 #include <memory>
-#include <boost/regex.hpp>
+#include <regex>
 #include <boost/algorithm/string/predicate.hpp>
 
 #include "common/Formatter.h"
@@ -923,10 +923,10 @@ static int do_unmap(const std::string &devpath)
 
 static int parse_imgpath(const std::string &imgpath, Config *cfg,
                          std::ostream *err_msg) {
-  boost::regex pattern("^(?:([^/@]+)/)?([^/@]+)(?:@([^/@]+))?$");
-  boost::smatch match;
-  if (!boost::regex_match(imgpath, match, pattern)) {
-    *err_msg << "rbd-nbd: invalid spec '" << imgpath << "'";
+  std::regex pattern("^(?:([^/@]+)/)?([^/@]+)(?:@([^/@]+))?$");
+  std::smatch match;
+  if (!std::regex_match(imgpath, match, pattern)) {
+    std::cerr << "rbd-nbd: invalid spec '" << imgpath << "'" << std::endl;
     return -EINVAL;
   }