Skip to content

Commit fd6497c

Browse files
Fixing issue with invalid usage of boost
1 parent ead8a31 commit fd6497c

File tree

4 files changed

+76
-34
lines changed

4 files changed

+76
-34
lines changed

util/functions.cc

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,21 @@ void Verify_call_parameters::extract_type_spec_fragments(
178178
util::string* required_args,
179179
util::string* optional_args)
180180
{
181-
util::strings type_spec_fragments;
182-
const char* Optional_args_separator{ "|" };
183-
boost::split(type_spec_fragments, type_spec, boost::is_any_of(Optional_args_separator));
184-
if (type_spec_fragments.size() < 2) {
185-
type_spec_fragments.resize(2);
186-
} else if (2 < type_spec_fragments.size()) {
187-
throw verify_error("only one optional args block is allowed");
181+
bool separator_found{ false };
182+
const char Optional_args_separator{ '|' };
183+
for( size_t i { 0 } ; i < type_spec.size(); ++i ) {
184+
if( type_spec[i] == Optional_args_separator ) {
185+
if( separator_found ) {
186+
throw verify_error("only one optional args block is allowed");
187+
}
188+
*required_args = type_spec.substr( 0, i );
189+
*optional_args = type_spec.substr( i + 1, type_spec.size() - i + 1 );
190+
separator_found = true;
191+
}
192+
}
193+
if( !separator_found ) {
194+
*required_args = type_spec;
188195
}
189-
190-
*required_args = type_spec_fragments.front();
191-
*optional_args = type_spec_fragments.back();
192196
}
193197

194198
Type_spec Verify_call_parameters::create_type_spec(const util::string& raw_args)

util/strings.cc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,30 @@ std::ostream& operator<<(std::ostream& os, const string& str)
2828
return os << str.c_str();
2929
}
3030

31+
32+
void single_separator_split(
33+
util::vector< util::string >& output,
34+
const util::string& input,
35+
const char separator
36+
)
37+
{
38+
if( input.empty() ) {
39+
return;
40+
}
41+
size_t idx{ 0 }, last{ 0 };
42+
for( ; idx < input.size() ; ++idx ){
43+
if( input[ idx ] == separator ) {
44+
util::string token = input.substr( last, idx - last );
45+
output.push_back( token );
46+
last = idx + 1;
47+
}
48+
}
49+
if( idx >= last ) {
50+
util::string token = input.substr( last );
51+
output.push_back( token );
52+
}
53+
}
54+
3155
} // namespace util
3256

3357
} // namespace mysqlx

util/strings.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ using wformatter = basic_formatter<wchar_t>;
6868
using std_strings = std::vector<std::string>;
6969
using std_stringset = std::set<std::string>;
7070

71+
void single_separator_split(
72+
util::vector< util::string >& output,
73+
const util::string& input,
74+
const char separator
75+
);
76+
77+
7178
} // namespace util
7279

7380
} // namespace mysqlx

xmysqlnd/xmysqlnd_session.cc

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -449,11 +449,13 @@ xmysqlnd_session_data::quote_name(const util::string_view& name)
449449
util::string ret;
450450
if (!name.empty()) {
451451
ret = '`';
452-
boost::replace_all_copy(
453-
std::back_inserter(ret),
454-
name,
455-
"`",
456-
"``");
452+
for( const auto& elem : name ) {
453+
if( elem == '`' ) {
454+
ret += "``";
455+
} else {
456+
ret += elem;
457+
}
458+
}
457459
ret += '`';
458460
}
459461
DBG_RETURN(ret);
@@ -2374,17 +2376,17 @@ xmysqlnd_session::get_server_version()
23742376
return 0;
23752377
}
23762378

2377-
std::vector<std::string> server_version_fragments;
2378-
const char* Version_separator{ "." };
2379-
boost::split(server_version_fragments, server_version_string, boost::is_any_of(Version_separator));
2379+
util::vector<util::string> server_version_fragments;
2380+
util::string version_string{ server_version_string };
2381+
mysqlx::util::single_separator_split(server_version_fragments, version_string, '.');
23802382

