CVS commit: src/usr.bin/make

2021-10-24 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sun Oct 24 18:45:46 UTC 2021

Modified Files:
src/usr.bin/make: job.c meta.c

Log Message:
Do not ignore write failures.

We should not ignore failure to write to cmdFILE,
meta files and filemon.

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.435 -r1.436 src/usr.bin/make/job.c
cvs rdiff -u -r1.183 -r1.184 src/usr.bin/make/meta.c

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/job.c
diff -u src/usr.bin/make/job.c:1.435 src/usr.bin/make/job.c:1.436
--- src/usr.bin/make/job.c:1.435	Wed Jun 16 09:47:51 2021
+++ src/usr.bin/make/job.c	Sun Oct 24 18:45:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.435 2021/06/16 09:47:51 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.436 2021/10/24 18:45:46 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -142,7 +142,7 @@
 #include "trace.h"
 
 /*	"@(#)job.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: job.c,v 1.435 2021/06/16 09:47:51 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.436 2021/10/24 18:45:46 sjg Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -765,8 +765,8 @@ ShellWriter_WriteFmt(ShellWriter *wr, co
 	DEBUG1(JOB, fmt, arg);
 
 	(void)fprintf(wr->f, fmt, arg);
-	/* XXX: Is flushing needed in any case, or only if f == stdout? */
-	(void)fflush(wr->f);
+	if (wr->f == stdout)
+		(void)fflush(wr->f);
 }
 
 static void
@@ -1163,7 +1163,9 @@ JobFinish(Job *job, int status)
 
 		JobClosePipes(job);
 		if (job->cmdFILE != NULL && job->cmdFILE != stdout) {
-			(void)fclose(job->cmdFILE);
+			if (fclose(job->cmdFILE) != 0)
+Punt("Cannot write shell script for '%s': %s",
+job->node->name, strerror(errno));
 			job->cmdFILE = NULL;
 		}
 		done = true;
@@ -1526,7 +1528,9 @@ JobExec(Job *job, char **argv)
 	watchfd(job);
 
 	if (job->cmdFILE != NULL && job->cmdFILE != stdout) {
-		(void)fclose(job->cmdFILE);
+		if (fclose(job->cmdFILE) != 0)
+			Punt("Cannot write shell script for '%s': %s",
+			job->node->name, strerror(errno));
 		job->cmdFILE = NULL;
 	}
 

Index: src/usr.bin/make/meta.c
diff -u src/usr.bin/make/meta.c:1.183 src/usr.bin/make/meta.c:1.184
--- src/usr.bin/make/meta.c:1.183	Thu Aug 19 15:50:30 2021
+++ src/usr.bin/make/meta.c	Sun Oct 24 18:45:46 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: meta.c,v 1.183 2021/08/19 15:50:30 rillig Exp $ */
+/*  $NetBSD: meta.c,v 1.184 2021/10/24 18:45:46 sjg Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -145,11 +145,11 @@ meta_open_filemon(BuildMon *pbm)
 else
 	pbm->mon_fd = mkTempFile("filemon.XX", NULL, 0);
 if ((dupfd = dup(pbm->mon_fd)) == -1) {
-	err(1, "Could not dup filemon output!");
+	Punt("Could not dup filemon output: %s", strerror(errno));
 }
 (void)fcntl(dupfd, F_SETFD, FD_CLOEXEC);
 if (filemon_setfd(pbm->filemon, dupfd) == -1) {
-	err(1, "Could not set filemon file descriptor!");
+	Punt("Could not set filemon file descriptor: %s", strerror(errno));
 }
 /* we don't need these once we exec */
 (void)fcntl(pbm->mon_fd, F_SETFD, FD_CLOEXEC);
@@ -187,7 +187,9 @@ filemon_read(FILE *mfp, int fd)
 		error = EIO;
 	}
 }
-fflush(mfp);
+if (fflush(mfp) != 0)
+	Punt("Cannot write filemon data to meta file: %s",
+	strerror(errno));
 if (close(fd) < 0)
 	error = errno;
 return error;
@@ -518,7 +520,7 @@ meta_create(BuildMon *pbm, GNode *gn)
 #endif
 
 if ((fp = fopen(fname, "w")) == NULL)
-	err(1, "Could not open meta file '%s'", fname);
+	Punt("Could not open meta file '%s': %s", fname, strerror(errno));
 
 fprintf(fp, "# Meta data file %s\n", fname);
 
@@ -536,7 +538,9 @@ meta_create(BuildMon *pbm, GNode *gn)
 }
 
 fprintf(fp, "-- command output --\n");
-fflush(fp);
+if (fflush(fp) != 0)
+	Punt("Cannot write expanded command to meta file: %s",
+	strerror(errno));
 
 Global_Append(".MAKE.META.FILES", fname);
 Global_Append(".MAKE.META.CREATED", fname);
@@ -710,7 +714,7 @@ meta_job_child(Job *job)
 
 	pid = getpid();
 	if (filemon_setpid_child(pbm->filemon, pid) == -1) {
-		err(1, "Could not set filemon pid!");
+		Punt("Could not set filemon pid: %s", strerror(errno));
 	}
 	}
 }
