From b4d26560138b37cefe12105d137214a33a1672c8 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Thu, 25 Mar 2021 22:09:16 -0600 Subject: always ignore comments --- yapymake/makefile/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/yapymake/makefile/__init__.py b/yapymake/makefile/__init__.py index 09dcb93..cb6fe85 100644 --- a/yapymake/makefile/__init__.py +++ b/yapymake/makefile/__init__.py @@ -5,7 +5,7 @@ from pathlib import Path as ImpurePath, PurePath import re import subprocess import sys -from typing import Dict, List, Optional, Set, TextIO, Tuple, Any, Union +from typing import Dict, List, Optional, Set, TextIO, Tuple, Union from .token import * from ..args import Args @@ -81,6 +81,11 @@ class Makefile: while line.endswith('\\\n'): line = line[:-2] + next(lines_iter, '').lstrip() + # > The trailing , any characters immediately preceding a comment, and any comment + # > shall be discarded. + # (that's only specified that way for includes but apparently needs to apply to everything) + line = re.sub(r'(\s*#.*)?\n', '', line) + # POSIX: # > If the word include appears at the beginning of a line and is followed by one or more # > characters... @@ -89,10 +94,6 @@ class Makefile: line = line[len('include '):].lstrip() # > shall be processed as follows to produce a pathname: - # > The trailing , any characters immediately preceding a comment, and any comment - # > shall be discarded. - line = re.sub(r'(\s+#.*)?\n', '', line) - # > The resulting string shall be processed for macro expansion. line = self.expand_macros(tokenize(line)) -- cgit v1.2.3