Skip to content

Commit

Permalink
deps: Handle escaped newlines in Makefile fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelforney committed Jun 30, 2023
1 parent 9d27eb2 commit 217059f
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions deps.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,21 +328,14 @@ depsparse(const char *name, bool allowmissing)
if (++n % 2 == 0)
bufadd(&buf, '\\');
} while (c == '\\');
switch (c) {
case '#':
/* assume no comments */
for (; n > 2; n -= 2)
bufadd(&buf, '\\');
if ((c == ' ' || c == '\t') && n % 2 != 0)
break;
case ' ':
case '\t':
if (n % 2 != 0)
break;
/* fallthrough */
default:
for (; n > 0; n -= 2)
bufadd(&buf, '\\');
continue;
for (; n > 2; n -= 2)
bufadd(&buf, '\\');
switch (c) {
case '#': break;
case '\n': c = ' '; continue;
default: bufadd(&buf, '\\'); continue;
}
break;
case '$':
Expand Down

0 comments on commit 217059f

Please sign in to comment.