CVS commit: src/usr.bin/make

2024-04-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Apr 14 15:21:20 UTC 2024

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

Log Message:
make: make string matching platform-independent

Previously, whether the character range '[a-ä]' matched, depended on the
signedness of the plain 'char' type.  Since make operates on byte
strings and does not support UTF-8 or other multi-byte character
encodings, this edge case is not expected to occur in practice.

No change in the unit tests as this edge case is not covered by tests.


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/usr.bin/make/str.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/str.c
diff -u src/usr.bin/make/str.c:1.102 src/usr.bin/make/str.c:1.103
--- src/usr.bin/make/str.c:1.102	Fri Jan  5 23:22:06 2024
+++ src/usr.bin/make/str.c	Sun Apr 14 15:21:20 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: str.c,v 1.102 2024/01/05 23:22:06 rillig Exp $	*/
+/*	$NetBSD: str.c,v 1.103 2024/04/14 15:21:20 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -71,7 +71,7 @@
 #include "make.h"
 
 /*	"@(#)str.c	5.8 (Berkeley) 6/1/90"	*/
-MAKE_RCSID("$NetBSD: str.c,v 1.102 2024/01/05 23:22:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: str.c,v 1.103 2024/04/14 15:21:20 rillig Exp $");
 
 
 static HashTable interned_strings;
@@ -297,26 +297,6 @@ Str_Words(const char *str, bool expand)
 }
 
 /*
- * XXX: In the extreme edge case that one of the characters is from the basic
- * execution character set and the other isn't, the result of the comparison
- * differs depending on whether plain char is signed or unsigned.
- *
- * An example is the character range from \xE4 to 'a', where \xE4 may come
- * from U+00E4 'Latin small letter A with diaeresis'.
- *
- * If char is signed, \xE4 evaluates to -28, the first half of the condition
- * becomes -28 <= '0' && '0' <= 'a', which evaluates to true.
- *
- * If char is unsigned, \xE4 evaluates to 228, the second half of the
- * condition becomes 'a' <= '0' && '0' <= 228, which evaluates to false.
- */
-static bool
-in_range(char e1, char c, char e2)
-{
-	return (e1 <= c && c <= e2) || (e2 <= c && c <= e1);
-}
-
-/*
  * Test if a string matches a pattern like "*.[ch]". The pattern matching
  * characters are '*', '?' and '[]', as in fnmatch(3).
  *
@@ -360,7 +340,11 @@ match_fixed_length:
 return res;
 			}
 			if (pat[1] == '-') {
-if (in_range(pat[0], *str, pat[2]))
+unsigned char e1 = (unsigned char)pat[0];
+unsigned char c = (unsigned char)*str;
+unsigned char e2 = (unsigned char)pat[2];
+if ((e1 <= c && c <= e2)
+|| (e2 <= c && c <= e1))
 	goto end_of_char_list;
 pat += 2;
 			}



CVS commit: src/usr.bin/make

2024-04-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Apr 14 15:21:20 UTC 2024

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

Log Message:
make: make string matching platform-independent

Previously, whether the character range '[a-ä]' matched, depended on the
signedness of the plain 'char' type.  Since make operates on byte
strings and does not support UTF-8 or other multi-byte character
encodings, this edge case is not expected to occur in practice.

No change in the unit tests as this edge case is not covered by tests.


To generate a diff of this commit:
cvs rdiff -u -r1.102 -r1.103 src/usr.bin/make/str.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

2024-04-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Apr 14 12:30:48 UTC 2024

Modified Files:
src/usr.bin/make: parse.c
src/usr.bin/make/unit-tests: directive-export-impl.exp
directive-for-escape.exp opt-debug-parse.exp var-eval-short.exp
varmod-loop.exp varname-dot-shell.exp

Log Message:
make: add debug logging for .if and .for lines in -dp mode

This helps track down in which line a condition is evaluated.


To generate a diff of this commit:
cvs rdiff -u -r1.718 -r1.719 src/usr.bin/make/parse.c
cvs rdiff -u -r1.17 -r1.18 \
src/usr.bin/make/unit-tests/directive-export-impl.exp
cvs rdiff -u -r1.23 -r1.24 \
src/usr.bin/make/unit-tests/directive-for-escape.exp \
src/usr.bin/make/unit-tests/var-eval-short.exp
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/opt-debug-parse.exp
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/varmod-loop.exp
cvs rdiff -u -r1.20 -r1.21 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.718 src/usr.bin/make/parse.c:1.719
--- src/usr.bin/make/parse.c:1.718	Mon Apr  1 12:26:02 2024
+++ src/usr.bin/make/parse.c	Sun Apr 14 12:30:47 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.718 2024/04/01 12:26:02 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.719 2024/04/14 12:30:47 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -105,7 +105,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.718 2024/04/01 12:26:02 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.719 2024/04/14 12:30:47 rillig Exp $");
 
 /* Detects a multiple-inclusion guard in a makefile. */
 typedef enum {
@@ -2607,6 +2607,7 @@ ReadHighLevelLine(void)
 		if (line == NULL)
 			return NULL;
 
+		DEBUG2(PARSE, "Parsing line %u: %s\n", curFile->lineno, line);
 		if (curFile->guardState != GS_NO
 		&& ((curFile->guardState == GS_START && line[0] != '.')
 			|| curFile->guardState == GS_DONE))
@@ -2929,8 +2930,6 @@ Parse_File(const char *name, int fd)
 
 	do {
 		while ((line = ReadHighLevelLine()) != NULL) {
-			DEBUG2(PARSE, "Parsing line %u: %s\n",
-			CurFile()->lineno, line);
 			ParseLine(line);
 		}
 	} while (ParseEOF());

Index: src/usr.bin/make/unit-tests/directive-export-impl.exp
diff -u src/usr.bin/make/unit-tests/directive-export-impl.exp:1.17 src/usr.bin/make/unit-tests/directive-export-impl.exp:1.18
--- src/usr.bin/make/unit-tests/directive-export-impl.exp:1.17	Thu Mar  3 19:36:35 2022
+++ src/usr.bin/make/unit-tests/directive-export-impl.exp	Sun Apr 14 12:30:47 2024
@@ -10,6 +10,7 @@ Pattern for ':N' is "*"
 ModifyWords: split "<>" into 1 word
 Result of ${UT_VAR:N*} is ""
 ParseDependency(: )
+Parsing line 42: .if ${:!echo "\$UT_VAR"!} != "<>"
 CondParser_Eval: ${:!echo "\$UT_VAR"!} != "<>"
 Var_Parse: ${:!echo "\$UT_VAR"!} != "<>" (eval-defined)
 Evaluating modifier ${:!...} on value "" (eval-defined, undefined)
@@ -34,6 +35,7 @@ Result of ${UT_VAR:N*} is ""
 ParseDependency(: )
 Parsing line 54: REF=		defined
 Global: REF = defined
+Parsing line 58: .if ${:!echo "\$UT_VAR"!} != ""
 CondParser_Eval: ${:!echo "\$UT_VAR"!} != ""
 Var_Parse: ${:!echo "\$UT_VAR"!} != "" (eval-defined)
 Evaluating modifier ${:!...} on value "" (eval-defined, undefined)

Index: src/usr.bin/make/unit-tests/directive-for-escape.exp
diff -u src/usr.bin/make/unit-tests/directive-for-escape.exp:1.23 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.24
--- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.23	Sun Nov 19 22:06:15 2023
+++ src/usr.bin/make/unit-tests/directive-for-escape.exp	Sun Apr 14 12:30:47 2024
@@ -106,6 +106,7 @@ make: "directive-for-escape.mk" line 228
 For: end for 1
 For: loop body with i = "
 ":
+Parsing line 244: .for i in "${.newline}"
 For: end for 1
 Parse_PushInput: .for loop in directive-for-escape.mk, line 244
 make: "directive-for-escape.mk" line 244: newline in .for value
Index: src/usr.bin/make/unit-tests/var-eval-short.exp
diff -u src/usr.bin/make/unit-tests/var-eval-short.exp:1.23 src/usr.bin/make/unit-tests/var-eval-short.exp:1.24
--- src/usr.bin/make/unit-tests/var-eval-short.exp:1.23	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/var-eval-short.exp	Sun Apr 14 12:30:47 2024
@@ -1,5 +1,6 @@
 make: "var-eval-short.mk" line 46: In the :@ modifier of "", the variable name "${FAIL}" must not contain a dollar
 make: "var-eval-short.mk" line 46: Malformed conditional (0 && ${:Uword:@${FAIL}@expr@})
+Parsing line 159: .if 0 && ${0:?${FAIL}then:${FAIL}else}
 CondParser_Eval: 0 && ${0:?${FAIL}then:${FAIL}else}
 Var_Parse: ${0:?${FAIL}then:${FAIL}else} (parse-only)
 Parsing modifier ${0:?...}
@@ -10,6 +11,7 @@ Modifier part: "${FAIL}else"
 Result of ${0:?${FAIL}then:${FAIL}else} is "" (parse-only, defined)
 Parsing line 167: DEFINED=	defined
 Global: 

CVS commit: src/usr.bin/make

2024-04-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Apr 14 12:30:48 UTC 2024

Modified Files:
src/usr.bin/make: parse.c
src/usr.bin/make/unit-tests: directive-export-impl.exp
directive-for-escape.exp opt-debug-parse.exp var-eval-short.exp
varmod-loop.exp varname-dot-shell.exp

Log Message:
make: add debug logging for .if and .for lines in -dp mode

This helps track down in which line a condition is evaluated.


To generate a diff of this commit:
cvs rdiff -u -r1.718 -r1.719 src/usr.bin/make/parse.c
cvs rdiff -u -r1.17 -r1.18 \
src/usr.bin/make/unit-tests/directive-export-impl.exp
cvs rdiff -u -r1.23 -r1.24 \
src/usr.bin/make/unit-tests/directive-for-escape.exp \
src/usr.bin/make/unit-tests/var-eval-short.exp
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/opt-debug-parse.exp
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/varmod-loop.exp
cvs rdiff -u -r1.20 -r1.21 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/unit-tests

2024-04-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Apr  2 15:05:15 UTC 2024

Modified Files:
src/usr.bin/make/unit-tests: opt-keep-going-indirect.mk

Log Message:
tests/make: pass PATH onto child processes

This fixes the tests on some Cygwin variant where the shell does not
initialize the PATH environment variable when it's missing.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/usr.bin/make/unit-tests/opt-keep-going-indirect.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/opt-keep-going-indirect.mk
diff -u src/usr.bin/make/unit-tests/opt-keep-going-indirect.mk:1.2 src/usr.bin/make/unit-tests/opt-keep-going-indirect.mk:1.3
--- src/usr.bin/make/unit-tests/opt-keep-going-indirect.mk:1.2	Sat Feb 12 20:05:36 2022
+++ src/usr.bin/make/unit-tests/opt-keep-going-indirect.mk	Tue Apr  2 15:05:15 2024
@@ -1,4 +1,4 @@
-# $NetBSD: opt-keep-going-indirect.mk,v 1.2 2022/02/12 20:05:36 rillig Exp $
+# $NetBSD: opt-keep-going-indirect.mk,v 1.3 2024/04/02 15:05:15 rillig Exp $
 #
 # Tests for the -k command line option, which stops building a target as soon
 # as an error is detected, but continues building the other, independent
@@ -49,19 +49,19 @@
 # to the child processes.
 all:
 	@echo 'direct compat'
-	@set +e; env -i ${MAKE} -r -f ${MAKEFILE} -k direct; echo "exited $$?"
+	@set +e; env -i "PATH=$$PATH" ${MAKE} -r -f ${MAKEFILE} -k direct; echo "exited $$?"
 	@echo
 
 	@echo 'direct jobs'
-	@set +e; env -i ${MAKE} -r -f ${MAKEFILE} -k direct -j1; echo "exited $$?"
+	@set +e; env -i "PATH=$$PATH" ${MAKE} -r -f ${MAKEFILE} -k direct -j1; echo "exited $$?"
 	@echo
 
 	@echo 'indirect compat'
-	@set +e; env -i ${MAKE} -r -f ${MAKEFILE} -k indirect; echo "exited $$?"
+	@set +e; env -i "PATH=$$PATH" ${MAKE} -r -f ${MAKEFILE} -k indirect; echo "exited $$?"
 	@echo
 
 	@echo 'indirect jobs'
-	@set +e; env -i ${MAKE} -r -f ${MAKEFILE} -k indirect -j1; echo "exited $$?"
+	@set +e; env -i "PATH=$$PATH" ${MAKE} -r -f ${MAKEFILE} -k indirect -j1; echo "exited $$?"
 	@echo
 
 indirect: direct



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

2024-04-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Apr  2 15:05:15 UTC 2024

Modified Files:
src/usr.bin/make/unit-tests: opt-keep-going-indirect.mk

Log Message:
tests/make: pass PATH onto child processes

This fixes the tests on some Cygwin variant where the shell does not
initialize the PATH environment variable when it's missing.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/usr.bin/make/unit-tests/opt-keep-going-indirect.mk

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



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

2024-04-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Apr  2 11:11:00 UTC 2024

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

Log Message:
tests/make: remove test for overly long chdir argument

On Cygwin, the path '/././..././' is normalized before being passed to
the child 'make' process. Since overly long pathnames are not required
to be supported on all platforms, remove the test.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-chdir.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/opt-chdir.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/opt-chdir.exp
diff -u src/usr.bin/make/unit-tests/opt-chdir.exp:1.3 src/usr.bin/make/unit-tests/opt-chdir.exp:1.4
--- src/usr.bin/make/unit-tests/opt-chdir.exp:1.3	Sun Dec 27 11:47:04 2020
+++ src/usr.bin/make/unit-tests/opt-chdir.exp	Tue Apr  2 11:11:00 2024
@@ -1,5 +1,3 @@
-make: chdir /././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././
 ././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././.
 /././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././././
 

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

2024-04-02 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Apr  2 11:11:00 UTC 2024

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

Log Message:
tests/make: remove test for overly long chdir argument

On Cygwin, the path '/././..././' is normalized before being passed to
the child 'make' process. Since overly long pathnames are not required
to be supported on all platforms, remove the test.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-chdir.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/opt-chdir.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

2024-04-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Apr  1 12:33:28 UTC 2024

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

Log Message:
make: remove unreachable code in handling .for loops


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

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

Modified files:

Index: src/usr.bin/make/for.c
diff -u src/usr.bin/make/for.c:1.178 src/usr.bin/make/for.c:1.179
--- src/usr.bin/make/for.c:1.178	Sun Jan 21 15:02:17 2024
+++ src/usr.bin/make/for.c	Mon Apr  1 12:33:27 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: for.c,v 1.178 2024/01/21 15:02:17 rillig Exp $	*/
+/*	$NetBSD: for.c,v 1.179 2024/04/01 12:33:27 rillig Exp $	*/
 
 /*
  * Copyright (c) 1992, The Regents of the University of California.
@@ -58,7 +58,7 @@
 #include "make.h"
 
 /*	"@(#)for.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: for.c,v 1.178 2024/01/21 15:02:17 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.179 2024/04/01 12:33:27 rillig Exp $");
 
 
 typedef struct ForLoop {
@@ -196,11 +196,7 @@ ForLoop_ParseItems(ForLoop *f, const cha
 	cpp_skip_whitespace();
 
 	items = Var_Subst(p, SCOPE_GLOBAL, VARE_WANTRES);
-	if (items == var_Error) {
-		/* TODO: Make this part of the code reachable. */
-		Parse_Error(PARSE_FATAL, "Error in .for loop items");
-		return false;
-	}
+	/* TODO: handle errors */
 
 	f->items = Substring_Words(items, false);
 	free(items);
@@ -490,12 +486,11 @@ ForLoop_SubstBody(ForLoop *f, unsigned i
 			p += 2;
 			ForLoop_SubstVarLong(f, firstItem, body,
 			, endc, );
-		} else if (p[1] != '\0') {
+		} else {
 			ForLoop_SubstVarShort(f, firstItem, body,
 			p + 1, );
 			p += 2;
-		} else
-			break;
+		}
 	}
 
 	Buf_AddRange(body, mark, end);



CVS commit: src/usr.bin/make

2024-04-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Apr  1 12:33:28 UTC 2024

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

Log Message:
make: remove unreachable code in handling .for loops


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

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



CVS commit: src/usr.bin/make

2024-04-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Apr  1 12:26:02 UTC 2024

Modified Files:
src/usr.bin/make: parse.c
src/usr.bin/make/unit-tests: directive-for-null.exp
directive-for-null.mk opt-file.exp opt-file.mk

Log Message:
make: exit immediately after reading a null byte from a makefile

The chance of other garbage bytes in such a file is just too high.


To generate a diff of this commit:
cvs rdiff -u -r1.717 -r1.718 src/usr.bin/make/parse.c
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/directive-for-null.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/directive-for-null.mk
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/opt-file.exp
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/opt-file.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

2024-04-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Apr  1 12:26:02 UTC 2024

Modified Files:
src/usr.bin/make: parse.c
src/usr.bin/make/unit-tests: directive-for-null.exp
directive-for-null.mk opt-file.exp opt-file.mk

Log Message:
make: exit immediately after reading a null byte from a makefile

The chance of other garbage bytes in such a file is just too high.


To generate a diff of this commit:
cvs rdiff -u -r1.717 -r1.718 src/usr.bin/make/parse.c
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/directive-for-null.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/directive-for-null.mk
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/opt-file.exp
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/opt-file.mk

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

