Merge pull request #19393 from tchaikov/wip-no-more-gcc-4.8

rgw,common,rbd: s/boost::regex/std::regex/

Reviewed-by: Adam C. Emerson <aemerson@redhat.com>
This commit is contained in:
Kefu Chai 2018-01-10 22:10:21 +08:00 committed by GitHub
commit 3f45280ac4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 104 additions and 110 deletions

View File

@ -627,7 +627,6 @@ set(ceph_common_deps
json_spirit erasure_code ${LIB_RESOLV}
Boost::thread
Boost::system
Boost::regex
Boost::random
Boost::program_options
Boost::date_time

View File

@ -8,20 +8,17 @@
*/
#include <netdb.h>
#include <regex>
#include "common/address_helper.h"
#include "boost/regex.hpp"
// decode strings like "tcp://<host>:<port>"
int entity_addr_from_url(entity_addr_t *addr /* out */, const char *url)
{
using namespace boost;
std::regex expr("(tcp|rdma)://([^:]*):([\\d]+)");
std::cmatch m;
regex expr("(tcp|rdma)://([^:]*):([\\d]+)");
cmatch m;
if (regex_match(url, m, expr)) {
if (std::regex_match(url, m, expr)) {
string host(m[2].first, m[2].second);
string port(m[3].first, m[3].second);
addrinfo hints;

View File

@ -9,7 +9,7 @@
#include "include/stringify.h"
#include <boost/algorithm/string.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/regex.hpp>
#include <regex>
// Definitions for enums
#include "common/perf_counters.h"
@ -5684,8 +5684,8 @@ static std::vector<Option> get_rbd_options() {
.set_default("rbd")
.set_description("default pool for storing new images")
.set_validator([](std::string *value, std::string *error_message){
boost::regex pattern("^[^@/]+$");
if (!boost::regex_match (*value, pattern)) {
std::regex pattern("^[^@/]+$");
if (!std::regex_match (*value, pattern)) {
*value = "rbd";
*error_message = "invalid RBD default pool, resetting to 'rbd'";
}
@ -5696,8 +5696,8 @@ static std::vector<Option> get_rbd_options() {
.set_default("")
.set_description("default pool for storing data blocks for new images")
.set_validator([](std::string *value, std::string *error_message){
boost::regex pattern("^[^@/]*$");
if (!boost::regex_match (*value, pattern)) {
std::regex pattern("^[^@/]*$");
if (!std::regex_match (*value, pattern)) {
*value = "";
*error_message = "ignoring invalid RBD data pool";
}

View 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");
}

View 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);

View 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;

View File

@ -4,6 +4,7 @@
#include <cstring>
#include <iostream>
#include <regex>
#include <sstream>
#include <stack>
#include <utility>
@ -26,7 +27,10 @@ using std::find;
using std::int64_t;
using std::move;
using std::pair;
using std::regex;
using std::regex_match;
using std::size_t;
using std::smatch;
using std::string;
using std::stringstream;
using std::ostream;
@ -35,11 +39,11 @@ using std::uint64_t;
using std::unordered_map;
using boost::container::flat_set;
using boost::regex;
using boost::regex_constants::ECMAScript;
using boost::regex_constants::optimize;
using boost::regex_match;
using boost::smatch;
using std::regex;
using std::regex_constants::ECMAScript;
using std::regex_constants::optimize;
using std::regex_match;
using std::smatch;
using rapidjson::BaseReaderHandler;
using rapidjson::UTF8;
@ -205,15 +209,13 @@ ARN::ARN(const rgw_bucket& b, const string& o)
}
boost::optional<ARN> ARN::parse(const string& s, bool wildcards) {
static const char str_wild[] = "arn:([^:]*):([^:]*):([^:]*):([^:]*):([^:]*)";
static const regex rx_wild(str_wild,
sizeof(str_wild) - 1,
ECMAScript | optimize);
static const char str_no_wild[]
= "arn:([^:*]*):([^:*]*):([^:*]*):([^:*]*):([^:*]*)";
static const regex rx_no_wild(str_no_wild,
sizeof(str_no_wild) - 1,
ECMAScript | optimize);
static const regex rx_wild("arn:([^:]*):([^:]*):([^:]*):([^:]*):([^:]*)",
std::regex_constants::ECMAScript |
std::regex_constants::optimize);
static const regex rx_no_wild(
"arn:([^:*]*):([^:*]*):([^:*]*):([^:*]*):([^:*]*)",
std::regex_constants::ECMAScript |
std::regex_constants::optimize);
smatch match;
@ -738,7 +740,8 @@ static boost::optional<Principal> parse_principal(CephContext* cct, TokenID t,
static const char rx_str[] = "([^/]*)/(.*)";
static const regex rx(rx_str, sizeof(rx_str) - 1,
ECMAScript | optimize);
std::regex_constants::ECMAScript |
std::regex_constants::optimize);
smatch match;
if (regex_match(a->resource, match, rx) && match.size() == 3) {
if (match[1] == "user") {

View File

@ -1,7 +1,6 @@
#include <errno.h>
#include <ctime>
#include <boost/regex.hpp>
#include <regex>
#include "common/errno.h"
#include "common/Formatter.h"
@ -377,14 +376,14 @@ bool RGWRole::validate_input()
return false;
}
boost::regex regex_name("[A-Za-z0-9:=,.@-]+");
if (! boost::regex_match(name, regex_name)) {
std::regex regex_name("[A-Za-z0-9:=,.@-]+");
if (! std::regex_match(name, regex_name)) {
ldout(cct, 0) << "ERROR: Invalid chars in name " << dendl;
return false;
}
boost::regex regex_path("(/[!-~]+/)|(/)");
if (! boost::regex_match(path,regex_path)) {
std::regex regex_path("(/[!-~]+/)|(/)");
if (! std::regex_match(path,regex_path)) {
ldout(cct, 0) << "ERROR: Invalid chars in path " << dendl;
return false;
}

View File

@ -1,7 +1,7 @@
#ifndef CEPH_RGW_SYNC_TRACE_H
#define CEPH_RGW_SYNC_TRACE_H
#include <boost/regex.hpp>
#include <regex>
#include "common/debug.h"
#include "common/ceph_json.h"
@ -92,8 +92,8 @@ RGWSyncTraceNodeRef RGWSyncTraceManager::add_node(RGWSyncTraceNode *node)
bool RGWSyncTraceNode::match(const string& search_term, bool search_history)
{
try {
boost::regex expr(search_term);
boost::smatch m;
std::regex expr(search_term);
std::smatch m;
if (regex_search(prefix, m, expr)) {
return true;
@ -110,10 +110,8 @@ bool RGWSyncTraceNode::match(const string& search_term, bool search_history)
return true;
}
}
} catch (boost::bad_expression const& e) {
} catch (const std::regex_error& e) {
ldout(cct, 5) << "NOTICE: sync trace: bad expression: bad regex search term" << dendl;
} catch (...) {
ldout(cct, 5) << "NOTICE: sync trace: regex_search() threw exception" << dendl;
}
return false;

View 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}

View File

@ -13,8 +13,8 @@
*/
#include <iostream>
#include <regex> // For regex, regex_search
#include <boost/filesystem/convenience.hpp> // For extension
#include <boost/regex.hpp> // For regex, regex_search
#include "common/admin_socket_client.h" // For AdminSocketClient
#include "common/ceph_json.h" // For JSONParser, JSONObjIter
@ -78,8 +78,8 @@ bool AdminSocketOutput::init_sockets() {
std::cout << x.path() << std::endl;
if (bfs::extension(x.path()) == ".asok") {
for (auto &target : targets) {
if (boost::regex_search(x.path().filename().string(),
boost::regex(prefix + target + R"(\..*\.asok)"))) {
if (std::regex_search(x.path().filename().string(),
std::regex(prefix + target + R"(\..*\.asok)"))) {
std::cout << "Found " << target << " socket " << x.path()
<< std::endl;
sockets.insert(std::make_pair(target, x.path().string()));

View File

@ -2,10 +2,8 @@
// vim: ts=8 sw=2 smarttab
#include <boost/algorithm/string.hpp>
// std::regex support in libstdc++ 4.8 is incomplete, so let's stick to
// boost::regex now.
#include <boost/regex.hpp>
#include <gtest/gtest.h>
#include <regex>
#include <sstream>
#include <string>
@ -34,7 +32,7 @@ TEST(BackTrace, Basic) {
const unsigned lineno = 1;
ASSERT_GT(lines.size(), lineno);
ASSERT_EQ(lines[0].find(pretty_version_to_str()), 1U);
boost::regex e{"^ 1: "
std::regex e{"^ 1: "
#ifdef __FreeBSD__
"<foo.*>\\s"
"at\\s.*$"};
@ -42,5 +40,5 @@ TEST(BackTrace, Basic) {
"\\(foo.*\\)\\s"
"\\[0x[[:xdigit:]]+\\]$"};
#endif
EXPECT_TRUE(boost::regex_match(lines[lineno], e));
EXPECT_TRUE(std::regex_match(lines[lineno], e));
}

View File

@ -19,7 +19,7 @@
#include <map>
#include <sstream>
#include <string>
#include <boost/regex.hpp>
#include <regex>
using namespace librados;
using std::map;
@ -1249,7 +1249,7 @@ TEST_F(LibRadosMisc, Applications) {
string result(buf);
rados_buffer_free(buf);
rados_buffer_free(st);
if (!boost::regex_search(result, boost::regex("require_osd_release [l-z]"))) {
if (!std::regex_search(result, std::regex("require_osd_release [l-z]"))) {
std::cout << "SKIPPING";
return;
}
@ -1318,8 +1318,8 @@ TEST_F(LibRadosMiscPP, Applications) {
inbl, &outbl, &outs));
ASSERT_LT(0u, outbl.length());
ASSERT_LE(0u, outs.length());
if (!boost::regex_search(outbl.to_str(),
boost::regex("require_osd_release [l-z]"))) {
if (!std::regex_search(outbl.to_str(),
std::regex("require_osd_release [l-z]"))) {
std::cout << "SKIPPING";
return;
}

View 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;
}

View 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 {

View 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;
}

View 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;
}

View 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;
}