Skip to content

Commit

Permalink
Now replacing comments with harmless dummy comments before processing…
Browse files Browse the repository at this point in the history
… so as to fix bug when they contain reserved expressions. Fixes #8
  • Loading branch information
Sylvain MARIE committed Jul 24, 2019
1 parent 66c71a7 commit 87b3975
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ circle:
empty:
# head

commented_var:
# this should not harm: $(dummy)

one:
@make two

Expand Down
4 changes: 4 additions & 0 deletions pymake/_pymake.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
RE_MAKE_CMD = re.compile(r'^\t(@\+?)(make)?')
RE_MACRO_DEF = re.compile(r"^(\S+)\s*\:?\=\s*(.*?)$")
RE_MACRO = re.compile(r"\$\(\s*\S+\s*\)")
RE_COMMENT = re.compile(r"#.*")


class PymakeTypeError(TypeError):
Expand Down Expand Up @@ -43,6 +44,9 @@ def parse_makefile_aliases(filepath):
ini_lines = (RE_MAKE_CMD.sub('\t', i) for i in ini_lines.split('\n'))
# fake section to resemble valid *.ini
ini_lines = ['[root]'] + list(ini_lines)
# replace comments with dummy contents so as to remove all reserved exprs
ini_lines = [RE_COMMENT.sub("# removed comment", line)
for line in ini_lines]

# Substitute macros
macros = dict(found for l in ini_lines
Expand Down

0 comments on commit 87b3975

Please sign in to comment.