From a1444c4ae67435625332a46a6315b1ae9b4d0273 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Tue, 23 Mar 2021 15:21:22 +0100 Subject: [PATCH] Use boost::tokenizer. It's already used in other parts of the code. --- src/xbt/log.cpp | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/src/xbt/log.cpp b/src/xbt/log.cpp index 5f37128af7..e9c170101a 100644 --- a/src/xbt/log.cpp +++ b/src/xbt/log.cpp @@ -8,12 +8,11 @@ #include "src/xbt/log_private.hpp" #include "src/xbt_modinter.h" #include "xbt/asserts.h" -#include "xbt/dynar.h" -#include "xbt/str.h" #include "xbt/string.hpp" #include #include +#include #include #include #include @@ -444,11 +443,6 @@ static xbt_log_category_t _xbt_log_cat_searchsub(xbt_log_category_t cat, const c void xbt_log_control_set(const char *control_string) { - /* To split the string in commands, and the cursors */ - xbt_dynar_t set_strings; - char *str; - unsigned int cpt; - if (!control_string) return; XBT_DEBUG("Parse log settings '%s'", control_string); @@ -458,17 +452,16 @@ void xbt_log_control_set(const char *control_string) xbt_log_no_loc = 1; return; } - /* split the string, and remove empty entries */ - set_strings = xbt_str_split_quoted(control_string); - - if (xbt_dynar_is_empty(set_strings)) { /* vicious user! */ - xbt_dynar_free(&set_strings); - return; - } - - /* Parse each entry and either use it right now (if the category was already created), or store it for further use */ - xbt_dynar_foreach(set_strings, cpt, str) { - xbt_log_setting_t set = _xbt_log_parse_setting(str); + /* Split the string, and remove empty entries + Parse each entry and either use it right now (if the category was already created), or store it for further use */ + std::string parsed_control_string(control_string); + boost::escaped_list_separator sep("\\", " ", "\"'"); + boost::tokenizer> tok(parsed_control_string, sep); + for (const auto& str : tok) { + if (str.empty()) + continue; + + xbt_log_setting_t set = _xbt_log_parse_setting(str.c_str()); xbt_log_category_t cat = _xbt_log_cat_searchsub(&_XBT_LOGV(XBT_LOG_ROOT_CAT), set.catname.c_str()); if (cat) { @@ -480,7 +473,6 @@ void xbt_log_control_set(const char *control_string) xbt_log_settings().emplace_back(std::move(set)); } } - xbt_dynar_free(&set_strings); } void xbt_log_appender_set(xbt_log_category_t cat, xbt_log_appender_t app) -- 2.20.1