adjusted_file_content.reserve(file_content.size());
bool content_rewritten = false;
- for (const auto& line : Util::split_into_views(file_content, "\n")) {
+ for (const auto line : util::Tokenizer(
+ file_content, "\n", util::Tokenizer::Mode::skip_last_empty)) {
const auto tokens = Util::split_into_views(line, " \t");
for (size_t i = 0; i < tokens.size(); ++i) {
- DEBUG_ASSERT(line.length() > 0); // line.empty() -> no tokens
+ DEBUG_ASSERT(!line.empty()); // line.empty() -> no tokens
if (i > 0 || line[0] == ' ' || line[0] == '\t') {
adjusted_file_content.push_back(' ');
}
-// Copyright (C) 2020 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2021 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
const auto cwd = ctx.actual_cwd;
ctx.has_absolute_include_headers = true;
- const auto content = FMT("foo.o: bar.c {0}/bar.h \\\n {1}/fie.h {0}/fum.h\n",
- cwd,
- Util::dir_name(cwd));
+ const auto content =
+ FMT("foo.o: bar.c {0}/bar.h \\\n\n {1}/fie.h {0}/fum.h\n",
+ cwd,
+ Util::dir_name(cwd));
SUBCASE("Base directory not in dep file content")
{
{
ctx.config.set_base_dir(cwd);
const auto actual = Depfile::rewrite_paths(ctx, content);
- const auto expected =
- FMT("foo.o: bar.c ./bar.h \\\n {}/fie.h ./fum.h\n", Util::dir_name(cwd));
+ const auto expected = FMT("foo.o: bar.c ./bar.h \\\n\n {}/fie.h ./fum.h\n",
+ Util::dir_name(cwd));
REQUIRE(actual);
CHECK(*actual == expected);
}