CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 09:28:35 UTC 2022

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

Log Message:
make: remove redundant variable in ParseDependencyTargetWord

No functional change.


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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 09:28:35 UTC 2022

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

Log Message:
make: remove redundant variable in ParseDependencyTargetWord

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.623 -r1.624 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.623 src/usr.bin/make/parse.c:1.624
--- src/usr.bin/make/parse.c:1.623	Fri Jan  7 09:19:43 2022
+++ src/usr.bin/make/parse.c	Fri Jan  7 09:28:35 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.623 2022/01/07 09:19:43 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.624 2022/01/07 09:28:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.623 2022/01/07 09:19:43 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.624 2022/01/07 09:28:35 rillig Exp $");
 
 /*
  * Structure for a file being read ("included file")
@@ -884,14 +884,11 @@ ParseDependencyTargetWord(char **pp, con
 			 * have been discovered in the initial Var_Subst and
 			 * we wouldn't be here.
 			 */
-			const char *nested_p = cp;
-			FStr nested_val;
+			FStr val;
 
-			(void)Var_Parse(_p, SCOPE_CMDLINE,
-			VARE_PARSE_ONLY, _val);
-			/* TODO: handle errors */
-			FStr_Done(_val);
-			cp += nested_p - cp;
+			(void)Var_Parse(, SCOPE_CMDLINE,
+			VARE_PARSE_ONLY, );
+			FStr_Done();
 		} else
 			cp++;
 	}



CVS commit: src/crypto/external/bsd/openssl/dist

2022-01-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan  7 15:50:11 UTC 2022

Modified Files:
src/crypto/external/bsd/openssl/dist: CHANGES Configure NEWS README
src/crypto/external/bsd/openssl/dist/apps: s_client.c s_server.c
speed.c
src/crypto/external/bsd/openssl/dist/crypto: armcap.c ppccap.c uid.c
src/crypto/external/bsd/openssl/dist/crypto/asn1: a_strex.c
src/crypto/external/bsd/openssl/dist/crypto/bn/asm: mips.pl
src/crypto/external/bsd/openssl/dist/crypto/ec: ec_asn1.c
src/crypto/external/bsd/openssl/dist/crypto/engine: eng_lib.c
src/crypto/external/bsd/openssl/dist/crypto/evp: e_aes.c evp_enc.c
src/crypto/external/bsd/openssl/dist/crypto/objects: o_names.c
src/crypto/external/bsd/openssl/dist/crypto/rand: rand_unix.c
src/crypto/external/bsd/openssl/dist/crypto/x509: x509_vfy.c
src/crypto/external/bsd/openssl/dist/ssl: d1_lib.c s3_cbc.c ssl_ciph.c
ssl_err.c ssl_lib.c t1_lib.c
src/crypto/external/bsd/openssl/dist/test: bntest.c ectest.c
evp_extra_test.c evp_test.c rsa_test.c
src/crypto/external/bsd/openssl/dist/test/testutil: format_output.c
tests.c

Log Message:
merge conflicts between openssl-1-1-1k and openssl-1-1-1m


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/crypto/external/bsd/openssl/dist/CHANGES \
src/crypto/external/bsd/openssl/dist/NEWS \
src/crypto/external/bsd/openssl/dist/README
cvs rdiff -u -r1.28 -r1.29 src/crypto/external/bsd/openssl/dist/Configure
cvs rdiff -u -r1.23 -r1.24 \
src/crypto/external/bsd/openssl/dist/apps/s_client.c \
src/crypto/external/bsd/openssl/dist/apps/s_server.c
cvs rdiff -u -r1.20 -r1.21 src/crypto/external/bsd/openssl/dist/apps/speed.c
cvs rdiff -u -r1.13 -r1.14 \
src/crypto/external/bsd/openssl/dist/crypto/armcap.c
cvs rdiff -u -r1.19 -r1.20 \
src/crypto/external/bsd/openssl/dist/crypto/ppccap.c
cvs rdiff -u -r1.7 -r1.8 src/crypto/external/bsd/openssl/dist/crypto/uid.c
cvs rdiff -u -r1.9 -r1.10 \
src/crypto/external/bsd/openssl/dist/crypto/asn1/a_strex.c
cvs rdiff -u -r1.8 -r1.9 \
src/crypto/external/bsd/openssl/dist/crypto/bn/asm/mips.pl
cvs rdiff -u -r1.11 -r1.12 \
src/crypto/external/bsd/openssl/dist/crypto/ec/ec_asn1.c
cvs rdiff -u -r1.8 -r1.9 \
src/crypto/external/bsd/openssl/dist/crypto/engine/eng_lib.c
cvs rdiff -u -r1.24 -r1.25 \
src/crypto/external/bsd/openssl/dist/crypto/evp/e_aes.c
cvs rdiff -u -r1.13 -r1.14 \
src/crypto/external/bsd/openssl/dist/crypto/evp/evp_enc.c
cvs rdiff -u -r1.9 -r1.10 \
src/crypto/external/bsd/openssl/dist/crypto/objects/o_names.c
cvs rdiff -u -r1.17 -r1.18 \
src/crypto/external/bsd/openssl/dist/crypto/rand/rand_unix.c
cvs rdiff -u -r1.23 -r1.24 \
src/crypto/external/bsd/openssl/dist/crypto/x509/x509_vfy.c
cvs rdiff -u -r1.11 -r1.12 src/crypto/external/bsd/openssl/dist/ssl/d1_lib.c
cvs rdiff -u -r1.10 -r1.11 src/crypto/external/bsd/openssl/dist/ssl/s3_cbc.c
cvs rdiff -u -r1.20 -r1.21 \
src/crypto/external/bsd/openssl/dist/ssl/ssl_ciph.c \
src/crypto/external/bsd/openssl/dist/ssl/ssl_lib.c
cvs rdiff -u -r1.18 -r1.19 src/crypto/external/bsd/openssl/dist/ssl/ssl_err.c
cvs rdiff -u -r1.33 -r1.34 src/crypto/external/bsd/openssl/dist/ssl/t1_lib.c
cvs rdiff -u -r1.8 -r1.9 src/crypto/external/bsd/openssl/dist/test/bntest.c \
src/crypto/external/bsd/openssl/dist/test/ectest.c \
src/crypto/external/bsd/openssl/dist/test/evp_test.c \
src/crypto/external/bsd/openssl/dist/test/rsa_test.c
cvs rdiff -u -r1.9 -r1.10 \
src/crypto/external/bsd/openssl/dist/test/evp_extra_test.c
cvs rdiff -u -r1.5 -r1.6 \
src/crypto/external/bsd/openssl/dist/test/testutil/format_output.c \
src/crypto/external/bsd/openssl/dist/test/testutil/tests.c

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



CVS commit: src/crypto/external/bsd/openssl/dist

2022-01-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan  7 15:50:11 UTC 2022

Modified Files:
src/crypto/external/bsd/openssl/dist: CHANGES Configure NEWS README
src/crypto/external/bsd/openssl/dist/apps: s_client.c s_server.c
speed.c
src/crypto/external/bsd/openssl/dist/crypto: armcap.c ppccap.c uid.c
src/crypto/external/bsd/openssl/dist/crypto/asn1: a_strex.c
src/crypto/external/bsd/openssl/dist/crypto/bn/asm: mips.pl
src/crypto/external/bsd/openssl/dist/crypto/ec: ec_asn1.c
src/crypto/external/bsd/openssl/dist/crypto/engine: eng_lib.c
src/crypto/external/bsd/openssl/dist/crypto/evp: e_aes.c evp_enc.c
src/crypto/external/bsd/openssl/dist/crypto/objects: o_names.c
src/crypto/external/bsd/openssl/dist/crypto/rand: rand_unix.c
src/crypto/external/bsd/openssl/dist/crypto/x509: x509_vfy.c
src/crypto/external/bsd/openssl/dist/ssl: d1_lib.c s3_cbc.c ssl_ciph.c
ssl_err.c ssl_lib.c t1_lib.c
src/crypto/external/bsd/openssl/dist/test: bntest.c ectest.c
evp_extra_test.c evp_test.c rsa_test.c
src/crypto/external/bsd/openssl/dist/test/testutil: format_output.c
tests.c

Log Message:
merge conflicts between openssl-1-1-1k and openssl-1-1-1m


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/crypto/external/bsd/openssl/dist/CHANGES \
src/crypto/external/bsd/openssl/dist/NEWS \
src/crypto/external/bsd/openssl/dist/README
cvs rdiff -u -r1.28 -r1.29 src/crypto/external/bsd/openssl/dist/Configure
cvs rdiff -u -r1.23 -r1.24 \
src/crypto/external/bsd/openssl/dist/apps/s_client.c \
src/crypto/external/bsd/openssl/dist/apps/s_server.c
cvs rdiff -u -r1.20 -r1.21 src/crypto/external/bsd/openssl/dist/apps/speed.c
cvs rdiff -u -r1.13 -r1.14 \
src/crypto/external/bsd/openssl/dist/crypto/armcap.c
cvs rdiff -u -r1.19 -r1.20 \
src/crypto/external/bsd/openssl/dist/crypto/ppccap.c
cvs rdiff -u -r1.7 -r1.8 src/crypto/external/bsd/openssl/dist/crypto/uid.c
cvs rdiff -u -r1.9 -r1.10 \
src/crypto/external/bsd/openssl/dist/crypto/asn1/a_strex.c
cvs rdiff -u -r1.8 -r1.9 \
src/crypto/external/bsd/openssl/dist/crypto/bn/asm/mips.pl
cvs rdiff -u -r1.11 -r1.12 \
src/crypto/external/bsd/openssl/dist/crypto/ec/ec_asn1.c
cvs rdiff -u -r1.8 -r1.9 \
src/crypto/external/bsd/openssl/dist/crypto/engine/eng_lib.c
cvs rdiff -u -r1.24 -r1.25 \
src/crypto/external/bsd/openssl/dist/crypto/evp/e_aes.c
cvs rdiff -u -r1.13 -r1.14 \
src/crypto/external/bsd/openssl/dist/crypto/evp/evp_enc.c
cvs rdiff -u -r1.9 -r1.10 \
src/crypto/external/bsd/openssl/dist/crypto/objects/o_names.c
cvs rdiff -u -r1.17 -r1.18 \
src/crypto/external/bsd/openssl/dist/crypto/rand/rand_unix.c
cvs rdiff -u -r1.23 -r1.24 \
src/crypto/external/bsd/openssl/dist/crypto/x509/x509_vfy.c
cvs rdiff -u -r1.11 -r1.12 src/crypto/external/bsd/openssl/dist/ssl/d1_lib.c
cvs rdiff -u -r1.10 -r1.11 src/crypto/external/bsd/openssl/dist/ssl/s3_cbc.c
cvs rdiff -u -r1.20 -r1.21 \
src/crypto/external/bsd/openssl/dist/ssl/ssl_ciph.c \
src/crypto/external/bsd/openssl/dist/ssl/ssl_lib.c
cvs rdiff -u -r1.18 -r1.19 src/crypto/external/bsd/openssl/dist/ssl/ssl_err.c
cvs rdiff -u -r1.33 -r1.34 src/crypto/external/bsd/openssl/dist/ssl/t1_lib.c
cvs rdiff -u -r1.8 -r1.9 src/crypto/external/bsd/openssl/dist/test/bntest.c \
src/crypto/external/bsd/openssl/dist/test/ectest.c \
src/crypto/external/bsd/openssl/dist/test/evp_test.c \
src/crypto/external/bsd/openssl/dist/test/rsa_test.c
cvs rdiff -u -r1.9 -r1.10 \
src/crypto/external/bsd/openssl/dist/test/evp_extra_test.c
cvs rdiff -u -r1.5 -r1.6 \
src/crypto/external/bsd/openssl/dist/test/testutil/format_output.c \
src/crypto/external/bsd/openssl/dist/test/testutil/tests.c

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

Modified files:

Index: src/crypto/external/bsd/openssl/dist/CHANGES
diff -u src/crypto/external/bsd/openssl/dist/CHANGES:1.27 src/crypto/external/bsd/openssl/dist/CHANGES:1.28
--- src/crypto/external/bsd/openssl/dist/CHANGES:1.27	Thu Mar 25 14:51:18 2021
+++ src/crypto/external/bsd/openssl/dist/CHANGES	Fri Jan  7 10:50:10 2022
@@ -7,6 +7,91 @@
  https://github.com/openssl/openssl/commits/ and pick the appropriate
  release branch.
 
+ Changes between 1.1.1l and 1.1.1m [14 Dec 2021]
+
+  *) Avoid loading of a dynamic engine twice.
+
+ [Bernd Edlinger]
+
+  *) Fixed building on Debian with kfreebsd kernels
+
+ [Mattias Ellert]
+
+  *) Prioritise DANE TLSA issuer certs over peer certs
+
+ [Viktor Dukhovni]
+
+  *) Fixed random API for MacOS prior to 10.12
+
+ These MacOS versions don't support the CommonCrypto APIs
+
+ [Lenny Primak]
+
+ Changes between 1.1.1k and 1.1.1l [24 Aug 2021]
+
+  *) Fixed an SM2 Decryption Buffer Overflow.
+
+ In order to decrypt SM2 encrypted data an application is 

CVS commit: src/doc

2022-01-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan  7 15:51:42 UTC 2022

Modified Files:
src/doc: 3RDPARTY CHANGES

Log Message:
new OpenSSL


To generate a diff of this commit:
cvs rdiff -u -r1.1828 -r1.1829 src/doc/3RDPARTY
cvs rdiff -u -r1.2855 -r1.2856 src/doc/CHANGES

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



CVS commit: src/doc

2022-01-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jan  7 15:51:42 UTC 2022

Modified Files:
src/doc: 3RDPARTY CHANGES

Log Message:
new OpenSSL


To generate a diff of this commit:
cvs rdiff -u -r1.1828 -r1.1829 src/doc/3RDPARTY
cvs rdiff -u -r1.2855 -r1.2856 src/doc/CHANGES

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

Modified files:

Index: src/doc/3RDPARTY
diff -u src/doc/3RDPARTY:1.1828 src/doc/3RDPARTY:1.1829
--- src/doc/3RDPARTY:1.1828	Sat Dec 18 13:05:55 2021
+++ src/doc/3RDPARTY	Fri Jan  7 10:51:42 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1828 2021/12/18 18:05:55 christos Exp $
+#	$NetBSD: 3RDPARTY,v 1.1829 2022/01/07 15:51:42 christos Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -1114,12 +1114,12 @@ markus is very cooperative about it):
 - adjust the DEFAULT_PKCS11_WHITELIST for ssh-agent
 
 Package:	OpenSSL
-Version:	1.0.2o/1.1.1k
-Current Vers:	1.0.2t/1.1.1k
+Version:	1.0.2o/1.1.1m
+Current Vers:	1.0.2t/1.1.1m
 Maintainer:	The OpenSSL Project
 Archive Site:	ftp://ftp.openssl.org/source/
 Home Page:	http://www.openssl.org/
-Date:		2021-03-25
+Date:		2022-01-07
 Mailing List:	openssl-annou...@openssl.org
 Responsible:	christos, mjf, tls, riastradh, spz
 License:	OpenSSL and SSLeay license (both BSD-like)

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2855 src/doc/CHANGES:1.2856
--- src/doc/CHANGES:1.2855	Mon Jan  3 12:21:13 2022
+++ src/doc/CHANGES	Fri Jan  7 10:51:42 2022
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2855 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2856 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -464,3 +464,4 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 		[jmcneill 20220103]
 	eqos(4): Add driver for DesignWare Ethernet Quality-of-Service
 		controller. [jmcneill 20220103]
+	OpenSSL: Imported 1.1.1m. [christos 20220107]



CVS commit: src/usr.bin/calendar/calendars

2022-01-07 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Jan  7 16:51:25 UTC 2022

Modified Files:
src/usr.bin/calendar/calendars: calendar.christian

Log Message:
Update Advent Sunday date to 2022


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/calendar/calendars/calendar.christian

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/calendar/calendars/calendar.christian
diff -u src/usr.bin/calendar/calendars/calendar.christian:1.9 src/usr.bin/calendar/calendars/calendar.christian:1.10
--- src/usr.bin/calendar/calendars/calendar.christian:1.9	Thu Oct 21 11:45:24 2021
+++ src/usr.bin/calendar/calendars/calendar.christian	Fri Jan  7 16:51:25 2022
@@ -13,7 +13,7 @@
 06/12*	Trinity Sunday (7 days after Pentecost)
 06/16*	Corpus Christi (11 days after Pentecost)
 10/18	Feast Day of St. Luke
-11/29*	First Sunday of Advent (4th Sunday before Christmas)
+11/27*	Advent Sunday (4th Sunday before Christmas)
 12/06	St. Nicholas' Day
 12/24	Christmas Eve
 12/25	Feast of the Nativity (Christmas)



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 12:44:57 UTC 2022

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

Log Message:
make: merge calls to ApplyModifier_Time

