CVS commit: src/usr.bin/find

2020-10-31 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Nov  1 05:38:29 UTC 2020

Modified Files:
src/usr.bin/find: option.c

Log Message:
add support for '-not': GNU and thus worldly scripts compatibility.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/find/option.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/find/option.c
diff -u src/usr.bin/find/option.c:1.27 src/usr.bin/find/option.c:1.28
--- src/usr.bin/find/option.c:1.27	Mon Jun 13 00:04:40 2016
+++ src/usr.bin/find/option.c	Sun Nov  1 05:38:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: option.c,v 1.27 2016/06/13 00:04:40 pgoyette Exp $	*/
+/*	$NetBSD: option.c,v 1.28 2020/11/01 05:38:29 mrg Exp $	*/
 
 /*-
  * Copyright (c) 1990, 1993, 1994
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "from: @(#)option.c	8.2 (Berkeley) 4/16/94";
 #else
-__RCSID("$NetBSD: option.c,v 1.27 2016/06/13 00:04:40 pgoyette Exp $");
+__RCSID("$NetBSD: option.c,v 1.28 2020/11/01 05:38:29 mrg Exp $");
 #endif
 #endif /* not lint */
 
@@ -126,6 +126,8 @@ static OPTION const options[] = {
  */
 
 	{ "-nogroup",	N_NOGROUP,	c_nogroup,	0 },
+/* Alias for compatability with Gnu findutils */
+	{ "-not",	N_NOT,		c_not,		0 },
 	{ "-nouser",	N_NOUSER,	c_nouser,	0 },
 	{ "-o",		N_OR,		c_or,		0 },
 	{ "-ok",	N_OK,		c_exec,		1 },



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Nov  1 00:24:57 UTC 2020

Modified Files:
src/usr.bin/make: main.c nonints.h parse.c
src/usr.bin/make/unit-tests: lint.exp

Log Message:
make(1): in lint mode, exit with error status on errors

Calling Parse_Error during parsing has always led to a nonzero exit
status.  Calling Parse_Error later, when expanding the shell commands,
has had no effect on the exit status.  Neither had calling Error.

To make make a reliable tool, it has to report errors as they occur.
Enable this strict behavior in lint mode for now.  Lint mode has to be
enabled explicitly, preserving the default behavior.


To generate a diff of this commit:
cvs rdiff -u -r1.420 -r1.421 src/usr.bin/make/main.c
cvs rdiff -u -r1.148 -r1.149 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.419 -r1.420 src/usr.bin/make/parse.c
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/lint.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/main.c
diff -u src/usr.bin/make/main.c:1.420 src/usr.bin/make/main.c:1.421
--- src/usr.bin/make/main.c:1.420	Sat Oct 31 21:09:22 2020
+++ src/usr.bin/make/main.c	Sun Nov  1 00:24:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.420 2020/10/31 21:09:22 sjg Exp $	*/
+/*	$NetBSD: main.c,v 1.421 2020/11/01 00:24:57 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -118,7 +118,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.420 2020/10/31 21:09:22 sjg Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.421 2020/11/01 00:24:57 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	"The Regents of the University of California.  "
@@ -156,6 +156,7 @@ pid_t myPid;
 int makelevel;
 
 Boolean forceJobs = FALSE;
+static int errors = 0;
 
 extern SearchPath *parseIncPath;
 
@@ -1600,6 +1601,8 @@ main(int argc, char **argv)
 
 	CleanUp();
 
+	if (DEBUG(LINT) && (errors > 0 || Parse_GetFatals() > 0))
+	return 2;		/* Not 1 so -q can distinguish error */
 	return outOfDate ? 1 : 0;
 }
 
@@ -1825,6 +1828,7 @@ Error(const char *fmt, ...)
 			break;
 		err_file = stderr;
 	}
+	errors++;
 }
 
 /* Produce a Fatal error message, then exit immediately.
@@ -1889,11 +1893,11 @@ DieHorribly(void)
  * The program exits.
  * Errors is the number of errors encountered in Make_Make. */
 void
-Finish(int errors)
+Finish(int errs)
 {
 	if (dieQuietly(NULL, -1))
 		exit(2);
-	Fatal("%d error%s", errors, errors == 1 ? "" : "s");
+	Fatal("%d error%s", errs, errs == 1 ? "" : "s");
 }
 
 /*

Index: src/usr.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.148 src/usr.bin/make/nonints.h:1.149
--- src/usr.bin/make/nonints.h:1.148	Sat Oct 31 11:54:33 2020
+++ src/usr.bin/make/nonints.h	Sun Nov  1 00:24:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.148 2020/10/31 11:54:33 rillig Exp $	*/
+/*	$NetBSD: nonints.h,v 1.149 2020/11/01 00:24:57 rillig Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -147,6 +147,7 @@ void Parse_AddIncludeDir(const char *);
 void Parse_File(const char *, int);
 void Parse_SetInput(const char *, int, int, NextBufProc, void *);
 GNodeList *Parse_MainName(void);
+int Parse_GetFatals(void);
 
 /* str.c */
 typedef struct Words {

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.419 src/usr.bin/make/parse.c:1.420
--- src/usr.bin/make/parse.c:1.419	Sat Oct 31 23:44:42 2020
+++ src/usr.bin/make/parse.c	Sun Nov  1 00:24:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.419 2020/10/31 23:44:42 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.420 2020/11/01 00:24:57 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.419 2020/10/31 23:44:42 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.420 2020/11/01 00:24:57 rillig Exp $");
 
 /* types and constants */
 
@@ -3221,3 +3221,9 @@ Parse_MainName(void)
 Var_Append(".TARGETS", mainNode->name, VAR_GLOBAL);
 return mainList;
 }
+
+int
+Parse_GetFatals(void)
+{
+return fatals;
+}

Index: src/usr.bin/make/unit-tests/lint.exp
diff -u src/usr.bin/make/unit-tests/lint.exp:1.1 src/usr.bin/make/unit-tests/lint.exp:1.2
--- src/usr.bin/make/unit-tests/lint.exp:1.1	Mon Aug  3 15:43:32 2020
+++ src/usr.bin/make/unit-tests/lint.exp	Sun Nov  1 00:24:57 2020
@@ -1,4 +1,4 @@
 make: In the :@ modifier of "VAR", the variable name "${:Ubar:S,b,v,}" must not contain a dollar.
 y@:Q}
 xvaluey
-exit status 0
+exit status 2



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 23:44:42 UTC 2020

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

Log Message:
make(1): clean up StrContainsWord


To generate a diff of this commit:
cvs rdiff -u -r1.418 -r1.419 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/parse.c
diff -u src/usr.bin/make/parse.c:1.418 src/usr.bin/make/parse.c:1.419
--- src/usr.bin/make/parse.c:1.418	Sat Oct 31 23:39:01 2020
+++ src/usr.bin/make/parse.c	Sat Oct 31 23:44:42 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.418 2020/10/31 23:39:01 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.419 2020/10/31 23:44:42 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.418 2020/10/31 23:39:01 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.419 2020/10/31 23:44:42 rillig Exp $");
 
 /* types and constants */
 
@@ -2354,23 +2354,22 @@ ParseSetParseFile(const char *filename)
 static Boolean
 StrContainsWord(const char *str, const char *word)
 {
-const char *val = str;
-size_t valLen = strlen(val);
+size_t strLen = strlen(str);
 size_t wordLen = strlen(word);
-const char *end;
+const char *p, *end;
 
-if (valLen < wordLen)
+if (strLen < wordLen)
 	return FALSE;		/* str is too short to contain word */
 
-end = val + valLen - wordLen;
-for (; val != NULL; val = strchr(val, ' ')) {
-	if (*val == ' ')
-	val++;
-	if (val > end)
+end = str + strLen - wordLen;
+for (p = str; p != NULL; p = strchr(p, ' ')) {
+	if (*p == ' ')
+	p++;
+	if (p > end)
 	return FALSE;	/* cannot contain word */
 
-	if (memcmp(val, word, wordLen) == 0 &&
-	(val[wordLen] == '\0' || val[wordLen] == ' '))
+	if (memcmp(p, word, wordLen) == 0 &&
+	(p[wordLen] == '\0' || p[wordLen] == ' '))
 	return TRUE;
 }
 return FALSE;



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 23:39:01 UTC 2020

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

Log Message:
make(1): fix out-of-bounds pointer in ParseTrackInput


To generate a diff of this commit:
cvs rdiff -u -r1.417 -r1.418 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/parse.c
diff -u src/usr.bin/make/parse.c:1.417 src/usr.bin/make/parse.c:1.418
--- src/usr.bin/make/parse.c:1.417	Sat Oct 31 23:10:06 2020
+++ src/usr.bin/make/parse.c	Sat Oct 31 23:39:01 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.417 2020/10/31 23:10:06 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.418 2020/10/31 23:39:01 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.417 2020/10/31 23:10:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.418 2020/10/31 23:39:01 rillig Exp $");
 
 /* types and constants */
 
@@ -2351,32 +2351,50 @@ ParseSetParseFile(const char *filename)
 }
 }
 
+static Boolean
+StrContainsWord(const char *str, const char *word)
+{
+const char *val = str;
+size_t valLen = strlen(val);
+size_t wordLen = strlen(word);
+const char *end;
+
+if (valLen < wordLen)
+	return FALSE;		/* str is too short to contain word */
+
+end = val + valLen - wordLen;
+for (; val != NULL; val = strchr(val, ' ')) {
+	if (*val == ' ')
+	val++;
+	if (val > end)
+	return FALSE;	/* cannot contain word */
+
+	if (memcmp(val, word, wordLen) == 0 &&
+	(val[wordLen] == '\0' || val[wordLen] == ' '))
+	return TRUE;
+}
+return FALSE;
+}
+
+/* XXX: Searching through a set of words with this linear search is
+ * inefficient for variables that contain thousands of words. */
+static Boolean
+VarContainsWord(const char *varname, const char *word)
+{
+void *val_freeIt;
+const char *val = Var_Value(varname, VAR_GLOBAL, _freeIt);
+Boolean found = val != NULL && StrContainsWord(val, word);
+bmake_free(val_freeIt);
+return found;
+}
+
 /* Track the makefiles we read - so makefiles can set dependencies on them.
  * Avoid adding anything more than once. */
 static void
 ParseTrackInput(const char *name)
 {
-void *old_freeIt = NULL;
-
-const char *old = Var_Value(MAKE_MAKEFILES, VAR_GLOBAL, _freeIt);
-if (old != NULL) {
-	size_t name_len = strlen(name);
-	/* XXX: undefined behavior if name_len > strlen(old) */
-	const char *ep = old + strlen(old) - name_len;
-	/* does it contain name? */
-	for (; old != NULL; old = strchr(old, ' ')) {
-	if (*old == ' ')
-		old++;
-	if (old > ep)
-		break;		/* cannot contain name */
-	if (memcmp(old, name, name_len) == 0 &&
-		(old[name_len] == '\0' || old[name_len] == ' '))
-		goto cleanup;
-	}
-}
-Var_Append(MAKE_MAKEFILES, name, VAR_GLOBAL);
-cleanup:
-bmake_free(old_freeIt);
+if (!VarContainsWord(MAKE_MAKEFILES, name))
+	Var_Append(MAKE_MAKEFILES, name, VAR_GLOBAL);
 }
 
 



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 23:23:22 UTC 2020

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

Log Message:
make(1): rename parameter of Var_Value


To generate a diff of this commit:
cvs rdiff -u -r1.631 -r1.632 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.631 src/usr.bin/make/var.c:1.632
--- src/usr.bin/make/var.c:1.631	Sat Oct 31 21:40:20 2020
+++ src/usr.bin/make/var.c	Sat Oct 31 23:23:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.631 2020/10/31 21:40:20 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.632 2020/10/31 23:23:22 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.631 2020/10/31 21:40:20 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.632 2020/10/31 23:23:22 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -1013,23 +1013,23 @@ Var_Exists(const char *name, GNode *ctxt
  *
  * Results:
  *	The value if the variable exists, NULL if it doesn't.
- *	If the returned value is not NULL, the caller must free *freeIt
- *	as soon as the returned value is no longer needed.
+ *	If the returned value is not NULL, the caller must free
+ *	out_freeIt when the returned value is no longer needed.
  *---
  */
 const char *
-Var_Value(const char *name, GNode *ctxt, void **freeIt)
+Var_Value(const char *name, GNode *ctxt, void **out_freeIt)
 {
 Var *v = VarFind(name, ctxt, TRUE);
 char *value;
 
-*freeIt = NULL;
+*out_freeIt = NULL;
 if (v == NULL)
 	return NULL;
 
 value = Buf_GetAll(>val, NULL);
 if (VarFreeEnv(v, FALSE))
-	*freeIt = value;
+	*out_freeIt = value;
 return value;
 }
 



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 23:10:07 UTC 2020

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

Log Message:
make(1): improve local variable name in ParseTrackInput

By the way, the Address Sanitizer that ran over this code on 2015-11-26
didn't find the other out-of-bounds bug.  Most probably the Address
Sanitizer only detected obvious bugs in the actual test data, and there
was no test case in which .MAKE.MAKEFILES was shorter than the newly
added makefile.


To generate a diff of this commit:
cvs rdiff -u -r1.416 -r1.417 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/parse.c
diff -u src/usr.bin/make/parse.c:1.416 src/usr.bin/make/parse.c:1.417
--- src/usr.bin/make/parse.c:1.416	Sat Oct 31 23:01:23 2020
+++ src/usr.bin/make/parse.c	Sat Oct 31 23:10:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.416 2020/10/31 23:01:23 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.417 2020/10/31 23:10:06 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.416 2020/10/31 23:01:23 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.417 2020/10/31 23:10:06 rillig Exp $");
 
 /* types and constants */
 
@@ -2356,11 +2356,12 @@ ParseSetParseFile(const char *filename)
 static void
 ParseTrackInput(const char *name)
 {
-void *fp = NULL;
+void *old_freeIt = NULL;
 
-const char *old = Var_Value(MAKE_MAKEFILES, VAR_GLOBAL, );
-if (old) {
+const char *old = Var_Value(MAKE_MAKEFILES, VAR_GLOBAL, _freeIt);
+if (old != NULL) {
 	size_t name_len = strlen(name);
+	/* XXX: undefined behavior if name_len > strlen(old) */
 	const char *ep = old + strlen(old) - name_len;
 	/* does it contain name? */
 	for (; old != NULL; old = strchr(old, ' ')) {
@@ -2375,7 +2376,7 @@ ParseTrackInput(const char *name)
 }
 Var_Append(MAKE_MAKEFILES, name, VAR_GLOBAL);
 cleanup:
-bmake_free(fp);
+bmake_free(old_freeIt);
 }
 
 



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 23:01:23 UTC 2020

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

Log Message:
make(1): fix off-by-one bug in ParseTrackInput (since 2015-11-26)


To generate a diff of this commit:
cvs rdiff -u -r1.415 -r1.416 src/usr.bin/make/parse.c
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/directive-include.exp \
src/usr.bin/make/unit-tests/directive-include.mk

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

Modified files:

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.415 src/usr.bin/make/parse.c:1.416
--- src/usr.bin/make/parse.c:1.415	Sat Oct 31 21:52:56 2020
+++ src/usr.bin/make/parse.c	Sat Oct 31 23:01:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.415 2020/10/31 21:52:56 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.416 2020/10/31 23:01:23 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.415 2020/10/31 21:52:56 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.416 2020/10/31 23:01:23 rillig Exp $");
 
 /* types and constants */
 
@@ -2366,7 +2366,7 @@ ParseTrackInput(const char *name)
 	for (; old != NULL; old = strchr(old, ' ')) {
 	if (*old == ' ')
 		old++;
-	if (old >= ep)
+	if (old > ep)
 		break;		/* cannot contain name */
 	if (memcmp(old, name, name_len) == 0 &&
 		(old[name_len] == '\0' || old[name_len] == ' '))

Index: src/usr.bin/make/unit-tests/directive-include.exp
diff -u src/usr.bin/make/unit-tests/directive-include.exp:1.2 src/usr.bin/make/unit-tests/directive-include.exp:1.3
--- src/usr.bin/make/unit-tests/directive-include.exp:1.2	Sat Oct 31 22:55:35 2020
+++ src/usr.bin/make/unit-tests/directive-include.exp	Sat Oct 31 23:01:23 2020
@@ -1,7 +1,5 @@
 CondParser_Eval: ${.MAKE.MAKEFILES:T} != "${.PARSEFILE} null"
 lhs = "directive-include.mk null", rhs = "directive-include.mk null", op = !=
-CondParser_Eval: ${.MAKE.MAKEFILES:T} != "${.PARSEFILE} null null"
-lhs = "directive-include.mk null null", rhs = "directive-include.mk null null", op = !=
-CondParser_Eval: ${.MAKE.MAKEFILES:T} != "${.PARSEFILE} null null"
-lhs = "directive-include.mk null null", rhs = "directive-include.mk null null", op = !=
+CondParser_Eval: ${.MAKE.MAKEFILES:T} != "${.PARSEFILE} null"
+lhs = "directive-include.mk null", rhs = "directive-include.mk null", op = !=
 exit status 0
Index: src/usr.bin/make/unit-tests/directive-include.mk
diff -u src/usr.bin/make/unit-tests/directive-include.mk:1.2 src/usr.bin/make/unit-tests/directive-include.mk:1.3
--- src/usr.bin/make/unit-tests/directive-include.mk:1.2	Sat Oct 31 22:55:35 2020
+++ src/usr.bin/make/unit-tests/directive-include.mk	Sat Oct 31 23:01:23 2020
@@ -1,4 +1,4 @@
-# $NetBSD: directive-include.mk,v 1.2 2020/10/31 22:55:35 rillig Exp $
+# $NetBSD: directive-include.mk,v 1.3 2020/10/31 23:01:23 rillig Exp $
 #
 # Tests for the .include directive, which includes another file.
 
@@ -15,17 +15,10 @@
 .endif
 
 # Each file is recorded only once in the variable .MAKE.MAKEFILES.
-# XXX: As of 2020-10-31, the very last file can be repeated, due to an
-# off-by-one bug in ParseTrackInput.
+# Between 2015-11-26 and 2020-10-31, the very last file could be repeated,
+# due to an off-by-one bug in ParseTrackInput.
 .include "/dev/null"
-.if ${.MAKE.MAKEFILES:T} != "${.PARSEFILE} null null"
-.  error
-.endif
-
-# Since the file /dev/null is not only recorded at the very end of the
-# variable .MAKE.MAKEFILES, it is not added a third time.
-.include "/dev/null"
-.if ${.MAKE.MAKEFILES:T} != "${.PARSEFILE} null null"
+.if ${.MAKE.MAKEFILES:T} != "${.PARSEFILE} null"
 .  error
 .endif
 



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

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 22:55:35 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: directive-include.exp directive-include.mk

Log Message:
make(1): add test for off-by-one bug in ParseTrackInput


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/directive-include.exp \
src/usr.bin/make/unit-tests/directive-include.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/directive-include.exp
diff -u src/usr.bin/make/unit-tests/directive-include.exp:1.1 src/usr.bin/make/unit-tests/directive-include.exp:1.2
--- src/usr.bin/make/unit-tests/directive-include.exp:1.1	Sun Sep 13 09:20:23 2020
+++ src/usr.bin/make/unit-tests/directive-include.exp	Sat Oct 31 22:55:35 2020
@@ -1 +1,7 @@
+CondParser_Eval: ${.MAKE.MAKEFILES:T} != "${.PARSEFILE} null"
+lhs = "directive-include.mk null", rhs = "directive-include.mk null", op = !=
+CondParser_Eval: ${.MAKE.MAKEFILES:T} != "${.PARSEFILE} null null"
+lhs = "directive-include.mk null null", rhs = "directive-include.mk null null", op = !=
+CondParser_Eval: ${.MAKE.MAKEFILES:T} != "${.PARSEFILE} null null"
+lhs = "directive-include.mk null null", rhs = "directive-include.mk null null", op = !=
 exit status 0
Index: src/usr.bin/make/unit-tests/directive-include.mk
diff -u src/usr.bin/make/unit-tests/directive-include.mk:1.1 src/usr.bin/make/unit-tests/directive-include.mk:1.2
--- src/usr.bin/make/unit-tests/directive-include.mk:1.1	Sun Sep 13 09:20:23 2020
+++ src/usr.bin/make/unit-tests/directive-include.mk	Sat Oct 31 22:55:35 2020
@@ -1,8 +1,33 @@
-# $NetBSD: directive-include.mk,v 1.1 2020/09/13 09:20:23 rillig Exp $
+# $NetBSD: directive-include.mk,v 1.2 2020/10/31 22:55:35 rillig Exp $
 #
 # Tests for the .include directive, which includes another file.
 
 # TODO: Implementation
 
+.MAKEFLAGS: -dc
+
+# All included files are recorded in the variable .MAKE.MAKEFILES.
+# In this test, only the basenames of the files are compared since
+# the directories can differ.
+.include "/dev/null"
+.if ${.MAKE.MAKEFILES:T} != "${.PARSEFILE} null"
+.  error
+.endif
+
+# Each file is recorded only once in the variable .MAKE.MAKEFILES.
+# XXX: As of 2020-10-31, the very last file can be repeated, due to an
+# off-by-one bug in ParseTrackInput.
+.include "/dev/null"
+.if ${.MAKE.MAKEFILES:T} != "${.PARSEFILE} null null"
+.  error
+.endif
+
+# Since the file /dev/null is not only recorded at the very end of the
+# variable .MAKE.MAKEFILES, it is not added a third time.
+.include "/dev/null"
+.if ${.MAKE.MAKEFILES:T} != "${.PARSEFILE} null null"
+.  error
+.endif
+
 all:
 	@:;



CVS commit: src

2020-10-31 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Sat Oct 31 22:43:02 UTC 2020

Modified Files:
src/distrib/sets/lists/comp: mi
src/share/man/man4: ddb.4
src/share/man/man9: Makefile

Log Message:
Install ddb(9).  Xref it from ddb(4).


To generate a diff of this commit:
cvs rdiff -u -r1.2362 -r1.2363 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.195 -r1.196 src/share/man/man4/ddb.4
cvs rdiff -u -r1.452 -r1.453 src/share/man/man9/Makefile

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

Modified files:

Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.2362 src/distrib/sets/lists/comp/mi:1.2363
--- src/distrib/sets/lists/comp/mi:1.2362	Sat Oct 24 05:01:57 2020
+++ src/distrib/sets/lists/comp/mi	Sat Oct 31 22:43:01 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.2362 2020/10/24 05:01:57 kamil Exp $
+#	$NetBSD: mi,v 1.2363 2020/10/31 22:43:01 uwe Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 ./etc/mtree/set.compcomp-sys-root
@@ -11347,6 +11347,7 @@
 ./usr/share/man/cat9/days_in_month.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/days_per_year.0		comp-sys-catman		.cat
 ./usr/share/man/cat9/dbtob.0			comp-sys-catman		.cat
+./usr/share/man/cat9/ddb.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/ddc.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/delay.0			comp-sys-catman		.cat
 ./usr/share/man/cat9/device_printf.0		comp-sys-catman		.cat
@@ -19508,6 +19509,7 @@
 ./usr/share/man/html9/days_in_month.html	comp-sys-htmlman	html
 ./usr/share/man/html9/days_per_year.html	comp-sys-htmlman	html
 ./usr/share/man/html9/dbtob.html		comp-sys-htmlman	html
+./usr/share/man/html9/ddb.html			comp-sys-htmlman	html
 ./usr/share/man/html9/ddc.html			comp-sys-htmlman	html
 ./usr/share/man/html9/delay.html		comp-sys-htmlman	html
 ./usr/share/man/html9/device_printf.html	comp-sys-htmlman	html
@@ -27809,6 +27811,7 @@
 ./usr/share/man/man9/days_in_month.9		comp-sys-man		.man
 ./usr/share/man/man9/days_per_year.9		comp-sys-man		.man
 ./usr/share/man/man9/dbtob.9			comp-sys-man		.man
+./usr/share/man/man9/ddb.9			comp-sys-man		.man
 ./usr/share/man/man9/ddc.9			comp-sys-man		.man
 ./usr/share/man/man9/delay.9			comp-sys-man		.man
 ./usr/share/man/man9/device_printf.9		comp-sys-man		.man

Index: src/share/man/man4/ddb.4
diff -u src/share/man/man4/ddb.4:1.195 src/share/man/man4/ddb.4:1.196
--- src/share/man/man4/ddb.4:1.195	Sun Aug 23 09:55:58 2020
+++ src/share/man/man4/ddb.4	Sat Oct 31 22:43:01 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ddb.4,v 1.195 2020/08/23 09:55:58 wiz Exp $
+.\"	$NetBSD: ddb.4,v 1.196 2020/10/31 22:43:01 uwe Exp $
 .\"
 .\" Copyright (c) 1997 - 2019 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -1506,7 +1506,8 @@ and modifiers as described above.
 .Xr crash 8 ,
 .Xr reboot 8 ,
 .Xr sysctl 8 ,
-.Xr cnmagic 9
+.Xr cnmagic 9 ,
+.Xr ddb 9
 .Sh HISTORY
 The
 .Nm

Index: src/share/man/man9/Makefile
diff -u src/share/man/man9/Makefile:1.452 src/share/man/man9/Makefile:1.453
--- src/share/man/man9/Makefile:1.452	Fri Jul 10 02:27:13 2020
+++ src/share/man/man9/Makefile	Sat Oct 31 22:43:01 2020
@@ -1,4 +1,4 @@
-#   $NetBSD: Makefile,v 1.452 2020/07/10 02:27:13 thorpej Exp $
+#   $NetBSD: Makefile,v 1.453 2020/10/31 22:43:01 uwe Exp $
 
 #	Makefile for section 9 (kernel function and variable) manual pages.
 
@@ -16,7 +16,8 @@ MAN=	accept_filter.9 accf_data.9 accf_ht
 	cpu_startup.9 cpu_switchto.9 cpufreq.9 \
 	csf.9 ctod.9 \
 	curproc.9 \
-	delay.9 devsw_attach.9 disk.9 ddc.9 disklabel.9 dksubr.9 dofileread.9 \
+	ddb.9 ddc.9 \
+	delay.9 devsw_attach.9 disk.9 disklabel.9 dksubr.9 dofileread.9 \
 	dopowerhooks.9 do_setresuid.9 doshutdownhooks.9 driver.9 \
 	edid.9 errno.9 ethersubr.9 evcnt.9 extattr.9 extent.9 \
 	file.9 fileassoc.9 filedesc.9 firmload.9 flash.9 \



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 22:05:56 UTC 2020

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

Log Message:
make(1): document possible undefined behavior in trace.c with .CURDIR


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/trace.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/trace.c
diff -u src/usr.bin/make/trace.c:1.20 src/usr.bin/make/trace.c:1.21
--- src/usr.bin/make/trace.c:1.20	Fri Oct 30 20:30:44 2020
+++ src/usr.bin/make/trace.c	Sat Oct 31 22:05:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: trace.c,v 1.20 2020/10/30 20:30:44 rillig Exp $	*/
+/*	$NetBSD: trace.c,v 1.21 2020/10/31 22:05:56 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
 #include "job.h"
 #include "trace.h"
 
-MAKE_RCSID("$NetBSD: trace.c,v 1.20 2020/10/30 20:30:44 rillig Exp $");
+MAKE_RCSID("$NetBSD: trace.c,v 1.21 2020/10/31 22:05:56 rillig Exp $");
 
 static FILE *trfile;
 static pid_t trpid;
@@ -69,6 +69,8 @@ Trace_Init(const char *pathname)
 	if (pathname != NULL) {
 		void *dontFreeIt;
 		trpid = getpid();
+		/* XXX: This variable may get overwritten later, which
+		 * would make trwd point to undefined behavior. */
 		trwd = Var_Value(".CURDIR", VAR_GLOBAL, );
 
 		trfile = fopen(pathname, "a");



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 21:52:56 UTC 2020

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

Log Message:
make(1): document local variable in parse.c more precisely


To generate a diff of this commit:
cvs rdiff -u -r1.414 -r1.415 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/parse.c
diff -u src/usr.bin/make/parse.c:1.414 src/usr.bin/make/parse.c:1.415
--- src/usr.bin/make/parse.c:1.414	Sat Oct 31 09:47:27 2020
+++ src/usr.bin/make/parse.c	Sat Oct 31 21:52:56 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.414 2020/10/31 09:47:27 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.415 2020/10/31 21:52:56 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.414 2020/10/31 09:47:27 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.415 2020/10/31 21:52:56 rillig Exp $");
 
 /* types and constants */
 
@@ -196,9 +196,9 @@ static GNode *mainNode;
 
 /* eval state */
 
-/* During parsing, the targets from the currently active dependency line,
- * or NULL if the current line does not belong to a dependency line, for
- * example because it is a variable assignment.
+/* During parsing, the targets from the left-hand side of the currently
+ * active dependency line, or NULL if the current line does not belong to a
+ * dependency line, for example because it is a variable assignment.
  *
  * See unit-tests/deptgt.mk, keyword "parse.c:targets". */
 static GNodeList *targets;



CVS commit: src/external/lgpl3/gmp/dist

2020-10-31 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Sat Oct 31 21:48:06 UTC 2020

Modified Files:
src/external/lgpl3/gmp/dist: config.sub

Log Message:
recognize some more G4 model names produced by config.guess
now native tools builds on ppc7447 and ppc7455 work again


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/lgpl3/gmp/dist/config.sub

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

Modified files:

Index: src/external/lgpl3/gmp/dist/config.sub
diff -u src/external/lgpl3/gmp/dist/config.sub:1.3 src/external/lgpl3/gmp/dist/config.sub:1.4
--- src/external/lgpl3/gmp/dist/config.sub:1.3	Sun Sep 27 00:30:26 2020
+++ src/external/lgpl3/gmp/dist/config.sub	Sat Oct 31 21:48:06 2020
@@ -112,7 +112,7 @@ powerpc601 | powerpc602  | \
 powerpc603 | powerpc603e | \
 powerpc604 | powerpc604e | \
 powerpc620 | powerpc630  | powerpc970  | \
-powerpc740 | powerpc7400 | powerpc7450 | powerpc750  | \
+powerpc740 | powerpc7400 | powerpc74[4-5][0-9] | powerpc750  | \
 powerpc801 | powerpc821 | powerpc823  | powerpc860 | \
 powerpc64)
   test_cpu=powerpc ;;



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 21:40:20 UTC 2020

Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: varmod-gmtime.exp varmod-localtime.exp

Log Message:
make(1): make parsing of the :gmtime and :localtime modifiers stricter

These variable modifiers accept an optional timestamp in seconds, to
select which date to print.  This feature is only used very rarely.  The
NetBSD build doesn't use it at all, and the FreeBSD build mainly uses
the plain modifiers :gmtime and :localtime, but not their optional
argument :gmtime=15.

Therefore, this change is not going to affect many builds.  Those that
are indeed affected had been wrong all the time anyway.

At parse time, these errors stop the build, as intended.  After that,
when the actual shell commands of the targets are expanded and run,
these errors don't stop anything, the build just continues as if nothing
had happened.  This is a general problem with Var_Parse, see the many
"handle errors" markers in the code.  Another problem is that on parse
errors, parsing continues and spits out spurious strings of the form
"mtime" and "ocaltime".  This as well is a general problem with error
handling in make.

ok sjg


To generate a diff of this commit:
cvs rdiff -u -r1.630 -r1.631 src/usr.bin/make/var.c
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-gmtime.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-localtime.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/var.c
diff -u src/usr.bin/make/var.c:1.630 src/usr.bin/make/var.c:1.631
--- src/usr.bin/make/var.c:1.630	Sat Oct 31 18:41:07 2020
+++ src/usr.bin/make/var.c	Sat Oct 31 21:40:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.630 2020/10/31 18:41:07 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.631 2020/10/31 21:40:20 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -119,6 +119,7 @@
 #include 
 #include 
 #endif
+#include 
 #include 
 #include 
 #include 
@@ -129,7 +130,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.630 2020/10/31 18:41:07 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.631 2020/10/31 21:40:20 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -2113,6 +2114,24 @@ ApplyModifier_Literal(const char **pp, A
 return AMR_OK;
 }
 
+static Boolean TryParseTime(const char **pp, time_t *out_time)
+{
+char *end;
+unsigned long n;
+
+if (!ch_isdigit(**pp))
+	return FALSE;
+
+errno = 0;
+n = strtoul(*pp, , 10);
+if (n == ULONG_MAX && errno == ERANGE)
+	return FALSE;
+
+*pp = end;
+*out_time = (time_t)n;	/* ignore possible truncation for now */
+return TRUE;
+}
+
 /* :gmtime */
 static ApplyModifierResult
 ApplyModifier_Gmtime(const char **pp, ApplyModifiersState *st)
@@ -2124,9 +2143,12 @@ ApplyModifier_Gmtime(const char **pp, Ap
 	return AMR_UNKNOWN;
 
 if (mod[6] == '=') {
-	char *ep;
-	utc = (time_t)strtoul(mod + 7, , 10);
-	*pp = ep;
+	const char *arg = mod + 7;
+	if (!TryParseTime(, )) {
+	Parse_Error(PARSE_FATAL, "Invalid time value: %s\n", mod + 7);
+	return AMR_CLEANUP;
+	}
+	*pp = arg;
 } else {
 	utc = 0;
 	*pp = mod + 6;
@@ -2146,9 +2168,12 @@ ApplyModifier_Localtime(const char **pp,
 	return AMR_UNKNOWN;
 
 if (mod[9] == '=') {
-	char *ep;
-	utc = (time_t)strtoul(mod + 10, , 10);
-	*pp = ep;
+	const char *arg = mod + 10;
+	if (!TryParseTime(, )) {
+	Parse_Error(PARSE_FATAL, "Invalid time value: %s\n", mod + 10);
+	return AMR_CLEANUP;
+	}
+	*pp = arg;
 } else {
 	utc = 0;
 	*pp = mod + 9;

Index: src/usr.bin/make/unit-tests/varmod-gmtime.exp
diff -u src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.5 src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.6
--- src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.5	Sat Oct 31 20:30:06 2020
+++ src/usr.bin/make/unit-tests/varmod-gmtime.exp	Sat Oct 31 21:40:20 2020
@@ -4,16 +4,24 @@ mod-gmtime:
 %Y
 localtime == localtime
 mod-gmtime-indirect:
-make: Unknown modifier '1'
+make: Invalid time value: ${:U1593536400}}
 
+mtime=1593536400}
 parse-errors:
-: -1 becomes Wed Dec 31 23:59:59 1969.
-: space 1 becomes Thu Jan  1 00:00:01 1970.
+make: Invalid time value: -1}.
+
+: -1 becomes mtime=-1}.
+make: Invalid time value:  1}.
+
+: space 1 becomes mtime= 1}.
 : 0 becomes ok.
 : 1 becomes Thu Jan  1 00:00:01 1970.
 : INT32_MAX becomes Tue Jan 19 03:14:07 2038.
 : INT32_MAX + 1 becomes Tue Jan 19 03:14:08 2038.
-: overflow becomes Wed Dec 31 23:59:59 1969.
-make: Unknown modifier 'e'
-: letter becomes .
+make: Invalid time value: 1000}.
+
+: overflow becomes mtime=1000}.
+make: Invalid time value: error}.
+
+: letter becomes mtime=error}.
 exit status 0

