#include <core/types.hpp>
#include <core/wincompat.hpp>
#include <fmtmacros.hpp>
+#include <util/Tokenizer.hpp>
#include <util/expected.hpp>
#include <util/file.hpp>
#include <util/path.hpp>
core::Sloppiness
parse_sloppiness(const std::string& value)
{
- size_t start = 0;
- size_t end = 0;
core::Sloppiness result;
- while (end != std::string::npos) {
- end = value.find_first_of(", ", start);
- std::string token =
- util::strip_whitespace(value.substr(start, end - start));
+
+ for (const auto token : util::Tokenizer(value, ", ")) {
if (token == "clang_index_store") {
result.enable(core::Sloppy::clang_index_store);
} else if (token == "file_stat_matches") {
} else if (token == "time_macros") {
result.enable(core::Sloppy::time_macros);
} // else: ignore unknown value for forward compatibility
- start = value.find_first_not_of(", ", end);
}
+
return result;
}
"run_second_cpp = false\n"
"sloppiness = time_macros ,include_file_mtime"
" include_file_ctime,file_stat_matches,file_stat_matches_ctime,pch_defines"
- " , no_system_headers,system_headers,clang_index_store,ivfsoverlay,gcno_cwd\n"
+ " , no_system_headers,system_headers,clang_index_store,ivfsoverlay,"
+ " gcno_cwd,\n"
"stats = false\n"
"temporary_dir = ${USER}_foo\n"
"umask = 777"); // Note: no newline.
"run_second_cpp = false\n"
"sloppiness = include_file_mtime, include_file_ctime, time_macros,"
" file_stat_matches, file_stat_matches_ctime, pch_defines, system_headers,"
- " clang_index_store, ivfsoverlay, gcno_cwd\n"
+ " clang_index_store, ivfsoverlay, gcno_cwd \n"
"stats = false\n"
"stats_log = sl\n"
"temporary_dir = td\n"