From 64c8fd597f8259ff6e485fd7baf7ad6e1c30d7bb Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Thu, 25 Mar 2021 21:19:28 -0600 Subject: handle (most) escaped newlines in command string --- yapymake/makefile/__init__.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/yapymake/makefile/__init__.py b/yapymake/makefile/__init__.py index e46179e..23cd144 100644 --- a/yapymake/makefile/__init__.py +++ b/yapymake/makefile/__init__.py @@ -145,10 +145,19 @@ class Makefile: else: prerequisite_tokens, command_tokens = semicolon_split prerequisites = self.expand_macros(prerequisite_tokens).split() + # TODO handle escaped newline in this case command_token_strings = [command_tokens] while (peeked := lines_iter.peek()) is not None and peeked.startswith('\t'): - # TODO handle escaped newlines - command_token_strings.append(tokenize(next(lines_iter).lstrip('\t').rstrip('\n'))) + next_line = next(lines_iter) + # > When an escaped is found in a command line in a makefile, the command line shall + # > contain the , the , and the next line, except that the first character of + # > the next line shall not be included if it is a . + while next_line.endswith('\\\n'): + line_after = next(lines_iter) + if line_after.startswith('\t'): + line_after = line_after[1:] + next_line += line_after + command_token_strings.append(tokenize(next_line.lstrip('\t').rstrip('\n'))) commands = [CommandLine(c) for c in command_token_strings] # we don't know yet if it's a target rule or an inference rule -- cgit v1.2.3