Handle empty lines in define
diff --git a/parser.go b/parser.go
index 09f407f..7d8f290 100644
--- a/parser.go
+++ b/parser.go
@@ -420,10 +420,6 @@
for !p.done {
line := p.readLine()
- if len(bytes.TrimSpace(line)) == 0 {
- continue
- }
-
if len(p.inDef) > 0 {
line = p.processDefineLine(line)
if trimLeftSpace(string(line)) == "endef" {
@@ -443,6 +439,10 @@
continue
}
+ if len(bytes.TrimSpace(line)) == 0 {
+ continue
+ }
+
if p.isDirective(string(line), makeDirectives) {
line = p.processMakefileLine(line)
p.parseKeywords(string(line), makeDirectives)
diff --git a/testcase/empty_line_in_define.mk b/testcase/empty_line_in_define.mk
new file mode 100644
index 0000000..591f486
--- /dev/null
+++ b/testcase/empty_line_in_define.mk
@@ -0,0 +1,7 @@
+define foo
+echo hoge
+
+endef
+
+test:
+ $(foo) $(foo)