Index: 

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

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 21:30:03 UTC 2020

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

Log Message:
make(1): add test for debug log for expansion of curly braces


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/dir.exp \
src/usr.bin/make/unit-tests/dir.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/dir.exp
diff -u src/usr.bin/make/unit-tests/dir.exp:1.6 src/usr.bin/make/unit-tests/dir.exp:1.7
--- src/usr.bin/make/unit-tests/dir.exp:1.6	Sat Oct 31 21:12:36 2020
+++ src/usr.bin/make/unit-tests/dir.exp	Sat Oct 31 21:30:03 2020
@@ -1,3 +1,29 @@
+Searching for .depend ...
+   failed.
+Searching for .depend ...
+   / ...
+   failed.
+Expanding "{one,two,three}"... one two three
+Expanding "f{our,ive}"... four five
+Expanding "{{thi,fou}r,fif}teen"... Expanding "{thi,fou}rteen"... thirteen fourteen
+thirteen fourteen fifteen
+Expanding "{pre-,}{patch,configure}"... Expanding "pre-{patch,configure}"... pre-patch pre-configure
+Expanding "{patch,configure}"... pre-patch pre-configure patch configure
+pre-patch pre-configure patch configure
+Expanding "{fetch,extract}{,-post}"... Expanding "fetch{,-post}"... fetch fetch-post
+Expanding "extract{,-post}"... fetch fetch-post extract extract-post
+fetch fetch-post extract extract-post
+Expanding "dup-{1,1,1,1,1,1,1}"... dup-1 dup-1 dup-1 dup-1 dup-1 dup-1 dup-1
+Expanding "{{single-word}}"... Expanding "{single-word}"... Expanding "single-word"... Expanding "{{{single-word}}}"... Expanding "{{single-word}}"... Expanding "{single-word}"... Expanding "single-word"... Expanding "{{{single-word}}}"... Expanding "{{single-word}}"... Expanding "{single-word}"... single-word
+single-word
+single-word
+single-word
+single-word
+single-word
+single-word
+single-word
+single-word
+single-word
 : 1
 : 2
 : 3
@@ -16,4 +42,9 @@
 : extract-post
 : dup-1
 : single-word
+Searching for .END ...
+   failed.
+Searching for .END ...
+   failed.
+Found '.END' as '(not found)'
 exit status 0
Index: src/usr.bin/make/unit-tests/dir.mk
diff -u src/usr.bin/make/unit-tests/dir.mk:1.6 src/usr.bin/make/unit-tests/dir.mk:1.7
--- src/usr.bin/make/unit-tests/dir.mk:1.6	Sat Oct 31 21:12:36 2020
+++ src/usr.bin/make/unit-tests/dir.mk	Sat Oct 31 21:30:03 2020
@@ -1,11 +1,28 @@
-# $NetBSD: dir.mk,v 1.6 2020/10/31 21:12:36 rillig Exp $
+# $NetBSD: dir.mk,v 1.7 2020/10/31 21:30:03 rillig Exp $
 #
 # Tests for dir.c.
 
+.MAKEFLAGS: -m /		# hide /usr/share/mk from the debug log
+
 # Dependency lines may use braces for expansion.
 # See DirExpandCurly for the implementation.
 all: {one,two,three}
 
+# XXX: The above dependency line is parsed as a single node named
+# "{one,two,three}".  There are no individual targets "one", "two", "three"
+# yet.  The node exists but is not a target since it never appeared
+# on the left-hand side of a dependency operator.  However, it is listed
+# in .ALLTARGETS (which lists all nodes, not only targets).
+.if target(one)
+.  error
+.endif
+.if target({one,two,three})
+.  error
+.endif
+.if ${.ALLTARGETS:M{one,two,three}} != "{one,two,three}"
+.  error
+.endif
+
 one:
 	: 1
 two:
@@ -58,3 +75,19 @@ all: {{single-word}}
 
 single-word:
 	: $@
+
+# Demonstrate debug logging for filename expansion, especially curly braces.
+.MAKEFLAGS: -dd
+# The below line does not call Dir_Expand yet.
+# It is expanded only when necessary, that is, when the 'debug' target is
+# indeed made.
+debug: {{thi,fou}r,fif}twen
+# Therefore, keep the debug logging active.
+
+.PHONY: one two three four five six
+.PHONY: thirteen fourteen fifteen
+.PHONY: single-word
+.PHONY: pre-patch patch pre-configure configure
+.PHONY: fetch fetch-post extract extract-post
+.PHONY: dup-1 single-word
+.PHONY: all



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

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 21:12:36 UTC 2020

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

Log Message:
make(1): mark the output in test dir.mk with a prefix

This is needed to distinguish it from the debug log, which will be added
in the next commit.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/dir.exp \
src/usr.bin/make/unit-tests/dir.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/dir.exp
diff -u src/usr.bin/make/unit-tests/dir.exp:1.5 src/usr.bin/make/unit-tests/dir.exp:1.6
--- src/usr.bin/make/unit-tests/dir.exp:1.5	Fri Jul 31 20:16:21 2020
+++ src/usr.bin/make/unit-tests/dir.exp	Sat Oct 31 21:12:36 2020
@@ -1,19 +1,19 @@
-1
-2
-3
-4
-5
-13
-14
-15
-pre-patch
-pre-configure
-patch
-configure
-fetch
-fetch-post
-extract
-extract-post
-dup-1
-single-word
+: 1
+: 2
+: 3
+: 4
+: 5
+: 13
+: 14
+: 15
+: pre-patch
+: pre-configure
+: patch
+: configure
+: fetch
+: fetch-post
+: extract
+: extract-post
+: dup-1
+: single-word
 exit status 0
Index: src/usr.bin/make/unit-tests/dir.mk
diff -u src/usr.bin/make/unit-tests/dir.mk:1.5 src/usr.bin/make/unit-tests/dir.mk:1.6
--- src/usr.bin/make/unit-tests/dir.mk:1.5	Mon Sep  7 19:48:08 2020
+++ src/usr.bin/make/unit-tests/dir.mk	Sat Oct 31 21:12:36 2020
@@ -1,4 +1,4 @@
-# $NetBSD: dir.mk,v 1.5 2020/09/07 19:48:08 rillig Exp $
+# $NetBSD: dir.mk,v 1.6 2020/10/31 21:12:36 rillig Exp $
 #
 # Tests for dir.c.
 
@@ -7,54 +7,54 @@
 all: {one,two,three}
 
 one:
-	@echo 1
+	: 1
 two:
-	@echo 2
+	: 2
 three:
-	@echo 3
+	: 3
 
 # The braces may start in the middle of a word.
 all: f{our,ive}
 
 four:
-	@echo 4
+	: 4
 five:
-	@echo 5
+	: 5
 six:
-	@echo 6
+	: 6
 
 # Nested braces work as expected since 2020-07-31 19:06 UTC.
 # They had been broken at least since 2003-01-01, probably even longer.
 all: {{thi,fou}r,fif}teen
 
 thirteen:
-	@echo 13
+	: 13
 fourteen:
-	@echo 14
+	: 14
 fifteen:
-	@echo 15
+	: 15
 
 # There may be multiple brace groups side by side.
 all: {pre-,}{patch,configure}
 
 pre-patch patch pre-configure configure:
-	@echo $@
+	: $@
 
 # Empty pieces are allowed in the braces.
 all: {fetch,extract}{,-post}
 
 fetch fetch-post extract extract-post:
-	@echo $@
+	: $@
 
 # The expansions may have duplicates.
 # These are merged together because of the dependency line.
 all: dup-{1,1,1,1,1,1,1}
 
 dup-1:
-	@echo $@
+	: $@
 
 # Other than in Bash, the braces are also expanded if there is no comma.
 all: {{single-word}}
 
 single-word:
-	@echo $@
+	: $@



CVS commit: src/usr.bin/make

2020-10-31 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sat Oct 31 21:09:22 UTC 2020

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

Log Message:
Main_SetObjdir is first called for curdir which may be readonly

Skip access check if path is curdir.
This ensures that all proper initialization is done at least once.

