Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] _make-parseMakefile: skip non-targets



From: Daniel Hahler <git@xxxxxxxxxx>

These look like this, and might come from pattern rules ("%.res" in this
case):

    # Not a target:
    test_autocmd.res:
    #  Implicit rule search has not been done.
    #  Modification time never checked.
    #  File has not been updated.
---
 Completion/Unix/Command/_make | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make
index 38d0b0e76..695fc9907 100644
--- a/Completion/Unix/Command/_make
+++ b/Completion/Unix/Command/_make
@@ -69,7 +69,7 @@ _make-expandVars() {
 }
 
 _make-parseMakefile () {
-  local input var val target dep TAB=$'\t' tmp IFS=
+  local input var val target dep TAB=$'\t' tmp IFS= not_a_target=0
 
   while read input
   do
@@ -92,11 +92,20 @@ _make-parseMakefile () {
       VARIABLES[$var]=$val
       ;;
 
+      # Skip following TARGET: after "Not a target:" comment.
+      '# Not a target: ')
+      not_a_target=1
+      ;;
+
       # TARGET: dependencies
       # TARGET1 TARGET2 TARGET3: dependencies
       ([[*?[:alnum:]$][^$TAB:=%]#:[^=]*)
-      target=$(_make-expandVars ${input%%:*})
-      TARGETS+=( ${(z)target} )
+      if (( not_a_target )); then
+        not_a_target=0
+      else
+        target=$(_make-expandVars ${input%%:*})
+        TARGETS+=( ${(z)target} )
+      fi
       ;;
 
       # Include another makefile
-- 
2.23.0



Messages sorted by: Reverse Date, Date, Thread, Author