23812383
if (server_version_fragments.size() != 3) {
23822384
return 0;
23832385
}
23842386

2385-
zend_long major{ std::stol(server_version_fragments[0])};
2386-
zend_long minor{ std::stol(server_version_fragments[1])};
2387-
zend_long patch{ std::stol(server_version_fragments[2])};
2387+
zend_long major{ std::stol(server_version_fragments[0].c_str())};
2388+
zend_long minor{ std::stol(server_version_fragments[1].c_str())};
2389+
zend_long patch{ std::stol(server_version_fragments[2].c_str())};
23882390

23892391
DBG_RETURN( (zend_ulong)(major * Z_L(10000) + (zend_ulong)(minor * Z_L(100) + patch)) );
23902392
}
@@ -3095,22 +3097,26 @@ util::std_strings Extract_client_option::parse_single_or_array(const std::string
30953097
]&...
30963098
*/
30973099
assert(!value.empty());
3098-
util::std_strings items;
3099-
if ((value.front() == '[') && (value.back() == ']')) {
3100-
const std::string contents(value.begin() + 1, value.end() - 1);
3100+
util::string val{ value.c_str() };
3101+
util::strings items;
3102+
if ((val.front() == '[') && (val.back() == ']')) {
3103+
const util::string contents(val.begin() + 1, val.end() - 1);
31013104
if (!contents.empty()) {
3102-
const char* Items_separator{ "," };
3103-
boost::split(items, contents, boost::is_any_of(Items_separator));
3105+
mysqlx::util::single_separator_split(items, contents, ',');
31043106
}
31053107
} else {
3106-
items.push_back(value);
3108+
items.push_back(val);
31073109
}
3110+
util::std_strings result;
31083111
std::for_each(
31093112
items.begin(),
31103113
items.end(),
3111-
[](std::string& str){ boost::trim<std::string>(str); }
3114+
[&result](util::string& str){
3115+
boost::trim<util::string>(str);
3116+
result.push_back( str.c_str() );
3117+
}
31123118
);
3113-
return items;
3119+
return result;
31143120
}
31153121

31163122
bool Extract_client_option::parse_boolean(const std::string& value_str) const
@@ -4170,7 +4176,8 @@ Session_auth_data* extract_auth_information(const util::Url& node_url)
41704176
*/
41714177
const util::string& query{ node_url.query };
41724178
util::vector<util::string> auth_data;
4173-
boost::split(auth_data, query, boost::is_any_of("&"));
4179+
4180+
mysqlx::util::single_separator_split(auth_data, query, '&');
41744181

41754182
for (const auto& auth_option : auth_data) {
41764183
if (auth_option.empty()) {
@@ -4606,9 +4613,9 @@ parse_attribute( const util::string& attribute )
46064613
static const size_t max_attrib_key_size{ 32 };
46074614
static const size_t max_attrib_val_size{ 1024 };
46084615
util::vector<util::string> key_value;
4609-
boost::split( key_value,
4616+
mysqlx::util::single_separator_split( key_value,
46104617
attribute,
4611-
boost::is_any_of("="));
4618+
'=');
46124619
if( key_value.empty() ) {
46134620
return { "", "" };
46144621
}
@@ -4648,9 +4655,9 @@ enum_func_status parse_conn_attrib(
46484655
if( is_a_list ) {
46494656
if( user_attribs.size() ) {
46504657
util::vector<util::string> attributes;
4651-
boost::split( attributes,
4658+
mysqlx::util::single_separator_split( attributes,
46524659
user_attribs,
4653-
boost::is_any_of(","));
4660+
',');
46544661
for( const auto& cur_attrib : attributes ) {
46554662
if( !cur_attrib.empty() ) {
46564663
auto result = parse_attribute( cur_attrib );

0 commit comments

Comments
 (0)