If path is not curdir it should be writable to be useful.

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.419 -r1.420 src/usr.bin/make/main.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/main.c
diff -u src/usr.bin/make/main.c:1.419 src/usr.bin/make/main.c:1.420
--- src/usr.bin/make/main.c:1.419	Sat Oct 31 16:13:00 2020
+++ src/usr.bin/make/main.c	Sat Oct 31 21:09:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.419 2020/10/31 16:13:00 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.420 2020/10/31 21:09:22 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -118,7 +118,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.419 2020/10/31 16:13:00 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.420 2020/10/31 21:09:22 sjg Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	"The Regents of the University of California.  "
@@ -721,7 +721,9 @@ Main_SetObjdir(const char *fmt, ...)
 
 	/* look for the directory and try to chdir there */
 	if (stat(path, ) == 0 && S_ISDIR(sb.st_mode)) {
-		if (chdir(path)) {
+		/* if not .CURDIR it must be writable */
+		if ((strcmp(path, curdir) != 0 && access(path, W_OK) != 0) ||
+		chdir(path)) {
 			(void)fprintf(stderr, "make warning: %s: %s.\n",
   path, strerror(errno));
 		} else {



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

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 20:30:06 UTC 2020

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

Log Message:
make(1): add more tests for the variable modifier :localtime


To generate a diff of this commit:
cvs rdiff -u -r1.179 -r1.180 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-gmtime.exp \
src/usr.bin/make/unit-tests/varmod-localtime.mk
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-gmtime.mk
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-localtime.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.179 src/usr.bin/make/unit-tests/Makefile:1.180
--- src/usr.bin/make/unit-tests/Makefile:1.179	Sat Oct 31 11:30:57 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sat Oct 31 20:30:06 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.179 2020/10/31 11:30:57 rillig Exp $
+# $NetBSD: Makefile,v 1.180 2020/10/31 20:30:06 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -378,6 +378,7 @@ ENV.envfirst=		FROM_ENV=value-from-env
 ENV.varmisc=		FROM_ENV=env
 ENV.varmisc+=		FROM_ENV_BEFORE=env
 ENV.varmisc+=		FROM_ENV_AFTER=env
+ENV.varmod-localtime+=	TZ=Europe/Berlin
 
 # Override make flags for some of the tests; default is -k.
 # If possible, write ".MAKEFLAGS: -dv" in the test .mk file instead of

Index: src/usr.bin/make/unit-tests/varmod-gmtime.exp
diff -u src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.4 src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.5
--- src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.4	Sat Oct 31 19:55:26 2020
+++ src/usr.bin/make/unit-tests/varmod-gmtime.exp	Sat Oct 31 20:30:06 2020
@@ -2,7 +2,7 @@ mod-gmtime:
 %Y
 2020
 %Y
-%Y
+localtime == localtime
 mod-gmtime-indirect:
 make: Unknown modifier '1'
 
Index: src/usr.bin/make/unit-tests/varmod-localtime.mk
diff -u src/usr.bin/make/unit-tests/varmod-localtime.mk:1.4 src/usr.bin/make/unit-tests/varmod-localtime.mk:1.5
--- src/usr.bin/make/unit-tests/varmod-localtime.mk:1.4	Thu Oct 29 19:01:10 2020
+++ src/usr.bin/make/unit-tests/varmod-localtime.mk	Sat Oct 31 20:30:06 2020
@@ -1,7 +1,15 @@
-# $NetBSD: varmod-localtime.mk,v 1.4 2020/10/29 19:01:10 rillig Exp $
+# $NetBSD: varmod-localtime.mk,v 1.5 2020/10/31 20:30:06 rillig Exp $
 #
-# Tests for the :localtime variable modifier, which returns the given time,
-# formatted as a local timestamp.
+# Tests for the :localtime variable modifier, which formats a timestamp
+# using strftime(3) in local time.
+
+.if ${TZ} != "Europe/Berlin"	# see unit-tests/Makefile
+.  error
+.endif
+
+all:	mod-localtime
+all:	mod-localtime-indirect
+all:	parse-errors
 
 # Test for the default time format, %c.  Since the time always varies, it's
 # only possible to check for the general format here.  The names of the
@@ -11,7 +19,74 @@
 .  error
 .endif
 
-all:
-	@echo ${%Y:L:localtim=1593536400}	# modifier name too short
-	@echo ${%Y:L:localtime=1593536400}	# 2020-07-01T00:00:00Z
-	@echo ${%Y:L:localtimer=1593536400}	# modifier name too long
+mod-localtime:
+	@echo $@
+
+	# modifier name too short
+	@echo ${%Y:L:localtim=1593536400}
+
+	# 2020-07-01T00:00:00Z
+	@echo ${%Y:L:localtime=1593536400}
+
+	# modifier name too long
+	@echo ${%Y:L:localtimer=1593536400}
+
+	# If the modifier name is not matched exactly, fall back to the
+	# :from=to modifier.
+	@echo ${localtime:L:local%=gm%} == gmtime
+
+mod-localtime-indirect:
+	@echo $@:
+
+	# As of 2020-08-16, it is not possible to pass the seconds via a
+	# variable expression.  This is because parsing of the :localtime
+	# modifier stops at the '$' and returns to ApplyModifiers.
+	#
+	# There, a colon would be skipped but not a dollar.
+	# Parsing therefore continues at the '$' of the ${:U159...}, looking
+	# for an ordinary variable modifier.
+	#
+	# At this point, the ${:U} is expanded and interpreted as a variable
+	# modifier, which results in the error message "Unknown modifier '1'".
+	#
+	# If ApplyModifier_Localtime were to pass its argument through
+	# ParseModifierPart, this would work.
+	@echo ${%Y:L:localtime=${:U1593536400}}
+
+parse-errors:
+	@echo $@:
+
+	# As of 2020-10-31, it is possible to pass negative time stamps
+	# to the :localtime modifier, resulting in dates before 1970.
+	# Going back 50 years in the past is not a practical use case for
+	# make.
+	: -1 becomes ${:L:localtime=-1}.
+
+	# Spaces are allowed, not because it would make sense but just as
+	# a side-effect from using strtoul.
+	: space 1 becomes ${:L:localtime= 1}.
+
+	# 0 means now; to get consistent test results, the actual value has
+	# to be normalized.
+	: 0 becomes ${:L:localtime=0:C,^... ... .. ..:..:.. 20..$,ok,W}.
+
+	: 1 becomes ${:L:localtime=1}.
+
+	: INT32_MAX becomes 

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

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 19:55:26 UTC 2020

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

Log Message:
make(1): add test for :gmtime with space before the number of seconds


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-gmtime.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-gmtime.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-gmtime.exp
diff -u src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.3 src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.4
--- src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.3	Sat Oct 31 19:48:23 2020
+++ src/usr.bin/make/unit-tests/varmod-gmtime.exp	Sat Oct 31 19:55:26 2020
@@ -8,6 +8,7 @@ make: Unknown modifier '1'
 
 parse-errors:
 : -1 becomes Wed Dec 31 23:59:59 1969.
+: space 1 becomes Thu Jan  1 00:00:01 1970.
 : 0 becomes ok.
 : 1 becomes Thu Jan  1 00:00:01 1970.
 : INT32_MAX becomes Tue Jan 19 03:14:07 2038.

Index: src/usr.bin/make/unit-tests/varmod-gmtime.mk
diff -u src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.4 src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.5
--- src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.4	Sat Oct 31 19:48:23 2020
+++ src/usr.bin/make/unit-tests/varmod-gmtime.mk	Sat Oct 31 19:55:26 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-gmtime.mk,v 1.4 2020/10/31 19:48:23 rillig Exp $
+# $NetBSD: varmod-gmtime.mk,v 1.5 2020/10/31 19:55:26 rillig Exp $
 #
 # Tests for the :gmtime variable modifier, which formats a timestamp
 # using strftime(3).
@@ -49,6 +49,10 @@ parse-errors:
 	# make.
 	: -1 becomes ${:L:gmtime=-1}.
 
+	# Spaces are allowed, not because it would make sense but just as
+	# a side-effect from using strtoul.
+	: space 1 becomes ${:L:gmtime= 1}.
+
 	# 0 means now; to get consistent test results, the actual value has
 	# to be normalized.
 	: 0 becomes ${:L:gmtime=0:C,^... ... .. ..:..:.. 20..$,ok,W}.



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

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 19:48:23 UTC 2020

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

Log Message:
make(1): add tests for error handling in the :gmtime variable modifier


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-gmtime.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-gmtime.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-gmtime.exp
diff -u src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.2 src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.3
--- src/usr.bin/make/unit-tests/varmod-gmtime.exp:1.2	Sun Aug 16 12:48:55 2020
+++ src/usr.bin/make/unit-tests/varmod-gmtime.exp	Sat Oct 31 19:48:23 2020
@@ -6,4 +6,13 @@ mod-gmtime:
 mod-gmtime-indirect:
 make: Unknown modifier '1'
 
+parse-errors:
+: -1 becomes Wed Dec 31 23:59:59 1969.
+: 0 becomes ok.
+: 1 becomes Thu Jan  1 00:00:01 1970.
+: INT32_MAX becomes Tue Jan 19 03:14:07 2038.
+: INT32_MAX + 1 becomes Tue Jan 19 03:14:08 2038.
+: overflow becomes Wed Dec 31 23:59:59 1969.
+make: Unknown modifier 'e'
+: letter becomes .
 exit status 0

Index: src/usr.bin/make/unit-tests/varmod-gmtime.mk
diff -u src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.3 src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.4
--- src/usr.bin/make/unit-tests/varmod-gmtime.mk:1.3	Thu Oct 29 18:59:43 2020
+++ src/usr.bin/make/unit-tests/varmod-gmtime.mk	Sat Oct 31 19:48:23 2020
@@ -1,10 +1,11 @@
-# $NetBSD: varmod-gmtime.mk,v 1.3 2020/10/29 18:59:43 rillig Exp $
+# $NetBSD: varmod-gmtime.mk,v 1.4 2020/10/31 19:48:23 rillig Exp $
 #
 # Tests for the :gmtime variable modifier, which formats a timestamp
 # using strftime(3).
 
 all:	mod-gmtime
 all:	mod-gmtime-indirect
+all:	parse-errors
 
 # Test for the default time format, %c.  Since the time always varies, it's
 # only possible to check for the general format here.  The names of the
@@ -39,5 +40,38 @@ mod-gmtime-indirect:
 	# ParseModifierPart, this would work.
 	@echo ${%Y:L:gmtime=${:U1593536400}}
 
+parse-errors:
+	@echo $@:
+
+	# As of 2020-10-31, it is possible to pass negative time stamps
+	# to the :gmtime modifier, resulting in dates before 1970.
+	# Going back 50 years in the past is not a practical use case for
+	# make.
+	: -1 becomes ${:L:gmtime=-1}.
+
+	# 0 means now; to get consistent test results, the actual value has
+	# to be normalized.
+	: 0 becomes ${:L:gmtime=0:C,^... ... .. ..:..:.. 20..$,ok,W}.
+
+	: 1 becomes ${:L:gmtime=1}.
+
+	: INT32_MAX becomes ${:L:gmtime=2147483647}.
+
+	# This may be different if time_t is still a 32-bit signed integer.
+	: INT32_MAX + 1 becomes ${:L:gmtime=2147483648}.
+
+	# Integer overflow.
+	# Because this modifier is implemented using strtoul, the parsed
+	# time is ULONG_MAX, which gets converted to -1.  This results
+	# in a time stamp of the second before 1970.
+	: overflow becomes ${:L:gmtime=1000}.
+
+	# As of 2020-10-31, there is no error handling while parsing the
+	# :gmtime modifier, thus no error message is printed.  Parsing
+	# stops after the '=', and the remaining string is parsed for
+	# more variable modifiers.  Because of the unknown modifier 'e',
+	# the whole variable value is discarded and thus not printed.
+	: letter becomes ${:L:gmtime=error}.
+
 all:
 	@:;



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 18:41:07 UTC 2020

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

Log Message:
make(1): format #include directives consistently


To generate a diff of this commit:
cvs rdiff -u -r1.150 -r1.151 src/usr.bin/make/arch.c
cvs rdiff -u -r1.111 -r1.112 src/usr.bin/make/for.c
cvs rdiff -u -r1.184 -r1.185 src/usr.bin/make/make.c
cvs rdiff -u -r1.629 -r1.630 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.150 src/usr.bin/make/arch.c:1.151
--- src/usr.bin/make/arch.c:1.150	Sat Oct 31 11:54:33 2020
+++ src/usr.bin/make/arch.c	Sat Oct 31 18:41:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.150 2020/10/31 11:54:33 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.151 2020/10/31 18:41:07 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -117,20 +117,20 @@
  *	Arch_End	Clean up this module.
  */
 
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-#include"make.h"
-#include"dir.h"
-#include"config.h"
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include "make.h"
+#include "dir.h"
+#include "config.h"
 
 /*	"@(#)arch.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: arch.c,v 1.150 2020/10/31 11:54:33 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.151 2020/10/31 18:41:07 rillig Exp $");
 
 #ifdef TARGET_MACHINE
 #undef MAKE_MACHINE

Index: src/usr.bin/make/for.c
diff -u src/usr.bin/make/for.c:1.111 src/usr.bin/make/for.c:1.112
--- src/usr.bin/make/for.c:1.111	Mon Oct 26 07:37:52 2020
+++ src/usr.bin/make/for.c	Sat Oct 31 18:41:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: for.c,v 1.111 2020/10/26 07:37:52 rillig Exp $	*/
+/*	$NetBSD: for.c,v 1.112 2020/10/31 18:41:07 rillig Exp $	*/
 
 /*
  * Copyright (c) 1992, The Regents of the University of California.
@@ -57,10 +57,10 @@
  *	For_Run		Run accumulated loop
  */
 
-#include"make.h"
+#include "make.h"
 
 /*	"@(#)for.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: for.c,v 1.111 2020/10/26 07:37:52 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.112 2020/10/31 18:41:07 rillig Exp $");
 
 /* The .for loop substitutes the items as ${:U...}, which means
  * that characters that break this syntax must be backslash-escaped. */

Index: src/usr.bin/make/make.c
diff -u src/usr.bin/make/make.c:1.184 src/usr.bin/make/make.c:1.185
--- src/usr.bin/make/make.c:1.184	Sat Oct 31 11:54:33 2020
+++ src/usr.bin/make/make.c	Sat Oct 31 18:41:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.184 2020/10/31 11:54:33 rillig Exp $	*/
+/*	$NetBSD: make.c,v 1.185 2020/10/31 18:41:07 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -102,12 +102,12 @@
  *	Make_ExpandUse	Expand .USE nodes
  */
 
-#include"make.h"
-#include"dir.h"
-#include"job.h"
+#include "make.h"
+#include "dir.h"
+#include "job.h"
 
 /*	"@(#)make.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: make.c,v 1.184 2020/10/31 11:54:33 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.185 2020/10/31 18:41:07 rillig Exp $");
 
 /* Sequence # to detect recursion. */
 static unsigned int checked = 1;

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.629 src/usr.bin/make/var.c:1.630
--- src/usr.bin/make/var.c:1.629	Sat Oct 31 18:17:08 2020
+++ src/usr.bin/make/var.c	Sat Oct 31 18:41:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.629 2020/10/31 18:17:08 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.630 2020/10/31 18:41:07 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -114,22 +114,22 @@
  * XXX: There's a lot of duplication in these functions.
  */
 
-#include
+#include 
 #ifndef NO_REGEX
-#include
-#include
+#include 
+#include 
 #endif
-#include
-#include
-#include
-
-#include"make.h"
-#include"dir.h"
-#include"job.h"
-#include"metachar.h"
+#include 
+#include 
+#include 
+
+#include "make.h"
+#include "dir.h"
+#include "job.h"
+#include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.629 2020/10/31 18:17:08 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.630 2020/10/31 18:41:07 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 18:20:01 UTC 2020

Modified Files:
src/usr.bin/make: compat.c metachar.h

Log Message:
make(1): remove unused code from needshell

Since usr.bin/xinstall no longer uses this code, there is no need to
keep the second parameter.


To generate a diff of this commit:
cvs rdiff -u -r1.171 -r1.172 src/usr.bin/make/compat.c
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/metachar.h

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/compat.c
diff -u src/usr.bin/make/compat.c:1.171 src/usr.bin/make/compat.c:1.172
--- src/usr.bin/make/compat.c:1.171	Sat Oct 31 11:54:33 2020
+++ src/usr.bin/make/compat.c	Sat Oct 31 18:20:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.171 2020/10/31 11:54:33 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.172 2020/10/31 18:20:00 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
 #include "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.171 2020/10/31 11:54:33 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.172 2020/10/31 18:20:00 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -267,7 +267,7 @@ Compat_RunCommand(const char *cmdp, GNod
  * meta characters as documented in make(1).
  */
 
-useShell = needshell(cmd, FALSE);
+useShell = needshell(cmd);
 #endif
 
 /*

Index: src/usr.bin/make/metachar.h
diff -u src/usr.bin/make/metachar.h:1.10 src/usr.bin/make/metachar.h:1.11
--- src/usr.bin/make/metachar.h:1.10	Sat Oct 31 18:17:08 2020
+++ src/usr.bin/make/metachar.h	Sat Oct 31 18:20:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: metachar.h,v 1.10 2020/10/31 18:17:08 rillig Exp $	*/
+/*	$NetBSD: metachar.h,v 1.11 2020/10/31 18:20:00 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -38,14 +38,10 @@ extern unsigned char _metachar[];
 #define is_shell_metachar(c)	_metachar[(c) & 0x7f]
 
 static inline MAKE_ATTR_UNUSED int
-needshell(const char *cmd, int white)
+needshell(const char *cmd)
 {
-	while (!is_shell_metachar(*cmd) && *cmd != ':' && *cmd != '=') {
-		if (white && ch_isspace(*cmd))
-			break;
+	while (!is_shell_metachar(*cmd) && *cmd != ':' && *cmd != '=')
 		cmd++;
-	}
-
 	return *cmd != '\0';
 }
 



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 18:17:08 UTC 2020

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

Log Message:
make(1): rename ismeta to is_shell_metachar

The old name was too broad.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/metachar.h
cvs rdiff -u -r1.628 -r1.629 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/metachar.h
diff -u src/usr.bin/make/metachar.h:1.9 src/usr.bin/make/metachar.h:1.10
--- src/usr.bin/make/metachar.h:1.9	Sun Sep 13 15:27:25 2020
+++ src/usr.bin/make/metachar.h	Sat Oct 31 18:17:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: metachar.h,v 1.9 2020/09/13 15:27:25 rillig Exp $	*/
+/*	$NetBSD: metachar.h,v 1.10 2020/10/31 18:17:08 rillig Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -35,12 +35,12 @@
 
 extern unsigned char _metachar[];
 
-#define ismeta(c)	_metachar[(c) & 0x7f]
+#define is_shell_metachar(c)	_metachar[(c) & 0x7f]
 
 static inline MAKE_ATTR_UNUSED int
 needshell(const char *cmd, int white)
 {
-	while (!ismeta(*cmd) && *cmd != ':' && *cmd != '=') {
+	while (!is_shell_metachar(*cmd) && *cmd != ':' && *cmd != '=') {
 		if (white && ch_isspace(*cmd))
 			break;
 		cmd++;

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.628 src/usr.bin/make/var.c:1.629
--- src/usr.bin/make/var.c:1.628	Sat Oct 31 18:14:59 2020
+++ src/usr.bin/make/var.c	Sat Oct 31 18:17:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.628 2020/10/31 18:14:59 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.629 2020/10/31 18:17:08 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include"metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.628 2020/10/31 18:14:59 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.629 2020/10/31 18:17:08 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -1647,7 +1647,7 @@ VarQuote(const char *str, Boolean quoteD
 	Buf_AddStr(, newline);
 	continue;
 	}
-	if (ch_isspace(*str) || ismeta((unsigned char)*str))
+	if (ch_isspace(*str) || is_shell_metachar((unsigned char)*str))
 	Buf_AddByte(, '\\');
 	Buf_AddByte(, *str);
 	if (quoteDollar && *str == '$')



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 18:14:59 UTC 2020

Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: vardebug.exp

Log Message:
make(1): remove debug logging for the :Q variable modifier

The same information is already logged in LogAfterApply.


To generate a diff of this commit:
cvs rdiff -u -r1.627 -r1.628 src/usr.bin/make/var.c
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/vardebug.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/var.c
diff -u src/usr.bin/make/var.c:1.627 src/usr.bin/make/var.c:1.628
--- src/usr.bin/make/var.c:1.627	Sat Oct 31 18:05:16 2020
+++ src/usr.bin/make/var.c	Sat Oct 31 18:14:59 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.627 2020/10/31 18:05:16 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.628 2020/10/31 18:14:59 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include"metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.627 2020/10/31 18:05:16 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.628 2020/10/31 18:14:59 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -1636,7 +1636,6 @@ VarUniq(const char *str)
 static char *
 VarQuote(const char *str, Boolean quoteDollar)
 {
-char *res;
 Buffer buf;
 Buf_Init(, 0);
 
@@ -1655,9 +1654,7 @@ VarQuote(const char *str, Boolean quoteD
 	Buf_AddStr(, "\\$");
 }
 
-res = Buf_Destroy(, FALSE);
-VAR_DEBUG1("QuoteMeta: [%s]\n", res);
-return res;
+return Buf_Destroy(, FALSE);
 }
 
 /* Compute the 32-bit hash of the given string, using the MurmurHash3

Index: src/usr.bin/make/unit-tests/vardebug.exp
diff -u src/usr.bin/make/unit-tests/vardebug.exp:1.11 src/usr.bin/make/unit-tests/vardebug.exp:1.12
--- src/usr.bin/make/unit-tests/vardebug.exp:1.11	Thu Oct 29 18:38:24 2020
+++ src/usr.bin/make/unit-tests/vardebug.exp	Sat Oct 31 18:14:59 2020
@@ -38,7 +38,6 @@ ModifyWords: split "1 2 3" into 3 words
 Result of ${VAR:S,2,two,} is "1 two 3" (VARE_UNDEFERR|VARE_WANTRES, none, none)
 Var_Parse: ${VAR:Q} with VARE_UNDEFERR|VARE_WANTRES
 Applying ${VAR:Q} to "1 2 3" (VARE_UNDEFERR|VARE_WANTRES, none, none)
-QuoteMeta: [1\ 2\ 3]
 Result of ${VAR:Q} is "1\ 2\ 3" (VARE_UNDEFERR|VARE_WANTRES, none, none)
 Var_Parse: ${VAR:tu:tl:Q} with VARE_UNDEFERR|VARE_WANTRES
 Applying ${VAR:t...} to "1 2 3" (VARE_UNDEFERR|VARE_WANTRES, none, none)
@@ -46,7 +45,6 @@ Result of ${VAR:tu} is "1 2 3" (VARE_UND
 Applying ${VAR:t...} to "1 2 3" (VARE_UNDEFERR|VARE_WANTRES, none, none)
 Result of ${VAR:tl} is "1 2 3" (VARE_UNDEFERR|VARE_WANTRES, none, none)
 Applying ${VAR:Q} to "1 2 3" (VARE_UNDEFERR|VARE_WANTRES, none, none)
-QuoteMeta: [1\ 2\ 3]
 Result of ${VAR:Q} is "1\ 2\ 3" (VARE_UNDEFERR|VARE_WANTRES, none, none)
 Var_Parse: ${:Uvalue:${:UM*e}:Mvalu[e]} with VARE_UNDEFERR|VARE_WANTRES
 Applying ${:U...} to "" (VARE_UNDEFERR|VARE_WANTRES, none, VEF_UNDEF)



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 18:05:16 UTC 2020

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

Log Message:
make(1): fix local variable names in ParseModifierPart


To generate a diff of this commit:
cvs rdiff -u -r1.626 -r1.627 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.626 src/usr.bin/make/var.c:1.627
--- src/usr.bin/make/var.c:1.626	Sat Oct 31 15:23:52 2020
+++ src/usr.bin/make/var.c	Sat Oct 31 18:05:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.626 2020/10/31 15:23:52 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.627 2020/10/31 18:05:16 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include"metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.626 2020/10/31 15:23:52 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.627 2020/10/31 18:05:16 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -1955,15 +1955,15 @@ ParseModifierPart(
 	 * and suck it in without further ado.
 	 * It will be interpreted later.
 	 */
-	char have = p[1];
-	int want = have == '(' ? ')' : '}';
+	char startc = p[1];
+	int endc = startc == '(' ? ')' : '}';
 	int depth = 1;
 
 	for (p += 2; *p != '\0' && depth > 0; p++) {
 		if (p[-1] != '\\') {
-		if (*p == have)
+		if (*p == startc)
 			depth++;
-		if (*p == want)
+		if (*p == endc)
 			depth--;
 		}
 	}



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 17:39:20 UTC 2020

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

Log Message:
make(1): remove dead code for filename expansion using curly braces

Any string containing curly braces is already handled in the very first
if statement.


To generate a diff of this commit:
cvs rdiff -u -r1.192 -r1.193 src/usr.bin/make/dir.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/dir.c
diff -u src/usr.bin/make/dir.c:1.192 src/usr.bin/make/dir.c:1.193
--- src/usr.bin/make/dir.c:1.192	Fri Oct 30 15:39:17 2020
+++ src/usr.bin/make/dir.c	Sat Oct 31 17:39:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.192 2020/10/30 15:39:17 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.193 2020/10/31 17:39:20 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -134,7 +134,7 @@
 #include "job.h"
 
 /*	"@(#)dir.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: dir.c,v 1.192 2020/10/30 15:39:17 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.193 2020/10/31 17:39:20 rillig Exp $");
 
 #define DIR_DEBUG0(text) DEBUG0(DIR, text)
 #define DIR_DEBUG1(fmt, arg1) DEBUG1(DIR, fmt, arg1)
@@ -790,17 +790,12 @@ Dir_Expand(const char *word, SearchPath 
 	 * in the string.
 	 */
 	for (cp = word; *cp; cp++) {
-		if (*cp == '?' || *cp == '[' || *cp == '*' || *cp == '{') {
+		if (*cp == '?' || *cp == '[' || *cp == '*') {
 		break;
 		}
 	}
-	if (*cp == '{') {
-		/*
-		 * This one will be fun.
-		 */
-		DirExpandCurly(word, cp, path, expansions);
-		return;
-	} else if (*cp != '\0') {
+
+	if (*cp != '\0') {
 		/*
 		 * Back up to the start of the component
 		 */



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 16:13:00 UTC 2020

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

Log Message:
make(1): revert requiring a writable objdir

The change in main.c 1.413 broke the NetBSD build.sh if it uses a
read-only source tree, as in the daily builds.

Original commit:
https://mail-index.netbsd.org/source-changes/2020/10/31/msg123560.html

Build log:
make warning: /home/source/ab/HEAD/src: Permission denied.
[1]   Segmentation fault  "${make}" -m ${T...


To generate a diff of this commit:
cvs rdiff -u -r1.418 -r1.419 src/usr.bin/make/main.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/main.c
diff -u src/usr.bin/make/main.c:1.418 src/usr.bin/make/main.c:1.419
--- src/usr.bin/make/main.c:1.418	Sat Oct 31 11:34:30 2020
+++ src/usr.bin/make/main.c	Sat Oct 31 16:13:00 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.418 2020/10/31 11:34:30 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.419 2020/10/31 16:13:00 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -118,7 +118,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.418 2020/10/31 11:34:30 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.419 2020/10/31 16:13:00 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	"The Regents of the University of California.  "
@@ -721,7 +721,7 @@ Main_SetObjdir(const char *fmt, ...)
 
 	/* look for the directory and try to chdir there */
 	if (stat(path, ) == 0 && S_ISDIR(sb.st_mode)) {
-		if (access(path, W_OK) || chdir(path)) {
+		if (chdir(path)) {
 			(void)fprintf(stderr, "make warning: %s: %s.\n",
   path, strerror(errno));
 		} else {



CVS commit: src/share/man/man9

2020-10-31 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Oct 31 16:03:01 UTC 2020

Modified Files:
src/share/man/man9: kfilter_register.9

Log Message:
document f_touch


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/share/man/man9/kfilter_register.9

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

Modified files:

Index: src/share/man/man9/kfilter_register.9
diff -u src/share/man/man9/kfilter_register.9:1.10 src/share/man/man9/kfilter_register.9:1.11
--- src/share/man/man9/kfilter_register.9:1.10	Wed Apr 30 09:10:58 2008
+++ src/share/man/man9/kfilter_register.9	Sat Oct 31 12:03:01 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: kfilter_register.9,v 1.10 2008/04/30 13:10:58 martin Exp $
+.\"	$NetBSD: kfilter_register.9,v 1.11 2020/10/31 16:03:01 christos Exp $
 .\"
 .\" Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd October 23, 2002
+.Dd October 31, 2020
 .Dt KFILTER_REGISTER 9
 .Os
 .Sh NAME
@@ -97,6 +97,11 @@ struct filterops {
 /* called when knote is DELETEd */
 	int	(*f_event)(struct knote *kn, long hint);
 /* called when event is triggered */
+	void	(*f_touch)(struct knote *kn, struct kevent *kev, long hint);
+/* called during registration and event 
+ * processing to provide custom handling 
+ * of event fflags and data
+ */
 };
 .Ed
 .Pp



CVS commit: src/lib/libnvmm

2020-10-31 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sat Oct 31 15:44:01 UTC 2020

Modified Files:
src/lib/libnvmm: libnvmm_x86.c

Log Message:
Revert (REPE) CMPS support per request of Maxime, it is incorrect.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/lib/libnvmm/libnvmm_x86.c

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

Modified files:

Index: src/lib/libnvmm/libnvmm_x86.c
diff -u src/lib/libnvmm/libnvmm_x86.c:1.41 src/lib/libnvmm/libnvmm_x86.c:1.42
--- src/lib/libnvmm/libnvmm_x86.c:1.41	Fri Oct 30 21:06:13 2020
+++ src/lib/libnvmm/libnvmm_x86.c	Sat Oct 31 15:44:01 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: libnvmm_x86.c,v 1.41 2020/10/30 21:06:13 reinoud Exp $	*/
+/*	$NetBSD: libnvmm_x86.c,v 1.42 2020/10/31 15:44:01 reinoud Exp $	*/
 
 /*
  * Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net
@@ -1051,7 +1051,6 @@ struct x86_opcode {
 	bool movs:1;
 	bool stos:1;
 	bool lods:1;
-	bool cmps:1;
 	bool szoverride:1;
 	bool group1:1;
 	bool group3:1;
@@ -1464,26 +1463,6 @@ static const struct x86_opcode primary_o
 	},
 
 	/*
-	 * CMPS
-	 */
-	[0xA6] = {
-		/* Yb, Xb */
-		.valid = true,
-		.cmps = true,
-		.szoverride = false,
-		.defsize = OPSIZE_BYTE,
-		.emul = _emul_cmp
-	},
-	[0xA7] = {
-		/* Yv, Xv */
-		.valid = true,
-		.cmps = true,
-		.szoverride = true,
-		.defsize = -1,
-		.emul = _emul_cmp
-	},
-
-	/*
 	 * STOS
 	 */
 	[0xAA] = {
@@ -1892,35 +1871,6 @@ node_movs(struct x86_decode_fsm *fsm, st
 }
 
 /*
- * Special node, for CMPS. Fake two displacements of zero on the source and
- * destination registers.
- * XXX coded as clone of movs as its similar in register usage
- * XXX might be merged with node_movs()
- */
-static int
-node_cmps(struct x86_decode_fsm *fsm, struct x86_instr *instr)
-{
-	size_t adrsize;
-
-	adrsize = instr->address_size;
-
-	/* DS:RSI */
-	instr->src.type = STORE_REG;
-	instr->src.u.reg = _map__special[1][2][adrsize-1];
-	instr->src.disp.type = DISP_0;
-
-	/* ES:RDI, force ES */
-	instr->dst.type = STORE_REG;
-	instr->dst.u.reg = _map__special[1][3][adrsize-1];
-	instr->dst.disp.type = DISP_0;
-	instr->dst.hardseg = NVMM_X64_SEG_ES;
-
-	fsm_advance(fsm, 0, NULL);
-
-	return 0;
-}
-
-/*
  * Special node, for STOS and LODS. Fake a displacement of zero on the
  * destination register.
  */
@@ -2520,8 +2470,6 @@ node_primary_opcode(struct x86_decode_fs
 		fsm_advance(fsm, 1, node_stlo);
 	} else if (opcode->movs) {
 		fsm_advance(fsm, 1, node_movs);
-	} else if (opcode->cmps) {
-		fsm_advance(fsm, 1, node_cmps);
 	} else {
 		return -1;
 	}
@@ -2698,16 +2646,8 @@ x86_decode(uint8_t *inst_bytes, size_t i
 
 	while (fsm.fn != NULL) {
 		ret = (*fsm.fn)(, instr);
-		if (ret == -1) {
-			printf("\nNVMM: %s missing support for instruction " \
-			   "with max length %ld : [ ", __func__,
-			   inst_len);
-			for (uint i = 0; i < inst_len; i++)
-printf("%02x ", inst_bytes[i]);
-			printf("], please report to NetBSD!\n\n");
-			fflush(stdout);
+		if (ret == -1)
 			return -1;
-		}
 	}
 
 	instr->len = fsm.buf - inst_bytes;



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 15:23:52 UTC 2020

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

Log Message:
make(1): rewrite VarIsDynamic to VarnameIsDynamic

The condition for the context is the same for both short and long names,
therefore move that condition to the only caller.

Clean up the comment and move its parts to the appropriate places.  The
"with the dollar sign escaped" part had been wrong already in 1993, and
it didn't get better over time.


To generate a diff of this commit:
cvs rdiff -u -r1.625 -r1.626 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.625 src/usr.bin/make/var.c:1.626
--- src/usr.bin/make/var.c:1.625	Sat Oct 31 14:55:33 2020
+++ src/usr.bin/make/var.c	Sat Oct 31 15:23:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.625 2020/10/31 14:55:33 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.626 2020/10/31 15:23:52 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include"metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.625 2020/10/31 14:55:33 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.626 2020/10/31 15:23:52 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -3326,23 +3326,13 @@ cleanup:
 return var_Error;
 }
 
+/* Only four of the local variables are treated specially as they are the
+ * only four that will be set when dynamic sources are expanded. */
 static Boolean
-VarIsDynamic(GNode *ctxt, const char *varname, size_t namelen)
+VarnameIsDynamic(const char *name, size_t len)
 {
-if ((namelen == 1 ||
-	 (namelen == 2 && (varname[1] == 'F' || varname[1] == 'D'))) &&
-	(ctxt == VAR_CMDLINE || ctxt == VAR_GLOBAL))
-{
-	/*
-	 * If substituting a local variable in a non-local context,
-	 * assume it's for dynamic source stuff. We have to handle
-	 * this specially and return the longhand for the variable
-	 * with the dollar sign escaped so it makes it back to the
-	 * caller. Only four of the local variables are treated
-	 * specially as they are the only four that will be set
-	 * when dynamic sources are expanded.
-	 */
-	switch (varname[0]) {
+if (len == 1 || (len == 2 && (name[1] == 'F' || name[1] == 'D'))) {
+	switch (name[0]) {
 	case '@':
 	case '%':
 	case '*':
@@ -3352,13 +3342,11 @@ VarIsDynamic(GNode *ctxt, const char *va
 	return FALSE;
 }
 
-if ((namelen == 7 || namelen == 8) && varname[0] == '.' &&
-	ch_isupper(varname[1]) && (ctxt == VAR_CMDLINE || ctxt == VAR_GLOBAL))
-{
-	return strcmp(varname, ".TARGET") == 0 ||
-	   strcmp(varname, ".ARCHIVE") == 0 ||
-	   strcmp(varname, ".PREFIX") == 0 ||
-	   strcmp(varname, ".MEMBER") == 0;
+if ((len == 7 || len == 8) && name[0] == '.' && ch_isupper(name[1])) {
+	return strcmp(name, ".TARGET") == 0 ||
+	   strcmp(name, ".ARCHIVE") == 0 ||
+	   strcmp(name, ".PREFIX") == 0 ||
+	   strcmp(name, ".MEMBER") == 0;
 }
 
 return FALSE;
@@ -3587,7 +3575,10 @@ ParseVarnameLong(
 }
 
 if (v == NULL) {
-	dynamic = VarIsDynamic(ctxt, varname, namelen);
+	/* Defer expansion of dynamic variables if they appear in non-local
+	 * context since they are not defined there. */
+	dynamic = VarnameIsDynamic(varname, namelen) &&
+		  (ctxt == VAR_CMDLINE || ctxt == VAR_GLOBAL);
 
 	if (!haveModifier) {
 	p++;		/* skip endc */
@@ -3714,7 +3705,7 @@ Var_Parse(const char **pp, GNode *ctxt, 
 char eflags_str[VarEvalFlags_ToStringSize];
 VarExprFlags exprFlags = 0;
 
-VAR_DEBUG3("%s: %s with %s\n", __func__, start,
+VAR_DEBUG2("Var_Parse: %s with %s\n", start,
 	   Enum_FlagsToString(eflags_str, sizeof eflags_str, eflags,
   VarEvalFlags_ToStringSpecs));
 



CVS commit: src/sys/arch/riscv/riscv

2020-10-31 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct 31 15:18:09 UTC 2020

Modified Files:
src/sys/arch/riscv/riscv: locore.S

Log Message:
Use the 'mv' pseudo-instruction instead of the 'move' equivalent as 'mv'
is mentioned in the ISA documentation and it's used elsewhere.  That is,
let's use 'mv' everywhere for consistency.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/riscv/riscv/locore.S

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

Modified files:

Index: src/sys/arch/riscv/riscv/locore.S
diff -u src/sys/arch/riscv/riscv/locore.S:1.12 src/sys/arch/riscv/riscv/locore.S:1.13
--- src/sys/arch/riscv/riscv/locore.S:1.12	Sat Mar 14 16:12:16 2020
+++ src/sys/arch/riscv/riscv/locore.S	Sat Oct 31 15:18:09 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.12 2020/03/14 16:12:16 skrll Exp $ */
+/* $NetBSD: locore.S,v 1.13 2020/10/31 15:18:09 skrll Exp $ */
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -75,7 +75,7 @@ ENTRY_NP(start)
 #ifdef _LP64
 	add	s3, s2, s10		// s3 = second PDE page (RV64 only)
 #else
-	move	s3, 22
+	mv	s3, 22
 #endif
 	add	s4, s3, s10		// s4 = first kernel PTE page
 	add	s5, s1, s9		// s5 = kernel_end
@@ -187,7 +187,7 @@ ENTRY_NP(cpu_switchto)
 
 	csrrci	t0, sstatus, SR_EI	// # disable interrupts
 
-	move	tp, a1			// # put the new lwp in thread pointer
+	mv	tp, a1			// # put the new lwp in thread pointer
 
 	PTR_L	t1, L_CPU(tp)		// # get curcpu
 	PTR_S	tp, CI_CURLWP(t1)	// # update curcpu with the new curlwp
@@ -221,10 +221,10 @@ ENTRY_NP(cpu_switchto)
 END(cpu_switchto)
 
 ENTRY_NP(cpu_lwp_trampoline)
-	move	a1, tp			// get new lwp
+	mv	a1, tp			// get new lwp
 	call	_C_LABEL(lwp_startup)	// call lwp startup
 
-	move	a0, s1			// get saved arg
+	mv	a0, s1			// get saved arg
 	jalr	s0			// call saved func
 
 	// If the saved func returns, we are returning to user land.
@@ -271,8 +271,8 @@ ENTRY_NP(cpu_fast_switchto)
 	csrr	t4, sstatus		// get status register (for intr state)
 	REG_S	t4, TF_SR(sp)		// save it
 
-	move	s0, tp			// remember curlwp
-	move	s1, sp			// remember kernel stack
+	mv	s0, tp			// remember curlwp
+	mv	s1, sp			// remember kernel stack
 
 #if 0
 	csrrci	t0, sstatus, SR_EI	// disable interrupts
@@ -280,7 +280,7 @@ ENTRY_NP(cpu_fast_switchto)
 	PTR_L	t1, L_CPU(tp)		// get curcpu()
 
 	PTR_S	sp, L_MD_KTF(tp)	// save trapframe ptr in oldlwp
-	move	tp, a0			// set thread pointer to newlwp
+	mv	tp, a0			// set thread pointer to newlwp
 	PTR_S	tp, CI_CURLWP(t1)	// update curlwp
 	PTR_L	sp, L_MD_KTF(tp)	// switch to its stack
 #if 0
@@ -291,12 +291,12 @@ ENTRY_NP(cpu_fast_switchto)
 	csrrci	t0, sstatus, SR_EI	// disable interrupts
 #endif
 	PTR_L	t1, L_CPU(tp)		// get curcpu() again
-	move	tp, s0			// return to pinned lwp
+	mv	tp, s0			// return to pinned lwp
 	PTR_S	tp, CI_CURLWP(t1)	// restore curlwp
 #if 0
 	csrw	sstatus, t0		// reeanble interrupts
 #endif
-	move	sp, s1			// restore stack pointer
+	mv	sp, s1			// restore stack pointer
 
 	REG_L	ra, (TF_RA + CALLFRAME_RA)(sp)	// get return address
 	REG_L	s0, TF_S0(sp)		// restore register we used
@@ -365,7 +365,7 @@ ENTRY_NP(cpu_exception_handler)
 	REG_S	t6, TF_T6(sp)		// save t6
 
 	// Now we get the
-	move	a0, sp			// trapframe pointer
+	mv	a0, sp			// trapframe pointer
 	csrr	a1, sepc		// get execption pc
 	csrr	a2, sstatus		// get status
 	csrr	a3, scause		// get cause
@@ -480,7 +480,7 @@ intr_usersave:
 	REG_S	s11, TF_S11(sp)		// only save from userland
 	PTR_LA	ra, exception_userexit
 trap_doast:
-	move	a0, sp			// only argument is trapframe
+	mv	a0, sp			// only argument is trapframe
 	tail	_C_LABEL(cpu_ast)
 
 intr_user:
@@ -555,7 +555,7 @@ ENTRY(longjmp)
 	REG_L	s10, FB_S10(a0)
 	REG_L	s11, FB_S11(a0)
 	REG_L	sp, FB_SP(a0)
-	move	a0, a1
+	mv	a0, a1
 	ret
 END(longjmp)
 



CVS commit: src/tests/kernel/kqueue

2020-10-31 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Oct 31 14:57:02 UTC 2020

Modified Files:
src/tests/kernel/kqueue: t_ioctl.c

Log Message:
Avoid hard-coding names and limits so this will not break again.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/kernel/kqueue/t_ioctl.c

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

Modified files:

Index: src/tests/kernel/kqueue/t_ioctl.c
diff -u src/tests/kernel/kqueue/t_ioctl.c:1.4 src/tests/kernel/kqueue/t_ioctl.c:1.5
--- src/tests/kernel/kqueue/t_ioctl.c:1.4	Tue Jan  9 12:35:29 2018
+++ src/tests/kernel/kqueue/t_ioctl.c	Sat Oct 31 10:57:02 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ioctl.c,v 1.4 2018/01/09 17:35:29 martin Exp $ */
+/* $NetBSD: t_ioctl.c,v 1.5 2020/10/31 14:57:02 christos Exp $ */
 
 /*-
  * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@@ -32,8 +32,9 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2008\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_ioctl.c,v 1.4 2018/01/09 17:35:29 martin Exp $");
+__RCSID("$NetBSD: t_ioctl.c,v 1.5 2020/10/31 14:57:02 christos Exp $");
 
+#define EVFILT_NAMES
 #include 
 #include 
 
@@ -61,13 +62,13 @@ ATF_TC_BODY(kfilter_byfilter, tc)
 	km.name = buf;
 	km.len = sizeof(buf) - 1;
 
-	for (i = 0; i < 8; ++i) {
+	for (i = 0; i < EVFILT_SYSCOUNT; ++i) {
 		km.filter = i;
 		RL(ioctl(kq, KFILTER_BYFILTER, ));
 		(void)printf("  map %d -> %s\n", km.filter, km.name);
 	}
 
-	km.filter = 8;
+	km.filter = EVFILT_SYSCOUNT;
 	ATF_REQUIRE_EQ(ioctl(kq, KFILTER_BYFILTER, ), -1);
 }
 
@@ -78,28 +79,16 @@ ATF_TC_HEAD(kfilter_byname, tc)
 }
 ATF_TC_BODY(kfilter_byname, tc)
 {
-	const char *tests[] = {
-		"EVFILT_READ",
-		"EVFILT_WRITE",
-		"EVFILT_AIO",
-		"EVFILT_VNODE",
-		"EVFILT_PROC",
-		"EVFILT_SIGNAL",
-		"EVFILT_TIMER",
-		"EVFILT_FS",
-		NULL
-	};
 	char buf[32];
 	struct kfilter_mapping km;
-	const char **test;
 	int kq;
 
 	RL(kq = kqueue());
 
 	km.name = buf;
 
-	for (test = [0]; *test != NULL; ++test) {
-		(void)strlcpy(buf, *test, sizeof(buf));
+	for (size_t i = 0; i < EVFILT_SYSCOUNT; i++) {
+		(void)strlcpy(buf, evfiltnames[i], sizeof(buf));
 		RL(ioctl(kq, KFILTER_BYNAME, ));
 		(void)printf("  map %s -> %d\n", km.name, km.filter);
 	}



CVS commit: src/sys/sys

2020-10-31 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Oct 31 14:55:53 UTC 2020

Modified Files:
src/sys/sys: event.h

Log Message:
Add an array of filter names.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/sys/event.h

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

Modified files:

Index: src/sys/sys/event.h
diff -u src/sys/sys/event.h:1.39 src/sys/sys/event.h:1.40
--- src/sys/sys/event.h:1.39	Fri Oct 30 21:08:32 2020
+++ src/sys/sys/event.h	Sat Oct 31 10:55:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: event.h,v 1.39 2020/10/31 01:08:32 christos Exp $	*/
+/*	$NetBSD: event.h,v 1.40 2020/10/31 14:55:52 christos Exp $	*/
 
 /*-
  * Copyright (c) 1999,2000,2001 Jonathan Lemon 
@@ -47,6 +47,20 @@
 #define	EVFILT_USER		8U	/* user events */
 #define	EVFILT_SYSCOUNT		9U	/* number of filters */
 
+#ifdef EVFILT_NAMES
+static const char *evfiltnames[] = {
+	"EVFILT_READ",
+	"EVFILT_WRITE",
+	"EVFILT_AIO",
+	"EVFILT_VNODE",
+	"EVFILT_PROC",
+	"EVFILT_SIGNAL",
+	"EVFILT_TIMER",
+	"EVFILT_FS",
+	"EVFILT_USER",
+};
+#endif
+
 struct kevent {
 	uintptr_t	ident;		/* identifier for this event */
 	uint32_t	filter;		/* filter for event */



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 14:55:33 UTC 2020

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

Log Message:
make(1): rename local variable freePtr in Var_Parse


To generate a diff of this commit:
cvs rdiff -u -r1.624 -r1.625 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.624 src/usr.bin/make/var.c:1.625
--- src/usr.bin/make/var.c:1.624	Sat Oct 31 14:47:32 2020
+++ src/usr.bin/make/var.c	Sat Oct 31 14:55:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.624 2020/10/31 14:47:32 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.625 2020/10/31 14:55:33 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include"metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.624 2020/10/31 14:47:32 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.625 2020/10/31 14:55:33 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -3664,11 +3664,8 @@ ParseVarnameLong(
  * Input:
  *	str		The string to parse
  *	ctxt		The context for the variable
- *	flags		VARE_UNDEFERR	if undefineds are an error
- *			VARE_WANTRES	if we actually want the result
- *			VARE_ASSIGN	if we are in a := assignment
- *	lengthPtr	OUT: The length of the specification
- *	freePtr		OUT: Non-NULL if caller should free *freePtr
+ *	flags		Select the exact details of parsing
+ *	out_val_freeIt	Must be freed by the caller after using out_val
  *
  * Results:
  *	Returns the value of the variable expression, never NULL.
@@ -3688,8 +3685,8 @@ ParseVarnameLong(
  *	If varUndefined is returned, a diagnostic may or may not have been
  *	printed. XXX: This is inconsistent.
  *
- *	After using the returned value, *freePtr must be freed, preferably
- *	using bmake_free since it is NULL in most cases.
+ *	After using the returned value, *out_val_freeIt must be freed,
+ *	preferably using bmake_free since it is NULL in most cases.
  *
  * Side Effects:
  *	Any effects from the modifiers, such as :!cmd! or ::=value.
@@ -3698,7 +3695,7 @@ ParseVarnameLong(
 /* coverity[+alloc : arg-*4] */
 VarParseResult
 Var_Parse(const char **pp, GNode *ctxt, VarEvalFlags eflags,
-	  const char **out_val, void **freePtr)
+	  const char **out_val, void **out_val_freeIt)
 {
 const char *const start = *pp;
 const char *p;
@@ -3721,7 +3718,7 @@ Var_Parse(const char **pp, GNode *ctxt, 
 	   Enum_FlagsToString(eflags_str, sizeof eflags_str, eflags,
   VarEvalFlags_ToStringSpecs));
 
-*freePtr = NULL;
+*out_val_freeIt = NULL;
 extramodifiers = NULL;	/* extra modifiers to apply first */
 dynamic = FALSE;
 
@@ -3739,7 +3736,7 @@ Var_Parse(const char **pp, GNode *ctxt, 
 } else {
 	VarParseResult res;
 	if (!ParseVarnameLong(pp, startc, ctxt, eflags,
-			  , out_val, freePtr,
+			  , out_val, out_val_freeIt,
 			  , , , , ,
 			  , ))
 	return res;
@@ -3766,7 +3763,7 @@ Var_Parse(const char **pp, GNode *ctxt, 
 	(void)Var_Subst(nstr, ctxt, nested_eflags, );
 	v->flags &= ~(unsigned)VAR_IN_USE;
 	/* TODO: handle errors */
-	*freePtr = nstr;
+	*out_val_freeIt = nstr;
 }
 
 if (haveModifier || extramodifiers != NULL) {
@@ -3784,10 +3781,10 @@ Var_Parse(const char **pp, GNode *ctxt, 
 	p++;
 
 	nstr = ApplyModifiers(, nstr, startc, endc,
-  v, , ctxt, eflags, freePtr);
+  v, , ctxt, eflags, out_val_freeIt);
 	free(extraFree);
 	} else {
-	*freePtr = extraFree;
+	*out_val_freeIt = extraFree;
 	}
 }
 
@@ -3801,18 +3798,18 @@ Var_Parse(const char **pp, GNode *ctxt, 
 	 * but don't free the variable value if it will be returned. */
 	Boolean keepValue = nstr == Buf_GetAll(>val, NULL);
 	if (keepValue)
-	*freePtr = nstr;
+	*out_val_freeIt = nstr;
 	(void)VarFreeEnv(v, !keepValue);
 
 } else if (exprFlags & VEF_UNDEF) {
 	if (!(exprFlags & VEF_DEF)) {
-	if (*freePtr != NULL) {
-		free(*freePtr);
-		*freePtr = NULL;
+	if (*out_val_freeIt != NULL) {
+		free(*out_val_freeIt);
+		*out_val_freeIt = NULL;
 	}
 	if (dynamic) {
 		nstr = bmake_strsedup(start, p);
-		*freePtr = nstr;
+		*out_val_freeIt = nstr;
 	} else {
 		/* The expression is still undefined, therefore discard the
 		 * actual value and return an error marker instead. */



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 14:47:32 UTC 2020

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

Log Message:
make(1): use consistent parameter order in varname parsing functions


To generate a diff of this commit:
cvs rdiff -u -r1.623 -r1.624 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.623 src/usr.bin/make/var.c:1.624
--- src/usr.bin/make/var.c:1.623	Sat Oct 31 14:40:34 2020
+++ src/usr.bin/make/var.c	Sat Oct 31 14:47:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.623 2020/10/31 14:40:34 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.624 2020/10/31 14:47:32 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include"metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.623 2020/10/31 14:40:34 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.624 2020/10/31 14:47:32 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -3465,12 +3465,15 @@ ValidShortVarname(char varname, const ch
 /* Parse a single-character variable name such as $V or $@.
  * Return whether to continue parsing. */
 static Boolean
-ParseVarnameShort(char const startc, const char **const pp, GNode *const ctxt,
-		  VarEvalFlags const eflags,
-		  const char **const out_FALSE_val,
-		  VarParseResult *const out_FALSE_res,
-		  Var **out_TRUE_var)
-{
+ParseVarnameShort(
+	char startc,
+	const char **pp,
+	GNode *ctxt,
+	VarEvalFlags eflags,
+	VarParseResult *out_FALSE_res,
+	const char **out_FALSE_val,
+	Var **out_TRUE_var
+) {
 char name[2];
 Var *v;
 
@@ -3513,22 +3516,22 @@ ParseVarnameShort(char const startc, con
  * Return whether to continue parsing. */
 static Boolean
 ParseVarnameLong(
-	const char **const pp,
-	char const startc,
-	GNode *const ctxt,
-	VarEvalFlags const eflags,
-
-	VarParseResult *const out_FALSE_res,
-	const char **const out_FALSE_val,
-	void **const out_FALSE_freePtr,
-
-	char *const out_TRUE_endc,
-	const char **const out_TRUE_p,
-	Var **const out_TRUE_v,
-	Boolean *const out_TRUE_haveModifier,
-	const char **const out_TRUE_extraModifiers,
-	Boolean *const out_TRUE_dynamic,
-	VarExprFlags *const out_TRUE_exprFlags
+	const char **pp,
+	char startc,
+	GNode *ctxt,
+	VarEvalFlags eflags,
+
+	VarParseResult *out_FALSE_res,
+	const char **out_FALSE_val,
+	void **out_FALSE_freePtr,
+
+	char *out_TRUE_endc,
+	const char **out_TRUE_p,
+	Var **out_TRUE_v,
+	Boolean *out_TRUE_haveModifier,
+	const char **out_TRUE_extraModifiers,
+	Boolean *out_TRUE_dynamic,
+	VarExprFlags *out_TRUE_exprFlags
 ) {
 size_t namelen;
 char *varname;
@@ -3729,7 +3732,7 @@ Var_Parse(const char **pp, GNode *ctxt, 
 startc = start[1];
 if (startc != '(' && startc != '{') {
 	VarParseResult res;
-	if (!ParseVarnameShort(startc, pp, ctxt, eflags, out_val, , ))
+	if (!ParseVarnameShort(startc, pp, ctxt, eflags, , out_val, ))
 	return res;
 	haveModifier = FALSE;
 	p = start + 1;



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 14:40:35 UTC 2020

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

Log Message:
make(1): extract ParseVarnameLong from Var_Parse


To generate a diff of this commit:
cvs rdiff -u -r1.622 -r1.623 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.622 src/usr.bin/make/var.c:1.623
--- src/usr.bin/make/var.c:1.622	Sat Oct 31 14:12:01 2020
+++ src/usr.bin/make/var.c	Sat Oct 31 14:40:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.622 2020/10/31 14:12:01 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.623 2020/10/31 14:40:34 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include"metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.622 2020/10/31 14:12:01 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.623 2020/10/31 14:40:34 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -3507,6 +3507,145 @@ ParseVarnameShort(char const startc, con
 return TRUE;
 }
 
+/* Parse a long variable name enclosed in braces or parentheses such as $(VAR)
+ * or ${VAR}, up to the closing brace or parenthesis, or in the case of
+ * ${VAR:Modifiers}, up to the ':' that starts the modifiers.
+ * Return whether to continue parsing. */
+static Boolean
+ParseVarnameLong(
+	const char **const pp,
+	char const startc,
+	GNode *const ctxt,
+	VarEvalFlags const eflags,
+
+	VarParseResult *const out_FALSE_res,
+	const char **const out_FALSE_val,
+	void **const out_FALSE_freePtr,
+
+	char *const out_TRUE_endc,
+	const char **const out_TRUE_p,
+	Var **const out_TRUE_v,
+	Boolean *const out_TRUE_haveModifier,
+	const char **const out_TRUE_extraModifiers,
+	Boolean *const out_TRUE_dynamic,
+	VarExprFlags *const out_TRUE_exprFlags
+) {
+size_t namelen;
+char *varname;
+Var *v;
+Boolean haveModifier;
+Boolean dynamic = FALSE;
+
+const char *const start = *pp;
+char endc = startc == '(' ? ')' : '}';
+
+const char *p = start + 2;
+varname = ParseVarname(, startc, endc, ctxt, eflags, );
+
+if (*p == ':') {
+	haveModifier = TRUE;
+} else if (*p == endc) {
+	haveModifier = FALSE;
+} else {
+	Parse_Error(PARSE_FATAL, "Unclosed variable \"%s\"", varname);
+	*pp = p;
+	free(varname);
+	*out_FALSE_val = var_Error;
+	*out_FALSE_res = VPR_PARSE_MSG;
+	return FALSE;
+}
+
+v = VarFind(varname, ctxt, TRUE);
+
+/* At this point, p points just after the variable name,
+ * either at ':' or at endc. */
+
+/*
+ * Check also for bogus D and F forms of local variables since we're
+ * in a local context and the name is the right length.
+ */
+if (v == NULL && ctxt != VAR_CMDLINE && ctxt != VAR_GLOBAL &&
+	namelen == 2 && (varname[1] == 'F' || varname[1] == 'D') &&
+	strchr("@%?*!<>", varname[0]) != NULL)
+{
+	/*
+	 * Well, it's local -- go look for it.
+	 */
+	char name[] = { varname[0], '\0' };
+	v = VarFind(name, ctxt, 0);
+
+	if (v != NULL) {
+	if (varname[1] == 'D') {
+		*out_TRUE_extraModifiers = "H:";
+	} else { /* F */
+		*out_TRUE_extraModifiers = "T:";
+	}
+	}
+}
+
+if (v == NULL) {
+	dynamic = VarIsDynamic(ctxt, varname, namelen);
+
+	if (!haveModifier) {
+	p++;		/* skip endc */
+	*pp = p;
+	if (dynamic) {
+		char *pstr = bmake_strsedup(start, p);
+		free(varname);
+		*out_FALSE_res = VPR_OK;
+		*out_FALSE_freePtr = pstr;
+		*out_FALSE_val = pstr;
+		return FALSE;
+	}
+
+	if ((eflags & VARE_UNDEFERR) && (eflags & VARE_WANTRES) &&
+		DEBUG(LINT))
+	{
+		Parse_Error(PARSE_FATAL, "Variable \"%s\" is undefined",
+			varname);
+		free(varname);
+		*out_FALSE_res = VPR_UNDEF_MSG;
+		*out_FALSE_val = var_Error;
+		return FALSE;
+	}
+
+	if (eflags & VARE_UNDEFERR) {
+		free(varname);
+		*out_FALSE_res = VPR_UNDEF_SILENT;
+		*out_FALSE_val = var_Error;
+		return FALSE;
+	}
+
+	free(varname);
+	*out_FALSE_res = VPR_OK;
+	*out_FALSE_val = varUndefined;
+	return FALSE;
+	}
+
+	/* The variable expression is based on an undefined variable.
+	 * Nevertheless it needs a Var, for modifiers that access the
+	 * variable name, such as :L or :?.
+	 *
+	 * Most modifiers leave this expression in the "undefined" state
+	 * (VEF_UNDEF), only a few modifiers like :D, :U, :L, :P turn this
+	 * undefined expression into a defined expression (VEF_DEF).
+	 *
+	 * At the end, after applying all modifiers, if the expression
+	 * is still undefined, Var_Parse will return an empty string
+	 * instead of the actually computed value. */
+	v = VarNew(varname, varname, "", 0);
+	*out_TRUE_exprFlags = VEF_UNDEF;
+} else
+	free(varname);
+
+*out_TRUE_endc = endc;
+*out_TRUE_p = p;
+*out_TRUE_v = v;
+*out_TRUE_haveModifier = 

CVS commit: src/sys/dev/i2c

2020-10-31 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Oct 31 14:38:54 UTC 2020

Modified Files:
src/sys/dev/i2c: pcagpio.c

Log Message:
Detach led's in our detach routine.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/i2c/pcagpio.c

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

Modified files:

Index: src/sys/dev/i2c/pcagpio.c
diff -u src/sys/dev/i2c/pcagpio.c:1.5 src/sys/dev/i2c/pcagpio.c:1.6
--- src/sys/dev/i2c/pcagpio.c:1.5	Thu Oct 29 06:50:53 2020
+++ src/sys/dev/i2c/pcagpio.c	Sat Oct 31 14:38:54 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: pcagpio.c,v 1.5 2020/10/29 06:50:53 jdc Exp $ */
+/* $NetBSD: pcagpio.c,v 1.6 2020/10/31 14:38:54 jdc Exp $ */
 
 /*-
  * Copyright (c) 2020 Michael Lorenz
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcagpio.c,v 1.5 2020/10/29 06:50:53 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcagpio.c,v 1.6 2020/10/31 14:38:54 jdc Exp $");
 
 #include 
 #include 
@@ -67,6 +67,7 @@ static void	pcagpio_timeout(void *);
 /* we can only pass one cookie to led_attach() but we need several values... */
 struct pcagpio_led {
 	void *cookie;
+	struct led_device *led;
 	uint32_t mask, v_on, v_off;
 };
 
@@ -215,9 +216,13 @@ pcagpio_attach(device_t parent, device_t
 static int
 pcagpio_detach(device_t self, int flags)
 {
-#ifdef PCAGPIO_DEBUG
 	struct pcagpio_softc *sc = device_private(self);
+	int i;
 
+	for (i = 0; i < sc->sc_nleds; i++)
+		led_detach(sc->sc_leds[i].led);
+
+#ifdef PCAGPIO_DEBUG
 	callout_halt(>sc_timer, NULL);
 	callout_destroy(>sc_timer);
 #endif
@@ -311,7 +316,7 @@ pcagpio_attach_led(struct pcagpio_softc 
 	l->mask = 1 << pin;
 	l->v_on = act ? l->mask : 0;
 	l->v_off = act ? 0 : l->mask;
-	led_attach(n, l, pcagpio_get, pcagpio_set);
+	l->led = led_attach(n, l, pcagpio_get, pcagpio_set);
 	if (def != -1) pcagpio_set(l, def);
 	DPRINTF("%s: %04x %04x %04x def %d\n",
 	__func__, l->mask, l->v_on, l->v_off, def);



CVS commit: src/sys/dev/i2c

2020-10-31 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Oct 31 14:39:31 UTC 2020

Modified Files:
src/sys/dev/i2c: pcf8574.c

Log Message:
Detach led's and sysmon in our detach routine.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/pcf8574.c

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

Modified files:

Index: src/sys/dev/i2c/pcf8574.c
diff -u src/sys/dev/i2c/pcf8574.c:1.1 src/sys/dev/i2c/pcf8574.c:1.2
--- src/sys/dev/i2c/pcf8574.c:1.1	Thu Oct 29 06:55:51 2020
+++ src/sys/dev/i2c/pcf8574.c	Sat Oct 31 14:39:31 2020
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8574.c,v 1.1 2020/10/29 06:55:51 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8574.c,v 1.2 2020/10/31 14:39:31 jdc Exp $");
 
 #include 
 #include 
@@ -53,6 +53,7 @@ __KERNEL_RCSID(0, "$NetBSD: pcf8574.c,v 
 
 struct pcf8574_led {
 	void *cookie;
+	struct led_device *led;
 	uint8_t mask, v_on, v_off;
 };
 
@@ -215,13 +216,19 @@ pcf8574_attach(device_t parent, device_t
 static int
 pcf8574_detach(device_t self, int flags)
 {
-#ifdef PCF8574_DEBUG
 	struct pcf8574_softc *sc = device_private(self);
+	int i;
+
+	if (sc->sc_sme != NULL)
+		sysmon_envsys_unregister(sc->sc_sme);
+
+	for (i = 0; i < sc->sc_nleds; i++)
+		led_detach(sc->sc_leds[i].led);
 
+#ifdef PCF8574_DEBUG
 	callout_halt(>sc_timer, NULL);
 	callout_destroy(>sc_timer);
 #endif
-
 	return 0;
 }
 



CVS commit: src/lib/libc/sys

2020-10-31 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Oct 31 14:35:28 UTC 2020

Modified Files:
src/lib/libc/sys: kqueue.2

Log Message:
add missing sentence.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/lib/libc/sys/kqueue.2

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

Modified files:

Index: src/lib/libc/sys/kqueue.2
diff -u src/lib/libc/sys/kqueue.2:1.52 src/lib/libc/sys/kqueue.2:1.53
--- src/lib/libc/sys/kqueue.2:1.52	Sat Oct 31 06:51:59 2020
+++ src/lib/libc/sys/kqueue.2	Sat Oct 31 10:35:28 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: kqueue.2,v 1.52 2020/10/31 10:51:59 wiz Exp $
+.\"	$NetBSD: kqueue.2,v 1.53 2020/10/31 14:35:28 christos Exp $
 .\"
 .\" Copyright (c) 2000 Jonathan Lemon
 .\" All rights reserved.
@@ -392,6 +392,7 @@ when the BPF has
 .Dq immediate mode
 enabled and there is any data to read;
 .Va data
+contains the number of bytes available.
 .El
 .It Dv EVFILT_WRITE
 Takes a descriptor as the identifier, and returns whenever



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 14:12:01 UTC 2020

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

Log Message:
make(1): extract ParseVarnameShort from Var_Parse

With its more than 200 lines, the latter has too much code to be read
easily.


To generate a diff of this commit:
cvs rdiff -u -r1.621 -r1.622 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.621 src/usr.bin/make/var.c:1.622
--- src/usr.bin/make/var.c:1.621	Sat Oct 31 12:59:28 2020
+++ src/usr.bin/make/var.c	Sat Oct 31 14:12:01 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.621 2020/10/31 12:59:28 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.622 2020/10/31 14:12:01 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include"metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.621 2020/10/31 12:59:28 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.622 2020/10/31 14:12:01 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -3462,6 +3462,51 @@ ValidShortVarname(char varname, const ch
 return FALSE;
 }
 
+/* Parse a single-character variable name such as $V or $@.
+ * Return whether to continue parsing. */
+static Boolean
+ParseVarnameShort(char const startc, const char **const pp, GNode *const ctxt,
+		  VarEvalFlags const eflags,
+		  const char **const out_FALSE_val,
+		  VarParseResult *const out_FALSE_res,
+		  Var **out_TRUE_var)
+{
+char name[2];
+Var *v;
+
+/*
+ * If it's not bounded by braces of some sort, life is much simpler.
+ * We just need to check for the first character and return the
+ * value if it exists.
+ */
+
+if (!ValidShortVarname(startc, *pp)) {
+	(*pp)++;
+	*out_FALSE_val = var_Error;
+	*out_FALSE_res = VPR_PARSE_MSG;
+	return FALSE;
+}
+
+name[0] = startc;
+name[1] = '\0';
+v = VarFind(name, ctxt, TRUE);
+if (v == NULL) {
+	*pp += 2;
+
+	*out_FALSE_val = UndefinedShortVarValue(startc, ctxt, eflags);
+	if (DEBUG(LINT) && *out_FALSE_val == var_Error) {
+	Parse_Error(PARSE_FATAL, "Variable \"%s\" is undefined", name);
+	*out_FALSE_res = VPR_UNDEF_MSG;
+	return FALSE;
+	}
+	*out_FALSE_res = eflags & VARE_UNDEFERR ? VPR_UNDEF_SILENT : VPR_OK;
+	return FALSE;
+}
+
+*out_TRUE_var = v;
+return TRUE;
+}
+
 /*-
  *---
  * Var_Parse --
@@ -3544,36 +3589,11 @@ Var_Parse(const char **pp, GNode *ctxt, 
 
 startc = start[1];
 if (startc != '(' && startc != '{') {
-	char name[2];
-
-	/*
-	 * If it's not bounded by braces of some sort, life is much simpler.
-	 * We just need to check for the first character and return the
-	 * value if it exists.
-	 */
-
-	if (!ValidShortVarname(startc, start)) {
-	(*pp)++;
-	*out_val = var_Error;
-	return VPR_PARSE_MSG;
-	}
-
-	name[0] = startc;
-	name[1] = '\0';
-	v = VarFind(name, ctxt, TRUE);
-	if (v == NULL) {
-	*pp += 2;
-
-	*out_val = UndefinedShortVarValue(startc, ctxt, eflags);
-	if (DEBUG(LINT) && *out_val == var_Error) {
-		Parse_Error(PARSE_FATAL, "Variable \"%s\" is undefined", name);
-		return VPR_UNDEF_MSG;
-	}
-	return eflags & VARE_UNDEFERR ? VPR_UNDEF_SILENT : VPR_OK;
-	} else {
-	haveModifier = FALSE;
-	p = start + 1;
-	}
+VarParseResult res;
+	if (!ParseVarnameShort(startc, pp, ctxt, eflags, out_val, , ))
+	return res;
+	haveModifier = FALSE;
+	p = start + 1;
 } else {
 	size_t namelen;
 	char *varname;



CVS commit: src/sys/arch/arm/include

2020-10-31 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct 31 13:58:22 UTC 2020

Modified Files:
src/sys/arch/arm/include: cpufunc.h

Log Message:
Fix armv6 builds by providing an armv6 is macro


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/arch/arm/include/cpufunc.h

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

Modified files:

Index: src/sys/arch/arm/include/cpufunc.h
diff -u src/sys/arch/arm/include/cpufunc.h:1.84 src/sys/arch/arm/include/cpufunc.h:1.85
--- src/sys/arch/arm/include/cpufunc.h:1.84	Tue Sep 29 18:13:29 2020
+++ src/sys/arch/arm/include/cpufunc.h	Sat Oct 31 13:58:22 2020
@@ -42,8 +42,6 @@
 #ifndef _ARM_CPUFUNC_H_
 #define _ARM_CPUFUNC_H_
 
-#define	isb()		__asm __volatile("isb" : : : "memory")
-
 #ifdef _ARM_ARCH_7
 /*
  * Options for DMB and DSB:
@@ -62,12 +60,16 @@
  */
 #define	dsb(opt)	__asm __volatile("dsb " __STRING(opt) : : : "memory")
 #define	dmb(opt)	__asm __volatile("dmb " __STRING(opt) : : : "memory")
+#define	isb()		__asm __volatile("isb" : : : "memory")
+
 #else
 
 #define dsb(opt)	\
 	__asm __volatile("mcr p15, 0, %0, c7, c10, 4" :: "r" (0) : "memory")
 #define dmb(opt)	\
 	__asm __volatile("mcr p15, 0, %0, c7, c10, 5" :: "r" (0) : "memory")
+#define isb()		\
+	__asm __volatile("mcr p15, 0, %0, c7, c5, 4" :: "r" (0) : "memory")
 
 #endif
 



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

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 13:45:00 UTC 2020

Modified Files:
src/usr.bin/make/unit-tests: var-recursive.exp var-recursive.mk

Log Message:
make(1): add test for recursion detection with short variable names


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-recursive.exp \
src/usr.bin/make/unit-tests/var-recursive.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/var-recursive.exp
diff -u src/usr.bin/make/unit-tests/var-recursive.exp:1.1 src/usr.bin/make/unit-tests/var-recursive.exp:1.2
--- src/usr.bin/make/unit-tests/var-recursive.exp:1.1	Sat Oct 31 11:30:57 2020
+++ src/usr.bin/make/unit-tests/var-recursive.exp	Sat Oct 31 13:45:00 2020
@@ -6,4 +6,7 @@ Variable INDIRECT1 is recursive.
 
 make: stopped in unit-tests
 make: "var-recursive.mk" line 35: ok
+Variable V is recursive.
+
+make: stopped in unit-tests
 exit status 0
Index: src/usr.bin/make/unit-tests/var-recursive.mk
diff -u src/usr.bin/make/unit-tests/var-recursive.mk:1.1 src/usr.bin/make/unit-tests/var-recursive.mk:1.2
--- src/usr.bin/make/unit-tests/var-recursive.mk:1.1	Sat Oct 31 11:30:57 2020
+++ src/usr.bin/make/unit-tests/var-recursive.mk	Sat Oct 31 13:45:00 2020
@@ -1,9 +1,9 @@
-# $NetBSD: var-recursive.mk,v 1.1 2020/10/31 11:30:57 rillig Exp $
+# $NetBSD: var-recursive.mk,v 1.2 2020/10/31 13:45:00 rillig Exp $
 #
 # Tests for variable expressions that refer to themselves and thus
 # cannot be evaluated.
 
-TESTS=	direct indirect conditional
+TESTS=	direct indirect conditional short
 
 # Since make exits immediately when it detects a recursive expression,
 # the actual tests are run in sub-makes.
@@ -34,6 +34,14 @@ INDIRECT2=	${INDIRECT1}
 CONDITIONAL=	${1:?ok:${CONDITIONAL}}
 .  info ${CONDITIONAL}
 
+.elif ${TEST} == short
+
+# Short variable names can be expanded using the short-hand $V notation,
+# which takes a different code path in Var_Parse for parsing the variable
+# name.  Ensure that these are checked as well.
+V=	$V
+.  info $V
+
 .else
 .  error Unknown test "${TEST}"
 .endif



CVS commit: src/external/mit/xorg/lib

2020-10-31 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Sat Oct 31 13:28:22 UTC 2020

Modified Files:
src/external/mit/xorg/lib: libmesa.mk
src/external/mit/xorg/lib/libGL: Makefile
src/external/mit/xorg/lib/libglapi: Makefile

Log Message:
mesa: re-enable GLX TLS to help i386

mesa's assembly code for i386 only seems to be position independent
when compiled with ELF TLS, so having it disabled causes worse problems
than the edge cases ELF TLS causes.

potentially the assembly code could be fixed (it looks like it not
being safe is a bug), it could also be disabled, but i don't currently
have the means to measure the impact of that.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/external/mit/xorg/lib/libmesa.mk
cvs rdiff -u -r1.30 -r1.31 src/external/mit/xorg/lib/libGL/Makefile
cvs rdiff -u -r1.8 -r1.9 src/external/mit/xorg/lib/libglapi/Makefile

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

Modified files:

Index: src/external/mit/xorg/lib/libmesa.mk
diff -u src/external/mit/xorg/lib/libmesa.mk:1.12 src/external/mit/xorg/lib/libmesa.mk:1.13
--- src/external/mit/xorg/lib/libmesa.mk:1.12	Wed Sep 16 18:19:23 2020
+++ src/external/mit/xorg/lib/libmesa.mk	Sat Oct 31 13:28:22 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: libmesa.mk,v 1.12 2020/09/16 18:19:23 nia Exp $
+#	$NetBSD: libmesa.mk,v 1.13 2020/10/31 13:28:22 nia Exp $
 #
 # Consumer of this Makefile should set MESA_SRC_MODULES.
 
@@ -526,6 +526,7 @@ CPPFLAGS+=	\
 	-DHAVE_LIBDRM -DGLX_USE_DRM \
 	-DGLX_INDIRECT_RENDERING \
 	-DGLX_DIRECT_RENDERING \
+	-DGLX_USE_TLS \
 	-DHAVE_X11_PLATFORM \
 	-DHAVE_DRM_PLATFORM \
 	-DENABLE_SHADER_CACHE \

Index: src/external/mit/xorg/lib/libGL/Makefile
diff -u src/external/mit/xorg/lib/libGL/Makefile:1.30 src/external/mit/xorg/lib/libGL/Makefile:1.31
--- src/external/mit/xorg/lib/libGL/Makefile:1.30	Wed Sep 16 18:19:23 2020
+++ src/external/mit/xorg/lib/libGL/Makefile	Sat Oct 31 13:28:22 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.30 2020/09/16 18:19:23 nia Exp $
+#	$NetBSD: Makefile,v 1.31 2020/10/31 13:28:22 nia Exp $
 
 .include 
 
@@ -180,7 +180,7 @@ CPPFLAGS+=	\
 	-DHAVE_FUNC_ATTRIBUTE_NORETURN=1 -DHAVE_ENDIAN_H=1 -DHAVE_DLADDR=1 \
 	-DHAVE_CLOCK_GETTIME=1 -DHAVE_PTHREAD_PRIO_INHERIT=1 \
 	-DHAVE_PTHREAD=1 -DENABLE_ST_OMX_BELLAGIO=0 -DENABLE_ST_OMX_TIZONIA=0 \
-	-DHAVE_TIMESPEC_GET
+	-DHAVE_TIMESPEC_GET -DGLX_USE_TLS
 
 .include "../asm.mk"
 
@@ -224,7 +224,7 @@ PKGCONFIG_SED_FLAGS= \
 	s,@GL_PKGCONF_LIB@,GL,; \
 	s,@GL_PC_LIB_PRIV@,-lm -lpthread -pthread,; \
 	s,@GL_PC_CFLAGS@,,; \
-	s,@GLX_TLS@,no,"
+	s,@GLX_TLS@,yes,"
 
 
 CWARNFLAGS.clang+=	-Wno-tautological-compare -Wno-format -Wno-constant-conversion \

Index: src/external/mit/xorg/lib/libglapi/Makefile
diff -u src/external/mit/xorg/lib/libglapi/Makefile:1.8 src/external/mit/xorg/lib/libglapi/Makefile:1.9
--- src/external/mit/xorg/lib/libglapi/Makefile:1.8	Wed Sep 16 18:19:24 2020
+++ src/external/mit/xorg/lib/libglapi/Makefile	Sat Oct 31 13:28:22 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.8 2020/09/16 18:19:24 nia Exp $
+#	$NetBSD: Makefile,v 1.9 2020/10/31 13:28:22 nia Exp $
 
 .include 
 
@@ -68,6 +68,7 @@ CPPFLAGS+=	\
 	-DGLX_USE_DRM \
 	-DGLX_INDIRECT_RENDERING \
 	-DGLX_DIRECT_RENDERING \
+	-DGLX_USE_TLS \
 	-DHAVE_X11_PLATFORM \
 	-DHAVE_DRM_PLATFORM \
 	-DENABLE_SHADER_CACHE \



CVS commit: src/sys/arch/sparc64/dev

2020-10-31 Thread Julian Coleman
Module Name:src
Committed By:   jdc
Date:   Sat Oct 31 13:17:34 UTC 2020

Modified Files:
src/sys/arch/sparc64/dev: pcf8591_envctrl.c tda.c

Log Message:
Call sysmon_envsys_unregister() not sysmon_envsys_destroy() when
detaching.  Pointed out by Michael van Elst.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sparc64/dev/pcf8591_envctrl.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sparc64/dev/tda.c

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

Modified files:

Index: src/sys/arch/sparc64/dev/pcf8591_envctrl.c
diff -u src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.10 src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.11
--- src/sys/arch/sparc64/dev/pcf8591_envctrl.c:1.10	Sat Oct 24 15:16:39 2020
+++ src/sys/arch/sparc64/dev/pcf8591_envctrl.c	Sat Oct 31 13:17:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcf8591_envctrl.c,v 1.10 2020/10/24 15:16:39 jdc Exp $	*/
+/*	$NetBSD: pcf8591_envctrl.c,v 1.11 2020/10/31 13:17:34 jdc Exp $	*/
 /*	$OpenBSD: pcf8591_envctrl.c,v 1.6 2007/10/25 21:17:20 kettenis Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.10 2020/10/24 15:16:39 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pcf8591_envctrl.c,v 1.11 2020/10/31 13:17:34 jdc Exp $");
 
 #include 
 #include 
@@ -264,7 +264,7 @@ ecadc_detach(device_t self, int flags)
 	}
 
 	if (sc->sc_sme != NULL)
-		sysmon_envsys_destroy(sc->sc_sme);
+		sysmon_envsys_unregister(sc->sc_sme);
 
 	return 0;
 }

Index: src/sys/arch/sparc64/dev/tda.c
diff -u src/sys/arch/sparc64/dev/tda.c:1.13 src/sys/arch/sparc64/dev/tda.c:1.14
--- src/sys/arch/sparc64/dev/tda.c:1.13	Fri Mar  1 02:38:17 2019
+++ src/sys/arch/sparc64/dev/tda.c	Sat Oct 31 13:17:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: tda.c,v 1.13 2019/03/01 02:38:17 mrg Exp $	*/
+/*	$NetBSD: tda.c,v 1.14 2020/10/31 13:17:34 jdc Exp $	*/
 /*	$OpenBSD: tda.c,v 1.4 2008/02/27 17:25:00 robert Exp $ */
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tda.c,v 1.13 2019/03/01 02:38:17 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tda.c,v 1.14 2020/10/31 13:17:34 jdc Exp $");
 
 #include 
 #include 
@@ -177,7 +177,7 @@ tda_detach(device_t self, int flags)
 	struct tda_softc *sc = device_private(self);
 
 	if (sc->sc_sme != NULL)
-		sysmon_envsys_destroy(sc->sc_sme);
+		sysmon_envsys_unregister(sc->sc_sme);
 
 	callout_halt(>sc_timer, NULL);
 	callout_destroy(>sc_timer);



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

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 13:15:10 UTC 2020

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

Log Message:
make(1): fix function names in test for variable debugging


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/vardebug.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/vardebug.mk
diff -u src/usr.bin/make/unit-tests/vardebug.mk:1.5 src/usr.bin/make/unit-tests/vardebug.mk:1.6
--- src/usr.bin/make/unit-tests/vardebug.mk:1.5	Thu Oct 29 18:38:24 2020
+++ src/usr.bin/make/unit-tests/vardebug.mk	Sat Oct 31 13:15:10 2020
@@ -1,4 +1,4 @@
-# $NetBSD: vardebug.mk,v 1.5 2020/10/29 18:38:24 rillig Exp $
+# $NetBSD: vardebug.mk,v 1.6 2020/10/31 13:15:10 rillig Exp $
 #
 # Demonstrates the debugging output for var.c.
 
@@ -19,12 +19,12 @@ VAR=		1
 VAR+=		2
 VAR+=		3
 
-.if ${VAR:M[2]}			# VarMatch
+.if ${VAR:M[2]}			# ModifyWord_Match
 .endif
-.if ${VAR:N[2]}			# VarNoMatch (no debug output)
+.if ${VAR:N[2]}			# ModifyWord_NoMatch (no debug output)
 .endif
 
-.if ${VAR:S,2,two,}		# VarGetPattern
+.if ${VAR:S,2,two,}		# ParseModifierPart
 .endif
 
 .if ${VAR:Q}			# VarQuote



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 12:59:28 UTC 2020

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

Log Message:
make(1): fix type of ParseModifierPart parameter delim


To generate a diff of this commit:
cvs rdiff -u -r1.620 -r1.621 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.620 src/usr.bin/make/var.c:1.621
--- src/usr.bin/make/var.c:1.620	Sat Oct 31 12:57:39 2020
+++ src/usr.bin/make/var.c	Sat Oct 31 12:59:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.620 2020/10/31 12:57:39 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.621 2020/10/31 12:59:28 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include"metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.620 2020/10/31 12:57:39 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.621 2020/10/31 12:59:28 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -1871,7 +1871,7 @@ IsEscapedModifierPart(const char *p, cha
 static VarParseResult
 ParseModifierPart(
 const char **pp,		/* The parsing position, updated upon return */
-int delim,			/* Parsing stops at this delimiter */
+char delim,			/* Parsing stops at this delimiter */
 VarEvalFlags eflags,	/* Flags for evaluating nested variables;
  * if VARE_WANTRES is not set, the text is
  * only parsed */



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 12:57:39 UTC 2020

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

Log Message:
make(1): extract IsEscapedModifierPart from ParseModifierPart


To generate a diff of this commit:
cvs rdiff -u -r1.619 -r1.620 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.619 src/usr.bin/make/var.c:1.620
--- src/usr.bin/make/var.c:1.619	Sat Oct 31 12:45:42 2020
+++ src/usr.bin/make/var.c	Sat Oct 31 12:57:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.619 2020/10/31 12:45:42 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.620 2020/10/31 12:57:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include"metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.619 2020/10/31 12:45:42 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.620 2020/10/31 12:57:39 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -1844,9 +1844,22 @@ typedef enum ApplyModifierResult {
 AMR_CLEANUP			/* Error out without error message */
 } ApplyModifierResult;
 
-/*-
- * Parse a part of a modifier such as the "from" and "to" in :S/from/to/
- * or the "var" or "replacement" in :@var@replacement+${var}@, up to and
+/* Allow backslashes to escape the delimiter, $, and \, but don't touch other
+ * backslashes. */
+static Boolean
+IsEscapedModifierPart(const char *p, char delim,
+		  struct ModifyWord_SubstArgs *subst)
+{
+if (p[0] != '\\')
+	return FALSE;
+if (p[1] == delim || p[1] == '\\' || p[1] == '$')
+	return TRUE;
+return p[1] == '&' && subst != NULL;
+}
+
+/*
+ * Parse a part of a modifier such as the "from" and "to" in :S/from/to/ or
+ * the "var" or "replacement ${var}" in :@var@replacement ${var}@, up to and
  * including the next unescaped delimiter.  The delimiter, as well as the
  * backslash or the dollar, can be escaped with a backslash.
  *
@@ -1880,19 +1893,14 @@ ParseModifierPart(
 Buf_Init(, 0);
 
 /*
- * Skim through until the matching delimiter is found;
- * pick up variable substitutions on the way. Also allow
- * backslashes to quote the delimiter, $, and \, but don't
- * touch other backslashes.
+ * Skim through until the matching delimiter is found; pick up variable
+ * expressions on the way.
  */
 p = *pp;
 while (*p != '\0' && *p != delim) {
 	const char *varstart;
 
-	Boolean is_escaped = p[0] == '\\' && (
-		p[1] == delim || p[1] == '\\' || p[1] == '$' ||
-		(p[1] == '&' && subst != NULL));
-	if (is_escaped) {
+	if (IsEscapedModifierPart(p, delim, subst)) {
 	Buf_AddByte(, p[1]);
 	p += 2;
 	continue;



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 12:45:42 UTC 2020

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

Log Message:
make(1): clean up ModifyWords

Reorder the parameters to match the documentation comment, and the
remaining parameters in chronological order.  Remove the unused
parameter ctxt.  The callbacks that need it pass it in their
modifyWordArgs instead.


To generate a diff of this commit:
cvs rdiff -u -r1.618 -r1.619 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.618 src/usr.bin/make/var.c:1.619
--- src/usr.bin/make/var.c:1.618	Sat Oct 31 12:34:03 2020
+++ src/usr.bin/make/var.c	Sat Oct 31 12:45:42 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.618 2020/10/31 12:34:03 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.619 2020/10/31 12:45:42 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include"metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.618 2020/10/31 12:34:03 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.619 2020/10/31 12:45:42 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -1476,11 +1476,8 @@ ModifyWord_Loop(const char *word, SepBuf
 }
 
 
-/*-
- * Implements the :[first..last] modifier.
- * This is a special case of ModifyWords since we want to be able
- * to scan the list backwards if first > last.
- */
+/* The :[first..last] modifier selects words from the expression.
+ * It can also reverse the words. */
 static char *
 VarSelectWords(char sep, Boolean oneBigWord, const char *str, int first,
 	   int last)
@@ -1553,9 +1550,7 @@ ModifyWord_Realpath(const char *word, Se
 SepBuf_AddStr(buf, word);
 }
 
-/*-
- *---
- * Modify each of the words of the passed string using the given function.
+/* Modify each of the words of the passed string using the given function.
  *
  * Input:
  *	str		String whose words should be modified
@@ -1567,8 +1562,9 @@ ModifyWord_Realpath(const char *word, Se
  *---
  */
 static char *
-ModifyWords(GNode *ctx, char sep, Boolean oneBigWord, const char *str,
-	ModifyWordsCallback modifyWord, void *modifyWord_args)
+ModifyWords(const char *str,
+	ModifyWordsCallback modifyWord, void *modifyWord_args,
+	Boolean oneBigWord, char sep)
 {
 SepBuf result;
 Words words;
@@ -2036,8 +2032,8 @@ ApplyModifier_Loop(const char **pp, Appl
 args.eflags = st->eflags & (VARE_UNDEFERR | VARE_WANTRES);
 prev_sep = st->sep;
 st->sep = ' ';		/* XXX: should be st->sep for consistency */
-st->newVal = ModifyWords(st->ctxt, st->sep, st->oneBigWord, st->val,
-			 ModifyWord_Loop, );
+st->newVal = ModifyWords(st->val, ModifyWord_Loop, ,
+			 st->oneBigWord, st->sep);
 st->sep = prev_sep;
 Var_Delete(args.tvar, st->ctxt);
 free(args.tvar);
@@ -2333,8 +2329,8 @@ ApplyModifier_Match(const char **pp, App
 VAR_DEBUG3("Pattern[%s] for [%s] is [%s]\n", st->v->name, st->val, pattern);
 
 callback = mod[0] == 'M' ? ModifyWord_Match : ModifyWord_NoMatch;
-st->newVal = ModifyWords(st->ctxt, st->sep, st->oneBigWord, st->val,
-			 callback, pattern);
+st->newVal = ModifyWords(st->val, callback, pattern,
+			 st->oneBigWord, st->sep);
 free(pattern);
 return AMR_OK;
 }
@@ -2397,8 +2393,8 @@ ApplyModifier_Subst(const char **pp, App
 	break;
 }
 
-st->newVal = ModifyWords(st->ctxt, st->sep, oneBigWord, st->val,
-			 ModifyWord_Subst, );
+st->newVal = ModifyWords(st->val, ModifyWord_Subst, ,
+			 oneBigWord, st->sep);
 
 free(lhs);
 free(rhs);
@@ -2467,8 +2463,8 @@ ApplyModifier_Regex(const char **pp, App
 args.nsub = args.re.re_nsub + 1;
 if (args.nsub > 10)
 	args.nsub = 10;
-st->newVal = ModifyWords(st->ctxt, st->sep, oneBigWord, st->val,
-			 ModifyWord_SubstRegex, );
+st->newVal = ModifyWords(st->val, ModifyWord_SubstRegex, ,
+			 oneBigWord, st->sep);
 regfree();
 free(args.replace);
 return AMR_OK;
@@ -2556,8 +2552,8 @@ ApplyModifier_ToSep(const char **pp, App
 }
 
 ok:
-st->newVal = ModifyWords(st->ctxt, st->sep, st->oneBigWord, st->val,
-			 ModifyWord_Copy, NULL);
+st->newVal = ModifyWords(st->val, ModifyWord_Copy, NULL,
+			 st->oneBigWord, st->sep);
 return AMR_OK;
 }
 
@@ -2583,8 +2579,8 @@ ApplyModifier_To(const char **pp, ApplyM
 
 /* Check for two-character options: ":tu", ":tl" */
 if (mod[1] == 'A') {	/* absolute path */
-	st->newVal = ModifyWords(st->ctxt, st->sep, st->oneBigWord, st->val,
- ModifyWord_Realpath, NULL);
+	st->newVal = ModifyWords(st->val, ModifyWord_Realpath, NULL,
+ 

CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 12:34:03 UTC 2020

Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: varmod-loop.mk

Log Message:
make(1): add test for combining the :@ and :? variable modifiers


To generate a diff of this commit:
cvs rdiff -u -r1.617 -r1.618 src/usr.bin/make/var.c
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-loop.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.617 src/usr.bin/make/var.c:1.618
--- src/usr.bin/make/var.c:1.617	Sat Oct 31 12:22:43 2020
+++ src/usr.bin/make/var.c	Sat Oct 31 12:34:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.617 2020/10/31 12:22:43 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.618 2020/10/31 12:34:03 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include"metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.617 2020/10/31 12:22:43 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.618 2020/10/31 12:34:03 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -1465,8 +1465,8 @@ ModifyWord_Loop(const char *word, SepBuf
 (void)Var_Subst(args->str, args->ctx, args->eflags, );
 /* TODO: handle errors */
 
-VAR_DEBUG4("ModifyWord_Loop: in \"%s\", replace \"%s\" with \"%s\" "
-	   "to \"%s\"\n",
+VAR_DEBUG4("ModifyWord_Loop: "
+	   "in \"%s\", replace \"%s\" with \"%s\" to \"%s\"\n",
 	   word, args->tvar, args->str, s);
 
 if (s[0] == '\n' || Buf_EndsWith(>buf, '\n'))

Index: src/usr.bin/make/unit-tests/varmod-loop.mk
diff -u src/usr.bin/make/unit-tests/varmod-loop.mk:1.4 src/usr.bin/make/unit-tests/varmod-loop.mk:1.5
--- src/usr.bin/make/unit-tests/varmod-loop.mk:1.4	Sun Oct 18 21:12:13 2020
+++ src/usr.bin/make/unit-tests/varmod-loop.mk	Sat Oct 31 12:34:03 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-loop.mk,v 1.4 2020/10/18 21:12:13 rillig Exp $
+# $NetBSD: varmod-loop.mk,v 1.5 2020/10/31 12:34:03 rillig Exp $
 #
 # Tests for the :@var@...${var}...@ variable modifier.
 
@@ -13,16 +13,20 @@ all: mod-loop-dollar
 # Therefore, in -dL mode, this is forbidden, see lint.mk.
 mod-loop-varname:
 	@echo :${:Uone two three:@${:Ubar:S,b,v,}@+${var}+@:Q}:
-	# ":::" is a very creative variable name, unlikely in practice
+
+	# ":::" is a very creative variable name, unlikely in practice.
 	# The expression ${\:\:\:} would not work since backslashes can only
 	# be escaped in the modifiers, but not in the variable name.
 	@echo :${:U1 2 3:@:::@x${${:U\:\:\:}}y@}:
+
 	# "@@" is another creative variable name.
 	@echo :${:U1 2 3:@\@\@@x${@@}y@}:
+
 	# Even "@" works as a variable name since the variable is installed
 	# in the "current" scope, which in this case is the one from the
 	# target.
 	@echo :$@: :${:U1 2 3:@\@@x${@}y@}: :$@:
+
 	# In extreme cases, even the backslash can be used as variable name.
 	# It needs to be doubled though.
 	@echo :${:U1 2 3:@\\@x${${:Ux:S,x,\\,}}y@}:
@@ -70,7 +74,7 @@ mod-loop-dollar:
 # It may happen that there are nested :@ modifiers that use the same name for
 # for the loop variable.  These modifiers influence each other.
 #
-# As of 2020-10-18, the :@ modifier is implemented by actually setting an
+# As of 2020-10-18, the :@ modifier is implemented by actually setting a
 # variable in the context of the expression and deleting it again after the
 # loop.  This is different from the .for loops, which substitute the variable
 # expression with ${:Uvalue}, leading to different unwanted side effects.
@@ -81,3 +85,18 @@ mod-loop-dollar:
 .if ${:U1 2 3:@i@$i${:Ua b c:@i@$i@}${i:Uu}@} != "1a b cu 2a b cu 3a b cu"
 .  error
 .endif
+
+# During the loop, the variable is actually defined and nonempty.
+# If the loop were implemented in the same way as the .for loop, the variable
+# would be neither defined nor nonempty since all expressions of the form
+# ${var} would have been replaced with ${:Uword} before evaluating them.
+.if defined(var)
+.  error
+.endif
+.if ${:Uword:@var@${defined(var):?def:undef} ${empty(var):?empty:nonempty}@} \
+!= "def nonempty"
+.  error
+.endif
+.if defined(var)
+.  error
+.endif



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 12:22:43 UTC 2020

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

Log Message:
make(1): remove redundant condition for regmatch_t.rm_eo being -1

If rm_so is -1, rm_eo is guaranteed to be -1 as well.


To generate a diff of this commit:
cvs rdiff -u -r1.616 -r1.617 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.616 src/usr.bin/make/var.c:1.617
--- src/usr.bin/make/var.c:1.616	Sat Oct 31 11:54:33 2020
+++ src/usr.bin/make/var.c	Sat Oct 31 12:22:43 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.616 2020/10/31 11:54:33 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.617 2020/10/31 12:22:43 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include"metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.616 2020/10/31 11:54:33 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.617 2020/10/31 12:22:43 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -1408,7 +1408,7 @@ tryagain:
 
 		if (n >= args->nsub) {
 		Error("No subexpression \\%zu", n);
-		} else if (m[n].rm_so == -1 && m[n].rm_eo == -1) {
+		} else if (m[n].rm_so == -1) {
 		Error("No match for subexpression \\%zu", n);
 		} else {
 		SepBuf_AddBytesBetween(buf, wp + m[n].rm_so,



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

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 12:20:36 UTC 2020

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

Log Message:
make(1): add tests for edge cases in the :C variable modifier


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-subst-regex.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-regex.mk
diff -u src/usr.bin/make/unit-tests/varmod-subst-regex.mk:1.4 src/usr.bin/make/unit-tests/varmod-subst-regex.mk:1.5
--- src/usr.bin/make/unit-tests/varmod-subst-regex.mk:1.4	Sat Oct 24 08:46:08 2020
+++ src/usr.bin/make/unit-tests/varmod-subst-regex.mk	Sat Oct 31 12:20:36 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-subst-regex.mk,v 1.4 2020/10/24 08:46:08 rillig Exp $
+# $NetBSD: varmod-subst-regex.mk,v 1.5 2020/10/31 12:20:36 rillig Exp $
 #
 # Tests for the :C,from,to, variable modifier.
 
@@ -48,21 +48,38 @@ all: mod-regex-errors
 # and since the matches must not overlap, the next possible match would
 # start at the 6, but at that point, there is only one character left,
 # and that cannot match the regular expression "..".  Therefore only the
-# "45" is doubled in the result.
+# "45" is doubled in the third word.
 .if ${:U1 23 456:C,..,\0\0,} != "1 2323 45456"
 .  error
 .endif
 
 # The modifier '1' applies the replacement at most once, across the whole
-# variable value, no matter whether it is a single big word or many small
+# expression value, no matter whether it is a single big word or many small
 # words.
 #
 # Up to 2020-08-28, the manual page said that the modifiers '1' and 'g'
-# were orthogonal, which was wrong.
+# were orthogonal, which was wrong.  It doesn't make sense to specify both
+# 'g' and '1' at the same time.
 .if ${:U12345 12345:C,.,\0\0,1} != "112345 12345"
 .  error
 .endif
 
+# A regular expression that matches the empty string applies before every
+# single character of the word.
+# XXX: Most other places where regular expression are used match at the end
+# of the string as well.
+.if ${:U1a2b3c:C,a*,*,g} != "*1**2*b*3*c"
+.  error
+.endif
+
+# A dot in the regular expression matches any character, even a newline.
+# In most other contexts where regular expressions are used, a dot matches
+# any character except newline.  In make, regcomp is called without
+# REG_NEWLINE, thus newline is an ordinary character.
+.if ${:U"${.newline}":C,.,.,g} != "..."
+.  error
+.endif
+
 # Multiple asterisks form an invalid regular expression.  This produces an
 # error message and (as of 2020-08-28) stops parsing in the middle of the
 # variable expression.  The unparsed part of the expression is then copied



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 12:04:24 UTC 2020

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

Log Message:
make(1): make memory allocation simpler in meta_create and meta_oodate

Since there is only a single variable left that needs to be freed at the
end (and probably never actually needs to be freed since nobody defines
an environment variable named .OBJDIR), there is no need to loop over
these variables.


To generate a diff of this commit:
cvs rdiff -u -r1.135 -r1.136 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.135 src/usr.bin/make/meta.c:1.136
--- src/usr.bin/make/meta.c:1.135	Sat Oct 31 11:54:33 2020
+++ src/usr.bin/make/meta.c	Sat Oct 31 12:04:24 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: meta.c,v 1.135 2020/10/31 11:54:33 rillig Exp $ */
+/*  $NetBSD: meta.c,v 1.136 2020/10/31 12:04:24 rillig Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -474,13 +474,11 @@ meta_create(BuildMon *pbm, GNode *gn)
 const char *tname;
 char *fname;
 const char *cp;
-void *p[5];/* >= possible uses */
-int i;
+void *objdir_freeIt;
 
 mf.fp = NULL;
-i = 0;
 
-dname = Var_Value(".OBJDIR", gn, [i++]);
+dname = Var_Value(".OBJDIR", gn, _freeIt);
 tname = GNode_VarTarget(gn);
 
 /* if this succeeds objdir is realpath of dname */
@@ -549,9 +547,7 @@ meta_create(BuildMon *pbm, GNode *gn)
 	gn->type |= OP_SILENT;
 }
  out:
-for (i--; i >= 0; i--) {
-	bmake_free(p[i]);
-}
+bmake_free(objdir_freeIt);
 
 return mf.fp;
 }
@@ -1090,16 +1086,13 @@ meta_oodate(GNode *gn, Boolean oodate)
 FILE *fp;
 Boolean needOODATE = FALSE;
 StringList *missingFiles;
-void *pa[4];			/* >= possible uses */
-int i;
 int have_filemon = FALSE;
+void *objdir_freeIt;
 
 if (oodate)
 	return oodate;		/* we're done */
 
-i = 0;
-
-dname = Var_Value(".OBJDIR", gn, [i++]);
+dname = Var_Value(".OBJDIR", gn, _freeIt);
 tname = GNode_VarTarget(gn);
 
 /* if this succeeds fname3 is realpath of dname */
@@ -1612,9 +1605,7 @@ meta_oodate(GNode *gn, Boolean oodate)
 }
 
  oodate_out:
-for (i--; i >= 0; i--) {
-	bmake_free(pa[i]);
-}
+bmake_free(objdir_freeIt);
 return oodate;
 }
 



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 11:54:33 UTC 2020

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

Log Message:
make(1): do not look up local variables like .TARGET anywhere else

Nobody defines a global variable named .TARGET since that would have
many unpredictable effects, applying to all targets at once.

Nobody defines an environment variable named .TARGET since that's
against the naming conventions for environment variables and would have
the same effect.

Because of this, there is no point looking up the variables that are
local to a GNode anywhere else.  This means they cannot come from the
environment and thus their value doesn't need to be freed after use,
which makes the code simpler.

The newly added accessor functions in make.h refer to external
functions, but since that header is not used anywhere outside of
usr.bin/make, it doesn't matter.  Between 2020-08-25 and 2020-10-30,
that header had been referenced by usr.bin/xinstall.


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 src/usr.bin/make/arch.c
cvs rdiff -u -r1.170 -r1.171 src/usr.bin/make/compat.c
cvs rdiff -u -r1.296 -r1.297 src/usr.bin/make/job.c
cvs rdiff -u -r1.183 -r1.184 src/usr.bin/make/make.c
cvs rdiff -u -r1.177 -r1.178 src/usr.bin/make/make.h
cvs rdiff -u -r1.134 -r1.135 src/usr.bin/make/meta.c
cvs rdiff -u -r1.147 -r1.148 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.229 -r1.230 src/usr.bin/make/suff.c
cvs rdiff -u -r1.615 -r1.616 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.149 src/usr.bin/make/arch.c:1.150
--- src/usr.bin/make/arch.c:1.149	Fri Oct 30 20:30:44 2020
+++ src/usr.bin/make/arch.c	Sat Oct 31 11:54:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.149 2020/10/30 20:30:44 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.150 2020/10/31 11:54:33 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
 #include"config.h"
 
 /*	"@(#)arch.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: arch.c,v 1.149 2020/10/30 20:30:44 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.150 2020/10/31 11:54:33 rillig Exp $");
 
 #ifdef TARGET_MACHINE
 #undef MAKE_MACHINE
@@ -861,15 +861,10 @@ Arch_Touch(GNode *gn)
 {
 FILE *arch;		/* Stream open to archive, positioned properly */
 struct ar_hdr arh;	/* Current header describing member */
-void *p1, *p2;
 
-arch = ArchFindMember(Var_Value(ARCHIVE, gn, ),
-			  Var_Value(MEMBER, gn, ),
+arch = ArchFindMember(GNode_VarArchive(gn), GNode_VarMember(gn),
 			  , "r+");
 
-bmake_free(p1);
-bmake_free(p2);
-
 snprintf(arh.ar_date, sizeof(arh.ar_date), "%-12ld", (long)now);
 
 if (arch != NULL) {
@@ -921,15 +916,8 @@ Arch_MTime(GNode *gn)
 {
 struct ar_hdr *arhPtr;	/* Header of desired member */
 time_t modTime;		/* Modification time as an integer */
-void *p1, *p2;
-
-arhPtr = ArchStatMember(Var_Value(ARCHIVE, gn, ),
-			Var_Value(MEMBER, gn, ),
-			TRUE);
-
-bmake_free(p1);
-bmake_free(p2);
 
+arhPtr = ArchStatMember(GNode_VarArchive(gn), GNode_VarMember(gn), TRUE);
 if (arhPtr != NULL) {
 	modTime = (time_t)strtol(arhPtr->ar_date, NULL, 10);
 } else {

Index: src/usr.bin/make/compat.c
diff -u src/usr.bin/make/compat.c:1.170 src/usr.bin/make/compat.c:1.171
--- src/usr.bin/make/compat.c:1.170	Fri Oct 30 20:30:44 2020
+++ src/usr.bin/make/compat.c	Sat Oct 31 11:54:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.170 2020/10/30 20:30:44 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.171 2020/10/31 11:54:33 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
 #include "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.170 2020/10/30 20:30:44 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.171 2020/10/31 11:54:33 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -110,14 +110,11 @@ static void
 CompatDeleteTarget(GNode *gn)
 {
 if (gn != NULL && !Targ_Precious(gn)) {
-	void *file_freeIt;
-	const char *file = Var_Value(TARGET, gn, _freeIt);
+	const char *file = GNode_VarTarget(gn);
 
 	if (!opts.noExecute && eunlink(file) != -1) {
 	Error("*** %s removed", file);
 	}
-
-	bmake_free(file_freeIt);
 }
 }
 
@@ -502,11 +499,8 @@ Compat_Make(GNode *gn, GNode *pgn)
 	goto cohorts;
 	}
 
-	if (Lst_FindDatum(gn->implicitParents, pgn) != NULL) {
-	void *target_freeIt;
-	Var_Set(IMPSRC, Var_Value(TARGET, gn, _freeIt), pgn);
-	bmake_free(target_freeIt);
-	}
+	if (Lst_FindDatum(gn->implicitParents, pgn) != NULL)
+	Var_Set(IMPSRC, GNode_VarTarget(gn), pgn);
 
 	/*
 	 * All the children were made ok. Now youngestChild->mtime contains the
@@ -597,10 

CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 11:34:30 UTC 2020

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

Log Message:
make(1): reduce the scope where recursive expressions are detected

Only the call to Var_Subst needs to be protected since the other
functions have nothing to do with expanding variables.


To generate a diff of this commit:
cvs rdiff -u -r1.417 -r1.418 src/usr.bin/make/main.c
cvs rdiff -u -r1.614 -r1.615 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/main.c
diff -u src/usr.bin/make/main.c:1.417 src/usr.bin/make/main.c:1.418
--- src/usr.bin/make/main.c:1.417	Sat Oct 31 09:35:58 2020
+++ src/usr.bin/make/main.c	Sat Oct 31 11:34:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.417 2020/10/31 09:35:58 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.418 2020/10/31 11:34:30 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -118,7 +118,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.417 2020/10/31 09:35:58 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.418 2020/10/31 11:34:30 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	"The Regents of the University of California.  "
@@ -1827,7 +1827,7 @@ Error(const char *fmt, ...)
 
 /* Produce a Fatal error message, then exit immediately.
  *
- * If jobs are running, waits for them to finish. */
+ * If jobs are running, wait for them to finish. */
 void
 Fatal(const char *fmt, ...)
 {

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.614 src/usr.bin/make/var.c:1.615
--- src/usr.bin/make/var.c:1.614	Sat Oct 31 09:57:47 2020
+++ src/usr.bin/make/var.c	Sat Oct 31 11:34:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.614 2020/10/31 09:57:47 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.615 2020/10/31 11:34:30 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include"metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.614 2020/10/31 09:57:47 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.615 2020/10/31 11:34:30 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -3662,12 +3662,8 @@ Var_Parse(const char **pp, GNode *ctxt, 
 	free(varname);
 }
 
-if (v->flags & VAR_IN_USE) {
+if (v->flags & VAR_IN_USE)
 	Fatal("Variable %s is recursive.", v->name);
-	/*NOTREACHED*/
-} else {
-	v->flags |= VAR_IN_USE;
-}
 
 /*
  * Before doing any modification, we have to make sure the value
@@ -3683,13 +3679,13 @@ Var_Parse(const char **pp, GNode *ctxt, 
 	VarEvalFlags nested_eflags = eflags;
 	if (DEBUG(LINT))
 	nested_eflags &= ~(unsigned)VARE_UNDEFERR;
+	v->flags |= VAR_IN_USE;
 	(void)Var_Subst(nstr, ctxt, nested_eflags, );
+	v->flags &= ~(unsigned)VAR_IN_USE;
 	/* TODO: handle errors */
 	*freePtr = nstr;
 }
 
-v->flags &= ~(unsigned)VAR_IN_USE;
-
 if (haveModifier || extramodifiers != NULL) {
 	void *extraFree;
 



CVS commit: src

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 11:30:57 UTC 2020

Modified Files:
src/distrib/sets/lists/tests: mi
src/usr.bin/make/unit-tests: Makefile
Added Files:
src/usr.bin/make/unit-tests: var-recursive.exp var-recursive.mk

Log Message:
make(1): add test for recursive variable expressions


To generate a diff of this commit:
cvs rdiff -u -r1.953 -r1.954 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.178 -r1.179 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/var-recursive.exp \
src/usr.bin/make/unit-tests/var-recursive.mk

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.953 src/distrib/sets/lists/tests/mi:1.954
--- src/distrib/sets/lists/tests/mi:1.953	Sat Oct 31 11:06:24 2020
+++ src/distrib/sets/lists/tests/mi	Sat Oct 31 11:30:56 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.953 2020/10/31 11:06:24 rillig Exp $
+# $NetBSD: mi,v 1.954 2020/10/31 11:30:56 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5300,6 +5300,8 @@
 ./usr/tests/usr.bin/make/unit-tests/var-op-sunsh.mktests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/var-op.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/var-op.mk	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/var-recursive.exptests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/var-recursive.mktests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varcmd.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varcmd.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/vardebug.exptests-usr.bin-tests	compattestfile,atf

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.178 src/usr.bin/make/unit-tests/Makefile:1.179
--- src/usr.bin/make/unit-tests/Makefile:1.178	Sat Oct 31 11:06:24 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sat Oct 31 11:30:57 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.178 2020/10/31 11:06:24 rillig Exp $
+# $NetBSD: Makefile,v 1.179 2020/10/31 11:30:57 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -278,6 +278,7 @@ TESTS+=		var-op-default
 TESTS+=		var-op-expand
 TESTS+=		var-op-shell
 TESTS+=		var-op-sunsh
+TESTS+=		var-recursive
 TESTS+=		varcmd
 TESTS+=		vardebug
 TESTS+=		varfind

Added files:

Index: src/usr.bin/make/unit-tests/var-recursive.exp
diff -u /dev/null src/usr.bin/make/unit-tests/var-recursive.exp:1.1
--- /dev/null	Sat Oct 31 11:30:57 2020
+++ src/usr.bin/make/unit-tests/var-recursive.exp	Sat Oct 31 11:30:57 2020
@@ -0,0 +1,9 @@
+make: "var-recursive.mk" line 20: still there
+Variable DIRECT is recursive.
+
+make: stopped in unit-tests
+Variable INDIRECT1 is recursive.
+
+make: stopped in unit-tests
+make: "var-recursive.mk" line 35: ok
+exit status 0
Index: src/usr.bin/make/unit-tests/var-recursive.mk
diff -u /dev/null src/usr.bin/make/unit-tests/var-recursive.mk:1.1
--- /dev/null	Sat Oct 31 11:30:57 2020
+++ src/usr.bin/make/unit-tests/var-recursive.mk	Sat Oct 31 11:30:57 2020
@@ -0,0 +1,41 @@
+# $NetBSD: var-recursive.mk,v 1.1 2020/10/31 11:30:57 rillig Exp $
+#
+# Tests for variable expressions that refer to themselves and thus
+# cannot be evaluated.
+
+TESTS=	direct indirect conditional
+
+# Since make exits immediately when it detects a recursive expression,
+# the actual tests are run in sub-makes.
+TEST?=	# none
+.if ${TEST} == ""
+all:
+.for test in ${TESTS}
+	@${.MAKE} -f ${MAKEFILE} TEST=${test} || :
+.endfor
+
+.elif ${TEST} == direct
+
+DIRECT=	${DIRECT}	# Defining a recursive variable is not yet an error.
+.  info still there	# Therefore this line is printed.
+.  info ${DIRECT}	# But expanding the variable is an error.
+
+.elif ${TEST} == indirect
+
+# The chain of variables that refer to each other may be long.
+INDIRECT1=	${INDIRECT2}
+INDIRECT2=	${INDIRECT1}
+.  info ${INDIRECT1}
+
+.elif ${TEST} == conditional
+
+# The variable refers to itself, but only in the branch of a condition that
+# is never satisfied and is thus not evaluated.
+CONDITIONAL=	${1:?ok:${CONDITIONAL}}
+.  info ${CONDITIONAL}
+
+.else
+.  error Unknown test "${TEST}"
+.endif
+
+all:



CVS commit: src

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 11:06:24 UTC 2020

Modified Files:
src/distrib/sets/lists/tests: mi
src/usr.bin/make/unit-tests: Makefile varmod-sysv.mk
Removed Files:
src/usr.bin/make/unit-tests: sysv.exp sysv.mk

Log Message:
make(1): merge the SysV modifier tests into varmod-sysv


To generate a diff of this commit:
cvs rdiff -u -r1.952 -r1.953 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.177 -r1.178 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.10 -r0 src/usr.bin/make/unit-tests/sysv.exp
cvs rdiff -u -r1.15 -r0 src/usr.bin/make/unit-tests/sysv.mk
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-sysv.mk

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.952 src/distrib/sets/lists/tests/mi:1.953
--- src/distrib/sets/lists/tests/mi:1.952	Sat Oct 31 11:03:18 2020
+++ src/distrib/sets/lists/tests/mi	Sat Oct 31 11:06:24 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.952 2020/10/31 11:03:18 rillig Exp $
+# $NetBSD: mi,v 1.953 2020/10/31 11:06:24 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5264,8 +5264,8 @@
 ./usr/tests/usr.bin/make/unit-tests/suffixes.mk	tests-obsolete		obsolete
 ./usr/tests/usr.bin/make/unit-tests/sunshcmd.exptests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/sunshcmd.mk	tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/make/unit-tests/sysv.exp	tests-usr.bin-tests	compattestfile,atf
-./usr/tests/usr.bin/make/unit-tests/sysv.mk	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/sysv.exp	tests-obsolete		obsolete
+./usr/tests/usr.bin/make/unit-tests/sysv.mk	tests-obsolete		obsolete
 ./usr/tests/usr.bin/make/unit-tests/ternary.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/ternary.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/unexport-env.exptests-usr.bin-tests	compattestfile,atf

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.177 src/usr.bin/make/unit-tests/Makefile:1.178
--- src/usr.bin/make/unit-tests/Makefile:1.177	Fri Oct 30 15:03:58 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sat Oct 31 11:06:24 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.177 2020/10/30 15:03:58 rillig Exp $
+# $NetBSD: Makefile,v 1.178 2020/10/31 11:06:24 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -261,7 +261,6 @@ TESTS+=		suff-transform-endless
 TESTS+=		suff-transform-expand
 TESTS+=		suff-transform-select
 TESTS+=		sunshcmd
-TESTS+=		sysv
 TESTS+=		ternary
 TESTS+=		unexport
 TESTS+=		unexport-env

Index: src/usr.bin/make/unit-tests/varmod-sysv.mk
diff -u src/usr.bin/make/unit-tests/varmod-sysv.mk:1.8 src/usr.bin/make/unit-tests/varmod-sysv.mk:1.9
--- src/usr.bin/make/unit-tests/varmod-sysv.mk:1.8	Sat Oct 31 10:18:32 2020
+++ src/usr.bin/make/unit-tests/varmod-sysv.mk	Sat Oct 31 11:06:24 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-sysv.mk,v 1.8 2020/10/31 10:18:32 rillig Exp $
+# $NetBSD: varmod-sysv.mk,v 1.9 2020/10/31 11:06:24 rillig Exp $
 #
 # Tests for the ${VAR:from=to} variable modifier, which replaces the suffix
 # "from" with "to".  It can also use '%' as a wildcard.
@@ -35,6 +35,13 @@
 .  error
 .endif
 
+# The :from=to modifier can also be used to surround each word by strings.
+# It might be tempting to use this for enclosing a string in quotes for the
+# shell, but that's the job of the :Q modifier.
+.if ${one two three:L:%=(%)} != "(one) (two) (three)"
+.  error
+.endif
+
 # When the :from=to modifier is parsed, it lasts until the closing brace
 # or parenthesis.  The :Q in the below expression may look like a modifier
 # but isn't.  It is part of the replacement string.
@@ -42,6 +49,38 @@
 .  error
 .endif
 
+# In the :from=to modifier, both parts can contain variable expressions.
+.if ${one two:L:${:Uone}=${:U1}} != "1 two"
+.  error
+.endif
+
+# In the :from=to modifier, the "from" part is expanded exactly once.
+.if ${:U\$ \$\$ \$\$\$\$:${:U\$\$\$\$}=4} != "\$ \$\$ 4"
+.  error
+.endif
+
+# In the :from=to modifier, the "to" part is expanded exactly twice.
+# XXX: The right-hand side should be expanded only once.
+# XXX: It's hard to get the escaping correct here, and to read that.
+# XXX: It's not intuitive why the closing brace must be escaped but not
+#  the opening brace.
+.if ${:U1 2 4:4=${:Uonce\${\:Utwice\}}} != "1 2 oncetwice"
+.  error
+.endif
+
+# The replacement string can contain spaces, thereby changing the number
+# of words in the variable expression.
+.if ${In:L:%=% ${:Uthe Sun}} != "In the Sun"
+.  error
+.endif
+
+# If the variable is empty, it is debatable whether it consists of a single
+# empty word, or no word at all.  The :from=to modifier treats it as no
+# word at all.
+.if 

CVS commit: src/distrib/sets/lists/tests

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 11:03:18 UTC 2020

Modified Files:
src/distrib/sets/lists/tests: mi

Log Message:
use the same indentation for all libcurses test files


To generate a diff of this commit:
cvs rdiff -u -r1.951 -r1.952 src/distrib/sets/lists/tests/mi

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.951 src/distrib/sets/lists/tests/mi:1.952
--- src/distrib/sets/lists/tests/mi:1.951	Sat Oct 24 04:47:43 2020
+++ src/distrib/sets/lists/tests/mi	Sat Oct 31 11:03:18 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.951 2020/10/24 04:47:43 blymn Exp $
+# $NetBSD: mi,v 1.952 2020/10/31 11:03:18 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -3257,262 +3257,262 @@
 ./usr/tests/lib/libcurses/Atffile			tests-lib-tests		compattestfile,atf
 ./usr/tests/lib/libcurses/Kyuafile			tests-lib-tests		compattestfile,atf,kyua
 ./usr/tests/lib/libcurses/check_files			tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/add_wch1.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/add_wch2.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/add_wch3.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/addch.chk		tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/addchstr.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/addchstr2.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/addchstr3.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/addnwstr1.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/addnwstr2.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/addstr.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/addwstr1.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/addwstr2.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/addwstr3.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/attributes.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/background1.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/background2.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/background3.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/background4.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/background5.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/bell.chk		tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/bkgdset1.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/blank.chk		tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/border_set1.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/border_set2.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/box_set1.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/box_set2.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/box_standout.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/chgat1.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/chgat2.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/chgat3.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/clear1.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/clear10.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/clear2.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/clear3.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/clear4.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/clear5.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/clear6.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/clear7.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/clear8.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/clear9.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/clearok1.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/clearok2.chk	tests-lib-tests		compattestfile,atf
-./usr/tests/lib/libcurses/check_files/clearok3.chk	tests-lib-tests		compattestfile,atf
+./usr/tests/lib/libcurses/check_files/add_wch1.chk		

CVS commit: src/lib/libc/sys

2020-10-31 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Oct 31 10:51:59 UTC 2020

Modified Files:
src/lib/libc/sys: kqueue.2

Log Message:
Remove trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/lib/libc/sys/kqueue.2

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

Modified files:

Index: src/lib/libc/sys/kqueue.2
diff -u src/lib/libc/sys/kqueue.2:1.51 src/lib/libc/sys/kqueue.2:1.52
--- src/lib/libc/sys/kqueue.2:1.51	Sat Oct 31 01:08:31 2020
+++ src/lib/libc/sys/kqueue.2	Sat Oct 31 10:51:59 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: kqueue.2,v 1.51 2020/10/31 01:08:31 christos Exp $
+.\"	$NetBSD: kqueue.2,v 1.52 2020/10/31 10:51:59 wiz Exp $
 .\"
 .\" Copyright (c) 2000 Jonathan Lemon
 .\" All rights reserved.
@@ -137,7 +137,7 @@ The
 .Fa eventlist
 argument
 is a pointer to an array of kevent structures.
-The 
+The
 .Fa nevents
 argument
 determines the size of



CVS commit: src/share/man/man9

2020-10-31 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sat Oct 31 10:48:17 UTC 2020

Modified Files:
src/share/man/man9: ddb.9

Log Message:
Improve wording.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/share/man/man9/ddb.9

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

Modified files:

Index: src/share/man/man9/ddb.9
diff -u src/share/man/man9/ddb.9:1.2 src/share/man/man9/ddb.9:1.3
--- src/share/man/man9/ddb.9:1.2	Fri Oct 30 22:29:30 2020
+++ src/share/man/man9/ddb.9	Sat Oct 31 10:48:17 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ddb.9,v 1.2 2020/10/30 22:29:30 uwe Exp $
+.\"	$NetBSD: ddb.9,v 1.3 2020/10/31 10:48:17 wiz Exp $
 .\"
 .\" Copyright (c) 2020 Valery Ushakov
 .\" All rights reserved.
@@ -95,7 +95,7 @@ command.
 .Pp
 The
 .Fa commands
-is an array of
+argument is an array of
 .Vt struct db_command\|
 entries.
 The initializer list for the array should use the
@@ -103,7 +103,7 @@ The initializer list for the array shoul
 macro for its entries.
 The
 .Fa name
-is the name of the debugger command.
+argument is the name of the debugger command.
 An entry with
 .Dv NULL
 .Fa name



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

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 10:18:32 UTC 2020

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

Log Message:
make(1): add tutorial for the :from=to variable modifier


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-sysv.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-sysv.mk
diff -u src/usr.bin/make/unit-tests/varmod-sysv.mk:1.7 src/usr.bin/make/unit-tests/varmod-sysv.mk:1.8
--- src/usr.bin/make/unit-tests/varmod-sysv.mk:1.7	Sat Oct 31 09:03:36 2020
+++ src/usr.bin/make/unit-tests/varmod-sysv.mk	Sat Oct 31 10:18:32 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-sysv.mk,v 1.7 2020/10/31 09:03:36 rillig Exp $
+# $NetBSD: varmod-sysv.mk,v 1.8 2020/10/31 10:18:32 rillig Exp $
 #
 # Tests for the ${VAR:from=to} variable modifier, which replaces the suffix
 # "from" with "to".  It can also use '%' as a wildcard.
@@ -7,10 +7,37 @@
 #
 # See ApplyModifier_SysV.
 
-all:
+# A typical use case for the :from=to modifier is conversion of filename
+# extensions.
+.if ${src.c:L:.c=.o} != "src.o"
+.  error
+.endif
+
+# The modifier applies to each word on its own.
+.if ${one.c two.c three.c:L:.c=.o} != "one.o two.o three.o"
+.  error
+.endif
+
+# Words that don't match the pattern are passed unmodified.
+.if ${src.c src.h:L:.c=.o} != "src.o src.h"
+.  error
+.endif
 
-# The :Q looks like a modifier but isn't.
-# It is part of the replacement string.
+# The :from=to modifier is therefore often combined with the :M modifier.
+.if ${src.c src.h:L:M*.c:.c=.o} != "src.o"
+.  error
+.endif
+
+# Another use case for the :from=to modifier is to append a suffix to each
+# word.  In this case, the "from" string is empty, therefore it always
+# matches.  The same effect can be achieved with the :S,$,teen, modifier.
+.if ${four six seven nine:L:=teen} != "fourteen sixteen seventeen nineteen"
+.  error
+.endif
+
+# When the :from=to modifier is parsed, it lasts until the closing brace
+# or parenthesis.  The :Q in the below expression may look like a modifier
+# but isn't.  It is part of the replacement string.
 .if ${a b c d e:L:%a=x:Q} != "x:Q b c d e"
 .  error
 .endif
@@ -127,3 +154,5 @@ INDIRECT=	1:${VALUE} 2:$${VALUE} 4:{
 .if ${x:L:x=${INDIRECT}} != "1:value 2:value 4:\${VALUE}"
 .  error
 .endif
+
+all:



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 09:57:47 UTC 2020

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

Log Message:
make(1): fix indentation in source code


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 src/usr.bin/make/meta.c
cvs rdiff -u -r1.613 -r1.614 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/meta.c
diff -u src/usr.bin/make/meta.c:1.133 src/usr.bin/make/meta.c:1.134
--- src/usr.bin/make/meta.c:1.133	Fri Oct 30 20:30:44 2020
+++ src/usr.bin/make/meta.c	Sat Oct 31 09:57:47 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: meta.c,v 1.133 2020/10/30 20:30:44 rillig Exp $ */
+/*  $NetBSD: meta.c,v 1.134 2020/10/31 09:57:47 rillig Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -326,7 +326,7 @@ is_submake(void *cmdp, void *gnp)
 int rc = 0;/* keep looking */
 
 if (!p_make) {
-void *dontFreeIt;
+	void *dontFreeIt;
 	p_make = Var_Value(".MAKE", gn, );
 	p_len = strlen(p_make);
 }
@@ -1602,7 +1602,7 @@ meta_oodate(GNode *gn, Boolean oodate)
 Lst_Destroy(missingFiles, free);
 
 if (oodate && needOODATE) {
-void *freeIt;
+	void *freeIt;
 	/*
 	 * Target uses .OODATE which is empty; or we wouldn't be here.
 	 * We have decided it is oodate, so .OODATE needs to be set.

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.613 src/usr.bin/make/var.c:1.614
--- src/usr.bin/make/var.c:1.613	Sat Oct 31 09:27:19 2020
+++ src/usr.bin/make/var.c	Sat Oct 31 09:57:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.613 2020/10/31 09:27:19 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.614 2020/10/31 09:57:47 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include"metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.613 2020/10/31 09:27:19 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.614 2020/10/31 09:57:47 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -751,7 +751,7 @@ Var_UnExport(const char *str)
 	 * just delete .MAKE.EXPORTED below.
 	 */
 	if (varnames == str) {
-	/* XXX: v->name is injected without escaping it */
+		/* XXX: v->name is injected without escaping it */
 		char *expr = str_concat3("${" MAKE_EXPORTED ":N", v->name, "}");
 		char *cp;
 		(void)Var_Subst(expr, VAR_GLOBAL, VARE_WANTRES, );
@@ -947,7 +947,7 @@ Var_Append(const char *name, const char 
 	/* XXX: name is expanded for the second time */
 	Var_Set(name, val, ctxt);
 } else if (v->flags & VAR_READONLY) {
-VAR_DEBUG1("Ignoring append to %s since it is read-only\n", name);
+	VAR_DEBUG1("Ignoring append to %s since it is read-only\n", name);
 } else if (ctxt == VAR_CMDLINE || !(v->flags & VAR_FROM_CMD)) {
 	Buf_AddByte(>val, ' ');
 	Buf_AddStr(>val, val);



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 09:47:28 UTC 2020

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

Log Message:
make(1): extract loadedfile_mmap from loadfile


To generate a diff of this commit:
cvs rdiff -u -r1.413 -r1.414 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/parse.c
diff -u src/usr.bin/make/parse.c:1.413 src/usr.bin/make/parse.c:1.414
--- src/usr.bin/make/parse.c:1.413	Fri Oct 30 20:30:44 2020
+++ src/usr.bin/make/parse.c	Sat Oct 31 09:47:27 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.413 2020/10/30 20:30:44 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.414 2020/10/31 09:47:27 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.413 2020/10/30 20:30:44 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.414 2020/10/31 09:47:27 rillig Exp $");
 
 /* types and constants */
 
@@ -283,7 +283,7 @@ CurFile(void)
 /* include paths */
 SearchPath *parseIncPath;	/* dirs for "..." includes */
 SearchPath *sysIncPath;		/* dirs for <...> includes */
-SearchPath *defSysIncPath;		/* default for sysIncPath */
+SearchPath *defSysIncPath;	/* default for sysIncPath */
 
 /* parser tables */
 
@@ -432,41 +432,13 @@ load_getsize(int fd, size_t *ret)
 	return TRUE;
 }
 
-/*
- * Read in a file.
- *
- * Until the path search logic can be moved under here instead of
- * being in the caller in another source file, we need to have the fd
- * passed in already open. Bleh.
- *
- * If the path is NULL use stdin and (to insure against fd leaks)
- * assert that the caller passed in -1.
- */
-static struct loadedfile *
-loadfile(const char *path, int fd)
+static Boolean
+loadedfile_mmap(struct loadedfile *lf, int fd)
 {
-	struct loadedfile *lf;
 	static unsigned long pagesize = 0;
-	ssize_t result;
-	size_t bufpos;
-
-	lf = loadedfile_create(path);
-
-	if (path == NULL) {
-		assert(fd == -1);
-		fd = STDIN_FILENO;
-	} else {
-#if 0 /* notyet */
-		fd = open(path, O_RDONLY);
-		if (fd < 0) {
-			...
-			Error("%s: %s", path, strerror(errno));
-			exit(1);
-		}
-#endif
-	}
 
 	if (load_getsize(fd, >len)) {
+
 		/* found a size, try mmap */
 		if (pagesize == 0)
 			pagesize = (unsigned long)sysconf(_SC_PAGESIZE);
@@ -474,7 +446,7 @@ loadfile(const char *path, int fd)
 			pagesize = 0x1000;
 		}
 		/* round size up to a page */
-		lf->maplen = pagesize * ((lf->len + pagesize - 1)/pagesize);
+		lf->maplen = pagesize * ((lf->len + pagesize - 1) / pagesize);
 
 		/*
 		 * XXX hack for dealing with empty files; remove when
@@ -501,9 +473,47 @@ loadfile(const char *path, int fd)
 lf->maplen = 0;
 lf->buf = b;
 			}
-			goto done;
+			return TRUE;
 		}
 	}
+	return FALSE;
+}
+
+/*
+ * Read in a file.
+ *
+ * Until the path search logic can be moved under here instead of
+ * being in the caller in another source file, we need to have the fd
+ * passed in already open. Bleh.
+ *
+ * If the path is NULL use stdin and (to insure against fd leaks)
+ * assert that the caller passed in -1.
+ */
+static struct loadedfile *
+loadfile(const char *path, int fd)
+{
+	struct loadedfile *lf;
+	ssize_t result;
+	size_t bufpos;
+
+	lf = loadedfile_create(path);
+
+	if (path == NULL) {
+		assert(fd == -1);
+		fd = STDIN_FILENO;
+	} else {
+#if 0 /* notyet */
+		fd = open(path, O_RDONLY);
+		if (fd < 0) {
+			...
+			Error("%s: %s", path, strerror(errno));
+			exit(1);
+		}
+#endif
+	}
+
+	if (loadedfile_mmap(lf, fd))
+		goto done;
 
 	/* cannot mmap; load the traditional way */
 



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 09:35:58 UTC 2020

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

Log Message:
make(1): remove redundant :tl from getBoolean

Uppercase and lowercase letters are already handled the same by
s2Boolean, which makes the :tl modifier redundant.


To generate a diff of this commit:
cvs rdiff -u -r1.416 -r1.417 src/usr.bin/make/main.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/main.c
diff -u src/usr.bin/make/main.c:1.416 src/usr.bin/make/main.c:1.417
--- src/usr.bin/make/main.c:1.416	Sat Oct 31 09:27:19 2020
+++ src/usr.bin/make/main.c	Sat Oct 31 09:35:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.416 2020/10/31 09:27:19 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.417 2020/10/31 09:35:58 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -118,7 +118,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.416 2020/10/31 09:27:19 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.417 2020/10/31 09:35:58 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	"The Regents of the University of California.  "
@@ -2049,7 +2049,7 @@ dieQuietly(GNode *gn, int bf)
 static int quietly = -1;
 
 if (quietly < 0) {
-	if (DEBUG(JOB) || getBoolean(".MAKE.DIE_QUIETLY", 1) == 0)
+	if (DEBUG(JOB) || !getBoolean(".MAKE.DIE_QUIETLY", TRUE))
 	quietly = 0;
 	else if (bf >= 0)
 	quietly = bf;
@@ -2225,16 +2225,16 @@ s2Boolean(const char *s, Boolean bf)
 }
 
 /*
- * Return a Boolean based on setting of a knob.
+ * Return a Boolean based on a variable.
  *
- * If the knob is not set, the supplied default is the return value.
- * If set, anything that looks or smells like "No", "False", "Off", "0" etc,
+ * If the knob is not set, return the fallback.
+ * If set, anything that looks or smells like "No", "False", "Off", "0", etc.
  * is FALSE, otherwise TRUE.
  */
 Boolean
-getBoolean(const char *name, Boolean fallback)
+getBoolean(const char *varname, Boolean fallback)
 {
-char *expr = str_concat3("${", name, ":U:tl}");
+char *expr = str_concat3("${", varname, ":U}");
 char *value;
 Boolean res;
 



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 09:27:20 UTC 2020

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

Log Message:
make(1): remove redundant null check from s2Boolean


To generate a diff of this commit:
cvs rdiff -u -r1.415 -r1.416 src/usr.bin/make/main.c
cvs rdiff -u -r1.612 -r1.613 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/main.c
diff -u src/usr.bin/make/main.c:1.415 src/usr.bin/make/main.c:1.416
--- src/usr.bin/make/main.c:1.415	Sat Oct 31 09:23:38 2020
+++ src/usr.bin/make/main.c	Sat Oct 31 09:27:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.415 2020/10/31 09:23:38 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.416 2020/10/31 09:27:19 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -118,7 +118,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.415 2020/10/31 09:23:38 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.416 2020/10/31 09:27:19 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	"The Regents of the University of California.  "
@@ -2206,22 +2206,20 @@ mkTempFile(const char *pattern, char **o
 Boolean
 s2Boolean(const char *s, Boolean bf)
 {
-if (s) {
-	switch(*s) {
-	case '\0':			/* not set - the default wins */
-	break;
-	case '0':
-	case 'F':
-	case 'f':
-	case 'N':
-	case 'n':
-	return FALSE;
-	case 'O':
-	case 'o':
-	return s[1] != 'F' && s[1] != 'f';
-	default:
-	return TRUE;
-	}
+switch(s[0]) {
+case '\0':			/* not set - the default wins */
+	break;
+case '0':
+case 'F':
+case 'f':
+case 'N':
+case 'n':
+	return FALSE;
+case 'O':
+case 'o':
+	return s[1] != 'F' && s[1] != 'f';
+default:
+	return TRUE;
 }
 return bf;
 }

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.612 src/usr.bin/make/var.c:1.613
--- src/usr.bin/make/var.c:1.612	Sat Oct 31 09:03:36 2020
+++ src/usr.bin/make/var.c	Sat Oct 31 09:27:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.612 2020/10/31 09:03:36 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.613 2020/10/31 09:27:19 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include"metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.612 2020/10/31 09:03:36 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.613 2020/10/31 09:27:19 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -853,7 +853,7 @@ Var_Set_with_flags(const char *name, con
 	 * Makefile settings.
 	 */
 	if (!opts.varNoExportEnv)
-	setenv(name, val ? val : "", 1);
+	setenv(name, val, 1);
 
 	Var_Append(MAKEOVERRIDES, name, VAR_GLOBAL);
 }



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 09:23:38 UTC 2020

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

Log Message:
make(1): write s2Boolean in a more compact form


To generate a diff of this commit:
cvs rdiff -u -r1.414 -r1.415 src/usr.bin/make/main.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/main.c
diff -u src/usr.bin/make/main.c:1.414 src/usr.bin/make/main.c:1.415
--- src/usr.bin/make/main.c:1.414	Sat Oct 31 09:20:07 2020
+++ src/usr.bin/make/main.c	Sat Oct 31 09:23:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.414 2020/10/31 09:20:07 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.415 2020/10/31 09:23:38 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -118,7 +118,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.414 2020/10/31 09:20:07 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.415 2020/10/31 09:23:38 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	"The Regents of the University of California.  "
@@ -2215,23 +2215,12 @@ s2Boolean(const char *s, Boolean bf)
 	case 'f':
 	case 'N':
 	case 'n':
-	bf = FALSE;
-	break;
+	return FALSE;
 	case 'O':
 	case 'o':
-	switch (s[1]) {
-	case 'F':
-	case 'f':
-		bf = FALSE;
-		break;
-	default:
-		bf = TRUE;
-		break;
-	}
-	break;
+	return s[1] != 'F' && s[1] != 'f';
 	default:
-	bf = TRUE;
-	break;
+	return TRUE;
 	}
 }
 return bf;



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 09:20:07 UTC 2020

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

Log Message:
make(1): clean up mkTempFile


To generate a diff of this commit:
cvs rdiff -u -r1.413 -r1.414 src/usr.bin/make/main.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/main.c
diff -u src/usr.bin/make/main.c:1.413 src/usr.bin/make/main.c:1.414
--- src/usr.bin/make/main.c:1.413	Sat Oct 31 06:18:21 2020
+++ src/usr.bin/make/main.c	Sat Oct 31 09:20:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.413 2020/10/31 06:18:21 sjg Exp $	*/
+/*	$NetBSD: main.c,v 1.414 2020/10/31 09:20:07 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -118,7 +118,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.413 2020/10/31 06:18:21 sjg Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.414 2020/10/31 09:20:07 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	"The Regents of the University of California.  "
@@ -2169,19 +2169,19 @@ getTmpdir(void)
 
 /*
  * Create and open a temp file using "pattern".
- * If "fnamep" is provided set it to a copy of the filename created.
+ * If out_fname is provided, set it to a copy of the filename created.
  * Otherwise unlink the file once open.
  */
 int
-mkTempFile(const char *pattern, char **fnamep)
+mkTempFile(const char *pattern, char **out_fname)
 {
 static char *tmpdir = NULL;
 char tfile[MAXPATHLEN];
 int fd;
 
-if (!pattern)
+if (pattern != NULL)
 	pattern = TMPPAT;
-if (!tmpdir)
+if (tmpdir == NULL)
 	tmpdir = getTmpdir();
 if (pattern[0] == '/') {
 	snprintf(tfile, sizeof(tfile), "%s", pattern);
@@ -2190,8 +2190,8 @@ mkTempFile(const char *pattern, char **f
 }
 if ((fd = mkstemp(tfile)) < 0)
 	Punt("Could not create temporary file %s: %s", tfile, strerror(errno));
-if (fnamep) {
-	*fnamep = bmake_strdup(tfile);
+if (out_fname) {
+	*out_fname = bmake_strdup(tfile);
 } else {
 	unlink(tfile);			/* we just want the descriptor */
 }



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 09:03:36 UTC 2020

Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: varmod-sysv.mk

Log Message:
make(1): remove redundant code branch in SysVMatch

The general code path of parsing :from=to achieves the same effect.


To generate a diff of this commit:
cvs rdiff -u -r1.611 -r1.612 src/usr.bin/make/var.c
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-sysv.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.611 src/usr.bin/make/var.c:1.612
--- src/usr.bin/make/var.c:1.611	Sat Oct 31 08:40:54 2020
+++ src/usr.bin/make/var.c	Sat Oct 31 09:03:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.611 2020/10/31 08:40:54 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.612 2020/10/31 09:03:36 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include"metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.611 2020/10/31 08:40:54 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.612 2020/10/31 09:03:36 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -1181,11 +1181,6 @@ SysVMatch(const char *word, const char *
 const char *w_tail;
 
 *out_hasPercent = FALSE;
-if (*p == '\0') {		/* ${VAR:=suffix} */
-	*out_match_len = strlen(w);	/* Null pattern is the whole string */
-	return w;
-}
-
 percent = strchr(p, '%');
 if (percent != NULL) {	/* ${VAR:...%...=...} */
 	*out_hasPercent = TRUE;

Index: src/usr.bin/make/unit-tests/varmod-sysv.mk
diff -u src/usr.bin/make/unit-tests/varmod-sysv.mk:1.6 src/usr.bin/make/unit-tests/varmod-sysv.mk:1.7
--- src/usr.bin/make/unit-tests/varmod-sysv.mk:1.6	Sat Oct 31 08:31:37 2020
+++ src/usr.bin/make/unit-tests/varmod-sysv.mk	Sat Oct 31 09:03:36 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-sysv.mk,v 1.6 2020/10/31 08:31:37 rillig Exp $
+# $NetBSD: varmod-sysv.mk,v 1.7 2020/10/31 09:03:36 rillig Exp $
 #
 # Tests for the ${VAR:from=to} variable modifier, which replaces the suffix
 # "from" with "to".  It can also use '%' as a wildcard.
@@ -60,6 +60,11 @@ all:
 .  error
 .endif
 
+# Each word gets the suffix "X" appended.
+.if ${one two:L:=X} != "oneX twoX"
+.  error
+.endif
+
 # The suffix "o" is replaced with "X".
 .if ${one two:L:o=X} != "one twX"
 .  error



CVS commit: src/usr.bin/make

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 08:40:54 UTC 2020

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

Log Message:
make(1): merge duplicate code in ModifyWord_Subst


To generate a diff of this commit:
cvs rdiff -u -r1.610 -r1.611 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.610 src/usr.bin/make/var.c:1.611
--- src/usr.bin/make/var.c:1.610	Fri Oct 30 22:55:34 2020
+++ src/usr.bin/make/var.c	Sat Oct 31 08:40:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.610 2020/10/30 22:55:34 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.611 2020/10/31 08:40:54 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -129,7 +129,7 @@
 #include"metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.610 2020/10/30 22:55:34 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.611 2020/10/31 08:40:54 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -1294,19 +1294,13 @@ ModifyWord_Subst(const char *word, SepBu
 	memcmp(word, args->lhs, args->lhsLen) != 0)
 	goto nosub;
 
-	if (args->pflags & VARP_ANCHOR_END) {
-	if (wordLen != args->lhsLen)
-		goto nosub;
-
-	/* :S,^whole$,replacement, */
-	SepBuf_AddBytes(buf, args->rhs, args->rhsLen);
-	args->matched = TRUE;
-	} else {
-	/* :S,^prefix,replacement, */
-	SepBuf_AddBytes(buf, args->rhs, args->rhsLen);
-	SepBuf_AddBytes(buf, word + args->lhsLen, wordLen - args->lhsLen);
-	args->matched = TRUE;
-	}
+	if ((args->pflags & VARP_ANCHOR_END) && wordLen != args->lhsLen)
+	goto nosub;
+
+	/* :S,^prefix,replacement, or :S,^whole$,replacement, */
+	SepBuf_AddBytes(buf, args->rhs, args->rhsLen);
+	SepBuf_AddBytes(buf, word + args->lhsLen, wordLen - args->lhsLen);
+	args->matched = TRUE;
 	return;
 }
 



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

2020-10-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Oct 31 08:31:38 UTC 2020

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

Log Message:
make(1): explain tests for the SysV variable modifier


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-sysv.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-sysv.mk
diff -u src/usr.bin/make/unit-tests/varmod-sysv.mk:1.5 src/usr.bin/make/unit-tests/varmod-sysv.mk:1.6
--- src/usr.bin/make/unit-tests/varmod-sysv.mk:1.5	Tue Oct  6 21:19:17 2020
+++ src/usr.bin/make/unit-tests/varmod-sysv.mk	Sat Oct 31 08:31:37 2020
@@ -1,9 +1,11 @@
-# $NetBSD: varmod-sysv.mk,v 1.5 2020/10/06 21:19:17 rillig Exp $
+# $NetBSD: varmod-sysv.mk,v 1.6 2020/10/31 08:31:37 rillig Exp $
 #
 # Tests for the ${VAR:from=to} variable modifier, which replaces the suffix
 # "from" with "to".  It can also use '%' as a wildcard.
 #
 # This modifier is applied when the other modifiers don't match exactly.
+#
+# See ApplyModifier_SysV.
 
 all:
 
@@ -58,34 +60,54 @@ all:
 .  error
 .endif
 
-# Trying to cover all possible variants of the SysV modifier.
-LIST=	one two
-
-.if ${LIST:o=X} != "one twX"
+# The suffix "o" is replaced with "X".
+.if ${one two:L:o=X} != "one twX"
 .  error
 .endif
-.if ${LIST:o=} != "one tw"
+
+# The suffix "o" is replaced with nothing.
+.if ${one two:L:o=} != "one tw"
 .  error
 .endif
-.if ${LIST:o=%} != "one tw%"
+
+# The suffix "o" is replaced with a literal percent.  The percent is only
+# a wildcard when it appears on the left-hand side.
+.if ${one two:L:o=%} != "one tw%"
 .  error
 .endif
-.if ${LIST:%o=X} != "one X"
+
+# Each word with the suffix "o" is replaced with "X".  The percent is a
+# wildcard even though the right-hand side does not contain another percent.
+.if ${one two:L:%o=X} != "one X"
 .  error
 .endif
-.if ${LIST:o%=X} != "X two"
+
+# Each word with the prefix "o" is replaced with "X".  The percent is a
+# wildcard even though the right-hand side does not contain another percent.
+.if ${one two:L:o%=X} != "X two"
 .  error
 .endif
-.if ${LIST:o%e=X} != "X two"
+
+# For each word with the prefix "o" and the suffix "e", the whole word is
+# replaced with "X".
+.if ${one two oe oxen:L:o%e=X} != "X two X oxen"
 .  error
 .endif
-.if ${LIST:o%%e=X} != "one two"	# Only the first '%' is the wildcard.
+
+# Only the first '%' is the wildcard.
+.if ${one two o%e other%e:L:o%%e=X} != "one two X X"
 .  error
 .endif
-.if ${LIST:%=%%} != "one% two%"	# None of the words contains a literal '%'.
+
+# In the replacement, only the first '%' is the placeholder, all others
+# are literal percent characters.
+.if ${one two:L:%=%%} != "one% two%"
 .  error
 .endif
-.if ${LIST:%nes=%xxx} != "one two" # lhs is longer than the word "one"
+
+# In the word "one", only a prefix of the pattern suffix "nes" matches,
+# the whole word is too short.  Therefore it doesn't match.
+.if ${one two:L:%nes=%xxx} != "one two"
 .  error
 .endif
 



CVS commit: src/usr.bin/make

2020-10-31 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sat Oct 31 06:18:21 UTC 2020

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

Log Message:
Do not use an objdir that is not writable.


To generate a diff of this commit:
cvs rdiff -u -r1.412 -r1.413 src/usr.bin/make/main.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/main.c
diff -u src/usr.bin/make/main.c:1.412 src/usr.bin/make/main.c:1.413
--- src/usr.bin/make/main.c:1.412	Fri Oct 30 20:30:44 2020
+++ src/usr.bin/make/main.c	Sat Oct 31 06:18:21 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.412 2020/10/30 20:30:44 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.413 2020/10/31 06:18:21 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -118,7 +118,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.412 2020/10/30 20:30:44 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.413 2020/10/31 06:18:21 sjg Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	"The Regents of the University of California.  "
@@ -721,7 +721,7 @@ Main_SetObjdir(const char *fmt, ...)
 
 	/* look for the directory and try to chdir there */
 	if (stat(path, ) == 0 && S_ISDIR(sb.st_mode)) {
-		if (chdir(path)) {
+		if (access(path, W_OK) || chdir(path)) {
 			(void)fprintf(stderr, "make warning: %s: %s.\n",
   path, strerror(errno));
 		} else {