Modified files:

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.717 src/usr.bin/make/parse.c:1.718
--- src/usr.bin/make/parse.c:1.717	Wed Feb  7 06:43:02 2024
+++ src/usr.bin/make/parse.c	Mon Apr  1 12:26:02 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.717 2024/02/07 06:43:02 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.718 2024/04/01 12:26:02 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -105,7 +105,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.717 2024/02/07 06:43:02 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.718 2024/04/01 12:26:02 rillig Exp $");
 
 /* Detects a multiple-inclusion guard in a makefile. */
 typedef enum {
@@ -2368,7 +2368,7 @@ ParseRawLine(IncludedFile *curFile, char
 		ch = *p;
 		if (ch == '\0' || (ch == '\\' && p[1] == '\0')) {
 			Parse_Error(PARSE_FATAL, "Zero byte read from file");
-			return PRLR_ERROR;
+			exit(2);
 		}
 
 		/* Treat next character after '\' as literal. */

Index: src/usr.bin/make/unit-tests/directive-for-null.exp
diff -u src/usr.bin/make/unit-tests/directive-for-null.exp:1.2 src/usr.bin/make/unit-tests/directive-for-null.exp:1.3
--- src/usr.bin/make/unit-tests/directive-for-null.exp:1.2	Thu Dec  9 20:13:10 2021
+++ src/usr.bin/make/unit-tests/directive-for-null.exp	Mon Apr  1 12:26:02 2024
@@ -1,9 +1,5 @@
 make: "(stdin)" line 2: Zero byte read from file
-make: "(stdin)" line 2: Unexpected end of file in .for loop
-make: "(stdin)" line 3: Zero byte read from file
-make: Fatal errors encountered -- cannot continue
-make: stopped in unit-tests
-*** Error code 1 (continuing)
+*** Error code 2 (continuing)
 
 Stop.
 make: stopped in unit-tests

Index: src/usr.bin/make/unit-tests/directive-for-null.mk
diff -u src/usr.bin/make/unit-tests/directive-for-null.mk:1.3 src/usr.bin/make/unit-tests/directive-for-null.mk:1.4
--- src/usr.bin/make/unit-tests/directive-for-null.mk:1.3	Sun Jun 12 15:03:27 2022
+++ src/usr.bin/make/unit-tests/directive-for-null.mk	Mon Apr  1 12:26:02 2024
@@ -1,18 +1,8 @@
-# $NetBSD: directive-for-null.mk,v 1.3 2022/06/12 15:03:27 rillig Exp $
+# $NetBSD: directive-for-null.mk,v 1.4 2024/04/01 12:26:02 rillig Exp $
 #
 # Test for parsing a .for loop that accidentally contains a null byte.
 #
-# As of 2020-12-19, there are 3 error messages:
-#
-#	make: "(stdin)" line 2: Zero byte read from file
-#	make: "(stdin)" line 2: Unexpected end of file in for loop.
-#	make: "(stdin)" line 3: Zero byte read from file
-#
-# The one about "end of file" might be misleading but is due to the
-# implementation.  On both errors and EOF, ParseRawLine returns NULL.
-#
-# The one about the "zero byte" in line 3 is surprising since the only
-# line that contains a null byte is line 2.
+# expect: make: "(stdin)" line 2: Zero byte read from file
 
 all: .PHONY
 	@printf '%s\n' \

Index: src/usr.bin/make/unit-tests/opt-file.exp
diff -u src/usr.bin/make/unit-tests/opt-file.exp:1.7 src/usr.bin/make/unit-tests/opt-file.exp:1.8
--- src/usr.bin/make/unit-tests/opt-file.exp:1.7	Tue Dec 22 08:51:30 2020
+++ src/usr.bin/make/unit-tests/opt-file.exp	Mon Apr  1 12:26:02 2024
@@ -2,9 +2,7 @@ value
 value
 line-with-trailing-whitespace
 make: "(stdin)" line 1: Zero byte read from file
-make: Fatal errors encountered -- cannot continue
-make: stopped in unit-tests
-*** Error code 1 (continuing)
+*** Error code 2 (continuing)
 `all' not remade because of errors.
 
 Stop.

Index: src/usr.bin/make/unit-tests/opt-file.mk
diff -u src/usr.bin/make/unit-tests/opt-file.mk:1.15 src/usr.bin/make/unit-tests/opt-file.mk:1.16
--- src/usr.bin/make/unit-tests/opt-file.mk:1.15	Sat Mar 26 13:32:31 2022
+++ src/usr.bin/make/unit-tests/opt-file.mk	Mon Apr  1 12:26:02 2024
@@ -1,4 +1,4 @@
-# $NetBSD: opt-file.mk,v 1.15 2022/03/26 13:32:31 rillig Exp $
+# $NetBSD: opt-file.mk,v 1.16 2024/04/01 12:26:02 rillig Exp $
 #
 # Tests for the -f command line option, which adds a makefile to the list of
 # files that are parsed.
@@ -79,7 +79,7 @@ line-with-trailing-whitespace: .PHONY
 #	exit status 0
 #
 #	2008 to 2010:
-#	make: 

CVS commit: src/usr.bin/make

2024-03-09 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sun Mar 10 02:53:38 UTC 2024

Modified Files:
src/usr.bin/make: compat.c job.c main.c make.1 make.h targ.c

Log Message:
make: record exit status in GNode

SetErrorVars can now set .ERROR_EXIT which allows
a .ERROR target to ignore the case of .ERROR_EXIT == 6
which means failure happened elsewhere.

Reviewed by:


To generate a diff of this commit:
cvs rdiff -u -r1.253 -r1.254 src/usr.bin/make/compat.c
cvs rdiff -u -r1.466 -r1.467 src/usr.bin/make/job.c
cvs rdiff -u -r1.611 -r1.612 src/usr.bin/make/main.c
cvs rdiff -u -r1.374 -r1.375 src/usr.bin/make/make.1
cvs rdiff -u -r1.328 -r1.329 src/usr.bin/make/make.h
cvs rdiff -u -r1.179 -r1.180 src/usr.bin/make/targ.c

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

Modified files:

Index: src/usr.bin/make/compat.c
diff -u src/usr.bin/make/compat.c:1.253 src/usr.bin/make/compat.c:1.254
--- src/usr.bin/make/compat.c:1.253	Fri Mar  1 16:41:42 2024
+++ src/usr.bin/make/compat.c	Sun Mar 10 02:53:37 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.253 2024/03/01 16:41:42 sjg Exp $	*/
+/*	$NetBSD: compat.c,v 1.254 2024/03/10 02:53:37 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -91,7 +91,7 @@
 #include "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.253 2024/03/01 16:41:42 sjg Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.254 2024/03/10 02:53:37 sjg Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -390,6 +390,8 @@ Compat_RunCommand(const char *cmdp, GNod
 meta_job_error(NULL, gn, false, status);
 #endif
 			gn->made = ERROR;
+			if (WIFEXITED(reason))
+gn->exit_status = status;
 			if (opts.keepgoing) {
 /*
  * Abort the current target,

Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.466 src/usr.bin/make/job.c:1.467
--- src/usr.bin/make/job.c:1.466	Fri Mar  1 16:41:42 2024
+++ src/usr.bin/make/job.c	Sun Mar 10 02:53:37 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.466 2024/03/01 16:41:42 sjg Exp $	*/
+/*	$NetBSD: job.c,v 1.467 2024/03/10 02:53:37 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -141,7 +141,7 @@
 #include "trace.h"
 
 /*	"@(#)job.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: job.c,v 1.466 2024/03/01 16:41:42 sjg Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.467 2024/03/10 02:53:37 sjg Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -2044,6 +2044,8 @@ JobReapChild(pid_t pid, int status, bool
 
 	job->status = JOB_ST_FINISHED;
 	job->exit_status = status;
+	if (WIFEXITED(status))
+		job->node->exit_status = WEXITSTATUS(status);
 
 	JobFinish(job, status);
 }

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.611 src/usr.bin/make/main.c:1.612
--- src/usr.bin/make/main.c:1.611	Fri Mar  1 16:41:42 2024
+++ src/usr.bin/make/main.c	Sun Mar 10 02:53:37 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.611 2024/03/01 16:41:42 sjg Exp $	*/
+/*	$NetBSD: main.c,v 1.612 2024/03/10 02:53:37 sjg 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.611 2024/03/01 16:41:42 sjg Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.612 2024/03/10 02:53:37 sjg Exp $");
 #if defined(MAKE_NATIVE)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	"The Regents of the University of California.  "
@@ -2037,10 +2037,13 @@ static void
 SetErrorVars(GNode *gn)
 {
 	StringListNode *ln;
+	char sts[16];
 
 	/*
 	 * We can print this even if there is no .ERROR target.
 	 */
+	snprintf(sts, sizeof(sts), "%d", gn->exit_status);
+	Global_Set(".ERROR_EXIT", sts);
 	Global_Set(".ERROR_TARGET", gn->name);
 	Global_Delete(".ERROR_CMD");
 

Index: src/usr.bin/make/make.1
diff -u src/usr.bin/make/make.1:1.374 src/usr.bin/make/make.1:1.375
--- src/usr.bin/make/make.1:1.374	Thu Jan 25 21:00:59 2024
+++ src/usr.bin/make/make.1	Sun Mar 10 02:53:37 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: make.1,v 1.374 2024/01/25 21:00:59 sjg Exp $
+.\"	$NetBSD: make.1,v 1.375 2024/03/10 02:53:37 sjg Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	from: @(#)make.1	8.4 (Berkeley) 3/19/94
 .\"
-.Dd January 24, 2024
+.Dd March 9, 2024
 .Dt MAKE 1
 .Os
 .Sh NAME
@@ -879,6 +879,9 @@ Is used in error handling, see
 .It Va .ERROR_CWD
 Is used in error handling, see
 .Va MAKE_PRINT_VAR_ON_ERROR .
+.It Va .ERROR_EXIT
+Is used in error handling, see
+.Va MAKE_PRINT_VAR_ON_ERROR .
 .It Va .ERROR_META_FILE
 Is used in error handling in
 .Dq meta
@@ -1185,6 +1188,8 @@ When
 stops due to an error, it sets
 .Sq Va .ERROR_TARGET
 to the name of the target that failed,
+.Sq Va .ERROR_EXIT
+to the exit status of the failed target,
 .Sq Va 

CVS commit: src/usr.bin/make

2024-03-09 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sun Mar 10 02:53:38 UTC 2024

Modified Files:
src/usr.bin/make: compat.c job.c main.c make.1 make.h targ.c

Log Message:
make: record exit status in GNode

SetErrorVars can now set .ERROR_EXIT which allows
a .ERROR target to ignore the case of .ERROR_EXIT == 6
which means failure happened elsewhere.

Reviewed by:


To generate a diff of this commit:
cvs rdiff -u -r1.253 -r1.254 src/usr.bin/make/compat.c
cvs rdiff -u -r1.466 -r1.467 src/usr.bin/make/job.c
cvs rdiff -u -r1.611 -r1.612 src/usr.bin/make/main.c
cvs rdiff -u -r1.374 -r1.375 src/usr.bin/make/make.1
cvs rdiff -u -r1.328 -r1.329 src/usr.bin/make/make.h
cvs rdiff -u -r1.179 -r1.180 src/usr.bin/make/targ.c

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



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

2024-03-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Mar  5 23:07:58 UTC 2024

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

Log Message:
tests/make: clean up test for local scope variables

Use the same style of quotes for both kinds of variables.  To make the
variable values more easily comparable, write them to a single line.
Add the output to the 'expect' lines.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/var-scope-local.exp
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/var-scope-local.mk

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



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

2024-03-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Tue Mar  5 23:07:58 UTC 2024

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

Log Message:
tests/make: clean up test for local scope variables

Use the same style of quotes for both kinds of variables.  To make the
variable values more easily comparable, write them to a single line.
Add the output to the 'expect' lines.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/var-scope-local.exp
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/var-scope-local.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-scope-local.exp
diff -u src/usr.bin/make/unit-tests/var-scope-local.exp:1.8 src/usr.bin/make/unit-tests/var-scope-local.exp:1.9
--- src/usr.bin/make/unit-tests/var-scope-local.exp:1.8	Fri Mar  1 20:15:59 2024
+++ src/usr.bin/make/unit-tests/var-scope-local.exp	Tue Mar  5 23:07:58 2024
@@ -60,19 +60,12 @@ dir/subdir/inference-rule-chain.ir-to: *
 : Making var-scope-local.c out of nothing.
 : Making var-scope-local.o from var-scope-local.c.
 : Making basename "var-scope-local.o" in "." from "var-scope-local.c" in ".".
-: Making var-scope-local-assign.o with VAR="local".
-var-scope-local-assign.o env has VAR='local'
-: Making var-scope-local-append.o with VAR="local to var-scope-local-append.o".
-var-scope-local-append.o env has VAR='local to var-scope-local-append.o'
-: Making var-scope-local-append-global.o with VAR="global+local".
-var-scope-local-append-global.o env has VAR='global+local'
-: Making var-scope-local-default.o with VAR="global".
-var-scope-local-default.o env has VAR='global'
-: Making var-scope-local-subst.o with VAR="global+local".
-var-scope-local-subst.o env has VAR='global+local'
-: Making var-scope-local-shell.o with VAR="output".
-var-scope-local-shell.o env has VAR='output'
-: var-scope-local-use.o uses .USE VAR="global"
-var-scope-local-use.o env has VAR='global'
+Making var-scope-local-assign.o with make 'local' and env 'local'.
+Making var-scope-local-append.o with make 'local to var-scope-local-append.o' and env 'local to var-scope-local-append.o'.
+Making var-scope-local-append-global.o with make 'global+local' and env 'global+local'.
+Making var-scope-local-default.o with make 'global' and env 'global'.
+Making var-scope-local-subst.o with make 'global+local' and env 'global+local'.
+Making var-scope-local-shell.o with make 'output' and env 'output'.
+Making .USE var-scope-local-use.o with make 'global' and env 'global'.
 : all overwritten
 exit status 0

Index: src/usr.bin/make/unit-tests/var-scope-local.mk
diff -u src/usr.bin/make/unit-tests/var-scope-local.mk:1.10 src/usr.bin/make/unit-tests/var-scope-local.mk:1.11
--- src/usr.bin/make/unit-tests/var-scope-local.mk:1.10	Fri Mar  1 20:15:59 2024
+++ src/usr.bin/make/unit-tests/var-scope-local.mk	Tue Mar  5 23:07:58 2024
@@ -1,4 +1,4 @@
-# $NetBSD: var-scope-local.mk,v 1.10 2024/03/01 20:15:59 sjg Exp $
+# $NetBSD: var-scope-local.mk,v 1.11 2024/03/05 23:07:58 rillig Exp $
 #
 # Tests for target-local variables, such as ${.TARGET} or $@.  These variables
 # are relatively short-lived as they are created just before making the
@@ -199,8 +199,7 @@ var-scope-local-append-global.o \
 var-scope-local-default.o \
 var-scope-local-subst.o \
 var-scope-local-shell.o:
-	: Making ${.TARGET} with VAR="${VAR}".
-	@echo "${.TARGET} env has VAR='$$VAR'"
+	@echo "Making ${.TARGET} with make '"${VAR:Q}"' and env '$$VAR'."
 
 # Target-local variables are enabled by default.  Force them to be enabled
 # just in case a test above has disabled them.
@@ -215,7 +214,7 @@ VAR=	global
 # irrelevant.
 #
 # expect-reset
-# expect: : Making var-scope-local-assign.o with VAR="local".
+# expect: Making var-scope-local-assign.o with make 'local' and env 'local'.
 var-scope-local-assign.o: VAR= local
 
 # Assignments using '+=' do *not* look up the global value, instead they only
@@ -225,7 +224,7 @@ var-scope-local-append.o: VAR+= local
 # behaves as expected.  Note that the expression '${.TARGET}' is not resolved
 # when parsing the dependency line, its evaluation is deferred until the
 # target is actually made.
-# expect: : Making var-scope-local-append.o with VAR="local to var-scope-local-append.o".
+# expect: Making var-scope-local-append.o with make 'local to var-scope-local-append.o' and env 'local to var-scope-local-append.o'.
 var-scope-local-append.o: VAR += to ${.TARGET}
 # To access the value of a global variable, use an expression.  This
 # expression is expanded before parsing the whole dependency line.  Since the
@@ -235,7 +234,7 @@ var-scope-local-append.o: VAR += to ${.T
 # not influence the parsing of the variable assignment.  The effective
 # variable assignment, after expanding the whole line first, is thus
 # 'VAR= global+local'.
-# expect: : Making 

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

2024-03-01 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Fri Mar  1 20:15:59 UTC 2024

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

Log Message:
make: update var-scope-local test

Show what VAR value is in environment of target script.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/var-scope-local.exp
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/var-scope-local.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-scope-local.exp
diff -u src/usr.bin/make/unit-tests/var-scope-local.exp:1.7 src/usr.bin/make/unit-tests/var-scope-local.exp:1.8
--- src/usr.bin/make/unit-tests/var-scope-local.exp:1.7	Wed Dec 20 09:03:09 2023
+++ src/usr.bin/make/unit-tests/var-scope-local.exp	Fri Mar  1 20:15:59 2024
@@ -61,11 +61,18 @@ dir/subdir/inference-rule-chain.ir-to: *
 : Making var-scope-local.o from var-scope-local.c.
 : Making basename "var-scope-local.o" in "." from "var-scope-local.c" in ".".
 : Making var-scope-local-assign.o with VAR="local".
+var-scope-local-assign.o env has VAR='local'
 : Making var-scope-local-append.o with VAR="local to var-scope-local-append.o".
+var-scope-local-append.o env has VAR='local to var-scope-local-append.o'
 : Making var-scope-local-append-global.o with VAR="global+local".
+var-scope-local-append-global.o env has VAR='global+local'
 : Making var-scope-local-default.o with VAR="global".
+var-scope-local-default.o env has VAR='global'
 : Making var-scope-local-subst.o with VAR="global+local".
+var-scope-local-subst.o env has VAR='global+local'
 : Making var-scope-local-shell.o with VAR="output".
+var-scope-local-shell.o env has VAR='output'
 : var-scope-local-use.o uses .USE VAR="global"
+var-scope-local-use.o env has VAR='global'
 : all overwritten
 exit status 0

Index: src/usr.bin/make/unit-tests/var-scope-local.mk
diff -u src/usr.bin/make/unit-tests/var-scope-local.mk:1.9 src/usr.bin/make/unit-tests/var-scope-local.mk:1.10
--- src/usr.bin/make/unit-tests/var-scope-local.mk:1.9	Wed Dec 20 09:03:09 2023
+++ src/usr.bin/make/unit-tests/var-scope-local.mk	Fri Mar  1 20:15:59 2024
@@ -1,4 +1,4 @@
-# $NetBSD: var-scope-local.mk,v 1.9 2023/12/20 09:03:09 rillig Exp $
+# $NetBSD: var-scope-local.mk,v 1.10 2024/03/01 20:15:59 sjg Exp $
 #
 # Tests for target-local variables, such as ${.TARGET} or $@.  These variables
 # are relatively short-lived as they are created just before making the
@@ -200,12 +200,14 @@ var-scope-local-default.o \
 var-scope-local-subst.o \
 var-scope-local-shell.o:
 	: Making ${.TARGET} with VAR="${VAR}".
+	@echo "${.TARGET} env has VAR='$$VAR'"
 
 # Target-local variables are enabled by default.  Force them to be enabled
 # just in case a test above has disabled them.
 .MAKE.TARGET_LOCAL_VARIABLES= yes
 
 VAR=	global
+.export VAR
 
 # If the sources of a dependency line look like a variable assignment, make
 # treats them as such.  There is only a single variable assignment per
@@ -264,6 +266,7 @@ var-scope-local-shell.o: VAR != echo out
 # expect: : var-scope-local-use.o uses .USE VAR="global"
 a_use: .USE VAR=use
 	: ${.TARGET} uses .USE VAR="${VAR}"
+	@echo "${.TARGET} env has VAR='$$VAR'"
 
 all: var-scope-local-use.o
 var-scope-local-use.o: a_use



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

2024-03-01 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Fri Mar  1 20:15:59 UTC 2024

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

Log Message:
make: update var-scope-local test

Show what VAR value is in environment of target script.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/var-scope-local.exp
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/var-scope-local.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

2024-03-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar  1 17:53:30 UTC 2024

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

Log Message:
make: fix type mismatch in lint's strict bool mode (since today)


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

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.1100 src/usr.bin/make/var.c:1.1101
--- src/usr.bin/make/var.c:1.1100	Fri Mar  1 16:41:42 2024
+++ src/usr.bin/make/var.c	Fri Mar  1 17:53:30 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1100 2024/03/01 16:41:42 sjg Exp $	*/
+/*	$NetBSD: var.c,v 1.1101 2024/03/01 17:53:30 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -137,7 +137,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1100 2024/03/01 16:41:42 sjg Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1101 2024/03/01 17:53:30 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -612,9 +612,9 @@ ExportVarEnv(Var *v, GNode *scope)
 	expr = str_concat3("${", name, "}");
 	val = Var_Subst(expr, scope, VARE_WANTRES);
 	if (scope != SCOPE_GLOBAL) {
-		/* we will need to re-rexport the Global version */
+		/* we will need to re-export the global version */
 		v = VarFind(name, SCOPE_GLOBAL, false);
-		if (v)
+		if (v != NULL)
 			v->exported = false;
 	}
 	/* TODO: handle errors */



CVS commit: src/usr.bin/make

2024-03-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar  1 17:53:30 UTC 2024

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

Log Message:
make: fix type mismatch in lint's strict bool mode (since today)


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

2024-03-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar  1 17:47:05 UTC 2024

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

Log Message:
make: remove test variant for NO_REGEX

The compile-time toggle was removed in var.c 1.1099 from 2024-02-07.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/test-variants.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/test-variants.mk
diff -u src/usr.bin/make/test-variants.mk:1.5 src/usr.bin/make/test-variants.mk:1.6
--- src/usr.bin/make/test-variants.mk:1.5	Thu Jan 19 19:55:27 2023
+++ src/usr.bin/make/test-variants.mk	Fri Mar  1 17:47:05 2024
@@ -1,4 +1,4 @@
-# $NetBSD: test-variants.mk,v 1.5 2023/01/19 19:55:27 rillig Exp $
+# $NetBSD: test-variants.mk,v 1.6 2024/03/01 17:47:05 rillig Exp $
 #
 # Build several variants of make and run the tests on them.
 #
@@ -81,15 +81,6 @@ TESTS+=			maxpathlen
 CPPFLAGS.maxpathlen=	-DMAXPATHLEN=20
 SKIP.maxpathlen=	yes
 
-# In this variant, the unit tests using the modifier ':C' fail, as expected.
-#
-TESTS+=			no-regex
-CPPFLAGS.no-regex=	-DNO_REGEX
-SKIP_TESTS.no-regex=	archive cond-short deptgt-makeflags dollar export-all
-SKIP_TESTS.no-regex+=	moderrs modmatch modmisc var-eval-short
-SKIP_TESTS.no-regex+=	varmod-select-words varmod-subst varmod-subst-regex
-SKIP_TESTS.no-regex+=	varname-dot-make-pid varname-dot-make-ppid
-
 # NetBSD 8.0 x86_64 says:
 # In file included from /usr/include/sys/param.h:115:0,
 # from arch.c:135:



CVS commit: src/usr.bin/make

2024-03-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar  1 17:47:05 UTC 2024

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

Log Message:
make: remove test variant for NO_REGEX

The compile-time toggle was removed in var.c 1.1099 from 2024-02-07.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/test-variants.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

2024-03-01 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Fri Mar  1 16:41:42 UTC 2024

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

Log Message:
make: export target scope values

Pass target scope to Var_ReexportVars so that a target process
will see the correct values in its env.
We must then mark any Global scope variable as unexported
so targets without local value get the Global one.


To generate a diff of this commit:
cvs rdiff -u -r1.252 -r1.253 src/usr.bin/make/compat.c
cvs rdiff -u -r1.465 -r1.466 src/usr.bin/make/job.c
cvs rdiff -u -r1.610 -r1.611 src/usr.bin/make/main.c
cvs rdiff -u -r1.327 -r1.328 src/usr.bin/make/make.h
cvs rdiff -u -r1.1099 -r1.1100 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/compat.c
diff -u src/usr.bin/make/compat.c:1.252 src/usr.bin/make/compat.c:1.253
--- src/usr.bin/make/compat.c:1.252	Fri Jan  5 23:22:06 2024
+++ src/usr.bin/make/compat.c	Fri Mar  1 16:41:42 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.252 2024/01/05 23:22:06 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.253 2024/03/01 16:41:42 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -91,7 +91,7 @@
 #include "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.252 2024/01/05 23:22:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.253 2024/03/01 16:41:42 sjg Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -326,7 +326,7 @@ Compat_RunCommand(const char *cmdp, GNod
 		meta_compat_start();
 #endif
 
-	Var_ReexportVars();
+	Var_ReexportVars(gn);
 
 	compatChild = cpid = vfork();
 	if (cpid < 0)

Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.465 src/usr.bin/make/job.c:1.466
--- src/usr.bin/make/job.c:1.465	Sun Jan  7 11:39:04 2024
+++ src/usr.bin/make/job.c	Fri Mar  1 16:41:42 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.465 2024/01/07 11:39:04 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.466 2024/03/01 16:41:42 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -141,7 +141,7 @@
 #include "trace.h"
 
 /*	"@(#)job.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: job.c,v 1.465 2024/01/07 11:39:04 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.466 2024/03/01 16:41:42 sjg Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -1420,7 +1420,7 @@ JobExec(Job *job, char **argv)
 	/* Pre-emptively mark job running, pid still zero though */
 	job->status = JOB_ST_RUNNING;
 
-	Var_ReexportVars();
+	Var_ReexportVars(job->node);
 
 	cpid = vfork();
 	if (cpid == -1)

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.610 src/usr.bin/make/main.c:1.611
--- src/usr.bin/make/main.c:1.610	Wed Feb  7 06:43:02 2024
+++ src/usr.bin/make/main.c	Fri Mar  1 16:41:42 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.610 2024/02/07 06:43:02 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.611 2024/03/01 16:41:42 sjg 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.610 2024/02/07 06:43:02 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.611 2024/03/01 16:41:42 sjg Exp $");
 #if defined(MAKE_NATIVE)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	"The Regents of the University of California.  "
@@ -1735,7 +1735,7 @@ Cmd_Exec(const char *cmd, char **error)
 		return bmake_strdup("");
 	}
 
-	Var_ReexportVars();
+	Var_ReexportVars(SCOPE_GLOBAL);
 
 	switch (cpid = vfork()) {
 	case 0:

Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.327 src/usr.bin/make/make.h:1.328
--- src/usr.bin/make/make.h:1.327	Sun Dec 17 09:02:26 2023
+++ src/usr.bin/make/make.h	Fri Mar  1 16:41:42 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.327 2023/12/17 09:02:26 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.328 2024/03/01 16:41:42 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -1011,7 +1011,7 @@ char *Var_Subst(const char *, GNode *, V
 void Var_Expand(FStr *, GNode *, VarEvalMode);
 void Var_Stats(void);
 void Var_Dump(GNode *);
-void Var_ReexportVars(void);
+void Var_ReexportVars(GNode *);
 void Var_Export(VarExportMode, const char *);
 void Var_ExportVars(const char *);
 void Var_UnExport(bool, const char *);

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.1099 src/usr.bin/make/var.c:1.1100
--- src/usr.bin/make/var.c:1.1099	Wed Feb  7 06:43:02 2024
+++ src/usr.bin/make/var.c	Fri Mar  1 16:41:42 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1099 2024/02/07 06:43:02 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.1100 2024/03/01 16:41:42 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -137,7 +137,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 

CVS commit: src/usr.bin/make

2024-03-01 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Fri Mar  1 16:41:42 UTC 2024

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

Log Message:
make: export target scope values

Pass target scope to Var_ReexportVars so that a target process
will see the correct values in its env.
We must then mark any Global scope variable as unexported
so targets without local value get the Global one.


To generate a diff of this commit:
cvs rdiff -u -r1.252 -r1.253 src/usr.bin/make/compat.c
cvs rdiff -u -r1.465 -r1.466 src/usr.bin/make/job.c
cvs rdiff -u -r1.610 -r1.611 src/usr.bin/make/main.c
cvs rdiff -u -r1.327 -r1.328 src/usr.bin/make/make.h
cvs rdiff -u -r1.1099 -r1.1100 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

2024-02-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Feb  7 07:21:22 UTC 2024

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

Log Message:
make: remove redundant comments

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.361 -r1.362 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.361 src/usr.bin/make/cond.c:1.362
--- src/usr.bin/make/cond.c:1.361	Sun Jan 21 16:32:41 2024
+++ src/usr.bin/make/cond.c	Wed Feb  7 07:21:22 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.361 2024/01/21 16:32:41 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.362 2024/02/07 07:21:22 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -91,7 +91,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.361 2024/01/21 16:32:41 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.362 2024/02/07 07:21:22 rillig Exp $");
 
 /*
  * Conditional expressions conform to this grammar:
@@ -394,7 +394,7 @@ CondParser_StringExpr(CondParser *par, c
 {
 	VarEvalMode emode;
 	const char *p;
-	bool atStart;
+	bool atStart;		/* true means an expression outside quotes */
 
 	emode = doEval && quoted ? VARE_WANTRES
 	: doEval ? VARE_UNDEFERR
@@ -411,11 +411,6 @@ CondParser_StringExpr(CondParser *par, c
 	}
 	par->p = p;
 
-	/*
-	 * If the '$' started the string literal (which means no quotes), and
-	 * the expression is followed by a space, a comparison operator or
-	 * the end of the expression, we are done.
-	 */
 	if (atStart && is_separator(par->p[0]))
 		return false;
 
@@ -509,26 +504,12 @@ EvalTruthy(CondParser *par, const char *
 {
 	double num;
 
-	/* For .ifxxx "...", check for non-empty string. */
 	if (quoted)
 		return value[0] != '\0';
-
-	/* For .ifxxx , compare against zero */
 	if (TryParseNumber(value, ))
 		return num != 0.0;
-
-	/*
-	 * For .if ${...}, check for non-empty string.  This is different
-	 * from the evaluation function from that .if variant, which would
-	 * test whether a variable of the given name were defined.
-	 */
-	/*
-	 * XXX: Whitespace should count as empty, just as in
-	 * CondParser_FuncCallEmpty.
-	 */
 	if (par->plain)
 		return value[0] != '\0';
-
 	return par->evalBare(value) != par->negateEvalBare;
 }
 



CVS commit: src/usr.bin/make

2024-02-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Feb  7 07:21:22 UTC 2024

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

Log Message:
make: remove redundant comments

No functional change.


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

2024-02-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Feb  7 06:43:02 UTC 2024

Modified Files:
src/usr.bin/make: arch.c config.h main.c parse.c suff.c var.c

Log Message:
make: remove unneeded conditional-compilation toggles

The toggles INCLUDES, LIBRARIES, POSIX, SYSVINCLUDE, SYSVVARSUB,
GMAKEEXPORT and SUNSHCMD are no longer needed, they were unconditionally
set.

The toggle NO_REGEX was configurable from the command line, but
disabling it would result in various error messages about the unknown
':C' modifier.

OK sjg@.


To generate a diff of this commit:
cvs rdiff -u -r1.214 -r1.215 src/usr.bin/make/arch.c
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/make/config.h
cvs rdiff -u -r1.609 -r1.610 src/usr.bin/make/main.c
cvs rdiff -u -r1.716 -r1.717 src/usr.bin/make/parse.c
cvs rdiff -u -r1.377 -r1.378 src/usr.bin/make/suff.c
cvs rdiff -u -r1.1098 -r1.1099 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/arch.c
diff -u src/usr.bin/make/arch.c:1.214 src/usr.bin/make/arch.c:1.215
--- src/usr.bin/make/arch.c:1.214	Sun Nov 19 22:50:11 2023
+++ src/usr.bin/make/arch.c	Wed Feb  7 06:43:02 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.214 2023/11/19 22:50:11 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.215 2024/02/07 06:43:02 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
 #include "config.h"
 
 /*	"@(#)arch.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: arch.c,v 1.214 2023/11/19 22:50:11 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.215 2024/02/07 06:43:02 rillig Exp $");
 
 typedef struct List ArchList;
 typedef struct ListNode ArchListNode;
@@ -978,11 +978,7 @@ Arch_FindLib(GNode *gn, SearchPath *path
 	gn->path = Dir_FindFile(libName, path);
 	free(libName);
 
-#ifdef LIBRARIES
 	Var_Set(gn, TARGET, gn->name);
-#else
-	Var_Set(gn, TARGET, GNode_Path(gn));
-#endif
 }
 
 /* ARGSUSED */

Index: src/usr.bin/make/config.h
diff -u src/usr.bin/make/config.h:1.28 src/usr.bin/make/config.h:1.29
--- src/usr.bin/make/config.h:1.28	Fri Dec 11 22:53:08 2020
+++ src/usr.bin/make/config.h	Wed Feb  7 06:43:02 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: config.h,v 1.28 2020/12/11 22:53:08 rillig Exp $	*/
+/*	$NetBSD: config.h,v 1.29 2024/02/07 06:43:02 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -73,20 +73,6 @@
  */
 
 /*
- * INCLUDES
- * LIBRARIES
- *	These control the handling of the .INCLUDES and .LIBS variables.
- *
- *	If INCLUDES is defined, the .INCLUDES variable will be filled
- *	from the search paths of those suffixes which are marked by
- *	.INCLUDES dependency lines. Similarly for LIBRARIES and .LIBS.
- *
- *	See varname-dot-include.mk and varname-dot-libs.mk for more details.
- */
-#define INCLUDES
-#define LIBRARIES
-
-/*
  * LIBSUFF
  *	Is the suffix used to denote libraries and is used by the Suff module
  *	to find the search path on which to seek any -l targets.
@@ -108,40 +94,6 @@
  */
 #define RECHECK
 
-/*
- * POSIX
- *	Adhere to the POSIX 1003.2 draft for the make(1) program.
- *	- Use MAKEFLAGS instead of MAKE to pick arguments from the
- *	  environment.
- */
-#define POSIX
-
-/*
- * SYSVINCLUDE
- *	Recognize system V like include directives [include "filename"]
- *	(required by POSIX 2018)
- * SYSVVARSUB
- *	Recognize system V like ${VAR:x=y} variable substitutions
- *	(required by POSIX 2018)
- */
-#define SYSVINCLUDE
-#define SYSVVARSUB
-
-/*
- * GMAKEEXPORT
- *	Recognize gmake like variable export directives [export =]
- */
-#define GMAKEEXPORT
-
-/*
- * SUNSHCMD
- *	Recognize SunOS and Solaris:
- *		VAR :sh= CMD	# Assign VAR to the command substitution of CMD
- *		${VAR:sh}	# Return the command substitution of the value
- *# of ${VAR}
- */
-#define SUNSHCMD
-
 #if defined(MAKE_NATIVE) && !defined(__ELF__)
 # ifndef RANLIBMAG
 #  define RANLIBMAG "__.SYMDEF"

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.609 src/usr.bin/make/main.c:1.610
--- src/usr.bin/make/main.c:1.609	Sun Jan  7 01:33:57 2024
+++ src/usr.bin/make/main.c	Wed Feb  7 06:43:02 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.609 2024/01/07 01:33:57 sjg Exp $	*/
+/*	$NetBSD: main.c,v 1.610 2024/02/07 06:43:02 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.609 2024/01/07 01:33:57 sjg Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.610 2024/02/07 06:43:02 rillig Exp $");
 #if defined(MAKE_NATIVE)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	"The Regents of the University of California.  "
@@ -1418,20 +1418,11 @@ main_Init(int argc, char **argv)
 #endif
 	Dir_Init();
 
-#ifdef POSIX
 	{
 		char *makeflags = explode(getenv("MAKEFLAGS"));
 		Main_ParseArgLine(makeflags);
 		free(makeflags);
 	}
-#else
-	/*
-	 * First snag any flags out of the MAKE 

CVS commit: src/usr.bin/make

2024-02-06 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Feb  7 06:43:02 UTC 2024

Modified Files:
src/usr.bin/make: arch.c config.h main.c parse.c suff.c var.c

Log Message:
make: remove unneeded conditional-compilation toggles

The toggles INCLUDES, LIBRARIES, POSIX, SYSVINCLUDE, SYSVVARSUB,
GMAKEEXPORT and SUNSHCMD are no longer needed, they were unconditionally
set.

The toggle NO_REGEX was configurable from the command line, but
disabling it would result in various error messages about the unknown
':C' modifier.

OK sjg@.


To generate a diff of this commit:
cvs rdiff -u -r1.214 -r1.215 src/usr.bin/make/arch.c
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/make/config.h
cvs rdiff -u -r1.609 -r1.610 src/usr.bin/make/main.c
cvs rdiff -u -r1.716 -r1.717 src/usr.bin/make/parse.c
cvs rdiff -u -r1.377 -r1.378 src/usr.bin/make/suff.c
cvs rdiff -u -r1.1098 -r1.1099 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

2024-02-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb  4 10:03:10 UTC 2024

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

Log Message:
make: do not evaluate indirect modifiers in parse-only mode

Discovered by sjg.


To generate a diff of this commit:
cvs rdiff -u -r1.1097 -r1.1098 src/usr.bin/make/var.c
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/make/unit-tests/varmod-indirect.exp
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/varmod-indirect.mk

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.1097 src/usr.bin/make/var.c:1.1098
--- src/usr.bin/make/var.c:1.1097	Sun Feb  4 09:56:24 2024
+++ src/usr.bin/make/var.c	Sun Feb  4 10:03:10 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1097 2024/02/04 09:56:24 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.1098 2024/02/04 10:03:10 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1097 2024/02/04 09:56:24 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1098 2024/02/04 10:03:10 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -3863,7 +3863,7 @@ ApplyModifiersIndirect(ModChain *ch, con
 	DEBUG3(VAR, "Indirect modifier \"%s\" from \"%.*s\"\n",
 	mods.str, (int)(p - *pp), *pp);
 
-	if (mods.str[0] != '\0') {
+	if (ModChain_ShouldEval(ch) && mods.str[0] != '\0') {
 		const char *modsp = mods.str;
 		ApplyModifiers(expr, , '\0', '\0');
 		if (Expr_Str(expr) == var_Error || *modsp != '\0') {

Index: src/usr.bin/make/unit-tests/varmod-indirect.exp
diff -u src/usr.bin/make/unit-tests/varmod-indirect.exp:1.26 src/usr.bin/make/unit-tests/varmod-indirect.exp:1.27
--- src/usr.bin/make/unit-tests/varmod-indirect.exp:1.26	Sun Feb  4 09:56:24 2024
+++ src/usr.bin/make/unit-tests/varmod-indirect.exp	Sun Feb  4 10:03:10 2024
@@ -38,12 +38,6 @@ Parsing line 197: .MAKEFLAGS: -d0
 ParseDependency(.MAKEFLAGS: -d0)
 Global: .MAKEFLAGS =  -r -k -d 0 -d pv -d
 Global: .MAKEFLAGS =  -r -k -d 0 -d pv -d 0
-make: "varmod-indirect.mk" line 275: Unknown modifier "Z"
-make: "varmod-indirect.mk" line 275: Malformed conditional (0 && ${VAR:${M_invalid}})
-make: "varmod-indirect.mk" line 282: Unknown modifier "Z"
-make: "varmod-indirect.mk" line 282: Malformed conditional (0 && ${VAR:${M_invalid:S,^,N*,:ts:}})
-make: "varmod-indirect.mk" line 288: Unknown modifier "Z"
-make: "varmod-indirect.mk" line 288: Malformed conditional (0 && ${VAR:${M_invalid:@m@N*$m@:ts:}})
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-indirect.mk
diff -u src/usr.bin/make/unit-tests/varmod-indirect.mk:1.17 src/usr.bin/make/unit-tests/varmod-indirect.mk:1.18
--- src/usr.bin/make/unit-tests/varmod-indirect.mk:1.17	Sun Feb  4 09:56:24 2024
+++ src/usr.bin/make/unit-tests/varmod-indirect.mk	Sun Feb  4 10:03:10 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-indirect.mk,v 1.17 2024/02/04 09:56:24 rillig Exp $
+# $NetBSD: varmod-indirect.mk,v 1.18 2024/02/04 10:03:10 rillig Exp $
 #
 # Tests for indirect variable modifiers, such as in ${VAR:${M_modifiers}}.
 # These can be used for very basic purposes like converting a string to either
@@ -258,7 +258,7 @@ _:=	before ${UNDEF:${:UZ}} after
 
 # In parse-only mode, the indirect modifiers must not be evaluated.
 #
-# Before var.c TODO from 2024-02-04, the expression for an indirect modifier
+# Before var.c 1.1098 from 2024-02-04, the expression for an indirect modifier
 # was partially evaluated (only the variable value, without applying any
 # modifiers) and then interpreted as modifiers to the main expression.
 #
@@ -270,20 +270,13 @@ _:=	before ${UNDEF:${:UZ}} after
 # The expression ${M_invalid} starts with the value "Z", which is an unknown
 # modifier.  Trying to apply this unknown modifier generated a warning.
 M_invalid=	Z
-# expect+2: Unknown modifier "Z"
-# expect+1: Malformed conditional (0 && ${VAR:${M_invalid}})
 .if 0 && ${VAR:${M_invalid}}
 .endif
-# The expression ${M_invalid} starts with the value "Z", and if its modifiers
-# were evaluated, would result in "N*Z", which is a valid modifier.  The
-# modifiers were not applied though, keeping the invalid value "Z".
-# expect+2: Unknown modifier "Z"
-# expect+1: Malformed conditional (0 && ${VAR:${M_invalid:S,^,N*,:ts:}})
+# The ':S' modifier does not change the expression value in parse-only mode,
+# keeping the "Z", which is then skipped in parse-only mode.
 .if 0 && ${VAR:${M_invalid:S,^,N*,:ts:}}
 .endif
 # The ':@' modifier does not change the expression value in parse-only mode,
-# keeping the "Z".
-# expect+2: Unknown modifier "Z"
-# expect+1: Malformed conditional (0 && ${VAR:${M_invalid:@m@N*$m@:ts:}})
+# keeping the 

CVS commit: src/usr.bin/make

2024-02-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb  4 10:03:10 UTC 2024

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

Log Message:
make: do not evaluate indirect modifiers in parse-only mode

Discovered by sjg.


To generate a diff of this commit:
cvs rdiff -u -r1.1097 -r1.1098 src/usr.bin/make/var.c
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/make/unit-tests/varmod-indirect.exp
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/varmod-indirect.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

2024-02-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb  4 09:56:24 UTC 2024

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

Log Message:
make: in parse-only mode, don't evaluate modifiers

Previously, the ':S', ':ts', ':tA' and ':from=to' modifiers were
evaluated in parse-only mode, unnecessarily.  This is only noticeable
when an indirect modifier is evaluated in parse-only mode, which is
another bug that will be fixed in a follow-up commit.


To generate a diff of this commit:
cvs rdiff -u -r1.1096 -r1.1097 src/usr.bin/make/var.c
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/make/unit-tests/varmod-indirect.exp
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varmod-indirect.mk

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.1096 src/usr.bin/make/var.c:1.1097
--- src/usr.bin/make/var.c:1.1096	Sat Feb  3 00:20:23 2024
+++ src/usr.bin/make/var.c	Sun Feb  4 09:56:24 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1096 2024/02/03 00:20:23 sjg Exp $	*/
+/*	$NetBSD: var.c,v 1.1097 2024/02/04 09:56:24 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1096 2024/02/03 00:20:23 sjg Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1097 2024/02/04 09:56:24 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -2274,6 +2274,9 @@ ModifyWords(ModChain *ch,
 	size_t i;
 	Substring word;
 
+	if (!ModChain_ShouldEval(ch))
+		return;
+
 	if (oneBigWord) {
 		SepBuf_Init(, ch->sep);
 		/* XXX: performance: Substring_InitStr calls strlen */
@@ -2806,8 +2809,7 @@ ApplyModifier_Mtime(const char **pp, Mod
 			goto invalid_argument;
 		*pp = p;
 	}
-	if (ModChain_ShouldEval(ch))
-		ModifyWords(ch, ModifyWord_Mtime, , ch->oneBigWord);
+	ModifyWords(ch, ModifyWord_Mtime, , ch->oneBigWord);
 	return args.rc;
 
 invalid_argument:
@@ -3552,8 +3554,7 @@ ApplyModifier_WordFunc(const char **pp, 
 		return AMR_UNKNOWN;
 	(*pp)++;
 
-	if (ModChain_ShouldEval(ch))
-		ModifyWords(ch, modifyWord, NULL, ch->oneBigWord);
+	ModifyWords(ch, modifyWord, NULL, ch->oneBigWord);
 
 	return AMR_OK;
 }

Index: src/usr.bin/make/unit-tests/varmod-indirect.exp
diff -u src/usr.bin/make/unit-tests/varmod-indirect.exp:1.25 src/usr.bin/make/unit-tests/varmod-indirect.exp:1.26
--- src/usr.bin/make/unit-tests/varmod-indirect.exp:1.25	Sun Feb  4 09:29:50 2024
+++ src/usr.bin/make/unit-tests/varmod-indirect.exp	Sun Feb  4 09:56:24 2024
@@ -40,8 +40,10 @@ Global: .MAKEFLAGS =  -r -k -d 0 -d pv -
 Global: .MAKEFLAGS =  -r -k -d 0 -d pv -d 0
 make: "varmod-indirect.mk" line 275: Unknown modifier "Z"
 make: "varmod-indirect.mk" line 275: Malformed conditional (0 && ${VAR:${M_invalid}})
-make: "varmod-indirect.mk" line 287: Unknown modifier "Z"
-make: "varmod-indirect.mk" line 287: Malformed conditional (0 && ${VAR:${M_invalid:@m@N*$m@:ts:}})
+make: "varmod-indirect.mk" line 282: Unknown modifier "Z"
+make: "varmod-indirect.mk" line 282: Malformed conditional (0 && ${VAR:${M_invalid:S,^,N*,:ts:}})
+make: "varmod-indirect.mk" line 288: Unknown modifier "Z"
+make: "varmod-indirect.mk" line 288: Malformed conditional (0 && ${VAR:${M_invalid:@m@N*$m@:ts:}})
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-indirect.mk
diff -u src/usr.bin/make/unit-tests/varmod-indirect.mk:1.16 src/usr.bin/make/unit-tests/varmod-indirect.mk:1.17
--- src/usr.bin/make/unit-tests/varmod-indirect.mk:1.16	Sun Feb  4 09:29:50 2024
+++ src/usr.bin/make/unit-tests/varmod-indirect.mk	Sun Feb  4 09:56:24 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-indirect.mk,v 1.16 2024/02/04 09:29:50 rillig Exp $
+# $NetBSD: varmod-indirect.mk,v 1.17 2024/02/04 09:56:24 rillig Exp $
 #
 # Tests for indirect variable modifiers, such as in ${VAR:${M_modifiers}}.
 # These can be used for very basic purposes like converting a string to either
@@ -258,7 +258,7 @@ _:=	before ${UNDEF:${:UZ}} after
 
 # In parse-only mode, the indirect modifiers must not be evaluated.
 #
-# Before var.c 1.1097 from 2024-02-04, the expression for an indirect modifier
+# Before var.c TODO from 2024-02-04, the expression for an indirect modifier
 # was partially evaluated (only the variable value, without applying any
 # modifiers) and then interpreted as modifiers to the main expression.
 #
@@ -277,7 +277,8 @@ M_invalid=	Z
 # The expression ${M_invalid} starts with the value "Z", and if its modifiers
 # were evaluated, would result in "N*Z", which is a valid modifier.  The
 # modifiers were not applied though, keeping the invalid value "Z".
-# FIXME: As of var.c 1.1096, the modifier ':S' _is_ actually evaluated.
+# expect+2: Unknown modifier "Z"
+# expect+1: Malformed 

CVS commit: src/usr.bin/make

2024-02-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb  4 09:56:24 UTC 2024

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

Log Message:
make: in parse-only mode, don't evaluate modifiers

Previously, the ':S', ':ts', ':tA' and ':from=to' modifiers were
evaluated in parse-only mode, unnecessarily.  This is only noticeable
when an indirect modifier is evaluated in parse-only mode, which is
another bug that will be fixed in a follow-up commit.


To generate a diff of this commit:
cvs rdiff -u -r1.1096 -r1.1097 src/usr.bin/make/var.c
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/make/unit-tests/varmod-indirect.exp
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varmod-indirect.mk

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



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

2024-02-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb  4 09:29:50 UTC 2024

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

Log Message:
tests/make: extend test for wrong evaluation in parse-only mode


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/make/unit-tests/varmod-indirect.exp
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/varmod-indirect.mk

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

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-indirect.exp
diff -u src/usr.bin/make/unit-tests/varmod-indirect.exp:1.24 src/usr.bin/make/unit-tests/varmod-indirect.exp:1.25
--- src/usr.bin/make/unit-tests/varmod-indirect.exp:1.24	Sun Feb  4 08:51:57 2024
+++ src/usr.bin/make/unit-tests/varmod-indirect.exp	Sun Feb  4 09:29:50 2024
@@ -38,8 +38,10 @@ Parsing line 197: .MAKEFLAGS: -d0
 ParseDependency(.MAKEFLAGS: -d0)
 Global: .MAKEFLAGS =  -r -k -d 0 -d pv -d
 Global: .MAKEFLAGS =  -r -k -d 0 -d pv -d 0
-make: "varmod-indirect.mk" line 274: Unknown modifier "Z"
-make: "varmod-indirect.mk" line 274: Malformed conditional (0 && ${VAR:${M_invalid}})
+make: "varmod-indirect.mk" line 275: Unknown modifier "Z"
+make: "varmod-indirect.mk" line 275: Malformed conditional (0 && ${VAR:${M_invalid}})
+make: "varmod-indirect.mk" line 287: Unknown modifier "Z"
+make: "varmod-indirect.mk" line 287: Malformed conditional (0 && ${VAR:${M_invalid:@m@N*$m@:ts:}})
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-indirect.mk
diff -u src/usr.bin/make/unit-tests/varmod-indirect.mk:1.15 src/usr.bin/make/unit-tests/varmod-indirect.mk:1.16
--- src/usr.bin/make/unit-tests/varmod-indirect.mk:1.15	Sun Feb  4 08:51:57 2024
+++ src/usr.bin/make/unit-tests/varmod-indirect.mk	Sun Feb  4 09:29:50 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-indirect.mk,v 1.15 2024/02/04 08:51:57 rillig Exp $
+# $NetBSD: varmod-indirect.mk,v 1.16 2024/02/04 09:29:50 rillig Exp $
 #
 # Tests for indirect variable modifiers, such as in ${VAR:${M_modifiers}}.
 # These can be used for very basic purposes like converting a string to either
@@ -258,8 +258,9 @@ _:=	before ${UNDEF:${:UZ}} after
 
 # In parse-only mode, the indirect modifiers must not be evaluated.
 #
-# Before var.c 1.1096 from 2024-02-04, the expression for an indirect modifier
-# was evaluated.
+# Before var.c 1.1097 from 2024-02-04, the expression for an indirect modifier
+# was partially evaluated (only the variable value, without applying any
+# modifiers) and then interpreted as modifiers to the main expression.
 #
 # The expression ${:UZ} starts with the value "", and in parse-only mode, the
 # modifier ':UZ' does not modify the expression value.  This results in an
@@ -273,3 +274,15 @@ M_invalid=	Z
 # expect+1: Malformed conditional (0 && ${VAR:${M_invalid}})
 .if 0 && ${VAR:${M_invalid}}
 .endif
+# The expression ${M_invalid} starts with the value "Z", and if its modifiers
+# were evaluated, would result in "N*Z", which is a valid modifier.  The
+# modifiers were not applied though, keeping the invalid value "Z".
+# FIXME: As of var.c 1.1096, the modifier ':S' _is_ actually evaluated.
+.if 0 && ${VAR:${M_invalid:S,^,N*,:ts:}}
+.endif
+# The ':@' modifier does not change the expression value in parse-only mode,
+# keeping the "Z".
+# expect+2: Unknown modifier "Z"
+# expect+1: Malformed conditional (0 && ${VAR:${M_invalid:@m@N*$m@:ts:}})
+.if 0 && ${VAR:${M_invalid:@m@N*$m@:ts:}}
+.endif



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

2024-02-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb  4 09:29:50 UTC 2024

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

Log Message:
tests/make: extend test for wrong evaluation in parse-only mode


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/make/unit-tests/varmod-indirect.exp
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/varmod-indirect.mk

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



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

2024-02-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb  4 08:51:57 UTC 2024

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

Log Message:
tests/make: indirect modifiers are evaluated in parse-only mode

Found by sjg@.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/varmod-indirect.exp
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/varmod-indirect.mk

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

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-indirect.exp
diff -u src/usr.bin/make/unit-tests/varmod-indirect.exp:1.23 src/usr.bin/make/unit-tests/varmod-indirect.exp:1.24
--- src/usr.bin/make/unit-tests/varmod-indirect.exp:1.23	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/varmod-indirect.exp	Sun Feb  4 08:51:57 2024
@@ -38,6 +38,8 @@ Parsing line 197: .MAKEFLAGS: -d0
 ParseDependency(.MAKEFLAGS: -d0)
 Global: .MAKEFLAGS =  -r -k -d 0 -d pv -d
 Global: .MAKEFLAGS =  -r -k -d 0 -d pv -d 0
+make: "varmod-indirect.mk" line 274: Unknown modifier "Z"
+make: "varmod-indirect.mk" line 274: Malformed conditional (0 && ${VAR:${M_invalid}})
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod-indirect.mk
diff -u src/usr.bin/make/unit-tests/varmod-indirect.mk:1.14 src/usr.bin/make/unit-tests/varmod-indirect.mk:1.15
--- src/usr.bin/make/unit-tests/varmod-indirect.mk:1.14	Sun Nov 19 22:32:44 2023
+++ src/usr.bin/make/unit-tests/varmod-indirect.mk	Sun Feb  4 08:51:57 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-indirect.mk,v 1.14 2023/11/19 22:32:44 rillig Exp $
+# $NetBSD: varmod-indirect.mk,v 1.15 2024/02/04 08:51:57 rillig Exp $
 #
 # Tests for indirect variable modifiers, such as in ${VAR:${M_modifiers}}.
 # These can be used for very basic purposes like converting a string to either
@@ -255,4 +255,21 @@ _:=	before ${UNDEF:${:UZ}} after
 .  error
 .endif
 
-all:
+
+# In parse-only mode, the indirect modifiers must not be evaluated.
+#
+# Before var.c 1.1096 from 2024-02-04, the expression for an indirect modifier
+# was evaluated.
+#
+# The expression ${:UZ} starts with the value "", and in parse-only mode, the
+# modifier ':UZ' does not modify the expression value.  This results in an
+# empty string for the indirect modifiers, generating no warning.
+.if 0 && ${VAR:${:UZ}}
+.endif
+# The expression ${M_invalid} starts with the value "Z", which is an unknown
+# modifier.  Trying to apply this unknown modifier generated a warning.
+M_invalid=	Z
+# expect+2: Unknown modifier "Z"
+# expect+1: Malformed conditional (0 && ${VAR:${M_invalid}})
+.if 0 && ${VAR:${M_invalid}}
+.endif



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

2024-02-04 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Feb  4 08:51:57 UTC 2024

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

Log Message:
tests/make: indirect modifiers are evaluated in parse-only mode

Found by sjg@.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/varmod-indirect.exp
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/varmod-indirect.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

2024-02-02 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sat Feb  3 00:20:23 UTC 2024

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

Log Message:
make: state of save_dollars affects what is a parse error

When save_dollars is false it is not a parse error to
encounter $$ rather than \$.


To generate a diff of this commit:
cvs rdiff -u -r1.1095 -r1.1096 src/usr.bin/make/var.c
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod.exp
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/varmod.mk

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.1095 src/usr.bin/make/var.c:1.1096
--- src/usr.bin/make/var.c:1.1095	Sun Jan 21 15:02:17 2024
+++ src/usr.bin/make/var.c	Sat Feb  3 00:20:23 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1095 2024/01/21 15:02:17 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.1096 2024/02/03 00:20:23 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1095 2024/01/21 15:02:17 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1096 2024/02/03 00:20:23 sjg Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -4147,12 +4147,12 @@ IsShortVarnameValid(char varname, const 
 	if (!opts.strict)
 		return false;	/* XXX: Missing error message */
 
-	if (varname == '$')
+	if (varname == '$' && save_dollars)
 		Parse_Error(PARSE_FATAL,
 		"To escape a dollar, use \\$, not $$, at \"%s\"", start);
 	else if (varname == '\0')
 		Parse_Error(PARSE_FATAL, "Dollar followed by nothing");
-	else
+	else if (save_dollars)
 		Parse_Error(PARSE_FATAL,
 		"Invalid variable name '%c', at \"%s\"", varname, start);
 

Index: src/usr.bin/make/unit-tests/varmod.exp
diff -u src/usr.bin/make/unit-tests/varmod.exp:1.7 src/usr.bin/make/unit-tests/varmod.exp:1.8
--- src/usr.bin/make/unit-tests/varmod.exp:1.7	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/varmod.exp	Sat Feb  3 00:20:23 2024
@@ -1,8 +1,8 @@
-make: "varmod.mk" line 98: To escape a dollar, use \$, not $$, at "$$:L} != """
-make: "varmod.mk" line 98: Invalid variable name ':', at "$:L} != """
-make: "varmod.mk" line 104: Dollar followed by nothing
-make: "varmod.mk" line 114: Missing delimiter ':' after modifier "P"
-make: "varmod.mk" line 116: Missing argument for ".error"
+make: "varmod.mk" line 101: To escape a dollar, use \$, not $$, at "$$:L} != """
+make: "varmod.mk" line 101: Invalid variable name ':', at "$:L} != """
+make: "varmod.mk" line 107: Dollar followed by nothing
+make: "varmod.mk" line 117: Missing delimiter ':' after modifier "P"
+make: "varmod.mk" line 119: Missing argument for ".error"
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/varmod.mk
diff -u src/usr.bin/make/unit-tests/varmod.mk:1.9 src/usr.bin/make/unit-tests/varmod.mk:1.10
--- src/usr.bin/make/unit-tests/varmod.mk:1.9	Sun Nov 19 21:47:52 2023
+++ src/usr.bin/make/unit-tests/varmod.mk	Sat Feb  3 00:20:23 2024
@@ -1,4 +1,4 @@
-# $NetBSD: varmod.mk,v 1.9 2023/11/19 21:47:52 rillig Exp $
+# $NetBSD: varmod.mk,v 1.10 2024/02/03 00:20:23 sjg Exp $
 #
 # Tests for variable modifiers, such as :Q, :S,from,to or :Ufallback.
 #
@@ -56,6 +56,9 @@
 # | `u`  | strict   || yes  |
 # | `from=to`| greedy   | SysV, fallback | N/A  |
 
+# These tests assume
+.MAKE.SAVE_DOLLARS = yes
+
 DOLLAR1=	$$
 DOLLAR2=	${:U\$}
 



CVS commit: src/usr.bin/make

2024-02-02 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sat Feb  3 00:20:23 UTC 2024

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

Log Message:
make: state of save_dollars affects what is a parse error

When save_dollars is false it is not a parse error to
encounter $$ rather than \$.


To generate a diff of this commit:
cvs rdiff -u -r1.1095 -r1.1096 src/usr.bin/make/var.c
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod.exp
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/varmod.mk

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



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

2024-01-25 Thread Simon Gerraty
On Thu, 25 Jan 2024 20:02:00 +0100, Roland Illig writes:
>>> Modified Files:
>>> src/usr.bin/make: make.1
>>>
>>> Log Message:
>>> Indicate that for :U newval is optional
>>
>> I think this is more confusing than helpful.
>
>I agree. Make doesn't distinguish between an empty string and an absent
>string here, so the wording in the manual page should be kept equally
>simple.

Not a question of what make likes or not, but what users glean from the
man page (those that don't also read the source).

The change was prompted by a user (not a make novice by any means)
complaining that :Unewval and the description provides no clue
that just :U is actually valid.

>If anything, you might mention that newval may be empty, but then you'd

I think I started with that, but then figured someone sufficiently
pedantic might consider that not the same as no value being provided ;-)

>have to add the same wording in many other places, for consistency:

>* the variable name in ${:Uvalue}

This is covered by the above no?

>* the two branches of the ':?' modifier in ${cond:?}

true

>* the pattern matching modifiers after ':S,from,to' (1gW)
>* the variable name in the variable assignment '!=3Dcmd'
>* the argument of a function call in '.if defined()'
>
>Most of these cases don't need this wording, and the '!=3Dcmd' case

Agreed, the :S usage at least is sufficiently familiar to anyone who's
used sed(1) to not need elaboration.

Is there perhaps a general statement somewhere (I may have missed it)
that could cover all these and be cited to pedantic users?
Eg to the effect of perhaps, unless stated otherwise arguments to
modifiers are optional or can be empty.

I don't think its there and is hard to word succinctly.

Thanks
--sjg



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

2024-01-25 Thread Simon Gerraty
On Thu, 25 Jan 2024 21:12:20 +0100, Roland Illig writes:
>them all. Due to this, I'd go with:
>
>> .It Cm \&:U\| Ns Ar newval
>> If the variable is undefined,
>> .Ar newval
>> (which may be empty) is the value.

That's almost exactly what I had in my 1st cut ;-)
Will do.

>Then, add the same wording to ':D' and maybe to ':N' (since ':N' is a
>shortcut for the more common ':M*') but not to ':M' itself (as that
>would always result in an empty string, making it uninteresting).

Will take a look, but not so sure.

--sjg


CVS commit: src/usr.bin/make

2024-01-25 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Thu Jan 25 21:00:59 UTC 2024

Modified Files:
src/usr.bin/make: make.1

Log Message:
Note that in both :U and :D newval may be empty


To generate a diff of this commit:
cvs rdiff -u -r1.373 -r1.374 src/usr.bin/make/make.1

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.1
diff -u src/usr.bin/make/make.1:1.373 src/usr.bin/make/make.1:1.374
--- src/usr.bin/make/make.1:1.373	Thu Jan 25 07:35:46 2024
+++ src/usr.bin/make/make.1	Thu Jan 25 21:00:59 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: make.1,v 1.373 2024/01/25 07:35:46 sjg Exp $
+.\"	$NetBSD: make.1,v 1.374 2024/01/25 21:00:59 sjg Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -1772,11 +1772,11 @@ is used to save the result of the
 .Ql :S
 modifier which is later referenced using the index values from
 .Ql :range .
-.It Cm \&:U\| Ns Oo Ar newval Oc
+.It Cm \&:U\| Ns Ar newval
 If the variable is undefined,
 the optional
 .Ar newval
-is the value.
+(which may be empty) is the value.
 If the variable is defined, the existing value is returned.
 This is another ODE make feature.
 It is handy for setting per-target CFLAGS for instance:
@@ -1786,7 +1786,7 @@ If a value is only required if the varia
 .It Cm \&:D\| Ns Ar newval
 If the variable is defined,
 .Ar newval
-is the value.
+(which may be empty) is the value.
 .It Cm \&:L
 The name of the variable is the value.
 .It Cm \&:P



CVS commit: src/usr.bin/make

2024-01-25 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Thu Jan 25 21:00:59 UTC 2024

Modified Files:
src/usr.bin/make: make.1

Log Message:
Note that in both :U and :D newval may be empty


To generate a diff of this commit:
cvs rdiff -u -r1.373 -r1.374 src/usr.bin/make/make.1

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



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

2024-01-25 Thread Roland Illig
About optional arguments to modifiers, such as in ${VAR:U}:

Am 25.01.2024 um 20:54 schrieb Simon Gerraty:
> Is there perhaps a general statement somewhere (I may have missed it)
> that could cover all these and be cited to pedantic users?
> Eg to the effect of perhaps, unless stated otherwise arguments to
> modifiers are optional or can be empty.
>
> I don't think its there and is hard to word succinctly.

No, I searched through the manual page but didn't find one.

Also, there are so many syntactic quirks and edge cases in make that I
don't think there's an easy to grasp single-line statement that covers
them all. Due to this, I'd go with:

> .It Cm \&:U\| Ns Ar newval
> If the variable is undefined,
> .Ar newval
> (which may be empty) is the value.

Then, add the same wording to ':D' and maybe to ':N' (since ':N' is a
shortcut for the more common ':M*') but not to ':M' itself (as that
would always result in an empty string, making it uninteresting).

Roland



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

2024-01-25 Thread Roland Illig
Am 25.01.2024 um 14:25 schrieb Valery Ushakov:
> On Thu, Jan 25, 2024 at 07:35:46 +, Simon J. Gerraty wrote:
>
>> Modified Files:
>>  src/usr.bin/make: make.1
>>
>> Log Message:
>> Indicate that for :U newval is optional
>
> I think this is more confusing than helpful.

I agree. Make doesn't distinguish between an empty string and an absent
string here, so the wording in the manual page should be kept equally
simple.

If anything, you might mention that newval may be empty, but then you'd
have to add the same wording in many other places, for consistency:

* the variable name in ${:Uvalue}
* the two branches of the ':?' modifier in ${cond:?}
* the pattern matching modifiers after ':S,from,to' (1gW)
* the variable name in the variable assignment '!=cmd'
* the argument of a function call in '.if defined()'

Most of these cases don't need this wording, and the '!=cmd' case
shouldn't be documented at all, as it is a dirty hack.

Roland



CVS commit: src/usr.bin/make

2024-01-24 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Thu Jan 25 07:35:46 UTC 2024

Modified Files:
src/usr.bin/make: make.1

Log Message:
Indicate that for :U newval is optional


To generate a diff of this commit:
cvs rdiff -u -r1.372 -r1.373 src/usr.bin/make/make.1

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.1
diff -u src/usr.bin/make/make.1:1.372 src/usr.bin/make/make.1:1.373
--- src/usr.bin/make/make.1:1.372	Sun Dec 24 16:48:30 2023
+++ src/usr.bin/make/make.1	Thu Jan 25 07:35:46 2024
@@ -1,4 +1,4 @@
-.\"	$NetBSD: make.1,v 1.372 2023/12/24 16:48:30 sjg Exp $
+.\"	$NetBSD: make.1,v 1.373 2024/01/25 07:35:46 sjg Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	from: @(#)make.1	8.4 (Berkeley) 3/19/94
 .\"
-.Dd December 24, 2023
+.Dd January 24, 2024
 .Dt MAKE 1
 .Os
 .Sh NAME
@@ -1772,8 +1772,9 @@ is used to save the result of the
 .Ql :S
 modifier which is later referenced using the index values from
 .Ql :range .
-.It Cm \&:U\| Ns Ar newval
+.It Cm \&:U\| Ns Oo Ar newval Oc
 If the variable is undefined,
+the optional
 .Ar newval
 is the value.
 If the variable is defined, the existing value is returned.



CVS commit: src/usr.bin/make

2024-01-24 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Thu Jan 25 07:35:46 UTC 2024

Modified Files:
src/usr.bin/make: make.1

Log Message:
Indicate that for :U newval is optional


To generate a diff of this commit:
cvs rdiff -u -r1.372 -r1.373 src/usr.bin/make/make.1

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

2024-01-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 21 16:32:41 UTC 2024

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

Log Message:
make: refactor CondParser_Term to be inlinable

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.360 -r1.361 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.360 src/usr.bin/make/cond.c:1.361
--- src/usr.bin/make/cond.c:1.360	Sun Jan 21 15:22:55 2024
+++ src/usr.bin/make/cond.c	Sun Jan 21 16:32:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.360 2024/01/21 15:22:55 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.361 2024/01/21 16:32:41 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -91,7 +91,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.360 2024/01/21 15:22:55 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.361 2024/01/21 16:32:41 rillig Exp $");
 
 /*
  * Conditional expressions conform to this grammar:
@@ -867,12 +867,13 @@ CondParser_Term(CondParser *par, bool do
 {
 	CondResult res;
 	Token t;
+	bool neg = false;
 
-	t = CondParser_Token(par, doEval);
-	if (t == TOK_TRUE)
-		return CR_TRUE;
-	if (t == TOK_FALSE)
-		return CR_FALSE;
+	while ((t = CondParser_Token(par, doEval)) == TOK_NOT)
+		neg = !neg;
+
+	if (t == TOK_TRUE || t == TOK_FALSE)
+		return neg == (t == TOK_FALSE) ? CR_TRUE : CR_FALSE;
 
 	if (t == TOK_LPAREN) {
 		res = CondParser_Or(par, doEval);
@@ -880,16 +881,7 @@ CondParser_Term(CondParser *par, bool do
 			return CR_ERROR;
 		if (CondParser_Token(par, doEval) != TOK_RPAREN)
 			return CR_ERROR;
-		return res;
-	}
-
-	if (t == TOK_NOT) {
-		res = CondParser_Term(par, doEval);
-		if (res == CR_TRUE)
-			res = CR_FALSE;
-		else if (res == CR_FALSE)
-			res = CR_TRUE;
-		return res;
+		return neg == (res == CR_FALSE) ? CR_TRUE : CR_FALSE;
 	}
 
 	return CR_ERROR;



CVS commit: src/usr.bin/make

2024-01-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 21 16:32:41 UTC 2024

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

Log Message:
make: refactor CondParser_Term to be inlinable

No functional change.


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

2024-01-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 21 15:22:55 UTC 2024

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

Log Message:
make: clean up parsing of conditions

No functional change.


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

2024-01-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 21 15:22:55 UTC 2024

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

Log Message:
make: clean up parsing of conditions

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.359 -r1.360 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.359 src/usr.bin/make/cond.c:1.360
--- src/usr.bin/make/cond.c:1.359	Fri Dec 29 12:59:43 2023
+++ src/usr.bin/make/cond.c	Sun Jan 21 15:22:55 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.359 2023/12/29 12:59:43 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.360 2024/01/21 15:22:55 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -91,7 +91,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.359 2023/12/29 12:59:43 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.360 2024/01/21 15:22:55 rillig Exp $");
 
 /*
  * Conditional expressions conform to this grammar:
@@ -937,20 +937,6 @@ CondParser_Or(CondParser *par, bool doEv
 	return res;
 }
 
-static CondResult
-CondParser_Eval(CondParser *par)
-{
-	CondResult res;
-
-	DEBUG1(COND, "CondParser_Eval: %s\n", par->p);
-
-	res = CondParser_Or(par, true);
-	if (res != CR_ERROR && CondParser_Token(par, false) != TOK_EOF)
-		return CR_ERROR;
-
-	return res;
-}
-
 /*
  * Evaluate the condition, including any side effects from the
  * expressions in the condition. The condition consists of &&, ||, !,
@@ -974,7 +960,10 @@ CondEvalExpression(const char *cond, boo
 	par.curr = TOK_NONE;
 	par.printedError = false;
 
-	rval = CondParser_Eval();
+	DEBUG1(COND, "CondParser_Eval: %s\n", par.p);
+	rval = CondParser_Or(, true);
+	if (par.curr != TOK_EOF)
+		rval = CR_ERROR;
 
 	if (rval == CR_ERROR && eprint && !par.printedError)
 		Parse_Error(PARSE_FATAL, "Malformed conditional (%s)", cond);



CVS commit: src/usr.bin/make

2024-01-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 21 15:02:17 UTC 2024

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

Log Message:
make: clean up redundant 'const' from automatic variables

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.177 -r1.178 src/usr.bin/make/for.c
cvs rdiff -u -r1.1094 -r1.1095 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/for.c
diff -u src/usr.bin/make/for.c:1.177 src/usr.bin/make/for.c:1.178
--- src/usr.bin/make/for.c:1.177	Sun Nov 19 22:50:11 2023
+++ src/usr.bin/make/for.c	Sun Jan 21 15:02:17 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: for.c,v 1.177 2023/11/19 22:50:11 rillig Exp $	*/
+/*	$NetBSD: for.c,v 1.178 2024/01/21 15:02:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1992, The Regents of the University of California.
@@ -58,7 +58,7 @@
 #include "make.h"
 
 /*	"@(#)for.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: for.c,v 1.177 2023/11/19 22:50:11 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.178 2024/01/21 15:02:17 rillig Exp $");
 
 
 typedef struct ForLoop {
@@ -434,7 +434,7 @@ static void
 ForLoop_SubstVarShort(ForLoop *f, unsigned int firstItem, Buffer *body,
 		  const char *p, const char **inout_mark)
 {
-	const char ch = *p;
+	char ch = *p;
 	const char **vars;
 	size_t i;
 

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.1094 src/usr.bin/make/var.c:1.1095
--- src/usr.bin/make/var.c:1.1094	Sun Jan  7 11:39:04 2024
+++ src/usr.bin/make/var.c	Sun Jan 21 15:02:17 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1094 2024/01/07 11:39:04 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.1095 2024/01/21 15:02:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1094 2024/01/07 11:39:04 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1095 2024/01/21 15:02:17 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -4279,7 +4279,7 @@ ParseVarnameLong(
 	bool dynamic = false;
 
 	const char *p = *pp;
-	const char *const start = p;
+	const char *start = p;
 	char endc = startc == '(' ? ')' : '}';
 
 	p += 2;			/* skip "${" or "$(" or "y(" */



CVS commit: src/usr.bin/make

2024-01-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan 21 15:02:17 UTC 2024

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

Log Message:
make: clean up redundant 'const' from automatic variables

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.177 -r1.178 src/usr.bin/make/for.c
cvs rdiff -u -r1.1094 -r1.1095 src/usr.bin/make/var.c

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



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

2024-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan  7 11:42:22 UTC 2024

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

Log Message:
tests/make: test the '::=' modifier in target scope


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

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

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-assign.exp
diff -u src/usr.bin/make/unit-tests/varmod-assign.exp:1.18 src/usr.bin/make/unit-tests/varmod-assign.exp:1.19
--- src/usr.bin/make/unit-tests/varmod-assign.exp:1.18	Fri Dec 29 15:47:03 2023
+++ src/usr.bin/make/unit-tests/varmod-assign.exp	Sun Jan  7 11:42:22 2024
@@ -50,4 +50,11 @@ make: Unfinished modifier for "ASSIGN" (
 ok=word
 make: " echo word; false " returned non-zero status
 err=previous
+Command: TARGET_CMD_VAR = cmd-value
+Global: TARGET_GLOBAL_VAR = global-value
+target: TARGET_TARGET_VAR = target-value
+target: TARGET_TARGET_VAR = new-value
+Global: TARGET_GLOBAL_VAR = new-value
+Global: TARGET_ENV_VAR = new-value
+target: TARGET_NEW_VAR = new-value
 exit status 0
Index: src/usr.bin/make/unit-tests/varmod-assign.mk
diff -u src/usr.bin/make/unit-tests/varmod-assign.mk:1.18 src/usr.bin/make/unit-tests/varmod-assign.mk:1.19
--- src/usr.bin/make/unit-tests/varmod-assign.mk:1.18	Sun Dec 31 10:09:01 2023
+++ src/usr.bin/make/unit-tests/varmod-assign.mk	Sun Jan  7 11:42:22 2024
@@ -1,8 +1,10 @@
-# $NetBSD: varmod-assign.mk,v 1.18 2023/12/31 10:09:01 rillig Exp $
+# $NetBSD: varmod-assign.mk,v 1.19 2024/01/07 11:42:22 rillig Exp $
 #
 # Tests for the obscure ::= variable modifiers, which perform variable
 # assignments during evaluation, just like the = operator in C.
 
+.if !make(target)
+
 all:	mod-assign-empty
 all:	mod-assign-parse
 all:	mod-assign-shell-error
@@ -162,7 +164,6 @@ ${VARNAME}=	initial-value	# Sets 'VAR.${
 .MAKEFLAGS: CMD_CMD_VAR=cmd-value
 CMD_GLOBAL_VAR=global-value
 export CMD_ENV_VAR=env-value
-
 .MAKEFLAGS: -dv
 # expect-reset
 # expect: Command: CMD_CMD_VAR = new-value
@@ -178,23 +179,30 @@ export CMD_ENV_VAR=env-value
 .endif
 .MAKEFLAGS: -d0
 
+# Run the 'target' test in a separate sub-make, with reduced debug logging.
+all: run-target
+run-target: .PHONY
+	@${MAKE} -r -f ${MAKEFILE} -dv target 2>&1 | grep ': TARGET_'
 
-# In target scope, assignments only happen in a few cases.  To extract the
-# debug log for this test, the debug log would have to be enabled for the
-# other targets as well, thus producing lots of irrelevant output.
+.else # make(target)
+
+# The commands of a target are evaluated in target scope.  An assignment
+# modifier that creates a new variable creates it in the target scope.
+# Existing variables are updated in their previous scope, and environment
+# variables are created in the global scope, as in other situations.
 #
-# Running './make -r -f varmod-assign.mk target | grep ": TARGET"' results in:
-#	target: TARGET_TARGET_VAR = new-value
-#	Global: TARGET_GLOBAL_VAR = new-value
-#	Global: TARGET_ENV_VAR = new-value
-#	target: TARGET_NEW_VAR = new-value
+# expect: target: TARGET_TARGET_VAR = new-value
+# expect: Global: TARGET_GLOBAL_VAR = new-value
+# expect: Global: TARGET_ENV_VAR = new-value
+# expect: target: TARGET_NEW_VAR = new-value
 .MAKEFLAGS: TARGET_CMD_VAR=cmd-value
 TARGET_GLOBAL_VAR=global-value
 export TARGET_ENV_VAR=env-value
-.MAKEFLAGS: ${make(target):?-dv:}
 target: .PHONY TARGET_TARGET_VAR=target-value
 	: ${TARGET_TARGET_VAR::=new-value}
 	: ${TARGET_CMD_VAR::=new-value}
 	: ${TARGET_GLOBAL_VAR::=new-value}
 	: ${TARGET_ENV_VAR::=new-value}
 	: ${TARGET_NEW_VAR::=new-value}
+
+.endif



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

2024-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan  7 11:42:22 UTC 2024

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

Log Message:
tests/make: test the '::=' modifier in target scope


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/varmod-assign.exp \
src/usr.bin/make/unit-tests/varmod-assign.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

2024-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan  7 11:39:04 UTC 2024

Modified Files:
src/usr.bin/make: job.c parse.c var.c
src/usr.bin/make/unit-tests: varparse-undef-partial.mk

Log Message:
make: clean up comments, constify shell name


To generate a diff of this commit:
cvs rdiff -u -r1.464 -r1.465 src/usr.bin/make/job.c
cvs rdiff -u -r1.715 -r1.716 src/usr.bin/make/parse.c
cvs rdiff -u -r1.1093 -r1.1094 src/usr.bin/make/var.c
cvs rdiff -u -r1.4 -r1.5 \
src/usr.bin/make/unit-tests/varparse-undef-partial.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

2024-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Jan  7 11:39:04 UTC 2024

Modified Files:
src/usr.bin/make: job.c parse.c var.c
src/usr.bin/make/unit-tests: varparse-undef-partial.mk

Log Message:
make: clean up comments, constify shell name


To generate a diff of this commit:
cvs rdiff -u -r1.464 -r1.465 src/usr.bin/make/job.c
cvs rdiff -u -r1.715 -r1.716 src/usr.bin/make/parse.c
cvs rdiff -u -r1.1093 -r1.1094 src/usr.bin/make/var.c
cvs rdiff -u -r1.4 -r1.5 \
src/usr.bin/make/unit-tests/varparse-undef-partial.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/job.c
diff -u src/usr.bin/make/job.c:1.464 src/usr.bin/make/job.c:1.465
--- src/usr.bin/make/job.c:1.464	Sun Jan  7 01:33:57 2024
+++ src/usr.bin/make/job.c	Sun Jan  7 11:39:04 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.464 2024/01/07 01:33:57 sjg Exp $	*/
+/*	$NetBSD: job.c,v 1.465 2024/01/07 11:39:04 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -141,7 +141,7 @@
 #include "trace.h"
 
 /*	"@(#)job.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: job.c,v 1.464 2024/01/07 01:33:57 sjg Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.465 2024/01/07 11:39:04 rillig Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -2474,16 +2474,9 @@ Job_ParseShell(char *line)
 			}
 		}
 	} else {
-		/*
-		 * The user provided a path. If s/he gave nothing else
-		 * (fullSpec is false), try and find a matching shell in the
-		 * ones we know of. Else we just take the specification at
-		 * its word and copy it to a new location. In either case,
-		 * we need to record the path the user gave for the shell.
-		 */
-		char *name = path + (str_basename(path) - path);
 		shellPath = path;
-		shellName = newShell.name != NULL ? newShell.name : name;
+		shellName = newShell.name != NULL ? newShell.name
+		: str_basename(path);
 		if (!fullSpec) {
 			if ((sh = FindShellByName(shellName)) == NULL) {
 Parse_Error(PARSE_WARNING,

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.715 src/usr.bin/make/parse.c:1.716
--- src/usr.bin/make/parse.c:1.715	Fri Jan  5 23:22:06 2024
+++ src/usr.bin/make/parse.c	Sun Jan  7 11:39:04 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.715 2024/01/05 23:22:06 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.716 2024/01/07 11:39:04 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -105,7 +105,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.715 2024/01/05 23:22:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.716 2024/01/07 11:39:04 rillig Exp $");
 
 /* Detects a multiple-inclusion guard in a makefile. */
 typedef enum {
@@ -115,9 +115,7 @@ typedef enum {
 	GS_NO			/* the file is not guarded */
 } GuardState;
 
-/*
- * A file being read.
- */
+/* A file being parsed. */
 typedef struct IncludedFile {
 	FStr name;		/* absolute or relative to the cwd */
 	unsigned lineno;	/* 1-based */
@@ -2901,13 +2899,6 @@ ParseDependencyLine(char *line)
 static void
 ParseLine(char *line)
 {
-	/*
-	 * Lines that begin with '.' can be pretty much anything:
-	 *	- directives like '.include' or '.if',
-	 *	- suffix rules like '.c.o:',
-	 *	- dependencies for filenames that start with '.',
-	 *	- variable assignments like '.tmp=value'.
-	 */
 	if (line[0] == '.' && ParseDirective(line))
 		return;
 

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.1093 src/usr.bin/make/var.c:1.1094
--- src/usr.bin/make/var.c:1.1093	Fri Jan  5 23:22:06 2024
+++ src/usr.bin/make/var.c	Sun Jan  7 11:39:04 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1093 2024/01/05 23:22:06 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.1094 2024/01/07 11:39:04 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1093 2024/01/05 23:22:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1094 2024/01/07 11:39:04 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -1859,15 +1859,15 @@ FormatTime(const char *fmt, time_t t, bo
  * Some modifiers such as ':sh' or '::=' have noticeable side effects though.
  *
  * Evaluating the modifier usually takes the current value of the
- * expression from ch->expr->value, or the variable name from ch->var->name
+ * expression from ch->expr->value, or the variable name from ch->var->name,
  * and stores the result back in ch->expr->value via Expr_SetValueOwn or
  * Expr_SetValueRefer.
  *
- * If evaluating fails (as of 2020-08-23), an error message is printed using
- * Error.  This function has no side effects, it really just prints the error
- * message.  Processing the expression continues as if everything were ok.
- * TODO: This should be fixed by adding proper 

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

2024-01-06 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sun Jan  7 02:07:44 UTC 2024

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

Log Message:
make: unit-tests handle TEST_MAKE:T != make

We need to allow for ${TEST_MAKE:T}[1-9]: etc when
TEST_MAKE is not 'make'


To generate a diff of this commit:
cvs rdiff -u -r1.341 -r1.342 src/usr.bin/make/unit-tests/Makefile

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

Modified files:

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.341 src/usr.bin/make/unit-tests/Makefile:1.342
--- src/usr.bin/make/unit-tests/Makefile:1.341	Sat Sep  9 16:41:04 2023
+++ src/usr.bin/make/unit-tests/Makefile	Sun Jan  7 02:07:44 2024
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.341 2023/09/09 16:41:04 sjg Exp $
+# $NetBSD: Makefile,v 1.342 2024/01/07 02:07:44 sjg Exp $
 #
 # Unit tests for make(1)
 #
@@ -747,6 +747,7 @@ _SED_CMDS+=	-e 's,${.OBJDIR},,g'
 _SED_CMDS+=	-e 's,^${TEST_MAKE:T:S,.,\\.,g}[][0-9]*:,make:,'
 _SED_CMDS+=	-e 's,${TEST_MAKE:S,.,\\.,g},make,'
 _SED_CMDS+=	-e 's,^usage: ${TEST_MAKE:T:S,.,\\.,g} ,usage: make ,'
+_SED_CMDS+=	-e 's,${TEST_MAKE:T:S,.,\\.,g}\(\[[1-9][0-9]*\]:\),make\1,'
 _SED_CMDS+=	-e 's,/,,g'
 _SED_CMDS+=	-e 's,${UNIT_TESTS:S,.,\\.,g}/,,g'
 _SED_CMDS+=	-e '/MAKE_VERSION/d'



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

2024-01-06 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sun Jan  7 02:07:44 UTC 2024

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

Log Message:
make: unit-tests handle TEST_MAKE:T != make

We need to allow for ${TEST_MAKE:T}[1-9]: etc when
TEST_MAKE is not 'make'


To generate a diff of this commit:
cvs rdiff -u -r1.341 -r1.342 src/usr.bin/make/unit-tests/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

2024-01-06 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sun Jan  7 01:33:58 UTC 2024

Modified Files:
src/usr.bin/make: job.c main.c
src/usr.bin/make/unit-tests: jobs-error-indirect.exp
jobs-error-nested-make.exp jobs-error-nested.exp var-recursive.exp

Log Message:
make: more consistent error messages

Move %s: progname from Job_CheckCommands to Fatal
to avoid is being repeated when Job_CheckCommands is passed Error.

This means some errors from var also report progname (and level)
which is useful.

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.463 -r1.464 src/usr.bin/make/job.c
cvs rdiff -u -r1.608 -r1.609 src/usr.bin/make/main.c
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/jobs-error-indirect.exp \
src/usr.bin/make/unit-tests/jobs-error-nested.exp
cvs rdiff -u -r1.3 -r1.4 \
src/usr.bin/make/unit-tests/jobs-error-nested-make.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/var-recursive.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/job.c
diff -u src/usr.bin/make/job.c:1.463 src/usr.bin/make/job.c:1.464
--- src/usr.bin/make/job.c:1.463	Fri Jan  5 23:22:06 2024
+++ src/usr.bin/make/job.c	Sun Jan  7 01:33:57 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.463 2024/01/05 23:22:06 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.464 2024/01/07 01:33:57 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -141,7 +141,7 @@
 #include "trace.h"
 
 /*	"@(#)job.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: job.c,v 1.463 2024/01/05 23:22:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.464 2024/01/07 01:33:57 sjg Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -1379,7 +1379,7 @@ Job_CheckCommands(GNode *gn, void (*abor
 		return false;
 	}
 
-	abortProc("%s: don't know how to make %s. Stop", progname, gn->name);
+	abortProc("don't know how to make %s. Stop", gn->name);
 	return false;
 }
 

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.608 src/usr.bin/make/main.c:1.609
--- src/usr.bin/make/main.c:1.608	Fri Jan  5 23:22:06 2024
+++ src/usr.bin/make/main.c	Sun Jan  7 01:33:57 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.608 2024/01/05 23:22:06 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.609 2024/01/07 01:33:57 sjg 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.608 2024/01/05 23:22:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.609 2024/01/07 01:33:57 sjg Exp $");
 #if defined(MAKE_NATIVE)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	"The Regents of the University of California.  "
@@ -1851,6 +1851,7 @@ Fatal(const char *fmt, ...)
 		Job_Wait();
 
 	(void)fflush(stdout);
+	fprintf(stderr, "%s: ", progname);
 	va_start(ap, fmt);
 	(void)vfprintf(stderr, fmt, ap);
 	va_end(ap);

Index: src/usr.bin/make/unit-tests/jobs-error-indirect.exp
diff -u src/usr.bin/make/unit-tests/jobs-error-indirect.exp:1.1 src/usr.bin/make/unit-tests/jobs-error-indirect.exp:1.2
--- src/usr.bin/make/unit-tests/jobs-error-indirect.exp:1.1	Tue Dec  1 17:50:04 2020
+++ src/usr.bin/make/unit-tests/jobs-error-indirect.exp	Sun Jan  7 01:33:57 2024
@@ -2,7 +2,7 @@ false
 *** [indirect] Error code 1
 
 make: stopped in unit-tests
-1 error
+make: 1 error
 
 make: stopped in unit-tests
 exit status 2
Index: src/usr.bin/make/unit-tests/jobs-error-nested.exp
diff -u src/usr.bin/make/unit-tests/jobs-error-nested.exp:1.1 src/usr.bin/make/unit-tests/jobs-error-nested.exp:1.2
--- src/usr.bin/make/unit-tests/jobs-error-nested.exp:1.1	Tue Dec  1 17:50:04 2020
+++ src/usr.bin/make/unit-tests/jobs-error-nested.exp	Sun Jan  7 01:33:57 2024
@@ -3,13 +3,13 @@ false
 *** [nested] Error code 1
 
 make: stopped in unit-tests
-1 error
+make: 1 error
 
 make: stopped in unit-tests
 *** [all] Error code 2
 
 make: stopped in unit-tests
-1 error
+make: 1 error
 
 make: stopped in unit-tests
 exit status 2

Index: src/usr.bin/make/unit-tests/jobs-error-nested-make.exp
diff -u src/usr.bin/make/unit-tests/jobs-error-nested-make.exp:1.3 src/usr.bin/make/unit-tests/jobs-error-nested-make.exp:1.4
--- src/usr.bin/make/unit-tests/jobs-error-nested-make.exp:1.3	Fri Jan  8 21:46:50 2021
+++ src/usr.bin/make/unit-tests/jobs-error-nested-make.exp	Sun Jan  7 01:33:57 2024
@@ -3,7 +3,7 @@ false
 *** [nested] Error code 1
 
 make: stopped in unit-tests
-1 error
+make: 1 error
 
 make: stopped in unit-tests
 

Index: src/usr.bin/make/unit-tests/var-recursive.exp
diff -u src/usr.bin/make/unit-tests/var-recursive.exp:1.6 src/usr.bin/make/unit-tests/var-recursive.exp:1.7
--- src/usr.bin/make/unit-tests/var-recursive.exp:1.6	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/var-recursive.exp	Sun Jan  7 01:33:57 2024
@@ -1,19 +1,19 @@
 make: 

CVS commit: src/usr.bin/make

2024-01-06 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sun Jan  7 01:33:58 UTC 2024

Modified Files:
src/usr.bin/make: job.c main.c
src/usr.bin/make/unit-tests: jobs-error-indirect.exp
jobs-error-nested-make.exp jobs-error-nested.exp var-recursive.exp

Log Message:
make: more consistent error messages

Move %s: progname from Job_CheckCommands to Fatal
to avoid is being repeated when Job_CheckCommands is passed Error.

This means some errors from var also report progname (and level)
which is useful.

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.463 -r1.464 src/usr.bin/make/job.c
cvs rdiff -u -r1.608 -r1.609 src/usr.bin/make/main.c
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/jobs-error-indirect.exp \
src/usr.bin/make/unit-tests/jobs-error-nested.exp
cvs rdiff -u -r1.3 -r1.4 \
src/usr.bin/make/unit-tests/jobs-error-nested-make.exp
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/var-recursive.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

2024-01-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  5 23:36:45 UTC 2024

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

Log Message:
tests/make: test long shell commands via Cmd_Exec


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/var-op-shell.mk

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

Modified files:

Index: src/usr.bin/make/unit-tests/var-op-shell.mk
diff -u src/usr.bin/make/unit-tests/var-op-shell.mk:1.7 src/usr.bin/make/unit-tests/var-op-shell.mk:1.8
--- src/usr.bin/make/unit-tests/var-op-shell.mk:1.7	Thu Jun  1 20:56:35 2023
+++ src/usr.bin/make/unit-tests/var-op-shell.mk	Fri Jan  5 23:36:45 2024
@@ -1,4 +1,4 @@
-# $NetBSD: var-op-shell.mk,v 1.7 2023/06/01 20:56:35 rillig Exp $
+# $NetBSD: var-op-shell.mk,v 1.8 2024/01/05 23:36:45 rillig Exp $
 #
 # Tests for the != variable assignment operator, which runs its right-hand
 # side through the shell.
@@ -91,4 +91,22 @@ OUTPUT!=	echo ''
 OUTPUT!=	echo ''
 .MAKEFLAGS: -d0
 
+
+# Since main.c 1.607 from 2024-01-05, long shell commands are not run directly
+# via '$shell -c $command', they are first written to a temporary file that is
+# then fed to the shell via '$shell $tmpfile'.
+OUTPUT_SHORT!=	echo "$$0"
+OUTPUT_LONG!=	echo "$$0" || : ${:U:range=1000}
+# When running '$shell -c $command', '$0' in the shell evaluates to the name
+# of the shell.
+.if ${OUTPUT_SHORT} != ${.SHELL:T}
+.  error
+.endif
+# When running '$shell $tmpfile', '$0' in the shell evaluates to the name of
+# the temporary file.
+.if !${OUTPUT_LONG:M*/make*}
+.  error
+.endif
+
+
 all:



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

2024-01-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  5 23:36:45 UTC 2024

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

Log Message:
tests/make: test long shell commands via Cmd_Exec


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/var-op-shell.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

2024-01-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  5 23:22:06 UTC 2024

Modified Files:
src/usr.bin/make: compat.c job.c main.c make.c parse.c str.c suff.c
var.c

Log Message:
make: miscellaneous cleanups


To generate a diff of this commit:
cvs rdiff -u -r1.251 -r1.252 src/usr.bin/make/compat.c
cvs rdiff -u -r1.462 -r1.463 src/usr.bin/make/job.c
cvs rdiff -u -r1.607 -r1.608 src/usr.bin/make/main.c
cvs rdiff -u -r1.261 -r1.262 src/usr.bin/make/make.c
cvs rdiff -u -r1.714 -r1.715 src/usr.bin/make/parse.c
cvs rdiff -u -r1.101 -r1.102 src/usr.bin/make/str.c
cvs rdiff -u -r1.376 -r1.377 src/usr.bin/make/suff.c
cvs rdiff -u -r1.1092 -r1.1093 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

2024-01-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  5 23:22:06 UTC 2024

Modified Files:
src/usr.bin/make: compat.c job.c main.c make.c parse.c str.c suff.c
var.c

Log Message:
make: miscellaneous cleanups


To generate a diff of this commit:
cvs rdiff -u -r1.251 -r1.252 src/usr.bin/make/compat.c
cvs rdiff -u -r1.462 -r1.463 src/usr.bin/make/job.c
cvs rdiff -u -r1.607 -r1.608 src/usr.bin/make/main.c
cvs rdiff -u -r1.261 -r1.262 src/usr.bin/make/make.c
cvs rdiff -u -r1.714 -r1.715 src/usr.bin/make/parse.c
cvs rdiff -u -r1.101 -r1.102 src/usr.bin/make/str.c
cvs rdiff -u -r1.376 -r1.377 src/usr.bin/make/suff.c
cvs rdiff -u -r1.1092 -r1.1093 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/compat.c
diff -u src/usr.bin/make/compat.c:1.251 src/usr.bin/make/compat.c:1.252
--- src/usr.bin/make/compat.c:1.251	Tue Dec 26 20:09:42 2023
+++ src/usr.bin/make/compat.c	Fri Jan  5 23:22:06 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.251 2023/12/26 20:09:42 sjg Exp $	*/
+/*	$NetBSD: compat.c,v 1.252 2024/01/05 23:22:06 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -91,7 +91,7 @@
 #include "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.251 2023/12/26 20:09:42 sjg Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.252 2024/01/05 23:22:06 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -107,10 +107,8 @@ CompatDeleteTarget(GNode *gn)
 	if (gn != NULL && !GNode_IsPrecious(gn) &&
 	(gn->type & OP_PHONY) == 0) {
 		const char *file = GNode_VarTarget(gn);
-
-		if (!opts.noExecute && unlink_file(file) == 0) {
+		if (!opts.noExecute && unlink_file(file) == 0)
 			Error("*** %s removed", file);
-		}
 	}
 }
 
@@ -132,9 +130,8 @@ CompatInterrupt(int signo)
 		/* Run .INTERRUPT only if hit with interrupt signal. */
 		if (signo == SIGINT) {
 			GNode *gn = Targ_FindNode(".INTERRUPT");
-			if (gn != NULL) {
+			if (gn != NULL)
 Compat_Make(gn, gn);
-			}
 		}
 	}
 
@@ -360,9 +357,8 @@ Compat_RunCommand(const char *cmdp, GNod
 	while ((retstat = wait()) != cpid) {
 		if (retstat > 0)
 			JobReapChild(retstat, reason, false); /* not ours? */
-		if (retstat == -1 && errno != EINTR) {
+		if (retstat == -1 && errno != EINTR)
 			break;
-		}
 	}
 
 	if (retstat < 0)

Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.462 src/usr.bin/make/job.c:1.463
--- src/usr.bin/make/job.c:1.462	Fri Dec 29 12:59:43 2023
+++ src/usr.bin/make/job.c	Fri Jan  5 23:22:06 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.462 2023/12/29 12:59:43 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.463 2024/01/05 23:22:06 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -141,7 +141,7 @@
 #include "trace.h"
 
 /*	"@(#)job.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: job.c,v 1.462 2023/12/29 12:59:43 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.463 2024/01/05 23:22:06 rillig Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -928,12 +928,10 @@ JobWriteCommand(Job *job, ShellWriter *w
 	escCmd = shell->hasErrCtl ? NULL : EscapeShellDblQuot(xcmd);
 
 	if (!cmdFlags.echo) {
-		if (job->echo && run && shell->hasEchoCtl) {
+		if (job->echo && run && shell->hasEchoCtl)
 			ShellWriter_EchoOff(wr);
-		} else {
-			if (shell->hasErrCtl)
-cmdFlags.echo = true;
-		}
+		else if (shell->hasErrCtl)
+			cmdFlags.echo = true;
 	}
 
 	if (cmdFlags.ignerr) {
@@ -2182,11 +2180,10 @@ Shell_GetNewline(void)
 void
 Job_SetPrefix(void)
 {
-	if (targPrefix != NULL) {
+	if (targPrefix != NULL)
 		free(targPrefix);
-	} else if (!Var_Exists(SCOPE_GLOBAL, ".MAKE.JOB.PREFIX")) {
+	else if (!Var_Exists(SCOPE_GLOBAL, ".MAKE.JOB.PREFIX"))
 		Global_Set(".MAKE.JOB.PREFIX", "---");
-	}
 
 	targPrefix = Var_Subst("${.MAKE.JOB.PREFIX}",
 	SCOPE_GLOBAL, VARE_WANTRES);
@@ -2484,18 +2481,9 @@ Job_ParseShell(char *line)
 		 * its word and copy it to a new location. In either case,
 		 * we need to record the path the user gave for the shell.
 		 */
+		char *name = path + (str_basename(path) - path);
 		shellPath = path;
-		path = strrchr(path, '/');
-		if (path == NULL) {
-			path = UNCONST(shellPath);
-		} else {
-			path++;
-		}
-		if (newShell.name != NULL) {
-			shellName = newShell.name;
-		} else {
-			shellName = path;
-		}
+		shellName = newShell.name != NULL ? newShell.name : name;
 		if (!fullSpec) {
 			if ((sh = FindShellByName(shellName)) == NULL) {
 Parse_Error(PARSE_WARNING,
@@ -2592,11 +2580,10 @@ Job_Finish(void)
 	GNode *endNode = Targ_GetEndNode();
 	if (!Lst_IsEmpty(>commands) ||
 	!Lst_IsEmpty(>children)) {
-		if (job_errors != 0) {
+		if (job_errors != 0)
 			Error("Errors reported so .END ignored");
-		} else {
+		else
 			JobRun(endNode);
-		}
 	}
 	return 

CVS commit: src/usr.bin/make

2024-01-05 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Fri Jan  5 22:20:07 UTC 2024

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

Log Message:
Cmd_Exec use tempfile if cmd is too big

To avoid blowing commandline/env limits, if "cmd"
is more than 1000 bytes, write it to a file and pass that
to shell.

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.606 -r1.607 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.606 src/usr.bin/make/main.c:1.607
--- src/usr.bin/make/main.c:1.606	Wed Dec 27 00:45:37 2023
+++ src/usr.bin/make/main.c	Fri Jan  5 22:20:07 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.606 2023/12/27 00:45:37 sjg Exp $	*/
+/*	$NetBSD: main.c,v 1.607 2024/01/05 22:20:07 sjg 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.606 2023/12/27 00:45:37 sjg Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.607 2024/01/05 22:20:07 sjg Exp $");
 #if defined(MAKE_NATIVE)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	"The Regents of the University of California.  "
@@ -1705,14 +1705,38 @@ Cmd_Exec(const char *cmd, char **error)
 	char *output;
 	char *p;
 	int saved_errno;
+	char cmd_file[MAXPATHLEN];
+	size_t cmd_len;
+	int cmd_fd = -1;
 
 	if (shellPath == NULL)
 		Shell_Init();
 
+	cmd_len = strlen(cmd);
+	if (cmd_len > 1000) {
+		cmd_fd = mkTempFile(NULL, cmd_file, sizeof(cmd_file));
+		if (cmd_fd >= 0) {
+			ssize_t n;
+
+			n = write(cmd_fd, cmd, cmd_len);
+			close(cmd_fd);
+			if (n < (ssize_t)cmd_len) {
+unlink(cmd_file);
+cmd_fd = -1;
+			}
+		}
+	}
+
 	args[0] = shellName;
-	args[1] = "-c";
-	args[2] = cmd;
-	args[3] = NULL;
+	if (cmd_fd >= 0) {
+		args[1] = cmd_file;
+		args[2] = NULL;
+	} else {
+		cmd_file[0] = '\0';
+		args[1] = "-c";
+		args[2] = cmd;
+		args[3] = NULL;
+	}
 	DEBUG1(VAR, "Capturing the output of command \"%s\"\n", cmd);
 
 	if (pipe(pipefds) == -1) {
@@ -1775,6 +1799,8 @@ Cmd_Exec(const char *cmd, char **error)
 		"Couldn't read shell's output for \"", cmd, "\"");
 	else
 		*error = NULL;
+	if (cmd_file[0] != '\0')
+		unlink(cmd_file);
 	return output;
 }
 
@@ -2129,7 +2155,7 @@ getTmpdir(void)
 
 /*
  * Create and open a temp file using "pattern".
- * If out_fname is provided, set it to a copy of the filename created.
+ * If tfile is provided, set it to a copy of the filename created.
  * Otherwise unlink the file once open.
  */
 int



CVS commit: src/usr.bin/make

2024-01-05 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Fri Jan  5 22:20:07 UTC 2024

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

Log Message:
Cmd_Exec use tempfile if cmd is too big

To avoid blowing commandline/env limits, if "cmd"
is more than 1000 bytes, write it to a file and pass that
to shell.

Reviewed by: rillig


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

2024-01-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  5 21:56:55 UTC 2024

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

Log Message:
make: clean up string functions

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/str.h
cvs rdiff -u -r1.1091 -r1.1092 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/str.h
diff -u src/usr.bin/make/str.h:1.18 src/usr.bin/make/str.h:1.19
--- src/usr.bin/make/str.h:1.18	Fri Jan  5 21:51:27 2024
+++ src/usr.bin/make/str.h	Fri Jan  5 21:56:55 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: str.h,v 1.18 2024/01/05 21:51:27 rillig Exp $	*/
+/*	$NetBSD: str.h,v 1.19 2024/01/05 21:56:55 rillig Exp $	*/
 
 /*
  Copyright (c) 2021 Roland Illig 
@@ -76,27 +76,24 @@ typedef struct StrMatchResult {
 } StrMatchResult;
 
 
+/* Return a string that is the sole owner of str. */
 MAKE_INLINE FStr
-FStr_Init(const char *str, void *freeIt)
+FStr_InitOwn(char *str)
 {
 	FStr fstr;
 	fstr.str = str;
-	fstr.freeIt = freeIt;
+	fstr.freeIt = str;
 	return fstr;
 }
 
-/* Return a string that is the sole owner of str. */
-MAKE_INLINE FStr
-FStr_InitOwn(char *str)
-{
-	return FStr_Init(str, str);
-}
-
 /* Return a string that refers to the shared str. */
 MAKE_INLINE FStr
 FStr_InitRefer(const char *str)
 {
-	return FStr_Init(str, NULL);
+	FStr fstr;
+	fstr.str = str;
+	fstr.freeIt = NULL;
+	return fstr;
 }
 
 MAKE_INLINE void
@@ -190,7 +187,7 @@ Substring_SkipFirst(Substring sub, char 
 }
 
 MAKE_STATIC const char *
-Substring_LastIndex(Substring sub, char ch)
+Substring_FindLast(Substring sub, char ch)
 {
 	const char *p;
 

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.1091 src/usr.bin/make/var.c:1.1092
--- src/usr.bin/make/var.c:1.1091	Fri Jan  5 21:51:27 2024
+++ src/usr.bin/make/var.c	Fri Jan  5 21:56:55 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1091 2024/01/05 21:51:27 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.1092 2024/01/05 21:56:55 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1091 2024/01/05 21:51:27 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1092 2024/01/05 21:56:55 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -1328,7 +1328,7 @@ ModifyWord_Tail(Substring word, SepBuf *
 static void
 ModifyWord_Suffix(Substring word, SepBuf *buf, void *dummy MAKE_ATTR_UNUSED)
 {
-	const char *lastDot = Substring_LastIndex(word, '.');
+	const char *lastDot = Substring_FindLast(word, '.');
 	if (lastDot != NULL)
 		SepBuf_AddRange(buf, lastDot + 1, word.end);
 }
@@ -1339,7 +1339,7 @@ ModifyWord_Root(Substring word, SepBuf *
 {
 	const char *lastDot, *end;
 
-	lastDot = Substring_LastIndex(word, '.');
+	lastDot = Substring_FindLast(word, '.');
 	end = lastDot != NULL ? lastDot : word.end;
 	SepBuf_AddRange(buf, word.start, end);
 }



CVS commit: src/usr.bin/make

2024-01-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  5 21:56:55 UTC 2024

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

Log Message:
make: clean up string functions

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/str.h
cvs rdiff -u -r1.1091 -r1.1092 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

2024-01-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  5 21:51:27 UTC 2024

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

Log Message:
make: inline Substring_Sub

Remove redundant assertions.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/str.h
cvs rdiff -u -r1.1090 -r1.1091 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/str.h
diff -u src/usr.bin/make/str.h:1.17 src/usr.bin/make/str.h:1.18
--- src/usr.bin/make/str.h:1.17	Fri Jun 23 04:56:54 2023
+++ src/usr.bin/make/str.h	Fri Jan  5 21:51:27 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: str.h,v 1.17 2023/06/23 04:56:54 rillig Exp $	*/
+/*	$NetBSD: str.h,v 1.18 2024/01/05 21:51:27 rillig Exp $	*/
 
 /*
  Copyright (c) 2021 Roland Illig 
@@ -154,14 +154,6 @@ Substring_Eq(Substring sub, Substring st
 	   memcmp(sub.start, str.start, len) == 0;
 }
 
-MAKE_STATIC Substring
-Substring_Sub(Substring sub, size_t start, size_t end)
-{
-	assert(start <= Substring_Length(sub));
-	assert(end <= Substring_Length(sub));
-	return Substring_Init(sub.start + start, sub.start + end);
-}
-
 MAKE_STATIC bool
 Substring_HasPrefix(Substring sub, Substring prefix)
 {

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.1090 src/usr.bin/make/var.c:1.1091
--- src/usr.bin/make/var.c:1.1090	Fri Dec 29 14:57:00 2023
+++ src/usr.bin/make/var.c	Fri Jan  5 21:51:27 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1090 2023/12/29 14:57:00 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.1091 2024/01/05 21:51:27 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1090 2023/12/29 14:57:00 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1091 2024/01/05 21:51:27 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -4222,7 +4222,8 @@ FindLocalLegacyVar(Substring varname, GN
 	if (strchr("@%?*!<>", varname.start[0]) == NULL)
 		return NULL;
 
-	v = VarFindSubstring(Substring_Sub(varname, 0, 1), scope, false);
+	v = VarFindSubstring(Substring_Init(varname.start, varname.start + 1),
+	scope, false);
 	if (v == NULL)
 		return NULL;
 



CVS commit: src/usr.bin/make

2024-01-05 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  5 21:51:27 UTC 2024

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

Log Message:
make: inline Substring_Sub

Remove redundant assertions.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/str.h
cvs rdiff -u -r1.1090 -r1.1091 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

2024-01-03 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Wed Jan  3 20:24:16 UTC 2024

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

Log Message:
make: do not add newline to an empty buffer

When LoadFile reads from /dev/null the buffer will be empty,
appending "\n" just results in an unnecessary extra call
to ParseRawLine.

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.713 -r1.714 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.713 src/usr.bin/make/parse.c:1.714
--- src/usr.bin/make/parse.c:1.713	Fri Dec 29 20:43:58 2023
+++ src/usr.bin/make/parse.c	Wed Jan  3 20:24:16 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.713 2023/12/29 20:43:58 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.714 2024/01/03 20:24:16 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -105,7 +105,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.713 2023/12/29 20:43:58 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.714 2024/01/03 20:24:16 sjg Exp $");
 
 /* Detects a multiple-inclusion guard in a makefile. */
 typedef enum {
@@ -383,7 +383,7 @@ LoadFile(const char *path, int fd)
 	}
 	assert(buf.len <= buf.cap);
 
-	if (!Buf_EndsWith(, '\n'))
+	if (buf.len > 0 && !Buf_EndsWith(, '\n'))
 		Buf_AddByte(, '\n');
 
 	return buf;		/* may not be null-terminated */



CVS commit: src/usr.bin/make

2024-01-03 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Wed Jan  3 20:24:16 UTC 2024

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

Log Message:
make: do not add newline to an empty buffer

When LoadFile reads from /dev/null the buffer will be empty,
appending "\n" just results in an unnecessary extra call
to ParseRawLine.

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.713 -r1.714 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/unit-tests

2023-12-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 31 10:09:01 UTC 2023

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

Log Message:
tests/make: finish incomplete sentence in test for assignment modifiers


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/varmod-assign.mk

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

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-assign.mk
diff -u src/usr.bin/make/unit-tests/varmod-assign.mk:1.17 src/usr.bin/make/unit-tests/varmod-assign.mk:1.18
--- src/usr.bin/make/unit-tests/varmod-assign.mk:1.17	Fri Dec 29 15:47:03 2023
+++ src/usr.bin/make/unit-tests/varmod-assign.mk	Sun Dec 31 10:09:01 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-assign.mk,v 1.17 2023/12/29 15:47:03 rillig Exp $
+# $NetBSD: varmod-assign.mk,v 1.18 2023/12/31 10:09:01 rillig Exp $
 #
 # Tests for the obscure ::= variable modifiers, which perform variable
 # assignments during evaluation, just like the = operator in C.
@@ -155,8 +155,10 @@ ${VARNAME}=	initial-value	# Sets 'VAR.${
 .MAKEFLAGS: -d0
 
 
-# Conditional directives are evaluated in command line scope.  Any assignment
-# modifiers in these conditions create or
+# Conditional directives are evaluated in command line scope.  An assignment
+# modifier that creates a new variable creates it in the command line scope.
+# Existing variables are updated in their previous scope, and environment
+# variables are created in the global scope, as in other situations.
 .MAKEFLAGS: CMD_CMD_VAR=cmd-value
 CMD_GLOBAL_VAR=global-value
 export CMD_ENV_VAR=env-value
@@ -181,8 +183,7 @@ export CMD_ENV_VAR=env-value
 # debug log for this test, the debug log would have to be enabled for the
 # other targets as well, thus producing lots of irrelevant output.
 #
-# Running './make -r -f varmod-assign.mk target' results in:
-#	target: TARGET_TARGET_VAR = target-value
+# Running './make -r -f varmod-assign.mk target | grep ": TARGET"' results in:
 #	target: TARGET_TARGET_VAR = new-value
 #	Global: TARGET_GLOBAL_VAR = new-value
 #	Global: TARGET_ENV_VAR = new-value
@@ -191,7 +192,7 @@ export CMD_ENV_VAR=env-value
 TARGET_GLOBAL_VAR=global-value
 export TARGET_ENV_VAR=env-value
 .MAKEFLAGS: ${make(target):?-dv:}
-target: TARGET_TARGET_VAR=target-value
+target: .PHONY TARGET_TARGET_VAR=target-value
 	: ${TARGET_TARGET_VAR::=new-value}
 	: ${TARGET_CMD_VAR::=new-value}
 	: ${TARGET_GLOBAL_VAR::=new-value}



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

2023-12-31 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Dec 31 10:09:01 UTC 2023

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

Log Message:
tests/make: finish incomplete sentence in test for assignment modifiers


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/varmod-assign.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

2023-12-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec 30 15:00:56 UTC 2023

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

Log Message:
make: clean up freeing of suffixes

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.375 -r1.376 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/suff.c
diff -u src/usr.bin/make/suff.c:1.375 src/usr.bin/make/suff.c:1.376
--- src/usr.bin/make/suff.c:1.375	Sat Dec 30 13:28:06 2023
+++ src/usr.bin/make/suff.c	Sat Dec 30 15:00:56 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.375 2023/12/30 13:28:06 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.376 2023/12/30 15:00:56 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.375 2023/12/30 13:28:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.376 2023/12/30 15:00:56 rillig Exp $");
 
 typedef List SuffixList;
 typedef ListNode SuffixListNode;
@@ -364,7 +364,6 @@ SuffixList_Unref(SuffixList *list, Suffi
 	}
 }
 
-/* Free up all memory associated with the given suffix structure. */
 static void
 Suffix_Free(Suffix *suff)
 {
@@ -390,12 +389,6 @@ Suffix_Free(Suffix *suff)
 	free(suff);
 }
 
-static void
-SuffFree(void *p)
-{
-	Suffix_Free(p);
-}
-
 /* Remove the suffix from the list, and free if it is otherwise unused. */
 static void
 SuffixList_Remove(SuffixList *list, Suffix *suff)
@@ -405,7 +398,7 @@ SuffixList_Remove(SuffixList *list, Suff
 		/* XXX: can lead to suff->refCount == -1 */
 		SuffixList_Unref(, suff);
 		DEBUG1(SUFF, "Removing suffix \"%s\"\n", suff->name);
-		SuffFree(suff);
+		Suffix_Free(suff);
 	}
 }
 
@@ -482,7 +475,7 @@ Suff_ClearSuffixes(void)
 	Lst_Init();
 	sNum = 0;
 	if (nullSuff != NULL)
-		SuffFree(nullSuff);
+		Suffix_Free(nullSuff);
 	emptySuff = nullSuff = Suffix_New("");
 
 	SearchPath_AddAll(nullSuff->searchPath, );
@@ -2054,16 +2047,21 @@ Suff_Init(void)
 	Suff_ClearSuffixes();
 }
 
-
 /* Clean up the suffixes module. */
 void
 Suff_End(void)
 {
 #ifdef CLEANUP
-	Lst_DoneCall(, SuffFree);
-	Lst_DoneCall(, SuffFree);
+	SuffixListNode *ln;
+
+	for (ln = sufflist.first; ln != NULL; ln = ln->next)
+		Suffix_Free(ln->datum);
+	Lst_Done();
+	for (ln = suffClean.first; ln != NULL; ln = ln->next)
+		Suffix_Free(ln->datum);
+	Lst_Done();
 	if (nullSuff != NULL)
-		SuffFree(nullSuff);
+		Suffix_Free(nullSuff);
 	Lst_Done();
 #endif
 }



CVS commit: src/usr.bin/make

2023-12-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec 30 15:00:56 UTC 2023

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

Log Message:
make: clean up freeing of suffixes

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.375 -r1.376 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/usr.bin/make

2023-12-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec 30 13:28:06 UTC 2023

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

Log Message:
make: remove unused field from suffix

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.374 -r1.375 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/suff.c
diff -u src/usr.bin/make/suff.c:1.374 src/usr.bin/make/suff.c:1.375
--- src/usr.bin/make/suff.c:1.374	Fri Dec 29 18:53:24 2023
+++ src/usr.bin/make/suff.c	Sat Dec 30 13:28:06 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.374 2023/12/29 18:53:24 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.375 2023/12/30 13:28:06 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.374 2023/12/29 18:53:24 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.375 2023/12/30 13:28:06 rillig Exp $");
 
 typedef List SuffixList;
 typedef ListNode SuffixListNode;
@@ -142,8 +142,6 @@ static GNodeList transforms = LST_INIT;
  */
 static int sNum = 0;
 
-typedef List SuffixListList;
-
 /*
  * A suffix such as ".c" or ".o" that may be used in suffix transformation
  * rules such as ".c.o:".
@@ -185,14 +183,6 @@ typedef struct Suffix {
 	SuffixList parents;
 	/* Suffixes we have a transformation from */
 	SuffixList children;
-	/*
-	 * Lists in which this suffix is referenced.
-	 *
-	 * XXX: These lists are used nowhere, they are just appended to, for
-	 * no apparent reason.  They do have the side effect of increasing
-	 * refCount though.
-	 */
-	SuffixListList ref;
 } Suffix;
 
 /*
@@ -392,7 +382,6 @@ Suffix_Free(Suffix *suff)
 		suff->name, suff->refCount);
 #endif
 
-	Lst_Done(>ref);
 	Lst_Done(>children);
 	Lst_Done(>parents);
 	SearchPath_Free(suff->searchPath);
@@ -440,12 +429,10 @@ SuffixList_Insert(SuffixList *list, Suff
 		DEBUG2(SUFF, "inserting \"%s\" (%d) at end of list\n",
 		suff->name, suff->sNum);
 		Lst_Append(list, Suffix_Ref(suff));
-		Lst_Append(>ref, list);
 	} else if (listSuff->sNum != suff->sNum) {
 		DEBUG4(SUFF, "inserting \"%s\" (%d) before \"%s\" (%d)\n",
 		suff->name, suff->sNum, listSuff->name, listSuff->sNum);
 		Lst_InsertBefore(list, ln, Suffix_Ref(suff));
-		Lst_Append(>ref, list);
 	} else {
 		DEBUG2(SUFF, "\"%s\" (%d) is already there\n",
 		suff->name, suff->sNum);
@@ -469,7 +456,6 @@ Suffix_New(const char *name)
 	suff->searchPath = SearchPath_New();
 	Lst_Init(>children);
 	Lst_Init(>parents);
-	Lst_Init(>ref);
 	suff->sNum = sNum++;
 	suff->include = false;
 	suff->library = false;
@@ -821,19 +807,7 @@ UpdateTargets(Suffix *suff)
 	}
 }
 
-/*
- * Add the suffix to the end of the list of known suffixes.
- * Should we restructure the suffix graph? Make doesn't.
- *
- * A GNode is created for the suffix (XXX: this sounds completely wrong) and
- * a Suffix structure is created and added to the suffixes list unless the
- * suffix was already known.
- * The mainNode passed can be modified if a target mutated into a
- * transform and that target happened to be the main target.
- *
- * Input:
- *	name		the name of the suffix to add
- */
+/* Add the suffix to the end of the list of known suffixes. */
 void
 Suff_AddSuffix(const char *name)
 {



CVS commit: src/usr.bin/make

2023-12-30 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Dec 30 13:28:06 UTC 2023

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

Log Message:
make: remove unused field from suffix

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.374 -r1.375 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/usr.bin/make

2023-12-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Dec 29 20:43:58 UTC 2023

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

Log Message:
make: unexport list memory management functions

They are only used in a single source file.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/usr.bin/make/lst.c
cvs rdiff -u -r1.103 -r1.104 src/usr.bin/make/lst.h
cvs rdiff -u -r1.712 -r1.713 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/lst.c
diff -u src/usr.bin/make/lst.c:1.106 src/usr.bin/make/lst.c:1.107
--- src/usr.bin/make/lst.c:1.106	Sat Feb 26 11:57:21 2022
+++ src/usr.bin/make/lst.c	Fri Dec 29 20:43:58 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.106 2022/02/26 11:57:21 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.107 2023/12/29 20:43:58 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -34,7 +34,7 @@
 
 #include "make.h"
 
-MAKE_RCSID("$NetBSD: lst.c,v 1.106 2022/02/26 11:57:21 rillig Exp $");
+MAKE_RCSID("$NetBSD: lst.c,v 1.107 2023/12/29 20:43:58 rillig Exp $");
 
 static ListNode *
 LstNodeNew(ListNode *prev, ListNode *next, void *datum)
@@ -48,15 +48,6 @@ LstNodeNew(ListNode *prev, ListNode *nex
 	return ln;
 }
 
-/* Create and initialize a new, empty list. */
-List *
-Lst_New(void)
-{
-	List *list = bmake_malloc(sizeof *list);
-	Lst_Init(list);
-	return list;
-}
-
 void
 Lst_Done(List *list)
 {
@@ -80,15 +71,6 @@ Lst_DoneCall(List *list, LstFreeProc fre
 	}
 }
 
-/* Free a list and all its nodes. The node data are not freed though. */
-void
-Lst_Free(List *list)
-{
-
-	Lst_Done(list);
-	free(list);
-}
-
 /* Insert a new node with the datum before the given node. */
 void
 Lst_InsertBefore(List *list, ListNode *ln, void *datum)

Index: src/usr.bin/make/lst.h
diff -u src/usr.bin/make/lst.h:1.103 src/usr.bin/make/lst.h:1.104
--- src/usr.bin/make/lst.h:1.103	Thu Mar  3 19:55:27 2022
+++ src/usr.bin/make/lst.h	Fri Dec 29 20:43:58 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: lst.h,v 1.103 2022/03/03 19:55:27 rillig Exp $	*/
+/*	$NetBSD: lst.h,v 1.104 2023/12/29 20:43:58 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -101,16 +101,10 @@ struct List {
 /* Free the datum of a node, called before freeing the node itself. */
 typedef void LstFreeProc(void *);
 
-/* Create or destroy a list */
-
-/* Create a new list. */
-List *Lst_New(void) MAKE_ATTR_USE;
 /* Free the list nodes, but not the list itself. */
 void Lst_Done(List *);
 /* Free the list nodes, freeing the node data using the given function. */
 void Lst_DoneCall(List *, LstFreeProc);
-/* Free the list, leaving the node data unmodified. */
-void Lst_Free(List *);
 
 #define LST_INIT { NULL, NULL }
 

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.712 src/usr.bin/make/parse.c:1.713
--- src/usr.bin/make/parse.c:1.712	Tue Dec 19 19:33:39 2023
+++ src/usr.bin/make/parse.c	Fri Dec 29 20:43:58 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.712 2023/12/19 19:33:39 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.713 2023/12/29 20:43:58 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -105,7 +105,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.712 2023/12/19 19:33:39 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.713 2023/12/29 20:43:58 rillig Exp $");
 
 /* Detects a multiple-inclusion guard in a makefile. */
 typedef enum {
@@ -312,6 +312,23 @@ enum PosixState posix_state = PS_NOT_YET
 
 static HashTable /* full file name -> Guard */ guards;
 
+
+static List *
+Lst_New(void)
+{
+	List *list = bmake_malloc(sizeof *list);
+	Lst_Init(list);
+	return list;
+}
+
+static void
+Lst_Free(List *list)
+{
+
+	Lst_Done(list);
+	free(list);
+}
+
 static IncludedFile *
 GetInclude(size_t i)
 {



CVS commit: src/usr.bin/make

2023-12-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Dec 29 20:43:58 UTC 2023

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

Log Message:
make: unexport list memory management functions

They are only used in a single source file.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/usr.bin/make/lst.c
cvs rdiff -u -r1.103 -r1.104 src/usr.bin/make/lst.h
cvs rdiff -u -r1.712 -r1.713 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

2023-12-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Dec 29 18:53:24 UTC 2023

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

Log Message:
make: fix declared types of list nodes

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.285 -r1.286 src/usr.bin/make/dir.c
cvs rdiff -u -r1.260 -r1.261 src/usr.bin/make/make.c
cvs rdiff -u -r1.373 -r1.374 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/dir.c
diff -u src/usr.bin/make/dir.c:1.285 src/usr.bin/make/dir.c:1.286
--- src/usr.bin/make/dir.c:1.285	Tue Dec 19 19:33:39 2023
+++ src/usr.bin/make/dir.c	Fri Dec 29 18:53:24 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.285 2023/12/19 19:33:39 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.286 2023/12/29 18:53:24 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -132,7 +132,7 @@
 #include "job.h"
 
 /*	"@(#)dir.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: dir.c,v 1.285 2023/12/19 19:33:39 rillig Exp $");
+MAKE_RCSID("$NetBSD: dir.c,v 1.286 2023/12/29 18:53:24 rillig Exp $");
 
 /*
  * A search path is a list of CachedDir structures. A CachedDir has in it the
@@ -227,8 +227,6 @@ struct CachedDir {
 typedef List CachedDirList;
 typedef ListNode CachedDirListNode;
 
-typedef ListNode SearchPathNode;
-
 /* A list of cached directories, with fast lookup by directory name. */
 typedef struct OpenDirs {
 	CachedDirList list;
@@ -803,7 +801,7 @@ DirExpandCurly(const char *word, const c
 static void
 DirExpandPath(const char *pattern, SearchPath *path, StringList *expansions)
 {
-	SearchPathNode *ln;
+	CachedDirListNode *ln;
 	for (ln = path->dirs.first; ln != NULL; ln = ln->next) {
 		CachedDir *dir = ln->datum;
 		DirMatchFiles(pattern, dir, expansions);
@@ -1044,7 +1042,7 @@ static bool
 FindFileRelative(SearchPath *path, bool seenDotLast,
 		 const char *name, char **out_file)
 {
-	SearchPathNode *ln;
+	CachedDirListNode *ln;
 	bool checkedDot = false;
 	char *file;
 
@@ -1107,7 +1105,7 @@ FindFileAbsolute(SearchPath *path, bool 
 		 const char *name, const char *base, char **out_file)
 {
 	char *file;
-	SearchPathNode *ln;
+	CachedDirListNode *ln;
 
 	DEBUG0(DIR, "   Trying exact path matches...\n");
 
@@ -1180,7 +1178,7 @@ Dir_FindFile(const char *name, SearchPat
 	 * of each of the directories on the search path.
 	 */
 	if (base == name || (base - name == 2 && *name == '.')) {
-		SearchPathNode *ln;
+		CachedDirListNode *ln;
 
 		/*
 		 * Look through all the directories on the path seeking one
@@ -1463,7 +1461,7 @@ SearchPath_Add(SearchPath *path, const c
 {
 
 	if (path != NULL && strcmp(name, ".DOTLAST") == 0) {
-		SearchPathNode *ln;
+		CachedDirListNode *ln;
 
 		/* XXX: Linear search gets slow with thousands of entries. */
 		for (ln = path->dirs.first; ln != NULL; ln = ln->next) {
@@ -1496,7 +1494,7 @@ SearchPath *
 Dir_CopyDirSearchPath(void)
 {
 	SearchPath *path = SearchPath_New();
-	SearchPathNode *ln;
+	CachedDirListNode *ln;
 	for (ln = dirSearchPath.dirs.first; ln != NULL; ln = ln->next) {
 		CachedDir *dir = ln->datum;
 		Lst_Append(>dirs, CachedDir_Ref(dir));
@@ -1514,7 +1512,7 @@ char *
 SearchPath_ToFlags(SearchPath *path, const char *flag)
 {
 	Buffer buf;
-	SearchPathNode *ln;
+	CachedDirListNode *ln;
 
 	Buf_Init();
 
@@ -1534,7 +1532,7 @@ SearchPath_ToFlags(SearchPath *path, con
 void
 SearchPath_Free(SearchPath *path)
 {
-	SearchPathNode *ln;
+	CachedDirListNode *ln;
 
 	for (ln = path->dirs.first; ln != NULL; ln = ln->next) {
 		CachedDir *dir = ln->datum;
@@ -1565,7 +1563,7 @@ SearchPath_Clear(SearchPath *path)
 void
 SearchPath_AddAll(SearchPath *dst, SearchPath *src)
 {
-	SearchPathNode *ln;
+	CachedDirListNode *ln;
 
 	for (ln = src->dirs.first; ln != NULL; ln = ln->next) {
 		CachedDir *dir = ln->datum;
@@ -1602,7 +1600,7 @@ Dir_PrintDirectories(void)
 void
 SearchPath_Print(const SearchPath *path)
 {
-	SearchPathNode *ln;
+	CachedDirListNode *ln;
 
 	for (ln = path->dirs.first; ln != NULL; ln = ln->next) {
 		const CachedDir *dir = ln->datum;

Index: src/usr.bin/make/make.c
diff -u src/usr.bin/make/make.c:1.260 src/usr.bin/make/make.c:1.261
--- src/usr.bin/make/make.c:1.260	Fri Dec 29 12:20:55 2023
+++ src/usr.bin/make/make.c	Fri Dec 29 18:53:24 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.260 2023/12/29 12:20:55 rillig Exp $	*/
+/*	$NetBSD: make.c,v 1.261 2023/12/29 18:53:24 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -104,7 +104,7 @@
 #include "job.h"
 
 /*	"@(#)make.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: make.c,v 1.260 2023/12/29 12:20:55 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.261 2023/12/29 18:53:24 rillig Exp $");
 
 /* Sequence # to detect recursion. */
 static unsigned int checked_seqno = 1;
@@ -1224,7 +1224,7 @@ MakePrintStatusList(GNodeList *gnodes, i
 static void
 ExamineLater(GNodeList *examine, GNodeList 

CVS commit: src/usr.bin/make

2023-12-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Dec 29 18:53:24 UTC 2023

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

Log Message:
make: fix declared types of list nodes

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.285 -r1.286 src/usr.bin/make/dir.c
cvs rdiff -u -r1.260 -r1.261 src/usr.bin/make/make.c
cvs rdiff -u -r1.373 -r1.374 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/usr.bin/make/unit-tests

2023-12-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Dec 29 15:47:03 UTC 2023

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

Log Message:
tests/make: test the '::=' assignment modifier


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/varmod-assign.exp
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varmod-assign.mk

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

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-assign.exp
diff -u src/usr.bin/make/unit-tests/varmod-assign.exp:1.17 src/usr.bin/make/unit-tests/varmod-assign.exp:1.18
--- src/usr.bin/make/unit-tests/varmod-assign.exp:1.17	Tue Nov 30 20:48:01 2021
+++ src/usr.bin/make/unit-tests/varmod-assign.exp	Fri Dec 29 15:47:03 2023
@@ -12,6 +12,31 @@ Var_Parse: ${${VARNAME}} != "assigned-va
 Var_Parse: ${VARNAME}} != "assigned-value" (eval-defined)
 Global: .MAKEFLAGS =  -r -k -d v -d
 Global: .MAKEFLAGS =  -r -k -d v -d 0
+Var_Parse: ${CMD_CMD_VAR::=new-value}  || ${CMD_GLOBAL_VAR::=new-value}  || ${CMD_ENV_VAR::=new-value}  || "${CMD_NEW_VAR::=new-value}" (eval-defined)
+Evaluating modifier ${CMD_CMD_VAR::...} on value "cmd-value"
+Modifier part: "new-value"
+Command: CMD_CMD_VAR = new-value
+Global: .MAKEOVERRIDES =  FIRST LAST LAST LAST APPENDED RAN RAN RAN IT1 THEN1 IE2 ELSE2 CMD_CMD_VAR CMD_CMD_VAR
+Result of ${CMD_CMD_VAR::=new-value} is ""
+Var_Parse: ${CMD_GLOBAL_VAR::=new-value}  || ${CMD_ENV_VAR::=new-value}  || "${CMD_NEW_VAR::=new-value}" (eval-defined)
+Evaluating modifier ${CMD_GLOBAL_VAR::...} on value "global-value"
+Modifier part: "new-value"
+Global: CMD_GLOBAL_VAR = new-value
+Result of ${CMD_GLOBAL_VAR::=new-value} is ""
+Var_Parse: ${CMD_ENV_VAR::=new-value}  || "${CMD_NEW_VAR::=new-value}" (eval-defined)
+Evaluating modifier ${CMD_ENV_VAR::...} on value "env-value"
+Modifier part: "new-value"
+Global: CMD_ENV_VAR = new-value
+Result of ${CMD_ENV_VAR::=new-value} is ""
+Var_Parse: ${CMD_NEW_VAR::=new-value}" (eval)
+Evaluating modifier ${CMD_NEW_VAR::...} on value "" (eval, undefined)
+Modifier part: "new-value"
+Global: ignoring delete 'CMD_NEW_VAR' as it is not found
+Command: CMD_NEW_VAR = new-value
+Global: .MAKEOVERRIDES =  FIRST LAST LAST LAST APPENDED RAN RAN RAN IT1 THEN1 IE2 ELSE2 CMD_CMD_VAR CMD_CMD_VAR CMD_NEW_VAR
+Result of ${CMD_NEW_VAR::=new-value} is "" (eval, undefined)
+Global: .MAKEFLAGS =  -r -k -d v -d 0 -d v -d
+Global: .MAKEFLAGS =  -r -k -d v -d 0 -d v -d 0
 make: Bad modifier ":" for variable ""
 mod-assign-empty: value}
 make: Bad modifier ":" for variable ""

Index: src/usr.bin/make/unit-tests/varmod-assign.mk
diff -u src/usr.bin/make/unit-tests/varmod-assign.mk:1.16 src/usr.bin/make/unit-tests/varmod-assign.mk:1.17
--- src/usr.bin/make/unit-tests/varmod-assign.mk:1.16	Sun Nov 19 21:47:52 2023
+++ src/usr.bin/make/unit-tests/varmod-assign.mk	Fri Dec 29 15:47:03 2023
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-assign.mk,v 1.16 2023/11/19 21:47:52 rillig Exp $
+# $NetBSD: varmod-assign.mk,v 1.17 2023/12/29 15:47:03 rillig Exp $
 #
 # Tests for the obscure ::= variable modifiers, which perform variable
 # assignments during evaluation, just like the = operator in C.
@@ -7,34 +7,38 @@ all:	mod-assign-empty
 all:	mod-assign-parse
 all:	mod-assign-shell-error
 
-# The modifier '::?=' applies the assignment operator '?=' 3 times. The
+# In the following loop expression,
+# the '::?=' modifier applies the assignment operator '?=' 3 times. The
 # operator '?=' only has an effect for the first time, therefore the variable
 # FIRST ends up with the value 1.
 .if "${1 2 3:L:@i@${FIRST::?=$i}@} first=${FIRST}" != " first=1"
 .  error
 .endif
 
-# The modifier '::=' applies the assignment operator '=' 3 times. The
+# In the following loop expression,
+# the modifier '::=' applies the assignment operator '=' 3 times. The
 # operator '=' overwrites the previous value, therefore the variable LAST ends
 # up with the value 3.
 .if "${1 2 3:L:@i@${LAST::=$i}@} last=${LAST}" != " last=3"
 .  error
 .endif
 
-# The modifier '::+=' applies the assignment operator '+=' 3 times. The
+# In the following loop expression,
+# the modifier '::+=' applies the assignment operator '+=' 3 times. The
 # operator '+=' appends 3 times to the variable, therefore the variable
 # APPENDED ends up with the value "1 2 3".
 .if "${1 2 3:L:@i@${APPENDED::+=$i}@} appended=${APPENDED}" != " appended=1 2 3"
 .  error
 .endif
 
-# The modifier '::!=' applies the assignment operator '!=' 3 times. Just as
+# In the following loop expression,
+# the modifier '::!=' applies the assignment operator '!=' 3 times. Just as
 # with the modifier '::=', the last value is stored in the RAN variable.
 .if "${1 2 3:L:@i@${RAN::!=${i:%=echo '<%>';}}@} ran=${RAN}" != " ran=<3>"
 .  error
 .endif
 
-# The assignments were performed as part of .if conditions and thus happened
+# When a '::=' modifier is 

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

2023-12-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Dec 29 15:47:03 UTC 2023

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

Log Message:
tests/make: test the '::=' assignment modifier


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/varmod-assign.exp
cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varmod-assign.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

2023-12-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Dec 29 14:57:00 UTC 2023

Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: varmod-defined.exp
varname-dot-suffixes.exp

Log Message:
make: simplify debug message for the ':@var@...@' modifier

The previous variant was hard to understand.


To generate a diff of this commit:
cvs rdiff -u -r1.1089 -r1.1090 src/usr.bin/make/var.c
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-defined.exp
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varname-dot-suffixes.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

2023-12-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Dec 29 14:57:00 UTC 2023

Modified Files:
src/usr.bin/make: var.c
src/usr.bin/make/unit-tests: varmod-defined.exp
varname-dot-suffixes.exp

Log Message:
make: simplify debug message for the ':@var@...@' modifier

The previous variant was hard to understand.


To generate a diff of this commit:
cvs rdiff -u -r1.1089 -r1.1090 src/usr.bin/make/var.c
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-defined.exp
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varname-dot-suffixes.exp

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.1089 src/usr.bin/make/var.c:1.1090
--- src/usr.bin/make/var.c:1.1089	Fri Dec 29 13:25:15 2023
+++ src/usr.bin/make/var.c	Fri Dec 29 14:57:00 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1089 2023/12/29 13:25:15 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.1090 2023/12/29 14:57:00 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1089 2023/12/29 13:25:15 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1090 2023/12/29 14:57:00 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -1597,9 +1597,8 @@ ModifyWord_Loop(Substring word, SepBuf *
 	/* TODO: handle errors */
 
 	assert(word.end[0] == '\0');	/* assume null-terminated word */
-	DEBUG4(VAR, "ModifyWord_Loop: "
-		"in \"%s\", replace \"%s\" with \"%s\" to \"%s\"\n",
-	word.start, args->var, args->body, s);
+	DEBUG2(VAR, "ModifyWord_Loop: expand \"%s\" to \"%s\"\n",
+	args->body, s);
 
 	if (s[0] == '\n' || Buf_EndsWith(>buf, '\n'))
 		buf->needSep = false;

Index: src/usr.bin/make/unit-tests/varmod-defined.exp
diff -u src/usr.bin/make/unit-tests/varmod-defined.exp:1.13 src/usr.bin/make/unit-tests/varmod-defined.exp:1.14
--- src/usr.bin/make/unit-tests/varmod-defined.exp:1.13	Tue Aug 23 19:22:01 2022
+++ src/usr.bin/make/unit-tests/varmod-defined.exp	Fri Dec 29 14:57:00 2023
@@ -14,7 +14,7 @@ Modifier part: "${8_DOLLARS}"
 ModifyWords: split "" into 1 word
 Global: var = 
 Var_Parse: ${8_DOLLARS} (eval-keep-undefined)
-ModifyWord_Loop: in "", replace "var" with "${8_DOLLARS}" to ""
+ModifyWord_Loop: expand "${8_DOLLARS}" to ""
 Global: delete var
 Result of ${VAR:@var@${8_DOLLARS}@} is "" (eval-keep-dollar-and-undefined, regular)
 Global: VAR = 

Index: src/usr.bin/make/unit-tests/varname-dot-suffixes.exp
diff -u src/usr.bin/make/unit-tests/varname-dot-suffixes.exp:1.7 src/usr.bin/make/unit-tests/varname-dot-suffixes.exp:1.8
--- src/usr.bin/make/unit-tests/varname-dot-suffixes.exp:1.7	Wed Dec 20 09:03:09 2023
+++ src/usr.bin/make/unit-tests/varname-dot-suffixes.exp	Fri Dec 29 14:57:00 2023
@@ -28,10 +28,10 @@ Modifier part: "${.SUFFIXES}"
 ModifyWords: split "1 2" into 2 words
 Command: ignoring '.SUFFIXES = 1' as it is read-only
 Var_Parse: ${.SUFFIXES} (eval-defined)
-ModifyWord_Loop: in "1", replace ".SUFFIXES" with "${.SUFFIXES}" to ".c .o .1 .err .tar.gz"
+ModifyWord_Loop: expand "${.SUFFIXES}" to ".c .o .1 .err .tar.gz"
 Command: ignoring '.SUFFIXES = 2' as it is read-only
 Var_Parse: ${.SUFFIXES} (eval-defined)
-ModifyWord_Loop: in "2", replace ".SUFFIXES" with "${.SUFFIXES}" to ".c .o .1 .err .tar.gz"
+ModifyWord_Loop: expand "${.SUFFIXES}" to ".c .o .1 .err .tar.gz"
 Command: ignoring delete '.SUFFIXES' as it is not found
 Result of ${1 2:@.SUFFIXES@${.SUFFIXES}@} is ".c .o .1 .err .tar.gz .c .o .1 .err .tar.gz" (eval-defined, defined)
 Global: .MAKEFLAGS =  -r -k -d v -d 0 -d v -d 0 -d v -d



CVS commit: src/usr.bin/make

2023-12-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Dec 29 13:25:15 UTC 2023

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

Log Message:
make: clean up variable handling

All variables from the command line scope have the fromCmd flag set, so
there is no need to check for it.

Inline redundant local variables.

Variables from a scope cannot be short-lived, so there is no need to
call VarFreeShortLived.

No functional change.


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

2023-12-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Dec 29 13:25:15 UTC 2023

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

Log Message:
make: clean up variable handling

All variables from the command line scope have the fromCmd flag set, so
there is no need to check for it.

Inline redundant local variables.

Variables from a scope cannot be short-lived, so there is no need to
call VarFreeShortLived.

No functional change.


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

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.1088 src/usr.bin/make/var.c:1.1089
--- src/usr.bin/make/var.c:1.1088	Fri Dec 29 12:59:43 2023
+++ src/usr.bin/make/var.c	Fri Dec 29 13:25:15 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1088 2023/12/29 12:59:43 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.1089 2023/12/29 13:25:15 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1088 2023/12/29 12:59:43 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1089 2023/12/29 13:25:15 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -897,20 +897,6 @@ Var_UnExport(bool isEnv, const char *arg
 	FStr_Done();
 }
 
-/*
- * When there is a variable of the same name in the command line scope, the
- * global variable would not be visible anywhere.  Therefore, there is no
- * point in setting it at all.
- *
- * See 'scope == SCOPE_CMDLINE' in Var_SetWithFlags.
- */
-static bool
-ExistsInCmdline(const char *name)
-{
-	Var *v = VarFind(name, SCOPE_CMDLINE, false);
-	return v != NULL && v->fromCmd;
-}
-
 /* Set the variable to the value; the name is not expanded. */
 void
 Var_SetWithFlags(GNode *scope, const char *name, const char *val,
@@ -926,7 +912,12 @@ Var_SetWithFlags(GNode *scope, const cha
 		return;
 	}
 
-	if (scope == SCOPE_GLOBAL && ExistsInCmdline(name)) {
+	if (scope == SCOPE_GLOBAL
+	&& VarFind(name, SCOPE_CMDLINE, false) != NULL) {
+		/*
+		 * The global variable would not be visible anywhere.
+		 * Therefore, there is no point in setting it at all.
+		 */
 		DEBUG3(VAR,
 		"%s: ignoring '%s = %s' "
 		"due to a command line variable of the same name\n",
@@ -1023,7 +1014,6 @@ Var_Set(GNode *scope, const char *name, 
 void
 Var_SetExpand(GNode *scope, const char *name, const char *val)
 {
-	const char *unexpanded_name = name;
 	FStr varname = FStr_InitRefer(name);
 
 	assert(val != NULL);
@@ -1034,7 +1024,7 @@ Var_SetExpand(GNode *scope, const char *
 		DEBUG4(VAR,
 		"%s: ignoring '%s = %s' "
 		"as the variable name '%s' expands to empty\n",
-		scope->name, varname.str, val, unexpanded_name);
+		scope->name, varname.str, val, name);
 	} else
 		Var_SetWithFlags(scope, varname.str, val, VAR_SET_NONE);
 
@@ -1421,10 +1411,9 @@ ModifyWord_Subst(Substring word, SepBuf 
 {
 	struct ModifyWord_SubstArgs *args = data;
 	size_t wordLen, lhsLen;
-	const char *wordEnd, *match;
+	const char *match;
 
 	wordLen = Substring_Length(word);
-	wordEnd = word.end;
 	if (args->pflags.subOnce && args->matched)
 		goto nosub;
 
@@ -1439,7 +1428,7 @@ ModifyWord_Subst(Substring word, SepBuf 
 
 		/* :S,^prefix,replacement, or :S,^whole$,replacement, */
 		SepBuf_AddSubstring(buf, args->rhs);
-		SepBuf_AddRange(buf, word.start + lhsLen, wordEnd);
+		SepBuf_AddRange(buf, word.start + lhsLen, word.end);
 		args->matched = true;
 		return;
 	}
@@ -1447,11 +1436,11 @@ ModifyWord_Subst(Substring word, SepBuf 
 	if (args->pflags.anchorEnd) {
 		if (wordLen < lhsLen)
 			goto nosub;
-		if (memcmp(wordEnd - lhsLen, args->lhs.start, lhsLen) != 0)
+		if (memcmp(word.end - lhsLen, args->lhs.start, lhsLen) != 0)
 			goto nosub;
 
 		/* :S,suffix$,replacement, */
-		SepBuf_AddRange(buf, word.start, wordEnd - lhsLen);
+		SepBuf_AddRange(buf, word.start, word.end - lhsLen);
 		SepBuf_AddSubstring(buf, args->rhs);
 		args->matched = true;
 		return;
@@ -2066,7 +2055,6 @@ static void
 ParseModifierPartBalanced(const char **pp, LazyBuf *part)
 {
 	const char *p = *pp;
-	const char *start = *pp;
 
 	if (p[1] == '(' || p[1] == '{') {
 		char startc = p[1];
@@ -2081,10 +2069,10 @@ ParseModifierPartBalanced(const char **p
 	depth--;
 			}
 		}
-		LazyBuf_AddSubstring(part, Substring_Init(start, p));
+		LazyBuf_AddSubstring(part, Substring_Init(*pp, p));
 		*pp = p;
 	} else {
-		LazyBuf_Add(part, *start);
+		LazyBuf_Add(part, *p);
 		*pp = p + 1;
 	}
 }
@@ -3480,7 +3468,7 @@ found_op:
 		return AMR_BAD;
 	}
 
-	*pp = mod + (op[0] == '+' || op[0] == '?' || op[0] == '!' ? 3 : 2);
+	*pp = mod + (op[0] != '=' ? 3 : 2);
 
 	if (!ParseModifierPart(pp, ch->endc, expr->emode, ch, ))
 		return AMR_CLEANUP;
@@ -3492,13 +3480,9 @@ found_op:
 		goto done;
 
 	scope = expr->scope;	/* scope where v 

CVS commit: src/usr.bin/make

2023-12-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Dec 29 12:59:43 UTC 2023

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

Log Message:
make: clean up comments

No binary change, except for line numbers in assertions.


To generate a diff of this commit:
cvs rdiff -u -r1.358 -r1.359 src/usr.bin/make/cond.c
cvs rdiff -u -r1.461 -r1.462 src/usr.bin/make/job.c
cvs rdiff -u -r1.1087 -r1.1088 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.358 src/usr.bin/make/cond.c:1.359
--- src/usr.bin/make/cond.c:1.358	Fri Dec 29 12:20:55 2023
+++ src/usr.bin/make/cond.c	Fri Dec 29 12:59:43 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.358 2023/12/29 12:20:55 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.359 2023/12/29 12:59:43 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -91,7 +91,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.358 2023/12/29 12:20:55 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.359 2023/12/29 12:59:43 rillig Exp $");
 
 /*
  * Conditional expressions conform to this grammar:
@@ -165,9 +165,7 @@ typedef struct CondParser {
 
 	/*
 	 * Whether an error message has already been printed for this
-	 * condition. The first available error message is usually the most
-	 * specific one, therefore it makes sense to suppress the standard
-	 * "Malformed conditional" message.
+	 * condition.
 	 */
 	bool printedError;
 } CondParser;
@@ -257,7 +255,7 @@ ParseFuncArg(CondParser *par, const char
 	const char *p = *pp;
 	char *res;
 
-	p++;			/* Skip opening '(' - verified by caller */
+	p++;			/* skip the '(' */
 	cpp_skip_hspace();
 	res = ParseWord(, doEval);
 	cpp_skip_hspace();
@@ -486,10 +484,6 @@ CondParser_Leaf(CondParser *par, bool do
 		default:
 			if (!unquotedOK && !quoted && *start != '$' &&
 			!ch_isdigit(*start)) {
-/*
- * The left-hand side must be quoted,
- * an expression or a number.
- */
 str = FStr_InitRefer(NULL);
 goto return_str;
 			}
@@ -743,13 +737,12 @@ CondParser_ComparisonOrLeaf(CondParser *
 	char *arg;
 	const char *p;
 
-	/* Push anything numeric through the compare expression */
 	p = par->p;
 	if (ch_isdigit(p[0]) || p[0] == '-' || p[0] == '+')
 		return CondParser_Comparison(par, doEval);
 
 	/*
-	 * Most likely we have a naked token to apply the default function to.
+	 * Most likely we have a bare word to apply the default function to.
 	 * However, ".if a == b" gets here when the "a" is unquoted and
 	 * doesn't start with a '$'. This surprises people.
 	 * If what follows the function argument is a '=' or '!' then the

Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.461 src/usr.bin/make/job.c:1.462
--- src/usr.bin/make/job.c:1.461	Tue Dec 19 19:33:39 2023
+++ src/usr.bin/make/job.c	Fri Dec 29 12:59:43 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.461 2023/12/19 19:33:39 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.462 2023/12/29 12:59:43 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -141,7 +141,7 @@
 #include "trace.h"
 
 /*	"@(#)job.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: job.c,v 1.461 2023/12/19 19:33:39 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.462 2023/12/29 12:59:43 rillig Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -857,13 +857,9 @@ static void
 JobWriteSpecials(Job *job, ShellWriter *wr, const char *escCmd, bool run,
 		 CommandFlags *inout_cmdFlags, const char **inout_cmdTemplate)
 {
-	if (!run) {
-		/*
-		 * If there is no command to run, there is no need to switch
-		 * error checking off and on again for nothing.
-		 */
+	if (!run)
 		inout_cmdFlags->ignerr = false;
-	} else if (shell->hasErrCtl)
+	else if (shell->hasErrCtl)
 		ShellWriter_ErrOff(wr, job->echo && inout_cmdFlags->echo);
 	else if (shell->runIgnTmpl != NULL && shell->runIgnTmpl[0] != '\0') {
 		JobWriteSpecialsEchoCtl(job, wr, inout_cmdFlags, escCmd,

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.1087 src/usr.bin/make/var.c:1.1088
--- src/usr.bin/make/var.c:1.1087	Fri Dec 29 12:20:55 2023
+++ src/usr.bin/make/var.c	Fri Dec 29 12:59:43 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1087 2023/12/29 12:20:55 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.1088 2023/12/29 12:59:43 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1087 2023/12/29 12:20:55 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1088 2023/12/29 12:59:43 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -261,10 +261,7 @@ typedef struct SepBuf {
 } SepBuf;
 
 
-/*
- * This lets us tell if we 

CVS commit: src/usr.bin/make

2023-12-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Dec 29 12:59:43 UTC 2023

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

Log Message:
make: clean up comments

No binary change, except for line numbers in assertions.


To generate a diff of this commit:
cvs rdiff -u -r1.358 -r1.359 src/usr.bin/make/cond.c
cvs rdiff -u -r1.461 -r1.462 src/usr.bin/make/job.c
cvs rdiff -u -r1.1087 -r1.1088 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

2023-12-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Dec 29 12:20:55 UTC 2023

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

Log Message:
make: simplify memory allocation for string buffers

In edge cases and short-lived buffers, the initial buffer size is
irrelevant, so use the default.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.357 -r1.358 src/usr.bin/make/cond.c
cvs rdiff -u -r1.259 -r1.260 src/usr.bin/make/make.c
cvs rdiff -u -r1.372 -r1.373 src/usr.bin/make/suff.c
cvs rdiff -u -r1.1086 -r1.1087 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.357 src/usr.bin/make/cond.c:1.358
--- src/usr.bin/make/cond.c:1.357	Tue Dec 19 19:33:39 2023
+++ src/usr.bin/make/cond.c	Fri Dec 29 12:20:55 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.357 2023/12/19 19:33:39 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.358 2023/12/29 12:20:55 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -91,7 +91,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.357 2023/12/19 19:33:39 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.358 2023/12/29 12:20:55 rillig Exp $");
 
 /*
  * Conditional expressions conform to this grammar:
@@ -213,7 +213,7 @@ ParseWord(const char **pp, bool doEval)
 	Buffer word;
 	int depth;
 
-	Buf_InitSize(, 16);
+	Buf_Init();
 
 	depth = 0;
 	for (;;) {

Index: src/usr.bin/make/make.c
diff -u src/usr.bin/make/make.c:1.259 src/usr.bin/make/make.c:1.260
--- src/usr.bin/make/make.c:1.259	Tue Feb 14 21:38:31 2023
+++ src/usr.bin/make/make.c	Fri Dec 29 12:20:55 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.259 2023/02/14 21:38:31 rillig Exp $	*/
+/*	$NetBSD: make.c,v 1.260 2023/12/29 12:20:55 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -104,7 +104,7 @@
 #include "job.h"
 
 /*	"@(#)make.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: make.c,v 1.259 2023/02/14 21:38:31 rillig Exp $");
+MAKE_RCSID("$NetBSD: make.c,v 1.260 2023/12/29 12:20:55 rillig Exp $");
 
 /* Sequence # to detect recursion. */
 static unsigned int checked_seqno = 1;
@@ -132,7 +132,7 @@ GNodeType_ToString(GNodeType type, void 
 {
 	Buffer buf;
 
-	Buf_InitSize(, 32);
+	Buf_Init();
 #define ADD(flag) Buf_AddFlag(, (type & (flag)) != OP_NONE, #flag)
 	ADD(OP_DEPENDS);
 	ADD(OP_FORCE);
@@ -174,7 +174,7 @@ GNodeFlags_ToString(GNodeFlags flags, vo
 {
 	Buffer buf;
 
-	Buf_InitSize(, 32);
+	Buf_Init();
 	Buf_AddFlag(, flags.remake, "REMAKE");
 	Buf_AddFlag(, flags.childMade, "CHILDMADE");
 	Buf_AddFlag(, flags.force, "FORCE");

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.372 src/usr.bin/make/suff.c:1.373
--- src/usr.bin/make/suff.c:1.372	Tue Dec 19 19:33:39 2023
+++ src/usr.bin/make/suff.c	Fri Dec 29 12:20:55 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.372 2023/12/19 19:33:39 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.373 2023/12/29 12:20:55 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.372 2023/12/19 19:33:39 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.373 2023/12/29 12:20:55 rillig Exp $");
 
 typedef List SuffixList;
 typedef ListNode SuffixListNode;
@@ -2113,7 +2113,7 @@ Suffix_Print(const Suffix *suff)
 {
 	Buffer buf;
 
-	Buf_InitSize(, 16);
+	Buf_Init();
 	Buf_AddFlag(, suff->include, "SUFF_INCLUDE");
 	Buf_AddFlag(, suff->library, "SUFF_LIBRARY");
 	Buf_AddFlag(, suff->isNull, "SUFF_NULL");
@@ -2169,7 +2169,7 @@ Suff_NamesStr(void)
 	SuffixListNode *ln;
 	Suffix *suff;
 
-	Buf_InitSize(, 16);
+	Buf_Init();
 	for (ln = sufflist.first; ln != NULL; ln = ln->next) {
 		suff = ln->datum;
 		if (ln != sufflist.first)

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.1086 src/usr.bin/make/var.c:1.1087
--- src/usr.bin/make/var.c:1.1086	Wed Dec 20 09:03:08 2023
+++ src/usr.bin/make/var.c	Fri Dec 29 12:20:55 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1086 2023/12/20 09:03:08 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.1087 2023/12/29 12:20:55 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1086 2023/12/20 09:03:08 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1087 2023/12/29 12:20:55 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -3252,7 +3252,7 @@ ApplyModifier_Words(const char **pp, Mod
 			size_t ac = words.len;
 			SubstringWords_Free(words);
 
-			Buf_InitSize(, 4);
+			Buf_Init();
 			Buf_AddInt(, (int)ac);
 			Expr_SetValueOwn(expr, Buf_DoneData());
 		}



CVS commit: src/usr.bin/make

2023-12-29 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Dec 29 12:20:55 UTC 2023

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

Log Message:
make: simplify memory allocation for string buffers

In edge cases and short-lived buffers, the initial buffer size is
irrelevant, so use the default.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.357 -r1.358 src/usr.bin/make/cond.c
cvs rdiff -u -r1.259 -r1.260 src/usr.bin/make/make.c
cvs rdiff -u -r1.372 -r1.373 src/usr.bin/make/suff.c
cvs rdiff -u -r1.1086 -r1.1087 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

2023-12-26 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Wed Dec 27 00:45:37 UTC 2023

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

Log Message:
make: ensure shellPath is set before using it.


To generate a diff of this commit:
cvs rdiff -u -r1.605 -r1.606 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.605 src/usr.bin/make/main.c:1.606
--- src/usr.bin/make/main.c:1.605	Sun Dec 17 09:02:26 2023
+++ src/usr.bin/make/main.c	Wed Dec 27 00:45:37 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.605 2023/12/17 09:02:26 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.606 2023/12/27 00:45:37 sjg 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.605 2023/12/17 09:02:26 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.606 2023/12/27 00:45:37 sjg Exp $");
 #if defined(MAKE_NATIVE)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	"The Regents of the University of California.  "
@@ -1706,7 +1706,7 @@ Cmd_Exec(const char *cmd, char **error)
 	char *p;
 	int saved_errno;
 
-	if (shellName == NULL)
+	if (shellPath == NULL)
 		Shell_Init();
 
 	args[0] = shellName;



CVS commit: src/usr.bin/make

2023-12-26 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Wed Dec 27 00:45:37 UTC 2023

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

Log Message:
make: ensure shellPath is set before using it.


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

2023-12-26 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Tue Dec 26 20:09:42 UTC 2023

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

Log Message:
Move fflush to a point to catch all cases.


To generate a diff of this commit:
cvs rdiff -u -r1.250 -r1.251 src/usr.bin/make/compat.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

2023-12-26 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Tue Dec 26 20:09:42 UTC 2023

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

Log Message:
Move fflush to a point to catch all cases.


To generate a diff of this commit:
cvs rdiff -u -r1.250 -r1.251 src/usr.bin/make/compat.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/compat.c
diff -u src/usr.bin/make/compat.c:1.250 src/usr.bin/make/compat.c:1.251
--- src/usr.bin/make/compat.c:1.250	Tue Dec 26 17:12:33 2023
+++ src/usr.bin/make/compat.c	Tue Dec 26 20:09:42 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.250 2023/12/26 17:12:33 sjg Exp $	*/
+/*	$NetBSD: compat.c,v 1.251 2023/12/26 20:09:42 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -91,7 +91,7 @@
 #include "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.250 2023/12/26 17:12:33 sjg Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.251 2023/12/26 20:09:42 sjg Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -400,7 +400,6 @@ Compat_RunCommand(const char *cmdp, GNod
  * but let others continue.
  */
 printf(" (continuing)\n");
-fflush(stdout);
 			} else {
 printf("\n");
 			}
@@ -412,9 +411,9 @@ Compat_RunCommand(const char *cmdp, GNod
 			 * If we return 0, this will happen...
 			 */
 			printf(" (ignored)\n");
-			fflush(stdout);
 			status = 0;
 		}
+		fflush(stdout);
 	}
 
 	free(cmdStart);



CVS commit: src/usr.bin/make

2023-12-26 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Tue Dec 26 17:12:33 UTC 2023

Modified Files:
src/usr.bin/make: compat.c
src/usr.bin/make/unit-tests: depsrc-ignore.exp
deptgt-delete_on_error.exp sh-leading-hyphen.exp

Log Message:
make: fix order of output in compat mode

Ensure that make's output is correctly ordered with the output of the
target's commands, even when the output does not go to a terminal.

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.249 -r1.250 src/usr.bin/make/compat.c
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/depsrc-ignore.exp \
src/usr.bin/make/unit-tests/sh-leading-hyphen.exp
cvs rdiff -u -r1.3 -r1.4 \
src/usr.bin/make/unit-tests/deptgt-delete_on_error.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

2023-12-26 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Tue Dec 26 17:12:33 UTC 2023

Modified Files:
src/usr.bin/make: compat.c
src/usr.bin/make/unit-tests: depsrc-ignore.exp
deptgt-delete_on_error.exp sh-leading-hyphen.exp

Log Message:
make: fix order of output in compat mode

Ensure that make's output is correctly ordered with the output of the
target's commands, even when the output does not go to a terminal.

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.249 -r1.250 src/usr.bin/make/compat.c
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/depsrc-ignore.exp \
src/usr.bin/make/unit-tests/sh-leading-hyphen.exp
cvs rdiff -u -r1.3 -r1.4 \
src/usr.bin/make/unit-tests/deptgt-delete_on_error.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/compat.c
diff -u src/usr.bin/make/compat.c:1.249 src/usr.bin/make/compat.c:1.250
--- src/usr.bin/make/compat.c:1.249	Sun Dec 24 16:48:30 2023
+++ src/usr.bin/make/compat.c	Tue Dec 26 17:12:33 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.249 2023/12/24 16:48:30 sjg Exp $	*/
+/*	$NetBSD: compat.c,v 1.250 2023/12/26 17:12:33 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -91,7 +91,7 @@
 #include "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.249 2023/12/24 16:48:30 sjg Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.250 2023/12/26 17:12:33 sjg Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -400,6 +400,7 @@ Compat_RunCommand(const char *cmdp, GNod
  * but let others continue.
  */
 printf(" (continuing)\n");
+fflush(stdout);
 			} else {
 printf("\n");
 			}
@@ -411,6 +412,7 @@ Compat_RunCommand(const char *cmdp, GNod
 			 * If we return 0, this will happen...
 			 */
 			printf(" (ignored)\n");
+			fflush(stdout);
 			status = 0;
 		}
 	}

Index: src/usr.bin/make/unit-tests/depsrc-ignore.exp
diff -u src/usr.bin/make/unit-tests/depsrc-ignore.exp:1.2 src/usr.bin/make/unit-tests/depsrc-ignore.exp:1.3
--- src/usr.bin/make/unit-tests/depsrc-ignore.exp:1.2	Sat Aug 29 15:06:33 2020
+++ src/usr.bin/make/unit-tests/depsrc-ignore.exp	Tue Dec 26 17:12:33 2023
@@ -1,8 +1,8 @@
 ignore-errors begin
 false ignore-errors
+*** Error code 1 (ignored)
 ignore-errors end
 all begin
-*** Error code 1 (ignored)
 false all
 *** Error code 1 (continuing)
 
Index: src/usr.bin/make/unit-tests/sh-leading-hyphen.exp
diff -u src/usr.bin/make/unit-tests/sh-leading-hyphen.exp:1.2 src/usr.bin/make/unit-tests/sh-leading-hyphen.exp:1.3
--- src/usr.bin/make/unit-tests/sh-leading-hyphen.exp:1.2	Thu Jan 19 19:55:27 2023
+++ src/usr.bin/make/unit-tests/sh-leading-hyphen.exp	Tue Dec 26 17:12:33 2023
@@ -6,6 +6,6 @@ unknown-command: not found
 *** Error code 127 (ignored)
 unknown-long-option 'needed for needshell in compat.c'
 unknown-long-option: not found
-whitespace in leading part
 *** Error code 127 (ignored)
+whitespace in leading part
 exit status 0

Index: src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp
diff -u src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp:1.3 src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp:1.4
--- src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp:1.3	Sat Mar 18 22:20:12 2023
+++ src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp	Tue Dec 26 17:12:33 2023
@@ -16,6 +16,7 @@ make: *** deptgt-delete_on_error-regular
 
 Stop.
 make: stopped in unit-tests
+*** Error code 1 (ignored)
 
 Parallel mode
 > deptgt-delete_on_error-regular; false
@@ -45,5 +46,4 @@ make: stopped in unit-tests
 
 make: stopped in unit-tests
 *** Error code 1 (ignored)
-*** Error code 1 (ignored)
 exit status 0



CVS commit: src/usr.bin/make

2023-12-24 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sun Dec 24 16:48:30 UTC 2023

Modified Files:
src/usr.bin/make: compat.c make.1
src/usr.bin/make/unit-tests: shell-sh.mk

Log Message:
Compat_RunCommand call Shell_Init is shellPath is NULL

Since .SHELL is potentially used in compat mode as well,
the man page description should not imply it is only used in jobs mode.

Remove path="sh" from shell-sh unit-test - and it would have detected
this bug.

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.248 -r1.249 src/usr.bin/make/compat.c
cvs rdiff -u -r1.371 -r1.372 src/usr.bin/make/make.1
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/shell-sh.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/compat.c
diff -u src/usr.bin/make/compat.c:1.248 src/usr.bin/make/compat.c:1.249
--- src/usr.bin/make/compat.c:1.248	Tue Dec 19 19:33:39 2023
+++ src/usr.bin/make/compat.c	Sun Dec 24 16:48:30 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.248 2023/12/19 19:33:39 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.249 2023/12/24 16:48:30 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -91,7 +91,7 @@
 #include "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.248 2023/12/19 19:33:39 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.249 2023/12/24 16:48:30 sjg Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -275,11 +275,9 @@ Compat_RunCommand(const char *cmdp, GNod
 			silent = !DEBUG(LOUD);
 		else if (*cmd == '-')
 			errCheck = false;
-		else if (*cmd == '+') {
+		else if (*cmd == '+')
 			doIt = true;
-			if (shellName == NULL)	/* we came here from jobs */
-Shell_Init();
-		} else if (!ch_isspace(*cmd))
+		else if (!ch_isspace(*cmd))
 			/* Ignore whitespace for compatibility with gnu make */
 			break;
 		cmd++;
@@ -302,6 +300,9 @@ Compat_RunCommand(const char *cmdp, GNod
 
 	DEBUG1(JOB, "Execute: '%s'\n", cmd);
 
+	if (useShell && shellPath == NULL)
+		Shell_Init();		/* we need shellPath */
+
 	if (useShell) {
 		static const char *shargv[5];
 

Index: src/usr.bin/make/make.1
diff -u src/usr.bin/make/make.1:1.371 src/usr.bin/make/make.1:1.372
--- src/usr.bin/make/make.1:1.371	Sun Sep 10 21:52:36 2023
+++ src/usr.bin/make/make.1	Sun Dec 24 16:48:30 2023
@@ -1,4 +1,4 @@
-.\"	$NetBSD: make.1,v 1.371 2023/09/10 21:52:36 rillig Exp $
+.\"	$NetBSD: make.1,v 1.372 2023/12/24 16:48:30 sjg Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	from: @(#)make.1	8.4 (Berkeley) 3/19/94
 .\"
-.Dd September 9, 2023
+.Dd December 24, 2023
 .Dt MAKE 1
 .Os
 .Sh NAME
@@ -2522,7 +2522,7 @@ set the read-only attribute on the globa
 .It Ic .SHELL
 Sets the shell that
 .Nm
-uses to execute commands in jobs mode.
+uses to execute commands.
 The sources are a set of
 .Ar field\| Ns Cm \&= Ns Ar value
 pairs.

Index: src/usr.bin/make/unit-tests/shell-sh.mk
diff -u src/usr.bin/make/unit-tests/shell-sh.mk:1.1 src/usr.bin/make/unit-tests/shell-sh.mk:1.2
--- src/usr.bin/make/unit-tests/shell-sh.mk:1.1	Sat Oct  3 14:39:36 2020
+++ src/usr.bin/make/unit-tests/shell-sh.mk	Sun Dec 24 16:48:30 2023
@@ -1,9 +1,9 @@
-# $NetBSD: shell-sh.mk,v 1.1 2020/10/03 14:39:36 rillig Exp $
+# $NetBSD: shell-sh.mk,v 1.2 2023/12/24 16:48:30 sjg Exp $
 #
 # Tests for using a bourne shell for running the commands.
 # This is the default shell, so there's nothing surprising.
 
-.SHELL: name="sh" path="sh"
+.SHELL: name="sh"
 
 all:
 	: normal



CVS commit: src/usr.bin/make

2023-12-24 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sun Dec 24 16:48:30 UTC 2023

Modified Files:
src/usr.bin/make: compat.c make.1
src/usr.bin/make/unit-tests: shell-sh.mk

Log Message:
Compat_RunCommand call Shell_Init is shellPath is NULL

Since .SHELL is potentially used in compat mode as well,
the man page description should not imply it is only used in jobs mode.

Remove path="sh" from shell-sh unit-test - and it would have detected
this bug.

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.248 -r1.249 src/usr.bin/make/compat.c
cvs rdiff -u -r1.371 -r1.372 src/usr.bin/make/make.1
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/shell-sh.mk

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



  1   2   3   4   5   6   7   8   9   10   >