diff options
author | Melody Horn <melody@boringcactus.com> | 2021-03-25 22:09:16 -0600 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2021-03-25 22:09:16 -0600 |
commit | b4d26560138b37cefe12105d137214a33a1672c8 (patch) | |
tree | 30c1f7586f08224ed6b8c9bdce09a3699bc52871 | |
parent | bbbb4bad078043d17637f685b83959753f8dc4ee (diff) | |
download | yapymake-b4d26560138b37cefe12105d137214a33a1672c8.tar.gz yapymake-b4d26560138b37cefe12105d137214a33a1672c8.zip |
always ignore comments
-rw-r--r-- | yapymake/makefile/__init__.py | 11 |
1 files 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 <newline>, any <blank> 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 <blank> # > characters... @@ -89,10 +94,6 @@ class Makefile: line = line[len('include '):].lstrip() # > shall be processed as follows to produce a pathname: - # > The trailing <newline>, any <blank> 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)) |