Skip to content

Commit

Permalink
minicargo - Improve error messages for depfile parse failures (fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
thepowersgang committed Sep 27, 2023
1 parent 2a9a8c1 commit 80c9c1d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tools/minicargo/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,12 @@ namespace {
// Load space-separated (backslash-escaped) paths
struct Lexer {
::std::ifstream ifp;
unsigned m_line;
char m_c;

Lexer(::std::ifstream ifp)
:ifp(::std::move(ifp))
,m_line(1)
,m_c(0)
{
nextc();
Expand Down Expand Up @@ -579,7 +581,10 @@ namespace {
auto& list = v.first->second;
auto target = t;
t = lexer.get_token();
assert(t == ":");
if( t != ":" ) {
::std::cerr << depfile_path << ":" << lexer.m_line << ": Malformed depfile, expected ':' but got '" << t << "'" << std::endl;
throw ::std::runtime_error("Malformed depfile: No `:` after filename");
}

do {
t = lexer.get_token();
Expand All @@ -591,7 +596,7 @@ namespace {
}
return rv;
}

std::string escape_dashes(const std::string& s) {
std::string rv;
for(char c : s)
Expand Down

0 comments on commit 80c9c1d

Please sign in to comment.