CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Dec 29 07:40:53 UTC 2021

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

Log Message:
make: replace table for function lookup in conditions with simple code

The code for looking up the function from the table forced the compiler
to use a specific memory layout.  Replacing the table with explicit code
provides the compiler more opportunities to optimize the code.  Another
side effect is that there are fewer pointer operations.

Previously, is_token checked that the character after the word does not
continue the word, this is now done separately since for the function
lookup, this check was unnecessary.  The newly added skip_string
provides a higher abstraction level, it is no longer necessary to pass
the string length as a separate, redundant parameter.

No functional change.


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

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

Modified files:

Index: src/usr.bin/make/cond.c
diff -u src/usr.bin/make/cond.c:1.313 src/usr.bin/make/cond.c:1.314
--- src/usr.bin/make/cond.c:1.313	Wed Dec 29 05:16:44 2021
+++ src/usr.bin/make/cond.c	Wed Dec 29 07:40:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.313 2021/12/29 05:16:44 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.314 2021/12/29 07:40:52 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.313 2021/12/29 05:16:44 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.314 2021/12/29 07:40:52 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -182,10 +182,14 @@ static unsigned int cond_min_depth = 0;	
 /* Names for ComparisonOp. */
 static const char opname[][3] = { "<", "<=", ">", ">=", "==", "!=" };
 
-static bool
-is_token(const char *str, const char *tok, unsigned char len)
+MAKE_INLINE bool
+skip_string(const char **pp, const char *str)
 {
-	return strncmp(str, tok, (size_t)len) == 0 && !ch_isalpha(str[len]);
+	size_t len = strlen(str);
+	bool ok = strncmp(*pp, str, len) == 0;
+	if (ok)
+		*pp += len;
+	return ok;
 }
 
 static Token
@@ -272,8 +276,12 @@ ParseWord(CondParser *par, const char **
 	cpp_skip_hspace(&p);
 
 	if (func != NULL && *p++ != ')') {
+		int len = 0;
+		while (ch_isalpha(func[len]))
+			len++;
+
 		Parse_Error(PARSE_FATAL,
-		"Missing closing parenthesis for %s()", func);
+		"Missing closing parenthesis for %.*s()", len, func);
 		par->printedError = true;
 		return 0;
 	}
