Commit 7b1d4fd5 authored by jan.koester's avatar jan.koester
Browse files

test

parent 8e96deac
Loading
Loading
Loading
Loading
+14 −0
Changes for parser.cpp: 14 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -38,6 +38,20 @@ std::string Parser::normalize_target(const std::string& s) {
        while (i < r.size() && r[i] == '/') i++; // collapse "./////"
        r = r.substr(i);
    }
    // Collapse internal duplicate slashes ("a//b" -> "a/b"). The tools/ build
    // framework concatenates variables with trailing '/' producing paths like
    // "tools/objtool//libsubcmd/libsubcmd.a"; GNU make resolves these to the
    // single-slash file, so a target and its prerequisite must compare equal
    // regardless of repeated separators.
    if (r.find("//") != std::string::npos) {
        std::string collapsed;
        collapsed.reserve(r.size());
        for (size_t i = 0; i < r.size(); i++) {
            if (r[i] == '/' && !collapsed.empty() && collapsed.back() == '/') continue;
            collapsed += r[i];
        }
        r.swap(collapsed);
    }
    // A path consisting solely of "./" (or ".///") denotes the current
    // directory; GNU make keeps it as a directory target. Map it to "." so
    // it does not collapse to an empty (and therefore unbuildable) target.