Module Name:    src
Committed By:   rillig
Date:           Sun Aug 23 09:28:52 UTC 2020

Modified Files:
        src/usr.bin/make: enum.h nonints.h var.c
        src/usr.bin/make/unit-tests: Makefile varname-dot-shell.exp
            varname-dot-shell.mk

Log Message:
make(1): fix assertion failure in debug output for read-only variables


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/enum.h
cvs rdiff -u -r1.96 -r1.97 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.462 -r1.463 src/usr.bin/make/var.c
cvs rdiff -u -r1.115 -r1.116 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varname-dot-shell.exp \
    src/usr.bin/make/unit-tests/varname-dot-shell.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/enum.h
diff -u src/usr.bin/make/enum.h:1.5 src/usr.bin/make/enum.h:1.6
--- src/usr.bin/make/enum.h:1.5	Sun Aug  9 09:44:14 2020
+++ src/usr.bin/make/enum.h	Sun Aug 23 09:28:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: enum.h,v 1.5 2020/08/09 09:44:14 rillig Exp $	*/
+/*	$NetBSD: enum.h,v 1.6 2020/08/23 09:28:52 rillig Exp $	*/
 
 /*
  Copyright (c) 2020 Roland Illig <[email protected]>
@@ -59,6 +59,8 @@ const char *Enum_ToString(char *, size_t
 	#v1 ENUM__SEP ENUM__JOIN_5(v2, v3, v4, v5, v6)
 #define ENUM__JOIN_7(v1, v2, v3, v4, v5, v6, v7) \
 	#v1 ENUM__SEP ENUM__JOIN_6(v2, v3, v4, v5, v6, v7)
+#define ENUM__JOIN_8(v1, v2, v3, v4, v5, v6, v7, v8) \
+	#v1 ENUM__SEP ENUM__JOIN_7(v2, v3, v4, v5, v6, v7, v8)
 
 #define ENUM__RTTI(typnam, specs, joined) \
 	static const EnumToStringSpec typnam ## _ ## ToStringSpecs[] = specs; \
@@ -72,7 +74,7 @@ const char *Enum_ToString(char *, size_t
 	ENUM__SPEC(v3), \
 	{ 0, "" } }
 
-#define ENUM__SPEC_7(v1, v2, v3, v4, v5, v6, v7) { \
+#define ENUM__SPEC_8(v1, v2, v3, v4, v5, v6, v7, v8) { \
 	ENUM__SPEC(v1), \
 	ENUM__SPEC(v2), \
 	ENUM__SPEC(v3), \
@@ -80,6 +82,7 @@ const char *Enum_ToString(char *, size_t
 	ENUM__SPEC(v5), \
 	ENUM__SPEC(v6), \
 	ENUM__SPEC(v7), \
+	ENUM__SPEC(v8), \
 	{ 0, "" } }
 
 #define ENUM_RTTI_3(typnam, v1, v2, v3) \
@@ -87,9 +90,9 @@ const char *Enum_ToString(char *, size_t
 		  ENUM__SPEC_3(v1, v2, v3), \
 		  ENUM__JOIN_3(v1, v2, v3))
 
-#define ENUM_RTTI_7(typnam, v1, v2, v3, v4, v5, v6, v7) \
+#define ENUM_RTTI_8(typnam, v1, v2, v3, v4, v5, v6, v7, v8) \
 	ENUM__RTTI(typnam, \
-		  ENUM__SPEC_7(v1, v2, v3, v4, v5, v6, v7), \
-		  ENUM__JOIN_7(v1, v2, v3, v4, v5, v6, v7))
+		  ENUM__SPEC_8(v1, v2, v3, v4, v5, v6, v7, v8), \
+		  ENUM__JOIN_8(v1, v2, v3, v4, v5, v6, v7, v8))
 
 #endif

Index: src/usr.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.96 src/usr.bin/make/nonints.h:1.97
--- src/usr.bin/make/nonints.h:1.96	Sat Aug 22 19:30:58 2020
+++ src/usr.bin/make/nonints.h	Sun Aug 23 09:28:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.96 2020/08/22 19:30:58 sjg Exp $	*/
+/*	$NetBSD: nonints.h,v 1.97 2020/08/23 09:28:52 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -188,6 +188,8 @@ typedef enum {
 
 typedef enum {
     VAR_NO_EXPORT	= 0x01,	/* do not export */
+    /* Make the variable read-only. No further modification is possible,
+     * except for another call to Var_Set with the same flag. */
     VAR_SET_READONLY	= 0x02
 } VarSet_Flags;
 

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.462 src/usr.bin/make/var.c:1.463
--- src/usr.bin/make/var.c:1.462	Sun Aug 23 08:32:57 2020
+++ src/usr.bin/make/var.c	Sun Aug 23 09:28:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.462 2020/08/23 08:32:57 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.463 2020/08/23 09:28:52 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.462 2020/08/23 08:32:57 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.463 2020/08/23 09:28:52 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.462 2020/08/23 08:32:57 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.463 2020/08/23 09:28:52 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -229,14 +229,15 @@ typedef enum {
     VAR_READONLY = 0x80
 } VarFlags;
 