@@ -701,9 +709,8 @@ CondParser_FuncCallEmpty(CondParser *par
 	Token tok;
 	FStr val;
 
-	if (!is_token(cp, "empty", 5))
+	if (!skip_string(&cp, "empty"))
 		return false;
-	cp += 5;
 
 	cpp_skip_whitespace(&cp);
 	if (*cp != '(')
@@ -731,37 +738,34 @@ CondParser_FuncCallEmpty(CondParser *par
 static bool
 CondParser_FuncCall(CondParser *par, bool doEval, Token *out_token)
 {
-	static const struct fn_def {
-		const char fn_name[9];
-		unsigned char fn_name_len;
-		bool (*fn_eval)(const char *);
-	} fns[] = {
-		{ "defined",  7, FuncDefined },
-		{ "make", 4, FuncMake },
-		{ "exists",   6, FuncExists },
-		{ "target",   6, FuncTarget },
-		{ "commands", 8, FuncCommands }
-	};
-	const struct fn_def *fn;
 	char *arg = NULL;
 	size_t arglen;
-	const char *cp = par->p;
-	const struct fn_def *last_fn = fns + sizeof fns / sizeof fns[0] - 1;
+	const char *p = par->p;
+	bool (*fn)(const char *);
+	const char *fn_name = p;
 
-	for (fn = fns; !is_token(cp, fn->fn_name, fn->fn_name_len); fn++)
-		if (fn == last_fn)
-			return false;
+	if (skip_string(&p, "defined"))
+		fn = FuncDefined;
+	else if (skip_string(&p, "make"))
+		fn = FuncMake;
+	else if (skip_string(&p, "exists"))
+		fn = FuncExists;
+	else if (skip_string(&p, "target"))
+		fn = FuncTarget;
+	else if (skip_string(&p, "commands"))
+		fn = FuncCommands;
+	else
+		return false;
 
-	cp += fn->fn_name_len;
-	cpp_skip_whitespace(&cp);
-	if (*cp != '(')
+	cpp_skip_whitespace(&p);
+	if (*p != '(')
 		return false;
 
-	arglen = ParseWord(par, &cp, doEval, fn->fn_name, &arg);
-	*out_token = ToToken(arglen != 0 && (!doEval || fn->fn_eval(arg)));
+	arglen = ParseWord(par, &p, doEval, fn_name, &arg);
+	*out_token = ToToken(arglen != 0 && (!doEval || fn(arg)));
 
 	free(arg);
-	par->p = cp;
+	par->p = p;
 	return true;
 }
 
@@ -1049,36 +1053,33 @@ DetermineKindOfConditional(const char **
 			   bool (**out_evalBare)(const char *),
 			   bool *out_negate)
 {
-	const char *p = *pp;
+	const char *p = *pp + 2;
 
-	p += 2;
 	*out_plain = false;
 	*out_evalBare = FuncDefined;
-	*out_negate = false;
-	if (*p == 'n') {
-		p++;
-		*out_negate = true;
-	}
-	if (is_token(p, "def", 3)) {		/* .ifdef and .ifndef */
-		p += 3;
-	} else if (is_token(p, "make", 4)) {	/* .ifmake and .ifnmake */
-		p += 4;
+	*out_negate = skip_string(&p

CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Dec 29 07:40:53 UTC 2021

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

Log Message:
make: replace table for function lookup in conditions with simple code

The code for looking up the function from the table forced the compiler
to use a specific memory layout.  Replacing the table with explicit code
provides the compiler more opportunities to optimize the code.  Another
side effect is that there are fewer pointer operations.

Previously, is_token checked that the character after the word does not
continue the word, this is now done separately since for the function
lookup, this check was unnecessary.  The newly added skip_string
provides a higher abstraction level, it is no longer necessary to pass
the string length as a separate, redundant parameter.

No functional change.


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

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



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Dec 29 05:16:44 UTC 2021

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

Log Message:
make: clean up condition parser

No functional change.


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

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

Modified files:

Index: src/usr.bin/make/cond.c
diff -u src/usr.bin/make/cond.c:1.312 src/usr.bin/make/cond.c:1.313
--- src/usr.bin/make/cond.c:1.312	Wed Dec 29 05:05:21 2021
+++ src/usr.bin/make/cond.c	Wed Dec 29 05:16:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.312 2021/12/29 05:05:21 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.313 2021/12/29 05:16:44 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.312 2021/12/29 05:05:21 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.313 2021/12/29 05:16:44 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -989,10 +989,7 @@ CondParser_Eval(CondParser *par)
 	DEBUG1(COND, "CondParser_Eval: %s\n", par->p);
 
 	res = CondParser_Or(par, true);
-	if (res == CR_ERROR)
-		return CR_ERROR;
-
-	if (CondParser_Token(par, false) != TOK_EOF)
+	if (res != CR_ERROR && CondParser_Token(par, false) != TOK_EOF)
 		return CR_ERROR;
 
 	return res;
@@ -1002,12 +999,6 @@ CondParser_Eval(CondParser *par)
  * Evaluate the condition, including any side effects from the variable
  * expressions in the condition. The condition consists of &&, ||, !,
  * function(arg), comparisons and parenthetical groupings thereof.
- *
- * Results:
- *	CR_TRUE		if the condition was valid grammatically
- *	CR_ERROR	if not a valid conditional.
- *
- *	*out_value	is set to the boolean value of the condition
  */
 static CondResult
 CondEvalExpression(const char *cond, bool plain,
@@ -1285,12 +1276,8 @@ Cond_EvalLine(const char *line)
 		return CR_FALSE;
 	}
 
-	if (res == CR_FALSE) {
-		cond_states[cond_depth] = IFS_INITIAL;
-		return CR_FALSE;
-	}
-	cond_states[cond_depth] = IFS_ACTIVE;
-	return CR_TRUE;
+	cond_states[cond_depth] = res == CR_TRUE ? IFS_ACTIVE : IFS_INITIAL;
+	return res;
 }
 
 void



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Dec 29 05:16:44 UTC 2021

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

Log Message:
make: clean up condition parser

No functional change.


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

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



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Dec 29 05:05:21 UTC 2021

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

Log Message:
make: merge duplicate types CondEvalResult and CondResult

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.311 -r1.312 src/usr.bin/make/cond.c
cvs rdiff -u -r1.283 -r1.284 src/usr.bin/make/make.h
cvs rdiff -u -r1.224 -r1.225 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.990 -r1.991 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/cond.c
diff -u src/usr.bin/make/cond.c:1.311 src/usr.bin/make/cond.c:1.312
--- src/usr.bin/make/cond.c:1.311	Wed Dec 29 05:01:35 2021
+++ src/usr.bin/make/cond.c	Wed Dec 29 05:05:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.311 2021/12/29 05:01:35 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.312 2021/12/29 05:05:21 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.311 2021/12/29 05:01:35 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.312 2021/12/29 05:05:21 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -981,7 +981,7 @@ CondParser_Or(CondParser *par, bool doEv
 	return res;
 }
 
-static CondEvalResult
+static CondResult
 CondParser_Eval(CondParser *par)
 {
 	CondResult res;
@@ -1009,13 +1009,13 @@ CondParser_Eval(CondParser *par)
  *
  *	*out_value	is set to the boolean value of the condition
  */
-static CondEvalResult
+static CondResult
 CondEvalExpression(const char *cond, bool plain,
 		   bool (*evalBare)(const char *), bool negate,
 		   bool eprint, bool leftUnquotedOK)
 {
 	CondParser par;
-	CondEvalResult rval;
+	CondResult rval;
 
 	cpp_skip_hspace(&cond);
 
@@ -1039,7 +1039,7 @@ CondEvalExpression(const char *cond, boo
  * Evaluate a condition in a :? modifier, such as
  * ${"${VAR}" == value:?yes:no}.
  */
-CondEvalResult
+CondResult
 Cond_EvalCondition(const char *cond)
 {
 	return CondEvalExpression(cond, true,
@@ -1120,7 +1120,7 @@ DetermineKindOfConditional(const char **
  *			a syntax error or because some variable was undefined
  *			or because the condition could not be evaluated
  */
-CondEvalResult
+CondResult
 Cond_EvalLine(const char *line)
 {
 	typedef enum IfState {

Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.283 src/usr.bin/make/make.h:1.284
--- src/usr.bin/make/make.h:1.283	Wed Dec 29 05:01:35 2021
+++ src/usr.bin/make/make.h	Wed Dec 29 05:05:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.283 2021/12/29 05:01:35 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.284 2021/12/29 05:05:21 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -518,11 +518,11 @@ typedef enum ParseErrorLevel {
 /*
  * Values returned by Cond_EvalLine and Cond_EvalCondition.
  */
-typedef enum CondEvalResult {
+typedef enum CondResult {
 	CR_TRUE,		/* Parse the next lines */
 	CR_FALSE,		/* Skip the next lines */
 	CR_ERROR		/* Unknown directive or parse error */
-} CondEvalResult, CondResult;
+} CondResult;
 
 /* Names of the variables that are "local" to a specific target. */
 #define TARGET	"@"		/* Target of dependency */

Index: src/usr.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.224 src/usr.bin/make/nonints.h:1.225
--- src/usr.bin/make/nonints.h:1.224	Wed Dec 29 04:50:56 2021
+++ src/usr.bin/make/nonints.h	Wed Dec 29 05:05:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.224 2021/12/29 04:50:56 rillig Exp $	*/
+/*	$NetBSD: nonints.h,v 1.225 2021/12/29 05:05:21 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -91,8 +91,8 @@ void Compat_Run(GNodeList *);
 void Compat_Make(GNode *, GNode *);
 
 /* cond.c */
-CondEvalResult Cond_EvalCondition(const char *) MAKE_ATTR_USE;
-CondEvalResult Cond_EvalLine(const char *) MAKE_ATTR_USE;
+CondResult Cond_EvalCondition(const char *) MAKE_ATTR_USE;
+CondResult Cond_EvalLine(const char *) MAKE_ATTR_USE;
 void Cond_restore_depth(unsigned int);
 unsigned int Cond_save_depth(void) MAKE_ATTR_USE;
 

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.990 src/usr.bin/make/var.c:1.991
--- src/usr.bin/make/var.c:1.990	Wed Dec 29 04:50:56 2021
+++ src/usr.bin/make/var.c	Wed Dec 29 05:05:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.990 2021/12/29 04:50:56 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.991 2021/12/29 05:05:21 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.990 2021/12/29 04:50:56 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.991 2021/12/29 05:05:21 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -3454,7 +3454,7 @@ ApplyModifier_IfElse(const char **pp, Mo
 	VarEval

CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Dec 29 05:05:21 UTC 2021

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

Log Message:
make: merge duplicate types CondEvalResult and CondResult

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.311 -r1.312 src/usr.bin/make/cond.c
cvs rdiff -u -r1.283 -r1.284 src/usr.bin/make/make.h
cvs rdiff -u -r1.224 -r1.225 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.990 -r1.991 src/usr.bin/make/var.c

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



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Dec 29 05:01:35 UTC 2021

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

Log Message:
make: merge duplicate enum constants for CondEvalResult and CondResult

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.310 -r1.311 src/usr.bin/make/cond.c
cvs rdiff -u -r1.282 -r1.283 src/usr.bin/make/make.h
cvs rdiff -u -r1.603 -r1.604 src/usr.bin/make/parse.c

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

Modified files:

Index: src/usr.bin/make/cond.c
diff -u src/usr.bin/make/cond.c:1.310 src/usr.bin/make/cond.c:1.311
--- src/usr.bin/make/cond.c:1.310	Wed Dec 29 04:50:56 2021
+++ src/usr.bin/make/cond.c	Wed Dec 29 05:01:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.310 2021/12/29 04:50:56 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.311 2021/12/29 05:01:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.310 2021/12/29 04:50:56 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.311 2021/12/29 05:01:35 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -990,10 +990,10 @@ CondParser_Eval(CondParser *par)
 
 	res = CondParser_Or(par, true);
 	if (res == CR_ERROR)
-		return COND_INVALID;
+		return CR_ERROR;
 
 	if (CondParser_Token(par, false) != TOK_EOF)
-		return COND_INVALID;
+		return CR_ERROR;
 
 	return res;
 }
@@ -1004,8 +1004,8 @@ CondParser_Eval(CondParser *par)
  * function(arg), comparisons and parenthetical groupings thereof.
  *
  * Results:
- *	COND_PARSE	if the condition was valid grammatically
- *	COND_INVALID	if not a valid conditional.
+ *	CR_TRUE		if the condition was valid grammatically
+ *	CR_ERROR	if not a valid conditional.
  *
  *	*out_value	is set to the boolean value of the condition
  */
@@ -1029,7 +1029,7 @@ CondEvalExpression(const char *cond, boo
 
 	rval = CondParser_Eval(&par);
 
-	if (rval == COND_INVALID && eprint && !par.printedError)
+	if (rval == CR_ERROR && eprint && !par.printedError)
 		Parse_Error(PARSE_FATAL, "Malformed conditional (%s)", cond);
 
 	return rval;
@@ -,12 +,12 @@ DetermineKindOfConditional(const char **
  * parenthetical groupings thereof.
  *
  * Results:
- *	COND_PARSE	to continue parsing the lines that follow the
+ *	CR_TRUE		to continue parsing the lines that follow the
  *			conditional (when  evaluates to true)
- *	COND_SKIP	to skip the lines after the conditional
+ *	CR_FALSE	to skip the lines after the conditional
  *			(when  evaluates to false, or when a previous
  *			branch has already been taken)
- *	COND_INVALID	if the conditional was not valid, either because of
+ *	CR_ERROR	if the conditional was not valid, either because of
  *			a syntax error or because some variable was undefined
  *			or because the condition could not be evaluated
  */
@@ -1170,13 +1170,13 @@ Cond_EvalLine(const char *line)
 
 		if (cond_depth == cond_min_depth) {
 			Parse_Error(PARSE_FATAL, "if-less endif");
-			return COND_PARSE;
+			return CR_TRUE;
 		}
 
 		/* Return state for previous conditional */
 		cond_depth--;
 		return cond_states[cond_depth] & IFS_ACTIVE
-		? COND_PARSE : COND_SKIP;
+		? CR_TRUE : CR_FALSE;
 	}
 
 	/* Parse the name of the directive, such as 'if', 'elif', 'endif'. */
@@ -1187,7 +1187,7 @@ Cond_EvalLine(const char *line)
 			 * transformation rule like '.err.txt',
 			 * therefore no error message here.
 			 */
-			return COND_INVALID;
+			return CR_ERROR;
 		}
 
 		/* Quite likely this is 'else' or 'elif' */
@@ -1201,7 +1201,7 @@ Cond_EvalLine(const char *line)
 
 			if (cond_depth == cond_min_depth) {
 Parse_Error(PARSE_FATAL, "if-less else");
-return COND_PARSE;
+return CR_TRUE;
 			}
 
 			state = cond_states[cond_depth];
@@ -1215,7 +1215,7 @@ Cond_EvalLine(const char *line)
 			}
 			cond_states[cond_depth] = state;
 
-			return state & IFS_ACTIVE ? COND_PARSE : COND_SKIP;
+			return state & IFS_ACTIVE ? CR_TRUE : CR_FALSE;
 		}
 		/* Assume for now it is an elif */
 		isElif = true;
@@ -1227,27 +1227,27 @@ Cond_EvalLine(const char *line)
 		 * Unknown directive.  It might still be a transformation rule
 		 * like '.elisp.scm', therefore no error message here.
 		 */
-		return COND_INVALID;	/* Not an ifxxx or elifxxx line */
+		return CR_ERROR;	/* Not an ifxxx or elifxxx line */
 	}
 
 	if (!DetermineKindOfConditional(&p, &plain, &evalBare, &negate))
-		return COND_INVALID;
+		return CR_ERROR;
 
 	if (isElif) {
 		if (cond_depth == cond_min_depth) {
 			Parse_Error(PARSE_FATAL, "if-less elif");
-			return COND_PARSE;
+			return CR_TRUE;
 		}
 		state = cond_states[cond_depth];
 		if (state & IFS_SEEN_ELSE) {
 			Parse_Error(PARSE_WARNING, "extra elif");
 			cond_states[cond_depth] =
 			IFS_WAS_ACTIVE | IFS_SEEN_ELSE;
-			return COND_SKIP;
+			

CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Dec 29 05:01:35 UTC 2021

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

Log Message:
make: merge duplicate enum constants for CondEvalResult and CondResult

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.310 -r1.311 src/usr.bin/make/cond.c
cvs rdiff -u -r1.282 -r1.283 src/usr.bin/make/make.h
cvs rdiff -u -r1.603 -r1.604 src/usr.bin/make/parse.c

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



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Dec 29 04:50:56 UTC 2021

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

Log Message:
make: remove redundant parameter for evaluating conditions

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.309 -r1.310 src/usr.bin/make/cond.c
cvs rdiff -u -r1.223 -r1.224 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.989 -r1.990 src/usr.bin/make/var.c

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



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Dec 29 04:50:56 UTC 2021

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

Log Message:
make: remove redundant parameter for evaluating conditions

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.309 -r1.310 src/usr.bin/make/cond.c
cvs rdiff -u -r1.223 -r1.224 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.989 -r1.990 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/cond.c
diff -u src/usr.bin/make/cond.c:1.309 src/usr.bin/make/cond.c:1.310
--- src/usr.bin/make/cond.c:1.309	Wed Dec 29 04:41:38 2021
+++ src/usr.bin/make/cond.c	Wed Dec 29 04:50:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.309 2021/12/29 04:41:38 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.310 2021/12/29 04:50:56 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.309 2021/12/29 04:41:38 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.310 2021/12/29 04:50:56 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -982,7 +982,7 @@ CondParser_Or(CondParser *par, bool doEv
 }
 
 static CondEvalResult
-CondParser_Eval(CondParser *par, bool *out_value)
+CondParser_Eval(CondParser *par)
 {
 	CondResult res;
 
@@ -995,8 +995,7 @@ CondParser_Eval(CondParser *par, bool *o
 	if (CondParser_Token(par, false) != TOK_EOF)
 		return COND_INVALID;
 
-	*out_value = res == CR_TRUE;
-	return COND_PARSE;
+	return res;
 }
 
 /*
@@ -1011,7 +1010,7 @@ CondParser_Eval(CondParser *par, bool *o
  *	*out_value	is set to the boolean value of the condition
  */
 static CondEvalResult
-CondEvalExpression(const char *cond, bool *out_value, bool plain,
+CondEvalExpression(const char *cond, bool plain,
 		   bool (*evalBare)(const char *), bool negate,
 		   bool eprint, bool leftUnquotedOK)
 {
@@ -1028,7 +1027,7 @@ CondEvalExpression(const char *cond, boo
 	par.curr = TOK_NONE;
 	par.printedError = false;
 
-	rval = CondParser_Eval(&par, out_value);
+	rval = CondParser_Eval(&par);
 
 	if (rval == COND_INVALID && eprint && !par.printedError)
 		Parse_Error(PARSE_FATAL, "Malformed conditional (%s)", cond);
@@ -1041,9 +1040,9 @@ CondEvalExpression(const char *cond, boo
  * ${"${VAR}" == value:?yes:no}.
  */
 CondEvalResult
-Cond_EvalCondition(const char *cond, bool *out_value)
+Cond_EvalCondition(const char *cond)
 {
-	return CondEvalExpression(cond, out_value, true,
+	return CondEvalExpression(cond, true,
 	FuncDefined, false, false, true);
 }
 
@@ -1150,7 +1149,7 @@ Cond_EvalLine(const char *line)
 	bool (*evalBare)(const char *);
 	bool negate;
 	bool isElif;
-	bool value;
+	CondResult res;
 	IfState state;
 	const char *p = line;
 
@@ -1275,8 +1274,8 @@ Cond_EvalLine(const char *line)
 	}
 
 	/* And evaluate the conditional expression */
-	if (CondEvalExpression(p, &value, plain, evalBare, negate,
-	true, false) == COND_INVALID) {
+	res = CondEvalExpression(p, plain, evalBare, negate, true, false);
+	if (res == COND_INVALID) {
 		/*
 		 * Syntax error in conditional, error message already output.
 		 */
@@ -1286,7 +1285,7 @@ Cond_EvalLine(const char *line)
 		return COND_SKIP;
 	}
 
-	if (!value) {
+	if (res == COND_SKIP) {
 		cond_states[cond_depth] = IFS_INITIAL;
 		return COND_SKIP;
 	}

Index: src/usr.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.223 src/usr.bin/make/nonints.h:1.224
--- src/usr.bin/make/nonints.h:1.223	Tue Dec 28 01:11:36 2021
+++ src/usr.bin/make/nonints.h	Wed Dec 29 04:50:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.223 2021/12/28 01:11:36 rillig Exp $	*/
+/*	$NetBSD: nonints.h,v 1.224 2021/12/29 04:50:56 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -91,7 +91,7 @@ void Compat_Run(GNodeList *);
 void Compat_Make(GNode *, GNode *);
 
 /* cond.c */
-CondEvalResult Cond_EvalCondition(const char *, bool *) MAKE_ATTR_USE;
+CondEvalResult Cond_EvalCondition(const char *) MAKE_ATTR_USE;
 CondEvalResult Cond_EvalLine(const char *) MAKE_ATTR_USE;
 void Cond_restore_depth(unsigned int);
 unsigned int Cond_save_depth(void) MAKE_ATTR_USE;

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.989 src/usr.bin/make/var.c:1.990
--- src/usr.bin/make/var.c:1.989	Wed Dec 15 13:03:33 2021
+++ src/usr.bin/make/var.c	Wed Dec 29 04:50:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.989 2021/12/15 13:03:33 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.990 2021/12/29 04:50:56 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.989 2021/12/15 13:03:33 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.990 2021/12/29 04:50:56 rillig Exp $");
 
 /*
  * Variables are defined using on

Re: CVS commit: xsrc/external/mit/xinit/dist

2021-12-28 Thread Valery Ushakov
On Wed, Dec 29, 2021 at 07:42:42 +0300, Valery Ushakov wrote:

> On Wed, Dec 29, 2021 at 15:09:08 +1100, matthew green wrote:
> 
> > "Nia Alarie" writes:
> > > Module Name:  xsrc
> > > Committed By: nia
> > > Date: Tue Dec 28 11:48:52 UTC 2021
> > >
> > > Modified Files:
> > >   xsrc/external/mit/xinit/dist: xinitrc.cpp
> > >
> > > Log Message:
> > > COLOR is not a C preprocessor macro :|
> > 
> > this used to work a long long time ago.  back when
> > sunos4 was not entirely obsolete :-)
> 
> I actually still have #ifdef COLOR in my resources carried around from
> that time, but the it's been quite a long ago that I used an actual
> b/w (1bpp) display where this actually mattered.  Any VAXstation users
> around?  Also, why not arrange for COLOR to be defined?

Uhm, actually xrdb *does* define COLOR but it defines it without value

switch (visual->class) {
case StaticColor:
case PseudoColor:
case TrueColor:
case DirectColor:
AddSimpleDef(defs, "COLOR");
break;
}

so the right fix would be to just fix the #if in xinitrc to #ifdef

-uwe


Re: CVS commit: xsrc/external/mit/xinit/dist

2021-12-28 Thread Valery Ushakov
On Wed, Dec 29, 2021 at 15:09:08 +1100, matthew green wrote:

> "Nia Alarie" writes:
> > Module Name:xsrc
> > Committed By:   nia
> > Date:   Tue Dec 28 11:48:52 UTC 2021
> >
> > Modified Files:
> > xsrc/external/mit/xinit/dist: xinitrc.cpp
> >
> > Log Message:
> > COLOR is not a C preprocessor macro :|
> 
> this used to work a long long time ago.  back when
> sunos4 was not entirely obsolete :-)

I actually still have #ifdef COLOR in my resources carried around from
that time, but the it's been quite a long ago that I used an actual
b/w (1bpp) display where this actually mattered.  Any VAXstation users
around?  Also, why not arrange for COLOR to be defined?

-uwe


CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Dec 29 04:41:38 UTC 2021

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

Log Message:
make: merge types CondResult and CondEvalResult

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.308 -r1.309 src/usr.bin/make/cond.c
cvs rdiff -u -r1.281 -r1.282 src/usr.bin/make/make.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/cond.c
diff -u src/usr.bin/make/cond.c:1.308 src/usr.bin/make/cond.c:1.309
--- src/usr.bin/make/cond.c:1.308	Mon Dec 27 21:21:17 2021
+++ src/usr.bin/make/cond.c	Wed Dec 29 04:41:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.308 2021/12/27 21:21:17 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.309 2021/12/29 04:41:38 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.308 2021/12/27 21:21:17 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.309 2021/12/29 04:41:38 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -131,10 +131,6 @@ typedef enum Token {
 	TOK_LPAREN, TOK_RPAREN, TOK_EOF, TOK_NONE, TOK_ERROR
 } Token;
 
-typedef enum CondResult {
-	CR_FALSE, CR_TRUE, CR_ERROR
-} CondResult;
-
 typedef enum ComparisonOp {
 	LT, LE, GT, GE, EQ, NE
 } ComparisonOp;

Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.281 src/usr.bin/make/make.h:1.282
--- src/usr.bin/make/make.h:1.281	Tue Dec 28 14:22:51 2021
+++ src/usr.bin/make/make.h	Wed Dec 29 04:41:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.281 2021/12/28 14:22:51 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.282 2021/12/29 04:41:38 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -521,8 +521,11 @@ typedef enum ParseErrorLevel {
 typedef enum CondEvalResult {
 	COND_PARSE,		/* Parse the next lines */
 	COND_SKIP,		/* Skip the next lines */
-	COND_INVALID		/* Not a conditional statement */
-} CondEvalResult;
+	COND_INVALID,		/* Not a conditional statement */
+	CR_TRUE = COND_PARSE,
+	CR_FALSE = COND_SKIP,
+	CR_ERROR = COND_INVALID
+} CondEvalResult, CondResult;
 
 /* Names of the variables that are "local" to a specific target. */
 #define TARGET	"@"		/* Target of dependency */



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Dec 29 04:41:38 UTC 2021

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

Log Message:
make: merge types CondResult and CondEvalResult

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.308 -r1.309 src/usr.bin/make/cond.c
cvs rdiff -u -r1.281 -r1.282 src/usr.bin/make/make.h

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



re: CVS commit: xsrc/external/mit/xinit/dist

2021-12-28 Thread matthew green
"Nia Alarie" writes:
> Module Name:  xsrc
> Committed By: nia
> Date: Tue Dec 28 11:48:52 UTC 2021
>
> Modified Files:
>   xsrc/external/mit/xinit/dist: xinitrc.cpp
>
> Log Message:
> COLOR is not a C preprocessor macro :|

this used to work a long long time ago.  back when
sunos4 was not entirely obsolete :-)


.mrg.


CVS commit: src/usr.bin/xlint/xlint

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 22:59:56 UTC 2021

Modified Files:
src/usr.bin/xlint/xlint: xlint.c

Log Message:
lint: do not output "Lint pass2:"

A colon at the end of a line requires at least 1 follow-up line, but
xlint cannot know whether lint2 will find anything to complain about.
Having a colon followed by nothing creates unnecessary confusion.


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/usr.bin/xlint/xlint/xlint.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/xlint/xlint/xlint.c
diff -u src/usr.bin/xlint/xlint/xlint.c:1.87 src/usr.bin/xlint/xlint/xlint.c:1.88
--- src/usr.bin/xlint/xlint/xlint.c:1.87	Tue Dec 14 16:22:30 2021
+++ src/usr.bin/xlint/xlint/xlint.c	Tue Dec 28 22:59:56 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: xlint.c,v 1.87 2021/12/14 16:22:30 christos Exp $ */
+/* $NetBSD: xlint.c,v 1.88 2021/12/28 22:59:56 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: xlint.c,v 1.87 2021/12/14 16:22:30 christos Exp $");
+__RCSID("$NetBSD: xlint.c,v 1.88 2021/12/28 22:59:56 rillig Exp $");
 #endif
 
 #include 
@@ -606,7 +606,6 @@ main(int argc, char *argv[])
 		findlibs(deflibs);
 	}
 
-	(void)printf("Lint pass2:\n");
 	run_lint2();
 
 	if (oflag)



CVS commit: src/usr.bin/xlint/xlint

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 22:59:56 UTC 2021

Modified Files:
src/usr.bin/xlint/xlint: xlint.c

Log Message:
lint: do not output "Lint pass2:"

A colon at the end of a line requires at least 1 follow-up line, but
xlint cannot know whether lint2 will find anything to complain about.
Having a colon followed by nothing creates unnecessary confusion.


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/usr.bin/xlint/xlint/xlint.c

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



CVS commit: src/tests/usr.bin/xlint/lint1

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 22:54:08 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: d_c99_init.c d_c99_init.exp

Log Message:
tests/lint: extend documentation for omitted braces in initializer


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/tests/usr.bin/xlint/lint1/d_c99_init.c
cvs rdiff -u -r1.28 -r1.29 src/tests/usr.bin/xlint/lint1/d_c99_init.exp

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/d_c99_init.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_init.c:1.38 src/tests/usr.bin/xlint/lint1/d_c99_init.c:1.39
--- src/tests/usr.bin/xlint/lint1/d_c99_init.c:1.38	Wed Dec 22 14:49:11 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_init.c	Tue Dec 28 22:54:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: d_c99_init.c,v 1.38 2021/12/22 14:49:11 rillig Exp $	*/
+/*	$NetBSD: d_c99_init.c,v 1.39 2021/12/28 22:54:08 rillig Exp $	*/
 # 3 "d_c99_init.c"
 
 /*
@@ -81,7 +81,7 @@ int array_with_fixed_size[3] = {
 	444,			/* expect: too many array initializers */
 };
 
-// See initialization_set_set_of_unknown_array.
+// See update_type_of_array_of_unknown_size.
 int array_of_unknown_size[] = {
 	111,
 	222,
@@ -150,8 +150,11 @@ int array_with_designator[] = {
  * C99 6.7.8p11 says that the initializer of a scalar can be "optionally
  * enclosed in braces".  It does not explicitly set an upper limit on the
  * number of braces.  It also doesn't restrict the term "initializer" to only
- * mean the "outermost initializer".  Both GCC 10 and Clang 8 already warn
- * about this, so there is no extra work for lint to do.
+ * mean the "outermost initializer".  6.7.8p13 defines that a brace for a
+ * structure or union always means to descend into the type.  Both GCC 10 and
+ * Clang 8 already warn about these extra braces, nevertheless there is
+ * real-life code (the Postfix MTA) that exploits this corner case of the
+ * standard.
  */
 struct point scalar_with_several_braces = {
 	{{{3}}},

Index: src/tests/usr.bin/xlint/lint1/d_c99_init.exp
diff -u src/tests/usr.bin/xlint/lint1/d_c99_init.exp:1.28 src/tests/usr.bin/xlint/lint1/d_c99_init.exp:1.29
--- src/tests/usr.bin/xlint/lint1/d_c99_init.exp:1.28	Wed Dec 22 00:45:53 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_init.exp	Tue Dec 28 22:54:08 2021
@@ -3,27 +3,27 @@ d_c99_init.c(64): error: cannot initiali
 d_c99_init.c(81): error: too many array initializers, expected 3 [173]
 d_c99_init.c(139): error: too many struct/union initializers [172]
 d_c99_init.c(145): error: syntax error 'designator '.member' is only for struct/union' [249]
-d_c99_init.c(218): error: array subscript cannot be > 2: 3 [168]
-d_c99_init.c(220): error: array subscript cannot be > 4: 5 [168]
-d_c99_init.c(222): error: array subscript cannot be > 1: 2 [168]
-d_c99_init.c(231): error: too many struct/union initializers [172]
-d_c99_init.c(237): warning: illegal combination of integer (char) and pointer (pointer to char) [183]
-d_c99_init.c(331): error: negative array dimension (-8) [20]
-d_c99_init.c(333): error: negative array dimension (-12) [20]
-d_c99_init.c(386): error: duplicate case in switch: 0 [199]
-d_c99_init.c(394): error: negative array dimension (-12) [20]
-d_c99_init.c(398): error: type 'struct point' does not have member 'r' [101]
-d_c99_init.c(405): error: type 'struct point' does not have member 'r' [101]
-d_c99_init.c(412): error: type 'struct point' does not have member 'r' [101]
-d_c99_init.c(421): error: type 'union value' does not have member 'unknown_value' [101]
-d_c99_init.c(427): error: type 'union value' does not have member 'unknown_value' [101]
-d_c99_init.c(431): error: syntax error 'designator '[...]' is only for arrays' [249]
-d_c99_init.c(436): error: type 'struct point' does not have member 'member' [101]
-d_c99_init.c(441): error: syntax error 'scalar type cannot use designator' [249]
-d_c99_init.c(448): warning: structure has no named members [65]
-d_c99_init.c(448): error: cannot initialize struct/union with no named member [179]
-d_c99_init.c(456): warning: union has no named members [65]
-d_c99_init.c(456): error: cannot initialize struct/union with no named member [179]
-d_c99_init.c(461): error: syntax error 'scalar type cannot use designator' [249]
-d_c99_init.c(465): error: syntax error 'scalar type cannot use designator' [249]
-d_c99_init.c(469): error: syntax error 'designator '[...]' is only for arrays' [249]
+d_c99_init.c(221): error: array subscript cannot be > 2: 3 [168]
+d_c99_init.c(223): error: array subscript cannot be > 4: 5 [168]
+d_c99_init.c(225): error: array subscript cannot be > 1: 2 [168]
+d_c99_init.c(234): error: too many struct/union initializers [172]
+d_c99_init.c(240): warning: illegal combination of integer (char) and pointer (pointer to char) [183]
+d_c99_init.c(334): error: negative array dimension (-8) [20]
+d_c99_init.c(336): error: negative array dimen

CVS commit: src/tests/usr.bin/xlint/lint1

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 22:54:08 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: d_c99_init.c d_c99_init.exp

Log Message:
tests/lint: extend documentation for omitted braces in initializer


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/tests/usr.bin/xlint/lint1/d_c99_init.c
cvs rdiff -u -r1.28 -r1.29 src/tests/usr.bin/xlint/lint1/d_c99_init.exp

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



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

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 22:13:56 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: cond-func-empty.mk cond-func.mk

Log Message:
tests/make: test function names without following '('


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/cond-func-empty.mk
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cond-func.mk

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

Modified files:

Index: src/usr.bin/make/unit-tests/cond-func-empty.mk
diff -u src/usr.bin/make/unit-tests/cond-func-empty.mk:1.16 src/usr.bin/make/unit-tests/cond-func-empty.mk:1.17
--- src/usr.bin/make/unit-tests/cond-func-empty.mk:1.16	Sat Dec 11 10:41:31 2021
+++ src/usr.bin/make/unit-tests/cond-func-empty.mk	Tue Dec 28 22:13:56 2021
@@ -1,4 +1,4 @@
-# $NetBSD: cond-func-empty.mk,v 1.16 2021/12/11 10:41:31 rillig Exp $
+# $NetBSD: cond-func-empty.mk,v 1.17 2021/12/28 22:13:56 rillig Exp $
 #
 # Tests for the empty() function in .if conditions, which tests a variable
 # expression for emptiness.
@@ -189,5 +189,16 @@ VARNAME=	${VARNAME${:U1}}
 .if defined(VARNAME${:U2}) && !empty(VARNAME${:U2})
 .endif
 
-all:
-	@:;
+
+# If the word 'empty' is not followed by '(', it is not a function call but an
+# ordinary bare word.  This bare word is interpreted as 'defined(empty)', and
+# since there is no variable named 'empty', the condition evaluates to false.
+.if empty
+.  error
+.endif
+
+empty=		# defined but empty
+.if empty
+.else
+.  error
+.endif

Index: src/usr.bin/make/unit-tests/cond-func.mk
diff -u src/usr.bin/make/unit-tests/cond-func.mk:1.9 src/usr.bin/make/unit-tests/cond-func.mk:1.10
--- src/usr.bin/make/unit-tests/cond-func.mk:1.9	Sun Nov 15 14:07:53 2020
+++ src/usr.bin/make/unit-tests/cond-func.mk	Tue Dec 28 22:13:56 2021
@@ -1,4 +1,4 @@
-# $NetBSD: cond-func.mk,v 1.9 2020/11/15 14:07:53 rillig Exp $
+# $NetBSD: cond-func.mk,v 1.10 2021/12/28 22:13:56 rillig Exp $
 #
 # Tests for those parts of the functions in .if conditions that are common
 # among several functions.
@@ -102,9 +102,9 @@ ${VARNAME_UNBALANCED_BRACES}=	variable n
 .  info A plain function name is parsed as !empty(...).
 .endif
 
-# If a variable named 'defined' is actually defined and not empty, the plain
-# symbol 'defined' evaluates to true.
-defined=	non-empty
+# If a variable named 'defined' is actually defined, the bare word 'defined'
+# is interpreted as 'defined(defined)', and the condition evaluates to true.
+defined=	# defined but empty
 .if defined
 .  info A plain function name is parsed as !empty(...).
 .else
@@ -119,7 +119,7 @@ defined=	non-empty
 .  info Symbols may start with a function name.
 .endif
 
-defined-var=	non-empty
+defined-var=	# defined but empty
 .if defined-var
 .  info Symbols may start with a function name.
 .else
@@ -132,6 +132,3 @@ defined-var=	non-empty
 .else
 .  error
 .endif
-
-all:
-	@:;



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

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 22:13:56 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: cond-func-empty.mk cond-func.mk

Log Message:
tests/make: test function names without following '('


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/cond-func-empty.mk
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cond-func.mk

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



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 21:56:13 UTC 2021

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

Log Message:
make: fix double-free in CLEANUP mode (since 2021.12.27.23.11.55)

When make is run without the '-f' option, it searches for the files
'makefile' and 'Makefile' in the current directory.  The function
ReadFirstDefaultMakefile allocated memory for these filenames, added the
filenames to opts.makefiles and then freed the memory.  From that
moment, opts.makefiles contained dangling pointers.

The function main_CleanUp cleans the list, but only if make is compiled
with -DCLEANUP.  Since main.c 1.557 from 2021.12.27.23.11.55, the
strings in opts.makefiles are freed as well, before that, only the list
nodes were freed.  Freeing the strings led to the double-free.

Fix this bug by using a separate list for these short-lived strings.  At
the point where ReadFirstDefaultMakefile is called, opts.makefiles is
not used anymore, therefore there are no side effects.

To reproduce, run 'make test-coverage', which compiles with -DCLEANUP.
The test opt-chdir failed with a segmentation fault in main_Cleanup.
This test may be the only one that doesn't use the option '-f'.


To generate a diff of this commit:
cvs rdiff -u -r1.561 -r1.562 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.561 src/usr.bin/make/main.c:1.562
--- src/usr.bin/make/main.c:1.561	Tue Dec 28 01:20:24 2021
+++ src/usr.bin/make/main.c	Tue Dec 28 21:56:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.561 2021/12/28 01:20:24 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.562 2021/12/28 21:56:13 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.561 2021/12/28 01:20:24 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.562 2021/12/28 21:56:13 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	"The Regents of the University of California.  "
@@ -1293,6 +1293,7 @@ ReadAllMakefiles(const StringList *makef
 static void
 ReadFirstDefaultMakefile(void)
 {
+	StringList makefiles = LST_INIT;
 	StringListNode *ln;
 	char *prefs;
 
@@ -1300,18 +1301,13 @@ ReadFirstDefaultMakefile(void)
 	SCOPE_CMDLINE, VARE_WANTRES, &prefs);
 	/* TODO: handle errors */
 
-	/*
-	 * XXX: This should use a local list instead of opts.makefiles since
-	 * these makefiles do not come from the command line.  They also have
-	 * different semantics in that only the first file that is found is
-	 * processed.  See ReadAllMakefiles.
-	 */
-	(void)str2Lst_Append(&opts.makefiles, prefs);
+	(void)str2Lst_Append(&makefiles, prefs);
 
-	for (ln = opts.makefiles.first; ln != NULL; ln = ln->next)
+	for (ln = makefiles.first; ln != NULL; ln = ln->next)
 		if (ReadMakefile(ln->datum))
 			break;
 
+	Lst_Done(&makefiles);
 	free(prefs);
 }
 



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 21:56:13 UTC 2021

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

Log Message:
make: fix double-free in CLEANUP mode (since 2021.12.27.23.11.55)

When make is run without the '-f' option, it searches for the files
'makefile' and 'Makefile' in the current directory.  The function
ReadFirstDefaultMakefile allocated memory for these filenames, added the
filenames to opts.makefiles and then freed the memory.  From that
moment, opts.makefiles contained dangling pointers.

The function main_CleanUp cleans the list, but only if make is compiled
with -DCLEANUP.  Since main.c 1.557 from 2021.12.27.23.11.55, the
strings in opts.makefiles are freed as well, before that, only the list
nodes were freed.  Freeing the strings led to the double-free.

Fix this bug by using a separate list for these short-lived strings.  At
the point where ReadFirstDefaultMakefile is called, opts.makefiles is
not used anymore, therefore there are no side effects.

To reproduce, run 'make test-coverage', which compiles with -DCLEANUP.
The test opt-chdir failed with a segmentation fault in main_Cleanup.
This test may be the only one that doesn't use the option '-f'.


To generate a diff of this commit:
cvs rdiff -u -r1.561 -r1.562 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.



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 19:43:43 UTC 2021

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

Log Message:
make: rename and constify SkipExtraTargets

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.602 -r1.603 src/usr.bin/make/parse.c

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



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 19:43:43 UTC 2021

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

Log Message:
make: rename and constify SkipExtraTargets

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.602 -r1.603 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.602 src/usr.bin/make/parse.c:1.603
--- src/usr.bin/make/parse.c:1.602	Tue Dec 28 19:41:01 2021
+++ src/usr.bin/make/parse.c	Tue Dec 28 19:43:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.602 2021/12/28 19:41:01 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.603 2021/12/28 19:43:42 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.602 2021/12/28 19:41:01 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.603 2021/12/28 19:43:42 rillig Exp $");
 
 /* types and constants */
 
@@ -1190,10 +1190,10 @@ HandleDependencyTargetMundane(char *targ
 }
 
 static void
-ParseDependencyTargetExtraWarn(char **pp, const char *lstart)
+SkipExtraTargets(char **pp, const char *lstart)
 {
 	bool warning = false;
-	char *cp = *pp;
+	const char *cp = *pp;
 
 	while (*cp != '\0') {
 		if (!IsEscaped(lstart, cp) && (*cp == '!' || *cp == ':'))
@@ -1205,7 +1205,7 @@ ParseDependencyTargetExtraWarn(char **pp
 	if (warning)
 		Parse_Error(PARSE_WARNING, "Extra target ignored");
 
-	*pp = cp;
+	*pp += cp - *pp;
 }
 
 static void
@@ -1427,7 +1427,7 @@ ParseDependencyTargets(char **inout_cp,
 			return false;
 
 		if (*inout_special != SP_NOT && *inout_special != SP_PATH)
-			ParseDependencyTargetExtraWarn(&cp, lstart);
+			SkipExtraTargets(&cp, lstart);
 		else
 			pp_skip_whitespace(&cp);
 



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 19:41:01 UTC 2021

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

Log Message:
make: clean up function names in parse.c, remove redundant comments

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.601 -r1.602 src/usr.bin/make/parse.c

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



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 19:41:01 UTC 2021

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

Log Message:
make: clean up function names in parse.c, remove redundant comments

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.601 -r1.602 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.601 src/usr.bin/make/parse.c:1.602
--- src/usr.bin/make/parse.c:1.601	Tue Dec 28 19:13:40 2021
+++ src/usr.bin/make/parse.c	Tue Dec 28 19:41:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.601 2021/12/28 19:13:40 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.602 2021/12/28 19:41:01 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.601 2021/12/28 19:13:40 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.602 2021/12/28 19:41:01 rillig Exp $");
 
 /* types and constants */
 
@@ -508,7 +508,7 @@ PrintStackTrace(void)
 
 /* Check if the current character is escaped on the current line. */
 static bool
-ParseIsEscaped(const char *line, const char *p)
+IsEscaped(const char *line, const char *p)
 {
 	bool active = false;
 	while (p > line && *--p == '\\')
@@ -533,7 +533,7 @@ RememberLocation(GNode *gn)
  * Return the index of the keyword, or -1 if it isn't there.
  */
 static int
-ParseFindKeyword(const char *str)
+FindKeyword(const char *str)
 {
 	int start = 0;
 	int end = sizeof parseKeywords / sizeof parseKeywords[0] - 1;
@@ -674,11 +674,11 @@ Parse_Error(ParseErrorLevel type, const 
 
 
 /*
- * Parse and handle an .info, .warning or .error directive.
- * For an .error directive, immediately exit.
+ * Handle an .info, .warning or .error directive.  For an .error directive,
+ * exit immediately.
  */
 static void
-ParseMessage(ParseErrorLevel level, const char *levelName, const char *umsg)
+HandleMessage(ParseErrorLevel level, const char *levelName, const char *umsg)
 {
 	char *xmsg;
 
@@ -845,7 +845,7 @@ ApplyDependencySourceKeyword(const char 
 	if (*src != '.' || !ch_isupper(src[1]))
 		return false;
 
-	keywd = ParseFindKeyword(src);
+	keywd = FindKeyword(src);
 	if (keywd == -1)
 		return false;
 
@@ -869,7 +869,7 @@ ApplyDependencySourceMain(const char *sr
 	 * list of things to create, but only if the user didn't specify a
 	 * target on the command line and .MAIN occurs for the first time.
 	 *
-	 * See ParseDependencyTargetSpecial, branch SP_MAIN.
+	 * See HandleDependencyTargetSpecial, branch SP_MAIN.
 	 * See unit-tests/cond-func-make-main.mk.
 	 */
 	Lst_Append(&opts.create, bmake_strdup(src));
@@ -981,15 +981,8 @@ FindMainTarget(void)
 	}
 }
 
-/*
- * We got to the end of the line while we were still looking at targets.
- *
- * Ending a dependency line without an operator is a Bozo no-no.  As a
- * heuristic, this is also often triggered by undetected conflicts from
- * cvs/rcs merges.
- */
 static void
-ParseErrorNoDependency(const char *lstart)
+InvalidLineType(const char *lstart)
 {
 	if ((strncmp(lstart, "<<", 6) == 0) ||
 	(strncmp(lstart, "==", 6) == 0) ||
@@ -1017,7 +1010,7 @@ ParseDependencyTargetWord(char **pp, con
 	while (*cp != '\0') {
 		if ((ch_isspace(*cp) || *cp == '!' || *cp == ':' ||
 		 *cp == '(') &&
-		!ParseIsEscaped(lstart, cp))
+		!IsEscaped(lstart, cp))
 			break;
 
 		if (*cp == '$') {
@@ -1051,9 +1044,9 @@ ParseDependencyTargetWord(char **pp, con
  * See the tests deptgt-*.mk.
  */
 static void
-ParseDependencyTargetSpecial(ParseSpecial *inout_special,
-			 const char *targetName,
-			 SearchPathList **inout_paths)
+HandleDependencyTargetSpecial(const char *targetName,
+			  ParseSpecial *inout_special,
+			  SearchPathList **inout_paths)
 {
 	switch (*inout_special) {
 	case SP_PATH:
@@ -1112,13 +1105,9 @@ ParseDependencyTargetSpecial(ParseSpecia
 	}
 }
 
-/*
- * .PATH has to be handled specially.
- * Call on the suffix module to give us a path to modify.
- */
 static bool
-ParseDependencyTargetPath(const char *suffixName,
-			  SearchPathList **inout_paths)
+HandleDependencyTargetPath(const char *suffixName,
+			   SearchPathList **inout_paths)
 {
 	SearchPath *path;
 
@@ -1140,10 +1129,10 @@ ParseDependencyTargetPath(const char *su
  * See if it's a special target and if so set inout_special to match it.
  */
 static bool
-ParseDependencyTarget(const char *targetName,
-		  ParseSpecial *inout_special,
-		  GNodeType *inout_targetAttr,
-		  SearchPathList **inout_paths)
+HandleDependencyTarget(const char *targetName,
+		   ParseSpecial *inout_special,
+		   GNodeType *inout_targetAttr,
+		   SearchPathList **inout_paths)
 {
 	int keywd;
 
@@ -1154,7 +1143,7 @@ ParseDependencyTarget(const char *target
 	 * See if the target is a special target that must h

CVS commit: src/external/gpl2/grep/dist/src

2021-12-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 28 19:22:58 UTC 2021

Modified Files:
src/external/gpl2/grep/dist/src: grep.c

Log Message:
Open with non-blocking I/O and then reset the flags to avoid blocking for
FIFOs. This is a lot easier to do than adding another stat(2) to avoid open(2).


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/gpl2/grep/dist/src/grep.c

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

Modified files:

Index: src/external/gpl2/grep/dist/src/grep.c
diff -u src/external/gpl2/grep/dist/src/grep.c:1.3 src/external/gpl2/grep/dist/src/grep.c:1.4
--- src/external/gpl2/grep/dist/src/grep.c:1.3	Tue Dec 28 09:59:02 2021
+++ src/external/gpl2/grep/dist/src/grep.c	Tue Dec 28 14:22:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: grep.c,v 1.3 2021/12/28 14:59:02 christos Exp $	*/
+/*	$NetBSD: grep.c,v 1.4 2021/12/28 19:22:58 christos Exp $	*/
 
 /* grep.c - main driver file for grep.
Copyright 1992, 1997-1999, 2000 Free Software Foundation, Inc.
@@ -911,9 +911,12 @@ grepfile (char const *file, struct stats
 }
   else
 {
-  while ((desc = open (file, O_RDONLY)) < 0 && errno == EINTR)
+  while ((desc = open (file, O_RDONLY | O_NONBLOCK)) < 0 && errno == EINTR)
 	continue;
 
+  if (desc >= 0 && (status = fcntl (desc, F_GETFL, 0)) != -1)
+	fcntl (desc, F_SETFL,  status & ~O_NONBLOCK);
+
   if (desc < 0)
 	{
 	  int e = errno;



CVS commit: src/external/gpl2/grep/dist/src

2021-12-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 28 19:22:58 UTC 2021

Modified Files:
src/external/gpl2/grep/dist/src: grep.c

Log Message:
Open with non-blocking I/O and then reset the flags to avoid blocking for
FIFOs. This is a lot easier to do than adding another stat(2) to avoid open(2).


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/external/gpl2/grep/dist/src/grep.c

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



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 19:13:40 UTC 2021

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

Log Message:
make: extract the non-parsing part from ParseDependencyTargets

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.600 -r1.601 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.600 src/usr.bin/make/parse.c:1.601
--- src/usr.bin/make/parse.c:1.600	Tue Dec 28 19:01:36 2021
+++ src/usr.bin/make/parse.c	Tue Dec 28 19:13:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.600 2021/12/28 19:01:36 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.601 2021/12/28 19:13:40 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.600 2021/12/28 19:01:36 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.601 2021/12/28 19:13:40 rillig Exp $");
 
 /* types and constants */
 
@@ -1377,6 +1377,27 @@ ParseDependencySourceSpecial(ParseSpecia
 }
 
 static bool
+ApplyDependencyTarget(char *name, char *nameEnd, ParseSpecial *inout_special,
+		  GNodeType *inout_targetAttr,
+		  SearchPathList **inout_paths)
+{
+	char savec = *nameEnd;
+	*nameEnd = '\0';
+
+	if (!ParseDependencyTarget(name, inout_special,
+	inout_targetAttr, inout_paths))
+		return false;
+
+	if (*inout_special == SP_NOT && *name != '\0')
+		ParseDependencyTargetMundane(name);
+	else if (*inout_special == SP_PATH && *name != '.' && *name != '\0')
+		Parse_Error(PARSE_WARNING, "Extra target (%s) ignored", name);
+
+	*nameEnd = savec;
+	return true;
+}
+
+static bool
 ParseDependencyTargets(char **inout_cp,
 		   const char *lstart,
 		   ParseSpecial *inout_special,
@@ -1385,7 +1406,6 @@ ParseDependencyTargets(char **inout_cp,
 {
 	char *cp;
 	char *tgt = *inout_cp;
-	char savec;
 
 	for (;;) {
 		/* Find the end of the next word. */
@@ -1413,32 +1433,10 @@ ParseDependencyTargets(char **inout_cp,
 			return false;
 		}
 
-		/* Insert a null terminator. */
-		savec = *cp;
-		*cp = '\0';
-
-		if (!ParseDependencyTarget(tgt, inout_special,
+		if (!ApplyDependencyTarget(tgt, cp, inout_special,
 		inout_targetAttr, inout_paths))
 			return false;
 
-		/*
-		 * Have word in line. Get or create its node and stick it at
-		 * the end of the targets list
-		 */
-		if (*inout_special == SP_NOT && *tgt != '\0')
-			ParseDependencyTargetMundane(tgt);
-		else if (*inout_special == SP_PATH && *tgt != '.' &&
-			 *tgt != '\0')
-			Parse_Error(PARSE_WARNING, "Extra target (%s) ignored",
-			tgt);
-
-		/* Don't need the inserted null terminator any more. */
-		*cp = savec;
-
-		/*
-		 * If it is a special type and not .PATH, it's the only target
-		 * we allow on this line.
-		 */
 		if (*inout_special != SP_NOT && *inout_special != SP_PATH)
 			ParseDependencyTargetExtraWarn(&cp, lstart);
 		else



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 19:13:40 UTC 2021

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

Log Message:
make: extract the non-parsing part from ParseDependencyTargets

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.600 -r1.601 src/usr.bin/make/parse.c

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



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 19:01:36 UTC 2021

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

Log Message:
make: clean up ParseDependency

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.599 -r1.600 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.599 src/usr.bin/make/parse.c:1.600
--- src/usr.bin/make/parse.c:1.599	Tue Dec 28 17:58:41 2021
+++ src/usr.bin/make/parse.c	Tue Dec 28 19:01:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.599 2021/12/28 17:58:41 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.600 2021/12/28 19:01:36 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.599 2021/12/28 17:58:41 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.600 2021/12/28 19:01:36 rillig Exp $");
 
 /* types and constants */
 
@@ -1608,37 +1608,31 @@ ParseDependencySources(char *p, GNodeTyp
 static void
 ParseDependency(char *line)
 {
-	char *cp;		/* our current position */
-	GNodeType op;		/* the dependency operator on the line */
+	char *p;
 	SearchPathList *paths;	/* search paths to alter when parsing a list
  * of .PATH targets */
 	GNodeType targetAttr;	/* from special sources */
-
-	/*
-	 * In special targets, the children are linked as children of the
-	 * parent but not vice versa.
-	 */
-	ParseSpecial special = SP_NOT;
+	ParseSpecial special;	/* in special targets, the children are
+ * linked as children of the parent but not
+ * vice versa */
 
 	DEBUG1(PARSE, "ParseDependency(%s)\n", line);
-	targetAttr = OP_NONE;
-
+	p = line;
 	paths = NULL;
+	targetAttr = OP_NONE;
+	special = SP_NOT;
 
-	cp = line;
-	if (!ParseDependencyTargets(&cp, line, &special,
-	&targetAttr, &paths))
+	if (!ParseDependencyTargets(&p, line, &special, &targetAttr, &paths))
 		goto out;
 
 	if (!Lst_IsEmpty(targets))
 		ParseDependencyCheckSpecial(special);
 
-	op = ParseDependencyOp(&cp);
-	ApplyDependencyOperator(op);
+	ApplyDependencyOperator(ParseDependencyOp(&p));
 
-	pp_skip_whitespace(&cp);
+	pp_skip_whitespace(&p);
 
-	ParseDependencySources(cp, targetAttr, special, &paths);
+	ParseDependencySources(p, targetAttr, special, &paths);
 
 out:
 	if (paths != NULL)



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 19:01:36 UTC 2021

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

Log Message:
make: clean up ParseDependency

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.599 -r1.600 src/usr.bin/make/parse.c

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



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 17:58:41 UTC 2021

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

Log Message:
make: remove redundant variable in ParseDependencyTargets

The idea of that variable was to work on constant strings as far as
possible.  For now it just blew up the code unnecessarily.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.598 -r1.599 src/usr.bin/make/parse.c

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



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 17:58:41 UTC 2021

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

Log Message:
make: remove redundant variable in ParseDependencyTargets

The idea of that variable was to work on constant strings as far as
possible.  For now it just blew up the code unnecessarily.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.598 -r1.599 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.598 src/usr.bin/make/parse.c:1.599
--- src/usr.bin/make/parse.c:1.598	Tue Dec 28 17:45:56 2021
+++ src/usr.bin/make/parse.c	Tue Dec 28 17:58:41 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.598 2021/12/28 17:45:56 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.599 2021/12/28 17:58:41 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.598 2021/12/28 17:45:56 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.599 2021/12/28 17:58:41 rillig Exp $");
 
 /* types and constants */
 
@@ -1010,7 +1010,7 @@ ParseErrorNoDependency(const char *lstar
 }
 
 static void
-ParseDependencyTargetWord(const char **pp, const char *lstart)
+ParseDependencyTargetWord(char **pp, const char *lstart)
 {
 	const char *cp = *pp;
 
@@ -1042,7 +1042,7 @@ ParseDependencyTargetWord(const char **p
 			cp++;
 	}
 
-	*pp = cp;
+	*pp += cp - *pp;
 }
 
 /*
@@ -1386,14 +1386,11 @@ ParseDependencyTargets(char **inout_cp,
 	char *cp;
 	char *tgt = *inout_cp;
 	char savec;
-	const char *p;
 
 	for (;;) {
 		/* Find the end of the next word. */
 		cp = tgt;
-		p = cp;
-		ParseDependencyTargetWord(&p, lstart);
-		cp += p - cp;
+		ParseDependencyTargetWord(&cp, lstart);
 
 		/*
 		 * If the word is followed by a left parenthesis, it's the



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs/sys

2021-12-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Dec 28 17:51:23 UTC 2021

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys: zfs_context.h

Log Message:
zfs: Expose hostid to zfs, as in gethostid/sethostid(3).

If set to nonzero, the hostid is recorded in the metadata of a zpool,
and checked by `zpool import' when the pool has not been explicitly
exported.  After reboot, zpool import will not need `-f' to reimport
the pool.

Setting the hostid must be done explicitly through sysctl (or the
sethostid(3) library call) on all ports except acorn32, amiga,
mvme68k, newsmips, sparc, sparc64, sun2, and sun3.  So for most users
this change will have no immediate effect.  But you can obviate the
need for `zpool import -f' by adding `kern.hostid=123456789' to
/etc/sysctl.conf and importing the pool one last time with `-f'.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/zfs_context.h

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

Modified files:

Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/zfs_context.h
diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/zfs_context.h:1.3 src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/zfs_context.h:1.4
--- src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/zfs_context.h:1.3	Tue Feb 16 09:54:17 2021
+++ src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/zfs_context.h	Tue Dec 28 17:51:23 2021
@@ -130,6 +130,7 @@ extern "C" {
 #include 
 #else /* !__NetBSD__ */
 #include 
+#include 
 #include 
 
 #include 
@@ -165,7 +166,7 @@ extern "C" {
 #define td_rul_ru
 #define UID_NOBODY			(32767)
 #define vnode_pager_setsize(vp, size)	zfs_netbsd_setsize(vp, size)
-#define zone_get_hostid(a)		0
+#define zone_get_hostid(a)		((unsigned)hostid)
 
 extern struct utsname utsname;
 



CVS commit: src/external/cddl/osnet/dist/uts/common/fs/zfs/sys

2021-12-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Dec 28 17:51:23 UTC 2021

Modified Files:
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys: zfs_context.h

Log Message:
zfs: Expose hostid to zfs, as in gethostid/sethostid(3).

If set to nonzero, the hostid is recorded in the metadata of a zpool,
and checked by `zpool import' when the pool has not been explicitly
exported.  After reboot, zpool import will not need `-f' to reimport
the pool.

Setting the hostid must be done explicitly through sysctl (or the
sethostid(3) library call) on all ports except acorn32, amiga,
mvme68k, newsmips, sparc, sparc64, sun2, and sun3.  So for most users
this change will have no immediate effect.  But you can obviate the
need for `zpool import -f' by adding `kern.hostid=123456789' to
/etc/sysctl.conf and importing the pool one last time with `-f'.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/external/cddl/osnet/dist/uts/common/fs/zfs/sys/zfs_context.h

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



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 17:45:56 UTC 2021

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

Log Message:
make: remove redundant parameter from ParseDependencyTargets

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.597 -r1.598 src/usr.bin/make/parse.c

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



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 17:45:56 UTC 2021

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

Log Message:
make: remove redundant parameter from ParseDependencyTargets

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.597 -r1.598 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.597 src/usr.bin/make/parse.c:1.598
--- src/usr.bin/make/parse.c:1.597	Tue Dec 28 17:39:04 2021
+++ src/usr.bin/make/parse.c	Tue Dec 28 17:45:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.597 2021/12/28 17:39:04 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.598 2021/12/28 17:45:56 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.597 2021/12/28 17:39:04 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.598 2021/12/28 17:45:56 rillig Exp $");
 
 /* types and constants */
 
@@ -1378,14 +1378,13 @@ ParseDependencySourceSpecial(ParseSpecia
 
 static bool
 ParseDependencyTargets(char **inout_cp,
-		   char **inout_line,
 		   const char *lstart,
 		   ParseSpecial *inout_special,
 		   GNodeType *inout_targetAttr,
 		   SearchPathList **inout_paths)
 {
 	char *cp;
-	char *tgt = *inout_line;
+	char *tgt = *inout_cp;
 	char savec;
 	const char *p;
 
@@ -1457,7 +1456,6 @@ ParseDependencyTargets(char **inout_cp,
 	}
 
 	*inout_cp = cp;
-	*inout_line = tgt;
 	return true;
 }
 
@@ -1618,7 +1616,6 @@ ParseDependency(char *line)
 	SearchPathList *paths;	/* search paths to alter when parsing a list
  * of .PATH targets */
 	GNodeType targetAttr;	/* from special sources */
-	const char *lstart = line;
 
 	/*
 	 * In special targets, the children are linked as children of the
@@ -1631,8 +1628,8 @@ ParseDependency(char *line)
 
 	paths = NULL;
 
-	/* XXX: don't use 'line' as an iterator variable */
-	if (!ParseDependencyTargets(&cp, &line, lstart, &special,
+	cp = line;
+	if (!ParseDependencyTargets(&cp, line, &special,
 	&targetAttr, &paths))
 		goto out;
 



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 17:39:04 UTC 2021

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

Log Message:
make: remove redundant parameters in dependency parsing functions

Before 2020, there had been a huge function for parsing a dependency
line, with lots of local variables that were reused for different
purposes.  When that function was split up into smaller functions, that
was done mechanically, without eliminating redundant variables.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.596 -r1.597 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.596 src/usr.bin/make/parse.c:1.597
--- src/usr.bin/make/parse.c:1.596	Tue Dec 28 17:30:11 2021
+++ src/usr.bin/make/parse.c	Tue Dec 28 17:39:04 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.596 2021/12/28 17:30:11 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.597 2021/12/28 17:39:04 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.596 2021/12/28 17:30:11 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.597 2021/12/28 17:39:04 rillig Exp $");
 
 /* types and constants */
 
@@ -1462,12 +1462,13 @@ ParseDependencyTargets(char **inout_cp,
 }
 
 static void
-ParseDependencySourcesSpecial(char *start, char *end,
+ParseDependencySourcesSpecial(char *start,
 			  ParseSpecial special, SearchPathList *paths)
 {
 	char savec;
 
 	while (*start != '\0') {
+		char *end = start;
 		while (*end != '\0' && !ch_isspace(*end))
 			end++;
 		savec = *end;
@@ -1482,10 +1483,11 @@ ParseDependencySourcesSpecial(char *star
 }
 
 static bool
-ParseDependencySourcesMundane(char *start, char *end,
+ParseDependencySourcesMundane(char *start,
 			  ParseSpecial special, GNodeType targetAttr)
 {
 	while (*start != '\0') {
+		char *end = start;
 		/*
 		 * The targets take real sources, so we must beware of archive
 		 * specifications (i.e. things with left parentheses in them)
@@ -1541,36 +1543,35 @@ ParseDependencySourcesMundane(char *star
  * See the tests depsrc-*.mk.
  */
 static void
-ParseDependencySources(char *line, char *cp, GNodeType targetAttr,
+ParseDependencySources(char *p, GNodeType targetAttr,
 		   ParseSpecial special, SearchPathList **inout_paths)
 {
-	if (line[0] == '\0') {
+	if (*p == '\0') {
 		ParseDependencySourcesEmpty(special, *inout_paths);
 	} else if (special == SP_MFLAGS) {
-		Main_ParseArgLine(line);
+		Main_ParseArgLine(p);
 		/*
 		 * Set the initial character to a null-character so the loop
 		 * to get sources won't get anything.
 		 */
-		*line = '\0';
+		*p = '\0';
 	} else if (special == SP_SHELL) {
-		if (!Job_ParseShell(line)) {
+		if (!Job_ParseShell(p)) {
 			Parse_Error(PARSE_FATAL,
 			"improper shell specification");
 			return;
 		}
-		*line = '\0';
+		*p = '\0';
 	} else if (special == SP_NOTPARALLEL || special == SP_SINGLESHELL ||
 		   special == SP_DELETE_ON_ERROR) {
-		*line = '\0';
+		*p = '\0';
 	}
 
 	/* Now go for the sources. */
 	if (special == SP_SUFFIXES || special == SP_PATH ||
 	special == SP_INCLUDES || special == SP_LIBS ||
 	special == SP_NULL || special == SP_OBJDIR) {
-		ParseDependencySourcesSpecial(line, cp, special,
-		*inout_paths);
+		ParseDependencySourcesSpecial(p, special, *inout_paths);
 		if (*inout_paths != NULL) {
 			Lst_Free(*inout_paths);
 			*inout_paths = NULL;
@@ -1579,8 +1580,7 @@ ParseDependencySources(char *line, char 
 			Dir_SetPATH();
 	} else {
 		assert(*inout_paths == NULL);
-		if (!ParseDependencySourcesMundane(line, cp, special,
-		targetAttr))
+		if (!ParseDependencySourcesMundane(p, special, targetAttr))
 			return;
 	}
 
@@ -1643,9 +1643,8 @@ ParseDependency(char *line)
 	ApplyDependencyOperator(op);
 
 	pp_skip_whitespace(&cp);
-	line = cp;		/* XXX: 'line' is an inappropriate name */
 
-	ParseDependencySources(line, cp, targetAttr, special, &paths);
+	ParseDependencySources(cp, targetAttr, special, &paths);
 
 out:
 	if (paths != NULL)



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 17:39:04 UTC 2021

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

Log Message:
make: remove redundant parameters in dependency parsing functions

Before 2020, there had been a huge function for parsing a dependency
line, with lots of local variables that were reused for different
purposes.  When that function was split up into smaller functions, that
was done mechanically, without eliminating redundant variables.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.596 -r1.597 src/usr.bin/make/parse.c

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



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 17:30:11 UTC 2021

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

Log Message:
make: remove redundant comments from ParseDependencyTargets

The large comment is already explained in the archive module.


To generate a diff of this commit:
cvs rdiff -u -r1.595 -r1.596 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.595 src/usr.bin/make/parse.c:1.596
--- src/usr.bin/make/parse.c:1.595	Tue Dec 28 16:59:09 2021
+++ src/usr.bin/make/parse.c	Tue Dec 28 17:30:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.595 2021/12/28 16:59:09 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.596 2021/12/28 17:30:11 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.595 2021/12/28 16:59:09 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.596 2021/12/28 17:30:11 rillig Exp $");
 
 /* types and constants */
 
@@ -1390,11 +1390,6 @@ ParseDependencyTargets(char **inout_cp,
 	const char *p;
 
 	for (;;) {
-		/*
-		 * Here LINE points to the beginning of the next word, and
-		 * LSTART points to the actual beginning of the line.
-		 */
-
 		/* Find the end of the next word. */
 		cp = tgt;
 		p = cp;
@@ -1403,22 +1398,9 @@ ParseDependencyTargets(char **inout_cp,
 
 		/*
 		 * If the word is followed by a left parenthesis, it's the
-		 * name of an object file inside an archive (ar file).
+		 * name of one or more files inside an archive.
 		 */
 		if (!ParseIsEscaped(lstart, cp) && *cp == '(') {
-			/*
-			 * Archives must be handled specially to make sure the
-			 * OP_ARCHV flag is set in their 'type' field, for one
-			 * thing, and because things like "archive(file1.o
-			 * file2.o file3.o)" are permissible.
-			 *
-			 * Arch_ParseArchive will set 'line' to be the first
-			 * non-blank after the archive-spec. It creates/finds
-			 * nodes for the members and places them on the given
-			 * list, returning true if all went well and false if
-			 * there was an error in the specification. On error,
-			 * line should remain untouched.
-			 */
 			if (!Arch_ParseArchive(&tgt, targets, SCOPE_CMDLINE)) {
 Parse_Error(PARSE_FATAL,
 "Error in archive specification: \"%s\"",



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 17:30:11 UTC 2021

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

Log Message:
make: remove redundant comments from ParseDependencyTargets

The large comment is already explained in the archive module.


To generate a diff of this commit:
cvs rdiff -u -r1.595 -r1.596 src/usr.bin/make/parse.c

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



CVS commit: src/external/bsd/openldap/lib/slapd

2021-12-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 28 17:06:05 UTC 2021

Added Files:
src/external/bsd/openldap/lib/slapd: Makefile.inc

Log Message:
for openldap.mk


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/external/bsd/openldap/lib/slapd/Makefile.inc

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

Added files:

Index: src/external/bsd/openldap/lib/slapd/Makefile.inc
diff -u /dev/null src/external/bsd/openldap/lib/slapd/Makefile.inc:1.1
--- /dev/null	Tue Dec 28 12:06:05 2021
+++ src/external/bsd/openldap/lib/slapd/Makefile.inc	Tue Dec 28 12:06:05 2021
@@ -0,0 +1,3 @@
+#	$NetBSD: Makefile.inc,v 1.1 2021/12/28 17:06:05 christos Exp $
+
+.include "../../openldap.mk"



CVS commit: src/external/bsd/openldap/lib/slapd

2021-12-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 28 17:06:05 UTC 2021

Added Files:
src/external/bsd/openldap/lib/slapd: Makefile.inc

Log Message:
for openldap.mk


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/external/bsd/openldap/lib/slapd/Makefile.inc

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



CVS commit: src/external/bsd/openldap

2021-12-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 28 17:05:44 UTC 2021

Modified Files:
src/external/bsd/openldap/include: portable.h
src/external/bsd/openldap/lib: Makefile
Added Files:
src/external/bsd/openldap/lib/slapd: Makefile
src/external/bsd/openldap/lib/slapd/back-ldif: Makefile
src/external/bsd/openldap/lib/slapd/back-mdb: Makefile
src/external/bsd/openldap/lib/slapd/back-monitor: Makefile
src/external/bsd/openldap/lib/slapd/back-relay: Makefile
src/external/bsd/openldap/lib/slapd/overlays: Makefile statover.c
src/external/bsd/openldap/sbin: Makefile.inc
src/external/bsd/openldap/sbin/slapd: Makefile backends.c

Log Message:
Add slapd WIP.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/external/bsd/openldap/include/portable.h
cvs rdiff -u -r1.1 -r1.2 src/external/bsd/openldap/lib/Makefile
cvs rdiff -u -r0 -r1.1 src/external/bsd/openldap/lib/slapd/Makefile
cvs rdiff -u -r0 -r1.1 src/external/bsd/openldap/lib/slapd/back-ldif/Makefile
cvs rdiff -u -r0 -r1.1 src/external/bsd/openldap/lib/slapd/back-mdb/Makefile
cvs rdiff -u -r0 -r1.1 \
src/external/bsd/openldap/lib/slapd/back-monitor/Makefile
cvs rdiff -u -r0 -r1.1 \
src/external/bsd/openldap/lib/slapd/back-relay/Makefile
cvs rdiff -u -r0 -r1.1 src/external/bsd/openldap/lib/slapd/overlays/Makefile \
src/external/bsd/openldap/lib/slapd/overlays/statover.c
cvs rdiff -u -r0 -r1.1 src/external/bsd/openldap/sbin/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/external/bsd/openldap/sbin/slapd/Makefile \
src/external/bsd/openldap/sbin/slapd/backends.c

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

Modified files:

Index: src/external/bsd/openldap/include/portable.h
diff -u src/external/bsd/openldap/include/portable.h:1.9 src/external/bsd/openldap/include/portable.h:1.10
--- src/external/bsd/openldap/include/portable.h:1.9	Tue Aug 11 09:15:43 2020
+++ src/external/bsd/openldap/include/portable.h	Tue Dec 28 12:05:43 2021
@@ -359,7 +359,7 @@
 #define HAVE_MKTEMP 1
 
 /* define this if you have mkversion */
-#define HAVE_MKVERSION 1
+#undef HAVE_MKVERSION
 
 /* define if you have MozNSS */
 /* #undef HAVE_MOZNSS */

Index: src/external/bsd/openldap/lib/Makefile
diff -u src/external/bsd/openldap/lib/Makefile:1.1 src/external/bsd/openldap/lib/Makefile:1.2
--- src/external/bsd/openldap/lib/Makefile:1.1	Thu May 22 09:57:47 2008
+++ src/external/bsd/openldap/lib/Makefile	Tue Dec 28 12:05:43 2021
@@ -1,5 +1,5 @@
-#	$NetBSD: Makefile,v 1.1 2008/05/22 13:57:47 lukem Exp $
+#	$NetBSD: Makefile,v 1.2 2021/12/28 17:05:43 christos Exp $
 
-SUBDIR=	liblber .WAIT libldap libldap_r liblutil 
+SUBDIR=	liblber .WAIT libldap libldap_r liblutil # librewrite liblunicode slapd
 
 .include 

Added files:

Index: src/external/bsd/openldap/lib/slapd/Makefile
diff -u /dev/null src/external/bsd/openldap/lib/slapd/Makefile:1.1
--- /dev/null	Tue Dec 28 12:05:44 2021
+++ src/external/bsd/openldap/lib/slapd/Makefile	Tue Dec 28 12:05:44 2021
@@ -0,0 +1,5 @@
+# $NetBSD: Makefile,v 1.1 2021/12/28 17:05:44 christos Exp $
+
+SUBDIR= back-ldif back-mdb back-monitor back-relay overlays
+
+.include 

Index: src/external/bsd/openldap/lib/slapd/back-ldif/Makefile
diff -u /dev/null src/external/bsd/openldap/lib/slapd/back-ldif/Makefile:1.1
--- /dev/null	Tue Dec 28 12:05:44 2021
+++ src/external/bsd/openldap/lib/slapd/back-ldif/Makefile	Tue Dec 28 12:05:44 2021
@@ -0,0 +1,19 @@
+# $NetBSD: Makefile,v 1.1 2021/12/28 17:05:44 christos Exp $
+
+USE_FORT=yes
+LIBISPRIVATE=yes
+
+.include 
+
+LIB=back_ldif
+
+SLAPD= ${LDAP_DISTDIR}/servers/slapd
+BACK_LDIF=${SLAPD}/back-ldif
+.PATH: ${BACK_LDIF}
+
+CPPFLAGS+=-I${SLAPD} -I${BACK_LDIF}
+
+SRCS += \
+	ldif.c version.c
+
+.include 

Index: src/external/bsd/openldap/lib/slapd/back-mdb/Makefile
diff -u /dev/null src/external/bsd/openldap/lib/slapd/back-mdb/Makefile:1.1
--- /dev/null	Tue Dec 28 12:05:45 2021
+++ src/external/bsd/openldap/lib/slapd/back-mdb/Makefile	Tue Dec 28 12:05:44 2021
@@ -0,0 +1,26 @@
+# $NetBSD: Makefile,v 1.1 2021/12/28 17:05:44 christos Exp $
+
+USE_FORT=yes
+LIBISPRIVATE=yes
+
+.include 
+
+LIB=back_mdb
+
+SLAPD= ${LDAP_DISTDIR}/servers/slapd
+BACK_MDB=${SLAPD}/back-mdb
+LMDB=${LDAP_DISTDIR}/libraries/liblmdb
+
+.PATH: ${BACK_MDB} ${LMDB}
+
+COPTS.mdb.c += -Wno-error=stringop-overflow
+
+CPPFLAGS+=-I${SLAPD} -I${BACK_MDB} -I${LMDB}
+
+SRCS += \
+	add.c delete.c id2entry.c mdb.c nextid.c attr.c dn2entry.c \
+	idl.c midl.c operational.c bind.c dn2id.c index.c modify.c \
+	search.c compare.c extended.c init.c modrdn.c tools.c \
+	config.c filterindex.c key.c monitor.c version.c \
+
+.include 

Index: src/external/bsd/openldap/lib/slapd/back-monitor/Makefile
diff -u /dev/null src/external/bsd/openldap/lib/slapd/back-monitor/Makefile:1.1
--- /dev/null	Tue Dec 28 12:05:45 2021
+++ src/external/bsd/openldap/lib/slapd/back-monitor/Makefile	Tue Dec 28 12:05:

CVS commit: src/external/bsd/openldap

2021-12-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 28 17:05:44 UTC 2021

Modified Files:
src/external/bsd/openldap/include: portable.h
src/external/bsd/openldap/lib: Makefile
Added Files:
src/external/bsd/openldap/lib/slapd: Makefile
src/external/bsd/openldap/lib/slapd/back-ldif: Makefile
src/external/bsd/openldap/lib/slapd/back-mdb: Makefile
src/external/bsd/openldap/lib/slapd/back-monitor: Makefile
src/external/bsd/openldap/lib/slapd/back-relay: Makefile
src/external/bsd/openldap/lib/slapd/overlays: Makefile statover.c
src/external/bsd/openldap/sbin: Makefile.inc
src/external/bsd/openldap/sbin/slapd: Makefile backends.c

Log Message:
Add slapd WIP.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/external/bsd/openldap/include/portable.h
cvs rdiff -u -r1.1 -r1.2 src/external/bsd/openldap/lib/Makefile
cvs rdiff -u -r0 -r1.1 src/external/bsd/openldap/lib/slapd/Makefile
cvs rdiff -u -r0 -r1.1 src/external/bsd/openldap/lib/slapd/back-ldif/Makefile
cvs rdiff -u -r0 -r1.1 src/external/bsd/openldap/lib/slapd/back-mdb/Makefile
cvs rdiff -u -r0 -r1.1 \
src/external/bsd/openldap/lib/slapd/back-monitor/Makefile
cvs rdiff -u -r0 -r1.1 \
src/external/bsd/openldap/lib/slapd/back-relay/Makefile
cvs rdiff -u -r0 -r1.1 src/external/bsd/openldap/lib/slapd/overlays/Makefile \
src/external/bsd/openldap/lib/slapd/overlays/statover.c
cvs rdiff -u -r0 -r1.1 src/external/bsd/openldap/sbin/Makefile.inc
cvs rdiff -u -r0 -r1.1 src/external/bsd/openldap/sbin/slapd/Makefile \
src/external/bsd/openldap/sbin/slapd/backends.c

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



CVS commit: src/external/bsd/openldap/lib/liblunicode

2021-12-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 28 17:05:23 UTC 2021

Modified Files:
src/external/bsd/openldap/lib/liblunicode: Makefile
Added Files:
src/external/bsd/openldap/lib/liblunicode/ucgendat: Makefile

Log Message:
remove tools support, not needed, but add the ugcendat Makefile


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/bsd/openldap/lib/liblunicode/Makefile
cvs rdiff -u -r0 -r1.1 \
src/external/bsd/openldap/lib/liblunicode/ucgendat/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/bsd/openldap/lib/liblunicode/Makefile
diff -u src/external/bsd/openldap/lib/liblunicode/Makefile:1.1 src/external/bsd/openldap/lib/liblunicode/Makefile:1.2
--- src/external/bsd/openldap/lib/liblunicode/Makefile:1.1	Tue Dec 28 12:04:18 2021
+++ src/external/bsd/openldap/lib/liblunicode/Makefile	Tue Dec 28 12:05:23 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.1 2021/12/28 17:04:18 christos Exp $
+#	$NetBSD: Makefile,v 1.2 2021/12/28 17:05:23 christos Exp $
 
 USE_FORT?=	yes
 
@@ -14,29 +14,4 @@ CPPFLAGS+=	-I${LIBLUNICODE} -I${LIBLUNIC
 
 SRCS+= ucdata.c ure.c urestubs.c ucstr.c
 
-
-.if ${USETOOLS} != "yes"
-UCGENDATOBJ!= cd ${.CURDIR}/ucgendat && ${PRINTOBJDIR}
-TOOL_UCGENDAT=   ${UCGENDATDIR}/ucgendat
-
-.PHONY: ucgendat
-includes:   ucgendat
-SUBDIR= ucgendat
-
-ucgendat:
-	@cd ${.CURDIR}/ucgendat && ${MAKE}
-.endif
-
-uctable.h: ${TOOL_UCGENDAT} ${LIBLUNICODE}/UnicodeData.txt ${LIBLUNICODE}/CompositionExclusions.txt
-	${_MKTARGET_CREATE}
-	${TOOL_UCGENDAT} ${LIBLUNICODE}/UnicodeData.txt \
-	-x ${LIBLUNICODE}/CompositionExclusions.txt
-
-ucdata.c: uctable.h
-.endif
-
-
 .include 
-.if ${USETOOLS} != "yes"
-.include 
-.endif

Added files:

Index: src/external/bsd/openldap/lib/liblunicode/ucgendat/Makefile
diff -u /dev/null src/external/bsd/openldap/lib/liblunicode/ucgendat/Makefile:1.1
--- /dev/null	Tue Dec 28 12:05:23 2021
+++ src/external/bsd/openldap/lib/liblunicode/ucgendat/Makefile	Tue Dec 28 12:05:23 2021
@@ -0,0 +1,22 @@
+# $NetBSD: Makefile,v 1.1 2021/12/28 17:05:23 christos Exp $
+
+.include 
+.include <${.CURDIR}/../../../openldap.mk>
+
+.PATH:	${LDAP_DISTDIR}/libraries/liblunicode/ucdata
+
+PROG= ucgendat
+
+SRCS+=	ucgendat.c
+
+CPPFLAGS+=\
+	-I${LDAP_SRCDIR}/include	\
+	-I${LDAP_DISTDIR}/include	\
+	'-Dlutil_progname(a,b,c)=__UNCONST(getprogname())'
+
+HOST_CPPFLAGS+= ${CPPFLAGS}
+
+.ifndef HOSTPROG
+HOSTPROG=	${PROG}
+.include 
+.endif



CVS commit: src/external/bsd/openldap/lib/liblunicode

2021-12-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 28 17:05:23 UTC 2021

Modified Files:
src/external/bsd/openldap/lib/liblunicode: Makefile
Added Files:
src/external/bsd/openldap/lib/liblunicode/ucgendat: Makefile

Log Message:
remove tools support, not needed, but add the ugcendat Makefile


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/external/bsd/openldap/lib/liblunicode/Makefile
cvs rdiff -u -r0 -r1.1 \
src/external/bsd/openldap/lib/liblunicode/ucgendat/Makefile

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



CVS commit: src/external/bsd/openldap/lib/liblunicode

2021-12-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 28 17:04:18 UTC 2021

Added Files:
src/external/bsd/openldap/lib/liblunicode: Makefile

Log Message:
Commit a Makefile with tools support


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/external/bsd/openldap/lib/liblunicode/Makefile

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

Added files:

Index: src/external/bsd/openldap/lib/liblunicode/Makefile
diff -u /dev/null src/external/bsd/openldap/lib/liblunicode/Makefile:1.1
--- /dev/null	Tue Dec 28 12:04:18 2021
+++ src/external/bsd/openldap/lib/liblunicode/Makefile	Tue Dec 28 12:04:18 2021
@@ -0,0 +1,42 @@
+#	$NetBSD: Makefile,v 1.1 2021/12/28 17:04:18 christos Exp $
+
+USE_FORT?=	yes
+
+LIBISPRIVATE=	yes
+
+.include "../../openldap.mk"
+
+LIB=		lunicode
+
+LIBLUNICODE=${LDAP_DISTDIR}/libraries/liblunicode
+.PATH:		${LIBLUNICODE} ${LIBLUNICODE}/ucdata ${LIBLUNICODE}/ure
+CPPFLAGS+=	-I${LIBLUNICODE} -I${LIBLUNICODE}/ucdata -I.
+
+SRCS+= ucdata.c ure.c urestubs.c ucstr.c
+
+
+.if ${USETOOLS} != "yes"
+UCGENDATOBJ!= cd ${.CURDIR}/ucgendat && ${PRINTOBJDIR}
+TOOL_UCGENDAT=   ${UCGENDATDIR}/ucgendat
+
+.PHONY: ucgendat
+includes:   ucgendat
+SUBDIR= ucgendat
+
+ucgendat:
+	@cd ${.CURDIR}/ucgendat && ${MAKE}
+.endif
+
+uctable.h: ${TOOL_UCGENDAT} ${LIBLUNICODE}/UnicodeData.txt ${LIBLUNICODE}/CompositionExclusions.txt
+	${_MKTARGET_CREATE}
+	${TOOL_UCGENDAT} ${LIBLUNICODE}/UnicodeData.txt \
+	-x ${LIBLUNICODE}/CompositionExclusions.txt
+
+ucdata.c: uctable.h
+.endif
+
+
+.include 
+.if ${USETOOLS} != "yes"
+.include 
+.endif



CVS commit: src/external/bsd/openldap/lib/liblunicode

2021-12-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 28 17:04:18 UTC 2021

Added Files:
src/external/bsd/openldap/lib/liblunicode: Makefile

Log Message:
Commit a Makefile with tools support


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/external/bsd/openldap/lib/liblunicode/Makefile

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



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 16:59:09 UTC 2021

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

Log Message:
make: reduce scope of the list of wildcard target names

The list is only used when a single target name is parsed, in case the
name contains wildcards.  There is no need to keep it any longer or
reuse it.

Clean up outdated and redundant comments.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.594 -r1.595 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.594 src/usr.bin/make/parse.c:1.595
--- src/usr.bin/make/parse.c:1.594	Tue Dec 28 16:35:43 2021
+++ src/usr.bin/make/parse.c	Tue Dec 28 16:59:09 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.594 2021/12/28 16:35:43 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.595 2021/12/28 16:59:09 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.594 2021/12/28 16:35:43 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.595 2021/12/28 16:59:09 rillig Exp $");
 
 /* types and constants */
 
@@ -1177,32 +1177,19 @@ ParseDependencyTarget(const char *target
 }
 
 static void
-ParseDependencyTargetMundane(char *targetName, StringList *targetNames)
+ParseDependencyTargetMundane(char *targetName)
 {
+	StringList targetNames = LST_INIT;
+
 	if (Dir_HasWildcards(targetName)) {
-		/*
-		 * Targets are to be sought only in the current directory,
-		 * so create an empty path for the thing. Note we need to
-		 * use Dir_Destroy in the destruction of the path as the
-		 * Dir module could have added a directory to the path...
-		 */
 		SearchPath *emptyPath = SearchPath_New();
-
-		SearchPath_Expand(emptyPath, targetName, targetNames);
-
+		SearchPath_Expand(emptyPath, targetName, &targetNames);
 		SearchPath_Free(emptyPath);
-	} else {
-		/*
-		 * No wildcards, but we want to avoid code duplication,
-		 * so create a list with the word on it.
-		 */
-		Lst_Append(targetNames, targetName);
-	}
-
-	/* Apply the targets. */
+	} else
+		Lst_Append(&targetNames, targetName);
 
-	while (!Lst_IsEmpty(targetNames)) {
-		char *targName = Lst_Dequeue(targetNames);
+	while (!Lst_IsEmpty(&targetNames)) {
+		char *targName = Lst_Dequeue(&targetNames);
 		GNode *gn = Suff_IsTransform(targName)
 		? Suff_AddTransform(targName)
 		: Targ_GetNode(targName);
@@ -1395,8 +1382,7 @@ ParseDependencyTargets(char **inout_cp,
 		   const char *lstart,
 		   ParseSpecial *inout_special,
 		   GNodeType *inout_targetAttr,
-		   SearchPathList **inout_paths,
-		   StringList *targetNames)
+		   SearchPathList **inout_paths)
 {
 	char *cp;
 	char *tgt = *inout_line;
@@ -1462,7 +1448,7 @@ ParseDependencyTargets(char **inout_cp,
 		 * the end of the targets list
 		 */
 		if (*inout_special == SP_NOT && *tgt != '\0')
-			ParseDependencyTargetMundane(tgt, targetNames);
+			ParseDependencyTargetMundane(tgt);
 		else if (*inout_special == SP_PATH && *tgt != '.' &&
 			 *tgt != '\0')
 			Parse_Error(PARSE_WARNING, "Extra target (%s) ignored",
@@ -1650,9 +1636,7 @@ ParseDependency(char *line)
 	SearchPathList *paths;	/* search paths to alter when parsing a list
  * of .PATH targets */
 	GNodeType targetAttr;	/* from special sources */
-	/* target names to be found and added to the targets list */
-	StringList targetNames = LST_INIT;
-	char *lstart = line;
+	const char *lstart = line;
 
 	/*
 	 * In special targets, the children are linked as children of the
@@ -1667,16 +1651,9 @@ ParseDependency(char *line)
 
 	/* XXX: don't use 'line' as an iterator variable */
 	if (!ParseDependencyTargets(&cp, &line, lstart, &special,
-	&targetAttr, &paths, &targetNames))
+	&targetAttr, &paths))
 		goto out;
 
-	/*
-	 * Don't need the list of target names anymore.
-	 * The targets themselves are now in the global variable 'targets'.
-	 */
-	Lst_Done(&targetNames);
-	Lst_Init(&targetNames);
-
 	if (!Lst_IsEmpty(targets))
 		ParseDependencyCheckSpecial(special);
 
@@ -1691,7 +1668,6 @@ ParseDependency(char *line)
 out:
 	if (paths != NULL)
 		Lst_Free(paths);
-	Lst_Done(&targetNames);
 }
 
 typedef struct VarAssignParsed {



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 16:59:09 UTC 2021

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

Log Message:
make: reduce scope of the list of wildcard target names

The list is only used when a single target name is parsed, in case the
name contains wildcards.  There is no need to keep it any longer or
reuse it.

Clean up outdated and redundant comments.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.594 -r1.595 src/usr.bin/make/parse.c

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



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 16:35:43 UTC 2021

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

Log Message:
make: make ParseIsEscape simpler

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.593 -r1.594 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.593 src/usr.bin/make/parse.c:1.594
--- src/usr.bin/make/parse.c:1.593	Tue Dec 28 16:17:54 2021
+++ src/usr.bin/make/parse.c	Tue Dec 28 16:35:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.593 2021/12/28 16:17:54 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.594 2021/12/28 16:35:43 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.593 2021/12/28 16:17:54 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.594 2021/12/28 16:35:43 rillig Exp $");
 
 /* types and constants */
 
@@ -508,16 +508,12 @@ PrintStackTrace(void)
 
 /* Check if the current character is escaped on the current line. */
 static bool
-ParseIsEscaped(const char *line, const char *c)
+ParseIsEscaped(const char *line, const char *p)
 {
 	bool active = false;
-	for (;;) {
-		if (line == c)
-			return active;
-		if (*--c != '\\')
-			return active;
+	while (p > line && *--p == '\\')
 		active = !active;
-	}
+	return active;
 }
 
 /*



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 16:35:43 UTC 2021

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

Log Message:
make: make ParseIsEscape simpler

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.593 -r1.594 src/usr.bin/make/parse.c

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



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 16:17:54 UTC 2021

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

Log Message:
make: rename functions for handling dependency lines

The prefix 'Parse' was ambiguous since it was both the module name and a
verb.  Rename those functions that don't actually parse anything.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.592 -r1.593 src/usr.bin/make/parse.c

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



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 16:17:54 UTC 2021

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

Log Message:
make: rename functions for handling dependency lines

The prefix 'Parse' was ambiguous since it was both the module name and a
verb.  Rename those functions that don't actually parse anything.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.592 -r1.593 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.592 src/usr.bin/make/parse.c:1.593
--- src/usr.bin/make/parse.c:1.592	Tue Dec 28 16:11:00 2021
+++ src/usr.bin/make/parse.c	Tue Dec 28 16:17:54 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.592 2021/12/28 16:11:00 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.593 2021/12/28 16:17:54 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.592 2021/12/28 16:11:00 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.593 2021/12/28 16:17:54 rillig Exp $");
 
 /* types and constants */
 
@@ -825,7 +825,7 @@ ApplyDependencyOperator(GNodeType op)
  * We give each .WAIT node a unique name (mainly for diagnostics).
  */
 static void
-ParseDependencySourceWait(bool isSpecial)
+ApplyDependencySourceWait(bool isSpecial)
 {
 	static int wait_number = 0;
 	char wait_src[16];
@@ -841,7 +841,7 @@ ParseDependencySourceWait(bool isSpecial
 }
 
 static bool
-ParseDependencySourceKeyword(const char *src, ParseSpecial special)
+ApplyDependencySourceKeyword(const char *src, ParseSpecial special)
 {
 	int keywd;
 	GNodeType targetAttr;
@@ -859,14 +859,14 @@ ParseDependencySourceKeyword(const char 
 		return true;
 	}
 	if (parseKeywords[keywd].special == SP_WAIT) {
-		ParseDependencySourceWait(special != SP_NOT);
+		ApplyDependencySourceWait(special != SP_NOT);
 		return true;
 	}
 	return false;
 }
 
 static void
-ParseDependencySourceMain(const char *src)
+ApplyDependencySourceMain(const char *src)
 {
 	/*
 	 * In a line like ".MAIN: source1 source2", add all sources to the
@@ -885,7 +885,7 @@ ParseDependencySourceMain(const char *sr
 }
 
 static void
-ParseDependencySourceOrder(const char *src)
+ApplyDependencySourceOrder(const char *src)
 {
 	GNode *gn;
 	/*
@@ -913,7 +913,7 @@ ParseDependencySourceOrder(const char *s
 }
 
 static void
-ParseDependencySourceOther(const char *src, GNodeType targetAttr,
+ApplyDependencySourceOther(const char *src, GNodeType targetAttr,
 			   ParseSpecial special)
 {
 	GNode *gn;
@@ -947,18 +947,18 @@ ParseDependencySourceOther(const char *s
  * Otherwise, make the source a child of the targets.
  */
 static void
-ParseDependencySource(GNodeType targetAttr, const char *src,
+ApplyDependencySource(GNodeType targetAttr, const char *src,
 		  ParseSpecial special)
 {
-	if (ParseDependencySourceKeyword(src, special))
+	if (ApplyDependencySourceKeyword(src, special))
 		return;
 
 	if (special == SP_MAIN)
-		ParseDependencySourceMain(src);
+		ApplyDependencySourceMain(src);
 	else if (special == SP_ORDER)
-		ParseDependencySourceOrder(src);
+		ApplyDependencySourceOrder(src);
 	else
-		ParseDependencySourceOther(src, targetAttr, special);
+		ApplyDependencySourceOther(src, targetAttr, special);
 }
 
 /*
@@ -1552,7 +1552,7 @@ ParseDependencySourcesMundane(char *star
 
 			while (!Lst_IsEmpty(&sources)) {
 GNode *gn = Lst_Dequeue(&sources);
-ParseDependencySource(targetAttr, gn->name,
+ApplyDependencySource(targetAttr, gn->name,
 special);
 			}
 			Lst_Done(&sources);
@@ -1563,7 +1563,7 @@ ParseDependencySourcesMundane(char *star
 end++;
 			}
 
-			ParseDependencySource(targetAttr, start, special);
+			ApplyDependencySource(targetAttr, start, special);
 		}
 		pp_skip_whitespace(&end);
 		start = end;
@@ -2027,7 +2027,7 @@ MaybeSubMake(const char *cmd)
  * be that.
  */
 static void
-ParseAddCmd(GNode *gn, char *cmd)
+GNode_AddCommand(GNode *gn, char *cmd)
 {
 	/* Add to last (ie current) cohort for :: targets */
 	if ((gn->type & OP_DOUBLEDEP) && gn->cohorts.last != NULL)
@@ -2284,7 +2284,7 @@ GetActuallyIncludingFile(void)
 
 /* Set .PARSEDIR, .PARSEFILE, .INCLUDEDFROMDIR and .INCLUDEDFROMFILE. */
 static void
-ParseSetParseFile(const char *filename)
+SetParseFile(const char *filename)
 {
 	const char *including;
 
@@ -2346,7 +2346,7 @@ VarContainsWord(const char *varname, con
  * of makefiles that have been loaded.
  */
 static void
-ParseTrackInput(const char *name)
+TrackInput(const char *name)
 {
 	if (!VarContainsWord(MAKE_MAKEFILES, name))
 		Global_Append(MAKE_MAKEFILES, name);
@@ -2370,7 +2370,7 @@ Parse_PushInput(const char *name, int li
 	if (fromForLoop)
 		name = CurFile()->name.str;
 	else
-		ParseTrackInput(name);
+		TrackInput(name);
 
 	DEBUG3(PARSE, "Parse_PushInput: %s %s, line %d\n",
 

CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 16:11:01 UTC 2021

Modified Files:
src/usr.bin/make: parse.c
src/usr.bin/make/unit-tests: deptgt-order.exp

Log Message:
make: make debug logging for .ORDER more human-friendly

The interesting part of the .ORDER constraint is what is made before
what, so reveal this information in the debug log.

The debug output from the test looks a bit strange since it forces
'three' to be made before 'one', but that's because the test exercises
the edge case of introducing a circular dependency.


To generate a diff of this commit:
cvs rdiff -u -r1.591 -r1.592 src/usr.bin/make/parse.c
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/deptgt-order.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/parse.c
diff -u src/usr.bin/make/parse.c:1.591 src/usr.bin/make/parse.c:1.592
--- src/usr.bin/make/parse.c:1.591	Tue Dec 28 15:48:59 2021
+++ src/usr.bin/make/parse.c	Tue Dec 28 16:11:00 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.591 2021/12/28 15:48:59 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.592 2021/12/28 16:11:00 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.591 2021/12/28 15:48:59 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.592 2021/12/28 16:11:00 rillig Exp $");
 
 /* types and constants */
 
@@ -900,8 +900,7 @@ ParseDependencySourceOrder(const char *s
 		Lst_Append(&gn->order_pred, order_pred);
 		if (DEBUG(PARSE)) {
 			debug_printf(
-			"# ParseDependencySourceOrder: "
-			"added Order dependency %s - %s\n",
+			"# .ORDER forces '%s' to be made before '%s'\n",
 			order_pred->name, gn->name);
 			Targ_PrintNode(order_pred, 0);
 			Targ_PrintNode(gn, 0);

Index: src/usr.bin/make/unit-tests/deptgt-order.exp
diff -u src/usr.bin/make/unit-tests/deptgt-order.exp:1.4 src/usr.bin/make/unit-tests/deptgt-order.exp:1.5
--- src/usr.bin/make/unit-tests/deptgt-order.exp:1.4	Tue Dec 28 15:49:00 2021
+++ src/usr.bin/make/unit-tests/deptgt-order.exp	Tue Dec 28 16:11:00 2021
@@ -1,6 +1,6 @@
 Parsing line 15: .ORDER: three one
 ParseDependency(.ORDER: three one)
-# ParseDependencySourceOrder: added Order dependency three - one
+# .ORDER forces 'three' to be made before 'one'
 # three, unmade, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS, flags none
 # one, unmade, type OP_DEPENDS|OP_PHONY, flags none
 Parsing line 16: .MAKEFLAGS: -d0



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 16:11:01 UTC 2021

Modified Files:
src/usr.bin/make: parse.c
src/usr.bin/make/unit-tests: deptgt-order.exp

Log Message:
make: make debug logging for .ORDER more human-friendly

The interesting part of the .ORDER constraint is what is made before
what, so reveal this information in the debug log.

The debug output from the test looks a bit strange since it forces
'three' to be made before 'one', but that's because the test exercises
the edge case of introducing a circular dependency.


To generate a diff of this commit:
cvs rdiff -u -r1.591 -r1.592 src/usr.bin/make/parse.c
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/deptgt-order.exp

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



CVS commit: src/sbin/sysctl

2021-12-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 28 16:06:57 UTC 2021

Modified Files:
src/sbin/sysctl: sysctl.c

Log Message:
kern.hashstat takes too long and it is meaningless here.


To generate a diff of this commit:
cvs rdiff -u -r1.162 -r1.163 src/sbin/sysctl/sysctl.c

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

Modified files:

Index: src/sbin/sysctl/sysctl.c
diff -u src/sbin/sysctl/sysctl.c:1.162 src/sbin/sysctl/sysctl.c:1.163
--- src/sbin/sysctl/sysctl.c:1.162	Sun Aug 18 00:10:22 2019
+++ src/sbin/sysctl/sysctl.c	Tue Dec 28 11:06:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysctl.c,v 1.162 2019/08/18 04:10:22 kamil Exp $ */
+/*	$NetBSD: sysctl.c,v 1.163 2021/12/28 16:06:57 christos Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1993\
 #if 0
 static char sccsid[] = "@(#)sysctl.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: sysctl.c,v 1.162 2019/08/18 04:10:22 kamil Exp $");
+__RCSID("$NetBSD: sysctl.c,v 1.163 2021/12/28 16:06:57 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -191,6 +191,7 @@ static const struct handlespec {
 	{ "/kern/boottime",			kern_boottime, NULL, NULL },
 	{ "/kern/consdev",			kern_consdev, NULL, NULL },
 	{ "/kern/cp_time(/[0-9]+)?",		kern_cp_time, NULL, NULL },
+	{ "/kern/hashstat",			printother, NULL, "vmstat -H" },
 	{ "/kern/sysvipc_info",			printother, NULL, "ipcs" },
 	{ "/kern/cp_id(/[0-9]+)?",		kern_cp_id, NULL, NULL },
 



CVS commit: src/sbin/sysctl

2021-12-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 28 16:06:57 UTC 2021

Modified Files:
src/sbin/sysctl: sysctl.c

Log Message:
kern.hashstat takes too long and it is meaningless here.


To generate a diff of this commit:
cvs rdiff -u -r1.162 -r1.163 src/sbin/sysctl/sysctl.c

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



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 15:49:00 UTC 2021

Modified Files:
src/usr.bin/make: parse.c
src/usr.bin/make/unit-tests: deptgt-order.exp deptgt.exp
directive-export-impl.exp include-main.exp suff-incomplete.exp
suff-main-several.exp suff-rebuild.exp var-eval-short.exp
varmod-indirect.exp varmod-loop.exp varname-dot-shell.exp

Log Message:
make: make debug logging a bit more human-friendly

The previous log format "ParseReadLine (%d): '%s'" focused on the
implementation, it was not immediately obvious to a casual reader that
the number in parentheses was the line number.  Additionally, having
both a colon and quotes in a log message is uncommon.  The quotes have
been added in parse.c 1.127 from 2007-01-01.

The new log format "Parsing line %d: %s" is meant to be easier readable
by humans.  The quotes are not needed since ParseReadLine always strips
trailing whitespace, leaving no room for ambiguities.  The other log
messages follow common punctuation rules, which makes the beginning of
the line equally unambiguous.  Before var.c 1.911 from 2021-04-05,
variable assignments were logged with the format "%s:%s = %s", without a
space after the colon.


To generate a diff of this commit:
cvs rdiff -u -r1.590 -r1.591 src/usr.bin/make/parse.c
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/deptgt-order.exp
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/deptgt.exp
cvs rdiff -u -r1.14 -r1.15 \
src/usr.bin/make/unit-tests/directive-export-impl.exp
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/include-main.exp \
src/usr.bin/make/unit-tests/suff-rebuild.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/suff-incomplete.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/suff-main-several.exp
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/var-eval-short.exp
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/varmod-indirect.exp
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-loop.exp
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/varname-dot-shell.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/parse.c
diff -u src/usr.bin/make/parse.c:1.590 src/usr.bin/make/parse.c:1.591
--- src/usr.bin/make/parse.c:1.590	Tue Dec 28 15:03:10 2021
+++ src/usr.bin/make/parse.c	Tue Dec 28 15:48:59 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.590 2021/12/28 15:03:10 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.591 2021/12/28 15:48:59 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.590 2021/12/28 15:03:10 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.591 2021/12/28 15:48:59 rillig Exp $");
 
 /* types and constants */
 
@@ -3180,7 +3180,7 @@ Parse_File(const char *name, int fd)
 
 	do {
 		while ((line = ParseReadLine()) != NULL) {
-			DEBUG2(PARSE, "ParseReadLine (%d): '%s'\n",
+			DEBUG2(PARSE, "Parsing line %d: %s\n",
 			CurFile()->lineno, line);
 			ParseLine(line);
 		}

Index: src/usr.bin/make/unit-tests/deptgt-order.exp
diff -u src/usr.bin/make/unit-tests/deptgt-order.exp:1.3 src/usr.bin/make/unit-tests/deptgt-order.exp:1.4
--- src/usr.bin/make/unit-tests/deptgt-order.exp:1.3	Mon Dec 13 23:38:54 2021
+++ src/usr.bin/make/unit-tests/deptgt-order.exp	Tue Dec 28 15:49:00 2021
@@ -1,9 +1,9 @@
-ParseReadLine (15): '.ORDER: three one'
+Parsing line 15: .ORDER: three one
 ParseDependency(.ORDER: three one)
 # ParseDependencySourceOrder: added Order dependency three - one
 # three, unmade, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS, flags none
 # one, unmade, type OP_DEPENDS|OP_PHONY, flags none
-ParseReadLine (16): '.MAKEFLAGS: -d0'
+Parsing line 16: .MAKEFLAGS: -d0
 ParseDependency(.MAKEFLAGS: -d0)
 : 'Making two out of one.'
 : 'Making three out of two.'

Index: src/usr.bin/make/unit-tests/deptgt.exp
diff -u src/usr.bin/make/unit-tests/deptgt.exp:1.9 src/usr.bin/make/unit-tests/deptgt.exp:1.10
--- src/usr.bin/make/unit-tests/deptgt.exp:1.9	Mon Dec 13 23:38:54 2021
+++ src/usr.bin/make/unit-tests/deptgt.exp	Tue Dec 28 15:49:00 2021
@@ -1,12 +1,12 @@
 make: "deptgt.mk" line 10: warning: Extra target ignored
 make: "deptgt.mk" line 28: Unassociated shell command ": command3		# parse error, since targets == NULL"
-ParseReadLine (34): '${:U}: empty-source'
+Parsing line 34: ${:U}: empty-source
 ParseDependency(: empty-source)
-ParseReadLine (35): '	: command for empty targets list'
-ParseReadLine (36): ': empty-source'
+Parsing line 35: 	: command for empty targets list
+Parsing line 36: : empty-source
 ParseDependency(: empty-source)
-ParseReadLine (37): '	: command for empty targets list'
-ParseReadLine (38): '.MAKEFLAGS: -d0'
+Parsing line 37: 	: command for empty targets list
+Parsing line 38: .MAKEFLAGS: -d0
 ParseDependency(.MAKEFL

CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 15:49:00 UTC 2021

Modified Files:
src/usr.bin/make: parse.c
src/usr.bin/make/unit-tests: deptgt-order.exp deptgt.exp
directive-export-impl.exp include-main.exp suff-incomplete.exp
suff-main-several.exp suff-rebuild.exp var-eval-short.exp
varmod-indirect.exp varmod-loop.exp varname-dot-shell.exp

Log Message:
make: make debug logging a bit more human-friendly

The previous log format "ParseReadLine (%d): '%s'" focused on the
implementation, it was not immediately obvious to a casual reader that
the number in parentheses was the line number.  Additionally, having
both a colon and quotes in a log message is uncommon.  The quotes have
been added in parse.c 1.127 from 2007-01-01.

The new log format "Parsing line %d: %s" is meant to be easier readable
by humans.  The quotes are not needed since ParseReadLine always strips
trailing whitespace, leaving no room for ambiguities.  The other log
messages follow common punctuation rules, which makes the beginning of
the line equally unambiguous.  Before var.c 1.911 from 2021-04-05,
variable assignments were logged with the format "%s:%s = %s", without a
space after the colon.


To generate a diff of this commit:
cvs rdiff -u -r1.590 -r1.591 src/usr.bin/make/parse.c
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/deptgt-order.exp
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/deptgt.exp
cvs rdiff -u -r1.14 -r1.15 \
src/usr.bin/make/unit-tests/directive-export-impl.exp
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/include-main.exp \
src/usr.bin/make/unit-tests/suff-rebuild.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/suff-incomplete.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/suff-main-several.exp
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/var-eval-short.exp
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/varmod-indirect.exp
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-loop.exp
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/varname-dot-shell.exp

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



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 15:03:10 UTC 2021

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

Log Message:
make: clean up variable names for parsing dependency lines

Rename 'spec' to 'special', for consistency with the previous commits.

Rename 'tOp' to 'targetAttr' since it is not an dependency operator like
':', it's an attribute like '.SILENT'.

No binary change, except for the line number of the assertion in line
1618.


To generate a diff of this commit:
cvs rdiff -u -r1.589 -r1.590 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.589 src/usr.bin/make/parse.c:1.590
--- src/usr.bin/make/parse.c:1.589	Tue Dec 28 14:06:42 2021
+++ src/usr.bin/make/parse.c	Tue Dec 28 15:03:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.589 2021/12/28 14:06:42 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.590 2021/12/28 15:03:10 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.589 2021/12/28 14:06:42 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.590 2021/12/28 15:03:10 rillig Exp $");
 
 /* types and constants */
 
@@ -264,9 +264,9 @@ SearchPath *defSysIncPath;	/* default fo
  * keyword is used as a source ("0" if the keyword isn't special as a source)
  */
 static const struct {
-	const char name[17];	/* Name of keyword */
-	ParseSpecial spec;	/* Type when used as a target */
-	GNodeType op;		/* Operator when used as a source */
+	const char name[17];
+	ParseSpecial special;	/* when used as a target */
+	GNodeType targetAttr;	/* when used as a source */
 } parseKeywords[] = {
 { ".BEGIN",		SP_BEGIN,	OP_NONE },
 { ".DEFAULT",	SP_DEFAULT,	OP_NONE },
@@ -844,7 +844,7 @@ static bool
 ParseDependencySourceKeyword(const char *src, ParseSpecial special)
 {
 	int keywd;
-	GNodeType op;
+	GNodeType targetAttr;
 
 	if (*src != '.' || !ch_isupper(src[1]))
 		return false;
@@ -853,12 +853,12 @@ ParseDependencySourceKeyword(const char 
 	if (keywd == -1)
 		return false;
 
-	op = parseKeywords[keywd].op;
-	if (op != OP_NONE) {
-		ApplyDependencyOperator(op);
+	targetAttr = parseKeywords[keywd].targetAttr;
+	if (targetAttr != OP_NONE) {
+		ApplyDependencyOperator(targetAttr);
 		return true;
 	}
-	if (parseKeywords[keywd].spec == SP_WAIT) {
+	if (parseKeywords[keywd].special == SP_WAIT) {
 		ParseDependencySourceWait(special != SP_NOT);
 		return true;
 	}
@@ -914,7 +914,7 @@ ParseDependencySourceOrder(const char *s
 }
 
 static void
-ParseDependencySourceOther(const char *src, GNodeType tOp,
+ParseDependencySourceOther(const char *src, GNodeType targetAttr,
 			   ParseSpecial special)
 {
 	GNode *gn;
@@ -934,25 +934,22 @@ ParseDependencySourceOther(const char *s
 	gn = Targ_GetNode(src);
 	if (doing_depend)
 		RememberLocation(gn);
-	if (tOp != OP_NONE)
-		gn->type |= tOp;
+	if (targetAttr != OP_NONE)
+		gn->type |= targetAttr;
 	else
 		LinkToTargets(gn, special != SP_NOT);
 }
 
 /*
  * Given the name of a source in a dependency line, figure out if it is an
- * attribute (such as .SILENT) and apply it to the targets if it is. Else
+ * attribute (such as .SILENT) and if so, apply it to all targets. Otherwise
  * decide if there is some attribute which should be applied *to* the source
  * because of some special target (such as .PHONY) and apply it if so.
- * Otherwise, make the source a child of the targets in the list 'targets'.
- *
- * Input:
- *	tOp		operator (if any) from special targets
- *	src		name of the source to handle
+ * Otherwise, make the source a child of the targets.
  */
 static void
-ParseDependencySource(GNodeType tOp, const char *src, ParseSpecial special)
+ParseDependencySource(GNodeType targetAttr, const char *src,
+		  ParseSpecial special)
 {
 	if (ParseDependencySourceKeyword(src, special))
 		return;
@@ -962,7 +959,7 @@ ParseDependencySource(GNodeType tOp, con
 	else if (special == SP_ORDER)
 		ParseDependencySourceOrder(src);
 	else
-		ParseDependencySourceOther(src, tOp, special);
+		ParseDependencySourceOther(src, targetAttr, special);
 }
 
 /*
@@ -1150,7 +1147,8 @@ ParseDependencyTargetPath(const char *su
 static bool
 ParseDependencyTarget(const char *targetName,
 		  ParseSpecial *inout_special,
-		  GNodeType *out_tOp, SearchPathList **inout_paths)
+		  GNodeType *inout_targetAttr,
+		  SearchPathList **inout_paths)
 {
 	int keywd;
 
@@ -1164,13 +1162,13 @@ ParseDependencyTarget(const char *target
 	keywd = ParseFindKeyword(targetName);
 	if (keywd != -1) {
 		if (*inout_special == SP_PATH &&
-		parseKeywords[keywd].spec != SP_PATH) {
+		parseKeywords[keywd].special != SP_PATH) {
 			Parse_Error(PARSE_FATAL, "Mismatched special targets");
 			return false;
 		}
 
-		*inout_special = parseKeywords[keywd].spec;
-		

CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 15:03:10 UTC 2021

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

Log Message:
make: clean up variable names for parsing dependency lines

Rename 'spec' to 'special', for consistency with the previous commits.

Rename 'tOp' to 'targetAttr' since it is not an dependency operator like
':', it's an attribute like '.SILENT'.

No binary change, except for the line number of the assertion in line
1618.


To generate a diff of this commit:
cvs rdiff -u -r1.589 -r1.590 src/usr.bin/make/parse.c

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



CVS commit: src/external/gpl2/grep/dist/src

2021-12-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 28 14:59:02 UTC 2021

Modified Files:
src/external/gpl2/grep/dist/src: grep.c

Log Message:
PR/56584: Andreas Gustafsson: Skip FIFO's when -D


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/gpl2/grep/dist/src/grep.c

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

Modified files:

Index: src/external/gpl2/grep/dist/src/grep.c
diff -u src/external/gpl2/grep/dist/src/grep.c:1.2 src/external/gpl2/grep/dist/src/grep.c:1.3
--- src/external/gpl2/grep/dist/src/grep.c:1.2	Sun Jan 10 17:16:40 2016
+++ src/external/gpl2/grep/dist/src/grep.c	Tue Dec 28 09:59:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: grep.c,v 1.2 2016/01/10 22:16:40 christos Exp $	*/
+/*	$NetBSD: grep.c,v 1.3 2021/12/28 14:59:02 christos Exp $	*/
 
 /* grep.c - main driver file for grep.
Copyright 1992, 1997-1999, 2000 Free Software Foundation, Inc.
@@ -271,11 +271,15 @@ reset (int fd, char const *file, struct 
 }
   if (directories == SKIP_DIRECTORIES && S_ISDIR (stats->stat.st_mode))
 return 0;
-#ifndef DJGPP
-  if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode) || S_ISSOCK(stats->stat.st_mode)))
-#else
-  if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode)))
+  if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode)
+  || S_ISBLK(stats->stat.st_mode)
+#ifdef S_ISSOCK
+  || S_ISSOCK(stats->stat.st_mode)
+#endif
+#ifdef S_ISFIFO
+  || S_ISFIFO(stats->stat.st_mode)
 #endif
+  ))
 return 0;
   if (S_ISREG (stats->stat.st_mode))
 {



CVS commit: src/external/gpl2/grep/dist/src

2021-12-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 28 14:59:02 UTC 2021

Modified Files:
src/external/gpl2/grep/dist/src: grep.c

Log Message:
PR/56584: Andreas Gustafsson: Skip FIFO's when -D


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/external/gpl2/grep/dist/src/grep.c

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



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 14:22:51 UTC 2021

Modified Files:
src/usr.bin/make: make.h
src/usr.bin/make/unit-tests: depsrc-use.mk depsrc-usebefore.mk

Log Message:
make: do not treat .USEBEFORE as candidate for the main target

A .USE target is not a candidate, so .USEBEFORE shouldn't either.

Since make.h 1.36 from 2001-07-03.  In that commit, OP_USEBEFORE should
have been added to OP_NOTARGET.


To generate a diff of this commit:
cvs rdiff -u -r1.280 -r1.281 src/usr.bin/make/make.h
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/depsrc-use.mk
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/depsrc-usebefore.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/make.h
diff -u src/usr.bin/make/make.h:1.280 src/usr.bin/make/make.h:1.281
--- src/usr.bin/make/make.h:1.280	Tue Dec 28 14:06:42 2021
+++ src/usr.bin/make/make.h	Tue Dec 28 14:22:51 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.280 2021/12/28 14:06:42 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.281 2021/12/28 14:22:51 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -816,9 +816,8 @@ GNode_IsError(const GNode *gn)
 MAKE_INLINE bool MAKE_ATTR_USE
 GNode_IsMainCandidate(const GNode *gn)
 {
-	/* XXX: What about OP_USEBEFORE? */
-	return (gn->type & (OP_NOTMAIN | OP_USE | OP_EXEC | OP_TRANSFORM)) ==
-	   0;
+	return (gn->type & (OP_NOTMAIN | OP_USE | OP_USEBEFORE |
+			OP_EXEC | OP_TRANSFORM)) == 0;
 }
 
 MAKE_INLINE const char * MAKE_ATTR_USE

Index: src/usr.bin/make/unit-tests/depsrc-use.mk
diff -u src/usr.bin/make/unit-tests/depsrc-use.mk:1.4 src/usr.bin/make/unit-tests/depsrc-use.mk:1.5
--- src/usr.bin/make/unit-tests/depsrc-use.mk:1.4	Sat Aug 22 12:30:57 2020
+++ src/usr.bin/make/unit-tests/depsrc-use.mk	Tue Dec 28 14:22:51 2021
@@ -1,8 +1,13 @@
-# $NetBSD: depsrc-use.mk,v 1.4 2020/08/22 12:30:57 rillig Exp $
+# $NetBSD: depsrc-use.mk,v 1.5 2021/12/28 14:22:51 rillig Exp $
 #
 # Tests for the special source .USE in dependency declarations,
 # which allows to append common commands to other targets.
 
+# Before make.h 1.280 from 2021-12-28, a .USEBEFORE target was accidentally
+# regarded as a candidate for the main target.  On the other hand, a .USE
+# target was not.
+not-a-main-candidate: .USE
+
 all: action directly
 
 first: .USE

Index: src/usr.bin/make/unit-tests/depsrc-usebefore.mk
diff -u src/usr.bin/make/unit-tests/depsrc-usebefore.mk:1.6 src/usr.bin/make/unit-tests/depsrc-usebefore.mk:1.7
--- src/usr.bin/make/unit-tests/depsrc-usebefore.mk:1.6	Sun Nov 15 20:20:58 2020
+++ src/usr.bin/make/unit-tests/depsrc-usebefore.mk	Tue Dec 28 14:22:51 2021
@@ -1,4 +1,4 @@
-# $NetBSD: depsrc-usebefore.mk,v 1.6 2020/11/15 20:20:58 rillig Exp $
+# $NetBSD: depsrc-usebefore.mk,v 1.7 2021/12/28 14:22:51 rillig Exp $
 #
 # Tests for the special source .USEBEFORE in dependency declarations,
 # which allows to prepend common commands to other targets.
@@ -7,6 +7,11 @@
 #	.USE
 #	depsrc-use.mk
 
+# Before make.h 1.280 from 2021-12-28, a .USEBEFORE target was accidentally
+# regarded as a candidate for the main target.  On the other hand, a .USE
+# target was not.
+not-a-main-candidate: .USEBEFORE
+
 all: action directly
 
 first: .USEBEFORE



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 14:22:51 UTC 2021

Modified Files:
src/usr.bin/make: make.h
src/usr.bin/make/unit-tests: depsrc-use.mk depsrc-usebefore.mk

Log Message:
make: do not treat .USEBEFORE as candidate for the main target

A .USE target is not a candidate, so .USEBEFORE shouldn't either.

Since make.h 1.36 from 2001-07-03.  In that commit, OP_USEBEFORE should
have been added to OP_NOTARGET.


To generate a diff of this commit:
cvs rdiff -u -r1.280 -r1.281 src/usr.bin/make/make.h
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/depsrc-use.mk
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/depsrc-usebefore.mk

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



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 14:06:43 UTC 2021

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

Log Message:
make: extract OP_NOTARGET into separate function

No binary change, except for line numbers in assertions.


To generate a diff of this commit:
cvs rdiff -u -r1.279 -r1.280 src/usr.bin/make/make.h
cvs rdiff -u -r1.588 -r1.589 src/usr.bin/make/parse.c
cvs rdiff -u -r1.360 -r1.361 src/usr.bin/make/suff.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/make.h
diff -u src/usr.bin/make/make.h:1.279 src/usr.bin/make/make.h:1.280
--- src/usr.bin/make/make.h:1.279	Mon Dec 27 18:26:22 2021
+++ src/usr.bin/make/make.h	Tue Dec 28 14:06:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.279 2021/12/27 18:26:22 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.280 2021/12/28 14:06:42 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -360,8 +360,6 @@ typedef enum GNodeType {
 	OP_DEPS_FOUND	= 1 << 24,
 	/* Node found while expanding .ALLSRC */
 	OP_MARK		= 1 << 23,
-
-	OP_NOTARGET	= OP_NOTMAIN | OP_USE | OP_EXEC | OP_TRANSFORM
 } GNodeType;
 
 typedef struct GNodeFlags {
@@ -815,6 +813,14 @@ GNode_IsError(const GNode *gn)
 	return gn->made == ERROR || gn->made == ABORTED;
 }
 
+MAKE_INLINE bool MAKE_ATTR_USE
+GNode_IsMainCandidate(const GNode *gn)
+{
+	/* XXX: What about OP_USEBEFORE? */
+	return (gn->type & (OP_NOTMAIN | OP_USE | OP_EXEC | OP_TRANSFORM)) ==
+	   0;
+}
+
 MAKE_INLINE const char * MAKE_ATTR_USE
 GNode_VarTarget(GNode *gn) { return GNode_ValueDirect(gn, TARGET); }
 MAKE_INLINE const char * MAKE_ATTR_USE

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.588 src/usr.bin/make/parse.c:1.589
--- src/usr.bin/make/parse.c:1.588	Tue Dec 28 01:27:37 2021
+++ src/usr.bin/make/parse.c	Tue Dec 28 14:06:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.588 2021/12/28 01:27:37 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.589 2021/12/28 14:06:42 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.588 2021/12/28 01:27:37 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.589 2021/12/28 14:06:42 rillig Exp $");
 
 /* types and constants */
 
@@ -154,8 +154,7 @@ typedef enum ParseSpecial {
 	SP_INCLUDES,	/* .INCLUDES; not mentioned in the manual page */
 	SP_INTERRUPT,	/* .INTERRUPT */
 	SP_LIBS,	/* .LIBS; not mentioned in the manual page */
-	/* .MAIN and we don't have anything user-specified to make */
-	SP_MAIN,
+	SP_MAIN,	/* .MAIN and no user-specified targets to make */
 	SP_META,	/* .META */
 	SP_MFLAGS,	/* .MFLAGS or .MAKEFLAGS */
 	SP_NOMETA,	/* .NOMETA */
@@ -187,8 +186,8 @@ typedef ListNode SearchPathListNode;
 /* result data */
 
 /*
- * The main target to create. This is the first target on the first
- * dependency line in the first makefile.
+ * The main target to create. This is the first target defined in any of the
+ * makefiles.
  */
 static GNode *mainNode;
 
@@ -981,7 +980,7 @@ FindMainTarget(void)
 
 	for (ln = targets->first; ln != NULL; ln = ln->next) {
 		GNode *gn = ln->datum;
-		if (!(gn->type & OP_NOTARGET)) {
+		if (GNode_IsMainCandidate(gn)) {
 			DEBUG1(MAKE, "Setting main node to \"%s\"\n", gn->name);
 			mainNode = gn;
 			Targ_SetMain(gn);

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.360 src/usr.bin/make/suff.c:1.361
--- src/usr.bin/make/suff.c:1.360	Wed Dec 15 12:58:01 2021
+++ src/usr.bin/make/suff.c	Tue Dec 28 14:06:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.360 2021/12/15 12:58:01 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.361 2021/12/28 14:06:42 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -115,7 +115,7 @@
 #include "dir.h"
 
 /*	"@(#)suff.c	8.4 (Berkeley) 3/21/94"	*/
-MAKE_RCSID("$NetBSD: suff.c,v 1.360 2021/12/15 12:58:01 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.361 2021/12/28 14:06:42 rillig Exp $");
 
 typedef List SuffixList;
 typedef ListNode SuffixListNode;
@@ -741,7 +741,7 @@ UpdateTarget(GNode *target, GNode **inou
 	char *ptr;
 
 	if (*inout_main == NULL && *inout_removedMain &&
-	!(target->type & OP_NOTARGET)) {
+	GNode_IsMainCandidate(target)) {
 		DEBUG1(MAKE, "Setting main node to \"%s\"\n", target->name);
 		*inout_main = target;
 		Targ_SetMain(target);



CVS commit: src/usr.bin/make

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 14:06:43 UTC 2021

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

Log Message:
make: extract OP_NOTARGET into separate function

No binary change, except for line numbers in assertions.


To generate a diff of this commit:
cvs rdiff -u -r1.279 -r1.280 src/usr.bin/make/make.h
cvs rdiff -u -r1.588 -r1.589 src/usr.bin/make/parse.c
cvs rdiff -u -r1.360 -r1.361 src/usr.bin/make/suff.c

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



CVS commit: src/sys/dev/acpi

2021-12-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec 28 13:41:12 UTC 2021

Modified Files:
src/sys/dev/acpi: sdhc_acpi.c

Log Message:
acpi: sdhc: Ignore clkbase register if clock-frequency property is present


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/acpi/sdhc_acpi.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/acpi/sdhc_acpi.c
diff -u src/sys/dev/acpi/sdhc_acpi.c:1.14 src/sys/dev/acpi/sdhc_acpi.c:1.15
--- src/sys/dev/acpi/sdhc_acpi.c:1.14	Sat Feb  1 20:11:24 2020
+++ src/sys/dev/acpi/sdhc_acpi.c	Tue Dec 28 13:41:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdhc_acpi.c,v 1.14 2020/02/01 20:11:24 tnn Exp $	*/
+/*	$NetBSD: sdhc_acpi.c,v 1.15 2021/12/28 13:41:12 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdhc_acpi.c,v 1.14 2020/02/01 20:11:24 tnn Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdhc_acpi.c,v 1.15 2021/12/28 13:41:12 jmcneill Exp $");
 
 #include 
 #include 
@@ -211,8 +211,10 @@ sdhc_acpi_attach(device_t parent, device
 	/* Read clock frequency from device properties */
 	rv = acpi_dsd_integer(aa->aa_node->ad_handle, "clock-frequency",
 	&clock_freq);
-	if (ACPI_SUCCESS(rv))
+	if (ACPI_SUCCESS(rv)) {
 		sc->sc.sc_clkbase = clock_freq / 1000;
+		sc->sc.sc_flags |= SDHC_FLAG_NO_CLKBASE;
+	}
 
 	if (sdhc_host_found(&sc->sc, sc->sc_memt, sc->sc_memh,
 	sc->sc_memsize) != 0) {



CVS commit: src/sys/dev/acpi

2021-12-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec 28 13:41:12 UTC 2021

Modified Files:
src/sys/dev/acpi: sdhc_acpi.c

Log Message:
acpi: sdhc: Ignore clkbase register if clock-frequency property is present


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/acpi/sdhc_acpi.c

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



CVS commit: src/sys/kern

2021-12-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Dec 28 13:28:24 UTC 2021

Modified Files:
src/sys/kern: kern_uidinfo.c

Log Message:
kern: Show relevant variables for uidinfo counts in kasserts.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/kern/kern_uidinfo.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/kern/kern_uidinfo.c
diff -u src/sys/kern/kern_uidinfo.c:1.12 src/sys/kern/kern_uidinfo.c:1.13
--- src/sys/kern/kern_uidinfo.c:1.12	Thu Apr  1 06:25:45 2021
+++ src/sys/kern/kern_uidinfo.c	Tue Dec 28 13:28:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_uidinfo.c,v 1.12 2021/04/01 06:25:45 simonb Exp $	*/
+/*	$NetBSD: kern_uidinfo.c,v 1.13 2021/12/28 13:28:24 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1991, 1993
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_uidinfo.c,v 1.12 2021/04/01 06:25:45 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_uidinfo.c,v 1.13 2021/12/28 13:28:24 riastradh Exp $");
 
 #include 
 #include 
@@ -238,7 +238,8 @@ chgproccnt(uid_t uid, int diff)
 
 	uip = uid_find(uid);
 	proccnt = atomic_add_long_nv(&uip->ui_proccnt, diff);
-	KASSERT(proccnt >= 0);
+	KASSERTMSG(proccnt >= 0, "uid=%d diff=%d proccnt=%ld",
+	uid, diff, proccnt);
 	return proccnt;
 }
 
@@ -254,7 +255,8 @@ chglwpcnt(uid_t uid, int diff)
 
 	uip = uid_find(uid);
 	lwpcnt = atomic_add_long_nv(&uip->ui_lwpcnt, diff);
-	KASSERT(lwpcnt >= 0);
+	KASSERTMSG(lwpcnt >= 0, "uid=%d diff=%d lwpcnt=%ld",
+	uid, diff, lwpcnt);
 	return lwpcnt;
 }
 
@@ -270,7 +272,8 @@ chgsemcnt(uid_t uid, int diff)
 
 	uip = uid_find(uid);
 	semcnt = atomic_add_long_nv(&uip->ui_semcnt, diff);
-	KASSERT(semcnt >= 0);
+	KASSERTMSG(semcnt >= 0, "uid=%d diff=%d semcnt=%ld",
+	uid, diff, semcnt);
 	return semcnt;
 }
 



CVS commit: src/sys/kern

2021-12-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Dec 28 13:28:24 UTC 2021

Modified Files:
src/sys/kern: kern_uidinfo.c

Log Message:
kern: Show relevant variables for uidinfo counts in kasserts.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/kern/kern_uidinfo.c

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



CVS commit: src/sys/dev/ata

2021-12-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Dec 28 13:27:32 UTC 2021

Modified Files:
src/sys/dev/ata: wd.c wdvar.h

Log Message:
wd(4): Fix bugs in softbadsect handling.

- Don't copyout kernel virtual addresses (of SLIST entries) that
  userland won't use anyway.
  => The structure still has space for this pointer; it's just always
 null when userland gets it now.

- Don't copyout under a lock.

- Stop and return error if copyout fails (unless we've already copied
  some out).

- Don't kmem_free under a lock.

XXX Unclear whether anyone actually uses WD_SOFTBADSECT or why --
it's always been disabled by default.  Maybe we should just remove
it?


To generate a diff of this commit:
cvs rdiff -u -r1.465 -r1.466 src/sys/dev/ata/wd.c
cvs rdiff -u -r1.50 -r1.51 src/sys/dev/ata/wdvar.h

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



CVS commit: src/sys/dev/ata

2021-12-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Dec 28 13:27:32 UTC 2021

Modified Files:
src/sys/dev/ata: wd.c wdvar.h

Log Message:
wd(4): Fix bugs in softbadsect handling.

- Don't copyout kernel virtual addresses (of SLIST entries) that
  userland won't use anyway.
  => The structure still has space for this pointer; it's just always
 null when userland gets it now.

- Don't copyout under a lock.

- Stop and return error if copyout fails (unless we've already copied
  some out).

- Don't kmem_free under a lock.

XXX Unclear whether anyone actually uses WD_SOFTBADSECT or why --
it's always been disabled by default.  Maybe we should just remove
it?


To generate a diff of this commit:
cvs rdiff -u -r1.465 -r1.466 src/sys/dev/ata/wd.c
cvs rdiff -u -r1.50 -r1.51 src/sys/dev/ata/wdvar.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/dev/ata/wd.c
diff -u src/sys/dev/ata/wd.c:1.465 src/sys/dev/ata/wd.c:1.466
--- src/sys/dev/ata/wd.c:1.465	Mon Sep 28 12:47:49 2020
+++ src/sys/dev/ata/wd.c	Tue Dec 28 13:27:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: wd.c,v 1.465 2020/09/28 12:47:49 jakllsch Exp $ */
+/*	$NetBSD: wd.c,v 1.466 2021/12/28 13:27:32 riastradh Exp $ */
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.  All rights reserved.
@@ -54,7 +54,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.465 2020/09/28 12:47:49 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wd.c,v 1.466 2021/12/28 13:27:32 riastradh Exp $");
 
 #include "opt_ata.h"
 #include "opt_wd.h"
@@ -316,6 +316,7 @@ wdattach(device_t parent, device_t self,
 	mutex_init(&wd->sc_lock, MUTEX_DEFAULT, IPL_BIO);
 #ifdef WD_SOFTBADSECT
 	SLIST_INIT(&wd->sc_bslist);
+	cv_init(&wd->sc_bslist_cv, "wdbadsect");
 #endif
 	wd->atabus = adev->adev_bustype;
 	wd->inflight = 0;
@@ -587,6 +588,11 @@ wddetach(device_t self, int flags)
 
 	wd_sysctl_detach(wd);
 
+#ifdef WD_SOFTBADSECT
+	KASSERT(SLIST_EMPTY(&wd->sc_bslist));
+	cv_destroy(&wd->sc_bslist_cv);
+#endif
+
 	mutex_destroy(&wd->sc_lock);
 
 	wd->drvp->drive_type = ATA_DRIVET_NONE; /* no drive any more here */
@@ -1279,13 +1285,13 @@ wdioctl(dev_t dev, u_long cmd, void *add
 		return 0;
 #endif
 #ifdef WD_SOFTBADSECT
-	case DIOCBSLIST :
-	{
+	case DIOCBSLIST: {
 		uint32_t count, missing, skip;
 		struct disk_badsecinfo dbsi;
-		struct disk_badsectors *dbs;
+		struct disk_badsectors *dbs, dbsbuf;
 		size_t available;
 		uint8_t *laddr;
+		int error;
 
 		dbsi = *(struct disk_badsecinfo *)addr;
 		missing = wd->sc_bscount;
@@ -1303,7 +1309,9 @@ wdioctl(dev_t dev, u_long cmd, void *add
 		 * back to user space whilst the summary is returned via
 		 * the struct passed in via the ioctl.
 		 */
+		error = 0;
 		mutex_enter(&wd->sc_lock);
+		wd->sc_bslist_inuse++;
 		SLIST_FOREACH(dbs, &wd->sc_bslist, dbs_next) {
 			if (skip > 0) {
 missing--;
@@ -1313,30 +1321,57 @@ wdioctl(dev_t dev, u_long cmd, void *add
 			if (available < sizeof(*dbs))
 break;
 			available -= sizeof(*dbs);
-			copyout(dbs, laddr, sizeof(*dbs));
+			memset(&dbsbuf, 0, sizeof(dbsbuf));
+			dbsbuf.dbs_min = dbs->dbs_min;
+			dbsbuf.dbs_max = dbs->dbs_max;
+			dbsbuf.dbs_failedat = dbs->dbs_failedat;
+			mutex_exit(&wd->sc_lock);
+			error = copyout(&dbsbuf, laddr, sizeof(dbsbuf));
+			mutex_enter(&wd->sc_lock);
+			if (error)
+break;
 			laddr += sizeof(*dbs);
 			missing--;
 			count++;
 		}
+		if (--wd->sc_bslist_inuse == 0)
+			cv_broadcast(&wd->sc_bslist_cv);
 		mutex_exit(&wd->sc_lock);
 		dbsi.dbsi_left = missing;
 		dbsi.dbsi_copied = count;
 		*(struct disk_badsecinfo *)addr = dbsi;
-		return 0;
+
+		/*
+		 * If we copied anything out, ignore error and return
+		 * success -- can't back it out.
+		 */
+		return count ? 0 : error;
 	}
 
-	case DIOCBSFLUSH :
+	case DIOCBSFLUSH: {
+		int error;
+
 		/* Clean out the bad sector list */
 		mutex_enter(&wd->sc_lock);
+		while (wd->sc_bslist_inuse) {
+			error = cv_wait_sig(&wd->sc_bslist_cv, &wd->sc_lock);
+			if (error) {
+mutex_exit(&wd->sc_lock);
+return error;
+			}
+		}
 		while (!SLIST_EMPTY(&wd->sc_bslist)) {
 			struct disk_badsectors *dbs =
 			SLIST_FIRST(&wd->sc_bslist);
 			SLIST_REMOVE_HEAD(&wd->sc_bslist, dbs_next);
+			mutex_exit(&wd->sc_lock);
 			kmem_free(dbs, sizeof(*dbs));
+			mutex_enter(&wd->sc_lock);
 		}
 		mutex_exit(&wd->sc_lock);
 		wd->sc_bscount = 0;
 		return 0;
+	}
 #endif
 
 #ifdef notyet

Index: src/sys/dev/ata/wdvar.h
diff -u src/sys/dev/ata/wdvar.h:1.50 src/sys/dev/ata/wdvar.h:1.51
--- src/sys/dev/ata/wdvar.h:1.50	Mon Mar  2 16:01:56 2020
+++ src/sys/dev/ata/wdvar.h	Tue Dec 28 13:27:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: wdvar.h,v 1.50 2020/03/02 16:01:56 riastradh Exp $	*/
+/*	$NetBSD: wdvar.h,v 1.51 2021/12/28 13:27:32 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.
@@ -31,8 +31,20 @@
 #include "opt_wd.h"
 #endif
 
-#include 
+#include 
+
+#include 
+#include 
+#include 
+#include

CVS commit: src/sys

2021-12-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Dec 28 13:22:43 UTC 2021

Modified Files:
src/sys/arch/mips/cavium/dev: octeon_rnm.c
src/sys/dev: random.c
src/sys/kern: sys_getrandom.c

Log Message:
sys: Use preempt_point and preempt_needed, not open-coded versions.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/mips/cavium/dev/octeon_rnm.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/random.c
cvs rdiff -u -r1.1 -r1.2 src/sys/kern/sys_getrandom.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/mips/cavium/dev/octeon_rnm.c
diff -u src/sys/arch/mips/cavium/dev/octeon_rnm.c:1.12 src/sys/arch/mips/cavium/dev/octeon_rnm.c:1.13
--- src/sys/arch/mips/cavium/dev/octeon_rnm.c:1.12	Thu Jun 18 13:52:08 2020
+++ src/sys/arch/mips/cavium/dev/octeon_rnm.c	Tue Dec 28 13:22:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: octeon_rnm.c,v 1.12 2020/06/18 13:52:08 simonb Exp $	*/
+/*	$NetBSD: octeon_rnm.c,v 1.13 2021/12/28 13:22:43 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2007 Internet Initiative Japan, Inc.
@@ -99,7 +99,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: octeon_rnm.c,v 1.12 2020/06/18 13:52:08 simonb Exp $");
+__KERNEL_RCSID(0, "$NetBSD: octeon_rnm.c,v 1.13 2021/12/28 13:22:43 riastradh Exp $");
 
 #include 
 #include 
@@ -262,9 +262,8 @@ octrnm_rng(size_t nbytes, void *vsc)
 		sizeof sc->sc_sample, NBBY*sizeof(sc->sc_sample)/BPB);
 		needed -= MIN(needed, MAX(1, NBBY*sizeof(sc->sc_sample)/BPB));
 
-		/* Yield if requested.  */
-		if (__predict_false(curcpu()->ci_schedstate.spc_flags &
-			SPCF_SHOULDYIELD)) {
+		/* Now's a good time to yield if need.  */
+		if (__predict_false(preempt_needed())) {
 			mutex_exit(&sc->sc_lock);
 			preempt();
 			mutex_enter(&sc->sc_lock);

Index: src/sys/dev/random.c
diff -u src/sys/dev/random.c:1.9 src/sys/dev/random.c:1.10
--- src/sys/dev/random.c:1.9	Wed Jan 13 23:54:21 2021
+++ src/sys/dev/random.c	Tue Dec 28 13:22:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: random.c,v 1.9 2021/01/13 23:54:21 riastradh Exp $	*/
+/*	$NetBSD: random.c,v 1.10 2021/12/28 13:22:43 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: random.c,v 1.9 2021/01/13 23:54:21 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: random.c,v 1.10 2021/12/28 13:22:43 riastradh Exp $");
 
 #include 
 #include 
@@ -282,9 +282,8 @@ random_write(dev_t dev, struct uio *uio,
 		rnd_add_data(&user_rndsource, buf, n, privileged ? n*NBBY : 0);
 		any = true;
 
-		/* Yield if requested.  */
-		if (curcpu()->ci_schedstate.spc_flags & SPCF_SHOULDYIELD)
-			preempt();
+		/* Now's a good time to yield if needed.  */
+		preempt_point();
 
 		/* Check for interruption.  */
 		if (__predict_false(curlwp->l_flag & LW_PENDSIG) &&

Index: src/sys/kern/sys_getrandom.c
diff -u src/sys/kern/sys_getrandom.c:1.1 src/sys/kern/sys_getrandom.c:1.2
--- src/sys/kern/sys_getrandom.c:1.1	Fri Aug 14 00:53:16 2020
+++ src/sys/kern/sys_getrandom.c	Tue Dec 28 13:22:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_getrandom.c,v 1.1 2020/08/14 00:53:16 riastradh Exp $	*/
+/*	$NetBSD: sys_getrandom.c,v 1.2 2021/12/28 13:22:43 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_getrandom.c,v 1.1 2020/08/14 00:53:16 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_getrandom.c,v 1.2 2021/12/28 13:22:43 riastradh Exp $");
 
 #include 
 #include 
@@ -174,9 +174,8 @@ dogetrandom(struct uio *uio, unsigned in
 			break;
 		}
 
-		/* Yield if requested.  */
-		if (curcpu()->ci_schedstate.spc_flags & SPCF_SHOULDYIELD)
-			preempt();
+		/* Now's a good time to yield if needed.  */
+		preempt_point();
 
 		/* Check for interruption after at least 256 bytes.  */
 		CTASSERT(RANDOM_BUFSIZE >= 256);



CVS commit: src/sys

2021-12-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Dec 28 13:22:43 UTC 2021

Modified Files:
src/sys/arch/mips/cavium/dev: octeon_rnm.c
src/sys/dev: random.c
src/sys/kern: sys_getrandom.c

Log Message:
sys: Use preempt_point and preempt_needed, not open-coded versions.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/mips/cavium/dev/octeon_rnm.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/random.c
cvs rdiff -u -r1.1 -r1.2 src/sys/kern/sys_getrandom.c

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



CVS commit: src/sys/dev/mii

2021-12-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Dec 28 12:00:48 UTC 2021

Modified Files:
src/sys/dev/mii: mii_physubr.c

Log Message:
mii(9): Fix callout race between mii_phy_down and mii_phy_detach.


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/sys/dev/mii/mii_physubr.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/mii/mii_physubr.c
diff -u src/sys/dev/mii/mii_physubr.c:1.96 src/sys/dev/mii/mii_physubr.c:1.97
--- src/sys/dev/mii/mii_physubr.c:1.96	Wed Dec 15 08:28:22 2021
+++ src/sys/dev/mii/mii_physubr.c	Tue Dec 28 12:00:48 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mii_physubr.c,v 1.96 2021/12/15 08:28:22 msaitoh Exp $	*/
+/*	$NetBSD: mii_physubr.c,v 1.97 2021/12/28 12:00:48 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mii_physubr.c,v 1.96 2021/12/15 08:28:22 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mii_physubr.c,v 1.97 2021/12/28 12:00:48 riastradh Exp $");
 
 #include 
 #include 
@@ -429,8 +429,20 @@ mii_phy_down(struct mii_softc *sc)
 	KASSERT(mii_locked(sc->mii_pdata));
 
 	if (sc->mii_flags & MIIF_DOINGAUTO) {
-		sc->mii_flags &= ~MIIF_DOINGAUTO;
-		callout_stop(&sc->mii_nway_ch);
+		/*
+		 * Try to stop it.
+		 *
+		 * - If we stopped it before it expired, callout_stop
+		 *   returns 0, and it is our responsibility to clear
+		 *   MIIF_DOINGAUTO.
+		 *
+		 * - Otherwise, we're too late -- the callout has
+		 *   already begun, and we must leave MIIF_DOINGAUTO
+		 *   set so mii_phy_detach will wait for it to
+		 *   complete.
+		 */
+		if (!callout_stop(&sc->mii_nway_ch))
+			sc->mii_flags &= ~MIIF_DOINGAUTO;
 	}
 }
 



CVS commit: src/sys/dev/mii

2021-12-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Dec 28 12:00:48 UTC 2021

Modified Files:
src/sys/dev/mii: mii_physubr.c

Log Message:
mii(9): Fix callout race between mii_phy_down and mii_phy_detach.


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 src/sys/dev/mii/mii_physubr.c

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



CVS commit: xsrc/external/mit/xinit/dist

2021-12-28 Thread Nia Alarie
Module Name:xsrc
Committed By:   nia
Date:   Tue Dec 28 11:48:52 UTC 2021

Modified Files:
xsrc/external/mit/xinit/dist: xinitrc.cpp

Log Message:
COLOR is not a C preprocessor macro :|


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 xsrc/external/mit/xinit/dist/xinitrc.cpp

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

Modified files:

Index: xsrc/external/mit/xinit/dist/xinitrc.cpp
diff -u xsrc/external/mit/xinit/dist/xinitrc.cpp:1.11 xsrc/external/mit/xinit/dist/xinitrc.cpp:1.12
--- xsrc/external/mit/xinit/dist/xinitrc.cpp:1.11	Sat Dec 25 11:37:25 2021
+++ xsrc/external/mit/xinit/dist/xinitrc.cpp	Tue Dec 28 11:48:52 2021
@@ -40,9 +40,7 @@ if [ -f "$userresources" ]; then
 #endif
 else
 XRDB -merge - <

CVS commit: xsrc/external/mit/xinit/dist

2021-12-28 Thread Nia Alarie
Module Name:xsrc
Committed By:   nia
Date:   Tue Dec 28 11:48:52 UTC 2021

Modified Files:
xsrc/external/mit/xinit/dist: xinitrc.cpp

Log Message:
COLOR is not a C preprocessor macro :|


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 xsrc/external/mit/xinit/dist/xinitrc.cpp

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



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

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 10:47:00 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: var-op-expand.mk varmod-assign-shell.mk
varquote.mk

Log Message:
tests/make: use tabs instead of spaces for indentation


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/var-op-expand.mk
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varmod-assign-shell.mk
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varquote.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-op-expand.mk
diff -u src/usr.bin/make/unit-tests/var-op-expand.mk:1.15 src/usr.bin/make/unit-tests/var-op-expand.mk:1.16
--- src/usr.bin/make/unit-tests/var-op-expand.mk:1.15	Tue Nov 30 23:52:19 2021
+++ src/usr.bin/make/unit-tests/var-op-expand.mk	Tue Dec 28 10:47:00 2021
@@ -1,4 +1,4 @@
-# $NetBSD: var-op-expand.mk,v 1.15 2021/11/30 23:52:19 rillig Exp $
+# $NetBSD: var-op-expand.mk,v 1.16 2021/12/28 10:47:00 rillig Exp $
 #
 # Tests for the := variable assignment operator, which expands its
 # right-hand side.
@@ -9,7 +9,7 @@
 # Force the test results to be independent of the default value of this
 # setting, which is 'yes' for NetBSD's usr.bin/make but 'no' for the bmake
 # distribution and pkgsrc/devel/bmake.
-.MAKE.SAVE_DOLLARS:=  yes
+.MAKE.SAVE_DOLLARS:=	yes
 
 # If the right-hand side does not contain a dollar sign, the ':=' assignment
 # operator has the same effect as the '=' assignment operator.

Index: src/usr.bin/make/unit-tests/varmod-assign-shell.mk
diff -u src/usr.bin/make/unit-tests/varmod-assign-shell.mk:1.1 src/usr.bin/make/unit-tests/varmod-assign-shell.mk:1.2
--- src/usr.bin/make/unit-tests/varmod-assign-shell.mk:1.1	Tue Dec 28 00:56:17 2021
+++ src/usr.bin/make/unit-tests/varmod-assign-shell.mk	Tue Dec 28 10:47:00 2021
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-assign-shell.mk,v 1.1 2021/12/28 00:56:17 rillig Exp $
+# $NetBSD: varmod-assign-shell.mk,v 1.2 2021/12/28 10:47:00 rillig Exp $
 #
 # Tests for the variable modifier '::!=', which assigns the output of a shell
 # command to the variable, but only if the command exited successfully.  This
@@ -21,11 +21,11 @@
 #	Having an error message instead of a warning like for the variable
 #	assignment operator '!=' is another unnecessary inconsistency.
 
-DIRECT= previous
-DIRECT!=echo output; false
+DIRECT=		previous
+DIRECT!=	echo output; false
 
-ASSIGNED=   previous
-_:= ${ASSIGNED::!=echo output; false}
+ASSIGNED=	previous
+_:=		${ASSIGNED::!=echo output; false}
 
 all:
 	@echo DIRECT=${DIRECT:Q}

Index: src/usr.bin/make/unit-tests/varquote.mk
diff -u src/usr.bin/make/unit-tests/varquote.mk:1.4 src/usr.bin/make/unit-tests/varquote.mk:1.5
--- src/usr.bin/make/unit-tests/varquote.mk:1.4	Sun Dec 16 18:53:34 2018
+++ src/usr.bin/make/unit-tests/varquote.mk	Tue Dec 28 10:47:00 2021
@@ -1,10 +1,10 @@
-# $NetBSD: varquote.mk,v 1.4 2018/12/16 18:53:34 christos Exp $
+# $NetBSD: varquote.mk,v 1.5 2021/12/28 10:47:00 rillig Exp $
 #
 # Test VAR:q modifier
 
 .if !defined(REPROFLAGS)
-REPROFLAGS+=-fdebug-prefix-map=\$$NETBSDSRCDIR=/usr/src
-REPROFLAGS+=-fdebug-regex-map='/usr/src/(.*)/obj$$=/usr/obj/\1'
+REPROFLAGS+=	-fdebug-prefix-map=\$$NETBSDSRCDIR=/usr/src
+REPROFLAGS+=	-fdebug-regex-map='/usr/src/(.*)/obj$$=/usr/obj/\1'
 all:
 	@${MAKE} -f ${MAKEFILE} REPROFLAGS=${REPROFLAGS:S/\$/&&/g:Q}
 	@${MAKE} -f ${MAKEFILE} REPROFLAGS=${REPROFLAGS:q}



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

2021-12-28 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Dec 28 10:47:00 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: var-op-expand.mk varmod-assign-shell.mk
varquote.mk

Log Message:
tests/make: use tabs instead of spaces for indentation


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/var-op-expand.mk
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varmod-assign-shell.mk
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varquote.mk

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



CVS commit: src/sys/dev/pci

2021-12-28 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Dec 28 09:19:02 UTC 2021

Modified Files:
src/sys/dev/pci: pci_subr.c

Log Message:
%hhx -> %x


To generate a diff of this commit:
cvs rdiff -u -r1.234 -r1.235 src/sys/dev/pci/pci_subr.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/pci/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.234 src/sys/dev/pci/pci_subr.c:1.235
--- src/sys/dev/pci/pci_subr.c:1.234	Tue Dec 28 09:16:05 2021
+++ src/sys/dev/pci/pci_subr.c	Tue Dec 28 09:19:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.234 2021/12/28 09:16:05 msaitoh Exp $	*/
+/*	$NetBSD: pci_subr.c,v 1.235 2021/12/28 09:19:02 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1997 Zubin D. Dittia.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.234 2021/12/28 09:16:05 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.235 2021/12/28 09:19:02 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -1856,7 +1856,7 @@ pci_print_pcie_link_compliance_preset_de
 	const char *deemphasis;
 
 	if (val >= __arraycount(pcie_link_compliance_preset_deemphasis)) {
-		printf("unknown value (0x%hhx)", val);
+		printf("unknown value (0x%x)", val);
 		return;
 	}
 



CVS commit: src/sys/dev/pci

2021-12-28 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Dec 28 09:19:02 UTC 2021

Modified Files:
src/sys/dev/pci: pci_subr.c

Log Message:
%hhx -> %x


To generate a diff of this commit:
cvs rdiff -u -r1.234 -r1.235 src/sys/dev/pci/pci_subr.c

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



CVS commit: src/sys/dev/pci

2021-12-28 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Dec 28 09:16:05 UTC 2021

Modified Files:
src/sys/dev/pci: pci_subr.c pcireg.h

Log Message:
Decode link control2's Compliance Preset/De-emphasis more. Fix typo.


To generate a diff of this commit:
cvs rdiff -u -r1.233 -r1.234 src/sys/dev/pci/pci_subr.c
cvs rdiff -u -r1.161 -r1.162 src/sys/dev/pci/pcireg.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/dev/pci/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.233 src/sys/dev/pci/pci_subr.c:1.234
--- src/sys/dev/pci/pci_subr.c:1.233	Fri Dec  3 13:27:38 2021
+++ src/sys/dev/pci/pci_subr.c	Tue Dec 28 09:16:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.233 2021/12/03 13:27:38 andvar Exp $	*/
+/*	$NetBSD: pci_subr.c,v 1.234 2021/12/28 09:16:05 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1997 Zubin D. Dittia.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.233 2021/12/03 13:27:38 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.234 2021/12/28 09:16:05 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -1833,6 +1833,41 @@ pci_print_pcie_link_deemphasis(pcireg_t 
 	}
 }
 
+static const struct _pcie_link_compliance_preset_deemphasis {
+	const char *preshoot;
+	const char *deemphasis;
+} pcie_link_compliance_preset_deemphasis[] = {
+	{ "0.0",	"-6.0+-1.5" },	/* P0 */
+	{ "0.0",	"-3.5+-1" },	/* P1 */
+	{ "0.0",	"-4.4+-1.5" },	/* P2 */
+	{ "0.0",	"-2.5+-1" },	/* P3 */
+	{ "0.0",	"0.0" },	/* P4 */
+	{ "1.9+-1",	"0.0" },	/* P5 */
+	{ "2.5+-1",	"0.0" },	/* P6 */
+	{ "3.5+-1",	"-6.0+-1.5" },	/* P7 */
+	{ "3.5+-1",	"-3.5+-1" },	/* P8 */
+	{ "3.5+-1",	"0.0" },	/* P9 */
+	{ "0.0",	NULL }		/* P10 */
+};
+
+static void
+pci_print_pcie_link_compliance_preset_deemphasis(pcireg_t val)
+{
+	const char *deemphasis;
+
+	if (val >= __arraycount(pcie_link_compliance_preset_deemphasis)) {
+		printf("unknown value (0x%hhx)", val);
+		return;
+	}
+
+	printf("Preshoot %sdB",
+	pcie_link_compliance_preset_deemphasis[val].preshoot);
+	deemphasis = pcie_link_compliance_preset_deemphasis[val].deemphasis;
+
+	if (deemphasis != NULL)
+		printf(", De-emphasis %sdB", deemphasis);
+}
+
 static void
 pci_conf_print_pcie_cap(const pcireg_t *regs, int capoff)
 {
@@ -2366,8 +2401,8 @@ pci_conf_print_pcie_cap(const pcireg_t *
 		PCIREG_SHIFTOUT(reg,  PCIE_LCSR2_TX_MARGIN));
 		onoff("Enter Modified Compliance", reg, PCIE_LCSR2_EN_MCOMP);
 		onoff("Compliance SOS", reg, PCIE_LCSR2_COMP_SOS);
-		printf("  Compliance Present/De-emphasis: ");
-		pci_print_pcie_link_deemphasis(
+		printf("  Compliance Preset/De-emphasis: ");
+		pci_print_pcie_link_compliance_preset_deemphasis(
 			PCIREG_SHIFTOUT(reg, PCIE_LCSR2_COMP_DEEMP));
 		printf("\n");
 

Index: src/sys/dev/pci/pcireg.h
diff -u src/sys/dev/pci/pcireg.h:1.161 src/sys/dev/pci/pcireg.h:1.162
--- src/sys/dev/pci/pcireg.h:1.161	Sun Oct 10 23:28:36 2021
+++ src/sys/dev/pci/pcireg.h	Tue Dec 28 09:16:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcireg.h,v 1.161 2021/10/10 23:28:36 msaitoh Exp $	*/
+/*	$NetBSD: pcireg.h,v 1.162 2021/12/28 09:16:05 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 1995, 1996, 1999, 2000
@@ -1174,7 +1174,7 @@ typedef u_int8_t pci_revision_t;
 #define PCIE_LCSR2_TX_MARGIN	__BITS(9, 7)   /* Transmit Margin */
 #define PCIE_LCSR2_EN_MCOMP	__BIT(10)  /* Enter Modified Compliance */
 #define PCIE_LCSR2_COMP_SOS	__BIT(11)  /* Compliance SOS */
-#define PCIE_LCSR2_COMP_DEEMP	__BITS(15, 12) /* Compliance Present/De-emph */
+#define PCIE_LCSR2_COMP_DEEMP	__BITS(15, 12) /* Compliance Preset/De-emph */
 #define PCIE_LCSR2_DEEMP_LVL	__BIT(0 + 16)  /* Current De-emphasis Level */
 #define PCIE_LCSR2_EQ_COMPL	__BIT(1 + 16)  /* Equalization Complete */
 #define PCIE_LCSR2_EQP1_SUC	__BIT(2 + 16)  /* Equaliz Phase 1 Successful */



CVS commit: src/sys/dev/pci

2021-12-28 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Tue Dec 28 09:16:05 UTC 2021

Modified Files:
src/sys/dev/pci: pci_subr.c pcireg.h

Log Message:
Decode link control2's Compliance Preset/De-emphasis more. Fix typo.


To generate a diff of this commit:
cvs rdiff -u -r1.233 -r1.234 src/sys/dev/pci/pci_subr.c
cvs rdiff -u -r1.161 -r1.162 src/sys/dev/pci/pcireg.h

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