@@ -850,8 +854,10 @@ meta_cmd_finish(void *pbmp)
 if (pbm->filemon != NULL) {
 	while (filemon_process(pbm->filemon) > 0)
 	continue;
-	if (filemon_close(pbm->filemon) == -1)
+	if (filemon_close(pbm->filemon) == -1) {
 	error = errno;
+	Punt("filemon failed: %s", strerror(errno));
+	}
 	x = filemon_read(pbm->mfp, pbm->mon_fd);
 	if (error == 0 && x != 0)
 	error = x;



CVS commit: src/usr.bin/make

2021-10-24 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sun Oct 24 18:45:46 UTC 2021

Modified Files:
src/usr.bin/make: job.c meta.c

Log Message:
Do not ignore write failures.

We should not ignore failure to write to cmdFILE,
meta files and filemon.

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.435 -r1.436 src/usr.bin/make/job.c
cvs rdiff -u -r1.183 -r1.184 src/usr.bin/make/meta.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2021-10-19 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Tue Oct 19 15:59:26 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: Makefile varname-empty.exp

Log Message:
Replace ${.OBJDIR} with  for consistent results.

If we replace ${.OBJDIR} with  some tests produce
different results depending on the value of .OBJDIR

For similar reasons eliminate .OBJDIR and .PATH from output of
varname-empty

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.283 -r1.284 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varname-empty.exp

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/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.283 src/usr.bin/make/unit-tests/Makefile:1.284
--- src/usr.bin/make/unit-tests/Makefile:1.283	Mon Aug 30 17:08:13 2021
+++ src/usr.bin/make/unit-tests/Makefile	Tue Oct 19 15:59:26 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.283 2021/08/30 17:08:13 rillig Exp $
+# $NetBSD: Makefile,v 1.284 2021/10/19 15:59:26 sjg Exp $
 #
 # Unit tests for make(1)
 #
@@ -530,9 +530,7 @@ SED_CMDS.varname-dot-parsefile=	-e '/in 
 SED_CMDS.varname-dot-shell=	-e 's, = /[^ ]*, = (details omitted),g'
 SED_CMDS.varname-dot-shell+=	-e 's,"/[^" ]*","(details omitted)",g'
 SED_CMDS.varname-dot-shell+=	-e 's,\[/[^] ]*\],[(details omitted)],g'
-SED_CMDS.varname-empty=		-e 's,${.CURDIR},,g'
-SED_CMDS.varname-empty+=	-e '/\.PARSEDIR/d'
-SED_CMDS.varname-empty+=	-e '/\.SHELL/d'
+SED_CMDS.varname-empty=		${.OBJDIR .PARSEDIR .PATH .SHELL:L:@v@-e '/\\$v/d'@}
 
 # Some tests need an additional round of postprocessing.
 POSTPROC.deptgt-suffixes=	awk '/^\#\*\*\* Suffixes/,/^never-stop/'
@@ -689,8 +687,14 @@ _SED_CMDS+=	-e 's,^usage: ${TEST_MAKE:T:
 # replace anything after 'stopped in' with unit-tests
 _SED_CMDS+=	-e '/stopped/s, /.*, unit-tests,'
 _SED_CMDS+=	-e 's,${TMPDIR},TMPDIR,g'
-# strip ${.CURDIR}/ from the output
-_SED_CMDS+=	-e 's,${.CURDIR:S,.,\\.,g}/,,g'
+# canonicalize ${.OBJDIR} and ${.CURDIR}
+.if ${.OBJDIR} != ${.CURDIR}
+# yes this is inaccurate but none of the tests expect  anywhere
+# which we get depending on how MAKEOBJDIR is set.
+_SED_CMDS+=	-e 's,${.OBJDIR},,g'
+.endif
+_SED_CMDS+=	-e 's,${.CURDIR},,g'
+_SED_CMDS+=	-e 's,/,,g'
 _SED_CMDS+=	-e 's,${UNIT_TESTS:S,.,\\.,g}/,,g'
 
 .rawout.out:

Index: src/usr.bin/make/unit-tests/varname-empty.exp
diff -u src/usr.bin/make/unit-tests/varname-empty.exp:1.16 src/usr.bin/make/unit-tests/varname-empty.exp:1.17
--- src/usr.bin/make/unit-tests/varname-empty.exp:1.16	Wed Apr 14 17:20:48 2021
+++ src/usr.bin/make/unit-tests/varname-empty.exp	Tue Oct 19 15:59:26 2021
@@ -2,10 +2,6 @@ Var_SetExpand: variable name "${:U}" exp
 Var_SetExpand: variable name "" expands to empty string, with value "cmdline-plain" - ignored
 Global: .CURDIR = 
 Var_Parse: ${MAKE_OBJDIR_CHECK_WRITABLE} (eval)
-Global: .OBJDIR = 
-Global:delete .PATH (not found)
-Global: .PATH = .
-Global: .PATH = . 
 Global: .TARGETS = 
 Internal: MAKEFILE = varname-empty.mk
 Global: .MAKE.MAKEFILES = varname-empty.mk



CVS commit: src/usr.bin/make/unit-tests

2021-10-19 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Tue Oct 19 15:59:26 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: Makefile varname-empty.exp

Log Message:
Replace ${.OBJDIR} with  for consistent results.

If we replace ${.OBJDIR} with  some tests produce
different results depending on the value of .OBJDIR

For similar reasons eliminate .OBJDIR and .PATH from output of
varname-empty

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.283 -r1.284 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varname-empty.exp

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-10-17 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 17 18:40:15 UTC 2021

Modified Files:
src/usr.bin/make: var.c

Log Message:
make: fix order of parameters in function comments

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.952 -r1.953 src/usr.bin/make/var.c

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/var.c
diff -u src/usr.bin/make/var.c:1.952 src/usr.bin/make/var.c:1.953
--- src/usr.bin/make/var.c:1.952	Thu Sep 23 22:54:09 2021
+++ src/usr.bin/make/var.c	Sun Oct 17 18:40:14 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.952 2021/09/23 22:54:09 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.953 2021/10/17 18:40:14 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.952 2021/09/23 22:54:09 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.953 2021/10/17 18:40:14 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -1057,9 +1057,9 @@ Var_Set(GNode *scope, const char *name, 
  * Otherwise the new value overwrites and replaces the old value.
  *
  * Input:
+ *	scope		scope in which to set it
  *	name		name of the variable to set, is expanded once
  *	val		value to give to the variable
- *	scope		scope in which to set it
  */
 void
 Var_SetExpand(GNode *scope, const char *name, const char *val)
@@ -1135,9 +1135,9 @@ Var_Append(GNode *scope, const char *nam
  * concatenated, with a space in between.
  *
  * Input:
+ *	scope		scope in which this should occur
  *	name		name of the variable to modify, is expanded once
  *	val		string to append to it
- *	scope		scope in which this should occur
  *
  * Notes:
  *	Only if the variable is being sought in the global scope is the
@@ -1196,8 +1196,8 @@ Var_Exists(GNode *scope, const char *nam
  * fallback scopes.
  *
  * Input:
- *	name		Variable to find, is expanded once
- *	scope		Scope in which to start search
+ *	scope		scope in which to start search
+ *	name		name of the variable to find, is expanded once
  */
 bool
 Var_ExistsExpand(GNode *scope, const char *name)
@@ -1222,8 +1222,8 @@ Var_ExistsExpand(GNode *scope, const cha
  * or the usual scopes.
  *
  * Input:
- *	name		name to find, is not expanded any further
  *	scope		scope in which to search for it
+ *	name		name to find, is not expanded any further
  *
  * Results:
  *	The value if the variable exists, NULL if it doesn't.



CVS commit: src/usr.bin/make

2021-10-17 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 17 18:40:15 UTC 2021

Modified Files:
src/usr.bin/make: var.c

Log Message:
make: fix order of parameters in function comments

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.952 -r1.953 src/usr.bin/make/var.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Sep 26 03:23:06 UTC 2021

Modified Files:
src/usr.bin/make: cond.c

Log Message:
make: fix lint warning on i386

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]


To generate a diff of this commit:
cvs rdiff -u -r1.279 -r1.280 src/usr.bin/make/cond.c

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/cond.c
diff -u src/usr.bin/make/cond.c:1.279 src/usr.bin/make/cond.c:1.280
--- src/usr.bin/make/cond.c:1.279	Tue Sep 21 23:06:18 2021
+++ src/usr.bin/make/cond.c	Sun Sep 26 03:23:06 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.279 2021/09/21 23:06:18 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.280 2021/09/26 03:23:06 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.279 2021/09/21 23:06:18 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.280 2021/09/26 03:23:06 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -189,9 +189,9 @@ static unsigned int cond_min_depth = 0;	
 static const char opname[][3] = { "<", "<=", ">", ">=", "==", "!=" };
 
 static bool
-is_token(const char *str, const char *tok, size_t len)
+is_token(const char *str, const char *tok, unsigned char len)
 {
-	return strncmp(str, tok, len) == 0 && !ch_isalpha(str[len]);
+	return strncmp(str, tok, (size_t)len) == 0 && !ch_isalpha(str[len]);
 }
 
 static Token



CVS commit: src/usr.bin/make

2021-09-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Sep 26 03:23:06 UTC 2021

Modified Files:
src/usr.bin/make: cond.c

Log Message:
make: fix lint warning on i386

cond.c(800): warning: argument #3 is converted from 'unsigned char' to
'unsigned int' due to prototype [259]


To generate a diff of this commit:
cvs rdiff -u -r1.279 -r1.280 src/usr.bin/make/cond.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-09-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Sep 23 22:54:09 UTC 2021

Modified Files:
src/usr.bin/make: var.c

Log Message:
make: fix memory leak in error case of the ':?' modifier


To generate a diff of this commit:
cvs rdiff -u -r1.951 -r1.952 src/usr.bin/make/var.c

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/var.c
diff -u src/usr.bin/make/var.c:1.951 src/usr.bin/make/var.c:1.952
--- src/usr.bin/make/var.c:1.951	Tue Sep 21 23:06:18 2021
+++ src/usr.bin/make/var.c	Thu Sep 23 22:54:09 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.951 2021/09/21 23:06:18 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.952 2021/09/23 22:54:09 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.951 2021/09/21 23:06:18 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.952 2021/09/23 22:54:09 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -3444,6 +3444,8 @@ ApplyModifier_IfElse(const char **pp, Mo
 	if (cond_rc == COND_INVALID) {
 		Error("Bad conditional expression '%s' in '%s?%s:%s'",
 		expr->name, expr->name, then_expr.str, else_expr.str);
+		FStr_Done(_expr);
+		FStr_Done(_expr);
 		return AMR_CLEANUP;
 	}
 



CVS commit: src/usr.bin/make

2021-09-23 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Sep 23 22:54:09 UTC 2021

Modified Files:
src/usr.bin/make: var.c

Log Message:
make: fix memory leak in error case of the ':?' modifier


To generate a diff of this commit:
cvs rdiff -u -r1.951 -r1.952 src/usr.bin/make/var.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-09-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Sep 21 23:06:18 UTC 2021

Modified Files:
src/usr.bin/make: cond.c parse.c trace.c var.c

Log Message:
make: reduce relocations, thereby reducing .text size

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.278 -r1.279 src/usr.bin/make/cond.c
cvs rdiff -u -r1.564 -r1.565 src/usr.bin/make/parse.c
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/make/trace.c
cvs rdiff -u -r1.950 -r1.951 src/usr.bin/make/var.c

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/cond.c
diff -u src/usr.bin/make/cond.c:1.278 src/usr.bin/make/cond.c:1.279
--- src/usr.bin/make/cond.c:1.278	Tue Sep 21 22:53:35 2021
+++ src/usr.bin/make/cond.c	Tue Sep 21 23:06:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.278 2021/09/21 22:53:35 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.279 2021/09/21 23:06:18 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.278 2021/09/21 22:53:35 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.279 2021/09/21 23:06:18 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -778,8 +778,8 @@ static bool
 CondParser_FuncCall(CondParser *par, bool doEval, Token *out_token)
 {
 	static const struct fn_def {
-		const char *fn_name;
-		size_t fn_name_len;
+		const char fn_name[9];
+		unsigned char fn_name_len;
 		size_t (*fn_parse)(CondParser *, const char **, bool,
    const char *, char **);
 		bool (*fn_eval)(size_t, const char *);

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.564 src/usr.bin/make/parse.c:1.565
--- src/usr.bin/make/parse.c:1.564	Tue Sep 21 21:39:32 2021
+++ src/usr.bin/make/parse.c	Tue Sep 21 23:06:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.564 2021/09/21 21:39:32 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.565 2021/09/21 23:06:18 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.564 2021/09/21 21:39:32 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.565 2021/09/21 23:06:18 rillig Exp $");
 
 /* types and constants */
 
@@ -261,7 +261,7 @@ SearchPath *defSysIncPath;	/* default fo
  * keyword is used as a source ("0" if the keyword isn't special as a source)
  */
 static const struct {
-	const char *name;	/* Name of keyword */
+	const char name[17];	/* Name of keyword */
 	ParseSpecial spec;	/* Type when used as a target */
 	GNodeType op;		/* Operator when used as a source */
 } parseKeywords[] = {

Index: src/usr.bin/make/trace.c
diff -u src/usr.bin/make/trace.c:1.28 src/usr.bin/make/trace.c:1.29
--- src/usr.bin/make/trace.c:1.28	Fri Feb  5 05:15:12 2021
+++ src/usr.bin/make/trace.c	Tue Sep 21 23:06:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: trace.c,v 1.28 2021/02/05 05:15:12 rillig Exp $	*/
+/*	$NetBSD: trace.c,v 1.29 2021/09/21 23:06:18 rillig Exp $	*/
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -48,13 +48,13 @@
 #include "job.h"
 #include "trace.h"
 
-MAKE_RCSID("$NetBSD: trace.c,v 1.28 2021/02/05 05:15:12 rillig Exp $");
+MAKE_RCSID("$NetBSD: trace.c,v 1.29 2021/09/21 23:06:18 rillig Exp $");
 
 static FILE *trfile;
 static pid_t trpid;
 const char *trwd;
 
-static const char *evname[] = {
+static const char evname[][4] = {
 	"BEG",
 	"END",
 	"ERR",

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.950 src/usr.bin/make/var.c:1.951
--- src/usr.bin/make/var.c:1.950	Sat Sep 11 09:16:14 2021
+++ src/usr.bin/make/var.c	Tue Sep 21 23:06:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.950 2021/09/11 09:16:14 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.951 2021/09/21 23:06:18 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.950 2021/09/11 09:16:14 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.951 2021/09/21 23:06:18 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -318,7 +318,7 @@ GNode *SCOPE_INTERNAL;
 
 static VarExportedMode var_exportedVars = VAR_EXPORTED_NONE;
 
-static const char *VarEvalMode_Name[] = {
+static const char VarEvalMode_Name[][32] = {
 	"parse-only",
 	"eval",
 	"eval-defined",
@@ -2010,7 +2010,7 @@ typedef enum ExprDefined {
 	DEF_DEFINED
 } ExprDefined;
 
-static const char *const ExprDefined_Name[] = {
+static const char ExprDefined_Name[][10] = {
 	"regular",
 	"undefined",
 	"defined"



CVS commit: src/usr.bin/make

2021-09-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Sep 21 23:06:18 UTC 2021

Modified Files:
src/usr.bin/make: cond.c parse.c trace.c var.c

Log Message:
make: reduce relocations, thereby reducing .text size

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.278 -r1.279 src/usr.bin/make/cond.c
cvs rdiff -u -r1.564 -r1.565 src/usr.bin/make/parse.c
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/make/trace.c
cvs rdiff -u -r1.950 -r1.951 src/usr.bin/make/var.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-09-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Sep 21 22:53:35 UTC 2021

Modified Files:
src/usr.bin/make: cond.c

Log Message:
make: reduce relocations and thereby .text size, make opname const

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.277 -r1.278 src/usr.bin/make/cond.c

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/cond.c
diff -u src/usr.bin/make/cond.c:1.277 src/usr.bin/make/cond.c:1.278
--- src/usr.bin/make/cond.c:1.277	Tue Sep 21 22:48:04 2021
+++ src/usr.bin/make/cond.c	Tue Sep 21 22:53:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.277 2021/09/21 22:48:04 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.278 2021/09/21 22:53:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.277 2021/09/21 22:48:04 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.278 2021/09/21 22:53:35 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -186,7 +186,7 @@ static unsigned int cond_depth = 0;	/* c
 static unsigned int cond_min_depth = 0;	/* depth at makefile open */
 
 /* Names for ComparisonOp. */
-static const char *opname[] = { "<", "<=", ">", ">=", "==", "!=" };
+static const char opname[][3] = { "<", "<=", ">", ">=", "==", "!=" };
 
 static bool
 is_token(const char *str, const char *tok, size_t len)



CVS commit: src/usr.bin/make

2021-09-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Sep 21 22:53:35 UTC 2021

Modified Files:
src/usr.bin/make: cond.c

Log Message:
make: reduce relocations and thereby .text size, make opname const

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.277 -r1.278 src/usr.bin/make/cond.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-09-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Sep 21 22:48:04 UTC 2021

Modified Files:
src/usr.bin/make: cond.c

Log Message:
make: rename and invert CondParser.lhsStrict to leftUnquotedOK

The new name is easier to grasp than the rather abstract word 'strict'.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.276 -r1.277 src/usr.bin/make/cond.c

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/cond.c
diff -u src/usr.bin/make/cond.c:1.276 src/usr.bin/make/cond.c:1.277
--- src/usr.bin/make/cond.c:1.276	Tue Sep 21 22:38:25 2021
+++ src/usr.bin/make/cond.c	Tue Sep 21 22:48:04 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.276 2021/09/21 22:38:25 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.277 2021/09/21 22:48:04 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.276 2021/09/21 22:38:25 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.277 2021/09/21 22:48:04 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -155,7 +155,7 @@ typedef struct CondParser {
 	bool negateEvalBare;
 
 	/*
-	 * Whether the left-hand side of a comparison may NOT be an unquoted
+	 * Whether the left-hand side of a comparison may be an unquoted
 	 * string.  This is allowed for expressions of the form
 	 * ${condition:?:}, see ApplyModifier_IfElse.  Such a condition is
 	 * expanded before it is evaluated, due to ease of implementation.
@@ -166,7 +166,7 @@ typedef struct CondParser {
 	 * In all other contexts, the left-hand side must either be a
 	 * variable expression, a quoted string or a number.
 	 */
-	bool lhsStrict;
+	bool leftUnquotedOK;
 
 	const char *p;		/* The remaining condition to parse */
 	Token curr;		/* Single push-back token used in parsing */
@@ -479,7 +479,7 @@ CondParser_StringExpr(CondParser *par, c
  *	Sets out_quoted if the leaf was a quoted string literal.
  */
 static void
-CondParser_Leaf(CondParser *par, bool doEval, bool strictLHS,
+CondParser_Leaf(CondParser *par, bool doEval, bool unquotedOK,
 		  FStr *out_str, bool *out_quoted)
 {
 	Buffer buf;
@@ -527,11 +527,11 @@ CondParser_Leaf(CondParser *par, bool do
 goto cleanup;
 			continue;
 		default:
-			if (strictLHS && !quoted && *start != '$' &&
+			if (!unquotedOK && !quoted && *start != '$' &&
 			!ch_isdigit(*start)) {
 /*
  * The left-hand side must be quoted,
- * a variable reference or a number.
+ * a variable expression or a number.
  */
 str = FStr_InitRefer(NULL);
 goto cleanup;
@@ -684,7 +684,7 @@ CondParser_Comparison(CondParser *par, b
 	ComparisonOp op;
 	bool lhsQuoted, rhsQuoted;
 
-	CondParser_Leaf(par, doEval, par->lhsStrict, , );
+	CondParser_Leaf(par, doEval, par->leftUnquotedOK, , );
 	if (lhs.str == NULL)
 		goto done_lhs;
 
@@ -705,7 +705,7 @@ CondParser_Comparison(CondParser *par, b
 		goto done_lhs;
 	}
 
-	CondParser_Leaf(par, doEval, false, , );
+	CondParser_Leaf(par, doEval, true, , );
 	if (rhs.str == NULL)
 		goto done_rhs;
 
@@ -1060,7 +1060,7 @@ CondParser_Eval(CondParser *par, bool *o
 static CondEvalResult
 CondEvalExpression(const char *cond, bool *out_value, bool plain,
 		   bool (*evalBare)(size_t, const char *), bool negate,
-		   bool eprint, bool strictLHS)
+		   bool eprint, bool leftUnquotedOK)
 {
 	CondParser par;
 	CondEvalResult rval;
@@ -1070,7 +1070,7 @@ CondEvalExpression(const char *cond, boo
 	par.plain = plain;
 	par.evalBare = evalBare;
 	par.negateEvalBare = negate;
-	par.lhsStrict = strictLHS;
+	par.leftUnquotedOK = leftUnquotedOK;
 	par.p = cond;
 	par.curr = TOK_NONE;
 	par.printedError = false;
@@ -1091,7 +1091,7 @@ CondEvalResult
 Cond_EvalCondition(const char *cond, bool *out_value)
 {
 	return CondEvalExpression(cond, out_value, true,
-	FuncDefined, false, false, false);
+	FuncDefined, false, false, true);
 }
 
 static bool
@@ -1322,7 +1322,7 @@ Cond_EvalLine(const char *line)
 
 	/* And evaluate the conditional expression */
 	if (CondEvalExpression(p, , plain, evalBare, negate,
-	true, true) == COND_INVALID) {
+	true, false) == COND_INVALID) {
 		/* Syntax error in conditional, error message already output. */
 		/* Skip everything to matching .endif */
 		/* XXX: An extra '.else' is not detected in this case. */



CVS commit: src/usr.bin/make

2021-09-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Sep 21 22:48:04 UTC 2021

Modified Files:
src/usr.bin/make: cond.c

Log Message:
make: rename and invert CondParser.lhsStrict to leftUnquotedOK

The new name is easier to grasp than the rather abstract word 'strict'.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.276 -r1.277 src/usr.bin/make/cond.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-09-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Sep 21 22:38:25 UTC 2021

Modified Files:
src/usr.bin/make: cond.c
src/usr.bin/make/unit-tests: cond-token-plain.exp cond-token-plain.mk

Log Message:
make: do not allow unquoted 'left == right' after modifier ':?'

Having a static variable for state that clearly belongs in the parser
looked suspicious, and indeed it was wrong.

When the distinction between .if conditions and expressions of the form
${condition:?:} was added in cond.c 1.68 from 2015-05-05, a new unit
test was added, but it didn't cover this edge case.  At that time, the
state of the condition parser consisted of a few global variables
instead of a separate data type, as would have been appropriate for
parsing nested conditions.


To generate a diff of this commit:
cvs rdiff -u -r1.275 -r1.276 src/usr.bin/make/cond.c
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/cond-token-plain.exp \
src/usr.bin/make/unit-tests/cond-token-plain.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/cond.c
diff -u src/usr.bin/make/cond.c:1.275 src/usr.bin/make/cond.c:1.276
--- src/usr.bin/make/cond.c:1.275	Tue Sep 21 21:43:32 2021
+++ src/usr.bin/make/cond.c	Tue Sep 21 22:38:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.275 2021/09/21 21:43:32 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.276 2021/09/21 22:38:25 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.275 2021/09/21 21:43:32 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.276 2021/09/21 22:38:25 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -154,6 +154,20 @@ typedef struct CondParser {
 	bool (*evalBare)(size_t, const char *);
 	bool negateEvalBare;
 
+	/*
+	 * Whether the left-hand side of a comparison may NOT be an unquoted
+	 * string.  This is allowed for expressions of the form
+	 * ${condition:?:}, see ApplyModifier_IfElse.  Such a condition is
+	 * expanded before it is evaluated, due to ease of implementation.
+	 * This means that at the point where the condition is evaluated,
+	 * make cannot know anymore whether the left-hand side had originally
+	 * been a variable expression or a plain word.
+	 *
+	 * In all other contexts, the left-hand side must either be a
+	 * variable expression, a quoted string or a number.
+	 */
+	bool lhsStrict;
+
 	const char *p;		/* The remaining condition to parse */
 	Token curr;		/* Single push-back token used in parsing */
 
@@ -174,18 +188,6 @@ static unsigned int cond_min_depth = 0;	
 /* Names for ComparisonOp. */
 static const char *opname[] = { "<", "<=", ">", ">=", "==", "!=" };
 
-/*
- * Indicate when we should be strict about lhs of comparisons.
- * In strict mode, the lhs must be a variable expression or a string literal
- * in quotes. In non-strict mode it may also be an unquoted string literal.
- *
- * True when CondEvalExpression is called from Cond_EvalLine (.if etc).
- * False when CondEvalExpression is called from ApplyModifier_IfElse
- * since lhs is already expanded, and at that point we cannot tell if
- * it was a variable reference or not.
- */
-static bool lhsStrict;
-
 static bool
 is_token(const char *str, const char *tok, size_t len)
 {
@@ -682,7 +684,7 @@ CondParser_Comparison(CondParser *par, b
 	ComparisonOp op;
 	bool lhsQuoted, rhsQuoted;
 
-	CondParser_Leaf(par, doEval, lhsStrict, , );
+	CondParser_Leaf(par, doEval, par->lhsStrict, , );
 	if (lhs.str == NULL)
 		goto done_lhs;
 
@@ -1063,13 +1065,12 @@ CondEvalExpression(const char *cond, boo
 	CondParser par;
 	CondEvalResult rval;
 
-	lhsStrict = strictLHS;
-
 	cpp_skip_hspace();
 
 	par.plain = plain;
 	par.evalBare = evalBare;
 	par.negateEvalBare = negate;
+	par.lhsStrict = strictLHS;
 	par.p = cond;
 	par.curr = TOK_NONE;
 	par.printedError = false;

Index: src/usr.bin/make/unit-tests/cond-token-plain.exp
diff -u src/usr.bin/make/unit-tests/cond-token-plain.exp:1.11 src/usr.bin/make/unit-tests/cond-token-plain.exp:1.12
--- src/usr.bin/make/unit-tests/cond-token-plain.exp:1.11	Tue Sep 21 21:59:56 2021
+++ src/usr.bin/make/unit-tests/cond-token-plain.exp	Tue Sep 21 22:38:25 2021
@@ -53,9 +53,9 @@ CondParser_Eval: left == right
 make: "cond-token-plain.mk" line 191: Malformed conditional (left == right)
 CondParser_Eval: ${0:?:} || left == right
 CondParser_Eval: 0
-lhs = "left", rhs = "right", op = ==
+make: "cond-token-plain.mk" line 197: Malformed conditional (${0:?:} || left == right)
 CondParser_Eval: left == right || ${0:?:}
-make: "cond-token-plain.mk" line 201: Malformed conditional (left == right || ${0:?:})
+make: "cond-token-plain.mk" line 202: Malformed conditional (left == right || ${0:?:})
 make: Fatal errors encountered -- cannot continue
 make: stopped in 

CVS commit: src/usr.bin/make

2021-09-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Sep 21 22:38:25 UTC 2021

Modified Files:
src/usr.bin/make: cond.c
src/usr.bin/make/unit-tests: cond-token-plain.exp cond-token-plain.mk

Log Message:
make: do not allow unquoted 'left == right' after modifier ':?'

Having a static variable for state that clearly belongs in the parser
looked suspicious, and indeed it was wrong.

When the distinction between .if conditions and expressions of the form
${condition:?:} was added in cond.c 1.68 from 2015-05-05, a new unit
test was added, but it didn't cover this edge case.  At that time, the
state of the condition parser consisted of a few global variables
instead of a separate data type, as would have been appropriate for
parsing nested conditions.


To generate a diff of this commit:
cvs rdiff -u -r1.275 -r1.276 src/usr.bin/make/cond.c
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/cond-token-plain.exp \
src/usr.bin/make/unit-tests/cond-token-plain.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2021-09-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Sep 21 21:59:56 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: cond-token-plain.exp cond-token-plain.mk

Log Message:
tests/make: demonstrate unintended unquoted string in conditions


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cond-token-plain.exp \
src/usr.bin/make/unit-tests/cond-token-plain.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/unit-tests/cond-token-plain.exp
diff -u src/usr.bin/make/unit-tests/cond-token-plain.exp:1.10 src/usr.bin/make/unit-tests/cond-token-plain.exp:1.11
--- src/usr.bin/make/unit-tests/cond-token-plain.exp:1.10	Mon Jun 21 21:10:01 2021
+++ src/usr.bin/make/unit-tests/cond-token-plain.exp	Tue Sep 21 21:59:56 2021
@@ -49,6 +49,13 @@ make: "cond-token-plain.mk" line 168: No
 CondParser_Eval: "unquoted\"quoted" != unquoted"quoted
 lhs = "unquoted"quoted", rhs = "unquoted"quoted", op = !=
 CondParser_Eval:  != ""
+CondParser_Eval: left == right
+make: "cond-token-plain.mk" line 191: Malformed conditional (left == right)
+CondParser_Eval: ${0:?:} || left == right
+CondParser_Eval: 0
+lhs = "left", rhs = "right", op = ==
+CondParser_Eval: left == right || ${0:?:}
+make: "cond-token-plain.mk" line 201: Malformed conditional (left == right || ${0:?:})
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1
Index: src/usr.bin/make/unit-tests/cond-token-plain.mk
diff -u src/usr.bin/make/unit-tests/cond-token-plain.mk:1.10 src/usr.bin/make/unit-tests/cond-token-plain.mk:1.11
--- src/usr.bin/make/unit-tests/cond-token-plain.mk:1.10	Thu Jan 21 14:08:09 2021
+++ src/usr.bin/make/unit-tests/cond-token-plain.mk	Tue Sep 21 21:59:56 2021
@@ -1,4 +1,4 @@
-# $NetBSD: cond-token-plain.mk,v 1.10 2021/01/21 14:08:09 rillig Exp $
+# $NetBSD: cond-token-plain.mk,v 1.11 2021/09/21 21:59:56 rillig Exp $
 #
 # Tests for plain tokens (that is, string literals without quotes)
 # in .if conditions.
@@ -185,6 +185,22 @@ ${:U}=	backslash
 .  error
 .endif
 
+# In a condition in an .if directive, the left-hand side must not be an
+# unquoted string literal.
+# expect+1: Malformed conditional (left == right)
+.if left == right
+.endif
+# Before cond.c 1.276 from 2021-09-21, a variable expression containing the
+# modifier ':?:' allowed unquoted string literals for the rest of the
+# condition.  This was an unintended implementation mistake.
+.if ${0:?:} || left == right
+.endif
+# This affected only the comparisons after the expression, so the following
+# was still a syntax error.
+# expect+1: Malformed conditional (left == right || ${0:?:})
+.if left == right || ${0:?:}
+.endif
+
 # See cond-token-string.mk for similar tests where the condition is enclosed
 # in "quotes".
 



CVS commit: src/usr.bin/make/unit-tests

2021-09-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Sep 21 21:59:56 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: cond-token-plain.exp cond-token-plain.mk

Log Message:
tests/make: demonstrate unintended unquoted string in conditions


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cond-token-plain.exp \
src/usr.bin/make/unit-tests/cond-token-plain.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-09-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Sep 21 21:43:32 UTC 2021

Modified Files:
src/usr.bin/make: cond.c

Log Message:
make: remove unnecessary negation from CondParser_StringExpr

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.274 -r1.275 src/usr.bin/make/cond.c

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/cond.c
diff -u src/usr.bin/make/cond.c:1.274 src/usr.bin/make/cond.c:1.275
--- src/usr.bin/make/cond.c:1.274	Tue Sep 21 21:39:32 2021
+++ src/usr.bin/make/cond.c	Tue Sep 21 21:43:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.274 2021/09/21 21:39:32 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.275 2021/09/21 21:43:32 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.274 2021/09/21 21:39:32 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.275 2021/09/21 21:43:32 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -421,9 +421,8 @@ CondParser_StringExpr(CondParser *par, c
 	bool atStart;
 	VarParseResult parseResult;
 
-	/* if we are in quotes, an undefined variable is ok */
-	emode = doEval && !quoted ? VARE_UNDEFERR
-	: doEval ? VARE_WANTRES
+	emode = doEval && quoted ? VARE_WANTRES
+	: doEval ? VARE_UNDEFERR
 	: VARE_PARSE_ONLY;
 
 	nested_p = par->p;



CVS commit: src/usr.bin/make

2021-09-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Sep 21 21:43:32 UTC 2021

Modified Files:
src/usr.bin/make: cond.c

Log Message:
make: remove unnecessary negation from CondParser_StringExpr

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.274 -r1.275 src/usr.bin/make/cond.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-09-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Sep 21 21:39:32 UTC 2021

Modified Files:
src/usr.bin/make: cond.c dir.c parse.c

Log Message:
make: remove unnecessary const from parameters

These were leftovers from earlier refactorings, when extracting code to
separate functions.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.273 -r1.274 src/usr.bin/make/cond.c
cvs rdiff -u -r1.272 -r1.273 src/usr.bin/make/dir.c
cvs rdiff -u -r1.563 -r1.564 src/usr.bin/make/parse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-09-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Sep 21 21:39:32 UTC 2021

Modified Files:
src/usr.bin/make: cond.c dir.c parse.c

Log Message:
make: remove unnecessary const from parameters

These were leftovers from earlier refactorings, when extracting code to
separate functions.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.273 -r1.274 src/usr.bin/make/cond.c
cvs rdiff -u -r1.272 -r1.273 src/usr.bin/make/dir.c
cvs rdiff -u -r1.563 -r1.564 src/usr.bin/make/parse.c

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/cond.c
diff -u src/usr.bin/make/cond.c:1.273 src/usr.bin/make/cond.c:1.274
--- src/usr.bin/make/cond.c:1.273	Tue Sep 21 21:03:36 2021
+++ src/usr.bin/make/cond.c	Tue Sep 21 21:39:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.273 2021/09/21 21:03:36 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.274 2021/09/21 21:39:32 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.273 2021/09/21 21:03:36 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.274 2021/09/21 21:39:32 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -413,8 +413,8 @@ is_separator(char ch)
  */
 static bool
 CondParser_StringExpr(CondParser *par, const char *start,
-		  bool const doEval, bool const quoted,
-		  Buffer *buf, FStr *const inout_str)
+		  bool doEval, bool quoted,
+		  Buffer *buf, FStr *inout_str)
 {
 	VarEvalMode emode;
 	const char *nested_p;

Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.272 src/usr.bin/make/dir.c:1.273
--- src/usr.bin/make/dir.c:1.272	Sun Apr  4 10:13:09 2021
+++ src/usr.bin/make/dir.c	Tue Sep 21 21:39:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.272 2021/04/04 10:13:09 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.273 2021/09/21 21:39:32 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -138,7 +138,7 @@
 #include "job.h"
 
 /*	"@(#)dir.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: dir.c,v 1.272 2021/04/04 10:13:09 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.273 2021/09/21 21:39:32 rillig Exp $");
 
 /*
  * A search path is a list of CachedDir structures. A CachedDir has in it the
@@ -1127,9 +1127,8 @@ found:
 }
 
 static bool
-FindFileAbsolute(SearchPath *path, bool const seenDotLast,
-		 const char *const name, const char *const base,
-		 char **out_file)
+FindFileAbsolute(SearchPath *path, bool seenDotLast,
+		 const char *name, const char *base, char **out_file)
 {
 	char *file;
 	SearchPathNode *ln;

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.563 src/usr.bin/make/parse.c:1.564
--- src/usr.bin/make/parse.c:1.563	Sat Aug 14 13:39:43 2021
+++ src/usr.bin/make/parse.c	Tue Sep 21 21:39:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.563 2021/08/14 13:39:43 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.564 2021/09/21 21:39:32 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.563 2021/08/14 13:39:43 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.564 2021/09/21 21:39:32 rillig Exp $");
 
 /* types and constants */
 
@@ -1597,10 +1597,8 @@ ParseDependencySourcesMundane(char *star
  * See the tests depsrc-*.mk.
  */
 static void
-ParseDependencySources(char *const line, char *const cp,
-		   GNodeType const tOp,
-		   ParseSpecial const specType,
-		   SearchPathList ** inout_paths)
+ParseDependencySources(char *line, char *cp, GNodeType tOp,
+		   ParseSpecial specType, SearchPathList **inout_paths)
 {
 	if (line[0] == '\0') {
 		ParseDependencySourcesEmpty(specType, *inout_paths);



CVS commit: src/usr.bin/make

2021-09-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Sep 21 21:03:36 UTC 2021

Modified Files:
src/usr.bin/make: cond.c

Log Message:
make: fix out-of-bounds memory read (since previous commit)


To generate a diff of this commit:
cvs rdiff -u -r1.272 -r1.273 src/usr.bin/make/cond.c

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/cond.c
diff -u src/usr.bin/make/cond.c:1.272 src/usr.bin/make/cond.c:1.273
--- src/usr.bin/make/cond.c:1.272	Tue Sep 21 20:54:42 2021
+++ src/usr.bin/make/cond.c	Tue Sep 21 21:03:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.272 2021/09/21 20:54:42 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.273 2021/09/21 21:03:36 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.272 2021/09/21 20:54:42 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.273 2021/09/21 21:03:36 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -794,10 +794,10 @@ CondParser_FuncCall(CondParser *par, boo
 	char *arg = NULL;
 	size_t arglen;
 	const char *cp = par->p;
-	const struct fn_def *fns_end = fns + sizeof fns / sizeof fns[0];
+	const struct fn_def *last_fn = fns + sizeof fns / sizeof fns[0] - 1;
 
 	for (fn = fns; !is_token(cp, fn->fn_name, fn->fn_name_len); fn++)
-		if (fn == fns_end)
+		if (fn == last_fn)
 			return false;
 
 	cp += fn->fn_name_len;



CVS commit: src/usr.bin/make

2021-09-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Sep 21 21:03:36 UTC 2021

Modified Files:
src/usr.bin/make: cond.c

Log Message:
make: fix out-of-bounds memory read (since previous commit)


To generate a diff of this commit:
cvs rdiff -u -r1.272 -r1.273 src/usr.bin/make/cond.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-09-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Sep 21 20:54:42 UTC 2021

Modified Files:
src/usr.bin/make: cond.c

Log Message:
make: reduce indentation in CondParser_FuncCall

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.271 -r1.272 src/usr.bin/make/cond.c

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/cond.c
diff -u src/usr.bin/make/cond.c:1.271 src/usr.bin/make/cond.c:1.272
--- src/usr.bin/make/cond.c:1.271	Tue Sep 21 20:51:38 2021
+++ src/usr.bin/make/cond.c	Tue Sep 21 20:54:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.271 2021/09/21 20:51:38 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.272 2021/09/21 20:54:42 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.271 2021/09/21 20:51:38 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.272 2021/09/21 20:54:42 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -796,30 +796,27 @@ CondParser_FuncCall(CondParser *par, boo
 	const char *cp = par->p;
 	const struct fn_def *fns_end = fns + sizeof fns / sizeof fns[0];
 
-	for (fn = fns; fn != fns_end; fn++) {
-		if (!is_token(cp, fn->fn_name, fn->fn_name_len))
-			continue;
-
-		cp += fn->fn_name_len;
-		cpp_skip_whitespace();
-		if (*cp != '(')
-			break;
-
-		arglen = fn->fn_parse(par, , doEval, fn->fn_name, );
-		if (arglen == 0 || arglen == (size_t)-1) {
-			par->p = cp;
-			*out_token = arglen == 0 ? TOK_FALSE : TOK_ERROR;
-			return true;
-		}
+	for (fn = fns; !is_token(cp, fn->fn_name, fn->fn_name_len); fn++)
+		if (fn == fns_end)
+			return false;
+
+	cp += fn->fn_name_len;
+	cpp_skip_whitespace();
+	if (*cp != '(')
+		return false;
 
-		/* Evaluate the argument using the required function. */
-		*out_token = ToToken(!doEval || fn->fn_eval(arglen, arg));
-		free(arg);
+	arglen = fn->fn_parse(par, , doEval, fn->fn_name, );
+	if (arglen == 0 || arglen == (size_t)-1) {
 		par->p = cp;
+		*out_token = arglen == 0 ? TOK_FALSE : TOK_ERROR;
 		return true;
 	}
 
-	return false;
+	/* Evaluate the argument using the required function. */
+	*out_token = ToToken(!doEval || fn->fn_eval(arglen, arg));
+	free(arg);
+	par->p = cp;
+	return true;
 }
 
 /*



CVS commit: src/usr.bin/make

2021-09-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Sep 21 20:54:42 UTC 2021

Modified Files:
src/usr.bin/make: cond.c

Log Message:
make: reduce indentation in CondParser_FuncCall

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.271 -r1.272 src/usr.bin/make/cond.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-09-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Sep 21 20:51:39 UTC 2021

Modified Files:
src/usr.bin/make: cond.c

Log Message:
make: fix documentation about operator associativity in conditions


To generate a diff of this commit:
cvs rdiff -u -r1.270 -r1.271 src/usr.bin/make/cond.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-09-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Sep 21 20:51:39 UTC 2021

Modified Files:
src/usr.bin/make: cond.c

Log Message:
make: fix documentation about operator associativity in conditions


To generate a diff of this commit:
cvs rdiff -u -r1.270 -r1.271 src/usr.bin/make/cond.c

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/cond.c
diff -u src/usr.bin/make/cond.c:1.270 src/usr.bin/make/cond.c:1.271
--- src/usr.bin/make/cond.c:1.270	Thu Jul 29 06:35:20 2021
+++ src/usr.bin/make/cond.c	Tue Sep 21 20:51:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.270 2021/07/29 06:35:20 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.271 2021/09/21 20:51:38 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,14 +95,14 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.270 2021/07/29 06:35:20 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.271 2021/09/21 20:51:38 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
- *	Or -> And '||' Or
  *	Or -> And
- *	And -> Term '&&' And
+ *	Or -> Or '||' And
  *	And -> Term
+ *	And -> And '&&' Term
  *	Term -> Function '(' Argument ')'
  *	Term -> Leaf Operator Leaf
  *	Term -> Leaf
@@ -977,8 +977,8 @@ CondParser_Term(CondParser *par, bool do
 }
 
 /*
- * And -> Term '&&' And
  * And -> Term
+ * And -> And '&&' Term
  */
 static CondResult
 CondParser_And(CondParser *par, bool doEval)
@@ -1004,8 +1004,8 @@ CondParser_And(CondParser *par, bool doE
 }
 
 /*
- * Or -> And '||' Or
  * Or -> And
+ * Or -> Or '||' And
  */
 static CondResult
 CondParser_Or(CondParser *par, bool doEval)



CVS commit: src/usr.bin/make

2021-09-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Sep 12 10:28:40 UTC 2021

Modified Files:
src/usr.bin/make: test-variants.sh

Log Message:
tests/make: allow to only test selected variants

Testing all variants takes several minutes, so make it possible to test
a single or a few test variants separately.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/test-variants.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-09-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Sep 12 10:28:40 UTC 2021

Modified Files:
src/usr.bin/make: test-variants.sh

Log Message:
tests/make: allow to only test selected variants

Testing all variants takes several minutes, so make it possible to test
a single or a few test variants separately.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/test-variants.sh

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/test-variants.sh
diff -u src/usr.bin/make/test-variants.sh:1.11 src/usr.bin/make/test-variants.sh:1.12
--- src/usr.bin/make/test-variants.sh:1.11	Sun Sep 12 09:51:14 2021
+++ src/usr.bin/make/test-variants.sh	Sun Sep 12 10:28:40 2021
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: test-variants.sh,v 1.11 2021/09/12 09:51:14 rillig Exp $
+# $NetBSD: test-variants.sh,v 1.12 2021/09/12 10:28:40 rillig Exp $
 #
 # Build several variants of make and run the tests on them.
 #
@@ -10,6 +10,7 @@
 set -eu
 
 failed="no"
+filter="${1-}"
 
 fail() {
 	echo "failed"
@@ -17,6 +18,11 @@ fail() {
 }
 
 testcase() {
+	case "$*" in
+	*"$filter"*) ;;
+	*) return;;
+	esac
+
 	echo "===> Running $*"
 
 	env -i PATH="$PATH" USETOOLS="no" "$@" \
@@ -31,7 +37,7 @@ testcase() {
 }
 
 
-testcase # just the plain default options
+testcase DESCR="just the plain default options"
 
 # Try a different compiler, with slightly different warnings and error
 # messages.  One feature that is missing from GCC is a little stricter



CVS commit: src/usr.bin/make/unit-tests

2021-09-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Sep 12 10:26:49 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: job-output-null.exp job-output-null.mk

Log Message:
tests/make: make output of test job-output-null clearer

Having 5 times the word 'hello' in the output doesn't help at
understanding the test and how the output was produced.

Bash 5 sometimes makes this test fail by adding '2b' and '2c' to the
output.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/job-output-null.exp \
src/usr.bin/make/unit-tests/job-output-null.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/unit-tests/job-output-null.exp
diff -u src/usr.bin/make/unit-tests/job-output-null.exp:1.2 src/usr.bin/make/unit-tests/job-output-null.exp:1.3
--- src/usr.bin/make/unit-tests/job-output-null.exp:1.2	Sat Jul  3 22:39:40 2021
+++ src/usr.bin/make/unit-tests/job-output-null.exp	Sun Sep 12 10:26:49 2021
@@ -1,4 +1,4 @@
-hello
-hello
-hello without   newline, hello without   newline.
+1
+2a
+3a without   newline, 3b without   newline.
 exit status 0
Index: src/usr.bin/make/unit-tests/job-output-null.mk
diff -u src/usr.bin/make/unit-tests/job-output-null.mk:1.2 src/usr.bin/make/unit-tests/job-output-null.mk:1.3
--- src/usr.bin/make/unit-tests/job-output-null.mk:1.2	Sat Jul  3 22:39:40 2021
+++ src/usr.bin/make/unit-tests/job-output-null.mk	Sun Sep 12 10:26:49 2021
@@ -1,4 +1,4 @@
-# $NetBSD: job-output-null.mk,v 1.2 2021/07/03 22:39:40 rillig Exp $
+# $NetBSD: job-output-null.mk,v 1.3 2021/09/12 10:26:49 rillig Exp $
 #
 # Test how null bytes in the output of a command are handled.  Make processes
 # them using null-terminated strings, which may cut off some of the output.
@@ -26,14 +26,14 @@ all: .PHONY
 	# The null byte from the command output is kept as-is.
 	# See CollectOutput, which looks like it intended to replace these
 	# null bytes with simple spaces.
-	@printf 'hello\0world\n'
+	@printf '1\0trailing\n'
 
 	# Give the parent process a chance to see the above output, but not
 	# yet the output from the next printf command.
 	@sleep 1
 
 	# All null bytes from the command output are kept as-is.
-	@printf 'hello\0world\n''hello\0world\n''hello\0world\n'
+	@printf '2a\0trailing\n''2b\0trailing\n''2c\0trailing\n'
 
 	@sleep 1
 
@@ -42,4 +42,4 @@ all: .PHONY
 	#
 	# The three null bytes in a row test whether this output is
 	# compressed to a single space like in DebugFailedTarget.  It isn't.
-	@printf 'hello\0without\0\0\0newline, hello\0without\0\0\0newline.'
+	@printf '3a\0without\0\0\0newline, 3b\0without\0\0\0newline.'



CVS commit: src/usr.bin/make/unit-tests

2021-09-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Sep 12 10:26:49 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: job-output-null.exp job-output-null.mk

Log Message:
tests/make: make output of test job-output-null clearer

Having 5 times the word 'hello' in the output doesn't help at
understanding the test and how the output was produced.

Bash 5 sometimes makes this test fail by adding '2b' and '2c' to the
output.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/job-output-null.exp \
src/usr.bin/make/unit-tests/job-output-null.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-09-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Sep 12 09:51:14 UTC 2021

Modified Files:
src/usr.bin/make: make.h test-variants.sh

Log Message:
make: error out if a pre-C99 platform defines bool in some cases

On NetBSD/amd64 9.99.88, when compiling make in C90 mode, make.h defined
its own boolean type as an alias for unsigned int.  Not plain int since
that would make the value of bit-fields -1 instead of 1.

This worked fine for all files except main.c, which includes
, which in turn includes  unconditionally, even
in C90 mode.  This meant that in main.c, sizeof(bool) was 1, while in
all other files it was 4.

This in turn led to a segmentation fault when ParseDependencySourceMain
tried to access opts.create.  Since parse.c assumed sizeof(bool) == 4,
it computed an offset outside of struct CmdOpts, which was defined in
main.c with sizeof(bool) == 1.

Rather than risking these segmentation faults, prevent building make on
platforms like these and suggest a proper workaround.


To generate a diff of this commit:
cvs rdiff -u -r1.264 -r1.265 src/usr.bin/make/make.h
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/test-variants.sh

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/make.h
diff -u src/usr.bin/make/make.h:1.264 src/usr.bin/make/make.h:1.265
--- src/usr.bin/make/make.h:1.264	Sat Jul 31 09:30:17 2021
+++ src/usr.bin/make/make.h	Sun Sep 12 09:51:14 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.264 2021/07/31 09:30:17 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.265 2021/09/12 09:51:14 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -142,18 +142,25 @@
 
 #if __STDC_VERSION__ >= 199901L || defined(lint) || defined(USE_C99_BOOLEAN)
 #include 
+#elif defined(__bool_true_false_are_defined)
+/*
+ * All files of make must be compiled with the same definition of bool.
+ * Since one of the files includes , that means the header is
+ * available on this platform.  Recompile everything with -DUSE_C99_BOOLEAN.
+ */
+#error " is included in pre-C99 mode"
+#elif defined(bool) || defined(true) || defined(false)
+/*
+ * In pre-C99 mode, make does not expect that bool is already defined.
+ * You need to ensure that all translation units use the same definition for
+ * bool.
+ */
+#error "bool/true/false is defined in pre-C99 mode"
 #else
-#ifndef bool
-typedef unsigned int Boolean;
-#define bool	Boolean
-#endif
-#ifndef true
+typedef unsigned char bool;
 #define true	1
-#endif
-#ifndef false
 #define false	0
 #endif
-#endif
 
 #include "lst.h"
 #include "enum.h"

Index: src/usr.bin/make/test-variants.sh
diff -u src/usr.bin/make/test-variants.sh:1.10 src/usr.bin/make/test-variants.sh:1.11
--- src/usr.bin/make/test-variants.sh:1.10	Sat Apr  3 11:08:40 2021
+++ src/usr.bin/make/test-variants.sh	Sun Sep 12 09:51:14 2021
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: test-variants.sh,v 1.10 2021/04/03 11:08:40 rillig Exp $
+# $NetBSD: test-variants.sh,v 1.11 2021/09/12 09:51:14 rillig Exp $
 #
 # Build several variants of make and run the tests on them.
 #
@@ -22,7 +22,7 @@ testcase() {
 	env -i PATH="$PATH" USETOOLS="no" "$@" \
 		sh -ce "make -s cleandir" \
 	&& env -i PATH="$PATH" USETOOLS="no" "$@" \
-		sh -ce "make -ks all" \
+		sh -ce "make -ks -j6 dependall" \
 	&& size *.o make \
 	&& env -i PATH="$PATH" USETOOLS="no" MALLOC_OPTIONS="JA" \
 		_MKMSG_TEST=":" "$@" \
@@ -120,10 +120,16 @@ testcase USER_CFLAGS="-O0 -ggdb"
 # Ensure that every inline function is declared as MAKE_ATTR_UNUSED.
 testcase USER_CPPFLAGS="-Dinline="
 
+# Is expected to fail with " is included in pre-C99 mode".
 testcase USER_CFLAGS="-std=c90" USER_CPPFLAGS="-Dinline="
 
+# This workaround is necessary on NetBSD 9.99 since main.c includes
+# , which includes  even in pre-C99 mode.
+testcase USER_CFLAGS="-std=c90" USER_CPPFLAGS="-Dinline= -DUSE_C99_BOOLEAN"
+
 #testcase USER_CFLAGS="-std=c90 -pedantic" USER_CPPFLAGS="-Dinline="
 
+# Is expected to fail with " is included in pre-C99 mode".
 testcase USER_CFLAGS="-ansi" USER_CPPFLAGS="-Dinline="
 
 # config.h does not allow overriding these features



CVS commit: src/usr.bin/make

2021-09-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Sep 12 09:51:14 UTC 2021

Modified Files:
src/usr.bin/make: make.h test-variants.sh

Log Message:
make: error out if a pre-C99 platform defines bool in some cases

On NetBSD/amd64 9.99.88, when compiling make in C90 mode, make.h defined
its own boolean type as an alias for unsigned int.  Not plain int since
that would make the value of bit-fields -1 instead of 1.

This worked fine for all files except main.c, which includes
, which in turn includes  unconditionally, even
in C90 mode.  This meant that in main.c, sizeof(bool) was 1, while in
all other files it was 4.

This in turn led to a segmentation fault when ParseDependencySourceMain
tried to access opts.create.  Since parse.c assumed sizeof(bool) == 4,
it computed an offset outside of struct CmdOpts, which was defined in
main.c with sizeof(bool) == 1.

Rather than risking these segmentation faults, prevent building make on
platforms like these and suggest a proper workaround.


To generate a diff of this commit:
cvs rdiff -u -r1.264 -r1.265 src/usr.bin/make/make.h
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/test-variants.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-09-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Sep 12 08:36:15 UTC 2021

Modified Files:
src/usr.bin/make: hash.c

Log Message:
make: fix build for DEBUG_HASH_LOOKUP


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/usr.bin/make/hash.c

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/hash.c
diff -u src/usr.bin/make/hash.c:1.64 src/usr.bin/make/hash.c:1.65
--- src/usr.bin/make/hash.c:1.64	Sun Apr 11 12:46:54 2021
+++ src/usr.bin/make/hash.c	Sun Sep 12 08:36:14 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: hash.c,v 1.64 2021/04/11 12:46:54 rillig Exp $	*/
+/*	$NetBSD: hash.c,v 1.65 2021/09/12 08:36:14 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -74,7 +74,7 @@
 #include "make.h"
 
 /*	"@(#)hash.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: hash.c,v 1.64 2021/04/11 12:46:54 rillig Exp $");
+MAKE_RCSID("$NetBSD: hash.c,v 1.65 2021/09/12 08:36:14 rillig Exp $");
 
 /*
  * The ratio of # entries to # buckets at which we rebuild the table to
@@ -152,7 +152,7 @@ HashTable_FindEntryBySubstring(HashTable
 	unsigned int chainlen = 0;
 
 #ifdef DEBUG_HASH_LOOKUP
-	DEBUG4(HASH, "%s: %p h=%08x key=%.*s\n", __func__, t, h,
+	DEBUG5(HASH, "%s: %p h=%08x key=%.*s\n", __func__, t, h,
 	(int)Substring_Length(key), key.start);
 #endif
 



CVS commit: src/usr.bin/make

2021-09-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Sep 12 08:36:15 UTC 2021

Modified Files:
src/usr.bin/make: hash.c

Log Message:
make: fix build for DEBUG_HASH_LOOKUP


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/usr.bin/make/hash.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-09-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Sep 12 08:32:23 UTC 2021

Modified Files:
src/usr.bin/make: targ.c

Log Message:
make: reduce number of relocations in Targ_PrintType

On x86_64, this saves 120 bytes of .text.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.171 -r1.172 src/usr.bin/make/targ.c

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/targ.c
diff -u src/usr.bin/make/targ.c:1.171 src/usr.bin/make/targ.c:1.172
--- src/usr.bin/make/targ.c:1.171	Sun Sep 12 08:03:48 2021
+++ src/usr.bin/make/targ.c	Sun Sep 12 08:32:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: targ.c,v 1.171 2021/09/12 08:03:48 rillig Exp $	*/
+/*	$NetBSD: targ.c,v 1.172 2021/09/12 08:32:23 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -113,7 +113,7 @@
 #include "dir.h"
 
 /*	"@(#)targ.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: targ.c,v 1.171 2021/09/12 08:03:48 rillig Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.172 2021/09/12 08:32:23 rillig Exp $");
 
 /*
  * All target nodes that appeared on the left-hand side of one of the
@@ -421,7 +421,7 @@ Targ_PrintType(GNodeType type)
 	static const struct {
 		GNodeType bit;
 		bool internal;
-		const char *name;
+		const char name[10];
 	} names[] = {
 		{ OP_MEMBER,	true,	"MEMBER"	},
 		{ OP_LIB,	true,	"LIB"		},



CVS commit: src/usr.bin/make

2021-09-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Sep 12 08:32:23 UTC 2021

Modified Files:
src/usr.bin/make: targ.c

Log Message:
make: reduce number of relocations in Targ_PrintType

On x86_64, this saves 120 bytes of .text.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.171 -r1.172 src/usr.bin/make/targ.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-09-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Sep 12 08:03:49 UTC 2021

Modified Files:
src/usr.bin/make: nonints.h targ.c

Log Message:
make: fix lint warnings for strict bool mode

In strict bool mode, lint does not consider 'x & y' as having type bool,
if x and y have integer type, it only allows this for enums.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.214 -r1.215 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.170 -r1.171 src/usr.bin/make/targ.c

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/nonints.h
diff -u src/usr.bin/make/nonints.h:1.214 src/usr.bin/make/nonints.h:1.215
--- src/usr.bin/make/nonints.h:1.214	Sat Aug 14 13:32:12 2021
+++ src/usr.bin/make/nonints.h	Sun Sep 12 08:03:48 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.214 2021/08/14 13:32:12 rillig Exp $	*/
+/*	$NetBSD: nonints.h,v 1.215 2021/09/12 08:03:48 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -203,7 +203,7 @@ void Targ_PrintCmds(GNode *);
 void Targ_PrintNode(GNode *, int);
 void Targ_PrintNodes(GNodeList *, int);
 const char *Targ_FmtTime(time_t);
-void Targ_PrintType(int);
+void Targ_PrintType(GNodeType);
 void Targ_PrintGraph(int);
 void Targ_Propagate(void);
 const char *GNodeMade_Name(GNodeMade);

Index: src/usr.bin/make/targ.c
diff -u src/usr.bin/make/targ.c:1.170 src/usr.bin/make/targ.c:1.171
--- src/usr.bin/make/targ.c:1.170	Sun Sep 12 07:52:21 2021
+++ src/usr.bin/make/targ.c	Sun Sep 12 08:03:48 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: targ.c,v 1.170 2021/09/12 07:52:21 rillig Exp $	*/
+/*	$NetBSD: targ.c,v 1.171 2021/09/12 08:03:48 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -113,7 +113,7 @@
 #include "dir.h"
 
 /*	"@(#)targ.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: targ.c,v 1.170 2021/09/12 07:52:21 rillig Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.171 2021/09/12 08:03:48 rillig Exp $");
 
 /*
  * All target nodes that appeared on the left-hand side of one of the
@@ -416,7 +416,7 @@ Targ_FmtTime(time_t tm)
 
 /* Print out a type field giving only those attributes the user can set. */
 void
-Targ_PrintType(int type)
+Targ_PrintType(GNodeType type)
 {
 	static const struct {
 		GNodeType bit;



CVS commit: src/usr.bin/make

2021-09-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Sep 12 08:03:49 UTC 2021

Modified Files:
src/usr.bin/make: nonints.h targ.c

Log Message:
make: fix lint warnings for strict bool mode

In strict bool mode, lint does not consider 'x & y' as having type bool,
if x and y have integer type, it only allows this for enums.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.214 -r1.215 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.170 -r1.171 src/usr.bin/make/targ.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-09-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Sep 12 07:52:21 UTC 2021

Modified Files:
src/usr.bin/make: targ.c

Log Message:
make: fix Targ_PrintType for pre-C99 compilers


To generate a diff of this commit:
cvs rdiff -u -r1.169 -r1.170 src/usr.bin/make/targ.c

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/targ.c
diff -u src/usr.bin/make/targ.c:1.169 src/usr.bin/make/targ.c:1.170
--- src/usr.bin/make/targ.c:1.169	Sun Sep 12 07:50:45 2021
+++ src/usr.bin/make/targ.c	Sun Sep 12 07:52:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: targ.c,v 1.169 2021/09/12 07:50:45 rillig Exp $	*/
+/*	$NetBSD: targ.c,v 1.170 2021/09/12 07:52:21 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -113,7 +113,7 @@
 #include "dir.h"
 
 /*	"@(#)targ.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: targ.c,v 1.169 2021/09/12 07:50:45 rillig Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.170 2021/09/12 07:52:21 rillig Exp $");
 
 /*
  * All target nodes that appeared on the left-hand side of one of the
@@ -439,8 +439,9 @@ Targ_PrintType(int type)
 		{ OP_USE,	false,	"USE"		},
 		{ OP_OPTIONAL,	false,	"OPTIONAL"	},
 	};
+	size_t i;
 
-	for (size_t i = 0; i < sizeof(names) / sizeof(names[0]); i++) {
+	for (i = 0; i < sizeof(names) / sizeof(names[0]); i++) {
 		if (type & names[i].bit) {
 			if (names[i].internal)
 DEBUG1(TARG, " .%s", names[i].name);



CVS commit: src/usr.bin/make

2021-09-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Sep 12 07:52:21 UTC 2021

Modified Files:
src/usr.bin/make: targ.c

Log Message:
make: fix Targ_PrintType for pre-C99 compilers


To generate a diff of this commit:
cvs rdiff -u -r1.169 -r1.170 src/usr.bin/make/targ.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-09-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Sep 12 07:50:45 UTC 2021

Modified Files:
src/usr.bin/make: targ.c

Log Message:
make: make Targ_PrintType simpler

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.168 -r1.169 src/usr.bin/make/targ.c

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/targ.c
diff -u src/usr.bin/make/targ.c:1.168 src/usr.bin/make/targ.c:1.169
--- src/usr.bin/make/targ.c:1.168	Sat Apr  3 12:01:00 2021
+++ src/usr.bin/make/targ.c	Sun Sep 12 07:50:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: targ.c,v 1.168 2021/04/03 12:01:00 rillig Exp $	*/
+/*	$NetBSD: targ.c,v 1.169 2021/09/12 07:50:45 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -113,7 +113,7 @@
 #include "dir.h"
 
 /*	"@(#)targ.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: targ.c,v 1.168 2021/04/03 12:01:00 rillig Exp $");
+MAKE_RCSID("$NetBSD: targ.c,v 1.169 2021/09/12 07:50:45 rillig Exp $");
 
 /*
  * All target nodes that appeared on the left-hand side of one of the
@@ -418,34 +418,34 @@ Targ_FmtTime(time_t tm)
 void
 Targ_PrintType(int type)
 {
-	int tbit;
-
-	type &= ~OP_OPMASK;
-
-	while (type != 0) {
-		tbit = 1 << (ffs(type) - 1);
-		type &= ~tbit;
-
-		switch (tbit) {
-#define PRINTBIT(bit, attr) case bit: debug_printf(" " attr); break
-#define PRINTDBIT(bit, attr) case bit: DEBUG0(TARG, " " attr); break
-		PRINTBIT(OP_OPTIONAL, ".OPTIONAL");
-		PRINTBIT(OP_USE, ".USE");
-		PRINTBIT(OP_EXEC, ".EXEC");
-		PRINTBIT(OP_IGNORE, ".IGNORE");
-		PRINTBIT(OP_PRECIOUS, ".PRECIOUS");
-		PRINTBIT(OP_SILENT, ".SILENT");
-		PRINTBIT(OP_MAKE, ".MAKE");
-		PRINTBIT(OP_JOIN, ".JOIN");
-		PRINTBIT(OP_INVISIBLE, ".INVISIBLE");
-		PRINTBIT(OP_NOTMAIN, ".NOTMAIN");
-		PRINTDBIT(OP_LIB, ".LIB");
-		PRINTDBIT(OP_MEMBER, ".MEMBER");
-		PRINTDBIT(OP_ARCHV, ".ARCHV");
-		PRINTDBIT(OP_MADE, ".MADE");
-		PRINTDBIT(OP_PHONY, ".PHONY");
-#undef PRINTBIT
-#undef PRINTDBIT
+	static const struct {
+		GNodeType bit;
+		bool internal;
+		const char *name;
+	} names[] = {
+		{ OP_MEMBER,	true,	"MEMBER"	},
+		{ OP_LIB,	true,	"LIB"		},
+		{ OP_ARCHV,	true,	"ARCHV"		},
+		{ OP_PHONY,	true,	"PHONY"		},
+		{ OP_NOTMAIN,	false,	"NOTMAIN"	},
+		{ OP_INVISIBLE,	false,	"INVISIBLE"	},
+		{ OP_MADE,	true,	"MADE"		},
+		{ OP_JOIN,	false,	"JOIN"		},
+		{ OP_MAKE,	false,	"MAKE"		},
+		{ OP_SILENT,	false,	"SILENT"	},
+		{ OP_PRECIOUS,	false,	"PRECIOUS"	},
+		{ OP_IGNORE,	false,	"IGNORE"	},
+		{ OP_EXEC,	false,	"EXEC"		},
+		{ OP_USE,	false,	"USE"		},
+		{ OP_OPTIONAL,	false,	"OPTIONAL"	},
+	};
+
+	for (size_t i = 0; i < sizeof(names) / sizeof(names[0]); i++) {
+		if (type & names[i].bit) {
+			if (names[i].internal)
+DEBUG1(TARG, " .%s", names[i].name);
+			else
+debug_printf(" .%s", names[i].name);
 		}
 	}
 }



CVS commit: src/usr.bin/make

2021-09-12 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Sep 12 07:50:45 UTC 2021

Modified Files:
src/usr.bin/make: targ.c

Log Message:
make: make Targ_PrintType simpler

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.168 -r1.169 src/usr.bin/make/targ.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-09-11 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Sep 11 09:16:14 UTC 2021

Modified Files:
src/usr.bin/make: var.c

Log Message:
make: eliminate a few common subexpressions

This commit contains only changes that don't increase the code size on
x86_64.  Replacing the remaining instance of ModChain_ShouldEval would
either increase the code size or make the code harder to understand.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.949 -r1.950 src/usr.bin/make/var.c

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/var.c
diff -u src/usr.bin/make/var.c:1.949 src/usr.bin/make/var.c:1.950
--- src/usr.bin/make/var.c:1.949	Mon Sep  6 19:38:30 2021
+++ src/usr.bin/make/var.c	Sat Sep 11 09:16:14 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.949 2021/09/06 19:38:30 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.950 2021/09/11 09:16:14 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.949 2021/09/06 19:38:30 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.950 2021/09/11 09:16:14 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -2564,6 +2564,7 @@ TryParseTime(const char **pp, time_t *ou
 static ApplyModifierResult
 ApplyModifier_Gmtime(const char **pp, ModChain *ch)
 {
+	Expr *expr;
 	time_t utc;
 
 	const char *mod = *pp;
@@ -2583,9 +2584,10 @@ ApplyModifier_Gmtime(const char **pp, Mo
 		*pp = mod + 6;
 	}
 
-	if (ModChain_ShouldEval(ch))
-		Expr_SetValueOwn(ch->expr,
-		VarStrftime(ch->expr->value.str, true, utc));
+	expr = ch->expr;
+	if (Expr_ShouldEval(expr))
+		Expr_SetValueOwn(expr,
+		VarStrftime(expr->value.str, true, utc));
 
 	return AMR_OK;
 }
@@ -2594,6 +2596,7 @@ ApplyModifier_Gmtime(const char **pp, Mo
 static ApplyModifierResult
 ApplyModifier_Localtime(const char **pp, ModChain *ch)
 {
+	Expr *expr;
 	time_t utc;
 
 	const char *mod = *pp;
@@ -2613,9 +2616,10 @@ ApplyModifier_Localtime(const char **pp,
 		*pp = mod + 9;
 	}
 
-	if (ModChain_ShouldEval(ch))
-		Expr_SetValueOwn(ch->expr,
-		VarStrftime(ch->expr->value.str, false, utc));
+	expr = ch->expr;
+	if (Expr_ShouldEval(expr))
+		Expr_SetValueOwn(expr,
+		VarStrftime(expr->value.str, false, utc));
 
 	return AMR_OK;
 }
@@ -2644,7 +2648,7 @@ ApplyModifier_Path(const char **pp, ModC
 
 	(*pp)++;
 
-	if (!ModChain_ShouldEval(ch))
+	if (!Expr_ShouldEval(expr))
 		return AMR_OK;
 
 	Expr_Define(expr);
@@ -3149,14 +3153,14 @@ ApplyModifier_To(const char **pp, ModCha
 
 	if (mod[1] == 'u') {/* :tu */
 		*pp = mod + 2;
-		if (ModChain_ShouldEval(ch))
+		if (Expr_ShouldEval(expr))
 			Expr_SetValueOwn(expr, str_toupper(expr->value.str));
 		return AMR_OK;
 	}
 
 	if (mod[1] == 'l') {/* :tl */
 		*pp = mod + 2;
-		if (ModChain_ShouldEval(ch))
+		if (Expr_ShouldEval(expr))
 			Expr_SetValueOwn(expr, str_tolower(expr->value.str));
 		return AMR_OK;
 	}
@@ -3443,7 +3447,7 @@ ApplyModifier_IfElse(const char **pp, Mo
 		return AMR_CLEANUP;
 	}
 
-	if (!ModChain_ShouldEval(ch)) {
+	if (!Expr_ShouldEval(expr)) {
 		FStr_Done(_expr);
 		FStr_Done(_expr);
 	} else if (value) {



CVS commit: src/usr.bin/make

2021-09-11 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Sep 11 09:16:14 UTC 2021

Modified Files:
src/usr.bin/make: var.c

Log Message:
make: eliminate a few common subexpressions

This commit contains only changes that don't increase the code size on
x86_64.  Replacing the remaining instance of ModChain_ShouldEval would
either increase the code size or make the code harder to understand.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.949 -r1.950 src/usr.bin/make/var.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2021-09-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Sep  7 20:41:58 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: cond-short.mk var-eval-short.exp
var-eval-short.mk

Log Message:
tests/make: expand on the history of unnecessary evaluation


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/cond-short.mk
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/var-eval-short.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/var-eval-short.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/unit-tests/cond-short.mk
diff -u src/usr.bin/make/unit-tests/cond-short.mk:1.16 src/usr.bin/make/unit-tests/cond-short.mk:1.17
--- src/usr.bin/make/unit-tests/cond-short.mk:1.16	Sun Mar 14 11:49:37 2021
+++ src/usr.bin/make/unit-tests/cond-short.mk	Tue Sep  7 20:41:58 2021
@@ -1,4 +1,4 @@
-# $NetBSD: cond-short.mk,v 1.16 2021/03/14 11:49:37 rillig Exp $
+# $NetBSD: cond-short.mk,v 1.17 2021/09/07 20:41:58 rillig Exp $
 #
 # Demonstrates that in conditions, the right-hand side of an && or ||
 # is only evaluated if it can actually influence the result.
@@ -12,7 +12,20 @@
 # possible to skip evaluation of irrelevant variable expressions and only
 # parse them.  They were still evaluated though, the only difference to
 # relevant variable expressions was that in the irrelevant variable
-# expressions, undefined variables were allowed.
+# expressions, undefined variables were allowed.  This allowed for conditions
+# like 'defined(VAR) && ${VAR:S,from,to,} != ""', which no longer produced an
+# error message 'Malformed conditional', but it still evaluated the
+# expression, even though the expression was irrelevant.
+#
+# Since the initial commit on 1993-03-21, the manual page has been saying that
+# make 'will only evaluate a conditional as far as is necessary to determine',
+# but that was wrong.  The code in cond.c 1.1 from 1993-03-21 looks good since
+# it calls Var_Parse(condExpr, VAR_CMD, doEval,,), but the
+# definition of Var_Parse does not call the third parameter 'doEval', as would
+# be expected, but instead 'err', accompanied by the comment 'TRUE if
+# undefined variables are an error'.  This subtle difference between 'do not
+# evaluate at all' and 'allow undefined variables' led to the unexpected
+# evaluation.
 #
 # See also:
 #	var-eval-short.mk, for short-circuited variable modifiers

Index: src/usr.bin/make/unit-tests/var-eval-short.exp
diff -u src/usr.bin/make/unit-tests/var-eval-short.exp:1.13 src/usr.bin/make/unit-tests/var-eval-short.exp:1.14
--- src/usr.bin/make/unit-tests/var-eval-short.exp:1.13	Mon Apr  5 13:35:41 2021
+++ src/usr.bin/make/unit-tests/var-eval-short.exp	Tue Sep  7 20:41:58 2021
@@ -1,16 +1,16 @@
 make: "var-eval-short.mk" line 41: In the :@ modifier of "", the variable name "${FAIL}" must not contain a dollar.
 make: "var-eval-short.mk" line 41: Malformed conditional (0 && ${:Uword:@${FAIL}@expr@})
-make: "var-eval-short.mk" line 79: Invalid time value: ${FAIL}}
-make: "var-eval-short.mk" line 79: Malformed conditional (0 && ${:Uword:gmtime=${FAIL}})
-make: "var-eval-short.mk" line 93: Invalid time value: ${FAIL}}
-make: "var-eval-short.mk" line 93: Malformed conditional (0 && ${:Uword:localtime=${FAIL}})
+make: "var-eval-short.mk" line 81: Invalid time value: ${FAIL}}
+make: "var-eval-short.mk" line 81: Malformed conditional (0 && ${:Uword:gmtime=${FAIL}})
+make: "var-eval-short.mk" line 95: Invalid time value: ${FAIL}}
+make: "var-eval-short.mk" line 95: Malformed conditional (0 && ${:Uword:localtime=${FAIL}})
 CondParser_Eval: 0 && ${0:?${FAIL}then:${FAIL}else}
 Var_Parse: ${0:?${FAIL}then:${FAIL}else} (parse-only)
 Parsing modifier ${0:?...}
 Modifier part: "${FAIL}then"
 Modifier part: "${FAIL}else"
 Result of ${0:?${FAIL}then:${FAIL}else} is "" (parse-only, defined)
-ParseReadLine (158): 'DEFINED=	defined'
+ParseReadLine (160): 'DEFINED=	defined'
 Global: DEFINED = defined
 CondParser_Eval: 0 && ${DEFINED:L:?${FAIL}then:${FAIL}else}
 Var_Parse: ${DEFINED:L:?${FAIL}then:${FAIL}else} (parse-only)
@@ -20,7 +20,7 @@ Parsing modifier ${DEFINED:?...}
 Modifier part: "${FAIL}then"
 Modifier part: "${FAIL}else"
 Result of ${DEFINED:?${FAIL}then:${FAIL}else} is "defined" (parse-only, regular)
-ParseReadLine (161): '.MAKEFLAGS: -d0'
+ParseReadLine (163): '.MAKEFLAGS: -d0'
 ParseDependency(.MAKEFLAGS: -d0)
 Global: .MAKEFLAGS =  -r -k -d cpv -d
 Global: .MAKEFLAGS =  -r -k -d cpv -d 0

Index: src/usr.bin/make/unit-tests/var-eval-short.mk
diff -u src/usr.bin/make/unit-tests/var-eval-short.mk:1.6 src/usr.bin/make/unit-tests/var-eval-short.mk:1.7
--- src/usr.bin/make/unit-tests/var-eval-short.mk:1.6	Mon Sep  6 19:38:30 2021
+++ src/usr.bin/make/unit-tests/var-eval-short.mk	Tue Sep  7 20:41:58 2021
@@ -1,4 +1,4 @@
-# $NetBSD: var-eval-short.mk,v 1.6 2021/09/06 19:38:30 rillig Exp $
+# $NetBSD: 

CVS commit: src/usr.bin/make/unit-tests

2021-09-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Sep  7 20:41:58 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: cond-short.mk var-eval-short.exp
var-eval-short.mk

Log Message:
tests/make: expand on the history of unnecessary evaluation


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/cond-short.mk
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/var-eval-short.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/var-eval-short.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2021-09-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Sep  6 21:18:55 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-subst.mk

Log Message:
tests/make: test modifier ':S' with replacement '&'

Before 2020-08-30, OpenBSD make incorrectly copied the anchors '^' and
'$' to the replacement string.  Just guard against this possible bug.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-subst.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/unit-tests/varmod-subst.mk
diff -u src/usr.bin/make/unit-tests/varmod-subst.mk:1.8 src/usr.bin/make/unit-tests/varmod-subst.mk:1.9
--- src/usr.bin/make/unit-tests/varmod-subst.mk:1.8	Fri May 14 19:37:16 2021
+++ src/usr.bin/make/unit-tests/varmod-subst.mk	Mon Sep  6 21:18:55 2021
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-subst.mk,v 1.8 2021/05/14 19:37:16 rillig Exp $
+# $NetBSD: varmod-subst.mk,v 1.9 2021/09/06 21:18:55 rillig Exp $
 #
 # Tests for the :S,from,to, variable modifier.
 
@@ -86,6 +86,19 @@ WORDS=		sequences of letters
 .  error The '.' seems to be interpreted as a wildcard of some kind.
 .endif
 
+.if ${:Uvalue:S,^val,&,} != "value"
+.  error
+.endif
+.if ${:Uvalue:S,ue$,&,} != "value"
+.  error
+.endif
+.if ${:Uvalue:S,^val,&-&-&,} != "val-val-value"
+.  error
+.endif
+.if ${:Uvalue:S,ue$,&-&-&,} != "value-ue-ue"
+.  error
+.endif
+
 mod-subst:
 	@echo $@:
 	@echo :${:Ua b b c:S,a b,,:Q}:



CVS commit: src/usr.bin/make/unit-tests

2021-09-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Sep  6 21:18:55 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: varmod-subst.mk

Log Message:
tests/make: test modifier ':S' with replacement '&'

Before 2020-08-30, OpenBSD make incorrectly copied the anchors '^' and
'$' to the replacement string.  Just guard against this possible bug.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-subst.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-09-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Sep  6 19:38:30 UTC 2021

Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: var-eval-short.mk

Log Message:
make: fix typos in comments


To generate a diff of this commit:
cvs rdiff -u -r1.948 -r1.949 src/usr.bin/make/var.c
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/var-eval-short.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/var.c
diff -u src/usr.bin/make/var.c:1.948 src/usr.bin/make/var.c:1.949
--- src/usr.bin/make/var.c:1.948	Wed Aug 25 22:14:38 2021
+++ src/usr.bin/make/var.c	Mon Sep  6 19:38:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.948 2021/08/25 22:14:38 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.949 2021/09/06 19:38:30 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.948 2021/08/25 22:14:38 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.949 2021/09/06 19:38:30 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -1975,7 +1975,7 @@ VarStrftime(const char *fmt, bool zulu, 
  * After parsing, the modifier is evaluated.  The side effects from evaluating
  * nested variable expressions in the modifier text often already happen
  * during parsing though.  For most modifiers this doesn't matter since their
- * only noticeable effect is that the update the value of the expression.
+ * only noticeable effect is that they update the value of the expression.
  * Some modifiers such as ':sh' or '::=' have noticeable side effects though.
  *
  * Evaluating the modifier usually takes the current value of the variable

Index: src/usr.bin/make/unit-tests/var-eval-short.mk
diff -u src/usr.bin/make/unit-tests/var-eval-short.mk:1.5 src/usr.bin/make/unit-tests/var-eval-short.mk:1.6
--- src/usr.bin/make/unit-tests/var-eval-short.mk:1.5	Sun Apr  4 13:35:26 2021
+++ src/usr.bin/make/unit-tests/var-eval-short.mk	Mon Sep  6 19:38:30 2021
@@ -1,4 +1,4 @@
-# $NetBSD: var-eval-short.mk,v 1.5 2021/04/04 13:35:26 rillig Exp $
+# $NetBSD: var-eval-short.mk,v 1.6 2021/09/06 19:38:30 rillig Exp $
 #
 # Tests for each variable modifier to ensure that they only do the minimum
 # necessary computations.  If the result of the expression is not needed, they
@@ -44,13 +44,13 @@ FAIL=	${:!echo unexpected 1>&2!}
 .if 0 && ${:Uword:@var@${FAIL}@}
 .endif
 
-# Before var.c,v 1.877 from 2021-03-14, the modifier ':[...]' did not expand
+# Before var.c 1.877 from 2021-03-14, the modifier ':[...]' did not expand
 # the nested expression ${FAIL} and then tried to parse the unexpanded text,
 # which failed since '$' is not a valid range character.
 .if 0 && ${:Uword:[${FAIL}]}
 .endif
 
-# Before var.c,v 1.867 from 2021-03-14, the modifier ':_' defined the variable
+# Before var.c 1.867 from 2021-03-14, the modifier ':_' defined the variable
 # even though the whole expression should have only been parsed, not
 # evaluated.
 .if 0 && ${:Uword:_=VAR}
@@ -58,7 +58,7 @@ FAIL=	${:!echo unexpected 1>&2!}
 .  error
 .endif
 
-# Before var.c,v 1.856 from 2021-03-14, the modifier ':C' did not expand the
+# Before var.c 1.856 from 2021-03-14, the modifier ':C' did not expand the
 # nested expression ${FAIL} and then tried to compile the unexpanded text as a
 # regular expression, which failed both because of the '{FAIL}', which is not
 # a valid repetition, and because of the '', which are repeated



CVS commit: src/usr.bin/make

2021-09-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Sep  6 19:38:30 UTC 2021

Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: var-eval-short.mk

Log Message:
make: fix typos in comments


To generate a diff of this commit:
cvs rdiff -u -r1.948 -r1.949 src/usr.bin/make/var.c
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/var-eval-short.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-09-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Sep  2 07:02:08 UTC 2021

Modified Files:
src/usr.bin/make: for.c
src/usr.bin/make/unit-tests: directive-for-escape.exp
directive-for-escape.mk

Log Message:
make: rename for_var_len to ExprLen

The text ${VAR} is not a variable, it's a variable expression.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.146 -r1.147 src/usr.bin/make/for.c
cvs rdiff -u -r1.11 -r1.12 \
src/usr.bin/make/unit-tests/directive-for-escape.exp
cvs rdiff -u -r1.10 -r1.11 \
src/usr.bin/make/unit-tests/directive-for-escape.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/for.c
diff -u src/usr.bin/make/for.c:1.146 src/usr.bin/make/for.c:1.147
--- src/usr.bin/make/for.c:1.146	Thu Sep  2 06:29:56 2021
+++ src/usr.bin/make/for.c	Thu Sep  2 07:02:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: for.c,v 1.146 2021/09/02 06:29:56 rillig Exp $	*/
+/*	$NetBSD: for.c,v 1.147 2021/09/02 07:02:07 rillig Exp $	*/
 
 /*
  * Copyright (c) 1992, The Regents of the University of California.
@@ -58,7 +58,7 @@
 #include "make.h"
 
 /*	"@(#)for.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: for.c,v 1.146 2021/09/02 06:29:56 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.147 2021/09/02 07:02:07 rillig Exp $");
 
 
 /* One of the variables to the left of the "in" in a .for loop. */
@@ -278,33 +278,33 @@ For_Accum(const char *line)
 
 
 static size_t
-for_var_len(const char *var)
+ExprLen(const char *expr)
 {
-	char ch, var_start, var_end;
+	char ch, expr_open, expr_close;
 	int depth;
 	size_t len;
 
-	var_start = *var;
-	if (var_start == '\0')
+	expr_open = expr[0];
+	if (expr_open == '\0')
 		/* just escape the $ */
 		return 0;
 
-	if (var_start == '(')
-		var_end = ')';
-	else if (var_start == '{')
-		var_end = '}';
+	if (expr_open == '(')
+		expr_close = ')';
+	else if (expr_open == '{')
+		expr_close = '}';
 	else
 		return 1;	/* Single char variable */
 
 	depth = 1;
-	for (len = 1; (ch = var[len++]) != '\0';) {
-		if (ch == var_start)
+	for (len = 1; (ch = expr[len++]) != '\0';) {
+		if (ch == expr_open)
 			depth++;
-		else if (ch == var_end && --depth == 0)
+		else if (ch == expr_close && --depth == 0)
 			return len;
 	}
 
-	/* Variable end not found, escape the $ */
+	/* Expression end not found, escape the $ */
 	return 0;
 }
 
@@ -345,8 +345,12 @@ Buf_AddEscaped(Buffer *cmds, const char 
 	 * :U processing, see ApplyModifier_Defined. */
 	while ((ch = *item++) != '\0') {
 		if (ch == '$') {
-			size_t len = for_var_len(item);
+			size_t len = ExprLen(item);
 			if (len != 0) {
+/*
+ * XXX: Should a '\' be added here?
+ * See directive-for-escape.mk, ExprLen.
+ */
 Buf_AddBytes(cmds, item - 1, len + 1);
 item += len;
 continue;
@@ -427,8 +431,10 @@ ForLoop_SubstVarShort(ForLoop *f, const 
 	return;
 
 found:
+	Buf_AddBytesBetween(>curBody, *inout_mark, p);
+	*inout_mark = p + 1;
+
 	/* Replace $ with ${:U} */
-	Buf_AddBytesBetween(>curBody, *inout_mark, p), *inout_mark = p + 1;
 	Buf_AddStr(>curBody, "{:U");
 	Buf_AddEscaped(>curBody, f->items.words[f->sub_next + i], '}');
 	Buf_AddByte(>curBody, '}');
@@ -444,8 +450,8 @@ found:
  * defined, see unit-tests/varname-empty.mk for more details.
  *
  * The detection of substitutions of the loop control variables is naive.
- * Many of the modifiers use '\' to escape '$' (not '$'), so it is possible
- * to contrive a makefile where an unwanted substitution happens.
+ * Many of the modifiers use '\$' instead of '$$' to escape '$', so it is
+ * possible to contrive a makefile where an unwanted substitution happens.
  */
 static void
 ForLoop_SubstBody(ForLoop *f)

Index: src/usr.bin/make/unit-tests/directive-for-escape.exp
diff -u src/usr.bin/make/unit-tests/directive-for-escape.exp:1.11 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.12
--- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.11	Fri Jun 25 16:10:07 2021
+++ src/usr.bin/make/unit-tests/directive-for-escape.exp	Thu Sep  2 07:02:08 2021
@@ -11,45 +11,45 @@ make: "directive-for-escape.mk" line 29:
 For: end for 1
 For: loop body:
 .  info ${:U\$}
-make: "directive-for-escape.mk" line 41: $
+make: "directive-for-escape.mk" line 43: $
 For: loop body:
 .  info ${:U${V}}
-make: "directive-for-escape.mk" line 41: value
+make: "directive-for-escape.mk" line 43: value
 For: loop body:
 .  info ${:U${V:=-with-modifier}}
-make: "directive-for-escape.mk" line 41: value-with-modifier
+make: "directive-for-escape.mk" line 43: value-with-modifier
 For: loop body:
 .  info ${:U$(V)}
-make: "directive-for-escape.mk" line 41: value
+make: "directive-for-escape.mk" line 43: value
 For: loop body:
 .  info ${:U$(V:=-with-modifier)}
-make: "directive-for-escape.mk" line 41: value-with-modifier
+make: "directive-for-escape.mk" line 43: value-with-modifier
 For: end for 1
 For: loop body:
 .  

CVS commit: src/usr.bin/make

2021-09-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Sep  2 07:02:08 UTC 2021

Modified Files:
src/usr.bin/make: for.c
src/usr.bin/make/unit-tests: directive-for-escape.exp
directive-for-escape.mk

Log Message:
make: rename for_var_len to ExprLen

The text ${VAR} is not a variable, it's a variable expression.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.146 -r1.147 src/usr.bin/make/for.c
cvs rdiff -u -r1.11 -r1.12 \
src/usr.bin/make/unit-tests/directive-for-escape.exp
cvs rdiff -u -r1.10 -r1.11 \
src/usr.bin/make/unit-tests/directive-for-escape.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-09-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Sep  2 06:29:56 UTC 2021

Modified Files:
src/usr.bin/make: for.c

Log Message:
make: inline strchr call, make ForLoop_SubstBody clearer

In ForLoop_SubstBody, GCC already merged the common subexpressions p[1]
and p[-1], but that was difficult to see for humans as well.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.145 -r1.146 src/usr.bin/make/for.c

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/for.c
diff -u src/usr.bin/make/for.c:1.145 src/usr.bin/make/for.c:1.146
--- src/usr.bin/make/for.c:1.145	Wed Sep  1 23:07:41 2021
+++ src/usr.bin/make/for.c	Thu Sep  2 06:29:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: for.c,v 1.145 2021/09/01 23:07:41 rillig Exp $	*/
+/*	$NetBSD: for.c,v 1.146 2021/09/02 06:29:56 rillig Exp $	*/
 
 /*
  * Copyright (c) 1992, The Regents of the University of California.
@@ -58,7 +58,7 @@
 #include "make.h"
 
 /*	"@(#)for.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: for.c,v 1.145 2021/09/01 23:07:41 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.146 2021/09/02 06:29:56 rillig Exp $");
 
 
 /* One of the variables to the left of the "in" in a .for loop. */
@@ -363,7 +363,7 @@ Buf_AddEscaped(Buffer *cmds, const char 
 }
 
 /*
- * While expanding the body of a .for loop, replace the variable name of an
+ * When expanding the body of a .for loop, replace the variable name of an
  * expression like ${i} or ${i:...} or $(i) or $(i:...) with ":Uvalue".
  */
 static void
@@ -404,7 +404,7 @@ ForLoop_SubstVarLong(ForLoop *f, const c
 }
 
 /*
- * While expanding the body of a .for loop, replace single-character
+ * When expanding the body of a .for loop, replace single-character
  * variable expressions like $i with their ${:U...} expansion.
  */
 static void
@@ -415,7 +415,7 @@ ForLoop_SubstVarShort(ForLoop *f, const 
 	size_t i;
 
 	/* Skip $$ and stupid ones. */
-	if (strchr("}):$", ch) != NULL)
+	if (ch == '}' || ch == ')' || ch == ':' || ch == '$')
 		return;
 
 	vars = Vector_Get(>vars, 0);
@@ -451,7 +451,7 @@ static void
 ForLoop_SubstBody(ForLoop *f)
 {
 	const char *p, *bodyEnd;
-	const char *mark;	/* where the last replacement left off */
+	const char *mark;	/* where the last substitution left off */
 
 	Buf_Empty(>curBody);
 
@@ -459,9 +459,9 @@ ForLoop_SubstBody(ForLoop *f)
 	bodyEnd = f->body.data + f->body.len;
 	for (p = mark; (p = strchr(p, '$')) != NULL;) {
 		if (p[1] == '{' || p[1] == '(') {
+			char endc = p[1] == '{' ? '}' : ')';
 			p += 2;
-			ForLoop_SubstVarLong(f, , bodyEnd,
-			p[-1] == '{' ? '}' : ')', );
+			ForLoop_SubstVarLong(f, , bodyEnd, endc, );
 		} else if (p[1] != '\0') {
 			ForLoop_SubstVarShort(f, p + 1, );
 			p += 2;



CVS commit: src/usr.bin/make

2021-09-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Sep  2 06:29:56 UTC 2021

Modified Files:
src/usr.bin/make: for.c

Log Message:
make: inline strchr call, make ForLoop_SubstBody clearer

In ForLoop_SubstBody, GCC already merged the common subexpressions p[1]
and p[-1], but that was difficult to see for humans as well.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.145 -r1.146 src/usr.bin/make/for.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-09-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Sep  1 23:07:41 UTC 2021

Modified Files:
src/usr.bin/make: for.c

Log Message:
make: remove optimization for single-letter .for variables

Most .for loops have a single iteration variable.  For these loops, the
difference between the optimized and the unoptimized versions of the
code is negligible.

Remove the optimization since the comment for explaining it was almost
larger than the code itself.


To generate a diff of this commit:
cvs rdiff -u -r1.144 -r1.145 src/usr.bin/make/for.c

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/for.c
diff -u src/usr.bin/make/for.c:1.144 src/usr.bin/make/for.c:1.145
--- src/usr.bin/make/for.c:1.144	Fri Jun 25 16:10:07 2021
+++ src/usr.bin/make/for.c	Wed Sep  1 23:07:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: for.c,v 1.144 2021/06/25 16:10:07 rillig Exp $	*/
+/*	$NetBSD: for.c,v 1.145 2021/09/01 23:07:41 rillig Exp $	*/
 
 /*
  * Copyright (c) 1992, The Regents of the University of California.
@@ -58,7 +58,7 @@
 #include "make.h"
 
 /*	"@(#)for.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: for.c,v 1.144 2021/06/25 16:10:07 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.145 2021/09/01 23:07:41 rillig Exp $");
 
 
 /* One of the variables to the left of the "in" in a .for loop. */
@@ -72,10 +72,6 @@ typedef struct ForLoop {
 	Vector /* of ForVar */ vars; /* Iteration variables */
 	Words items;		/* Substitution items */
 	Buffer curBody;		/* Expanded body of the current iteration */
-	/* Is any of the names 1 character long? If so, when the variable
-	 * values are substituted, the parser must handle $V expressions as
-	 * well, not only ${V} and $(V). */
-	bool short_var;
 	unsigned int sub_next;	/* Where to continue iterating */
 } ForLoop;
 
@@ -94,7 +90,6 @@ ForLoop_New(void)
 	f->items.words = NULL;
 	f->items.freeIt = NULL;
 	Buf_Init(>curBody);
-	f->short_var = false;
 	f->sub_next = 0;
 
 	return f;
@@ -150,8 +145,6 @@ ForLoop_ParseVarnames(ForLoop *f, const 
 			p += 2;
 			break;
 		}
-		if (len == 1)
-			f->short_var = true;
 
 		ForLoop_AddVar(f, p, len);
 		p += len;
@@ -422,7 +415,7 @@ ForLoop_SubstVarShort(ForLoop *f, const 
 	size_t i;
 
 	/* Skip $$ and stupid ones. */
-	if (!f->short_var || strchr("}):$", ch) != NULL)
+	if (strchr("}):$", ch) != NULL)
 		return;
 
 	vars = Vector_Get(>vars, 0);



CVS commit: src/usr.bin/make

2021-09-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Sep  1 23:07:41 UTC 2021

Modified Files:
src/usr.bin/make: for.c

Log Message:
make: remove optimization for single-letter .for variables

Most .for loops have a single iteration variable.  For these loops, the
difference between the optimized and the unoptimized versions of the
code is negligible.

Remove the optimization since the comment for explaining it was almost
larger than the code itself.


To generate a diff of this commit:
cvs rdiff -u -r1.144 -r1.145 src/usr.bin/make/for.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2021-09-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Sep  1 22:44:50 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: directive-for-if.exp

Log Message:
tests/make: fix test directive-for-if

The additional lines 'VAR1' and 'VAR3' were supposed to be there from
the beginning.  I somehow managed to commit an inconsistent state of the
.mk and the .exp file.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/directive-for-if.exp

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/unit-tests/directive-for-if.exp
diff -u src/usr.bin/make/unit-tests/directive-for-if.exp:1.1 src/usr.bin/make/unit-tests/directive-for-if.exp:1.2
--- src/usr.bin/make/unit-tests/directive-for-if.exp:1.1	Mon Aug 30 17:08:13 2021
+++ src/usr.bin/make/unit-tests/directive-for-if.exp	Wed Sep  1 22:44:50 2021
@@ -1,6 +1,8 @@
 make: "directive-for-if.mk" line 48: if-less endif
 make: "directive-for-if.mk" line 48: if-less endif
 make: "directive-for-if.mk" line 48: if-less endif
+VAR1
+VAR3
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1



CVS commit: src/usr.bin/make/unit-tests

2021-09-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Sep  1 22:44:50 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: directive-for-if.exp

Log Message:
tests/make: fix test directive-for-if

The additional lines 'VAR1' and 'VAR3' were supposed to be there from
the beginning.  I somehow managed to commit an inconsistent state of the
.mk and the .exp file.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/directive-for-if.exp

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-08-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Aug 25 22:14:38 UTC 2021

Modified Files:
src/usr.bin/make: arch.c var.c

Log Message:
make: fix lint warnings on ilp32 platforms

The warnings in arch.c were about conversions from int to long.

The warnings in var.c were about conversions from long long to
ptrdiff_t.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.202 -r1.203 src/usr.bin/make/arch.c
cvs rdiff -u -r1.947 -r1.948 src/usr.bin/make/var.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-08-25 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Aug 25 22:14:38 UTC 2021

Modified Files:
src/usr.bin/make: arch.c var.c

Log Message:
make: fix lint warnings on ilp32 platforms

The warnings in arch.c were about conversions from int to long.

The warnings in var.c were about conversions from long long to
ptrdiff_t.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.202 -r1.203 src/usr.bin/make/arch.c
cvs rdiff -u -r1.947 -r1.948 src/usr.bin/make/var.c

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/arch.c
diff -u src/usr.bin/make/arch.c:1.202 src/usr.bin/make/arch.c:1.203
--- src/usr.bin/make/arch.c:1.202	Sat Aug 14 14:43:30 2021
+++ src/usr.bin/make/arch.c	Wed Aug 25 22:14:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.202 2021/08/14 14:43:30 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.203 2021/08/25 22:14:38 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
 #include "config.h"
 
 /*	"@(#)arch.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: arch.c,v 1.202 2021/08/14 14:43:30 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.203 2021/08/25 22:14:38 rillig Exp $");
 
 typedef struct List ArchList;
 typedef struct ListNode ArchListNode;
@@ -552,14 +552,14 @@ ArchStatMember(const char *archive, cons
 		if (strncmp(memName, AR_EFMT1, sizeof AR_EFMT1 - 1) == 0 &&
 		ch_isdigit(memName[sizeof AR_EFMT1 - 1])) {
 
-			int elen = atoi(memName + sizeof AR_EFMT1 - 1);
+			size_t elen = atoi(memName + sizeof AR_EFMT1 - 1);
 
-			if ((unsigned int)elen > MAXPATHLEN)
+			if (elen > MAXPATHLEN)
 goto badarch;
-			if (fread(memName, (size_t)elen, 1, arch) != 1)
+			if (fread(memName, elen, 1, arch) != 1)
 goto badarch;
 			memName[elen] = '\0';
-			if (fseek(arch, -elen, SEEK_CUR) != 0)
+			if (fseek(arch, -(long)elen, SEEK_CUR) != 0)
 goto badarch;
 			if (DEBUG(ARCH) || DEBUG(MAKE))
 debug_printf(
@@ -791,14 +791,15 @@ ArchFindMember(const char *archive, cons
 		if (strncmp(out_arh->ar_name, AR_EFMT1, sizeof AR_EFMT1 - 1) ==
 		0 &&
 		(ch_isdigit(out_arh->ar_name[sizeof AR_EFMT1 - 1]))) {
-			int elen = atoi(_arh->ar_name[sizeof AR_EFMT1 - 1]);
+			size_t elen = atoi(
+			_arh->ar_name[sizeof AR_EFMT1 - 1]);
 			char ename[MAXPATHLEN + 1];
 
-			if ((unsigned int)elen > MAXPATHLEN) {
+			if (elen > MAXPATHLEN) {
 fclose(arch);
 return NULL;
 			}
-			if (fread(ename, (size_t)elen, 1, arch) != 1) {
+			if (fread(ename, elen, 1, arch) != 1) {
 fclose(arch);
 return NULL;
 			}
@@ -811,14 +812,14 @@ ArchFindMember(const char *archive, cons
 			if (strncmp(ename, member, len) == 0) {
 /* Found as extended name */
 if (fseek(arch,
-	  -(long)sizeof(struct ar_hdr) - elen,
-	  SEEK_CUR) != 0) {
+-(long)(sizeof(struct ar_hdr) - elen),
+SEEK_CUR) != 0) {
 	fclose(arch);
 	return NULL;
 }
 return arch;
 			}
-			if (fseek(arch, -elen, SEEK_CUR) != 0) {
+			if (fseek(arch, -(long)elen, SEEK_CUR) != 0) {
 fclose(arch);
 return NULL;
 			}
@@ -834,7 +835,7 @@ ArchFindMember(const char *archive, cons
 		 */
 		out_arh->ar_size[sizeof out_arh->ar_size - 1] = '\0';
 		size = (int)strtol(out_arh->ar_size, NULL, 10);
-		if (fseek(arch, (size + 1) & ~1, SEEK_CUR) != 0) {
+		if (fseek(arch, (size + 1) & ~1L, SEEK_CUR) != 0) {
 			fclose(arch);
 			return NULL;
 		}

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.947 src/usr.bin/make/var.c:1.948
--- src/usr.bin/make/var.c:1.947	Sat Aug 14 13:11:33 2021
+++ src/usr.bin/make/var.c	Wed Aug 25 22:14:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.947 2021/08/14 13:11:33 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.948 2021/08/25 22:14:38 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.947 2021/08/14 13:11:33 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.948 2021/08/25 22:14:38 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -1605,7 +1605,8 @@ RegexReplace(const char *replace, SepBuf
 
 		if (*rp == '&') {
 			SepBuf_AddBytesBetween(buf,
-			wp + m[0].rm_so, wp + m[0].rm_eo);
+			wp + (size_t)m[0].rm_so,
+			wp + (size_t)m[0].rm_eo);
 			continue;
 		}
 
@@ -1626,7 +1627,8 @@ RegexReplace(const char *replace, SepBuf
 			}
 		} else {
 			SepBuf_AddBytesBetween(buf,
-			wp + m[n].rm_so, wp + m[n].rm_eo);
+			wp + (size_t)m[n].rm_so,
+			wp + (size_t)m[n].rm_eo);
 		}
 	}
 }
@@ -1673,7 +1675,7 @@ ok:
 
 	RegexReplace(args->replace, buf, wp, m, args->nsub);
 
-	wp += m[0].rm_eo;
+	wp += (size_t)m[0].rm_eo;
 	if (args->pflags.subGlobal) {
 		flags |= REG_NOTBOL;
 		if (m[0].rm_so == 0 && m[0].rm_eo == 0) {



CVS commit: src/usr.bin/make

2021-08-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Aug 19 15:50:30 UTC 2021

Modified Files:
src/usr.bin/make: meta.c

Log Message:
make: fix lint warning about strrchr discarding 'const'

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 src/usr.bin/make/meta.c

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/meta.c
diff -u src/usr.bin/make/meta.c:1.182 src/usr.bin/make/meta.c:1.183
--- src/usr.bin/make/meta.c:1.182	Sat Aug 14 13:04:00 2021
+++ src/usr.bin/make/meta.c	Thu Aug 19 15:50:30 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: meta.c,v 1.182 2021/08/14 13:04:00 rillig Exp $ */
+/*  $NetBSD: meta.c,v 1.183 2021/08/19 15:50:30 rillig Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -244,8 +244,8 @@ meta_name(char *mname, size_t mnamelen,
 	  const char *cwd)
 {
 char buf[MAXPATHLEN];
-char *rp;
-char *cp;
+char *rp, *cp;
+const char *tname_base;
 char *tp;
 char *dtp;
 size_t ldname;
@@ -257,13 +257,13 @@ meta_name(char *mname, size_t mnamelen,
  * So we use realpath() just to get the dirname, and leave the
  * basename as given to us.
  */
-if ((cp = strrchr(tname, '/')) != NULL) {
+if ((tname_base = strrchr(tname, '/')) != NULL) {
 	if (cached_realpath(tname, buf) != NULL) {
 	if ((rp = strrchr(buf, '/')) != NULL) {
 		rp++;
-		cp++;
-		if (strcmp(cp, rp) != 0)
-		strlcpy(rp, cp, sizeof buf - (size_t)(rp - buf));
+		tname_base++;
+		if (strcmp(tname_base, rp) != 0)
+		strlcpy(rp, tname_base, sizeof buf - (size_t)(rp - buf));
 	}
 	tname = buf;
 	} else {
@@ -552,9 +552,9 @@ meta_create(BuildMon *pbm, GNode *gn)
 }
 
 static bool
-boolValue(char *s)
+boolValue(const char *s)
 {
-switch(*s) {
+switch (*s) {
 case '0':
 case 'N':
 case 'n':
@@ -589,7 +589,7 @@ void
 meta_mode_init(const char *make_mode)
 {
 static bool once = false;
-char *cp;
+const char *cp;
 FStr value;
 
 useMeta = true;



CVS commit: src/usr.bin/make

2021-08-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Aug 19 15:50:30 UTC 2021

Modified Files:
src/usr.bin/make: meta.c

Log Message:
make: fix lint warning about strrchr discarding 'const'

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 src/usr.bin/make/meta.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/usr.bin/make

2021-01-29 Thread Roland Illig

On 27.01.2021 20:54, Reinoud Zandijk wrote:

Hi,

On Tue, Jan 26, 2021 at 11:44:56PM +, Roland Illig wrote:

Module Name:src
Committed By:   rillig
Date:   Tue Jan 26 23:44:56 UTC 2021

Modified Files:
src/usr.bin/make: parse.c
src/usr.bin/make/unit-tests: include-main.exp include-subsub.mk

Log Message:
make(1): in -dp mode, print stack trace with each diagnostic


Maybe related but could you make printing of the 1st failing error message
easier to find in a parallel build? Say recording the command and output of
the offending command and print it at the end?


Sounds possible.  I'll look into it but cannot promise anything right
now.  Ideally this diagnostic information would be passed up to the
top-level make process, which would then print it at the very end.

Roland


Re: CVS commit: src/usr.bin/make

2021-01-27 Thread Reinoud Zandijk
Hi,

On Tue, Jan 26, 2021 at 11:44:56PM +, Roland Illig wrote:
> Module Name:  src
> Committed By: rillig
> Date: Tue Jan 26 23:44:56 UTC 2021
> 
> Modified Files:
>   src/usr.bin/make: parse.c
>   src/usr.bin/make/unit-tests: include-main.exp include-subsub.mk
> 
> Log Message:
> make(1): in -dp mode, print stack trace with each diagnostic

Maybe related but could you make printing of the 1st failing error message
easier to find in a parallel build? Say recording the command and output of
the offending command and print it at the end ?

Reinoud



Re: CVS commit: src/usr.bin/make

2021-01-26 Thread Martin Husemann
On Tue, Jan 26, 2021 at 11:39:52PM +0100, Roland Illig wrote:
> The code of usr.bin/make gets distributed to a wider audience by Simon's
> bmake distribution (http://www.crufty.net/help/sjg/bmake.html), that's
> where the requirement of supporting C89 compilers comes from.  At the
> time I committed this fix, Simon had managed to dig out an old Solaris 9
> installation with GCC, and these few changes were the only ones needed
> to let bmake run on that platform.  That sounded easy enough to me.

Also note that we need bmake during bootstrap of pkgsrc, and besides
finding a working compiler it is one of the early things you need to
make work on an ancient platform if you try to bring it to new use (I
have been there with Solaris 2.6 at one point, but gave up for other
reasons - and of course the machine in question now runs NetBSD (again)
[the Solaris adventure was a temporary thing anyway and as pkgsrc did
not help as a "plug and play" way to get a usable dev/debug environment
it was not worth pushing]).

But I must admit that the *commit log* of that change sounded way more scary
than the actual change is:

replace %zu with %u in printf calls

would be plain wrong and of course break (either at runtime or if lucky
at compile time) many, many platforms.

But

-   (void)fprintf(f, "\"%s\" line %zu: ", fname, lineno);
+   (void)fprintf(f, "\"%s\" line %u: ", fname, (unsigned)lineno);

is ok for portable code and "lineno" referencing (I guess) a makefile.
It could have been (long unsigned) and "%lu", but maybe portability to
systems where that would make a difference is a bit far stretched.

Martin


Re: CVS commit: src/usr.bin/make

2021-01-26 Thread Roland Illig

On 26.01.2021 21:04, Christos Zoulas wrote:

Yes, and I did not push for it for the exact reasons stated below:
There was only a handful of cases and those can be handled with casts or a 
macro for now.

I am questioning though the utility of maintaining compatibility with platforms 
that
do not support C99 20 years later, vs. using %u and casting or using a 
formatting macro.


The support for ancient platforms is not only with regards to "%zu" vs.
"%u", in util.c there is even support for platforms that lack getenv().
 Apparently nobody cared enough to remove these bits, even though
getenv is guaranteed to exist since C89 already.

The code of usr.bin/make gets distributed to a wider audience by Simon's
bmake distribution (http://www.crufty.net/help/sjg/bmake.html), that's
where the requirement of supporting C89 compilers comes from.  At the
time I committed this fix, Simon had managed to dig out an old Solaris 9
installation with GCC, and these few changes were the only ones needed
to let bmake run on that platform.  That sounded easy enough to me.

Roland


Re: CVS commit: src/usr.bin/make

2021-01-26 Thread Christos Zoulas
Yes, and I did not push for it for the exact reasons stated below:
There was only a handful of cases and those can be handled with casts or a 
macro for now.

I am questioning though the utility of maintaining compatibility with platforms 
that
do not support C99 20 years later, vs. using %u and casting or using a 
formatting macro.

christos

> On Jan 26, 2021, at 2:00 PM, Roland Illig  wrote:
> 
> On 26.01.2021 11:19, Rin Okuyama wrote:
>> Ping?
>> 
>> I don't think this is correct fix either.
>> Can you please revert this commit?
> 
> Sorry, I didn't get the first mail from Christos back in December,
> that's why I didn't take any action.
> 
> Why shouldn't the fix I did be correct?  I carefully checked the few
> places where I added the casts, and none of the numbers that are
> involved will ever be more than a billion.
> 
> 1.  The number of variables in a .for loop
> 
> 2.  The number of items in a .for loop
> 
> 3.  A single line of a text file in meta mode.  (Only in debug mode.)
> 
> 4.  The number of lines in a single makefile.
> 
> 5.  The capturing subexpression in a :C variable modifier, which only
> ever ranges from 0 to 9.
> 
> 6.  The number of words into which a variable value is split. (Only in
> debug mode.)
> 
> Given these, why should a simple %u not be appropriate?  I don't want to
> clutter the code with another preprocessor macro, therefore I'd like to
> keep the code the way it is right now.
> 
> I also don't see why this could ever have the slightest chance of
> "breaking everyone else".
> 
> For reference and easy viewing, here is the corresponding commit on
> GitHub:
> https://github.com/NetBSD/src/commit/ff11c7d3497a40c90ec70101ad72612e2f0884b2
> 
> Roland
> 
>> On 2020/12/15 7:57, Christos Zoulas wrote:
>>> In article <20201213212746.3cfc3f...@cvs.netbsd.org>,
>>> Roland Illig  wrote:
 -=-=-=-=-=-
 
 Module Name:src
 Committed By:rillig
 Date:Sun Dec 13 21:27:46 UTC 2020
 
 Modified Files:
 src/usr.bin/make: for.c meta.c parse.c var.c
 
 Log Message:
 make(1): replace %zu with %u in printf calls
 
 This is needed to compile bmake with GCC 2.8.1 on SunOS 5.9.
 
 To support ancient systems like this, the whole code of usr.bin/make is
 supposed to use only ISO C90 features, except for filemon, which is not
 used on these systems.
>>> 
>>> Please revert! This breaks everyone else. %zu is the format to
>>> print size_t.  Last I checked SunOS 5.9 has been dead since 2014
>>> and whoever is still using it might as well install a new compiler,
>>> or tie the box at the end of a long chain so it can find its true
>>> calling. If you really want to support it instead define MAKE_FMT_SIZE_T
>>> and conditionalize it properly for "ancient OS", windows, cygwin,
>>> mingwin, and regular folks (this does not even handle "ancient os"):
>>> 
>>>  https://github.com/file/file/blob/master/src/file.h#L55
>>> 
>>> I am still against it though...
>>> 
>>> christos
>>> 



signature.asc
Description: Message signed with OpenPGP


Re: CVS commit: src/usr.bin/make

2021-01-26 Thread Roland Illig

On 26.01.2021 11:19, Rin Okuyama wrote:

Ping?

I don't think this is correct fix either.
Can you please revert this commit?


Sorry, I didn't get the first mail from Christos back in December,
that's why I didn't take any action.

Why shouldn't the fix I did be correct?  I carefully checked the few
places where I added the casts, and none of the numbers that are
involved will ever be more than a billion.

1.  The number of variables in a .for loop

2.  The number of items in a .for loop

3.  A single line of a text file in meta mode.  (Only in debug mode.)

4.  The number of lines in a single makefile.

5.  The capturing subexpression in a :C variable modifier, which only
ever ranges from 0 to 9.

6.  The number of words into which a variable value is split. (Only in
debug mode.)

Given these, why should a simple %u not be appropriate?  I don't want to
clutter the code with another preprocessor macro, therefore I'd like to
keep the code the way it is right now.

I also don't see why this could ever have the slightest chance of
"breaking everyone else".

For reference and easy viewing, here is the corresponding commit on
GitHub:
https://github.com/NetBSD/src/commit/ff11c7d3497a40c90ec70101ad72612e2f0884b2

Roland


On 2020/12/15 7:57, Christos Zoulas wrote:

In article <20201213212746.3cfc3f...@cvs.netbsd.org>,
Roland Illig  wrote:

-=-=-=-=-=-

Module Name:    src
Committed By:    rillig
Date:    Sun Dec 13 21:27:46 UTC 2020

Modified Files:
src/usr.bin/make: for.c meta.c parse.c var.c

Log Message:
make(1): replace %zu with %u in printf calls

This is needed to compile bmake with GCC 2.8.1 on SunOS 5.9.

To support ancient systems like this, the whole code of usr.bin/make is
supposed to use only ISO C90 features, except for filemon, which is not
used on these systems.


Please revert! This breaks everyone else. %zu is the format to
print size_t.  Last I checked SunOS 5.9 has been dead since 2014
and whoever is still using it might as well install a new compiler,
or tie the box at the end of a long chain so it can find its true
calling. If you really want to support it instead define MAKE_FMT_SIZE_T
and conditionalize it properly for "ancient OS", windows, cygwin,
mingwin, and regular folks (this does not even handle "ancient os"):

 https://github.com/file/file/blob/master/src/file.h#L55

I am still against it though...

christos



Re: CVS commit: src/usr.bin/make

2021-01-26 Thread Rin Okuyama

Ping?

I don't think this is correct fix either.
Can you please revert this commit?

Thanks,
rin

On 2020/12/15 7:57, Christos Zoulas wrote:

In article <20201213212746.3cfc3f...@cvs.netbsd.org>,
Roland Illig  wrote:

-=-=-=-=-=-

Module Name:src
Committed By:   rillig
Date:   Sun Dec 13 21:27:46 UTC 2020

Modified Files:
src/usr.bin/make: for.c meta.c parse.c var.c

Log Message:
make(1): replace %zu with %u in printf calls

This is needed to compile bmake with GCC 2.8.1 on SunOS 5.9.

To support ancient systems like this, the whole code of usr.bin/make is
supposed to use only ISO C90 features, except for filemon, which is not
used on these systems.


Please revert! This breaks everyone else. %zu is the format to
print size_t.  Last I checked SunOS 5.9 has been dead since 2014
and whoever is still using it might as well install a new compiler,
or tie the box at the end of a long chain so it can find its true
calling. If you really want to support it instead define MAKE_FMT_SIZE_T
and conditionalize it properly for "ancient OS", windows, cygwin,
mingwin, and regular folks (this does not even handle "ancient os"):

 https://github.com/file/file/blob/master/src/file.h#L55

I am still against it though...

christos



re: CVS commit: src/usr.bin/make

2020-12-22 Thread matthew green
"Roland Illig" writes:
> Module Name:  src
> Committed By: rillig
> Date: Tue Dec 22 08:10:39 UTC 2020
>
> Modified Files:
>   src/usr.bin/make: parse.c

i'm not sure which change did it (but before this one for sure),
but my builds crash early now (still trying to bootstrap nbmake):

cc -o nbmake *.o
assertion "*line_end == '\n'" failed: file "/usr/src/usr.bin/make/parse.c", 
line 2844, function "ParseGetLine"
[1]   Abort trap (core dumped) "${make}" -m ${TOP}/share/mk -s -B -f- _x_ <<...

ERROR: bomb_getmakevar MAKECONF: /tmp/nbbuild14989/nbmake failed

please fix :-)


.mrg.


Re: CVS commit: src/usr.bin/make

2020-12-14 Thread Christos Zoulas
In article <20201213212746.3cfc3f...@cvs.netbsd.org>,
Roland Illig  wrote:
>-=-=-=-=-=-
>
>Module Name:   src
>Committed By:  rillig
>Date:  Sun Dec 13 21:27:46 UTC 2020
>
>Modified Files:
>   src/usr.bin/make: for.c meta.c parse.c var.c
>
>Log Message:
>make(1): replace %zu with %u in printf calls
>
>This is needed to compile bmake with GCC 2.8.1 on SunOS 5.9.
>
>To support ancient systems like this, the whole code of usr.bin/make is
>supposed to use only ISO C90 features, except for filemon, which is not
>used on these systems.

Please revert! This breaks everyone else. %zu is the format to
print size_t.  Last I checked SunOS 5.9 has been dead since 2014
and whoever is still using it might as well install a new compiler,
or tie the box at the end of a long chain so it can find its true
calling. If you really want to support it instead define MAKE_FMT_SIZE_T
and conditionalize it properly for "ancient OS", windows, cygwin,
mingwin, and regular folks (this does not even handle "ancient os"):

https://github.com/file/file/blob/master/src/file.h#L55

I am still against it though...

christos



Re: CVS commit: src/usr.bin/make

2020-10-26 Thread David Holland
On Sun, Oct 25, 2020 at 05:37:36PM +, Simon J. Gerraty wrote:
 > Modified Files:
 >  src/usr.bin/make: main.c
 >  src/usr.bin/make/unit-tests: varmod-match-escape.exp
 > 
 > Log Message:
 > Skip reading .MAKE.DEPENDFILE if set to
 > "/dev/null" or anything starting with "no".
 > 
 > Ref: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=223564

I object to this, particularly the "no" part but also making /dev/null
magic.

This is an unnecessary workaround for a bug in freebsd's build
system.

If there's going to be a change, it should be removing the :T from the
generated reference; there is no reason to remove the directory name
from a user-supplied .MAKE.DEPENDFILE, and the default doesn't have a
directory part. That would also remove the problem freebsd's seeing,
and would be, y'know, actually correct.

(also the application of :T is undocumented as well as wrong)


kept for reference:

 > To generate a diff of this commit:
 > cvs rdiff -u -r1.388 -r1.389 src/usr.bin/make/main.c
 > cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varmod-match-escape.exp

-- 
David A. Holland
dholl...@netbsd.org


Re: CVS commit: src/usr.bin/make

2020-09-24 Thread Roland Illig

On 24.09.2020 18:02, Jonathan A. Kollasch wrote:

cvs rdiff -u -r1.65 -r1.66 src/usr.bin/make/lst.h


breaks build on Debian 9:

In file included from /local/jakllsch/netbsd/src/usr.bin/make/make.h:158:0,
  from /local/jakllsch/netbsd/src/usr.bin/make/arch.c:130:
/local/jakllsch/netbsd/src/usr.bin/make/lst.h:92:5: error: unknown type name 
'uint8_t'
  uint8_t priv_useCount; /* Count of functions using the node.


Thank you.  Fixed in lst.h 1.67 from a minute ago.


Re: CVS commit: src/usr.bin/make

2020-09-24 Thread Jonathan A. Kollasch
> cvs rdiff -u -r1.65 -r1.66 src/usr.bin/make/lst.h

breaks build on Debian 9:

In file included from /local/jakllsch/netbsd/src/usr.bin/make/make.h:158:0,
 from /local/jakllsch/netbsd/src/usr.bin/make/arch.c:130:
/local/jakllsch/netbsd/src/usr.bin/make/lst.h:92:5: error: unknown type name 
'uint8_t'
 uint8_t priv_useCount; /* Count of functions using the node.
 ^~~


Re: CVS commit: src/usr.bin/make

2020-09-14 Thread Roland Illig

On 14.09.2020 21:05, Robert Elz wrote:

 Date:Mon, 14 Sep 2020 16:16:52 +
 From:"Roland Illig" 
 Message-ID:  <20200914161652.d4eb5f...@cvs.netbsd.org>

   | make(1): inline LPAREN in parse.c
   |
   | It's shorter and more readable, and the other characters don't have
   | named constants as well.

Most likely the reason for that was for parentheses matching editors.

Using '(' creates a ( that (a non C syntax savvy) editor will match
against the next (otherwise unmatched) ')' it finds.   LPAREN doesn't
have that effect.   An alternative is to add a /*)*/ comment on the line,
but that starts getting obtrusive, and difficult to justify.


I've seen all 3 variants in usr.bin/make/*.c, even in the code from
-D2020.01.01.00.00.00, before I started the big rewrite:

$ grep "'[(){}]'" *.c | wc -l
  58

$ grep -Ew 'LPAREN|RPAREN|BROPEN|BRCLOSE|PROPEN|PRCLOSE' *.c \
| wc -l
  19

$ grep '/\*[[:space:]]*[(){}][[:space:]]*\*/' *.c | wc -l
   2

Therefore I had the impression that there was no hard preference, and
that it would be ok to change this.  If it had been consistent over the
majority of the code in usr.bin/make, I would have left it that way.


Re: CVS commit: src/usr.bin/make

2020-09-14 Thread Robert Elz
Date:Mon, 14 Sep 2020 16:16:52 +
From:"Roland Illig" 
Message-ID:  <20200914161652.d4eb5f...@cvs.netbsd.org>

  | make(1): inline LPAREN in parse.c
  |
  | It's shorter and more readable, and the other characters don't have
  | named constants as well.

Most likely the reason for that was for parentheses matching editors.

Using '(' creates a ( that (a non C syntax savvy) editor will match
against the next (otherwise unmatched) ')' it finds.   LPAREN doesn't
have that effect.   An alternative is to add a /*)*/ comment on the line,
but that starts getting obtrusive, and difficult to justify.

kre



Re: CVS commit: src/usr.bin/make

2020-08-02 Thread Roland Illig
On 02.08.2020 13:06, Simon Burge wrote:
> "Roland Illig" wrote:
>
>> Module Name: src
>> Committed By:rillig
>> Date:Sun Aug  2 09:43:22 UTC 2020
>>
>> Modified Files:
>>
>>  src/usr.bin/make: var.c
>>
>> Log Message:
>>
>> make(1): use shorter local variable names
>>
>> The c in cp was redundant since the context makes it obvious that this
>> is a character pointer. In a tight loop where lots of characters are
>> compared, every letter counts.
>
> I don't understand the intent of this commit.  Are you saying the length
> of a C variable name has some sort of impact on code execution speed?

No, I know that it has absolutely no influence on execution speed.

My concern was about the ease of reading by humans.  In var.c, there are
several functions that do low-level parsing by reading the input byte by
byte and comparing the current character.  These functions are
ParseModifierPart, ApplyModifier_Defined, ApplyModifier_Match,
ModifyWord_SubstRegex.

In these functions, there are often 3 to 4 comparisons in a single line.
The comparisons all have the same left-hand side, so that expression
becomes uninteresting to the reader and should therefore be as short as
possible, to leave room for the more interesting details, which are the
right-hand sides of the comparisons.

Therefore I renamed the cp to p, since the c did not add any valuable
information to the code.  It's pretty obvious that in a comparison like
*p == '$', the p must be a pointer to a character.

Only in these very tight loops, and only because these have only a
single interesting pointer, do I prefer this short variable name.  For
comparison, in ApplyModifier_Match, in the second big loop, I named the
variables src and dst, to keep them apart.

Another reason for renaming cp and cp2 is that the make(1) source code
uses these names in a lot of places, and these names do not add any
valuable information to the reader, while a more expressive variable
name could do that very well.  Therefore I'm generally against this
variable name, especially when these variables are used as
general-purpose storage that serves 3 or 4 completely distinct purposes
during its lifetime, happily mixing between storing const char * and
char * and maybe a void * in between, followed by UNCONST to free the cp
at the end.  How should a casual reader know at the end what exactly is
freed here?  It's obviously cp, but what does this mean?

In summary: By the variable name p, I mean a moving pointer in a parsing
function, therefore it's usually the only moving pointer in that
function.  I'm using that variable name consistently for this single
purpose.  This is unlike the original make(1) code, which uses cp and
cp2 for everything.

I notice I'm getting too much into rant mode right now, therefore I'd
rather stop here. :)

Roland


Re: CVS commit: src/usr.bin/make

2020-08-02 Thread Simon Burge
"Roland Illig" wrote:

> Module Name:  src
> Committed By: rillig
> Date: Sun Aug  2 09:43:22 UTC 2020
>
> Modified Files:
>
>   src/usr.bin/make: var.c
>
> Log Message:
>
> make(1): use shorter local variable names
>
> The c in cp was redundant since the context makes it obvious that this
> is a character pointer. In a tight loop where lots of characters are
> compared, every letter counts.

I don't understand the intent of this commit.  Are you saying the length
of a C variable name has some sort of impact on code execution speed?

Cheers,
Simon.


Re: CVS commit: src/usr.bin/make

2020-08-02 Thread Jared McNeill

On Sun, 2 Aug 2020, Roland Illig wrote:


Module Name:src
Committed By:   rillig
Date:   Sun Aug  2 09:43:22 UTC 2020

Modified Files:
src/usr.bin/make: var.c

Log Message:
make(1): use shorter local variable names

The c in cp was redundant since the context makes it obvious that this
is a character pointer. In a tight loop where lots of characters are
compared, every letter counts.


I don't follow the rationale here. Can you expand on this?


Re: CVS commit: src/usr.bin/make

2020-07-26 Thread Christos Zoulas
In article <20200726200457.f2522f...@cvs.netbsd.org>,
Roland Illig  wrote:
>-=-=-=-=-=-
>
>Module Name:   src
>Committed By:  rillig
>Date:  Sun Jul 26 20:04:57 UTC 2020
>
>Modified Files:
>   src/usr.bin/make: Makefile
>
>Log Message:
>make(1): explicitly add dependencies on headers
>
>This prevents partial builds after changing a header.  The declared
>dependencies are more than strictly necessary, but that's still better
>than having inconsistent partial builds because too few dependencies are
>declared.

Isn't that what make depend is for?

christos



re: CVS commit: src/usr.bin/make

2020-07-26 Thread matthew green
> In a follow-up commit, I adjusted the build scripts, and I'm doing a
> full build right now. I'm pretty confident that everything works now
> again, and if not, I'll fix it immediately.

thanks!


.mrg.


Re: CVS commit: src/usr.bin/make

2020-07-26 Thread Roland Illig
On 26.07.2020 10:29, matthew green wrote:
> "Roland Illig" writes:
>> Module Name: src
>> Committed By:rillig
>> Date:Sun Jul 26 07:15:26 UTC 2020
>>
>> Modified Files:
>>  src/usr.bin/make: Makefile
>> Added Files:
>>  src/usr.bin/make: lst.c
>> Removed Files:
>>  src/usr.bin/make/lst.lib: Makefile lstAppend.c lstAtEnd.c lstAtFront.c
>>  lstClose.c lstConcat.c lstDatum.c lstDeQueue.c lstDestroy.c
>>  lstDupl.c lstEnQueue.c lstFind.c lstFindFrom.c lstFirst.c
>>  lstForEach.c lstForEachFrom.c lstInit.c lstInsert.c lstInt.h
>>  lstIsAtEnd.c lstIsEmpty.c lstLast.c lstMember.c lstNext.c lstOpen.c
>>  lstPrev.c lstRemove.c lstReplace.c lstSucc.c
>>
>> Log Message:
>> make(1): condense the list library into a single file
>
> hi Roland.
>
>
> this has broken the build:
>
> cc: error: /usr/src3/usr.bin/make/lst.lib/*.c: No such file or directory
>
> please be more careful with make changes they affect everyone.

Ouch, I'm sorry for that.

I had planned to do a full build with this change before committing it,
but I simply forgot it at the right moment.

In a follow-up commit, I adjusted the build scripts, and I'm doing a
full build right now. I'm pretty confident that everything works now
again, and if not, I'll fix it immediately.

Roland


re: CVS commit: src/usr.bin/make

2020-07-26 Thread matthew green
"Roland Illig" writes:
> Module Name:  src
> Committed By: rillig
> Date: Sun Jul 26 07:15:26 UTC 2020
> 
> Modified Files:
>   src/usr.bin/make: Makefile
> Added Files:
>   src/usr.bin/make: lst.c
> Removed Files:
>   src/usr.bin/make/lst.lib: Makefile lstAppend.c lstAtEnd.c lstAtFront.c
>   lstClose.c lstConcat.c lstDatum.c lstDeQueue.c lstDestroy.c
>   lstDupl.c lstEnQueue.c lstFind.c lstFindFrom.c lstFirst.c
>   lstForEach.c lstForEachFrom.c lstInit.c lstInsert.c lstInt.h
>   lstIsAtEnd.c lstIsEmpty.c lstLast.c lstMember.c lstNext.c lstOpen.c
>   lstPrev.c lstRemove.c lstReplace.c lstSucc.c
> 
> Log Message:
> make(1): condense the list library into a single file

hi Roland.


this has broken the build:

cc: error: /usr/src3/usr.bin/make/lst.lib/*.c: No such file or directory

please be more careful with make changes they affect everyone.

thanks.


.mrg.


Re: CVS commit: src/usr.bin/make

2020-07-19 Thread Izumi Tsutsui
kardel@ wrote:

> nbmake currently fails to build the tree.
> 
> config.status: creating buildmake.sh
>  compile  arch.c
>  compile  buf.c
>  compile  compat.c
>  compile  cond.c
>  compile  dir.c
>  compile  for.c
>  compile  hash.c
>  compile  job.c
>  compile  main.c
>  compile  make.c
>  compile  make_malloc.c
>  compile  meta.c
>  compile  metachar.c
>  compile  parse.c
>  compile  str.c
>  compile  strlist.c
>  compile  suff.c
>  compile  targ.c
>  compile  trace.c
>  compile  util.c
>  compile  var.c
>  compile  lstAppend.c
>  compile  lstAtEnd.c
>  compile  lstAtFront.c
>  compile  lstClose.c
>  compile  lstConcat.c
>  compile  lstDatum.c
>  compile  lstDeQueue.c
>  compile  lstDestroy.c
>  compile  lstDupl.c
>  compile  lstEnQueue.c
>  compile  lstFind.c
>  compile  lstFindFrom.c
>  compile  lstFirst.c
>  compile  lstForEach.c
>  compile  lstForEachFrom.c
>  compile  lstInit.c
>  compile  lstInsert.c
>  compile  lstIsAtEnd.c
>  compile  lstIsEmpty.c
>  compile  lstLast.c
>  compile  lstMember.c
>  compile  lstNext.c
>  compile  lstOpen.c
>  compile  lstPrev.c
>  compile  lstRemove.c
>  compile  lstReplace.c
>  compile  lstSucc.c
> link  nbmake
> ===> MAKECONF file:   /etc/mk.conf
>   objdir  /src/NetBSD/native/src/obj.evbarm/tools
> nbmake: "/src/NetBSD/native/src/share/mk/bsd.nls.mk" line 18: Unknown 
> directive
> nbmake: "/src/NetBSD/native/src/share/mk/bsd.nls.mk" line 19: Unknown 
> directive
> nbmake: Fatal errors encountered -- cannot continue
> ERROR: bomb_getmakevar TOOLDIR: /tmp/nbbuild851/nbmake failed

Also reported:
 https://mail-index.netbsd.org/current-users/2020/07/19/msg039168.html
 https://releng.netbsd.org/builds/HEAD/202007191220Z/
and still broken here.

Could you please fix or revert changes?

Thanks,
---
Izumi Tsutsui


Re: CVS commit: src/usr.bin/make

2020-07-19 Thread Frank Kardel

nbmake currently fails to build the tree.

config.status: creating buildmake.sh
compile  arch.c
compile  buf.c
compile  compat.c
compile  cond.c
compile  dir.c
compile  for.c
compile  hash.c
compile  job.c
compile  main.c
compile  make.c
compile  make_malloc.c
compile  meta.c
compile  metachar.c
compile  parse.c
compile  str.c
compile  strlist.c
compile  suff.c
compile  targ.c
compile  trace.c
compile  util.c
compile  var.c
compile  lstAppend.c
compile  lstAtEnd.c
compile  lstAtFront.c
compile  lstClose.c
compile  lstConcat.c
compile  lstDatum.c
compile  lstDeQueue.c
compile  lstDestroy.c
compile  lstDupl.c
compile  lstEnQueue.c
compile  lstFind.c
compile  lstFindFrom.c
compile  lstFirst.c
compile  lstForEach.c
compile  lstForEachFrom.c
compile  lstInit.c
compile  lstInsert.c
compile  lstIsAtEnd.c
compile  lstIsEmpty.c
compile  lstLast.c
compile  lstMember.c
compile  lstNext.c
compile  lstOpen.c
compile  lstPrev.c
compile  lstRemove.c
compile  lstReplace.c
compile  lstSucc.c
   link  nbmake
===> MAKECONF file:   /etc/mk.conf
 objdir  /src/NetBSD/native/src/obj.evbarm/tools
nbmake: "/src/NetBSD/native/src/share/mk/bsd.nls.mk" line 18: Unknown 
directive
nbmake: "/src/NetBSD/native/src/share/mk/bsd.nls.mk" line 19: Unknown 
directive

nbmake: Fatal errors encountered -- cannot continue
ERROR: bomb_getmakevar TOOLDIR: /tmp/nbbuild851/nbmake failed

Frank

On 07/19/20 14:26, Roland Illig wrote:

Module Name:src
Committed By:   rillig
Date:   Sun Jul 19 12:26:17 UTC 2020

Modified Files:
src/usr.bin/make: arch.c compat.c cond.c for.c job.c main.c make.c
meta.c nonints.h parse.c suff.c var.c

Log Message:
make(1): rename Varf_Flags to VarEvalFlags

In var.c there are lots of different flag types.  To make any accidental
mixture obvious, each flag group gets its own prefix.

The only flag group that is visible outside of var.c is concerned with
evaluating variables, therefore the "e", which replaces the former "f"
that probably just meant "flag".


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/usr.bin/make/arch.c
cvs rdiff -u -r1.113 -r1.114 src/usr.bin/make/compat.c
cvs rdiff -u -r1.79 -r1.80 src/usr.bin/make/cond.c src/usr.bin/make/nonints.h
cvs rdiff -u -r1.54 -r1.55 src/usr.bin/make/for.c
cvs rdiff -u -r1.201 -r1.202 src/usr.bin/make/job.c
cvs rdiff -u -r1.280 -r1.281 src/usr.bin/make/main.c
cvs rdiff -u -r1.99 -r1.100 src/usr.bin/make/make.c
cvs rdiff -u -r1.86 -r1.87 src/usr.bin/make/meta.c
cvs rdiff -u -r1.236 -r1.237 src/usr.bin/make/parse.c
cvs rdiff -u -r1.88 -r1.89 src/usr.bin/make/suff.c
cvs rdiff -u -r1.258 -r1.259 src/usr.bin/make/var.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.





Re: CVS commit: src/usr.bin/make

2020-07-04 Thread Joerg Sonnenberger
On Sat, Jul 04, 2020 at 03:44:07PM +, Roland Illig wrote:
> Module Name:  src
> Committed By: rillig
> Date: Sat Jul  4 15:44:07 UTC 2020
> 
> Modified Files:
>   src/usr.bin/make: var.c
> 
> Log Message:
> make(1): fix :hash modifier on 16-bit platforms
> 
> On platforms where int has only 16 bits the shifts would have been in
> 16-bit arithmetic, which would invoke undefined behavior for "ustr[3] <<
> 24" as well as "ustr[2] << 16" (C99, 6.5.7p3).

WTF should we care? This is just making things more complicated without
adding any value.

Joerg


CVS commit: src/usr.bin/make/unit-tests

2019-11-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Nov 30 03:53:45 UTC 2019

Modified Files:
src/usr.bin/make/unit-tests: varmod-edge.exp varmod-edge.mk

Log Message:
Demonstrate some more edge cases for the :M modifier


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-edge.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-edge.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2019-11-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Nov 30 03:53:45 UTC 2019

Modified Files:
src/usr.bin/make/unit-tests: varmod-edge.exp varmod-edge.mk

Log Message:
Demonstrate some more edge cases for the :M modifier


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-edge.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-edge.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/unit-tests/varmod-edge.exp
diff -u src/usr.bin/make/unit-tests/varmod-edge.exp:1.2 src/usr.bin/make/unit-tests/varmod-edge.exp:1.3
--- src/usr.bin/make/unit-tests/varmod-edge.exp:1.2	Sat Nov 30 02:31:19 2019
+++ src/usr.bin/make/unit-tests/varmod-edge.exp	Sat Nov 30 03:53:45 2019
@@ -1,8 +1,11 @@
 make: Unclosed variable specification (expecting '}') for "" (value "*)") modifier U
 ok M-paren
 ok M-mixed
+ok M-unescape
 ok M-nest-mix
 ok M-nest-brk
 ok M-pat-err
 ok M-bsbs
+ok M-bs1-par
+ok M-bs2-par
 exit status 0

Index: src/usr.bin/make/unit-tests/varmod-edge.mk
diff -u src/usr.bin/make/unit-tests/varmod-edge.mk:1.3 src/usr.bin/make/unit-tests/varmod-edge.mk:1.4
--- src/usr.bin/make/unit-tests/varmod-edge.mk:1.3	Sat Nov 30 02:55:47 2019
+++ src/usr.bin/make/unit-tests/varmod-edge.mk	Sat Nov 30 03:53:45 2019
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-edge.mk,v 1.3 2019/11/30 02:55:47 rillig Exp $
+# $NetBSD: varmod-edge.mk,v 1.4 2019/11/30 03:53:45 rillig Exp $
 #
 # Tests for edge cases in variable modifiers.
 #
@@ -24,6 +24,18 @@ INP.M-mixed=	(paren-brace} (
 MOD.M-mixed=	${INP.M-mixed:M(*}}
 EXP.M-mixed=	(paren-brace}
 
+# After the :M modifier has parsed the pattern, only the closing brace
+# and the colon are unescaped. The other characters are left as-is.
+# To actually see this effect, the backslashes in the :M modifier need
+# to be doubled since single backslashes would simply be unescaped by
+# Str_Match.
+#
+# XXX: This is unexpected. The opening brace should also be unescaped.
+TESTS+=		M-unescape
+INP.M-unescape=	({}): \(\{\}\)\: \(\{}\):
+MOD.M-unescape=	${INP.M-unescape:M\\(\\{\\}\\)\\:}
+EXP.M-unescape=	\(\{}\):
+
 # When the :M and :N modifiers are parsed, the pattern finishes as soon
 # as open_parens + open_braces == closing_parens + closing_braces. This
 # means that ( and } form a matching pair.
@@ -76,6 +88,27 @@ MOD.M-bsbs=	${INP.M-bsbs:M\\(}}
 EXP.M-bsbs=	\(}
 #EXP.M-bsbs=	(}	# If the first backslash were to escape ...
 
+# The backslash in \( does not escape the parenthesis, therefore it
+# counts for the nesting level and matches with the first closing brace.
+# The second closing brace closes the variable, and the third is copied
+# literally.
+#
+# The second :M in the pattern is nested between ( and }, therefore it
+# does not start a new modifier.
+TESTS+=		M-bs1-par
+INP.M-bs1-par=	( (:M (:M} \( \(:M \(:M}
+MOD.M-bs1-par=	${INP.M-bs1-par:M\(:M*}}}
+EXP.M-bs1-par=	(:M}}
+
+# The double backslash is passed verbatim to the pattern matcher.
+# The Str_Match pattern is \\(:M*}, and there the backslash is unescaped.
+# Again, the ( takes place in the nesting level, and there is no way to
+# prevent this, no matter how many backslashes are used.
+TESTS+=		M-bs2-par
+INP.M-bs2-par=	( (:M (:M} \( \(:M \(:M}
+MOD.M-bs2-par=	${INP.M-bs2-par:M\\(:M*}}}
+EXP.M-bs2-par=	\(:M}}
+
 all:
 .for test in ${TESTS}
 .  if ${MOD.${test}} == ${EXP.${test}}



CVS commit: src/usr.bin/make/unit-tests

2019-11-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Nov 30 02:55:47 UTC 2019

Modified Files:
src/usr.bin/make/unit-tests: varmod-edge.mk

Log Message:
Fix unit test for edge case in :M modifier


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-edge.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/unit-tests/varmod-edge.mk
diff -u src/usr.bin/make/unit-tests/varmod-edge.mk:1.2 src/usr.bin/make/unit-tests/varmod-edge.mk:1.3
--- src/usr.bin/make/unit-tests/varmod-edge.mk:1.2	Sat Nov 30 02:31:19 2019
+++ src/usr.bin/make/unit-tests/varmod-edge.mk	Sat Nov 30 02:55:47 2019
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-edge.mk,v 1.2 2019/11/30 02:31:19 rillig Exp $
+# $NetBSD: varmod-edge.mk,v 1.3 2019/11/30 02:55:47 rillig Exp $
 #
 # Tests for edge cases in variable modifiers.
 #
@@ -68,11 +68,13 @@ EXP.M-pat-err=	[
 # If the first backslash were to escape the second backslash, the first
 # closing brace would match the opening parenthesis (see M-mixed), and
 # the second closing brace would be needed to close the variable.
+# After that, the remaining backslash would escape the parenthesis in
+# the pattern, therefore (} would match.
 TESTS+=		M-bsbs
-INP.M-bsbs=	\( \(}
+INP.M-bsbs=	(} \( \(}
 MOD.M-bsbs=	${INP.M-bsbs:M\\(}}
 EXP.M-bsbs=	\(}
-#EXP.M-bsbs=	\(	# If the first backslash were to escape ...
+#EXP.M-bsbs=	(}	# If the first backslash were to escape ...
 
 all:
 .for test in ${TESTS}



CVS commit: src/usr.bin/make/unit-tests

2019-11-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Nov 30 02:55:47 UTC 2019

Modified Files:
src/usr.bin/make/unit-tests: varmod-edge.mk

Log Message:
Fix unit test for edge case in :M modifier


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-edge.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2019-11-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Nov 30 02:35:28 UTC 2019

Added Files:
src/usr.bin/make/unit-tests: .cvsignore

Log Message:
Ignore temporary files from running the unit tests


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/.cvsignore

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2019-11-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Nov 30 02:35:28 UTC 2019

Added Files:
src/usr.bin/make/unit-tests: .cvsignore

Log Message:
Ignore temporary files from running the unit tests


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/.cvsignore

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Added files:

Index: src/usr.bin/make/unit-tests/.cvsignore
diff -u /dev/null src/usr.bin/make/unit-tests/.cvsignore:1.1
--- /dev/null	Sat Nov 30 02:35:28 2019
+++ src/usr.bin/make/unit-tests/.cvsignore	Sat Nov 30 02:35:28 2019
@@ -0,0 +1,3 @@
+*.out
+*.rawout
+*.status



CVS commit: src/usr.bin/make/unit-tests

2019-11-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Nov 30 02:31:19 UTC 2019

Modified Files:
src/usr.bin/make/unit-tests: varmod-edge.exp varmod-edge.mk

Log Message:
Add another unit test for the :M modifier


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varmod-edge.exp \
src/usr.bin/make/unit-tests/varmod-edge.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/unit-tests/varmod-edge.exp
diff -u src/usr.bin/make/unit-tests/varmod-edge.exp:1.1 src/usr.bin/make/unit-tests/varmod-edge.exp:1.2
--- src/usr.bin/make/unit-tests/varmod-edge.exp:1.1	Sat Nov 30 00:38:51 2019
+++ src/usr.bin/make/unit-tests/varmod-edge.exp	Sat Nov 30 02:31:19 2019
@@ -4,4 +4,5 @@ ok M-mixed
 ok M-nest-mix
 ok M-nest-brk
 ok M-pat-err
+ok M-bsbs
 exit status 0
Index: src/usr.bin/make/unit-tests/varmod-edge.mk
diff -u src/usr.bin/make/unit-tests/varmod-edge.mk:1.1 src/usr.bin/make/unit-tests/varmod-edge.mk:1.2
--- src/usr.bin/make/unit-tests/varmod-edge.mk:1.1	Sat Nov 30 00:38:51 2019
+++ src/usr.bin/make/unit-tests/varmod-edge.mk	Sat Nov 30 02:31:19 2019
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-edge.mk,v 1.1 2019/11/30 00:38:51 rillig Exp $
+# $NetBSD: varmod-edge.mk,v 1.2 2019/11/30 02:31:19 rillig Exp $
 #
 # Tests for edge cases in variable modifiers.
 #
@@ -54,11 +54,26 @@ EXP.M-nest-brk=	[
 # No error is reported though, and the pattern is closed implicitly.
 #
 # XXX: It is unexpected that no error is reported.
+# See str.c, function Str_Match.
 TESTS+=		M-pat-err
 INP.M-pat-err=	[ [[ [[[
 MOD.M-pat-err=	${INP.M-pat-err:M${:U[[}}
 EXP.M-pat-err=	[
 
+# The first backslash does not escape the second backslash.
+# Therefore, the second backslash escapes the parenthesis.
+# This means that the pattern ends there.
+# The final } in the output comes from the end of MOD.M-bsbs.
+#
+# If the first backslash were to escape the second backslash, the first
+# closing brace would match the opening parenthesis (see M-mixed), and
+# the second closing brace would be needed to close the variable.
+TESTS+=		M-bsbs
+INP.M-bsbs=	\( \(}
+MOD.M-bsbs=	${INP.M-bsbs:M\\(}}
+EXP.M-bsbs=	\(}
+#EXP.M-bsbs=	\(	# If the first backslash were to escape ...
+
 all:
 .for test in ${TESTS}
 .  if ${MOD.${test}} == ${EXP.${test}}



CVS commit: src/usr.bin/make/unit-tests

2019-11-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Nov 30 02:31:19 UTC 2019

Modified Files:
src/usr.bin/make/unit-tests: varmod-edge.exp varmod-edge.mk

Log Message:
Add another unit test for the :M modifier


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varmod-edge.exp \
src/usr.bin/make/unit-tests/varmod-edge.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make/unit-tests

2019-11-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Nov 30 00:38:51 UTC 2019

Modified Files:
src/usr.bin/make/unit-tests: Makefile
Added Files:
src/usr.bin/make/unit-tests: varmod-edge.exp varmod-edge.mk

Log Message:
Add unit tests for variable modifiers like :M and :N


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/varmod-edge.exp \
src/usr.bin/make/unit-tests/varmod-edge.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/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.53 src/usr.bin/make/unit-tests/Makefile:1.54
--- src/usr.bin/make/unit-tests/Makefile:1.53	Thu May 24 00:25:44 2018
+++ src/usr.bin/make/unit-tests/Makefile	Sat Nov 30 00:38:51 2019
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.53 2018/05/24 00:25:44 christos Exp $
+# $NetBSD: Makefile,v 1.54 2019/11/30 00:38:51 rillig Exp $
 #
 # Unit tests for make(1)
 # The main targets are:
@@ -50,6 +50,7 @@ TESTNAMES= \
 	unexport-env \
 	varcmd \
 	varmisc \
+	varmod-edge \
 	varquote \
 	varshell
 

Added files:

Index: src/usr.bin/make/unit-tests/varmod-edge.exp
diff -u /dev/null src/usr.bin/make/unit-tests/varmod-edge.exp:1.1
--- /dev/null	Sat Nov 30 00:38:51 2019
+++ src/usr.bin/make/unit-tests/varmod-edge.exp	Sat Nov 30 00:38:51 2019
@@ -0,0 +1,7 @@
+make: Unclosed variable specification (expecting '}') for "" (value "*)") modifier U
+ok M-paren
+ok M-mixed
+ok M-nest-mix
+ok M-nest-brk
+ok M-pat-err
+exit status 0
Index: src/usr.bin/make/unit-tests/varmod-edge.mk
diff -u /dev/null src/usr.bin/make/unit-tests/varmod-edge.mk:1.1
--- /dev/null	Sat Nov 30 00:38:51 2019
+++ src/usr.bin/make/unit-tests/varmod-edge.mk	Sat Nov 30 00:38:51 2019
@@ -0,0 +1,70 @@
+# $NetBSD: varmod-edge.mk,v 1.1 2019/11/30 00:38:51 rillig Exp $
+#
+# Tests for edge cases in variable modifiers.
+#
+# These tests demonstrate the current implementation in small examples.
+# They may contain surprising behavior.
+#
+# Each test consists of:
+# - INP, the input to the test
+# - MOD, the expression for testing the modifier
+# - EXP, the expected output
+
+TESTS+=		M-paren
+INP.M-paren=	(parentheses) {braces} (opening closing) ()
+MOD.M-paren=	${INP.M-paren:M(*)}
+EXP.M-paren=	(parentheses) ()
+
+# The first closing brace matches the opening parenthesis.
+# The second closing brace actually ends the variable expression.
+#
+# XXX: This is unexpected but rarely occurs in practice.
+TESTS+=		M-mixed
+INP.M-mixed=	(paren-brace} (
+MOD.M-mixed=	${INP.M-mixed:M(*}}
+EXP.M-mixed=	(paren-brace}
+
+# When the :M and :N modifiers are parsed, the pattern finishes as soon
+# as open_parens + open_braces == closing_parens + closing_braces. This
+# means that ( and } form a matching pair.
+#
+# Nested variable expressions are not parsed as such. Instead, only the
+# parentheses and braces are counted. This leads to a parse error since
+# the nested expression is not "${:U*)}" but only "${:U*)", which is
+# missing the closing brace. The expression is evaluated anyway.
+# The final brace in the output comes from the end of M.nest-mix.
+#
+# XXX: This is unexpected but rarely occurs in practice.
+TESTS+=		M-nest-mix
+INP.M-nest-mix=	(parentheses)
+MOD.M-nest-mix=	${INP.M-nest-mix:M${:U*)}}
+EXP.M-nest-mix=	(parentheses)}
+
+# In contrast to parentheses and braces, the brackets are not counted
+# when the :M modifier is parsed since Makefile variables only take the
+# ${VAR} or $(VAR) forms, but not $[VAR].
+#
+# The final ] in the pattern is needed to close the character class.
+TESTS+=		M-nest-brk
+INP.M-nest-brk=	[ [[ [[[
+MOD.M-nest-brk=	${INP.M-nest-brk:M${:U[]}}
+EXP.M-nest-brk=	[
+
+# The pattern in the nested variable has an unclosed character class.
+# No error is reported though, and the pattern is closed implicitly.
+#
+# XXX: It is unexpected that no error is reported.
+TESTS+=		M-pat-err
+INP.M-pat-err=	[ [[ [[[
+MOD.M-pat-err=	${INP.M-pat-err:M${:U[[}}
+EXP.M-pat-err=	[
+
+all:
+.for test in ${TESTS}
+.  if ${MOD.${test}} == ${EXP.${test}}
+	@printf 'ok %s\n' ${test:Q}''
+.  else
+	@printf 'error in %s: expected %s, got %s\n' \
+		${test:Q}'' ${EXP.${test}:Q}'' ${MOD.${test}:Q}''
+.  endif
+.endfor



CVS commit: src/usr.bin/make/unit-tests

2019-11-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Nov 30 00:38:51 UTC 2019

Modified Files:
src/usr.bin/make/unit-tests: Makefile
Added Files:
src/usr.bin/make/unit-tests: varmod-edge.exp varmod-edge.mk

Log Message:
Add unit tests for variable modifiers like :M and :N


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/varmod-edge.exp \
src/usr.bin/make/unit-tests/varmod-edge.mk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



  1   2   >