Module Name: src
Committed By: rillig
Date: Mon Sep 14 18:21:26 UTC 2020
Modified Files:
src/usr.bin/make: parse.c
src/usr.bin/make/unit-tests: deptgt.exp deptgt.mk
Log Message:
make(1): add test for the global variable 'targets' in parse.c
To generate a diff of this commit:
cvs rdiff -u -r1.317 -r1.318 src/usr.bin/make/parse.c
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/deptgt.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/deptgt.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.317 src/usr.bin/make/parse.c:1.318
--- src/usr.bin/make/parse.c:1.317 Mon Sep 14 17:47:05 2020
+++ src/usr.bin/make/parse.c Mon Sep 14 18:21:26 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.317 2020/09/14 17:47:05 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.318 2020/09/14 18:21:26 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.317 2020/09/14 17:47:05 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.318 2020/09/14 18:21:26 rillig Exp $");
/* types and constants */
@@ -214,7 +214,9 @@ static GNode *mainNode;
/* eval state */
-/* targets we're working on */
+/* During parsing, the targets from the previous dependency line.
+ *
+ * See unit-tests/deptgt.mk, keyword "parse.c:targets". */
static Lst targets;
#ifdef CLEANUP
@@ -3034,7 +3036,7 @@ Parse_File(const char *name, int fd)
line = Var_Subst(line, VAR_CMD, VARE_UNDEFERR|VARE_WANTRES);
/*
- * Need a non-circular list for the target nodes
+ * Need a list for the target nodes
*/
if (targets != NULL)
Lst_Free(targets);
Index: src/usr.bin/make/unit-tests/deptgt.exp
diff -u src/usr.bin/make/unit-tests/deptgt.exp:1.2 src/usr.bin/make/unit-tests/deptgt.exp:1.3
--- src/usr.bin/make/unit-tests/deptgt.exp:1.2 Mon Sep 14 17:43:36 2020
+++ src/usr.bin/make/unit-tests/deptgt.exp Mon Sep 14 18:21:26 2020
@@ -1,2 +1,5 @@
make: "deptgt.mk" line 10: warning: Extra target ignored
-exit status 0
+make: "deptgt.mk" line 27: Unassociated shell command ": command3"
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
Index: src/usr.bin/make/unit-tests/deptgt.mk
diff -u src/usr.bin/make/unit-tests/deptgt.mk:1.3 src/usr.bin/make/unit-tests/deptgt.mk:1.4
--- src/usr.bin/make/unit-tests/deptgt.mk:1.3 Mon Sep 14 17:43:36 2020
+++ src/usr.bin/make/unit-tests/deptgt.mk Mon Sep 14 18:21:26 2020
@@ -1,4 +1,4 @@
-# $NetBSD: deptgt.mk,v 1.3 2020/09/14 17:43:36 rillig Exp $
+# $NetBSD: deptgt.mk,v 1.4 2020/09/14 18:21:26 rillig Exp $
#
# Tests for special targets like .BEGIN or .SUFFIXES in dependency
# declarations.
@@ -9,5 +9,22 @@
# dependency line: That doesn't work, and make immediately rejects it.
.SUFFIXES .PHONY: .c.o
+# Keyword "parse.c:targets"
+#
+# The following lines demonstrate how 'target' is set and reset during
+# parsing of dependencies. To see it in action, set breakpoints in:
+#
+# ParseDoDependency at the beginning
+# ParseFinishLine at "targets = NULL"
+# Parse_File at "Lst_Free(targets)"
+# Parse_File at "targets = Lst_Init()"
+# Parse_File at "!inLine"
+#
+target1 target2: sources
+ : command1
+ : command2
+VAR=value
+ : command3
+
all:
@:;