diff --git a/openmp/tools/archer/ompt-tsan.cpp b/openmp/tools/archer/ompt-tsan.cpp --- a/openmp/tools/archer/ompt-tsan.cpp +++ b/openmp/tools/archer/ompt-tsan.cpp @@ -15,6 +15,7 @@ #define __STDC_FORMAT_MACROS #endif +#include #include #include #include @@ -89,17 +90,23 @@ TsanFlags(const char *env) : ignore_noninstrumented_modules(0) { if (env) { std::vector tokens; - std::string token; std::string str(env); - std::istringstream iss(str); - while (std::getline(iss, token, ' ')) - tokens.push_back(token); + auto end = str.end(); + auto it = str.begin(); + auto is_sep = [](char c) { + return c == ' ' || c == ',' || c == ':' || c == '\n' || c == '\t' || + c == '\r'; + }; + while (it != end) { + auto next_it = std::find_if(it, end, is_sep); + tokens.emplace_back(it, next_it); + it = next_it + 1; + } - for (std::vector::iterator it = tokens.begin(); - it != tokens.end(); ++it) { + for (const auto &token : tokens) { // we are interested in ignore_noninstrumented_modules to print a // warning - if (sscanf(it->c_str(), "ignore_noninstrumented_modules=%d", + if (sscanf(token.c_str(), "ignore_noninstrumented_modules=%d", &ignore_noninstrumented_modules)) continue; }