Skip to content

Commit

Permalink
deps: Print name of file on parse error
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelforney committed Feb 23, 2024
1 parent 217059f commit 1890235
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions deps.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ depsparse(const char *name, bool allowmissing)
case '$':
c = getc(f);
if (c != '$') {
warn("bad depfile: contains variable reference");
warn("bad depfile '%s': contains variable reference", name);
goto err;
}
break;
Expand All @@ -351,7 +351,7 @@ depsparse(const char *name, bool allowmissing)
}
if (sawcolon) {
if (!isspace(c) && c != EOF) {
warn("bad depfile: '%c' is not a valid target character", c);
warn("bad depfile '%s': '%c' is not a valid target character", name, c);
goto err;
}
if (buf.len > 0) {
Expand All @@ -377,15 +377,15 @@ depsparse(const char *name, bool allowmissing)
if (c == EOF)
break;
if (c != ':') {
warn("bad depfile: expected ':', saw '%c'", c);
warn("bad depfile '%s': expected ':', saw '%c'", name, c);
goto err;
}
if (!out) {
out = mkstr(buf.len);
memcpy(out->s, buf.data, buf.len);
out->s[buf.len] = '\0';
} else if (out->n != buf.len || memcmp(buf.data, out->s, buf.len) != 0) {
warn("bad depfile: multiple outputs: %.*s != %s", (int)buf.len, buf.data, out->s);
warn("bad depfile '%s': multiple outputs: %.*s != %s", name, (int)buf.len, buf.data, out->s);
goto err;
}
sawcolon = true;
Expand All @@ -395,7 +395,7 @@ depsparse(const char *name, bool allowmissing)
for (;;) {
if (c == '\\') {
if (getc(f) != '\n') {
warn("bad depfile: '\\' only allowed before newline");
warn("bad depfile '%s': '\\' only allowed before newline", name);
goto err;
}
} else if (!isblank(c)) {
Expand All @@ -405,7 +405,7 @@ depsparse(const char *name, bool allowmissing)
}
}
if (ferror(f)) {
warn("depfile read:");
warn("depfile read '%s':", name);
goto err;
}
fclose(f);
Expand Down

0 comments on commit 1890235

Please sign in to comment.