diff --git a/include/maxscale/log.h b/include/maxscale/log.h index 4639fd2f1..ecd480160 100644 --- a/include/maxscale/log.h +++ b/include/maxscale/log.h @@ -20,7 +20,7 @@ #include #include -#include +#include MXS_BEGIN_DECLS diff --git a/include/maxscale/utils.h b/include/maxscale/utils.h index 98bf8cfa8..3e8809d2d 100644 --- a/include/maxscale/utils.h +++ b/include/maxscale/utils.h @@ -117,41 +117,6 @@ void gw_sha1_2_str(const uint8_t* in, int in_len, const uint8_t* in2, int int gw_getsockerrno(int fd); char* create_hex_sha1_sha1_passwd(char* passwd); -/** - * Trim leading whitespace from a string. - * - * @param str String to trim. - * @return @c str - * - * @note If there is leading whitespace, the string is moved so that - * the returned pointer is always the same as the one given as - * argument. - */ -char* trim_leading(char* str); - -/** - * Trim trailing whitespace from a string. - * - * @param str String to trim. - * @return @c str - * - * @note The returned pointer is always the same the one given as - * argument. - */ -char* trim_trailing(char* str); - -/** - * Trim leading and trailing whitespace from a string. - * - * @param str String to trim. - * @return @c str - * - * @note If there is leading whitespace, the string is moved so that - * the returned pointer is always the same the one given as - * argument. - */ -char* trim(char* str); - void replace_whitespace(char* str); char* squeeze_whitespace(char* str); bool strip_escape_chars(char*); diff --git a/include/maxscale/utils.hh b/include/maxscale/utils.hh index e0f21c592..433ac926d 100644 --- a/include/maxscale/utils.hh +++ b/include/maxscale/utils.hh @@ -34,86 +34,6 @@ namespace maxscale { -/** - * @brief Left trim a string. - * - * @param s The string to be trimmed. - */ -inline void ltrim(std::string& s) -{ - s.erase(s.begin(), - std::find_if(s.begin(), - s.end(), - std::not1(std::ptr_fun(std::isspace)))); -} - -/** - * @brief Right trim a string. - * - * @param s The string to be trimmed. - */ -inline void rtrim(std::string& s) -{ - s.erase(std::find_if(s.rbegin(), - s.rend(), - std::not1(std::ptr_fun(std::isspace))).base(), - s.end()); -} - -/** - * @brief Trim a string. - * - * @param s The string to be trimmed. - */ -inline void trim(std::string& s) -{ - ltrim(s); - rtrim(s); -} - -/** - * @brief Left-trimmed copy of a string. - * - * @param s The string to the trimmed. - * - * @return A left-trimmed copy of the string. - */ -inline std::string ltrimmed_copy(const std::string& original) -{ - std::string s(original); - ltrim(s); - return s; -} - -/** - * @brief Right-trimmed copy of a string. - * - * @param s The string to the trimmed. - * - * @return A right-trimmed copy of the string. - */ -inline std::string rtrimmed_copy(const std::string& original) -{ - std::string s(original); - rtrim(s); - return s; -} - -/** - * @brief Trimmed copy of a string. - * - * @param s The string to the trimmed. - * - * @return A trimmed copy of the string. - */ -inline std::string trimmed_copy(const std::string& original) -{ - std::string s(original); - ltrim(s); - rtrim(s); - return s; -} - /** * Tokenize a string * diff --git a/maxutils/maxbase/include/maxbase/string.h b/maxutils/maxbase/include/maxbase/string.h deleted file mode 100644 index 0c7038928..000000000 --- a/maxutils/maxbase/include/maxbase/string.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2018 MariaDB Corporation Ab - * - * Use of this software is governed by the Business Source License included - * in the LICENSE.TXT file and at www.mariadb.com/bsl11. - * - * Change Date: 2022-01-01 - * - * On the date above, in accordance with the Business Source License, use - * of this software will be governed by version 2 or later of the General - * Public License. - */ -#pragma once - -#include - -MXB_BEGIN_DECLS - -/** - * Thread-safe strerror - */ -const char* mxb_strerror(int error); - -MXB_END_DECLS diff --git a/maxutils/maxbase/include/maxbase/string.hh b/maxutils/maxbase/include/maxbase/string.hh new file mode 100644 index 000000000..6243d424e --- /dev/null +++ b/maxutils/maxbase/include/maxbase/string.hh @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2018 MariaDB Corporation Ab + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file and at www.mariadb.com/bsl11. + * + * Change Date: 2022-01-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2 or later of the General + * Public License. + */ +#pragma once + +#include +#include +#include + +/** + * Thread-safe (but not re-entrant) strerror. + * + * @param error An errno value. + * + * @return The corresponding string. + */ +const char* mxb_strerror(int error); + +namespace maxbase +{ + +/** + * Left trim a string. + * + * @param str String to trim. + * @return @c str + * + * @note If there is leading whitespace, the string is moved so that + * the returned pointer is always the same as the one given as + * argument. + */ +char* ltrim(char* str); + +/** + * Right trim a string. + * + * @param str String to trim. + * @return @c str + * + * @note The returned pointer is always the same the one given as + * argument. + */ +char* rtrim(char* str); + +/** + * Left and right trim a string. + * + * @param str String to trim. + * @return @c str + * + * @note If there is leading whitespace, the string is moved so that + * the returned pointer is always the same the one given as + * argument. + */ +char* trim(char* str); + +/** + * @brief Left trim a string. + * + * @param s The string to be trimmed. + */ +inline void ltrim(std::string& s) +{ + s.erase(s.begin(), + std::find_if(s.begin(), + s.end(), + std::not1(std::ptr_fun(std::isspace)))); +} + +/** + * @brief Right trim a string. + * + * @param s The string to be trimmed. + */ +inline void rtrim(std::string& s) +{ + s.erase(std::find_if(s.rbegin(), + s.rend(), + std::not1(std::ptr_fun(std::isspace))).base(), + s.end()); +} + +/** + * @brief Trim a string. + * + * @param s The string to be trimmed. + */ +inline void trim(std::string& s) +{ + ltrim(s); + rtrim(s); +} + +/** + * @brief Left-trimmed copy of a string. + * + * @param s The string to the trimmed. + * + * @return A left-trimmed copy of the string. + */ +inline std::string ltrimmed_copy(const std::string& original) +{ + std::string s(original); + ltrim(s); + return s; +} + +/** + * @brief Right-trimmed copy of a string. + * + * @param s The string to the trimmed. + * + * @return A right-trimmed copy of the string. + */ +inline std::string rtrimmed_copy(const std::string& original) +{ + std::string s(original); + rtrim(s); + return s; +} + +/** + * @brief Trimmed copy of a string. + * + * @param s The string to the trimmed. + * + * @return A trimmed copy of the string. + */ +inline std::string trimmed_copy(const std::string& original) +{ + std::string s(original); + ltrim(s); + rtrim(s); + return s; +} + +} diff --git a/maxutils/maxbase/src/logger.cc b/maxutils/maxbase/src/logger.cc index f76bc8154..d4eb4b8f7 100644 --- a/maxutils/maxbase/src/logger.cc +++ b/maxutils/maxbase/src/logger.cc @@ -23,7 +23,7 @@ #include #include -#include +#include /** * Error logging for the logger itself. diff --git a/maxutils/maxbase/src/messagequeue.cc b/maxutils/maxbase/src/messagequeue.cc index d2129e4cf..41896c5b9 100644 --- a/maxutils/maxbase/src/messagequeue.cc +++ b/maxutils/maxbase/src/messagequeue.cc @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include namespace diff --git a/maxutils/maxbase/src/string.cc b/maxutils/maxbase/src/string.cc index a87f51e9f..f1dbc3cfb 100644 --- a/maxutils/maxbase/src/string.cc +++ b/maxutils/maxbase/src/string.cc @@ -11,14 +11,15 @@ * Public License. */ -#include - +#include +#include #include namespace { thread_local char errbuf[512]; // Enough for all errors + } const char* mxb_strerror(int error) @@ -30,3 +31,47 @@ const char* mxb_strerror(int error) return errbuf; #endif } + +namespace maxbase +{ + +char* ltrim(char* str) +{ + char* ptr = str; + + while (isspace(*ptr)) + { + ptr++; + } + + if (ptr != str) + { + memmove(str, ptr, strlen(ptr) + 1); + } + + return str; +} + +char* rtrim(char* str) +{ + char* ptr = strchr(str, '\0') - 1; + + while (ptr > str && isspace(*ptr)) + { + ptr--; + } + + if (isspace(*(ptr + 1))) + { + *(ptr + 1) = '\0'; + } + + return str; +} + +char* trim(char* str) +{ + return ltrim(rtrim(str)); +} + +} diff --git a/maxutils/maxbase/src/test/CMakeLists.txt b/maxutils/maxbase/src/test/CMakeLists.txt index e60d9a208..cd7f6c06c 100644 --- a/maxutils/maxbase/src/test/CMakeLists.txt +++ b/maxutils/maxbase/src/test/CMakeLists.txt @@ -10,6 +10,10 @@ add_executable(test_semaphore test_semaphore.cc) target_link_libraries(test_semaphore maxbase pthread rt) add_test(test_semaphore test_semaphore) +add_executable(test_mxb_string test_string.cc) +target_link_libraries(test_mxb_string maxbase) +add_test(test_semaphore test_semaphore) + add_executable(test_worker test_worker.cc) target_link_libraries(test_worker maxbase pthread rt) add_test(test_worker test_worker) diff --git a/maxutils/maxbase/src/test/test_string.cc b/maxutils/maxbase/src/test/test_string.cc new file mode 100644 index 000000000..a753106cf --- /dev/null +++ b/maxutils/maxbase/src/test/test_string.cc @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2016 MariaDB Corporation Ab + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file and at www.mariadb.com/bsl11. + * + * Change Date: 2019-07-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2 or later of the General + * Public License. + */ + +#include +#include +#include +#include + +using std::cout; +using std::endl; + +namespace +{ + +#define TRIM_TCE(zFrom, zTo) {zFrom, zTo} + +struct TRIM_TEST_CASE +{ + const char* zFrom; + const char* zTo; +}; + +TRIM_TEST_CASE trim_testcases[] = +{ + TRIM_TCE("", ""), + TRIM_TCE("a", "a"), + TRIM_TCE(" a", "a"), + TRIM_TCE("a ", "a"), + TRIM_TCE(" a ", "a"), + TRIM_TCE(" a", "a"), + TRIM_TCE("a ", "a"), + TRIM_TCE(" a ", "a"), + TRIM_TCE(" a b ", "a b"), +}; + +const int n_trim_testcases = sizeof(trim_testcases) / sizeof(trim_testcases[0]); + +TRIM_TEST_CASE ltrim_testcases[] = +{ + TRIM_TCE("", ""), + TRIM_TCE("a", "a"), + TRIM_TCE(" a", "a"), + TRIM_TCE("a ", "a "), + TRIM_TCE(" a ", "a "), + TRIM_TCE(" a", "a"), + TRIM_TCE("a ", "a "), + TRIM_TCE(" a ", "a "), + TRIM_TCE(" a b ", "a b "), +}; + +const int n_ltrim_testcases = sizeof(ltrim_testcases) / sizeof(ltrim_testcases[0]); + +TRIM_TEST_CASE rtrim_testcases[] = +{ + TRIM_TCE("", ""), + TRIM_TCE("a", "a"), + TRIM_TCE(" a", " a"), + TRIM_TCE("a ", "a"), + TRIM_TCE(" a ", " a"), + TRIM_TCE(" a", " a"), + TRIM_TCE("a ", "a"), + TRIM_TCE(" a ", " a"), + TRIM_TCE(" a b ", " a b"), +}; + +const int n_rtrim_testcases = sizeof(rtrim_testcases) / sizeof(rtrim_testcases[0]); + + +int test(TRIM_TEST_CASE* pTest_cases, int n_test_cases, char* (*p)(char*)) +{ + int rv = 0; + + for (int i = 0; i < n_test_cases; ++i) + { + const char* zFrom = pTest_cases[i].zFrom; + const char* zTo = pTest_cases[i].zTo; + + char copy[strlen(zFrom) + 1]; + strcpy(copy, zFrom); + + char* z = p(copy); + + if (strcmp(z, zTo) != 0) + { + ++rv; + } + } + + return rv; +} + +int test_trim() +{ + cout << "trim()" << endl; + return test(trim_testcases, n_trim_testcases, mxb::trim); +} + +int test_ltrim() +{ + cout << "ltrim()" << endl; + return test(ltrim_testcases, n_ltrim_testcases, mxb::ltrim); +} + +int test_rtrim() +{ + cout << "rtrim()" << endl; + return test(rtrim_testcases, n_rtrim_testcases, mxb::rtrim); +} + +} + +int main(int argc, char* argv[]) +{ + int rv = 0; + + rv += test_trim(); + rv += test_ltrim(); + rv += test_rtrim(); + + return rv; +} diff --git a/maxutils/maxbase/src/worker.cc b/maxutils/maxbase/src/worker.cc index 32c753371..8554842cd 100644 --- a/maxutils/maxbase/src/worker.cc +++ b/maxutils/maxbase/src/worker.cc @@ -25,7 +25,7 @@ #include #include #include -#include +#include #define WORKER_ABSENT_ID -1 diff --git a/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc b/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc index 656eeaa7b..2241e255a 100644 --- a/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc +++ b/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc @@ -2854,7 +2854,7 @@ static void update_field_infos(parsing_info_t* pi, char func_name[strlen(f) + 3 + 1]; // strlen(substring) - strlen(substr) from below. strcpy(func_name, f); - trim(func_name); // Sometimes the embedded parser leaves leading and trailing whitespace. + mxb::trim(func_name); // Sometimes the embedded parser leaves leading and trailing whitespace. // Non native functions are surrounded by back-ticks, let's remove them. remove_surrounding_back_ticks(func_name); diff --git a/query_classifier/qc_sqlite/qc_sqlite.cc b/query_classifier/qc_sqlite/qc_sqlite.cc index 6079ccd9f..4ca6d37fc 100644 --- a/query_classifier/qc_sqlite/qc_sqlite.cc +++ b/query_classifier/qc_sqlite/qc_sqlite.cc @@ -4445,8 +4445,8 @@ static bool get_key_and_value(char* arg, const char** pkey, const char** pvalue) { *p = 0; - *pkey = trim(arg); - *pvalue = trim(p + 1); + *pkey = mxb::trim(arg); + *pvalue = mxb::trim(p + 1); } return p != NULL; diff --git a/server/core/config.cc b/server/core/config.cc index 0606df739..3b0e14de6 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -642,7 +642,7 @@ static void fix_section_name(char* section) void fix_object_name(char* name) { squeeze_whitespace(name); - trim(name); + mxb::trim(name); replace_whitespace(name); } @@ -4352,7 +4352,7 @@ int config_parse_server_list(const char* servers, char*** output_array) * be trimmed of whitespace. */ char srv_list_tmp[strlen(servers) + 1]; strcpy(srv_list_tmp, servers); - trim(srv_list_tmp); + mxb::trim(srv_list_tmp); bool error = false; int output_ind = 0; @@ -4796,8 +4796,8 @@ bool config_parse_disk_space_threshold(MxsDiskSpaceThreshold* pDisk_space_thresh string path = entry.substr(0, j); string tail = entry.substr(j + 1); - mxs::trim(path); - mxs::trim(tail); + mxb::trim(path); + mxb::trim(tail); if (!path.empty() && !tail.empty()) { diff --git a/server/core/server.cc b/server/core/server.cc index 53cfbfaf6..3ad18426b 100644 --- a/server/core/server.cc +++ b/server/core/server.cc @@ -1432,7 +1432,7 @@ static json_t* server_json_attributes(const SERVER* server) char timebuf[30]; time_t tim = server->node_ts; asctime_r(localtime_r(&tim, &result), timebuf); - trim(timebuf); + mxb::trim(timebuf); json_object_set_new(attr, "last_heartbeat", json_string(timebuf)); } diff --git a/server/core/service.cc b/server/core/service.cc index b9ff56839..daf4e432b 100644 --- a/server/core/service.cc +++ b/server/core/service.cc @@ -1667,7 +1667,7 @@ json_t* service_attributes(const SERVICE* service) char timebuf[30]; asctime_r(localtime_r(&service->stats.started, &result), timebuf); - trim(timebuf); + mxb::trim(timebuf); json_object_set_new(attr, "started", json_string(timebuf)); json_object_set_new(attr, "total_connections", json_integer(service->stats.n_sessions)); diff --git a/server/core/session.cc b/server/core/session.cc index 125d8e25f..b0f1d9ab0 100644 --- a/server/core/session.cc +++ b/server/core/session.cc @@ -778,7 +778,7 @@ json_t* session_json_data(const Session* session, const char* host) char buf[60]; asctime_r(localtime_r(&session->stats.connect, &result), buf); - trim(buf); + mxb::trim(buf); json_object_set_new(attr, "connected", json_string(buf)); diff --git a/server/core/test/test_utils.cc b/server/core/test/test_utils.cc index daa118ff4..9b59f8c70 100644 --- a/server/core/test/test_utils.cc +++ b/server/core/test/test_utils.cc @@ -23,102 +23,6 @@ using std::endl; namespace { -#define TRIM_TCE(zFrom, zTo) {zFrom, zTo} - -struct TRIM_TEST_CASE -{ - const char* zFrom; - const char* zTo; -}; - -TRIM_TEST_CASE trim_testcases[] = -{ - TRIM_TCE("", ""), - TRIM_TCE("a", "a"), - TRIM_TCE(" a", "a"), - TRIM_TCE("a ", "a"), - TRIM_TCE(" a ", "a"), - TRIM_TCE(" a", "a"), - TRIM_TCE("a ", "a"), - TRIM_TCE(" a ", "a"), - TRIM_TCE(" a b ", "a b"), -}; - -const int n_trim_testcases = sizeof(trim_testcases) / sizeof(trim_testcases[0]); - -TRIM_TEST_CASE trim_leading_testcases[] = -{ - TRIM_TCE("", ""), - TRIM_TCE("a", "a"), - TRIM_TCE(" a", "a"), - TRIM_TCE("a ", "a "), - TRIM_TCE(" a ", "a "), - TRIM_TCE(" a", "a"), - TRIM_TCE("a ", "a "), - TRIM_TCE(" a ", "a "), - TRIM_TCE(" a b ", "a b "), -}; - -const int n_trim_leading_testcases = sizeof(trim_leading_testcases) / sizeof(trim_leading_testcases[0]); - -TRIM_TEST_CASE trim_trailing_testcases[] = -{ - TRIM_TCE("", ""), - TRIM_TCE("a", "a"), - TRIM_TCE(" a", " a"), - TRIM_TCE("a ", "a"), - TRIM_TCE(" a ", " a"), - TRIM_TCE(" a", " a"), - TRIM_TCE("a ", "a"), - TRIM_TCE(" a ", " a"), - TRIM_TCE(" a b ", " a b"), -}; - -const int n_trim_trailing_testcases = sizeof(trim_trailing_testcases) / sizeof(trim_trailing_testcases[0]); - - -int test(TRIM_TEST_CASE* pTest_cases, int n_test_cases, char* (*p)(char*)) -{ - int rv = 0; - - for (int i = 0; i < n_test_cases; ++i) - { - const char* zFrom = pTest_cases[i].zFrom; - const char* zTo = pTest_cases[i].zTo; - - char copy[strlen(zFrom) + 1]; - strcpy(copy, zFrom); - - char* z = p(copy); - - if (strcmp(z, zTo) != 0) - { - ++rv; - } - } - - return rv; -} - -int test_trim() -{ - cout << "trim()" << endl; - return test(trim_testcases, n_trim_testcases, trim); -} - -int test_trim_leading() -{ - cout << "trim_leading()" << endl; - return test(trim_leading_testcases, n_trim_leading_testcases, trim_leading); -} - -int test_trim_trailing() -{ - cout << "trim_trailing()" << endl; - return test(trim_trailing_testcases, n_trim_trailing_testcases, trim_trailing); -} -} - template int test_checksums() { @@ -169,13 +73,12 @@ int test_checksums() return 0; } +} + int main(int argc, char* argv[]) { int rv = 0; - rv += test_trim(); - rv += test_trim_leading(); - rv += test_trim_trailing(); rv += test_checksums(); rv += test_checksums(); diff --git a/server/core/utils.cc b/server/core/utils.cc index c54b8c3f4..8840fa855 100644 --- a/server/core/utils.cc +++ b/server/core/utils.cc @@ -459,45 +459,6 @@ bool mxs_mkdir_all(const char* path, int mask) return mkdir_all_internal(local_path, (mode_t)mask); } -char* trim_leading(char* str) -{ - char* ptr = str; - - while (isspace(*ptr)) - { - ptr++; - } - - if (ptr != str) - { - memmove(str, ptr, strlen(ptr) + 1); - } - - return str; -} - -char* trim_trailing(char* str) -{ - char* ptr = strchr(str, '\0') - 1; - - while (ptr > str && isspace(*ptr)) - { - ptr--; - } - - if (isspace(*(ptr + 1))) - { - *(ptr + 1) = '\0'; - } - - return str; -} - -char* trim(char* str) -{ - return trim_leading(trim_trailing(str)); -} - /** * @brief Replace whitespace with hyphens * @@ -1229,42 +1190,4 @@ uint8_t* set_byteN(uint8_t* ptr, uint64_t value, int bytes) return ptr + bytes; } -namespace -{ - -size_t write_callback(char* ptr, size_t size, size_t nmemb, void* userdata) -{ - std::string* buf = static_cast(userdata); - - if (nmemb > 0) - { - buf->append(ptr, nmemb); - } - - return nmemb; -} - -size_t header_callback(char* ptr, size_t size, size_t nmemb, void* userdata) -{ - std::unordered_map* map = - static_cast*>(userdata); - - if (nmemb > 0) - { - std::string data(ptr, size* nmemb); - auto pos = data.find_first_of(':'); - - if (pos != std::string::npos) - { - std::string key = data.substr(0, pos); - std::string value = data.substr(pos + 1); - trim(key); - trim(value); - map->insert(std::make_pair(key, value)); - } - } - - return nmemb * size; -} -} } diff --git a/server/modules/filter/dbfwfilter/dbfwfilter.cc b/server/modules/filter/dbfwfilter/dbfwfilter.cc index 225d3dc7d..eb20e0f6a 100644 --- a/server/modules/filter/dbfwfilter/dbfwfilter.cc +++ b/server/modules/filter/dbfwfilter/dbfwfilter.cc @@ -1781,11 +1781,11 @@ json_t* Dbfw::diagnostics_json() const } extern "C" -void dbfilter_log_warning(const char* file, int line, const char* function, - const char* format, const char* what) +void log_warning(const char* module, const char* file, int line, const char* function, + const char* format, const char* what) { char buffer[strlen(format) + strlen(what) + 1]; sprintf(buffer, format, what); - mxb_log_message(LOG_WARNING, file, line, function, "%s", buffer); + mxb_log_message(LOG_WARNING, module, file, line, function, "%s", buffer); } diff --git a/server/modules/filter/namedserverfilter/namedserverfilter.cc b/server/modules/filter/namedserverfilter/namedserverfilter.cc index 03aa879fe..39256b1dd 100644 --- a/server/modules/filter/namedserverfilter/namedserverfilter.cc +++ b/server/modules/filter/namedserverfilter/namedserverfilter.cc @@ -905,7 +905,7 @@ void RegexHintFilter::set_source_addresses(const std::string& input_host_names, for (auto host : mxs::strtok(host_names, ",")) { - char* trimmed_host = trim((char*)host.c_str()); + char* trimmed_host = mxb::trim((char*)host.c_str()); if (!add_source_address(trimmed_host, source_hosts)) { diff --git a/server/modules/routing/avrorouter/avro_client.cc b/server/modules/routing/avrorouter/avro_client.cc index 6a57985a9..4cdc81d61 100644 --- a/server/modules/routing/avrorouter/avro_client.cc +++ b/server/modules/routing/avrorouter/avro_client.cc @@ -267,7 +267,7 @@ int avro_client_callback(DCB* dcb, DCB_REASON reason, void* userdata) */ std::pair get_avrofile_and_gtid(std::string file) { - mxs::ltrim(file); + mxb::ltrim(file); auto pos = file.find_first_of(' '); std::string filename; std::string gtid; diff --git a/server/modules/routing/binlogrouter/blr.cc b/server/modules/routing/binlogrouter/blr.cc index 9d8d945bb..1f299be0d 100644 --- a/server/modules/routing/binlogrouter/blr.cc +++ b/server/modules/routing/binlogrouter/blr.cc @@ -2278,7 +2278,7 @@ static json_t* diagnostics_json(const MXS_ROUTER* router) localtime_r(&session_last_event, &tm); asctime_r(&tm, buf); - trim(buf); + mxb::trim(buf); json_object_set_new(rval, "last_binlog_event_timestamp", json_string(buf)); json_object_set_new(rval, "seconds_behind_master", json_integer(seconds_behind)); } diff --git a/server/modules/routing/binlogrouter/blr_slave.cc b/server/modules/routing/binlogrouter/blr_slave.cc index 68e71645b..400fa6ae9 100644 --- a/server/modules/routing/binlogrouter/blr_slave.cc +++ b/server/modules/routing/binlogrouter/blr_slave.cc @@ -4499,7 +4499,7 @@ static int blr_apply_change_master(ROUTER_INSTANCE* router, */ static char* get_connection_name(char* command, std::string* pConnection_name) { - command = trim_leading(command); + command = mxb::ltrim(command); char* to = strcasestr(command, "TO"); diff --git a/server/modules/routing/debugcli/debugcmd.cc b/server/modules/routing/debugcli/debugcmd.cc index 15665c15b..b1150f970 100644 --- a/server/modules/routing/debugcli/debugcmd.cc +++ b/server/modules/routing/debugcli/debugcmd.cc @@ -2113,7 +2113,7 @@ int execute_cmd(CLI_SESSION* cli) bool in_space = false; int nskip = 0; - args[0] = trim_leading(cli->cmdbuf); + args[0] = mxb::ltrim(cli->cmdbuf); ptr = args[0]; lptr = ptr; i = 1;