This enables GCC 11 to inline ApplyModifier_Time, like all the other
modifiers.  Similar pattern as for ':M' and ':N', as well as for ':D'
and ':U'.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.994 -r1.995 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.994 src/usr.bin/make/var.c:1.995
--- src/usr.bin/make/var.c:1.994	Fri Jan  7 12:37:27 2022
+++ src/usr.bin/make/var.c	Fri Jan  7 12:44:57 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.994 2022/01/07 12:37:27 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.995 2022/01/07 12:44:57 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.994 2022/01/07 12:37:27 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.995 2022/01/07 12:44:57 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -2596,13 +2596,14 @@ TryParseTime(const char **pp, time_t *ou
 
 /* :gmtime and :localtime */
 static ApplyModifierResult
-ApplyModifier_Time(const char **pp, ModChain *ch, bool gmt)
+ApplyModifier_Time(const char **pp, ModChain *ch)
 {
 	Expr *expr;
 	time_t t;
 	const char *args;
-
 	const char *mod = *pp;
+	bool gmt = mod[0] == 'g';
+
 	if (!ModMatchEq(mod, gmt ? "gmtime" : "localtime", ch))
 		return AMR_UNKNOWN;
 	args = mod + (gmt ? 6 : 9);
@@ -3832,15 +3833,14 @@ ApplyModifier(const char **pp, ModChain 
 	case 'E':
 		return ApplyModifier_WordFunc(pp, ch, ModifyWord_Suffix);
 	case 'g':
-		return ApplyModifier_Time(pp, ch, true);
+	case 'l':
+		return ApplyModifier_Time(pp, ch);
 	case 'H':
 		return ApplyModifier_WordFunc(pp, ch, ModifyWord_Head);
 	case 'h':
 		return ApplyModifier_Hash(pp, ch);
 	case 'L':
 		return ApplyModifier_Literal(pp, ch);
-	case 'l':
-		return ApplyModifier_Time(pp, ch, false);
 	case 'M':
 	case 'N':
 		return ApplyModifier_Match(pp, ch);



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 12:44:57 UTC 2022

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

Log Message:
make: merge calls to ApplyModifier_Time

This enables GCC 11 to inline ApplyModifier_Time, like all the other
modifiers.  Similar pattern as for ':M' and ':N', as well as for ':D'
and ':U'.

No functional change.


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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 09:19:43 UTC 2022

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

Log Message:
make: clean up function argument names and comments

No binary change except for assertion line numbers.


To generate a diff of this commit:
cvs rdiff -u -r1.323 -r1.324 src/usr.bin/make/cond.c
cvs rdiff -u -r1.622 -r1.623 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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 09:19:43 UTC 2022

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

Log Message:
make: clean up function argument names and comments

No binary change except for assertion line numbers.


To generate a diff of this commit:
cvs rdiff -u -r1.323 -r1.324 src/usr.bin/make/cond.c
cvs rdiff -u -r1.622 -r1.623 src/usr.bin/make/parse.c

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

Modified files:

Index: src/usr.bin/make/cond.c
diff -u src/usr.bin/make/cond.c:1.323 src/usr.bin/make/cond.c:1.324
--- src/usr.bin/make/cond.c:1.323	Fri Jan  7 09:02:19 2022
+++ src/usr.bin/make/cond.c	Fri Jan  7 09:19:43 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.323 2022/01/07 09:02:19 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.324 2022/01/07 09:19:43 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,10 +95,10 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.323 2022/01/07 09:02:19 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.324 2022/01/07 09:19:43 rillig Exp $");
 
 /*
- * The parsing of conditional expressions is based on this grammar:
+ * Conditional expressions conform to this grammar:
  *	Or -> And ('||' And)*
  *	And -> Term ('&&' Term)*
  *	Term -> Function '(' Argument ')'
@@ -109,13 +109,13 @@ MAKE_RCSID("$NetBSD: cond.c,v 1.323 2022
  *	Leaf -> "string"
  *	Leaf -> Number
  *	Leaf -> VariableExpression
- *	Leaf -> Symbol
+ *	Leaf -> BareWord
  *	Operator -> '==' | '!=' | '>' | '<' | '>=' | '<='
  *
- * 'Symbol' is an unquoted string literal to which the default function is
- * applied.
+ * BareWord is an unquoted string literal, its evaluation depends on the kind
+ * of '.if' directive.
  *
- * The tokens are scanned by CondToken, which returns:
+ * The tokens are scanned by CondParser_Token, which returns:
  *	TOK_AND		for '&&'
  *	TOK_OR		for '||'
  *	TOK_NOT		for '!'
@@ -288,9 +288,9 @@ ParseFuncArg(CondParser *par, const char
 
 /* Test whether the given variable is defined. */
 static bool
-FuncDefined(const char *arg)
+FuncDefined(const char *var)
 {
-	FStr value = Var_Value(SCOPE_CMDLINE, arg);
+	FStr value = Var_Value(SCOPE_CMDLINE, var);
 	bool result = value.str != NULL;
 	FStr_Done();
 	return result;
@@ -298,26 +298,26 @@ FuncDefined(const char *arg)
 
 /* See if the given target is requested to be made. */
 static bool
-FuncMake(const char *arg)
+FuncMake(const char *target)
 {
 	StringListNode *ln;
 
 	for (ln = opts.create.first; ln != NULL; ln = ln->next)
-		if (Str_Match(ln->datum, arg))
+		if (Str_Match(ln->datum, target))
 			return true;
 	return false;
 }
 
 /* See if the given file exists. */
 static bool
-FuncExists(const char *arg)
+FuncExists(const char *file)
 {
 	bool result;
 	char *path;
 
-	path = Dir_FindFile(arg, );
+	path = Dir_FindFile(file, );
 	DEBUG2(COND, "exists(%s) result is \"%s\"\n",
-	arg, path != NULL ? path : "");
+	file, path != NULL ? path : "");
 	result = path != NULL;
 	free(path);
 	return result;
@@ -325,9 +325,9 @@ FuncExists(const char *arg)
 
 /* See if the given node exists and is an actual target. */
 static bool
-FuncTarget(const char *arg)
+FuncTarget(const char *node)
 {
-	GNode *gn = Targ_FindNode(arg);
+	GNode *gn = Targ_FindNode(node);
 	return gn != NULL && GNode_IsTarget(gn);
 }
 
@@ -336,20 +336,16 @@ FuncTarget(const char *arg)
  * associated with it.
  */
 static bool
-FuncCommands(const char *arg)
+FuncCommands(const char *node)
 {
-	GNode *gn = Targ_FindNode(arg);
-	return gn != NULL && GNode_IsTarget(gn) && !Lst_IsEmpty(>commands);
+	GNode *gn = Targ_FindNode(node);
+	return gn != NULL && GNode_IsTarget(gn) &&
+	   !Lst_IsEmpty(>commands);
 }
 
 /*
- * Convert the given number into a double.
- * We try a base 10 or 16 integer conversion first, if that fails
- * then we try a floating point conversion instead.
- *
- * Results:
- *	Returns true if the conversion succeeded.
- *	Sets 'out_value' to the converted number.
+ * Convert the string into a floating-point number.  Accepted formats are
+ * base-10 integer, base-16 integer and finite floating point numbers.
  */
 static bool
 TryParseNumber(const char *str, double *out_value)
@@ -1262,11 +1258,9 @@ Cond_EvalLine(const char *line)
 	/* And evaluate the conditional expression */
 	res = CondEvalExpression(p, plain, evalBare, negate, true, false);
 	if (res == CR_ERROR) {
-		/*
-		 * Syntax error in conditional, error message already output.
-		 */
-		/* Skip everything to matching .endif */
-		/* XXX: An extra '.else' is not detected in this case. */
+		/* Syntax error, error message already output. */
+		/* Skip everything to the matching '.endif'. */
+		/* An extra '.else' is not detected in this case. */
 		cond_states[cond_depth] = IFS_WAS_ACTIVE;
 		return CR_FALSE;
 	}

Index: src/usr.bin/make/parse.c
diff -u 

CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 12:37:27 UTC 2022

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

Log Message:
make: merge duplicate code for modifiers 'gmtime' and 'localtime'

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.993 -r1.994 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.993 src/usr.bin/make/var.c:1.994
--- src/usr.bin/make/var.c:1.993	Fri Jan  7 12:33:25 2022
+++ src/usr.bin/make/var.c	Fri Jan  7 12:37:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.993 2022/01/07 12:33:25 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.994 2022/01/07 12:37:27 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.993 2022/01/07 12:33:25 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.994 2022/01/07 12:37:27 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -2594,19 +2594,21 @@ TryParseTime(const char **pp, time_t *ou
 	return true;
 }
 
-/* :gmtime */
+/* :gmtime and :localtime */
 static ApplyModifierResult
-ApplyModifier_Gmtime(const char **pp, ModChain *ch)
+ApplyModifier_Time(const char **pp, ModChain *ch, bool gmt)
 {
 	Expr *expr;
 	time_t t;
+	const char *args;
 
 	const char *mod = *pp;
-	if (!ModMatchEq(mod, "gmtime", ch))
+	if (!ModMatchEq(mod, gmt ? "gmtime" : "localtime", ch))
 		return AMR_UNKNOWN;
+	args = mod + (gmt ? 6 : 9);
 
-	if (mod[6] == '=') {
-		const char *p = mod + 7;
+	if (args[0] == '=') {
+		const char *p = args + 1;
 		if (!TryParseTime(, )) {
 			Parse_Error(PARSE_FATAL,
 			"Invalid time value at \"%s\"", p);
@@ -2615,45 +2617,12 @@ ApplyModifier_Gmtime(const char **pp, Mo
 		*pp = p;
 	} else {
 		t = 0;
-		*pp = mod + 6;
+		*pp = args;
 	}
 
 	expr = ch->expr;
 	if (Expr_ShouldEval(expr))
-		Expr_SetValueOwn(expr,
-		VarStrftime(Expr_Str(expr), t, true));
-
-	return AMR_OK;
-}
-
-/* :localtime */
-static ApplyModifierResult
-ApplyModifier_Localtime(const char **pp, ModChain *ch)
-{
-	Expr *expr;
-	time_t t;
-
-	const char *mod = *pp;
-	if (!ModMatchEq(mod, "localtime", ch))
-		return AMR_UNKNOWN;
-
-	if (mod[9] == '=') {
-		const char *p = mod + 10;
-		if (!TryParseTime(, )) {
-			Parse_Error(PARSE_FATAL,
-			"Invalid time value at \"%s\"", p);
-			return AMR_CLEANUP;
-		}
-		*pp = p;
-	} else {
-		t = 0;
-		*pp = mod + 9;
-	}
-
-	expr = ch->expr;
-	if (Expr_ShouldEval(expr))
-		Expr_SetValueOwn(expr,
-		VarStrftime(Expr_Str(expr), t, false));
+		Expr_SetValueOwn(expr, VarStrftime(Expr_Str(expr), t, gmt));
 
 	return AMR_OK;
 }
@@ -3863,7 +3832,7 @@ ApplyModifier(const char **pp, ModChain 
 	case 'E':
 		return ApplyModifier_WordFunc(pp, ch, ModifyWord_Suffix);
 	case 'g':
-		return ApplyModifier_Gmtime(pp, ch);
+		return ApplyModifier_Time(pp, ch, true);
 	case 'H':
 		return ApplyModifier_WordFunc(pp, ch, ModifyWord_Head);
 	case 'h':
@@ -3871,7 +3840,7 @@ ApplyModifier(const char **pp, ModChain 
 	case 'L':
 		return ApplyModifier_Literal(pp, ch);
 	case 'l':
-		return ApplyModifier_Localtime(pp, ch);
+		return ApplyModifier_Time(pp, ch, false);
 	case 'M':
 	case 'N':
 		return ApplyModifier_Match(pp, ch);



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 12:37:27 UTC 2022

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

Log Message:
make: merge duplicate code for modifiers 'gmtime' and 'localtime'

No functional change.


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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 13:56:10 UTC 2022

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

Log Message:
make: rename IFile and its fields to match their actual content

For lines that use backslash continuation, the human-readable line
number does not equal the number of raw lines that have been read from
the file.

The big comment in PrintStackTrace has become outdated, it still
referred to first_lineno.  Due to the bugs documented in
opt-debug-parse.mk, that function needs to be redone completely.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.284 -r1.285 src/usr.bin/make/make.h
cvs rdiff -u -r1.626 -r1.627 src/usr.bin/make/parse.c
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/include-sub.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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 13:56:10 UTC 2022

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

Log Message:
make: rename IFile and its fields to match their actual content

For lines that use backslash continuation, the human-readable line
number does not equal the number of raw lines that have been read from
the file.

The big comment in PrintStackTrace has become outdated, it still
referred to first_lineno.  Due to the bugs documented in
opt-debug-parse.mk, that function needs to be redone completely.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.284 -r1.285 src/usr.bin/make/make.h
cvs rdiff -u -r1.626 -r1.627 src/usr.bin/make/parse.c
cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/include-sub.mk

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

Modified files:

Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.284 src/usr.bin/make/make.h:1.285
--- src/usr.bin/make/make.h:1.284	Wed Dec 29 05:05:21 2021
+++ src/usr.bin/make/make.h	Fri Jan  7 13:56:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.284 2021/12/29 05:05:21 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.285 2022/01/07 13:56:09 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -498,7 +498,7 @@ typedef struct GNode {
 
 	/* Filename where the GNode got defined, unlimited lifetime */
 	const char *fname;
-	/* Line number where the GNode got defined */
+	/* Line number where the GNode got defined, 1-based */
 	int lineno;
 } GNode;
 

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.626 src/usr.bin/make/parse.c:1.627
--- src/usr.bin/make/parse.c:1.626	Fri Jan  7 09:49:43 2022
+++ src/usr.bin/make/parse.c	Fri Jan  7 13:56:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.626 2022/01/07 09:49:43 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.627 2022/01/07 13:56:09 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,15 +106,26 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.626 2022/01/07 09:49:43 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.627 2022/01/07 13:56:09 rillig Exp $");
 
 /*
- * Structure for a file being read ("included file")
+ * A file being read.
  */
-typedef struct IFile {
+typedef struct IncludedFile {
 	FStr name;		/* absolute or relative to the cwd */
-	int lineno;		/* current line number in file */
-	int forBodyLineno;	/* start of the .for loop body, 0-based */
+	/* TODO: add lineno for accurate line number information */
+	int readLines;		/* the number of physical lines that have
+ * been read from the file; for lines without
+ * backslash continuation, it coincidentally
+ * equals the 1-based human-readable line
+ * number for messages */
+	/* TODO: add forHeadLineno for accurate line number information */
+	int forBodyReadLines;	/* the number of physical lines that have
+ * been read from the file above the body of
+ * the .for loop; in .for loops whose head
+ * fits in a single line, it coincidentally
+ * equals the 1-based human-readable line
+ * number for messages */
 	unsigned int cond_depth; /* 'if' nesting when file opened */
 	bool depending;		/* state of doing_depend on EOF */
 
@@ -124,7 +135,7 @@ typedef struct IFile {
 	char *buf_end;		/* buf_end[-1] == '\n' */
 
 	struct ForLoop *forLoop;
-} IFile;
+} IncludedFile;
 
 /*
  * Tokens for target attributes
@@ -210,7 +221,7 @@ static int parseErrors = 0;
  *
  * See PrintStackTrace for how to interpret the data.
  */
-static Vector /* of IFile */ includes;
+static Vector /* of IncludedFile */ includes;
 
 SearchPath *parseIncPath;	/* directories for "..." includes */
 SearchPath *sysIncPath;		/* directories for <...> includes */
@@ -275,14 +286,14 @@ static const struct {
 };
 
 
-static IFile *
+static IncludedFile *
 GetInclude(size_t i)
 {
 	return Vector_Get(, i);
 }
 
 /* The file that is currently being read. */
-static IFile *
+static IncludedFile *
 CurFile(void)
 {
 	return GetInclude(includes.len - 1);
@@ -332,7 +343,7 @@ loadfile(const char *path, int fd)
 static void
 PrintStackTrace(void)
 {
-	const IFile *entries;
+	const IncludedFile *entries;
 	size_t i, n;
 
 	if (!DEBUG(PARSE))
@@ -344,33 +355,28 @@ PrintStackTrace(void)
 		return;
 	n--;			/* This entry is already in the diagnostic. */
 
-	/*
-	 * For the IFiles with forLoop, lineno is the number of completely
-	 * parsed lines, which is right after the corresponding .endfor.  The
-	 * intuitive line number comes from first_lineno instead, which
-	 * points at the start of the .for loop.
-	 *
-	 * To make the stack trace intuitive, the entry below each chain of
-	 * .for loop entries must be ignored completely since neither its
-	 * lineno nor its first_lineno is useful.  Instead, the topmost of
-	 * each chain of .for loop entries needs to be 

CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 09:35:12 UTC 2022

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

Log Message:
make: clean up local variables in ParseDependencyTargets

Having only a single moving pointer is less confusing than the previous
copying between tgt and cp.  For example, it did not make sense that the
target would start with '!'.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.624 -r1.625 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.624 src/usr.bin/make/parse.c:1.625
--- src/usr.bin/make/parse.c:1.624	Fri Jan  7 09:28:35 2022
+++ src/usr.bin/make/parse.c	Fri Jan  7 09:35:11 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.624 2022/01/07 09:28:35 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.625 2022/01/07 09:35:11 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.624 2022/01/07 09:28:35 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.625 2022/01/07 09:35:11 rillig Exp $");
 
 /*
  * Structure for a file being read ("included file")
@@ -1229,12 +1229,11 @@ ParseDependencyTargets(char **inout_cp,
 		   GNodeType *inout_targetAttr,
 		   SearchPathList **inout_paths)
 {
-	char *cp;
-	char *tgt = *inout_cp;
+	char *cp = *inout_cp;
 
 	for (;;) {
-		/* Find the end of the next word. */
-		cp = tgt;
+		char *tgt = cp;
+
 		ParseDependencyTargetWord(, lstart);
 
 		/*
@@ -1242,14 +1241,13 @@ ParseDependencyTargets(char **inout_cp,
 		 * name of one or more files inside an archive.
 		 */
 		if (!IsEscaped(lstart, cp) && *cp == '(') {
-			if (!Arch_ParseArchive(, targets, SCOPE_CMDLINE)) {
+			cp = tgt;
+			if (!Arch_ParseArchive(, targets, SCOPE_CMDLINE)) {
 Parse_Error(PARSE_FATAL,
 "Error in archive specification: \"%s\"",
 tgt);
 return false;
 			}
-
-			cp = tgt;
 			continue;
 		}
 
@@ -1267,10 +1265,9 @@ ParseDependencyTargets(char **inout_cp,
 		else
 			pp_skip_whitespace();
 
-		tgt = cp;
-		if (*tgt == '\0')
+		if (*cp == '\0')
 			break;
-		if ((*tgt == '!' || *tgt == ':') && !IsEscaped(lstart, tgt))
+		if ((*cp == '!' || *cp == ':') && !IsEscaped(lstart, cp))
 			break;
 	}
 



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 09:35:12 UTC 2022

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

Log Message:
make: clean up local variables in ParseDependencyTargets

Having only a single moving pointer is less confusing than the previous
copying between tgt and cp.  For example, it did not make sense that the
target would start with '!'.

No functional change.


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

2022-01-07 Thread Christoph Badura
Module Name:src
Committed By:   bad
Date:   Fri Jan  7 10:17:39 UTC 2022

Modified Files:
src/sbin/ifconfig: ifconfig.8
src/usr.bin/netstat: netstat.1

Log Message:
mention ifmcstat(8) in SEE ALSO.


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sbin/ifconfig/ifconfig.8
cvs rdiff -u -r1.74 -r1.75 src/usr.bin/netstat/netstat.1

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



CVS commit: src

2022-01-07 Thread Christoph Badura
Module Name:src
Committed By:   bad
Date:   Fri Jan  7 10:17:39 UTC 2022

Modified Files:
src/sbin/ifconfig: ifconfig.8
src/usr.bin/netstat: netstat.1

Log Message:
mention ifmcstat(8) in SEE ALSO.


To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/sbin/ifconfig/ifconfig.8
cvs rdiff -u -r1.74 -r1.75 src/usr.bin/netstat/netstat.1

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

Modified files:

Index: src/sbin/ifconfig/ifconfig.8
diff -u src/sbin/ifconfig/ifconfig.8:1.122 src/sbin/ifconfig/ifconfig.8:1.123
--- src/sbin/ifconfig/ifconfig.8:1.122	Tue Mar  9 14:39:43 2021
+++ src/sbin/ifconfig/ifconfig.8	Fri Jan  7 10:17:39 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ifconfig.8,v 1.122 2021/03/09 14:39:43 christos Exp $
+.\"	$NetBSD: ifconfig.8,v 1.123 2022/01/07 10:17:39 bad Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -902,6 +902,7 @@ tried to alter an interface's configurat
 .Xr vlan 4 ,
 .Xr ifconfig.if 5 ,
 .\" .Xr eon 5 ,
+.Xr ifmcstat 8 ,
 .Xr rc 8 ,
 .Xr routed 8
 .Sh BUGS

Index: src/usr.bin/netstat/netstat.1
diff -u src/usr.bin/netstat/netstat.1:1.74 src/usr.bin/netstat/netstat.1:1.75
--- src/usr.bin/netstat/netstat.1:1.74	Tue Jul 21 04:58:43 2020
+++ src/usr.bin/netstat/netstat.1	Fri Jan  7 10:17:39 2022
@@ -1,4 +1,4 @@
-.\"	$NetBSD: netstat.1,v 1.74 2020/07/21 04:58:43 gutteridge Exp $
+.\"	$NetBSD: netstat.1,v 1.75 2022/01/07 10:17:39 bad Exp $
 .\"
 .\" Copyright (c) 1983, 1990, 1992, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -441,6 +441,7 @@ And the fifth character shows the header
 .Xr networks 5 ,
 .Xr protocols 5 ,
 .Xr services 5 ,
+.Xr ifmcstat 8 ,
 .Xr iostat 8 ,
 .Xr route 8 ,
 .Xr trpt 8



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 12:33:25 UTC 2022

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

Log Message:
make: clean up variable modifiers 'gmtime' and 'localtime'

Use consistent wording (zulu -> gmt), make VarStrftime parameter order
consistent with strftime, rename confusing 'time_t utc' to 't',
eliminate common subexpression in error message.

No functional change.


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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 12:33:25 UTC 2022

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

Log Message:
make: clean up variable modifiers 'gmtime' and 'localtime'

Use consistent wording (zulu -> gmt), make VarStrftime parameter order
consistent with strftime, rename confusing 'time_t utc' to 't',
eliminate common subexpression in error message.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.992 -r1.993 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.992 src/usr.bin/make/var.c:1.993
--- src/usr.bin/make/var.c:1.992	Thu Dec 30 23:56:34 2021
+++ src/usr.bin/make/var.c	Fri Jan  7 12:33:25 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.992 2021/12/30 23:56:34 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.993 2022/01/07 12:33:25 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.992 2021/12/30 23:56:34 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.993 2022/01/07 12:33:25 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -1942,15 +1942,15 @@ VarHash(const char *str)
 }
 
 static char *
-VarStrftime(const char *fmt, bool zulu, time_t tim)
+VarStrftime(const char *fmt, time_t t, bool gmt)
 {
 	char buf[BUFSIZ];
 
-	if (tim == 0)
-		time();
+	if (t == 0)
+		time();
 	if (*fmt == '\0')
 		fmt = "%c";
-	strftime(buf, sizeof buf, fmt, zulu ? gmtime() : localtime());
+	strftime(buf, sizeof buf, fmt, gmt ? gmtime() : localtime());
 
 	buf[sizeof buf - 1] = '\0';
 	return bmake_strdup(buf);
@@ -2599,7 +2599,7 @@ static ApplyModifierResult
 ApplyModifier_Gmtime(const char **pp, ModChain *ch)
 {
 	Expr *expr;
-	time_t utc;
+	time_t t;
 
 	const char *mod = *pp;
 	if (!ModMatchEq(mod, "gmtime", ch))
@@ -2607,21 +2607,21 @@ ApplyModifier_Gmtime(const char **pp, Mo
 
 	if (mod[6] == '=') {
 		const char *p = mod + 7;
-		if (!TryParseTime(, )) {
+		if (!TryParseTime(, )) {
 			Parse_Error(PARSE_FATAL,
-			"Invalid time value at \"%s\"", mod + 7);
+			"Invalid time value at \"%s\"", p);
 			return AMR_CLEANUP;
 		}
 		*pp = p;
 	} else {
-		utc = 0;
+		t = 0;
 		*pp = mod + 6;
 	}
 
 	expr = ch->expr;
 	if (Expr_ShouldEval(expr))
 		Expr_SetValueOwn(expr,
-		VarStrftime(Expr_Str(expr), true, utc));
+		VarStrftime(Expr_Str(expr), t, true));
 
 	return AMR_OK;
 }
@@ -2631,7 +2631,7 @@ static ApplyModifierResult
 ApplyModifier_Localtime(const char **pp, ModChain *ch)
 {
 	Expr *expr;
-	time_t utc;
+	time_t t;
 
 	const char *mod = *pp;
 	if (!ModMatchEq(mod, "localtime", ch))
@@ -2639,21 +2639,21 @@ ApplyModifier_Localtime(const char **pp,
 
 	if (mod[9] == '=') {
 		const char *p = mod + 10;
-		if (!TryParseTime(, )) {
+		if (!TryParseTime(, )) {
 			Parse_Error(PARSE_FATAL,
-			"Invalid time value at \"%s\"", mod + 10);
+			"Invalid time value at \"%s\"", p);
 			return AMR_CLEANUP;
 		}
 		*pp = p;
 	} else {
-		utc = 0;
+		t = 0;
 		*pp = mod + 9;
 	}
 
 	expr = ch->expr;
 	if (Expr_ShouldEval(expr))
 		Expr_SetValueOwn(expr,
-		VarStrftime(Expr_Str(expr), false, utc));
+		VarStrftime(Expr_Str(expr), t, false));
 
 	return AMR_OK;
 }



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 09:49:43 UTC 2022

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

Log Message:
make: clean up ParseDependencySources

It is not necessary anymore to modify the passed-in line.  It had been
necessary when the parsing function was several hundred lines long, to
avoid gotos.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.625 -r1.626 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.625 src/usr.bin/make/parse.c:1.626
--- src/usr.bin/make/parse.c:1.625	Fri Jan  7 09:35:11 2022
+++ src/usr.bin/make/parse.c	Fri Jan  7 09:49:43 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.625 2022/01/07 09:35:11 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.626 2022/01/07 09:49:43 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.625 2022/01/07 09:35:11 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.626 2022/01/07 09:49:43 rillig Exp $");
 
 /*
  * Structure for a file being read ("included file")
@@ -1352,7 +1352,7 @@ ParseDependencySourcesMundane(char *star
 }
 
 /*
- * In a dependency line like 'targets: sources', parse the sources.
+ * From a dependency line like 'targets: sources', parse the sources.
  *
  * See the tests depsrc-*.mk.
  */
@@ -1364,21 +1364,17 @@ ParseDependencySources(char *p, GNodeTyp
 		ParseDependencySourcesEmpty(special, *inout_paths);
 	} else if (special == SP_MFLAGS) {
 		Main_ParseArgLine(p);
-		/*
-		 * Set the initial character to a null-character so the loop
-		 * to get sources won't get anything.
-		 */
-		*p = '\0';
+		return;
 	} else if (special == SP_SHELL) {
 		if (!Job_ParseShell(p)) {
 			Parse_Error(PARSE_FATAL,
 			"improper shell specification");
 			return;
 		}
-		*p = '\0';
+		return;
 	} else if (special == SP_NOTPARALLEL || special == SP_SINGLESHELL ||
 		   special == SP_DELETE_ON_ERROR) {
-		*p = '\0';
+		return;
 	}
 
 	/* Now go for the sources. */



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 09:49:43 UTC 2022

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

Log Message:
make: clean up ParseDependencySources

It is not necessary anymore to modify the passed-in line.  It had been
necessary when the parsing function was several hundred lines long, to
avoid gotos.

No functional change.


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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 14:03:55 UTC 2022

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

Log Message:
make: clean up comments and names in parse.c

No binary change except for assertion line numbers.


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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 14:03:55 UTC 2022

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

Log Message:
make: clean up comments and names in parse.c

No binary change except for assertion line numbers.


To generate a diff of this commit:
cvs rdiff -u -r1.627 -r1.628 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.627 src/usr.bin/make/parse.c:1.628
--- src/usr.bin/make/parse.c:1.627	Fri Jan  7 13:56:09 2022
+++ src/usr.bin/make/parse.c	Fri Jan  7 14:03:55 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.627 2022/01/07 13:56:09 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.628 2022/01/07 14:03:55 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.627 2022/01/07 13:56:09 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.628 2022/01/07 14:03:55 rillig Exp $");
 
 /*
  * A file being read.
@@ -137,9 +137,7 @@ typedef struct IncludedFile {
 	struct ForLoop *forLoop;
 } IncludedFile;
 
-/*
- * Tokens for target attributes
- */
+/* Special attributes for target nodes. */
 typedef enum ParseSpecial {
 	SP_ATTRIBUTE,	/* Generic attribute */
 	SP_BEGIN,	/* .BEGIN */
@@ -207,11 +205,10 @@ static StringList targCmds = LST_INIT;
 
 /*
  * Predecessor node for handling .ORDER. Initialized to NULL when .ORDER
- * seen, then set to each successive source on the line.
+ * is seen, then set to each successive source on the line.
  */
 static GNode *order_pred;
 
-/* number of fatal errors */
 static int parseErrors = 0;
 
 /*
@@ -384,10 +381,10 @@ PrintStackTrace(void)
 static bool
 IsEscaped(const char *line, const char *p)
 {
-	bool active = false;
+	bool escaped = false;
 	while (p > line && *--p == '\\')
-		active = !active;
-	return active;
+		escaped = !escaped;
+	return escaped;
 }
 
 /*
@@ -991,9 +988,7 @@ HandleDependencyTargetPath(const char *s
 	return true;
 }
 
-/*
- * See if it's a special target and if so set inout_special to match it.
- */
+/* See if it's a special target and if so set inout_special to match it. */
 static bool
 HandleDependencyTarget(const char *targetName,
 		   ParseSpecial *inout_special,
@@ -1059,23 +1054,23 @@ static void
 SkipExtraTargets(char **pp, const char *lstart)
 {
 	bool warning = false;
-	const char *cp = *pp;
+	const char *p = *pp;
 
-	while (*cp != '\0') {
-		if (!IsEscaped(lstart, cp) && (*cp == '!' || *cp == ':'))
+	while (*p != '\0') {
+		if (!IsEscaped(lstart, p) && (*p == '!' || *p == ':'))
 			break;
-		if (IsEscaped(lstart, cp) || (*cp != ' ' && *cp != '\t'))
+		if (IsEscaped(lstart, p) || (*p != ' ' && *p != '\t'))
 			warning = true;
-		cp++;
+		p++;
 	}
 	if (warning)
 		Parse_Error(PARSE_WARNING, "Extra target ignored");
 
-	*pp += cp - *pp;
+	*pp += p - *pp;
 }
 
 static void
-ParseDependencyCheckSpecial(ParseSpecial special)
+CheckSpecialMundaneMixture(ParseSpecial special)
 {
 	switch (special) {
 	case SP_DEFAULT:
@@ -1449,7 +1444,7 @@ ParseDependency(char *line)
 		goto out;
 
 	if (!Lst_IsEmpty(targets))
-		ParseDependencyCheckSpecial(special);
+		CheckSpecialMundaneMixture(special);
 
 	ApplyDependencyOperator(ParseDependencyOp());
 



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 08:20:00 UTC 2022

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

Log Message:
make: fix null pointer when including empty file (since 2022-01-01)

Calling malloc(0) may return a null pointer, but callers of bmake_malloc
do not expect that.

Reported by Chris Pinnock, found by cross-compiling NetBSD on OpenBSD,
where tools/groff creates Makefile.dep files of size 0.


To generate a diff of this commit:
cvs rdiff -u -r1.619 -r1.620 src/usr.bin/make/parse.c
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/directive-include.mk

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

Modified files:

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.619 src/usr.bin/make/parse.c:1.620
--- src/usr.bin/make/parse.c:1.619	Sun Jan  2 02:57:39 2022
+++ src/usr.bin/make/parse.c	Fri Jan  7 08:20:00 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.619 2022/01/02 02:57:39 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.620 2022/01/07 08:20:00 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.619 2022/01/02 02:57:39 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.620 2022/01/07 08:20:00 rillig Exp $");
 
 /*
  * Structure for a file being read ("included file")
@@ -297,7 +297,7 @@ loadfile(const char *path, int fd)
 	struct stat st;
 
 	bufSize = fstat(fd, ) == 0 && S_ISREG(st.st_mode) &&
-		  st.st_size >= 0 && st.st_size <= 0x3fff
+		  st.st_size >= 1 && st.st_size <= 0x3fff
 	? (size_t)st.st_size : 1024;
 	Buf_InitSize(, bufSize);
 

Index: src/usr.bin/make/unit-tests/directive-include.mk
diff -u src/usr.bin/make/unit-tests/directive-include.mk:1.9 src/usr.bin/make/unit-tests/directive-include.mk:1.10
--- src/usr.bin/make/unit-tests/directive-include.mk:1.9	Tue Dec 14 01:00:04 2021
+++ src/usr.bin/make/unit-tests/directive-include.mk	Fri Jan  7 08:20:00 2022
@@ -1,4 +1,4 @@
-# $NetBSD: directive-include.mk,v 1.9 2021/12/14 01:00:04 rillig Exp $
+# $NetBSD: directive-include.mk,v 1.10 2022/01/07 08:20:00 rillig Exp $
 #
 # Tests for the .include directive, which includes another file.
 
@@ -71,4 +71,15 @@ include
 # or any other indicator for the empty filename at the end of the line.
 #include ${:U}
 
+
+# Since parse.c 1.612 from 2022-01-01 and before parse.c 1.620 from
+# 2022-01-07, including an empty regular file called bmake_malloc(0), which
+# may return a null pointer.  On OpenBSD, this led to a segmentation fault in
+# Buf_InitSize, which assumes that bmake_malloc never returns NULL, just like
+# all other places in the code.
+_!=		> directive-include-empty
+.include "${.CURDIR}/directive-include-empty"
+_!=		rm directive-include-empty
+
+
 all:



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 08:20:00 UTC 2022

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

Log Message:
make: fix null pointer when including empty file (since 2022-01-01)

Calling malloc(0) may return a null pointer, but callers of bmake_malloc
do not expect that.

Reported by Chris Pinnock, found by cross-compiling NetBSD on OpenBSD,
where tools/groff creates Makefile.dep files of size 0.


To generate a diff of this commit:
cvs rdiff -u -r1.619 -r1.620 src/usr.bin/make/parse.c
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/directive-include.mk

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



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 08:28:06 UTC 2022

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

Log Message:
make: reduce code for initializing error handling in shell

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.445 -r1.446 src/usr.bin/make/job.c

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

Modified files:

Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.445 src/usr.bin/make/job.c:1.446
--- src/usr.bin/make/job.c:1.445	Mon Dec 27 18:26:22 2021
+++ src/usr.bin/make/job.c	Fri Jan  7 08:28:06 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.445 2021/12/27 18:26:22 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.446 2022/01/07 08:28:06 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -142,7 +142,7 @@
 #include "trace.h"
 
 /*	"@(#)job.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: job.c,v 1.445 2021/12/27 18:26:22 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.446 2022/01/07 08:28:06 rillig Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -2189,14 +2189,8 @@ Shell_Init(void)
 			free(shellErrFlag);
 			shellErrFlag = NULL;
 		}
-		if (shellErrFlag == NULL) {
-			size_t n = strlen(shell->errFlag) + 2;
-
-			shellErrFlag = bmake_malloc(n);
-			if (shellErrFlag != NULL)
-snprintf(shellErrFlag, n, "-%s",
-shell->errFlag);
-		}
+		if (shellErrFlag == NULL)
+			shellErrFlag = str_concat2("-", shell->errFlag);
 	} else if (shellErrFlag != NULL) {
 		free(shellErrFlag);
 		shellErrFlag = NULL;



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 08:28:06 UTC 2022

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

Log Message:
make: reduce code for initializing error handling in shell

No functional change.


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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 08:30:04 UTC 2022

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

Log Message:
make: rename local variable in bmake_malloc

The length of a string does not include the trailing '\0'.

No binary change.


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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 08:30:04 UTC 2022

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

Log Message:
make: rename local variable in bmake_malloc

The length of a string does not include the trailing '\0'.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/make/make_malloc.c

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

Modified files:

Index: src/usr.bin/make/make_malloc.c
diff -u src/usr.bin/make/make_malloc.c:1.25 src/usr.bin/make/make_malloc.c:1.26
--- src/usr.bin/make/make_malloc.c:1.25	Tue Jan 19 20:51:46 2021
+++ src/usr.bin/make/make_malloc.c	Fri Jan  7 08:30:04 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: make_malloc.c,v 1.25 2021/01/19 20:51:46 rillig Exp $	*/
+/*	$NetBSD: make_malloc.c,v 1.26 2022/01/07 08:30:04 rillig Exp $	*/
 
 /*
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
 
 #include "make.h"
 
-MAKE_RCSID("$NetBSD: make_malloc.c,v 1.25 2021/01/19 20:51:46 rillig Exp $");
+MAKE_RCSID("$NetBSD: make_malloc.c,v 1.26 2022/01/07 08:30:04 rillig Exp $");
 
 #ifndef USE_EMALLOC
 
@@ -57,12 +57,12 @@ bmake_malloc(size_t len)
 char *
 bmake_strdup(const char *str)
 {
-	size_t len;
+	size_t size;
 	char *p;
 
-	len = strlen(str) + 1;
-	p = bmake_malloc(len);
-	return memcpy(p, str, len);
+	size = strlen(str) + 1;
+	p = bmake_malloc(size);
+	return memcpy(p, str, size);
 }
 
 /* Allocate a string starting from str with exactly len characters. */



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 08:37:24 UTC 2022

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

Log Message:
make: reduce negations in ParseVErrorInternal

No functional change.


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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 08:37:24 UTC 2022

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

Log Message:
make: reduce negations in ParseVErrorInternal

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.620 -r1.621 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.620 src/usr.bin/make/parse.c:1.621
--- src/usr.bin/make/parse.c:1.620	Fri Jan  7 08:20:00 2022
+++ src/usr.bin/make/parse.c	Fri Jan  7 08:37:23 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.620 2022/01/07 08:20:00 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.621 2022/01/07 08:37:23 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.620 2022/01/07 08:20:00 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.621 2022/01/07 08:37:23 rillig Exp $");
 
 /*
  * Structure for a file being read ("included file")
@@ -470,17 +470,16 @@ ParseVErrorInternal(FILE *f, const char 
 	(void)fprintf(f, "\n");
 	(void)fflush(f);
 
-	if (type == PARSE_INFO)
-		goto print_stack_trace;
-	if (type == PARSE_WARNING && !opts.parseWarnFatal)
-		goto print_stack_trace;
-	parseErrors++;
-	if (type == PARSE_WARNING && !fatal_warning_error_printed) {
-		Error("parsing warnings being treated as errors");
-		fatal_warning_error_printed = true;
+	if (type == PARSE_FATAL)
+		parseErrors++;
+	if (type == PARSE_WARNING && opts.parseWarnFatal) {
+		if (!fatal_warning_error_printed) {
+			Error("parsing warnings being treated as errors");
+			fatal_warning_error_printed = true;
+		}
+		parseErrors++;
 	}
 
-print_stack_trace:
 	PrintStackTrace();
 }
 



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 08:48:16 UTC 2022

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

Log Message:
make: clean up nitpicks in parse.c

In PrintLocation, fname is not an iterator, so prefer fname[0] over
*fname.

List stdout and stderr in this order, for consistency with main.c.

No functional change.


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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 08:48:16 UTC 2022

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

Log Message:
make: clean up nitpicks in parse.c

In PrintLocation, fname is not an iterator, so prefer fname[0] over
*fname.

List stdout and stderr in this order, for consistency with main.c.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.621 -r1.622 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.621 src/usr.bin/make/parse.c:1.622
--- src/usr.bin/make/parse.c:1.621	Fri Jan  7 08:37:23 2022
+++ src/usr.bin/make/parse.c	Fri Jan  7 08:48:16 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.621 2022/01/07 08:37:23 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.622 2022/01/07 08:48:16 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.621 2022/01/07 08:37:23 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.622 2022/01/07 08:48:16 rillig Exp $");
 
 /*
  * Structure for a file being read ("included file")
@@ -427,16 +427,11 @@ PrintLocation(FILE *f, const char *fname
 	char dirbuf[MAXPATHLEN + 1];
 	FStr dir, base;
 
-	if (*fname == '/' || strcmp(fname, "(stdin)") == 0) {
+	if (fname[0] == '/' || strcmp(fname, "(stdin)") == 0) {
 		(void)fprintf(f, "\"%s\" line %u: ", fname, (unsigned)lineno);
 		return;
 	}
 
-	/*
-	 * Find out which makefile is the culprit. We try ${.PARSEDIR} and
-	 * apply realpath(3) if not absolute.
-	 */
-
 	dir = Var_Value(SCOPE_GLOBAL, ".PARSEDIR");
 	if (dir.str == NULL)
 		dir.str = ".";
@@ -494,7 +489,7 @@ ParseErrorInternal(const char *fname, si
 	ParseVErrorInternal(stderr, fname, lineno, type, fmt, ap);
 	va_end(ap);
 
-	if (opts.debug_file != stderr && opts.debug_file != stdout) {
+	if (opts.debug_file != stdout && opts.debug_file != stderr) {
 		va_start(ap, fmt);
 		ParseVErrorInternal(opts.debug_file, fname, lineno, type,
 		fmt, ap);
@@ -531,7 +526,7 @@ Parse_Error(ParseErrorLevel type, const 
 	ParseVErrorInternal(stderr, fname, lineno, type, fmt, ap);
 	va_end(ap);
 
-	if (opts.debug_file != stderr && opts.debug_file != stdout) {
+	if (opts.debug_file != stdout && opts.debug_file != stderr) {
 		va_start(ap, fmt);
 		ParseVErrorInternal(opts.debug_file, fname, lineno, type,
 		fmt, ap);
@@ -1182,7 +1177,7 @@ AddToPaths(const char *dir, SearchPathLi
  * a something and deal with it accordingly.
  */
 static void
-ParseDependencySourceSpecial(ParseSpecial special, char *word,
+ParseDependencySourceSpecial(ParseSpecial special, const char *word,
 			 SearchPathList *paths)
 {
 	switch (special) {



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 09:02:19 UTC 2022

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

Log Message:
make: remove redundant initializer in CondParser_ComparisonOrLeaf

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.322 -r1.323 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.322 src/usr.bin/make/cond.c:1.323
--- src/usr.bin/make/cond.c:1.322	Sun Jan  2 02:57:39 2022
+++ src/usr.bin/make/cond.c	Fri Jan  7 09:02:19 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.322 2022/01/02 02:57:39 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.323 2022/01/07 09:02:19 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*	"@(#)cond.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: cond.c,v 1.322 2022/01/02 02:57:39 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.323 2022/01/07 09:02:19 rillig Exp $");
 
 /*
  * The parsing of conditional expressions is based on this grammar:
@@ -776,7 +776,7 @@ static Token
 CondParser_ComparisonOrLeaf(CondParser *par, bool doEval)
 {
 	Token t;
-	char *arg = NULL;
+	char *arg;
 	const char *cp;
 
 	/* Push anything numeric through the compare expression */



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 09:02:19 UTC 2022

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

Log Message:
make: remove redundant initializer in CondParser_ComparisonOrLeaf

No binary change.


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

2022-01-07 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Fri Jan  7 22:59:32 UTC 2022

Modified Files:
src/sys/arch/powerpc/include: asm.h
src/tests/net/ipsec: t_ipsec_misc.sh

Log Message:
s/udpate/update/


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/powerpc/include/asm.h
cvs rdiff -u -r1.24 -r1.25 src/tests/net/ipsec/t_ipsec_misc.sh

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



CVS commit: src

2022-01-07 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Fri Jan  7 22:59:32 UTC 2022

Modified Files:
src/sys/arch/powerpc/include: asm.h
src/tests/net/ipsec: t_ipsec_misc.sh

Log Message:
s/udpate/update/


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/powerpc/include/asm.h
cvs rdiff -u -r1.24 -r1.25 src/tests/net/ipsec/t_ipsec_misc.sh

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

Modified files:

Index: src/sys/arch/powerpc/include/asm.h
diff -u src/sys/arch/powerpc/include/asm.h:1.52 src/sys/arch/powerpc/include/asm.h:1.53
--- src/sys/arch/powerpc/include/asm.h:1.52	Mon Jul  6 08:20:40 2020
+++ src/sys/arch/powerpc/include/asm.h	Fri Jan  7 22:59:32 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: asm.h,v 1.52 2020/07/06 08:20:40 rin Exp $	*/
+/*	$NetBSD: asm.h,v 1.53 2022/01/07 22:59:32 andvar Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -330,17 +330,17 @@ y:	.quad	.##y,.TOC.@tocbase,0;	\
 #ifndef _LP64
 
 # define ldlong		lwz	/* load "C" long */
-# define ldlongu	lwzu	/* load "C" long with udpate */
+# define ldlongu	lwzu	/* load "C" long with update */
 # define stlong		stw	/* load "C" long */
-# define stlongu	stwu	/* load "C" long with udpate */
+# define stlongu	stwu	/* load "C" long with update */
 # define ldptr		lwz	/* load "C" pointer */
-# define ldptru		lwzu	/* load "C" pointer with udpate */
+# define ldptru		lwzu	/* load "C" pointer with update */
 # define stptr		stw	/* load "C" pointer */
-# define stptru		stwu	/* load "C" pointer with udpate */
+# define stptru		stwu	/* load "C" pointer with update */
 # define ldreg		lwz	/* load PPC general register */
-# define ldregu		lwzu	/* load PPC general register with udpate */
+# define ldregu		lwzu	/* load PPC general register with update */
 # define streg		stw	/* load PPC general register */
-# define stregu		stwu	/* load PPC general register with udpate */
+# define stregu		stwu	/* load PPC general register with update */
 # define SZREG		4	/* 4 byte registers */
 # define P2SZREG	2
 

Index: src/tests/net/ipsec/t_ipsec_misc.sh
diff -u src/tests/net/ipsec/t_ipsec_misc.sh:1.24 src/tests/net/ipsec/t_ipsec_misc.sh:1.25
--- src/tests/net/ipsec/t_ipsec_misc.sh:1.24	Mon Aug 31 14:03:56 2020
+++ src/tests/net/ipsec/t_ipsec_misc.sh	Fri Jan  7 22:59:32 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: t_ipsec_misc.sh,v 1.24 2020/08/31 14:03:56 martin Exp $
+#	$NetBSD: t_ipsec_misc.sh,v 1.25 2022/01/07 22:59:32 andvar Exp $
 #
 # Copyright (c) 2017 Internet Initiative Japan Inc.
 # All rights reserved.
@@ -356,7 +356,7 @@ add_test_update()
 	local _algo=$(echo $algo | sed 's/-//g')
 	local name= desc=
 
-	desc="Tests trying to udpate $_update of $proto ($algo)"
+	desc="Tests trying to update $_update of $proto ($algo)"
 	name="ipsec_update_${update}_${proto}_${_algo}"
 
 	atf_test_case ${name} cleanup
@@ -421,7 +421,7 @@ add_test_getspi_update()
 	local _algo=$(echo $algo | sed 's/-//g')
 	local name= desc=
 
-	desc="Tests trying to getspi and udpate SA of $proto ($algo)"
+	desc="Tests trying to getspi and update SA of $proto ($algo)"
 	name="ipsec_getspi_update_sa_${proto}_${_algo}"
 
 	atf_test_case ${name} cleanup



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 23:13:50 UTC 2022

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

Log Message:
make: clean up structure of For_Eval

Put related decisions on the same indentation level, remove unnecessary
negation, keep the code for the '.for' directive together.

No functional change.


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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 23:13:50 UTC 2022

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

Log Message:
make: clean up structure of For_Eval

Put related decisions on the same indentation level, remove unnecessary
negation, keep the code for the '.for' directive together.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.157 -r1.158 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.157 src/usr.bin/make/for.c:1.158
--- src/usr.bin/make/for.c:1.157	Fri Jan  7 20:15:10 2022
+++ src/usr.bin/make/for.c	Fri Jan  7 23:13:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: for.c,v 1.157 2022/01/07 20:15:10 rillig Exp $	*/
+/*	$NetBSD: for.c,v 1.158 2022/01/07 23:13:50 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.157 2022/01/07 20:15:10 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.158 2022/01/07 23:13:50 rillig Exp $");
 
 
 typedef struct ForLoop {
@@ -191,35 +191,30 @@ IsEndfor(const char *p)
 int
 For_Eval(const char *line)
 {
-	ForLoop *f;
 	const char *p;
+	ForLoop *f;
 
 	p = line + 1;		/* skip the '.' */
 	cpp_skip_whitespace();
 
-	if (!IsFor(p)) {
-		if (IsEndfor(p)) {
-			Parse_Error(PARSE_FATAL, "for-less endfor");
+	if (IsFor(p)) {
+		p += 3;
+
+		f = ForLoop_New();
+		if (!ForLoop_ParseVarnames(f, )) {
+			ForLoop_Free(f);
 			return -1;
 		}
-		return 0;
-	}
-	p += 3;
-
-	f = ForLoop_New();
+		if (!ForLoop_ParseItems(f, p))
+			f->items.len = 0;	/* don't iterate */
 
-	if (!ForLoop_ParseVarnames(f, )) {
-		ForLoop_Free(f);
+		accumFor = f;
+		return 1;
+	} else if (IsEndfor(p)) {
+		Parse_Error(PARSE_FATAL, "for-less endfor");
 		return -1;
-	}
-
-	if (!ForLoop_ParseItems(f, p)) {
-		/* Continue parsing the .for loop, but don't iterate. */
-		f->items.len = 0;
-	}
-
-	accumFor = f;
-	return 1;
+	} else
+		return 0;
 }
 
 /*



CVS commit: src/sys/modules/ffs

2022-01-07 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat Jan  8 01:50:54 UTC 2022

Modified Files:
src/sys/modules/ffs: Makefile

Log Message:
Use \t for pre-comment white-space


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/modules/ffs/Makefile

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



CVS commit: src/sys/modules/ffs

2022-01-07 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat Jan  8 01:50:54 UTC 2022

Modified Files:
src/sys/modules/ffs: Makefile

Log Message:
Use \t for pre-comment white-space


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/modules/ffs/Makefile

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

Modified files:

Index: src/sys/modules/ffs/Makefile
diff -u src/sys/modules/ffs/Makefile:1.19 src/sys/modules/ffs/Makefile:1.20
--- src/sys/modules/ffs/Makefile:1.19	Thu Jan  6 15:08:56 2022
+++ src/sys/modules/ffs/Makefile	Sat Jan  8 01:50:54 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.19 2022/01/06 15:08:56 pgoyette Exp $
+#	$NetBSD: Makefile,v 1.20 2022/01/08 01:50:54 pgoyette Exp $
 
 .include "../Makefile.inc"
 
@@ -7,7 +7,7 @@
 KMOD=	ffs
 CPPFLAGS+=	-DFFS_EI -DWAPBL -DAPPLE_UFS -DQUOTA -DQUOTA2
 CPPFLAGS+=	-DUFS_EXTATTR -DUFS_ACL
-#CPPFLAGS+=	-DUFS_DIRHASH # disabled - suspected of corrupting memory
+#CPPFLAGS+=	-DUFS_DIRHASH	# disabled - suspected of corrupting memory
 
 CWARNFLAGS.clang=	-Wno-conversion
 COPTS.ffs_appleufs.c+=   ${NO_ADDR_OF_PACKED_MEMBER}



CVS commit: src/usr.sbin/postinstall

2022-01-07 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Jan  8 06:53:58 UTC 2022

Modified Files:
src/usr.sbin/postinstall: postinstall.in

Log Message:
postinstall: help to stdout. usage tweaks

When invoked as "help" or "usage", send the usage to stdout
instead of stderr, so that it's easier to pipe to a pager.

Explicitly warn that the operation is missing.

Tweak the usage; "operation" instead of "op", no need for [] around ...


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/usr.sbin/postinstall/postinstall.in

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



CVS commit: src/usr.sbin/postinstall

2022-01-07 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Jan  8 06:53:58 UTC 2022

Modified Files:
src/usr.sbin/postinstall: postinstall.in

Log Message:
postinstall: help to stdout. usage tweaks

When invoked as "help" or "usage", send the usage to stdout
instead of stderr, so that it's easier to pipe to a pager.

Explicitly warn that the operation is missing.

Tweak the usage; "operation" instead of "op", no need for [] around ...


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/usr.sbin/postinstall/postinstall.in

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

Modified files:

Index: src/usr.sbin/postinstall/postinstall.in
diff -u src/usr.sbin/postinstall/postinstall.in:1.42 src/usr.sbin/postinstall/postinstall.in:1.43
--- src/usr.sbin/postinstall/postinstall.in:1.42	Fri Jan  7 01:03:02 2022
+++ src/usr.sbin/postinstall/postinstall.in	Sat Jan  8 06:53:58 2022
@@ -1,8 +1,8 @@
 #!/bin/sh
 #
-# $NetBSD: postinstall.in,v 1.42 2022/01/07 01:03:02 lukem Exp $
+# $NetBSD: postinstall.in,v 1.43 2022/01/08 06:53:58 lukem Exp $
 #
-# Copyright (c) 2002-2021 The NetBSD Foundation, Inc.
+# Copyright (c) 2002-2022 The NetBSD Foundation, Inc.
 # All rights reserved.
 #
 # This code is derived from software contributed to The NetBSD Foundation
@@ -2538,10 +2538,10 @@ do_obsolete()
 #
 
 
-usage()
+help()
 {
-	cat 1>&2 << _USAGE_
-Usage: ${PROGNAME} [-s srcdir] [-x xsrcdir] [-d destdir] [-m mach] [-a arch] op [item [...]]
+	cat << _USAGE_
+Usage: ${PROGNAME} [-s srcdir] [-x xsrcdir] [-d destdir] [-m mach] [-a arch] operation [item ...]
 	Perform post-installation checks and/or fixes on a system's
 	configuration files.
 	If no items are provided, a default set of checks or fixes is applied.
@@ -2564,7 +2564,7 @@ Usage: ${PROGNAME} [-s srcdir] [-x xsrcd
 	-m mach		MACHINE.			[${MACHINE}]
 	-a arch		MACHINE_ARCH.			[${MACHINE_ARCH}]
 
-	Operation may be one of:
+	Supported values for operation:
 		help	Display this help.
 		list	List available items.
 		check	Perform post-installation checks on items.
@@ -2573,6 +2573,11 @@ Usage: ${PROGNAME} [-s srcdir] [-x xsrcd
 		fix	Apply fixes that 'check' determines need to be applied.
 		usage	Display this usage.
 _USAGE_
+}
+
+usage()
+{
+	help 1>&2
 	exit 2
 }
 
@@ -2673,7 +2678,10 @@ main()
 		esac
 	done
 	shift $((${OPTIND} - 1))
-	[ $# -gt 0 ] || usage
+	if [ $# -eq 0 ] ; then
+		warn "Missing operation"
+		usage
+	fi
 
 	if [ "$N_SRC_ARGS" -gt 1 ] && $DIRMODE; then
 		err 2 "Multiple -s args are allowed only with tgz files"
@@ -2759,7 +2767,7 @@ main()
 	case "${op}" in
 
 	usage|help)
-		usage
+		help
 		;;
 
 	list)



CVS commit: src/sys/modules/ffs

2022-01-07 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat Jan  8 01:58:16 UTC 2022

Modified Files:
src/sys/modules/ffs: Makefile

Log Message:
Remove extra blank line


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/modules/ffs/Makefile

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

Modified files:

Index: src/sys/modules/ffs/Makefile
diff -u src/sys/modules/ffs/Makefile:1.20 src/sys/modules/ffs/Makefile:1.21
--- src/sys/modules/ffs/Makefile:1.20	Sat Jan  8 01:50:54 2022
+++ src/sys/modules/ffs/Makefile	Sat Jan  8 01:58:16 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.20 2022/01/08 01:50:54 pgoyette Exp $
+#	$NetBSD: Makefile,v 1.21 2022/01/08 01:58:16 pgoyette Exp $
 
 .include "../Makefile.inc"
 
@@ -12,7 +12,6 @@ CPPFLAGS+=	-DUFS_EXTATTR -DUFS_ACL
 CWARNFLAGS.clang=	-Wno-conversion
 COPTS.ffs_appleufs.c+=   ${NO_ADDR_OF_PACKED_MEMBER}
 
-
 SRCS+=	ffs_alloc.c ffs_balloc.c ffs_inode.c ffs_subr.c ffs_tables.c \
 	ffs_vfsops.c ffs_vnops.c ffs_snapshot.c ffs_extattr.c \
 	ffs_bswap.c ffs_wapbl.c ffs_appleufs.c ffs_quota2.c



CVS commit: src/sys/modules/ffs

2022-01-07 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat Jan  8 01:58:16 UTC 2022

Modified Files:
src/sys/modules/ffs: Makefile

Log Message:
Remove extra blank line


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/modules/ffs/Makefile

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



CVS commit: src/usr.sbin/postinstall

2022-01-07 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Jan  8 06:55:13 UTC 2022

Modified Files:
src/usr.sbin/postinstall: postinstall.in

Log Message:
postinstall: style tweaks

Fix ... in comments and internal errors.
Sort variables declared at top of main(), for easier review.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/usr.sbin/postinstall/postinstall.in

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



CVS commit: src/usr.sbin/postinstall

2022-01-07 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Jan  8 06:55:13 UTC 2022

Modified Files:
src/usr.sbin/postinstall: postinstall.in

Log Message:
postinstall: style tweaks

Fix ... in comments and internal errors.
Sort variables declared at top of main(), for easier review.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/usr.sbin/postinstall/postinstall.in

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

Modified files:

Index: src/usr.sbin/postinstall/postinstall.in
diff -u src/usr.sbin/postinstall/postinstall.in:1.43 src/usr.sbin/postinstall/postinstall.in:1.44
--- src/usr.sbin/postinstall/postinstall.in:1.43	Sat Jan  8 06:53:58 2022
+++ src/usr.sbin/postinstall/postinstall.in	Sat Jan  8 06:55:13 2022
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: postinstall.in,v 1.43 2022/01/08 06:53:58 lukem Exp $
+# $NetBSD: postinstall.in,v 1.44 2022/01/08 06:55:13 lukem Exp $
 #
 # Copyright (c) 2002-2022 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -222,7 +222,7 @@ check_dir()
 	return 0
 }
 
-# check_ids op type file srcfile start id [...]
+# check_ids op type file srcfile start id ...
 #	Check if file of type "users" or "groups" contains the relevant IDs.
 #	Use srcfile as a reference for the expected contents.
 #	The specified "id" names should be given in numerical order,
@@ -233,7 +233,7 @@ check_dir()
 #
 check_ids()
 {
-	[ $# -ge 6 ] || err 3 "USAGE: checks_ids op type file start srcfile id [...]"
+	[ $# -ge 6 ] || err 3 "USAGE: checks_ids op type file start srcfile id ..."
 	_op="$1"
 	_type="$2"
 	_file="$3"
@@ -294,7 +294,7 @@ check_ids()
 	return 0
 }
 
-# populate_dir op onlynew src dest mode file [file ...]
+# populate_dir op onlynew src dest mode file ...
 #	Perform op ("check" or "fix") on files in src/ against dest/
 #	If op = "check" display missing or changed files, optionally with diffs.
 #	If op != "check" copies any missing or changed files.
@@ -303,7 +303,7 @@ check_ids()
 #
 populate_dir()
 {
-	[ $# -ge 5 ] || err 3 "USAGE: populate_dir op onlynew src dest mode file [...]"
+	[ $# -ge 5 ] || err 3 "USAGE: populate_dir op onlynew src dest mode file ..."
 	_op="$1"
 	_onlynew="$2"
 	_src="$3"
@@ -353,7 +353,7 @@ populate_dir()
 	return ${_cmpdir_rv}
 }
 
-# compare_dir op src dest mode file [file ...]
+# compare_dir op src dest mode file ...
 #	Perform op ("check" or "fix") on files in src/ against dest/
 #	If op = "check" display missing or changed files, optionally with diffs.
 #	If op != "check" copies any missing or changed files.
@@ -361,7 +361,7 @@ populate_dir()
 #
 compare_dir()
 {
-	[ $# -ge 4 ] || err 3 "USAGE: compare_dir op src dest mode file [...]"
+	[ $# -ge 4 ] || err 3 "USAGE: compare_dir op src dest mode file ..."
 	_op="$1"
 	_src="$2"
 	_dest="$3"
@@ -457,7 +457,7 @@ rcvar_is_enabled()
 	)
 }
 
-# find_file_in_dirlist() file message dir1 [...] --
+# find_file_in_dirlist() file message dir1 ... --
 #	Find which directory file is in, and sets ${dir} to match.
 #	Returns 0 if matched, otherwise 1 (and sets ${dir} to "").
 #
@@ -466,7 +466,7 @@ rcvar_is_enabled()
 #
 find_file_in_dirlist()
 {
-	[ $# -ge 3 ] || err 3 "USAGE: find_file_in_dirlist file msg dir1 [...]"
+	[ $# -ge 3 ] || err 3 "USAGE: find_file_in_dirlist file msg dir1 ..."
 
 	_file="$1" ; shift
 	_msg="$1" ; shift
@@ -756,12 +756,12 @@ contents_owner()
 	fi
 }
 
-# get_makevar var [var ...]
+# get_makevar var ...
 #	Retrieve the value of a user-settable system make variable
 get_makevar()
 {
 	$SOURCEMODE || err 3 "get_makevar must be used in source mode"
-	[ $# -eq 0 ] && err 3 "USAGE: get_makevar var [var ...]"
+	[ $# -eq 0 ] && err 3 "USAGE: get_makevar var ..."
 
 	for _var in "$@"; do
 		_value="$(echo '.include ' | \
@@ -2604,14 +2604,15 @@ list()
 
 main()
 {
-	TGZLIST=		# quoted list list of tgz files
+	DIRMODE=false		# true if "-s" specified a directory
+	N_SRC_ARGS=0		# number of "-s" args in SRC_ARGLIST
+	SOURCEMODE=false	# true if "-s" specified a source directory
 	SRC_ARGLIST=		# quoted list of one or more "-s" args
 	SRC_DIR="${SRC_ARG}"	# set default value for early usage()
-	XSRC_DIR="${SRC_ARG}/../xsrc"
-	N_SRC_ARGS=0		# number of "-s" args
+	TGZLIST=		# quoted list list of tgz files
 	TGZMODE=false		# true if "-s" specifies a tgz file
-	DIRMODE=false		# true if "-s" specified a directory
-	SOURCEMODE=false	# true if "-s" specified a source directory
+	XSRC_DIR="${SRC_ARG}/../xsrc"
+	XSRC_DIR_FIX=
 
 	case "$(uname -s)" in
 	Darwin)



CVS commit: src/sys/modules/ufs

2022-01-07 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat Jan  8 02:00:49 UTC 2022

Modified Files:
src/sys/modules/ufs: Makefile

Log Message:
Use += for SRCS list


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/modules/ufs/Makefile

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



CVS commit: src/sys/modules/ufs

2022-01-07 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat Jan  8 02:00:49 UTC 2022

Modified Files:
src/sys/modules/ufs: Makefile

Log Message:
Use += for SRCS list


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/modules/ufs/Makefile

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

Modified files:

Index: src/sys/modules/ufs/Makefile
diff -u src/sys/modules/ufs/Makefile:1.6 src/sys/modules/ufs/Makefile:1.7
--- src/sys/modules/ufs/Makefile:1.6	Thu Jan  6 20:41:30 2022
+++ src/sys/modules/ufs/Makefile	Sat Jan  8 02:00:49 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.6 2022/01/06 20:41:30 pgoyette Exp $
+#	$NetBSD: Makefile,v 1.7 2022/01/08 02:00:49 pgoyette Exp $
 
 .include "../Makefile.inc"
 
@@ -11,7 +11,7 @@ CPPFLAGS+=	-DUFS_EXTATTR -DUFS_ACL
 CWARNFLAGS.clang=	-Wno-conversion
 
 .PATH:	${S}/ufs/ufs
-SRCS=	ufs_acl.c ufs_bmap.c ufs_dirhash.c ufs_extattr.c ufs_inode.c \
+SRCS+=	ufs_acl.c ufs_bmap.c ufs_dirhash.c ufs_extattr.c ufs_inode.c \
 	ufs_lookup.c ufs_quota.c ufs_quota1.c ufs_quota2.c ufs_rename.c \
 	ufs_vfsops.c ufs_vnops.c quota1_subr.c quota2_subr.c
 



CVS commit: src/usr.sbin/postinstall

2022-01-07 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Jan  8 06:56:43 UTC 2022

Modified Files:
src/usr.sbin/postinstall: postinstall.in

Log Message:
postinstall: improve validation and help

Validate the operation and items before extracting any etc.tgz,
so that help or errors are displayed quicker, for a better user
experience.

Style:
- Rename todo to ITEMS.
- Order processing of list after check.
- Ensure DIFF_OPT is initialised, for consistency.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/usr.sbin/postinstall/postinstall.in

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

Modified files:

Index: src/usr.sbin/postinstall/postinstall.in
diff -u src/usr.sbin/postinstall/postinstall.in:1.44 src/usr.sbin/postinstall/postinstall.in:1.45
--- src/usr.sbin/postinstall/postinstall.in:1.44	Sat Jan  8 06:55:13 2022
+++ src/usr.sbin/postinstall/postinstall.in	Sat Jan  8 06:56:43 2022
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: postinstall.in,v 1.44 2022/01/08 06:55:13 lukem Exp $
+# $NetBSD: postinstall.in,v 1.45 2022/01/08 06:56:43 lukem Exp $
 #
 # Copyright (c) 2002-2022 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -2598,13 +2598,13 @@ list()
 		eval desc=\"\${desc_${i}}\"
 		printf " %-20s %s\n" "${i}" "${desc}"
 	done
-
 }
 
 
 main()
 {
 	DIRMODE=false		# true if "-s" specified a directory
+	ITEMS=			# items to check|diff|fix. [${defaultitems}]
 	N_SRC_ARGS=0		# number of "-s" args in SRC_ARGLIST
 	SOURCEMODE=false	# true if "-s" specified a source directory
 	SRC_ARGLIST=		# quoted list of one or more "-s" args
@@ -2624,6 +2624,8 @@ main()
 		;;
 	esac
 
+		# Validate options.
+		#
 	while getopts s:x:d:m:a: ch; do
 		case "${ch}" in
 		s)
@@ -2683,6 +2685,8 @@ main()
 		warn "Missing operation"
 		usage
 	fi
+	op="$1"
+	shift
 
 	if [ "$N_SRC_ARGS" -gt 1 ] && $DIRMODE; then
 		err 2 "Multiple -s args are allowed only with tgz files"
@@ -2694,6 +2698,68 @@ main()
 		SRC_ARGLIST="-s $(shell_quote "${SRC_ARG}")"
 	fi
 
+		# Validate 'diff' first, as it becomes 'check'
+		#
+	case "${op}" in
+
+	diff)
+		op=check
+		DIFF_STYLE=n			# default style is RCS
+		OPTIND=1
+		while getopts bcenpuw ch; do
+			case "${ch}" in
+			c|e|n|u)
+if [ "${DIFF_STYLE}" != "n" -a \
+"${DIFF_STYLE}" != "${ch}" ]; then
+	err 2 "diff: conflicting output style: ${ch}"
+fi
+DIFF_STYLE="${ch}"
+;;
+			b|p|w)
+DIFF_OPT="${DIFF_OPT} -${ch}"
+;;
+			*)
+err 2 "diff: unknown option"
+;;
+			esac
+		done
+		shift $((${OPTIND} - 1))
+		;;
+
+	esac
+
+		# Validate operation and items.
+		#
+	case "${op}" in
+
+	check|fix)
+		ITEMS="$*"
+		: ${ITEMS:="${defaultitems}"}
+
+		# ensure that all supplied items are valid
+		#
+		for i in ${ITEMS}; do
+			eval desc=\"\${desc_${i}}\"
+			[ -n "${desc}" ] || err 2 "Unsupported ${op} '"${i}"'"
+		done
+		;;
+
+	help|usage)
+		help
+		return	# no further processing or validation
+		;;
+
+	list)
+		# processed below
+		;;
+
+	*)
+		warn "Unknown operation '"${op}"'"
+		usage
+		;;
+
+	esac
+
 	#
 	# If '-s' arg or args specified tgz files, extract them
 	# to a scratch directory.
@@ -2736,63 +2802,13 @@ main()
 
 	detect_x11
 
-	op="$1"
-	shift
-
-	case "${op}" in
-	diff)
-		op=check
-		DIFF_STYLE=n			# default style is RCS
-		OPTIND=1
-		while getopts bcenpuw ch; do
-			case "${ch}" in
-			c|e|n|u)
-if [ "${DIFF_STYLE}" != "n" -a \
-"${DIFF_STYLE}" != "${ch}" ]; then
-	err 2 "conflicting output style: ${ch}"
-fi
-DIFF_STYLE="${ch}"
-;;
-			b|p|w)
-DIFF_OPT="${DIFF_OPT} -${ch}"
-;;
-			*)
-err 2 "unknown diff option"
-;;
-			esac
-		done
-		shift $((${OPTIND} - 1))
-		;;
-	esac
-
+		# Perform operation.
+		#
 	case "${op}" in
 
-	usage|help)
-		help
-		;;
-
-	list)
-		echo "Source directory: ${SRC_DIR:-/}"
-		echo "Target directory: ${DEST_DIR:-/}"
-		if $TGZMODE; then
-			echo " (extracted from: ${SRC_ARG})"
-		fi
-		list
-		;;
-
 	check|fix)
-		todo="$*"
-		: ${todo:="${defaultitems}"}
-
-		# ensure that all supplied items are valid
-		#
-		for i in ${todo}; do
-			eval desc=\"\${desc_${i}}\"
-			[ -n "${desc}" ] || err 2 "Unsupported ${op} '"${i}"'"
-		done
+		[ -n "${ITEMS}" ] || err 2 "${op}: missing items"
 
-		# perform each check/fix
-		#
 		echo "Source directory: ${SRC_DIR:-/}"
 		if $TGZMODE; then
 			echo " (extracted from: ${SRC_ARG})"
@@ -2800,7 +2816,7 @@ main()
 		echo "Target directory: ${DEST_DIR:-/}"
 		items_passed=
 		items_failed=
-		for i in ${todo}; do
+		for i in ${ITEMS}; do
 			echo "${i} ${op}:"
 			( eval do_${i} ${op} )
 			if [ $? -eq 0 ]; then
@@ -2829,12 +2845,20 @@ Note that this may overwrite local chang
 _Fix_me_
 		fi
 		fi
+		;;
 
+	list)
+		echo "Source directory: ${SRC_DIR:-/}"
+		echo "Target directory: ${DEST_DIR:-/}"
+		if $TGZMODE; then
+			echo " (extracted from: ${SRC_ARG})"
+		fi
+		list
 		;;
 
 	*)
-		warn "Unknown operation '"${op}"'"
-		usage
+			# 

CVS commit: src/usr.sbin/postinstall

2022-01-07 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Jan  8 06:57:34 UTC 2022

Modified Files:
src/usr.sbin/postinstall: postinstall.in

Log Message:
postinstall: usage improvements

Show options alphabetically.
Use UPPER_CASE instead of lowercase as the convention for argument names.
Provide per-OPERATION argument usage.
Implement options alphabetically.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/usr.sbin/postinstall/postinstall.in

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

Modified files:

Index: src/usr.sbin/postinstall/postinstall.in
diff -u src/usr.sbin/postinstall/postinstall.in:1.45 src/usr.sbin/postinstall/postinstall.in:1.46
--- src/usr.sbin/postinstall/postinstall.in:1.45	Sat Jan  8 06:56:43 2022
+++ src/usr.sbin/postinstall/postinstall.in	Sat Jan  8 06:57:34 2022
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: postinstall.in,v 1.45 2022/01/08 06:56:43 lukem Exp $
+# $NetBSD: postinstall.in,v 1.46 2022/01/08 06:57:34 lukem Exp $
 #
 # Copyright (c) 2002-2022 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -2541,15 +2541,17 @@ do_obsolete()
 help()
 {
 	cat << _USAGE_
-Usage: ${PROGNAME} [-s srcdir] [-x xsrcdir] [-d destdir] [-m mach] [-a arch] operation [item ...]
+Usage: ${PROGNAME} [-a ARCH] [-d DEST_DIR] [-m MACHINE] [-s SRC_DIR] [-x XSRC_DIR] OPERATION ...
 	Perform post-installation checks and/or fixes on a system's
 	configuration files.
 	If no items are provided, a default set of checks or fixes is applied.
 
 	Options:
-	-s {srcdir|tgzfile|tempdir}
-			Location of the source files.  This may be any
-			of the following:
+	-a ARCH		\$MACHINE_ARCH.			[${MACHINE_ARCH}]
+	-d DEST_DIR	Destination directory to check. [${DEST_DIR:-/}]
+	-m MACHINE	\$MACHINE.			[${MACHINE}]
+	-s SRC_DIR	Location of the source files.  This may be any of
+			the following:
 			* A directory that contains a NetBSD source tree;
 			* A distribution set file such as "etc.tgz" or
 			  "xetc.tgz".  Pass multiple -s options to specify
@@ -2557,21 +2559,19 @@ Usage: ${PROGNAME} [-s srcdir] [-x xsrcd
 			* A temporary directory in which one or both of
 			  "etc.tgz" and "xetc.tgz" have been extracted.
 			[${SRC_DIR:-/usr/src}]
-	-x xsrcdir  Location of the X11 source files.  This must be
+	-x XSRC_DIR	Location of the X11 source files.  This must be
 			a directory that contains a NetBSD xsrc tree.
 			[${XSRC_DIR:-/usr/src/../xsrc}]
-	-d destdir	Destination directory to check. [${DEST_DIR:-/}]
-	-m mach		MACHINE.			[${MACHINE}]
-	-a arch		MACHINE_ARCH.			[${MACHINE_ARCH}]
-
-	Supported values for operation:
-		help	Display this help.
-		list	List available items.
-		check	Perform post-installation checks on items.
-		diff [diff(1) options ...]
-			Similar to 'check' but also output difference of files.
-		fix	Apply fixes that 'check' determines need to be applied.
-		usage	Display this usage.
+
+	Supported values for OPERATION:
+	help		Display this help.
+	list		List available items.
+	check ITEM ...	Perform post-installation checks on ITEMs.
+	diff [DIFFOPT] ITEM ...
+			Similar to 'check' but also output difference of files,
+			using diff [DIFFOPT].
+	fix ITEM ...	Apply fixes that 'check' determines need to be applied.
+	usage		Display this usage.
 _USAGE_
 }
 
@@ -2626,8 +2626,17 @@ main()
 
 		# Validate options.
 		#
-	while getopts s:x:d:m:a: ch; do
+	while getopts a:d:m:s:x: ch; do
 		case "${ch}" in
+		a)
+			MACHINE_ARCH="${OPTARG}"
+			;;
+		d)
+			DEST_DIR="${OPTARG}"
+			;;
+		m)
+			MACHINE="${OPTARG}"
+			;;
 		s)
 			qarg="$(shell_quote "${OPTARG}")"
 			N_SRC_ARGS=$(( $N_SRC_ARGS + 1 ))
@@ -2666,15 +2675,6 @@ main()
 err 2 "Not a directory for -x option"
 			fi
 			;;
-		d)
-			DEST_DIR="${OPTARG}"
-			;;
-		m)
-			MACHINE="${OPTARG}"
-			;;
-		a)
-			MACHINE_ARCH="${OPTARG}"
-			;;
 		*)
 			usage
 			;;



CVS commit: src/usr.sbin/postinstall

2022-01-07 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Jan  8 06:57:34 UTC 2022

Modified Files:
src/usr.sbin/postinstall: postinstall.in

Log Message:
postinstall: usage improvements

Show options alphabetically.
Use UPPER_CASE instead of lowercase as the convention for argument names.
Provide per-OPERATION argument usage.
Implement options alphabetically.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/usr.sbin/postinstall/postinstall.in

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



CVS commit: src/usr.sbin/postinstall

2022-01-07 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Jan  8 06:58:40 UTC 2022

Modified Files:
src/usr.sbin/postinstall: postinstall.in

Log Message:
postinstall: add -?. improve option errors

Support -? to show help.
Implemented using getopts "leading colon optstring" feature.
Improve error messages for unknown options and missing arguments.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/usr.sbin/postinstall/postinstall.in

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



CVS commit: src/usr.sbin/postinstall

2022-01-07 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sat Jan  8 06:58:40 UTC 2022

Modified Files:
src/usr.sbin/postinstall: postinstall.in

Log Message:
postinstall: add -?. improve option errors

Support -? to show help.
Implemented using getopts "leading colon optstring" feature.
Improve error messages for unknown options and missing arguments.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/usr.sbin/postinstall/postinstall.in

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

Modified files:

Index: src/usr.sbin/postinstall/postinstall.in
diff -u src/usr.sbin/postinstall/postinstall.in:1.46 src/usr.sbin/postinstall/postinstall.in:1.47
--- src/usr.sbin/postinstall/postinstall.in:1.46	Sat Jan  8 06:57:34 2022
+++ src/usr.sbin/postinstall/postinstall.in	Sat Jan  8 06:58:40 2022
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: postinstall.in,v 1.46 2022/01/08 06:57:34 lukem Exp $
+# $NetBSD: postinstall.in,v 1.47 2022/01/08 06:58:40 lukem Exp $
 #
 # Copyright (c) 2002-2022 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -2542,6 +2542,8 @@ help()
 {
 	cat << _USAGE_
 Usage: ${PROGNAME} [-a ARCH] [-d DEST_DIR] [-m MACHINE] [-s SRC_DIR] [-x XSRC_DIR] OPERATION ...
+   ${PROGNAME} -?
+
 	Perform post-installation checks and/or fixes on a system's
 	configuration files.
 	If no items are provided, a default set of checks or fixes is applied.
@@ -2567,9 +2569,9 @@ Usage: ${PROGNAME} [-a ARCH] [-d DEST_DI
 	help		Display this help.
 	list		List available items.
 	check ITEM ...	Perform post-installation checks on ITEMs.
-	diff [DIFFOPT] ITEM ...
+	diff [-bcenpuw] ITEM ...
 			Similar to 'check' but also output difference of files,
-			using diff [DIFFOPT].
+			using diff with the provided options.
 	fix ITEM ...	Apply fixes that 'check' determines need to be applied.
 	usage		Display this usage.
 _USAGE_
@@ -2626,7 +2628,7 @@ main()
 
 		# Validate options.
 		#
-	while getopts a:d:m:s:x: ch; do
+	while getopts :a:d:m:s:x: ch; do
 		case "${ch}" in
 		a)
 			MACHINE_ARCH="${OPTARG}"
@@ -2675,9 +2677,23 @@ main()
 err 2 "Not a directory for -x option"
 			fi
 			;;
-		*)
+		"?")
+			if [ "${OPTARG}" = "?" ]; then
+help
+return	# no further processing or validation
+			fi
+			warn "Unknown option -${OPTARG}"
+			usage
+			;;
+
+		:)
+			warn "Missing argument for option -${OPTARG}"
 			usage
 			;;
+
+		*)
+			err 3 "Unimplemented option -${ch}"
+			;;
 		esac
 	done
 	shift $((${OPTIND} - 1))
@@ -2706,20 +2722,30 @@ main()
 		op=check
 		DIFF_STYLE=n			# default style is RCS
 		OPTIND=1
-		while getopts bcenpuw ch; do
+		while getopts :bcenpuw ch; do
 			case "${ch}" in
 			c|e|n|u)
 if [ "${DIFF_STYLE}" != "n" -a \
 "${DIFF_STYLE}" != "${ch}" ]; then
-	err 2 "diff: conflicting output style: ${ch}"
+	warn "diff: conflicting output style: -${ch}"
+	usage
 fi
 DIFF_STYLE="${ch}"
 ;;
 			b|p|w)
 DIFF_OPT="${DIFF_OPT} -${ch}"
 ;;
+			"?")
+# NOTE: not supporting diff -?
+warn "diff: Unknown option -${OPTARG}"
+usage
+;;
+			:)
+warn "diff: Missing argument for option -${OPTARG}"
+usage
+;;
 			*)
-err 2 "diff: unknown option"
+err 3 "diff: Unimplemented option -${ch}"
 ;;
 			esac
 		done



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 20:15:10 UTC 2022

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

Log Message:
make: clean up handling of .for loops

Sort ForLoop members in natural reading order.

Remove redundant condition in ForLoop_ParseItems; at that point, the
number of variables is non-zero.

Rename Buf_AddEscaped since that function is not part of the Buffer API,
it is specific to .for loops.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 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.156 src/usr.bin/make/for.c:1.157
--- src/usr.bin/make/for.c:1.156	Fri Jan  7 20:09:58 2022
+++ src/usr.bin/make/for.c	Fri Jan  7 20:15:10 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: for.c,v 1.156 2022/01/07 20:09:58 rillig Exp $	*/
+/*	$NetBSD: for.c,v 1.157 2022/01/07 20:15:10 rillig Exp $	*/
 
 /*
  * Copyright (c) 1992, The Regents of the University of California.
@@ -58,13 +58,13 @@
 #include "make.h"
 
 /*	"@(#)for.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: for.c,v 1.156 2022/01/07 20:09:58 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.157 2022/01/07 20:15:10 rillig Exp $");
 
 
 typedef struct ForLoop {
-	Buffer body;		/* Unexpanded body of the loop */
 	Vector /* of 'char *' */ vars; /* Iteration variables */
 	SubstringWords items;	/* Substitution items */
+	Buffer body;		/* Unexpanded body of the loop */
 	unsigned int nextItem;	/* Where to continue iterating */
 } ForLoop;
 
@@ -77,9 +77,9 @@ ForLoop_New(void)
 {
 	ForLoop *f = bmake_malloc(sizeof *f);
 
-	Buf_Init(>body);
 	Vector_Init(>vars, sizeof(char *));
 	SubstringWords_Init(>items);
+	Buf_Init(>body);
 	f->nextItem = 0;
 
 	return f;
@@ -88,13 +88,12 @@ ForLoop_New(void)
 static void
 ForLoop_Free(ForLoop *f)
 {
-	Buf_Done(>body);
-
 	while (f->vars.len > 0)
 		free(*(char **)Vector_Pop(>vars));
 	Vector_Done(>vars);
 
 	SubstringWords_Free(f->items);
+	Buf_Done(>body);
 
 	free(f);
 }
@@ -156,7 +155,7 @@ ForLoop_ParseItems(ForLoop *f, const cha
 	if (f->items.len == 1 && Substring_IsEmpty(f->items.words[0]))
 		f->items.len = 0;	/* .for var in ${:U} */
 
-	if (f->items.len != 0 && f->items.len % f->vars.len != 0) {
+	if (f->items.len % f->vars.len != 0) {
 		Parse_Error(PARSE_FATAL,
 		"Wrong number of words (%u) in .for "
 		"substitution list with %u variables",
@@ -184,13 +183,10 @@ IsEndfor(const char *p)
  * Evaluate the for loop in the passed line. The line looks like this:
  *	.for  in 
  *
- * Input:
- *	line		Line to parse
- *
  * Results:
- *	0: Not a .for statement, parse the line
- *	1: We found a for loop
- *	-1: A .for statement with a bad syntax error, discard.
+ *	0	not a .for directive
+ *	1	found a .for directive
+ *	-1	erroneous .for directive
  */
 int
 For_Eval(const char *line)
@@ -241,7 +237,7 @@ For_Accum(const char *line, int *forLeve
 
 		if (IsEndfor(p)) {
 			DEBUG1(FOR, "For: end for %d\n", *forLevel);
-			if (--*forLevel <= 0)
+			if (--*forLevel == 0)
 return false;
 		} else if (IsFor(p)) {
 			(*forLevel)++;
@@ -309,7 +305,7 @@ NeedsEscapes(Substring value, char endc)
  * The result is later unescaped by ApplyModifier_Defined.
  */
 static void
-Buf_AddEscaped(Buffer *cmds, Substring item, char endc)
+AddEscaped(Buffer *cmds, Substring item, char endc)
 {
 	const char *p;
 	char ch;
@@ -377,7 +373,7 @@ ForLoop_SubstVarLong(ForLoop *f, Buffer 
 		 */
 		Buf_AddBytesBetween(body, *inout_mark, start);
 		Buf_AddStr(body, ":U");
-		Buf_AddEscaped(body, f->items.words[f->nextItem + i], endc);
+		AddEscaped(body, f->items.words[f->nextItem + i], endc);
 
 		*inout_mark = p;
 		*pp = p;
@@ -415,7 +411,7 @@ found:
 
 	/* Replace $ with ${:U} */
 	Buf_AddStr(body, "{:U");
-	Buf_AddEscaped(body, f->items.words[f->nextItem + i], '}');
+	AddEscaped(body, f->items.words[f->nextItem + i], '}');
 	Buf_AddByte(body, '}');
 }
 



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 20:15:10 UTC 2022

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

Log Message:
make: clean up handling of .for loops

Sort ForLoop members in natural reading order.

Remove redundant condition in ForLoop_ParseItems; at that point, the
number of variables is non-zero.

Rename Buf_AddEscaped since that function is not part of the Buffer API,
it is specific to .for loops.

No functional change.


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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 20:50:35 UTC 2022

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

Log Message:
make: merge duplicate variables for the main target

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.286 -r1.287 src/usr.bin/make/make.h
cvs rdiff -u -r1.231 -r1.232 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.630 -r1.631 src/usr.bin/make/parse.c
cvs rdiff -u -r1.362 -r1.363 src/usr.bin/make/suff.c
cvs rdiff -u -r1.175 -r1.176 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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 20:50:35 UTC 2022

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

Log Message:
make: merge duplicate variables for the main target

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.286 -r1.287 src/usr.bin/make/make.h
cvs rdiff -u -r1.231 -r1.232 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.630 -r1.631 src/usr.bin/make/parse.c
cvs rdiff -u -r1.362 -r1.363 src/usr.bin/make/suff.c
cvs rdiff -u -r1.175 -r1.176 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/make.h
diff -u src/usr.bin/make/make.h:1.286 src/usr.bin/make/make.h:1.287
--- src/usr.bin/make/make.h:1.286	Fri Jan  7 19:24:27 2022
+++ src/usr.bin/make/make.h	Fri Jan  7 20:50:35 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.286 2022/01/07 19:24:27 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.287 2022/01/07 20:50:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -589,6 +589,7 @@ extern int makelevel;
 extern char *makeDependfile;
 /* If we replaced environ, this will be non-NULL. */
 extern char **savedEnv;
+extern GNode *mainNode;
 
 extern pid_t myPid;
 

Index: src/usr.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.231 src/usr.bin/make/nonints.h:1.232
--- src/usr.bin/make/nonints.h:1.231	Fri Jan  7 20:09:58 2022
+++ src/usr.bin/make/nonints.h	Fri Jan  7 20:50:35 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.231 2022/01/07 20:09:58 rillig Exp $	*/
+/*	$NetBSD: nonints.h,v 1.232 2022/01/07 20:50:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -183,7 +183,6 @@ GNode *Targ_GetNode(const char *) MAKE_A
 GNode *Targ_NewInternalNode(const char *) MAKE_ATTR_USE;
 GNode *Targ_GetEndNode(void);
 void Targ_FindList(GNodeList *, StringList *);
-void Targ_SetMain(GNode *);
 void Targ_PrintCmds(GNode *);
 void Targ_PrintNode(GNode *, int);
 void Targ_PrintNodes(GNodeList *, int);

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.630 src/usr.bin/make/parse.c:1.631
--- src/usr.bin/make/parse.c:1.630	Fri Jan  7 20:37:25 2022
+++ src/usr.bin/make/parse.c	Fri Jan  7 20:50:35 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.630 2022/01/07 20:37:25 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.631 2022/01/07 20:50:35 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.630 2022/01/07 20:37:25 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.631 2022/01/07 20:50:35 rillig Exp $");
 
 /*
  * A file being read.
@@ -179,10 +179,10 @@ typedef List SearchPathList;
 typedef ListNode SearchPathListNode;
 
 /*
- * The main target to create. This is the first target defined in any of the
- * makefiles.
+ * The target to be made if no targets are specified in the command line.
+ * This is the first target defined in any of the makefiles.
  */
-static GNode *mainNode;
+GNode *mainNode;
 
 /*
  * During parsing, the targets from the left-hand side of the currently
@@ -829,7 +829,6 @@ MaybeUpdateMainTarget(void)
 		if (GNode_IsMainCandidate(gn)) {
 			DEBUG1(MAKE, "Setting main node to \"%s\"\n", gn->name);
 			mainNode = gn;
-			Targ_SetMain(gn);
 			return;
 		}
 	}

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.362 src/usr.bin/make/suff.c:1.363
--- src/usr.bin/make/suff.c:1.362	Sat Jan  1 19:44:05 2022
+++ src/usr.bin/make/suff.c	Fri Jan  7 20:50:35 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.362 2022/01/01 19:44:05 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.363 2022/01/07 20:50:35 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.362 2022/01/01 19:44:05 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.363 2022/01/07 20:50:35 rillig Exp $");
 
 typedef List SuffixList;
 typedef ListNode SuffixListNode;
@@ -744,7 +744,6 @@ UpdateTarget(GNode *target, GNode **inou
 	GNode_IsMainCandidate(target)) {
 		DEBUG1(MAKE, "Setting main node to \"%s\"\n", target->name);
 		*inout_main = target;
-		Targ_SetMain(target);
 		/*
 		 * XXX: Why could it be a good idea to return true here?
 		 * The main task of this function is to turn ordinary nodes
@@ -788,7 +787,6 @@ UpdateTarget(GNode *target, GNode **inou
 			target->name);
 			*inout_removedMain = true;
 			*inout_main = NULL;
-			Targ_SetMain(NULL);
 		}
 		Lst_Done(>children);
 		Lst_Init(>children);

Index: src/usr.bin/make/targ.c
diff -u src/usr.bin/make/targ.c:1.175 src/usr.bin/make/targ.c:1.176
--- src/usr.bin/make/targ.c:1.175	Fri Jan  7 20:37:25 2022
+++ src/usr.bin/make/targ.c	Fri Jan  7 20:50:35 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: targ.c,v 1.175 2022/01/07 20:37:25 rillig Exp $	*/
+/*	$NetBSD: targ.c,v 1.176 2022/01/07 20:50:35 rillig Exp $	

CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 20:54:45 UTC 2022

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

Log Message:
make: remove redundant function parameter in suffix handling

Now that mainNode is globally visible, there is no need to pass it
through function parameters.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.232 -r1.233 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.631 -r1.632 src/usr.bin/make/parse.c
cvs rdiff -u -r1.363 -r1.364 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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 20:54:45 UTC 2022

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

Log Message:
make: remove redundant function parameter in suffix handling

Now that mainNode is globally visible, there is no need to pass it
through function parameters.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.232 -r1.233 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.631 -r1.632 src/usr.bin/make/parse.c
cvs rdiff -u -r1.363 -r1.364 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/nonints.h
diff -u src/usr.bin/make/nonints.h:1.232 src/usr.bin/make/nonints.h:1.233
--- src/usr.bin/make/nonints.h:1.232	Fri Jan  7 20:50:35 2022
+++ src/usr.bin/make/nonints.h	Fri Jan  7 20:54:45 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.232 2022/01/07 20:50:35 rillig Exp $	*/
+/*	$NetBSD: nonints.h,v 1.233 2022/01/07 20:54:45 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -160,7 +160,7 @@ void Suff_ClearSuffixes(void);
 bool Suff_IsTransform(const char *) MAKE_ATTR_USE;
 GNode *Suff_AddTransform(const char *);
 void Suff_EndTransform(GNode *);
-void Suff_AddSuffix(const char *, GNode **);
+void Suff_AddSuffix(const char *);
 SearchPath *Suff_GetPath(const char *) MAKE_ATTR_USE;
 void Suff_ExtendPaths(void);
 void Suff_AddInclude(const char *);

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.631 src/usr.bin/make/parse.c:1.632
--- src/usr.bin/make/parse.c:1.631	Fri Jan  7 20:50:35 2022
+++ src/usr.bin/make/parse.c	Fri Jan  7 20:54:45 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.631 2022/01/07 20:50:35 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.632 2022/01/07 20:54:45 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.631 2022/01/07 20:50:35 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.632 2022/01/07 20:54:45 rillig Exp $");
 
 /*
  * A file being read.
@@ -1160,7 +1160,7 @@ ParseDependencySourceSpecial(ParseSpecia
 {
 	switch (special) {
 	case SP_SUFFIXES:
-		Suff_AddSuffix(word, );
+		Suff_AddSuffix(word);
 		break;
 	case SP_PATH:
 		AddToPaths(word, paths);

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.363 src/usr.bin/make/suff.c:1.364
--- src/usr.bin/make/suff.c:1.363	Fri Jan  7 20:50:35 2022
+++ src/usr.bin/make/suff.c	Fri Jan  7 20:54:45 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.363 2022/01/07 20:50:35 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.364 2022/01/07 20:54:45 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.363 2022/01/07 20:50:35 rillig Exp $");
+MAKE_RCSID("$NetBSD: suff.c,v 1.364 2022/01/07 20:54:45 rillig Exp $");
 
 typedef List SuffixList;
 typedef ListNode SuffixListNode;
@@ -734,16 +734,15 @@ RebuildGraph(GNode *transform, Suffix *s
  *	true iff a new main target has been selected.
  */
 static bool
-UpdateTarget(GNode *target, GNode **inout_main, Suffix *suff,
-	 bool *inout_removedMain)
+UpdateTarget(GNode *target, Suffix *suff, bool *inout_removedMain)
 {
 	Suffix *srcSuff, *targSuff;
 	char *ptr;
 
-	if (*inout_main == NULL && *inout_removedMain &&
+	if (mainNode == NULL && *inout_removedMain &&
 	GNode_IsMainCandidate(target)) {
 		DEBUG1(MAKE, "Setting main node to \"%s\"\n", target->name);
-		*inout_main = target;
+		mainNode = target;
 		/*
 		 * XXX: Why could it be a good idea to return true here?
 		 * The main task of this function is to turn ordinary nodes
@@ -781,12 +780,12 @@ UpdateTarget(GNode *target, GNode **inou
 		return false;
 
 	if (ParseTransform(target->name, , )) {
-		if (*inout_main == target) {
+		if (mainNode == target) {
 			DEBUG1(MAKE,
 			"Setting main node from \"%s\" back to null\n",
 			target->name);
 			*inout_removedMain = true;
-			*inout_main = NULL;
+			mainNode = NULL;
 		}
 		Lst_Done(>children);
 		Lst_Init(>children);
@@ -810,14 +809,14 @@ UpdateTarget(GNode *target, GNode **inou
  * suffix rules.
  */
 static void
-UpdateTargets(GNode **inout_main, Suffix *suff)
+UpdateTargets(Suffix *suff)
 {
 	bool removedMain = false;
 	GNodeListNode *ln;
 
 	for (ln = Targ_List()->first; ln != NULL; ln = ln->next) {
 		GNode *gn = ln->datum;
-		if (UpdateTarget(gn, inout_main, suff, ))
+		if (UpdateTarget(gn, suff, ))
 			break;
 	}
 }
@@ -836,7 +835,7 @@ UpdateTargets(GNode **inout_main, Suffix
  *	name		the name of the suffix to add
  */
 void
-Suff_AddSuffix(const char *name, GNode **inout_main)
+Suff_AddSuffix(const char *name)
 {
 	GNodeListNode *ln;
 
@@ -848,7 +847,7 @@ Suff_AddSuffix(const char *name, GNode *
 	Lst_Append(, suff);
 	DEBUG1(SUFF, "Adding suffix \"%s\"\n", suff->name);
 
-	

CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 21:00:50 UTC 2022

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

Log Message:
make: have as few statements as possible between va_start and va_end

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.566 -r1.567 src/usr.bin/make/main.c
cvs rdiff -u -r1.632 -r1.633 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/main.c
diff -u src/usr.bin/make/main.c:1.566 src/usr.bin/make/main.c:1.567
--- src/usr.bin/make/main.c:1.566	Fri Jan  7 20:37:25 2022
+++ src/usr.bin/make/main.c	Fri Jan  7 21:00:49 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.566 2022/01/07 20:37:25 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.567 2022/01/07 21:00:49 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.566 2022/01/07 20:37:25 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.567 2022/01/07 21:00:49 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	"The Regents of the University of California.  "
@@ -1805,9 +1805,10 @@ Error(const char *fmt, ...)
 	if (f == stdout)
 		f = stderr;
 	(void)fflush(stdout);
+
 	for (;;) {
-		va_start(ap, fmt);
 		fprintf(f, "%s: ", progname);
+		va_start(ap, fmt);
 		(void)vfprintf(f, fmt, ap);
 		va_end(ap);
 		(void)fprintf(f, "\n");
@@ -1858,9 +1859,9 @@ Punt(const char *fmt, ...)
 {
 	va_list ap;
 
-	va_start(ap, fmt);
 	(void)fflush(stdout);
 	(void)fprintf(stderr, "%s: ", progname);
+	va_start(ap, fmt);
 	(void)vfprintf(stderr, fmt, ap);
 	va_end(ap);
 	(void)fprintf(stderr, "\n");

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.632 src/usr.bin/make/parse.c:1.633
--- src/usr.bin/make/parse.c:1.632	Fri Jan  7 20:54:45 2022
+++ src/usr.bin/make/parse.c	Fri Jan  7 21:00:49 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.632 2022/01/07 20:54:45 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.633 2022/01/07 21:00:49 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.632 2022/01/07 20:54:45 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.633 2022/01/07 21:00:49 rillig Exp $");
 
 /*
  * A file being read.
@@ -526,8 +526,8 @@ Parse_Error(ParseErrorLevel type, const 
 		lineno = (size_t)curFile->readLines;
 	}
 
-	va_start(ap, fmt);
 	(void)fflush(stdout);
+	va_start(ap, fmt);
 	ParseVErrorInternal(stderr, fname, lineno, type, fmt, ap);
 	va_end(ap);
 
@@ -1612,6 +1612,7 @@ VarAssign_EvalSubst(GNode *scope, const 
 	 *
 	 * TODO: Add a test that demonstrates why this code is needed,
 	 *  apart from making the debug log longer.
+	 *
 	 * XXX: The variable name is expanded up to 3 times.
 	 */
 	if (!Var_ExistsExpand(scope, name))



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 21:00:50 UTC 2022

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

Log Message:
make: have as few statements as possible between va_start and va_end

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.566 -r1.567 src/usr.bin/make/main.c
cvs rdiff -u -r1.632 -r1.633 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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 19:30:18 UTC 2022

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

Log Message:
tests/make: fix documentation in cond-func.mk


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

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

Modified files:

Index: src/usr.bin/make/unit-tests/cond-func.exp
diff -u src/usr.bin/make/unit-tests/cond-func.exp:1.7 src/usr.bin/make/unit-tests/cond-func.exp:1.8
--- src/usr.bin/make/unit-tests/cond-func.exp:1.7	Sun Dec 12 08:36:21 2021
+++ src/usr.bin/make/unit-tests/cond-func.exp	Fri Jan  7 19:30:17 2022
@@ -2,11 +2,11 @@ make: "cond-func.mk" line 36: Missing cl
 make: "cond-func.mk" line 51: Missing closing parenthesis for defined()
 make: "cond-func.mk" line 54: Missing closing parenthesis for defined()
 make: "cond-func.mk" line 94: The empty variable is never defined.
-make: "cond-func.mk" line 102: A plain function name is parsed as !empty(...).
-make: "cond-func.mk" line 109: A plain function name is parsed as !empty(...).
-make: "cond-func.mk" line 119: Symbols may start with a function name.
-make: "cond-func.mk" line 124: Symbols may start with a function name.
-make: "cond-func.mk" line 130: Missing closing parenthesis for defined()
+make: "cond-func.mk" line 103: A plain function name is parsed as defined(...).
+make: "cond-func.mk" line 110: A plain function name is parsed as defined(...).
+make: "cond-func.mk" line 120: Symbols may start with a function name.
+make: "cond-func.mk" line 125: Symbols may start with a function name.
+make: "cond-func.mk" line 131: Missing closing parenthesis for defined()
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/cond-func.mk
diff -u src/usr.bin/make/unit-tests/cond-func.mk:1.10 src/usr.bin/make/unit-tests/cond-func.mk:1.11
--- src/usr.bin/make/unit-tests/cond-func.mk:1.10	Tue Dec 28 22:13:56 2021
+++ src/usr.bin/make/unit-tests/cond-func.mk	Fri Jan  7 19:30:17 2022
@@ -1,4 +1,4 @@
-# $NetBSD: cond-func.mk,v 1.10 2021/12/28 22:13:56 rillig Exp $
+# $NetBSD: cond-func.mk,v 1.11 2022/01/07 19:30:17 rillig Exp $
 #
 # Tests for those parts of the functions in .if conditions that are common
 # among several functions.
@@ -94,19 +94,20 @@ ${VARNAME_UNBALANCED_BRACES}=	variable n
 .  info The empty variable is never defined.
 .endif
 
-# The plain word 'defined' is interpreted as '!empty(defined)'.
+# The plain word 'defined' is interpreted as 'defined(defined)', see
+# CondParser_ComparisonOrLeaf.
 # That variable is not defined (yet).
 .if defined
 .  error
 .else
-.  info A plain function name is parsed as !empty(...).
+.  info A plain function name is parsed as defined(...).
 .endif
 
 # If a variable named 'defined' is actually defined, the bare word 'defined'
 # is interpreted as 'defined(defined)', and the condition evaluates to true.
 defined=	# defined but empty
 .if defined
-.  info A plain function name is parsed as !empty(...).
+.  info A plain function name is parsed as defined(...).
 .else
 .  error
 .endif



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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 19:30:18 UTC 2022

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

Log Message:
tests/make: fix documentation in cond-func.mk


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

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



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 20:04:49 UTC 2022

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

Log Message:
make: use simpler code for handling .for loops

Since the body of a .for loop is scanned from start to end, there is no
need to remember the length of a variable name.

Using memcmp for comparing the variable name was probably overkill since
the variable names are usually very short, so rather compare them byte
by byte.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.154 -r1.155 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.154 src/usr.bin/make/for.c:1.155
--- src/usr.bin/make/for.c:1.154	Sun Jan  2 01:54:43 2022
+++ src/usr.bin/make/for.c	Fri Jan  7 20:04:49 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: for.c,v 1.154 2022/01/02 01:54:43 rillig Exp $	*/
+/*	$NetBSD: for.c,v 1.155 2022/01/07 20:04:49 rillig Exp $	*/
 
 /*
  * Copyright (c) 1992, The Regents of the University of California.
@@ -58,18 +58,12 @@
 #include "make.h"
 
 /*	"@(#)for.c	8.1 (Berkeley) 6/6/93"	*/
-MAKE_RCSID("$NetBSD: for.c,v 1.154 2022/01/02 01:54:43 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.155 2022/01/07 20:04:49 rillig Exp $");
 
 
-/* One of the variables to the left of the "in" in a .for loop. */
-typedef struct ForVar {
-	char *name;
-	size_t nameLen;
-} ForVar;
-
 typedef struct ForLoop {
 	Buffer body;		/* Unexpanded body of the loop */
-	Vector /* of ForVar */ vars; /* Iteration variables */
+	Vector /* of 'char *' */ vars; /* Iteration variables */
 	SubstringWords items;	/* Substitution items */
 	unsigned int nextItem;	/* Where to continue iterating */
 } ForLoop;
@@ -85,7 +79,7 @@ ForLoop_New(void)
 	ForLoop *f = bmake_malloc(sizeof *f);
 
 	Buf_Init(>body);
-	Vector_Init(>vars, sizeof(ForVar));
+	Vector_Init(>vars, sizeof(char *));
 	SubstringWords_Init(>items);
 	f->nextItem = 0;
 
@@ -97,10 +91,8 @@ ForLoop_Free(ForLoop *f)
 {
 	Buf_Done(>body);
 
-	while (f->vars.len > 0) {
-		ForVar *var = Vector_Pop(>vars);
-		free(var->name);
-	}
+	while (f->vars.len > 0)
+		free(*(char **)Vector_Pop(>vars));
 	Vector_Done(>vars);
 
 	SubstringWords_Free(f->items);
@@ -108,14 +100,6 @@ ForLoop_Free(ForLoop *f)
 	free(f);
 }
 
-static void
-ForLoop_AddVar(ForLoop *f, const char *name, size_t len)
-{
-	ForVar *var = Vector_Push(>vars);
-	var->name = bmake_strldup(name, len);
-	var->nameLen = len;
-}
-
 static bool
 ForLoop_ParseVarnames(ForLoop *f, const char **pp)
 {
@@ -142,7 +126,7 @@ ForLoop_ParseVarnames(ForLoop *f, const 
 			break;
 		}
 
-		ForLoop_AddVar(f, p, len);
+		*(char **)Vector_Push(>vars) = bmake_strldup(p, len);
 		p += len;
 	}
 
@@ -374,31 +358,29 @@ ForLoop_SubstVarLong(ForLoop *f, Buffer 
 		 const char *end, char endc, const char **inout_mark)
 {
 	size_t i;
-	const char *p = *pp;
+	const char *start = *pp;
+	const char **vars = Vector_Get(>vars, 0);
 
 	for (i = 0; i < f->vars.len; i++) {
-		const ForVar *forVar = Vector_Get(>vars, i);
-		const char *varname = forVar->name;
-		size_t varnameLen = forVar->nameLen;
+		const char *p = start;
+		const char *varname = vars[i];
 
-		if (varnameLen >= (size_t)(end - p))
-			continue;
-		if (memcmp(p, varname, varnameLen) != 0)
+		while (p < end && *varname != '\0' && *p == *varname)
+			p++, varname++;
+		if (*varname != '\0')
 			continue;
 		/* XXX: why test for backslash here? */
-		if (p[varnameLen] != ':' && p[varnameLen] != endc &&
-		p[varnameLen] != '\\')
+		if (*p != ':' && *p != endc && *p != '\\')
 			continue;
 
 		/*
 		 * Found a variable match.  Skip over the variable name and
 		 * instead add ':U' to the current body.
 		 */
-		Buf_AddBytesBetween(body, *inout_mark, p);
+		Buf_AddBytesBetween(body, *inout_mark, start);
 		Buf_AddStr(body, ":U");
 		Buf_AddEscaped(body, f->items.words[f->nextItem + i], endc);
 
-		p += varnameLen;
 		*inout_mark = p;
 		*pp = p;
 		return;
@@ -414,7 +396,7 @@ ForLoop_SubstVarShort(ForLoop *f, Buffer
 		  const char *p, const char **inout_mark)
 {
 	const char ch = *p;
-	const ForVar *vars;
+	const char **vars;
 	size_t i;
 
 	/* Skip $$ and stupid ones. */
@@ -423,7 +405,7 @@ ForLoop_SubstVarShort(ForLoop *f, Buffer
 
 	vars = Vector_Get(>vars, 0);
 	for (i = 0; i < f->vars.len; i++) {
-		const char *varname = vars[i].name;
+		const char *varname = vars[i];
 		if (varname[0] == ch && varname[1] == '\0')
 			goto found;
 	}



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 20:04:49 UTC 2022

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

Log Message:
make: use simpler code for handling .for loops

Since the body of a .for loop is scanned from start to end, there is no
need to remember the length of a variable name.

Using memcmp for comparing the variable name was probably overkill since
the variable names are usually very short, so rather compare them byte
by byte.

No functional change.


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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 20:37:25 UTC 2022

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

Log Message:
make: clean up comments, variable names, function names

The comment in ApplyDependencySourceOther repeated the code, its second
half didn't match any current code.

The comment above ParseDependencySourcesEmpty repeated the code.

No binary change, except for assertion line numbers.


To generate a diff of this commit:
cvs rdiff -u -r1.565 -r1.566 src/usr.bin/make/main.c
cvs rdiff -u -r1.629 -r1.630 src/usr.bin/make/parse.c
cvs rdiff -u -r1.174 -r1.175 src/usr.bin/make/targ.c
cvs rdiff -u -r1.995 -r1.996 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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 20:37:25 UTC 2022

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

Log Message:
make: clean up comments, variable names, function names

The comment in ApplyDependencySourceOther repeated the code, its second
half didn't match any current code.

The comment above ParseDependencySourcesEmpty repeated the code.

No binary change, except for assertion line numbers.


To generate a diff of this commit:
cvs rdiff -u -r1.565 -r1.566 src/usr.bin/make/main.c
cvs rdiff -u -r1.629 -r1.630 src/usr.bin/make/parse.c
cvs rdiff -u -r1.174 -r1.175 src/usr.bin/make/targ.c
cvs rdiff -u -r1.995 -r1.996 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.565 src/usr.bin/make/main.c:1.566
--- src/usr.bin/make/main.c:1.565	Sat Jan  1 21:41:50 2022
+++ src/usr.bin/make/main.c	Fri Jan  7 20:37:25 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.565 2022/01/01 21:41:50 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.566 2022/01/07 20:37:25 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.565 2022/01/01 21:41:50 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.566 2022/01/07 20:37:25 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	"The Regents of the University of California.  "
@@ -1799,22 +1799,22 @@ void
 Error(const char *fmt, ...)
 {
 	va_list ap;
-	FILE *err_file;
+	FILE *f;
 
-	err_file = opts.debug_file;
-	if (err_file == stdout)
-		err_file = stderr;
+	f = opts.debug_file;
+	if (f == stdout)
+		f = stderr;
 	(void)fflush(stdout);
 	for (;;) {
 		va_start(ap, fmt);
-		fprintf(err_file, "%s: ", progname);
-		(void)vfprintf(err_file, fmt, ap);
+		fprintf(f, "%s: ", progname);
+		(void)vfprintf(f, fmt, ap);
 		va_end(ap);
-		(void)fprintf(err_file, "\n");
-		(void)fflush(err_file);
-		if (err_file == stderr)
+		(void)fprintf(f, "\n");
+		(void)fflush(f);
+		if (f == stderr)
 			break;
-		err_file = stderr;
+		f = stderr;
 	}
 	main_errors++;
 }
@@ -2093,21 +2093,21 @@ void
 Main_ExportMAKEFLAGS(bool first)
 {
 	static bool once = true;
-	const char *expr;
-	char *s;
+	char *flags;
 
 	if (once != first)
 		return;
 	once = false;
 
-	expr = "${.MAKEFLAGS} ${.MAKEOVERRIDES:O:u:@v@$v=${$v:Q}@}";
-	(void)Var_Subst(expr, SCOPE_CMDLINE, VARE_WANTRES, );
+	(void)Var_Subst(
+	"${.MAKEFLAGS} ${.MAKEOVERRIDES:O:u:@v@$v=${$v:Q}@}",
+	SCOPE_CMDLINE, VARE_WANTRES, );
 	/* TODO: handle errors */
-	if (s[0] != '\0') {
+	if (flags[0] != '\0') {
 #ifdef POSIX
-		setenv("MAKEFLAGS", s, 1);
+		setenv("MAKEFLAGS", flags, 1);
 #else
-		setenv("MAKE", s, 1);
+		setenv("MAKE", flags, 1);
 #endif
 	}
 }
@@ -2121,7 +2121,7 @@ getTmpdir(void)
 	if (tmpdir != NULL)
 		return tmpdir;
 
-	/* Honor $TMPDIR but only if it is valid. Ensure it ends with '/'. */
+	/* Honor $TMPDIR if it is valid, strip a trailing '/'. */
 	(void)Var_Subst("${TMPDIR:tA:U" _PATH_TMP ":S,/$,,W}/",
 	SCOPE_GLOBAL, VARE_WANTRES, );
 	/* TODO: handle errors */

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.629 src/usr.bin/make/parse.c:1.630
--- src/usr.bin/make/parse.c:1.629	Fri Jan  7 20:09:58 2022
+++ src/usr.bin/make/parse.c	Fri Jan  7 20:37:25 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.629 2022/01/07 20:09:58 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.630 2022/01/07 20:37:25 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.629 2022/01/07 20:09:58 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.630 2022/01/07 20:37:25 rillig Exp $");
 
 /*
  * A file being read.
@@ -334,7 +334,7 @@ loadfile(const char *path, int fd)
 	if (!Buf_EndsWith(, '\n'))
 		Buf_AddByte(, '\n');
 
-	return buf;
+	return buf;		/* may not be null-terminated */
 }
 
 static void
@@ -568,11 +568,9 @@ HandleMessage(ParseErrorLevel level, con
 }
 
 /*
- * Add the child to the parent's children.
- *
- * Additionally, add the parent to the child's parents, but only if the
- * target is not special.  An example for such a special target is .END,
- * which does not need to be informed once the child target has been made.
+ * Add the child to the parent's children, and for non-special targets, vice
+ * versa.  Special targets such as .END do not need to be informed once the
+ * child target has been made.
  */
 static void
 LinkSource(GNode *pgn, GNode *cgn, bool isSpecial)
@@ -728,17 +726,17 @@ ApplyDependencySourceKeyword(const char 
 	return false;
 }
 
+/*
+ * In a line like ".MAIN: source1 source2", add all sources to the list of
+ * things to create, but only if the user didn't specify a 

CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 21:04:50 UTC 2022

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

Log Message:
make: in loadfile, use simpler magic numbers

No functional change.


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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 21:04:50 UTC 2022

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

Log Message:
make: in loadfile, use simpler magic numbers

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.633 -r1.634 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.633 src/usr.bin/make/parse.c:1.634
--- src/usr.bin/make/parse.c:1.633	Fri Jan  7 21:00:49 2022
+++ src/usr.bin/make/parse.c	Fri Jan  7 21:04:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.633 2022/01/07 21:00:49 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.634 2022/01/07 21:04:50 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.633 2022/01/07 21:00:49 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.634 2022/01/07 21:04:50 rillig Exp $");
 
 /*
  * A file being read.
@@ -305,14 +305,13 @@ loadfile(const char *path, int fd)
 	struct stat st;
 
 	bufSize = fstat(fd, ) == 0 && S_ISREG(st.st_mode) &&
-		  st.st_size >= 1 && st.st_size <= 0x3fff
+		  st.st_size > 0 && st.st_size < 1024 * 1024 * 1024
 	? (size_t)st.st_size : 1024;
 	Buf_InitSize(, bufSize);
 
 	for (;;) {
 		if (buf.len == buf.cap) {
-			if (buf.cap > 0x1fff) {
-errno = EFBIG;
+			if (buf.cap >= 512 * 1024 * 1024) {
 Error("%s: file too large", path);
 exit(2); /* Not 1 so -q can distinguish error */
 			}



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 21:57:26 UTC 2022

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

Log Message:
make: rename local variable in ParseRawLine

The previous variable name suggested that the variable would point to
the first '#' character of the line, instead it points to the whitespace
before the first '#'.

No functional change.


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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 21:57:26 UTC 2022

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

Log Message:
make: rename local variable in ParseRawLine

The previous variable name suggested that the variable would point to
the first '#' character of the line, instead it points to the whitespace
before the first '#'.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.635 -r1.636 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.635 src/usr.bin/make/parse.c:1.636
--- src/usr.bin/make/parse.c:1.635	Fri Jan  7 21:40:56 2022
+++ src/usr.bin/make/parse.c	Fri Jan  7 21:57:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.635 2022/01/07 21:40:56 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.636 2022/01/07 21:57:26 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.635 2022/01/07 21:40:56 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.636 2022/01/07 21:57:26 rillig Exp $");
 
 /*
  * A file being read.
@@ -2299,14 +2299,14 @@ typedef enum ParseRawLineResult {
  */
 static ParseRawLineResult
 ParseRawLine(IncludedFile *curFile, char **out_line, char **out_line_end,
-	 char **out_firstBackslash, char **out_firstComment)
+	 char **out_firstBackslash, char **out_commentLineEnd)
 {
 	char *line = curFile->buf_ptr;
 	char *buf_end = curFile->buf_end;
 	char *p = line;
 	char *line_end = line;
 	char *firstBackslash = NULL;
-	char *firstComment = NULL;
+	char *commentLineEnd = NULL;
 	ParseRawLineResult res = PRLR_LINE;
 
 	curFile->readLines++;
@@ -2349,9 +2349,9 @@ ParseRawLine(IncludedFile *curFile, char
 		 * Remember the first '#' for comment stripping, unless
 		 * the previous char was '[', as in the modifier ':[#]'.
 		 */
-		if (ch == '#' && firstComment == NULL &&
+		if (ch == '#' && commentLineEnd == NULL &&
 		!(p > line && p[-1] == '['))
-			firstComment = line_end;
+			commentLineEnd = line_end;
 
 		p++;
 		if (ch == '\n')
@@ -2366,7 +2366,7 @@ ParseRawLine(IncludedFile *curFile, char
 	*out_line = line;
 	*out_line_end = line_end;
 	*out_firstBackslash = firstBackslash;
-	*out_firstComment = firstComment;
+	*out_commentLineEnd = commentLineEnd;
 	return res;
 }
 
@@ -2454,15 +2454,15 @@ ReadLowLevelLine(LineKind kind)
 	char *line;
 	char *line_end;
 	char *firstBackslash;
-	char *firstComment;
+	char *commentLineEnd;
 
 	for (;;) {
 		ParseRawLineResult res = ParseRawLine(curFile,
-		, _end, , );
+		, _end, , );
 		if (res == PRLR_ERROR)
 			return NULL;
 
-		if (line_end == line || firstComment == line) {
+		if (line == line_end || line == commentLineEnd) {
 			if (res == PRLR_EOF)
 return NULL;
 			if (kind != LK_FOR_BODY)
@@ -2482,8 +2482,8 @@ ReadLowLevelLine(LineKind kind)
 	}
 
 	/* Ignore anything after a non-escaped '#' in non-commands. */
-	if (firstComment != NULL && line[0] != '\t')
-		*firstComment = '\0';
+	if (commentLineEnd != NULL && line[0] != '\t')
+		*commentLineEnd = '\0';
 
 	/* If we didn't see a '\\' then the in-situ data is fine. */
 	if (firstBackslash == NULL)



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 22:08:09 UTC 2022

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

Log Message:
make: remove redundant condition in ParseRawLine

The input buffer is guaranteed to be terminated by '\n'.  This means
that after a '\\', there is no need to check for the end of that buffer.

While here, condense ReadLowLevelLine.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.636 -r1.637 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.636 src/usr.bin/make/parse.c:1.637
--- src/usr.bin/make/parse.c:1.636	Fri Jan  7 21:57:26 2022
+++ src/usr.bin/make/parse.c	Fri Jan  7 22:08:09 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.636 2022/01/07 21:57:26 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.637 2022/01/07 22:08:09 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.636 2022/01/07 21:57:26 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.637 2022/01/07 22:08:09 rillig Exp $");
 
 /*
  * A file being read.
@@ -2320,8 +2320,7 @@ ParseRawLine(IncludedFile *curFile, char
 		}
 
 		ch = *p;
-		if (ch == '\0' ||
-		(ch == '\\' && p + 1 < buf_end && p[1] == '\0')) {
+		if (ch == '\0' || (ch == '\\' && p[1] == '\0')) {
 			Parse_Error(PARSE_FATAL, "Zero byte read from file");
 			return PRLR_ERROR;
 		}
@@ -2481,17 +2480,10 @@ ReadLowLevelLine(LineKind kind)
 		break;
 	}
 
-	/* Ignore anything after a non-escaped '#' in non-commands. */
 	if (commentLineEnd != NULL && line[0] != '\t')
 		*commentLineEnd = '\0';
-
-	/* If we didn't see a '\\' then the in-situ data is fine. */
-	if (firstBackslash == NULL)
-		return line;
-
-	/* Remove escapes from '\n' and '#' */
-	UnescapeBackslash(line, firstBackslash);
-
+	if (firstBackslash != NULL)
+		UnescapeBackslash(line, firstBackslash);
 	return line;
 }
 



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 22:08:09 UTC 2022

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

Log Message:
make: remove redundant condition in ParseRawLine

The input buffer is guaranteed to be terminated by '\n'.  This means
that after a '\\', there is no need to check for the end of that buffer.

While here, condense ReadLowLevelLine.

No functional change.


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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 19:24:27 UTC 2022

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

Log Message:
make: rename and inline Targ_Precious

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.235 -r1.236 src/usr.bin/make/compat.c
cvs rdiff -u -r1.446 -r1.447 src/usr.bin/make/job.c
cvs rdiff -u -r1.285 -r1.286 src/usr.bin/make/make.h
cvs rdiff -u -r1.229 -r1.230 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.173 -r1.174 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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 19:24:27 UTC 2022

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

Log Message:
make: rename and inline Targ_Precious

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.235 -r1.236 src/usr.bin/make/compat.c
cvs rdiff -u -r1.446 -r1.447 src/usr.bin/make/job.c
cvs rdiff -u -r1.285 -r1.286 src/usr.bin/make/make.h
cvs rdiff -u -r1.229 -r1.230 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.173 -r1.174 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.235 src/usr.bin/make/compat.c:1.236
--- src/usr.bin/make/compat.c:1.235	Mon Dec 27 18:26:22 2021
+++ src/usr.bin/make/compat.c	Fri Jan  7 19:24:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.235 2021/12/27 18:26:22 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.236 2022/01/07 19:24:27 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
 #include "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.235 2021/12/27 18:26:22 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.236 2022/01/07 19:24:27 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -109,7 +109,7 @@ static int compatSigno;
 static void
 CompatDeleteTarget(GNode *gn)
 {
-	if (gn != NULL && !Targ_Precious(gn)) {
+	if (gn != NULL && !GNode_IsPrecious(gn)) {
 		const char *file = GNode_VarTarget(gn);
 
 		if (!opts.noExecute && unlink_file(file)) {
@@ -132,7 +132,7 @@ CompatInterrupt(int signo)
 {
 	CompatDeleteTarget(curTarg);
 
-	if (curTarg != NULL && !Targ_Precious(curTarg)) {
+	if (curTarg != NULL && !GNode_IsPrecious(curTarg)) {
 		/*
 		 * Run .INTERRUPT only if hit with interrupt signal
 		 */

Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.446 src/usr.bin/make/job.c:1.447
--- src/usr.bin/make/job.c:1.446	Fri Jan  7 08:28:06 2022
+++ src/usr.bin/make/job.c	Fri Jan  7 19:24:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.446 2022/01/07 08:28:06 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.447 2022/01/07 19:24:27 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -142,7 +142,7 @@
 #include "trace.h"
 
 /*	"@(#)job.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: job.c,v 1.446 2022/01/07 08:28:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.447 2022/01/07 19:24:27 rillig Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -506,7 +506,7 @@ JobDeleteTarget(GNode *gn)
 		return;
 	if (gn->type & OP_PHONY)
 		return;
-	if (Targ_Precious(gn))
+	if (GNode_IsPrecious(gn))
 		return;
 	if (opts.noExecute)
 		return;

Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.285 src/usr.bin/make/make.h:1.286
--- src/usr.bin/make/make.h:1.285	Fri Jan  7 13:56:09 2022
+++ src/usr.bin/make/make.h	Fri Jan  7 19:24:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.285 2022/01/07 13:56:09 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.286 2022/01/07 19:24:27 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -820,6 +820,14 @@ GNode_IsMainCandidate(const GNode *gn)
 			OP_EXEC | OP_TRANSFORM)) == 0;
 }
 
+/* Return whether the target file should be preserved on interrupt. */
+MAKE_INLINE bool MAKE_ATTR_USE
+GNode_IsPrecious(const GNode *gn)
+{
+	/* XXX: Why are '::' targets precious? */
+	return allPrecious || gn->type & (OP_PRECIOUS | OP_DOUBLEDEP);
+}
+
 MAKE_INLINE const char * MAKE_ATTR_USE
 GNode_VarTarget(GNode *gn) { return GNode_ValueDirect(gn, TARGET); }
 MAKE_INLINE const char * MAKE_ATTR_USE

Index: src/usr.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.229 src/usr.bin/make/nonints.h:1.230
--- src/usr.bin/make/nonints.h:1.229	Sun Jan  2 01:54:43 2022
+++ src/usr.bin/make/nonints.h	Fri Jan  7 19:24:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.229 2022/01/02 01:54:43 rillig Exp $	*/
+/*	$NetBSD: nonints.h,v 1.230 2022/01/07 19:24:27 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -183,7 +183,6 @@ GNode *Targ_GetNode(const char *) MAKE_A
 GNode *Targ_NewInternalNode(const char *) MAKE_ATTR_USE;
 GNode *Targ_GetEndNode(void);
 void Targ_FindList(GNodeList *, StringList *);
-bool Targ_Precious(const GNode *) MAKE_ATTR_USE;
 void Targ_SetMain(GNode *);
 void Targ_PrintCmds(GNode *);
 void Targ_PrintNode(GNode *, int);

Index: src/usr.bin/make/targ.c
diff -u src/usr.bin/make/targ.c:1.173 src/usr.bin/make/targ.c:1.174
--- src/usr.bin/make/targ.c:1.173	Sun Nov 28 19:51:06 2021
+++ src/usr.bin/make/targ.c	Fri Jan  7 19:24:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: targ.c,v 1.173 2021/11/28 19:51:06 rillig Exp $	*/
+/*	$NetBSD: targ.c,v 1.174 2022/01/07 19:24:27 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -93,9 

CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 20:09:58 UTC 2022

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

Log Message:
make: eliminate file-scope variable forLevel

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.155 -r1.156 src/usr.bin/make/for.c
cvs rdiff -u -r1.230 -r1.231 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.628 -r1.629 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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 20:09:58 UTC 2022

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

Log Message:
make: eliminate file-scope variable forLevel

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.155 -r1.156 src/usr.bin/make/for.c
cvs rdiff -u -r1.230 -r1.231 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.628 -r1.629 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/for.c
diff -u src/usr.bin/make/for.c:1.155 src/usr.bin/make/for.c:1.156
--- src/usr.bin/make/for.c:1.155	Fri Jan  7 20:04:49 2022
+++ src/usr.bin/make/for.c	Fri Jan  7 20:09:58 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: for.c,v 1.155 2022/01/07 20:04:49 rillig Exp $	*/
+/*	$NetBSD: for.c,v 1.156 2022/01/07 20:09:58 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.155 2022/01/07 20:04:49 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.156 2022/01/07 20:09:58 rillig Exp $");
 
 
 typedef struct ForLoop {
@@ -70,7 +70,6 @@ typedef struct ForLoop {
 
 
 static ForLoop *accumFor;	/* Loop being accumulated */
-static int forLevel = 0;	/* Nesting level */
 
 
 static ForLoop *
@@ -224,7 +223,6 @@ For_Eval(const char *line)
 	}
 
 	accumFor = f;
-	forLevel = 1;
 	return 1;
 }
 
@@ -233,7 +231,7 @@ For_Eval(const char *line)
  * Returns false when the matching .endfor is reached.
  */
 bool
-For_Accum(const char *line)
+For_Accum(const char *line, int *forLevel)
 {
 	const char *p = line;
 
@@ -242,12 +240,12 @@ For_Accum(const char *line)
 		cpp_skip_whitespace();
 
 		if (IsEndfor(p)) {
-			DEBUG1(FOR, "For: end for %d\n", forLevel);
-			if (--forLevel <= 0)
+			DEBUG1(FOR, "For: end for %d\n", *forLevel);
+			if (--*forLevel <= 0)
 return false;
 		} else if (IsFor(p)) {
-			forLevel++;
-			DEBUG1(FOR, "For: new loop %d\n", forLevel);
+			(*forLevel)++;
+			DEBUG1(FOR, "For: new loop %d\n", *forLevel);
 		}
 	}
 

Index: src/usr.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.230 src/usr.bin/make/nonints.h:1.231
--- src/usr.bin/make/nonints.h:1.230	Fri Jan  7 19:24:27 2022
+++ src/usr.bin/make/nonints.h	Fri Jan  7 20:09:58 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.230 2022/01/07 19:24:27 rillig Exp $	*/
+/*	$NetBSD: nonints.h,v 1.231 2022/01/07 20:09:58 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -118,7 +118,7 @@ void SearchPath_Free(SearchPath *);
 /* for.c */
 struct ForLoop;
 int For_Eval(const char *) MAKE_ATTR_USE;
-bool For_Accum(const char *) MAKE_ATTR_USE;
+bool For_Accum(const char *, int *) MAKE_ATTR_USE;
 void For_Run(int);
 bool For_NextIteration(struct ForLoop *, Buffer *);
 

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.628 src/usr.bin/make/parse.c:1.629
--- src/usr.bin/make/parse.c:1.628	Fri Jan  7 14:03:55 2022
+++ src/usr.bin/make/parse.c	Fri Jan  7 20:09:58 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.628 2022/01/07 14:03:55 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.629 2022/01/07 20:09:58 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.628 2022/01/07 14:03:55 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.629 2022/01/07 20:09:58 rillig Exp $");
 
 /*
  * A file being read.
@@ -2559,6 +2559,7 @@ ParseForLoop(const char *line)
 {
 	int rval;
 	int firstLineno;
+	int forLevel;
 
 	rval = For_Eval(line);
 	if (rval == 0)
@@ -2570,6 +2571,7 @@ ParseForLoop(const char *line)
 	firstLineno = CurFile()->readLines;
 
 	/* Accumulate the loop body until the matching '.endfor'. */
+	forLevel = 1;
 	do {
 		line = ReadLowLevelLine(LK_FOR_BODY);
 		if (line == NULL) {
@@ -2577,7 +2579,7 @@ ParseForLoop(const char *line)
 			"Unexpected end of file in .for loop");
 			break;
 		}
-	} while (For_Accum(line));
+	} while (For_Accum(line, ));
 
 	For_Run(firstLineno);
 	return true;



CVS commit: src/usr.bin/make

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 21:40:57 UTC 2022

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

Log Message:
make: condense UnescapeBackslash

No functional change.


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

2022-01-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Jan  7 21:40:57 UTC 2022

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

Log Message:
make: condense UnescapeBackslash

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.634 -r1.635 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.634 src/usr.bin/make/parse.c:1.635
--- src/usr.bin/make/parse.c:1.634	Fri Jan  7 21:04:50 2022
+++ src/usr.bin/make/parse.c	Fri Jan  7 21:40:56 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.634 2022/01/07 21:04:50 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.635 2022/01/07 21:40:56 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.634 2022/01/07 21:04:50 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.635 2022/01/07 21:40:56 rillig Exp $");
 
 /*
  * A file being read.
@@ -2362,8 +2362,8 @@ ParseRawLine(IncludedFile *curFile, char
 			line_end = p;
 	}
 
-	*out_line = line;
 	curFile->buf_ptr = p;
+	*out_line = line;
 	*out_line_end = line_end;
 	*out_firstBackslash = firstBackslash;
 	*out_firstComment = firstComment;
@@ -2392,35 +2392,24 @@ UnescapeBackslash(char *line, char *star
 
 		ch = *src++;
 		if (ch == '\0') {
-			/* Delete '\\' at end of buffer */
+			/* Delete '\\' at the end of the buffer. */
 			dst--;
 			break;
 		}
 
-		/* Delete '\\' from before '#' on non-command lines */
-		if (ch == '#' && line[0] != '\t') {
+		/* Delete '\\' from before '#' on non-command lines. */
+		if (ch == '#' && line[0] != '\t')
 			*dst++ = ch;
-			continue;
-		}
-
-		if (ch != '\n') {
-			/* Leave '\\' in buffer for later */
+		else if (ch == '\n') {
+			pp_skip_hspace();
+			*dst++ = ' ';
+		} else {
+			/* Leave '\\' in the buffer for later. */
 			*dst++ = '\\';
-			/*
-			 * Make sure we don't delete an escaped ' ' from the
-			 * line end.
-			 */
-			spaceStart = dst + 1;
 			*dst++ = ch;
-			continue;
+			/* Keep an escaped ' ' at the line end. */
+			spaceStart = dst;
 		}
-
-		/*
-		 * Escaped '\n' -- replace following whitespace with a single
-		 * ' '.
-		 */
-		pp_skip_hspace();
-		*dst++ = ' ';
 	}
 
 	/* Delete any trailing spaces - eg from empty continuations */