-ENUM_RTTI_7(VarFlags,
-	   VAR_IN_USE,
-	   VAR_FROM_ENV,
-	   VAR_JUNK,
-	   VAR_KEEP,
-	   VAR_EXPORTED,
-	   VAR_REEXPORT,
-	   VAR_FROM_CMD);
+ENUM_RTTI_8(VarFlags,
+	    VAR_IN_USE,
+	    VAR_FROM_ENV,
+	    VAR_JUNK,
+	    VAR_KEEP,
+	    VAR_EXPORTED,
+	    VAR_REEXPORT,
+	    VAR_FROM_CMD,
+	    VAR_READONLY);
 
 typedef struct Var {
     char          *name;	/* the variable's name; it is allocated for

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.115 src/usr.bin/make/unit-tests/Makefile:1.116
--- src/usr.bin/make/unit-tests/Makefile:1.115	Sun Aug 23 09:18:25 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sun Aug 23 09:28:52 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.115 2020/08/23 09:18:25 rillig Exp $
+# $NetBSD: Makefile,v 1.116 2020/08/23 09:28:52 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -335,7 +335,9 @@ SED_CMDS.varmod-subst-regex+= \
 SED_CMDS.varmod-edge+=	-e 's, line [0-9]*:, line omitted:,'
 SED_CMDS.varshell+=	-e 's,^${.SHELL:T}: ,,'
 SED_CMDS.varshell+=	-e '/command/s,No such.*,not found,'
-SED_CMDS.varname-dot-shell= -e 's, = /.*, = (details omitted),'
+SED_CMDS.varname-dot-shell=	-e 's, = /.*, = (details omitted),'
+SED_CMDS.varname-dot-shell+=	-e 's,"/[^"]*","(details omitted)",'
+SED_CMDS.varname-dot-shell+=	-e 's,\[/[^]]*\],[(details omitted)],'
 
 # Some tests need an additional round of postprocessing.
 POSTPROC.counter=	${TOOL_SED} -n -e '/:RELEVANT = yes/,/:RELEVANT = no/p'

Index: src/usr.bin/make/unit-tests/varname-dot-shell.exp
diff -u src/usr.bin/make/unit-tests/varname-dot-shell.exp:1.1 src/usr.bin/make/unit-tests/varname-dot-shell.exp:1.2
--- src/usr.bin/make/unit-tests/varname-dot-shell.exp:1.1	Sun Aug 23 09:18:25 2020
+++ src/usr.bin/make/unit-tests/varname-dot-shell.exp	Sun Aug 23 09:28:52 2020
@@ -11,4 +11,9 @@ ParseReadLine (19): '.SHELL=		newly over
 Global:.SHELL = newly overwritten
 Var_Parse: ${.SHELL} != ${ORIG_SHELL} with VARE_UNDEFERR|VARE_WANTRES
 ParseReadLine (24): 'all:'
+ParseReadLine (25): '	@echo ${.SHELL:M*}'
+Var_Parse: ${.SHELL:M*} with VARE_WANTRES
+Applying ${.SHELL:M...} to "(details omitted)" (eflags = VARE_WANTRES, vflags = VAR_READONLY)
+Pattern[.SHELL] for [(details omitted)] is [*]
+Result of ${.SHELL:M*} is "(details omitted)" (eflags = VARE_WANTRES, vflags = VAR_READONLY)
 exit status 0
Index: src/usr.bin/make/unit-tests/varname-dot-shell.mk
diff -u src/usr.bin/make/unit-tests/varname-dot-shell.mk:1.1 src/usr.bin/make/unit-tests/varname-dot-shell.mk:1.2
--- src/usr.bin/make/unit-tests/varname-dot-shell.mk:1.1	Sun Aug 23 09:18:25 2020
+++ src/usr.bin/make/unit-tests/varname-dot-shell.mk	Sun Aug 23 09:28:52 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varname-dot-shell.mk,v 1.1 2020/08/23 09:18:25 rillig Exp $
+# $NetBSD: varname-dot-shell.mk,v 1.2 2020/08/23 09:28:52 rillig Exp $
 #
 # Tests for the special .SHELL variable, which contains the shell used for
 # running the commands.
@@ -22,5 +22,4 @@ ORIG_SHELL:=	${.SHELL}
 .endif
 
 all:
-# Cannot be activated yet because VAR_READONLY is not in the debug info.
-#	@echo ${.SHELL:M*}
+	@echo ${.SHELL:M*}

Reply via email to