From 87b397555f453dc94c56276b413d2e7551e1b9d3 Mon Sep 17 00:00:00 2001 From: Sylvain MARIE Date: Wed, 24 Jul 2019 12:16:58 +0200 Subject: [PATCH 1/2] Now replacing comments with harmless dummy comments before processing so as to fix bug when they contain reserved expressions. Fixes #8 --- examples/Makefile | 3 +++ pymake/_pymake.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/examples/Makefile b/examples/Makefile index 172c554..1dd5fa6 100755 --- a/examples/Makefile +++ b/examples/Makefile @@ -18,6 +18,9 @@ circle: empty: # head +commented_var: + # this should not harm: $(dummy) + one: @make two diff --git a/pymake/_pymake.py b/pymake/_pymake.py index fdd21c8..1683369 100644 --- a/pymake/_pymake.py +++ b/pymake/_pymake.py @@ -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): @@ -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 From 3fd465beb03eb00eec8471b71a9425ea76a28af5 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Fri, 23 Aug 2019 03:52:49 +0100 Subject: [PATCH 2/2] minor tidy --- examples/Makefile | 5 +---- pymake/_pymake.py | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/examples/Makefile b/examples/Makefile index 1dd5fa6..e44f228 100755 --- a/examples/Makefile +++ b/examples/Makefile @@ -16,10 +16,7 @@ circle: circle empty: - # head - -commented_var: - # this should not harm: $(dummy) + # head $(ignored_expansion) one: @make two diff --git a/pymake/_pymake.py b/pymake/_pymake.py index 1683369..a7904e6 100644 --- a/pymake/_pymake.py +++ b/pymake/_pymake.py @@ -16,7 +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"#.*") +RE_COMMENT = re.compile("#.*$") class PymakeTypeError(TypeError):