CVS commit: src/sys/dev/audio

2020-08-22 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Aug 23 04:20:01 UTC 2020

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
Improve debug messages.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/dev/audio/audio.c

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



CVS commit: src/sys/dev/audio

2020-08-22 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Aug 23 04:20:01 UTC 2020

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
Improve debug messages.


To generate a diff of this commit:
cvs rdiff -u -r1.77 -r1.78 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.77 src/sys/dev/audio/audio.c:1.78
--- src/sys/dev/audio/audio.c:1.77	Sun Aug 23 04:14:57 2020
+++ src/sys/dev/audio/audio.c	Sun Aug 23 04:20:01 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.77 2020/08/23 04:14:57 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.78 2020/08/23 04:20:01 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.77 2020/08/23 04:14:57 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.78 2020/08/23 04:20:01 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -2498,7 +2498,7 @@ audio_read(struct audio_softc *sc, struc
 	if (track->mmapped)
 		return EPERM;
 
-	TRACET(2, track, "resid=%zd", uio->uio_resid);
+	TRACET(2, track, "resid=%zd ioflag=0x%x", uio->uio_resid, ioflag);
 
 #ifdef AUDIO_PM_IDLE
 	error = audio_exlock_mutex_enter(sc);
@@ -6082,7 +6082,7 @@ audio_softintr_wr(void *cookie)
 		if (track == NULL)
 			continue;
 
-		TRACET(4, track, "broadcast; trseq=%d out=%d/%d/%d",
+		TRACET(4, track, "broadcast; trkseq=%d out=%d/%d/%d",
 		(int)track->seq,
 		track->outbuf.head,
 		track->outbuf.used,



CVS commit: src/sys/dev/audio

2020-08-22 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Aug 23 04:14:57 UTC 2020

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
Improve and update comments.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/dev/audio/audio.c

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



CVS commit: src/sys/dev/audio

2020-08-22 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Aug 23 04:14:57 UTC 2020

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
Improve and update comments.


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.76 src/sys/dev/audio/audio.c:1.77
--- src/sys/dev/audio/audio.c:1.76	Sun Aug 23 04:07:23 2020
+++ src/sys/dev/audio/audio.c	Sun Aug 23 04:14:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.76 2020/08/23 04:07:23 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.77 2020/08/23 04:14:57 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.76 2020/08/23 04:07:23 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.77 2020/08/23 04:14:57 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -4233,8 +4233,9 @@ audio_track_init_freq(audio_track_t *tra
 
 /*
  * Set the userland format of this track.
- * usrfmt argument should be parameter verified with audio_check_params().
- * It will release and reallocate all internal conversion buffers.
+ * usrfmt argument should have been previously verified by
+ * audio_track_setinfo_check().
+ * This function may release and reallocate all internal conversion buffers.
  * It returns 0 if successful.  Otherwise it returns errno with clearing all
  * internal buffers.
  * It must be called without sc_intr_lock since uvm_* routines require non
@@ -7295,7 +7296,7 @@ abort:
  * - pfil and rfil must be zero-filled.
  * If successful,
  * - pfil, rfil will be filled with filter information specified by the
- *   hardware driver.
+ *   hardware driver if necessary.
  * and then returns 0.  Otherwise returns errno.
  * Must be called without sc_lock held.
  */



CVS commit: src/sys/dev/audio

2020-08-22 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Aug 23 04:07:23 UTC 2020

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
Style fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/dev/audio/audio.c

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



CVS commit: src/sys/dev/audio

2020-08-22 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Aug 23 04:07:23 UTC 2020

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
Style fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/dev/audio/audio.c

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

Modified files:

Index: src/sys/dev/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.75 src/sys/dev/audio/audio.c:1.76
--- src/sys/dev/audio/audio.c:1.75	Fri May 29 03:09:14 2020
+++ src/sys/dev/audio/audio.c	Sun Aug 23 04:07:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.75 2020/05/29 03:09:14 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.76 2020/08/23 04:07:23 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.75 2020/05/29 03:09:14 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.76 2020/08/23 04:07:23 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -901,13 +901,15 @@ audioattach(device_t parent, device_t se
 		return;
 	}
 	if (has_playback) {
-		if ((hw_if->start_output == NULL && hw_if->trigger_output == NULL) ||
+		if ((hw_if->start_output == NULL &&
+		 hw_if->trigger_output == NULL) ||
 		hw_if->halt_output == NULL) {
 			aprint_error(": missing playback method\n");
 		}
 	}
 	if (has_capture) {
-		if ((hw_if->start_input == NULL && hw_if->trigger_input == NULL) ||
+		if ((hw_if->start_input == NULL &&
+		 hw_if->trigger_input == NULL) ||
 		hw_if->halt_input == NULL) {
 			aprint_error(": missing capture method\n");
 		}
@@ -6129,7 +6131,7 @@ audio_check_params(audio_format2_t *p)
 
 	/*
 	 * Convert obsolete AUDIO_ENCODING_PCM encodings.
-	 * 
+	 *
 	 * AUDIO_ENCODING_PCM16 == AUDIO_ENCODING_LINEAR
 	 * So, it's always signed, as in SunOS.
 	 *
@@ -6432,7 +6434,7 @@ audio_hw_probe(struct audio_softc *sc, a
  * If fmt is included in the result of query_format, returns 0.
  * Otherwise returns EINVAL.
  * Must be called without sc_lock held.
- */ 
+ */
 static int
 audio_hw_validate_format(struct audio_softc *sc, int mode,
 	const audio_format2_t *fmt)



CVS commit: src/share/man/man4

2020-08-22 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sun Aug 23 03:23:53 UTC 2020

Modified Files:
src/share/man/man4: ddb.4

Log Message:
Document the MIPs "mips machine {cpu,nmi,watch,unwatch}" commands.
Add commented out stubs for the mfcr and mtcr commands.


To generate a diff of this commit:
cvs rdiff -u -r1.193 -r1.194 src/share/man/man4/ddb.4

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



CVS commit: src/share/man/man4

2020-08-22 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sun Aug 23 03:23:53 UTC 2020

Modified Files:
src/share/man/man4: ddb.4

Log Message:
Document the MIPs "mips machine {cpu,nmi,watch,unwatch}" commands.
Add commented out stubs for the mfcr and mtcr commands.


To generate a diff of this commit:
cvs rdiff -u -r1.193 -r1.194 src/share/man/man4/ddb.4

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

Modified files:

Index: src/share/man/man4/ddb.4
diff -u src/share/man/man4/ddb.4:1.193 src/share/man/man4/ddb.4:1.194
--- src/share/man/man4/ddb.4:1.193	Sun Aug 23 03:17:00 2020
+++ src/share/man/man4/ddb.4	Sun Aug 23 03:23:53 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ddb.4,v 1.193 2020/08/23 03:17:00 simonb Exp $
+.\"	$NetBSD: ddb.4,v 1.194 2020/08/23 03:23:53 simonb Exp $
 .\"
 .\" Copyright (c) 1997 - 2019 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -56,7 +56,7 @@
 .\" any improvements or extensions that they make and grant Carnegie Mellon
 .\" the rights to redistribute these changes.
 .\"
-.Dd July 13, 2020
+.Dd August 23, 2020
 .Dt DDB 4
 .Os
 .Sh NAME
@@ -208,7 +208,7 @@ is entered by using
 or by setting
 .Ar ddb.commandonenter
 with
-.Xr sysctl 8 .
+2Xr sysctl 8 .
 Multiple commands can be separated by a semi-colon.
 .Sh COMMAND SYNTAX
 The general command syntax is:
@@ -1091,18 +1091,48 @@ Otherwise, the given vector is shown.
 .Bl -tag -width "traptrace" -compact
 .It Ic cp0
 Dump CP0 (coprocessor 0) register values.
+.It Ic cpu
+Switch to another CPU.
 .It Ic kvtop
 Print the physical address for a given kernel virtual address.
+.\" .It Ic mfcr -- document this!
+.\" .It Ic mtcr -- document this!
+.It Ic nmi
+Send an NMI to a different CPU.
+This DDB command is currently only implemented for Cavium
+Octeon CPUs.
 .It Ic reset
 Reset the system.
 Not implemented for many CPUs and/or systems.
 .It Ic tlb
 Print out the Translation Lookaside Buffer (TLB).
-Only works in
-.Nx
-kernels compiled with
-.Dv DEBUG
-option.
+Use the
+.Cm /v
+modifier to show only valid TLB entries.
+.It Ic watch
+Set a hardware watchpoint on an address or a TLB ASID.
+Pass the address to be watched.
+If no address is specified, show a list of active watchpoints.
+The modifiers are
+.Cm /m
+i for trap on an instruction fetch,
+.Cm /r
+for trap on a read,
+.Cm /w
+for trap on a write,
+.Cm /m
+for a mask on the address to match,
+.Cm /a
+for trap on a TLB ASID match.
+The
+.Cm /m
+and
+.Cm /a
+modifiers require an extra argument for the mask and ASID respectively.
+.It Ic unwatch
+Clear a hardware watchpoint.
+If an address is specified, clear watchpoints that match that address.
+If no address is specified, clear all watchpoints.
 .El
 .Ss POWERPC 4xx
 .Bl -tag -width "traptrace" -compact



CVS commit: src/sys/arch/mips/mips

2020-08-22 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sun Aug 23 03:21:58 UTC 2020

Modified Files:
src/sys/arch/mips/mips: db_interface.c

Log Message:
Add /v to show only valid TLBs.
Align tlb display nicely if > 100 TLBs.
Sort commands in the command dispatch function.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/arch/mips/mips/db_interface.c

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

Modified files:

Index: src/sys/arch/mips/mips/db_interface.c
diff -u src/sys/arch/mips/mips/db_interface.c:1.90 src/sys/arch/mips/mips/db_interface.c:1.91
--- src/sys/arch/mips/mips/db_interface.c:1.90	Mon Aug 17 03:19:35 2020
+++ src/sys/arch/mips/mips/db_interface.c	Sun Aug 23 03:21:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_interface.c,v 1.90 2020/08/17 03:19:35 mrg Exp $	*/
+/*	$NetBSD: db_interface.c,v 1.91 2020/08/23 03:21:57 simonb Exp $	*/
 
 /*
  * Mach Operating System
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.90 2020/08/17 03:19:35 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.91 2020/08/23 03:21:57 simonb Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_multiprocessor.h"
@@ -229,6 +229,10 @@ db_tlbdump_cmd(db_expr_t addr, bool have
 	   const char *modif)
 {
 	struct tlbmask tlb;
+	bool valid_only = false;
+
+	if (modif[0] == 'v')
+		valid_only = true;
 
 #ifdef MIPS1
 	if (!MIPS_HAS_R4K_MMU) {
@@ -236,6 +240,8 @@ db_tlbdump_cmd(db_expr_t addr, bool have
 
 		for (i = 0; i < mips_options.mips_num_tlb_entries; i++) {
 			tlb_read_entry(i, );
+			if (valid_only && !(tlb.tlb_lo1 & MIPS1_PG_V))
+continue;	/* skip invalid TLBs */
 			db_printf("TLB%c%2d Hi 0x%08x Lo 0x%08x",
 (tlb.tlb_lo1 & MIPS1_PG_V) ? ' ' : '*',
 i, tlb.tlb_hi,
@@ -250,12 +256,18 @@ db_tlbdump_cmd(db_expr_t addr, bool have
 #ifdef MIPS3_PLUS
 	if (MIPS_HAS_R4K_MMU) {
 		int i;
+		const int tlb_count_width =
+		mips_options.mips_num_tlb_entries > 100 ? 3 : 2;
 
 		for (i = 0; i < mips_options.mips_num_tlb_entries; i++) {
 			tlb_read_entry(i, );
-			db_printf("TLB%c%2d Hi 0x%08"PRIxVADDR" ",
-			(tlb.tlb_lo0 | tlb.tlb_lo1) & MIPS3_PG_V ? ' ' : '*',
-i, tlb.tlb_hi);
+			if (valid_only &&
+			!((tlb.tlb_lo0 | tlb.tlb_lo1) & MIPS3_PG_V))
+continue;	/* skip invalid TLBs */
+
+			db_printf("TLB%c%*d Hi 0x%08"PRIxVADDR" ",
+			(tlb.tlb_lo0 | tlb.tlb_lo1) & MIPS3_PG_V ? ' ' : '*',
+			tlb_count_width, i, tlb.tlb_hi);
 			db_printf("Lo0=0x%09" PRIx64 " %c%c attr %x ",
 (uint64_t)mips_tlbpfn_to_paddr(tlb.tlb_lo0),
 (tlb.tlb_lo0 & MIPS3_PG_D) ? 'D' : ' ',
@@ -784,21 +796,10 @@ const struct db_command db_machine_comma
 	{ DDB_ADD_CMD("cp0",	db_cp0dump_cmd,	0,
 		"Dump CP0 registers.",
 		NULL, NULL) },
-#if (MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) > 0
-	{ DDB_ADD_CMD("watch",	db_watch_cmd,		CS_MORE,
-		"set cp0 watchpoint",
-		"address   ", NULL) },
-	{ DDB_ADD_CMD("unwatch",db_unwatch_cmd,		0,
-		"delete cp0 watchpoint",
-		"address", NULL) },
-#endif	/* (MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) > 0 */
 	{ DDB_ADD_CMD("kvtop",	db_kvtophys_cmd,	0,
 		"Print the physical address for a given kernel virtual address",
 		"address",
 		"   address:\tvirtual address to look up") },
-	{ DDB_ADD_CMD("tlb",	db_tlbdump_cmd,		0,
-		"Print out TLB entries. (only works with options DEBUG)",
-		NULL, NULL) },
 #ifdef MIPS64_XLS
 	{ DDB_ADD_CMD("mfcr", 	db_mfcr_cmd,		CS_NOREPEAT,
 		"Dump processor control register",
@@ -815,6 +816,17 @@ const struct db_command db_machine_comma
 	{ DDB_ADD_CMD("reset", 	db_mach_reset_cmd,	CS_NOREPEAT,
 		"Initiate hardware reset",
 		NULL, NULL) },
+	{ DDB_ADD_CMD("tlb",	db_tlbdump_cmd,		0,
+		"Print out TLB entries. (only works with options DEBUG)",
+		NULL, NULL) },
+#if (MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) > 0
+	{ DDB_ADD_CMD("watch",	db_watch_cmd,		CS_MORE,
+		"set cp0 watchpoint",
+		"address   ", NULL) },
+	{ DDB_ADD_CMD("unwatch",db_unwatch_cmd,		0,
+		"delete cp0 watchpoint",
+		"address", NULL) },
+#endif	/* (MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) > 0 */
 	{ DDB_ADD_CMD(NULL, NULL,   0,  NULL,NULL,NULL) }
 };
 #endif	/* !KGDB */



CVS commit: src/sys/arch/mips/mips

2020-08-22 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sun Aug 23 03:21:58 UTC 2020

Modified Files:
src/sys/arch/mips/mips: db_interface.c

Log Message:
Add /v to show only valid TLBs.
Align tlb display nicely if > 100 TLBs.
Sort commands in the command dispatch function.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/arch/mips/mips/db_interface.c

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



CVS commit: src/share/man/man4

2020-08-22 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sun Aug 23 03:17:00 UTC 2020

Modified Files:
src/share/man/man4: ddb.4

Log Message:
Use upper-case "CPU" consistently in all text except DDB command names.


To generate a diff of this commit:
cvs rdiff -u -r1.192 -r1.193 src/share/man/man4/ddb.4

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

Modified files:

Index: src/share/man/man4/ddb.4
diff -u src/share/man/man4/ddb.4:1.192 src/share/man/man4/ddb.4:1.193
--- src/share/man/man4/ddb.4:1.192	Mon Jul 13 08:58:48 2020
+++ src/share/man/man4/ddb.4	Sun Aug 23 03:17:00 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: ddb.4,v 1.192 2020/07/13 08:58:48 wiz Exp $
+.\"	$NetBSD: ddb.4,v 1.193 2020/08/23 03:17:00 simonb Exp $
 .\"
 .\" Copyright (c) 1997 - 2019 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -1009,9 +1009,9 @@ Some of these commands are:
 .Ss AARCH64
 .Bl -tag -width "traptrace" -compact
 .It Ic cpu
-Switch to another cpu.
+Switch to another CPU.
 .It Ic cpuinfo
-Print cpu information about the ``struct cpuinfo''.
+Print CPU information about the ``struct cpuinfo''.
 .It Ic frame
 Given a trap frame address, print out the trap frame.
 .It Ic lwp
@@ -1050,7 +1050,7 @@ for 64 bit.
 .Ss ALPHA
 .Bl -tag -width "traptrace" -compact
 .It Ic cpu
-Switch to another cpu.
+Switch to another CPU.
 .\" .It Ic halt
 .\" Call the PROM monitor to halt the CPU.
 .\" .It Ic reboot
@@ -1059,7 +1059,7 @@ Switch to another cpu.
 .Ss AMD64
 .Bl -tag -width "traptrace" -compact
 .It Ic cpu
-Switch to another cpu.
+Switch to another CPU.
 .El
 .Ss ARM32
 .Bl -tag -width "traptrace" -compact
@@ -1079,7 +1079,7 @@ modifier is used, an LWP address.
 .Ss I386
 .Bl -tag -width "traptrace" -compact
 .It Ic cpu
-Switch to another cpu.
+Switch to another CPU.
 .El
 .Ss IA64
 .Bl -tag -width "traptrace" -compact
@@ -1151,7 +1151,7 @@ option.
 .Ss SPARC
 .Bl -tag -width "traptrace" -compact
 .It Ic cpu
-Switch to another cpu.
+Switch to another CPU.
 .It Ic prom
 Enter the Sun PROM monitor.
 .It Ic proc
@@ -1170,7 +1170,7 @@ for this physical address.
 .It Ic ctx
 Print process context information.
 .It Ic cpu
-Switch to another cpu.
+Switch to another CPU.
 .It Ic dtlb
 Print data translation look-aside buffer context information.
 .It Ic dtsb
@@ -1274,7 +1274,7 @@ Page Table Entry (PTE).
 .Ss VAX
 .Bl -tag -width "traptrace" -compact
 .It Ic cpu
-Switch to another cpu.
+Switch to another CPU.
 .El
 .Sh VARIABLES
 .Nm



CVS commit: src/share/man/man4

2020-08-22 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sun Aug 23 03:17:00 UTC 2020

Modified Files:
src/share/man/man4: ddb.4

Log Message:
Use upper-case "CPU" consistently in all text except DDB command names.


To generate a diff of this commit:
cvs rdiff -u -r1.192 -r1.193 src/share/man/man4/ddb.4

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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 23:06:51 UTC 2020

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

Log Message:
make(1): migrate Lst_AtFront to Lst_PrependS

This makes Lst_AtFront unused, as well as LstInsertBefore.


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/usr.bin/make/dir.c
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/make/lst.c

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

Modified files:

Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.108 src/usr.bin/make/dir.c:1.109
--- src/usr.bin/make/dir.c:1.108	Sat Aug 22 22:57:53 2020
+++ src/usr.bin/make/dir.c	Sat Aug 22 23:06:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.108 2020/08/22 22:57:53 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.109 2020/08/22 23:06:51 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.108 2020/08/22 22:57:53 rillig Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.109 2020/08/22 23:06:51 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)dir.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: dir.c,v 1.108 2020/08/22 22:57:53 rillig Exp $");
+__RCSID("$NetBSD: dir.c,v 1.109 2020/08/22 23:06:51 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1564,8 +1564,11 @@ Dir_AddDir(Lst path, const char *name)
 	if (ln != NULL)
 	return Lst_DatumS(ln);
 	else {
+	/* XXX: It is wrong to increment the refCount if dotLast is not
+	 * used afterwards. */
 	dotLast->refCount += 1;
-	(void)Lst_AtFront(path, dotLast);
+	if (path != NULL)
+		Lst_PrependS(path, dotLast);
 	}
 }
 

Index: src/usr.bin/make/lst.c
diff -u src/usr.bin/make/lst.c:1.35 src/usr.bin/make/lst.c:1.36
--- src/usr.bin/make/lst.c:1.35	Sat Aug 22 22:57:53 2020
+++ src/usr.bin/make/lst.c	Sat Aug 22 23:06:51 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.35 2020/08/22 22:57:53 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.36 2020/08/22 23:06:51 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -37,11 +37,11 @@
 #include "make.h"
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: lst.c,v 1.35 2020/08/22 22:57:53 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.36 2020/08/22 23:06:51 rillig Exp $";
 #else
 #include 
 #ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.35 2020/08/22 22:57:53 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.36 2020/08/22 23:06:51 rillig Exp $");
 #endif /* not lint */
 #endif
 
@@ -179,46 +179,6 @@ Lst_Destroy(Lst list, FreeProc *freeProc
 
 /* Insert a new node with the given piece of data before the given node in the
  * given list. */
-static ReturnStatus
-LstInsertBefore(Lst list, LstNode node, void *datum)
-{
-LstNode newNode;
-
-/*
- * check validity of arguments
- */
-if (LstIsValid(list) && (LstIsEmpty(list) && node == NULL))
-	goto ok;
-
-if (!LstIsValid(list) || LstIsEmpty(list) || !LstNodeIsValid(node)) {
-	return FAILURE;
-}
-
-ok:
-newNode = LstNodeNew(datum);
-
-if (node == NULL) {
-	newNode->prev = newNode->next = NULL;
-	list->first = list->last = newNode;
-} else {
-	newNode->prev = node->prev;
-	newNode->next = node;
-
-	if (newNode->prev != NULL) {
-	newNode->prev->next = newNode;
-	}
-	node->prev = newNode;
-
-	if (node == list->first) {
-	list->first = newNode;
-	}
-}
-
-return SUCCESS;
-}
-
-/* Insert a new node with the given piece of data before the given node in the
- * given list. */
 void
 Lst_InsertBeforeS(Lst list, LstNode node, void *datum)
 {
@@ -243,14 +203,6 @@ Lst_InsertBeforeS(Lst list, LstNode node
 }
 }
 
-/* Add a piece of data at the front of the given list. */
-ReturnStatus
-Lst_AtFront(Lst list, void *datum)
-{
-LstNode front = Lst_First(list);
-return LstInsertBefore(list, front, datum);
-}
-
 /* Add a piece of data at the start of the given list. */
 void
 Lst_PrependS(Lst list, void *datum)



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 23:06:51 UTC 2020

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

Log Message:
make(1): migrate Lst_AtFront to Lst_PrependS

This makes Lst_AtFront unused, as well as LstInsertBefore.


To generate a diff of this commit:
cvs rdiff -u -r1.108 -r1.109 src/usr.bin/make/dir.c
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/make/lst.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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 22:57:53 UTC 2020

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

Log Message:
make(1): replace Lst_Duplicate with Lst_CopyS

Lst_Duplicate would have passed through any null pointer, which was not
needed for make.  It was the last function that used Lst_AtEnd, which in
turn was the last function that used LstInsertAfter.  As a result, these
two functions have been removed.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/usr.bin/make/dir.c
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/make/lst.c
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/make/lst.h
cvs rdiff -u -r1.120 -r1.121 src/usr.bin/make/make.c
cvs rdiff -u -r1.111 -r1.112 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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 22:57:53 UTC 2020

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

Log Message:
make(1): replace Lst_Duplicate with Lst_CopyS

Lst_Duplicate would have passed through any null pointer, which was not
needed for make.  It was the last function that used Lst_AtEnd, which in
turn was the last function that used LstInsertAfter.  As a result, these
two functions have been removed.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/usr.bin/make/dir.c
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/make/lst.c
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/make/lst.h
cvs rdiff -u -r1.120 -r1.121 src/usr.bin/make/make.c
cvs rdiff -u -r1.111 -r1.112 src/usr.bin/make/suff.c

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

Modified files:

Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.107 src/usr.bin/make/dir.c:1.108
--- src/usr.bin/make/dir.c:1.107	Sat Aug 22 19:57:43 2020
+++ src/usr.bin/make/dir.c	Sat Aug 22 22:57:53 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.107 2020/08/22 19:57:43 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.108 2020/08/22 22:57:53 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.107 2020/08/22 19:57:43 rillig Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.108 2020/08/22 22:57:53 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)dir.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: dir.c,v 1.107 2020/08/22 19:57:43 rillig Exp $");
+__RCSID("$NetBSD: dir.c,v 1.108 2020/08/22 22:57:53 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1613,15 +1613,11 @@ Dir_AddDir(Lst path, const char *name)
 /*-
  *---
  * Dir_CopyDir --
- *	Callback function for duplicating a search path via Lst_Duplicate.
+ *	Callback function for duplicating a search path via Lst_CopyS.
  *	Ups the reference count for the directory.
  *
  * Results:
  *	Returns the Path it was given.
- *
- * Side Effects:
- *	The refCount of the path is incremented.
- *
  *---
  */
 void *

Index: src/usr.bin/make/lst.c
diff -u src/usr.bin/make/lst.c:1.34 src/usr.bin/make/lst.c:1.35
--- src/usr.bin/make/lst.c:1.34	Sat Aug 22 22:41:42 2020
+++ src/usr.bin/make/lst.c	Sat Aug 22 22:57:53 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.34 2020/08/22 22:41:42 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.35 2020/08/22 22:57:53 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -37,11 +37,11 @@
 #include "make.h"
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: lst.c,v 1.34 2020/08/22 22:41:42 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.35 2020/08/22 22:57:53 rillig Exp $";
 #else
 #include 
 #ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.34 2020/08/22 22:41:42 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.35 2020/08/22 22:57:53 rillig Exp $");
 #endif /* not lint */
 #endif
 
@@ -71,8 +71,6 @@ struct List {
 LstNode prev;		/* Previous node, if open. Used by Lst_Remove */
 };
 
-static ReturnStatus Lst_AtEnd(Lst, void *);
-
 static Boolean
 LstIsValid(Lst list)
 {
@@ -121,31 +119,20 @@ Lst_Init(void)
 
 /* Duplicate an entire list, usually by copying the datum pointers.
  * If copyProc is given, that function is used to create the new datum from the
- * old datum, usually by creating a copy of it.
- * Return the new list, or NULL on failure. */
+ * old datum, usually by creating a copy of it. */
 Lst
-Lst_Duplicate(Lst list, DuplicateProc *copyProc)
+Lst_CopyS(Lst list, DuplicateProc *copyProc)
 {
 Lst newList;
 LstNode node;
 
-if (!LstIsValid(list)) {
-	return NULL;
-}
+assert(LstIsValid(list));
 
 newList = Lst_Init();
 
-node = list->first;
-while (node != NULL) {
-	if (copyProc != NULL) {
-	if (Lst_AtEnd(newList, copyProc(node->datum)) == FAILURE) {
-		return NULL;
-	}
-	} else if (Lst_AtEnd(newList, node->datum) == FAILURE) {
-	return NULL;
-	}
-
-	node = node->next;
+for (node = list->first; node != NULL; node = node->next) {
+	void *datum = copyProc != NULL ? copyProc(node->datum) : node->datum;
+	Lst_AppendS(newList, datum);
 }
 
 return newList;
@@ -256,44 +243,6 @@ Lst_InsertBeforeS(Lst list, LstNode node
 }
 }
 
-/* Insert a new node with the given piece of data after the given node in the
- * given list. */
-static ReturnStatus
-LstInsertAfter(Lst list, LstNode node, void *datum)
-{
-LstNode newNode;
-
-if (LstIsValid(list) && (node == NULL && LstIsEmpty(list))) {
-	goto ok;
-}
-
-if (!LstIsValid(list) || LstIsEmpty(list) || !LstNodeIsValid(node)) {
-	return FAILURE;
-}
-ok:
-
-newNode = LstNodeNew(datum);
-
-if (node == NULL) {
-	

CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 22:41:42 UTC 2020

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

Log Message:
make(1): make moving and copying lists simpler

Instead of the two-in-one Lst_Concat, having two separate functions is
easier to understand.  There is no need for a long API comment anymore
since the new functions have a single purpose that is accurately
described by their name.

The long comment inside Lst_Concat has been removed since it only
repeated the exact code, only in more words.

The comments in make.c about appending the cohorts had been wrong.  They
were not appended but prepended.  Once more, the function name expresses
everything that the comment said, making the comment redundant.  There
is no need to test whether the cohorts list is empty, doing nothing is
implied by the word All in Lst_PrependAllS.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/make/lst.c
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/make/lst.h
cvs rdiff -u -r1.119 -r1.120 src/usr.bin/make/make.c
cvs rdiff -u -r1.260 -r1.261 src/usr.bin/make/parse.c
cvs rdiff -u -r1.110 -r1.111 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/lst.c
diff -u src/usr.bin/make/lst.c:1.33 src/usr.bin/make/lst.c:1.34
--- src/usr.bin/make/lst.c:1.33	Sat Aug 22 22:00:50 2020
+++ src/usr.bin/make/lst.c	Sat Aug 22 22:41:42 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.33 2020/08/22 22:00:50 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.34 2020/08/22 22:41:42 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -37,11 +37,11 @@
 #include "make.h"
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: lst.c,v 1.33 2020/08/22 22:00:50 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.34 2020/08/22 22:41:42 rillig Exp $";
 #else
 #include 
 #ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.33 2020/08/22 22:00:50 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.34 2020/08/22 22:41:42 rillig Exp $");
 #endif /* not lint */
 #endif
 
@@ -597,87 +597,24 @@ Lst_ForEachFrom(Lst list, LstNode node,
 return result;
 }
 
-/* Concatenate two lists. New nodes are created to hold the data elements,
- * if specified, but the data themselves are not copied. If the data
- * should be duplicated to avoid confusion with another list, the Lst_Duplicate
- * function should be called first. If LST_CONCLINK is specified, the second
- * list is destroyed since its pointers have been corrupted and the list is no
- * longer usable.
- *
- * Input:
- *	list1		The list to which list2 is to be appended
- *	list2		The list to append to list1
- *	flags		LST_CONCNEW if the list nodes should be duplicated
- *			LST_CONCLINK if the list nodes should just be relinked
- */
-ReturnStatus
-Lst_Concat(Lst list1, Lst list2, int flags)
+/* Move all nodes from list2 to the end of list1.
+ * List2 is destroyed and freed. */
+void
+Lst_MoveAllS(Lst list1, Lst list2)
 {
-LstNode node;	/* original node */
-LstNode newNode;
-LstNode last;	/* the last element in the list.
-			 * Keeps bookkeeping until the end */
+assert(LstIsValid(list1));
+assert(LstIsValid(list2));
 
-if (!LstIsValid(list1) || !LstIsValid(list2)) {
-	return FAILURE;
-}
-
-if (flags == LST_CONCLINK) {
-	if (list2->first != NULL) {
-	/*
-	 * So long as the second list isn't empty, we just link the
-	 * first element of the second list to the last element of the
-	 * first list. If the first list isn't empty, we then link the
-	 * last element of the list to the first element of the second list
-	 * The last element of the second list, if it exists, then becomes
-	 * the last element of the first list.
-	 */
-	list2->first->prev = list1->last;
-	if (list1->last != NULL) {
-		list1->last->next = list2->first;
-	} else {
-		list1->first = list2->first;
-	}
-	list1->last = list2->last;
-	}
-	free(list2);
-} else if (list2->first != NULL) {
-	/*
-	 * We set the 'next' of the last element of list 2 to be nil to make
-	 * the loop less difficult. The loop simply goes through the entire
-	 * second list creating new LstNodes and filling in the 'next', and
-	 * 'prev' to fit into list1 and its datum field from the
-	 * datum field of the corresponding element in list2. The 'last' node
-	 * follows the last of the new nodes along until the entire list2 has
-	 * been appended. Only then does the bookkeeping catch up with the
-	 * changes. During the first iteration of the loop, if 'last' is nil,
-	 * the first list must have been empty so the newly-created node is
-	 * made the first node of the list.
-	 */
-	list2->last->next = NULL;
-	for (last = list1->last, node = list2->first;
-	 node != NULL;
-	 node = node->next)
-	{
-	newNode = LstNodeNew(node->datum);
-	if (last != NULL) {
-		last->next = newNode;
-	   

CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 22:41:42 UTC 2020

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

Log Message:
make(1): make moving and copying lists simpler

Instead of the two-in-one Lst_Concat, having two separate functions is
easier to understand.  There is no need for a long API comment anymore
since the new functions have a single purpose that is accurately
described by their name.

The long comment inside Lst_Concat has been removed since it only
repeated the exact code, only in more words.

The comments in make.c about appending the cohorts had been wrong.  They
were not appended but prepended.  Once more, the function name expresses
everything that the comment said, making the comment redundant.  There
is no need to test whether the cohorts list is empty, doing nothing is
implied by the word All in Lst_PrependAllS.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/make/lst.c
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/make/lst.h
cvs rdiff -u -r1.119 -r1.120 src/usr.bin/make/make.c
cvs rdiff -u -r1.260 -r1.261 src/usr.bin/make/parse.c
cvs rdiff -u -r1.110 -r1.111 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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 22:00:50 UTC 2020

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

Log Message:
make(1): make Lst_Prev stricter regarding null pointers


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/make/lst.c
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/make/lst.h
cvs rdiff -u -r1.109 -r1.110 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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 22:00:50 UTC 2020

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

Log Message:
make(1): make Lst_Prev stricter regarding null pointers


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/make/lst.c
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/make/lst.h
cvs rdiff -u -r1.109 -r1.110 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/lst.c
diff -u src/usr.bin/make/lst.c:1.32 src/usr.bin/make/lst.c:1.33
--- src/usr.bin/make/lst.c:1.32	Sat Aug 22 21:42:38 2020
+++ src/usr.bin/make/lst.c	Sat Aug 22 22:00:50 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.32 2020/08/22 21:42:38 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.33 2020/08/22 22:00:50 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -37,11 +37,11 @@
 #include "make.h"
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: lst.c,v 1.32 2020/08/22 21:42:38 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.33 2020/08/22 22:00:50 rillig Exp $";
 #else
 #include 
 #ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.32 2020/08/22 21:42:38 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.33 2020/08/22 22:00:50 rillig Exp $");
 #endif /* not lint */
 #endif
 
@@ -456,13 +456,10 @@ Lst_Succ(LstNode node)
 
 /* Return the predecessor to the given node on its list, or NULL. */
 LstNode
-Lst_Prev(LstNode node)
+Lst_PrevS(LstNode node)
 {
-if (node == NULL) {
-	return NULL;
-} else {
-	return node->prev;
-}
+assert(LstNodeIsValid(node));
+return node->prev;
 }
 
 /* Return the datum stored in the given node. */

Index: src/usr.bin/make/lst.h
diff -u src/usr.bin/make/lst.h:1.35 src/usr.bin/make/lst.h:1.36
--- src/usr.bin/make/lst.h:1.35	Sat Aug 22 15:43:32 2020
+++ src/usr.bin/make/lst.h	Sat Aug 22 22:00:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lst.h,v 1.35 2020/08/22 15:43:32 rillig Exp $	*/
+/*	$NetBSD: lst.h,v 1.36 2020/08/22 22:00:50 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -139,7 +139,7 @@ LstNode		Lst_Last(Lst);
 /* Return successor to given element */
 LstNode		Lst_Succ(LstNode);
 /* Return predecessor to given element */
-LstNode		Lst_Prev(LstNode);
+LstNode		Lst_PrevS(LstNode);
 /* Get datum from LstNode */
 void		*Lst_DatumS(LstNode);
 

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.109 src/usr.bin/make/suff.c:1.110
--- src/usr.bin/make/suff.c:1.109	Sat Aug 22 21:42:38 2020
+++ src/usr.bin/make/suff.c	Sat Aug 22 22:00:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.109 2020/08/22 21:42:38 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.110 2020/08/22 22:00:50 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: suff.c,v 1.109 2020/08/22 21:42:38 rillig Exp $";
+static char rcsid[] = "$NetBSD: suff.c,v 1.110 2020/08/22 22:00:50 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)suff.c	8.4 (Berkeley) 3/21/94";
 #else
-__RCSID("$NetBSD: suff.c,v 1.109 2020/08/22 21:42:38 rillig Exp $");
+__RCSID("$NetBSD: suff.c,v 1.110 2020/08/22 22:00:50 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1649,7 +1649,7 @@ SuffExpandChildren(LstNode cln, GNode *p
 	Lst_AppendS(gn->parents, pgn);
 	pgn->unmade++;
 	/* Expand wildcards on new node */
-	SuffExpandWildcards(Lst_Prev(cln), pgn);
+	SuffExpandWildcards(Lst_PrevS(cln), pgn);
 	}
 	Lst_Destroy(members, NULL);
 



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 21:58:27 UTC 2020

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

Log Message:
make(1): use Lst_OpenS in Arch_MemMTime

The field GNode.parents is guaranteed to be a valid list.


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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 21:58:27 UTC 2020

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

Log Message:
make(1): use Lst_OpenS in Arch_MemMTime

The field GNode.parents is guaranteed to be a valid list.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/usr.bin/make/arch.c

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

Modified files:

Index: src/usr.bin/make/arch.c
diff -u src/usr.bin/make/arch.c:1.90 src/usr.bin/make/arch.c:1.91
--- src/usr.bin/make/arch.c:1.90	Sat Aug 22 15:46:28 2020
+++ src/usr.bin/make/arch.c	Sat Aug 22 21:58:27 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.90 2020/08/22 15:46:28 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.91 2020/08/22 21:58:27 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.90 2020/08/22 15:46:28 rillig Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.91 2020/08/22 21:58:27 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)arch.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: arch.c,v 1.90 2020/08/22 15:46:28 rillig Exp $");
+__RCSID("$NetBSD: arch.c,v 1.91 2020/08/22 21:58:27 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1123,10 +1123,7 @@ Arch_MemMTime(GNode *gn)
 char	  *nameStart,
 		  *nameEnd;
 
-if (Lst_Open(gn->parents) != SUCCESS) {
-	gn->mtime = 0;
-	return 0;
-}
+Lst_OpenS(gn->parents);
 while ((ln = Lst_NextS(gn->parents)) != NULL) {
 	pgn = Lst_DatumS(ln);
 



CVS commit: src

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 21:55:54 UTC 2020

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

Log Message:
make(1): add test for expanding wildcards in directories

This test covers DirExpandInt.


To generate a diff of this commit:
cvs rdiff -u -r1.900 -r1.901 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.113 -r1.114 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/dir-expand-path.exp \
src/usr.bin/make/unit-tests/dir-expand-path.mk

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



CVS commit: src

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 21:55:54 UTC 2020

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

Log Message:
make(1): add test for expanding wildcards in directories

This test covers DirExpandInt.


To generate a diff of this commit:
cvs rdiff -u -r1.900 -r1.901 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.113 -r1.114 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/dir-expand-path.exp \
src/usr.bin/make/unit-tests/dir-expand-path.mk

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.900 src/distrib/sets/lists/tests/mi:1.901
--- src/distrib/sets/lists/tests/mi:1.900	Sat Aug 22 20:23:14 2020
+++ src/distrib/sets/lists/tests/mi	Sat Aug 22 21:55:54 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.900 2020/08/22 20:23:14 rillig Exp $
+# $NetBSD: mi,v 1.901 2020/08/22 21:55:54 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4685,6 +4685,8 @@
 ./usr/tests/usr.bin/make/unit-tests/deptgt-suffixes.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/deptgt.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/deptgt.mk	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/dir-expand-path.exp	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/dir-expand-path.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/dir.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/dir.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/directive-elif.exp	tests-usr.bin-tests	compattestfile,atf

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.113 src/usr.bin/make/unit-tests/Makefile:1.114
--- src/usr.bin/make/unit-tests/Makefile:1.113	Sat Aug 22 21:30:52 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sat Aug 22 21:55:54 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.113 2020/08/22 21:30:52 sjg Exp $
+# $NetBSD: Makefile,v 1.114 2020/08/22 21:55:54 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -111,6 +111,7 @@ TESTS+=		deptgt-silent
 TESTS+=		deptgt-stale
 TESTS+=		deptgt-suffixes
 TESTS+=		dir
+TESTS+=		dir-expand-path
 TESTS+=		directive
 TESTS+=		directive-elif
 TESTS+=		directive-elifdef

Added files:

Index: src/usr.bin/make/unit-tests/dir-expand-path.exp
diff -u /dev/null src/usr.bin/make/unit-tests/dir-expand-path.exp:1.1
--- /dev/null	Sat Aug 22 21:55:54 2020
+++ src/usr.bin/make/unit-tests/dir-expand-path.exp	Sat Aug 22 21:55:54 2020
@@ -0,0 +1,4 @@
+dir-expand-path.dir.1/file1.src
+dir-expand-path.dir.1/file2.src
+dir-expand-path.dir.2/file3.src
+exit status 0
Index: src/usr.bin/make/unit-tests/dir-expand-path.mk
diff -u /dev/null src/usr.bin/make/unit-tests/dir-expand-path.mk:1.1
--- /dev/null	Sat Aug 22 21:55:54 2020
+++ src/usr.bin/make/unit-tests/dir-expand-path.mk	Sat Aug 22 21:55:54 2020
@@ -0,0 +1,19 @@
+# $NetBSD: dir-expand-path.mk,v 1.1 2020/08/22 21:55:54 rillig Exp $
+#
+# Tests for filename expansion in the search path.
+
+_!=	rm -rf dir-expand-path.dir.*
+_!=	mkdir dir-expand-path.dir.1
+_!=	mkdir dir-expand-path.dir.2
+_!=	touch dir-expand-path.dir.1/file1.src
+_!=	touch dir-expand-path.dir.1/file2.src
+_!=	touch dir-expand-path.dir.2/file3.src
+
+.PATH: dir-expand-path.dir.1
+.PATH: dir-expand-path.dir.2
+
+all: *.src
+	@printf '%s\n' ${.ALLSRC:O}
+
+.END:
+	@rm -rf dir-expand-path.dir.*



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 21:42:38 UTC 2020

Modified Files:
src/usr.bin/make: compat.c cond.c dir.h for.c job.c lst.c make.h
parse.c suff.c var.c

Log Message:
make(1): clean up headers

Remove redundant headers that are already included by "make.h".
Make  available to all compilation units that use "make.h".


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/usr.bin/make/compat.c
cvs rdiff -u -r1.98 -r1.99 src/usr.bin/make/cond.c
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/dir.h
cvs rdiff -u -r1.63 -r1.64 src/usr.bin/make/for.c
cvs rdiff -u -r1.213 -r1.214 src/usr.bin/make/job.c
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/make/lst.c
cvs rdiff -u -r1.122 -r1.123 src/usr.bin/make/make.h
cvs rdiff -u -r1.259 -r1.260 src/usr.bin/make/parse.c
cvs rdiff -u -r1.108 -r1.109 src/usr.bin/make/suff.c
cvs rdiff -u -r1.458 -r1.459 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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 21:42:38 UTC 2020

Modified Files:
src/usr.bin/make: compat.c cond.c dir.h for.c job.c lst.c make.h
parse.c suff.c var.c

Log Message:
make(1): clean up headers

Remove redundant headers that are already included by "make.h".
Make  available to all compilation units that use "make.h".


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/usr.bin/make/compat.c
cvs rdiff -u -r1.98 -r1.99 src/usr.bin/make/cond.c
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/dir.h
cvs rdiff -u -r1.63 -r1.64 src/usr.bin/make/for.c
cvs rdiff -u -r1.213 -r1.214 src/usr.bin/make/job.c
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/make/lst.c
cvs rdiff -u -r1.122 -r1.123 src/usr.bin/make/make.h
cvs rdiff -u -r1.259 -r1.260 src/usr.bin/make/parse.c
cvs rdiff -u -r1.108 -r1.109 src/usr.bin/make/suff.c
cvs rdiff -u -r1.458 -r1.459 src/usr.bin/make/var.c

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

Modified files:

Index: src/usr.bin/make/compat.c
diff -u src/usr.bin/make/compat.c:1.125 src/usr.bin/make/compat.c:1.126
--- src/usr.bin/make/compat.c:1.125	Sat Aug 22 19:53:22 2020
+++ src/usr.bin/make/compat.c	Sat Aug 22 21:42:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.125 2020/08/22 19:53:22 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.126 2020/08/22 21:42:38 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: compat.c,v 1.125 2020/08/22 19:53:22 rillig Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.126 2020/08/22 21:42:38 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)compat.c	8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: compat.c,v 1.125 2020/08/22 19:53:22 rillig Exp $");
+__RCSID("$NetBSD: compat.c,v 1.126 2020/08/22 21:42:38 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -99,7 +99,6 @@ __RCSID("$NetBSD: compat.c,v 1.125 2020/
 #include
 #include
 
-#include
 #include
 #include
 #include

Index: src/usr.bin/make/cond.c
diff -u src/usr.bin/make/cond.c:1.98 src/usr.bin/make/cond.c:1.99
--- src/usr.bin/make/cond.c:1.98	Thu Aug 20 18:47:57 2020
+++ src/usr.bin/make/cond.c	Sat Aug 22 21:42:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.98 2020/08/20 18:47:57 rillig Exp $	*/
+/*	$NetBSD: cond.c,v 1.99 2020/08/22 21:42:38 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: cond.c,v 1.98 2020/08/20 18:47:57 rillig Exp $";
+static char rcsid[] = "$NetBSD: cond.c,v 1.99 2020/08/22 21:42:38 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)cond.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: cond.c,v 1.98 2020/08/20 18:47:57 rillig Exp $");
+__RCSID("$NetBSD: cond.c,v 1.99 2020/08/22 21:42:38 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -91,14 +91,10 @@ __RCSID("$NetBSD: cond.c,v 1.98 2020/08/
  *
  */
 
-#include
-#include
-#include
-
-#include"make.h"
-#include"hash.h"
-#include"dir.h"
-#include"buf.h"
+#include 
+
+#include "make.h"
+#include "dir.h"
 
 /*
  * The parsing of conditional expressions is based on this grammar:

Index: src/usr.bin/make/dir.h
diff -u src/usr.bin/make/dir.h:1.19 src/usr.bin/make/dir.h:1.20
--- src/usr.bin/make/dir.h:1.19	Sat Aug 22 00:48:02 2020
+++ src/usr.bin/make/dir.h	Sat Aug 22 21:42:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.h,v 1.19 2020/08/22 00:48:02 rillig Exp $	*/
+/*	$NetBSD: dir.h,v 1.20 2020/08/22 21:42:38 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -72,9 +72,6 @@
  *	from: @(#)dir.h	8.1 (Berkeley) 6/6/93
  */
 
-/* dir.h --
- */
-
 #ifndef	MAKE_DIR_H
 #define	MAKE_DIR_H
 

Index: src/usr.bin/make/for.c
diff -u src/usr.bin/make/for.c:1.63 src/usr.bin/make/for.c:1.64
--- src/usr.bin/make/for.c:1.63	Sun Aug  9 19:51:02 2020
+++ src/usr.bin/make/for.c	Sat Aug 22 21:42:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: for.c,v 1.63 2020/08/09 19:51:02 rillig Exp $	*/
+/*	$NetBSD: for.c,v 1.64 2020/08/22 21:42:38 rillig Exp $	*/
 
 /*
  * Copyright (c) 1992, The Regents of the University of California.
@@ -30,14 +30,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: for.c,v 1.63 2020/08/09 19:51:02 rillig Exp $";
+static char rcsid[] = "$NetBSD: for.c,v 1.64 2020/08/22 21:42:38 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)for.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: for.c,v 1.63 2020/08/09 19:51:02 rillig Exp $");
+__RCSID("$NetBSD: for.c,v 1.64 2020/08/22 21:42:38 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -52,13 +52,7 @@ __RCSID("$NetBSD: for.c,v 1.63 2020/08/0
  *
  */
 
-#include
-#include

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

2020-08-22 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sat Aug 22 21:30:52 UTC 2020

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

Log Message:
bash says 'command not found'


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

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



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

2020-08-22 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sat Aug 22 21:30:52 UTC 2020

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

Log Message:
bash says 'command not found'


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

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

Modified files:

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.112 src/usr.bin/make/unit-tests/Makefile:1.113
--- src/usr.bin/make/unit-tests/Makefile:1.112	Sat Aug 22 21:22:24 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sat Aug 22 21:30:52 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.112 2020/08/22 21:22:24 rillig Exp $
+# $NetBSD: Makefile,v 1.113 2020/08/22 21:30:52 sjg Exp $
 #
 # Unit tests for make(1)
 #
@@ -326,7 +326,7 @@ FLAGS.varmod-match-escape= -dv
 FLAGS.varname-empty=	-dv '$${:U}=cmdline-u' '=cmline-plain'
 
 # Some tests need extra post-processing.
-SED_CMDS.sh-dots+=	-e 's,^${.SHELL}: ,,'
+SED_CMDS.sh-dots+=	-e 's,^${.SHELL}: ,,' -e '/not found/s,command ,,'
 SED_CMDS.varmod-subst-regex+= \
 			-e 's,\(Regex compilation error:\).*,\1 (details omitted),'
 SED_CMDS.varmod-edge+=	-e 's, line [0-9]*:, line omitted:,'



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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 21:22:24 UTC 2020

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

Log Message:
make(1): try to set the variable named "" using the command line

Before 2020-08-22, the command line argument '=cmline-plain' triggered
undefined behavior, just like the assignment '=assigned' in the Makefile.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varname-empty.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varname-empty.mk

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



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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 21:22:24 UTC 2020

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

Log Message:
make(1): try to set the variable named "" using the command line

Before 2020-08-22, the command line argument '=cmline-plain' triggered
undefined behavior, just like the assignment '=assigned' in the Makefile.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varname-empty.exp
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varname-empty.mk

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

Modified files:

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.111 src/usr.bin/make/unit-tests/Makefile:1.112
--- src/usr.bin/make/unit-tests/Makefile:1.111	Sat Aug 22 20:50:43 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sat Aug 22 21:22:24 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.111 2020/08/22 20:50:43 sjg Exp $
+# $NetBSD: Makefile,v 1.112 2020/08/22 21:22:24 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -323,6 +323,7 @@ FLAGS.order=		-j1
 FLAGS.recursive=	-dL
 FLAGS.vardebug=		-k -dv FROM_CMDLINE=
 FLAGS.varmod-match-escape= -dv
+FLAGS.varname-empty=	-dv '$${:U}=cmdline-u' '=cmline-plain'
 
 # Some tests need extra post-processing.
 SED_CMDS.sh-dots+=	-e 's,^${.SHELL}: ,,'
@@ -336,6 +337,7 @@ SED_CMDS.varshell+=	-e '/command/s,No su
 POSTPROC.counter=	${TOOL_SED} -n -e '/:RELEVANT = yes/,/:RELEVANT = no/p'
 POSTPROC.vardebug=	${TOOL_SED} -n -e '/:RELEVANT = yes/,/:RELEVANT = no/p'
 POSTPROC.varmod-match-escape= ${TOOL_SED} -n -e '/^Pattern/p'
+POSTPROC.varname-empty=	${TOOL_SED} -n -e '/^Var_Set/p' -e '/^out:/p'
 
 # Some tests reuse other tests, which makes them unnecessarily fragile.
 export-all.rawout: export.mk

Index: src/usr.bin/make/unit-tests/varname-empty.exp
diff -u src/usr.bin/make/unit-tests/varname-empty.exp:1.2 src/usr.bin/make/unit-tests/varname-empty.exp:1.3
--- src/usr.bin/make/unit-tests/varname-empty.exp:1.2	Sat Aug 22 20:31:50 2020
+++ src/usr.bin/make/unit-tests/varname-empty.exp	Sat Aug 22 21:22:24 2020
@@ -1,3 +1,11 @@
-fallback
-1 2 3
+Var_Set("${:U}", "cmdline-u", ...) name expands to empty string - ignored
+Var_Set("", "cmline-plain", ...) name expands to empty string - ignored
+Var_Set("", "default", ...) name expands to empty string - ignored
+Var_Set("", "assigned", ...) name expands to empty string - ignored
+Var_Set("", "appended", ...) name expands to empty string - ignored
+Var_Set("", "", ...) name expands to empty string - ignored
+Var_Set("", "subst", ...) name expands to empty string - ignored
+Var_Set("", "shell-output", ...) name expands to empty string - ignored
+out: fallback
+out: 1 2 3
 exit status 0

Index: src/usr.bin/make/unit-tests/varname-empty.mk
diff -u src/usr.bin/make/unit-tests/varname-empty.mk:1.4 src/usr.bin/make/unit-tests/varname-empty.mk:1.5
--- src/usr.bin/make/unit-tests/varname-empty.mk:1.4	Sat Aug 22 21:12:29 2020
+++ src/usr.bin/make/unit-tests/varname-empty.mk	Sat Aug 22 21:22:24 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varname-empty.mk,v 1.4 2020/08/22 21:12:29 rillig Exp $
+# $NetBSD: varname-empty.mk,v 1.5 2020/08/22 21:22:24 rillig Exp $
 #
 # Tests for the special variable with the empty name.
 #
@@ -12,7 +12,7 @@
 =	assigned	# undefined behavior until 2020-08-22
 +=	appended
 :=	subst
-!=	echo 'value'
+!=	echo 'shell-output'
 
 # The .for loop expands the expression ${i} to ${:U1}, ${:U2} and so on.
 # This only works if the variable with the empty name is guaranteed to
@@ -22,5 +22,5 @@ NUMBERS+=	${i}
 .endfor
 
 all:
-	@echo ${:Ufallback}
-	@echo ${NUMBERS}
+	@echo out: ${:Ufallback}
+	@echo out: ${NUMBERS}



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 21:12:29 UTC 2020

Modified Files:
src/usr.bin/make: parse.c
src/usr.bin/make/unit-tests: varname-empty.mk

Log Message:
make(1): fix undefined behavior when assigning to variable ""

Using a programming language with built-in array bounds checks would
have prevented this bug, and many others as well.


To generate a diff of this commit:
cvs rdiff -u -r1.258 -r1.259 src/usr.bin/make/parse.c
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varname-empty.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.258 src/usr.bin/make/parse.c:1.259
--- src/usr.bin/make/parse.c:1.258	Sat Aug 22 17:34:25 2020
+++ src/usr.bin/make/parse.c	Sat Aug 22 21:12:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.258 2020/08/22 17:34:25 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.259 2020/08/22 21:12:29 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.258 2020/08/22 17:34:25 rillig Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.259 2020/08/22 21:12:29 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)parse.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: parse.c,v 1.258 2020/08/22 17:34:25 rillig Exp $");
+__RCSID("$NetBSD: parse.c,v 1.259 2020/08/22 21:12:29 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1876,7 +1876,7 @@ Parse_DoVar(char *line, GNode *ctxt)
  * XXX Rather than counting () and {} we should look for $ and
  * then expand the variable.
  */
-for (depth = 0, cp = line + 1; depth > 0 || *cp != '='; cp++) {
+for (depth = 0, cp = line; depth > 0 || *cp != '='; cp++) {
 	if (*cp == '(' || *cp == '{') {
 	depth++;
 	continue;

Index: src/usr.bin/make/unit-tests/varname-empty.mk
diff -u src/usr.bin/make/unit-tests/varname-empty.mk:1.3 src/usr.bin/make/unit-tests/varname-empty.mk:1.4
--- src/usr.bin/make/unit-tests/varname-empty.mk:1.3	Sat Aug 22 21:02:56 2020
+++ src/usr.bin/make/unit-tests/varname-empty.mk	Sat Aug 22 21:12:29 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varname-empty.mk,v 1.3 2020/08/22 21:02:56 rillig Exp $
+# $NetBSD: varname-empty.mk,v 1.4 2020/08/22 21:12:29 rillig Exp $
 #
 # Tests for the special variable with the empty name.
 #
@@ -9,7 +9,7 @@
 # Until 2020-08-22 it was possible to assign a value to the variable with
 # the empty name, leading to all kinds of unexpected effects.
 ?=	default
-#=	assigned	# XXX: probably undefined behavior
+=	assigned	# undefined behavior until 2020-08-22
 +=	appended
 :=	subst
 !=	echo 'value'



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 21:12:29 UTC 2020

Modified Files:
src/usr.bin/make: parse.c
src/usr.bin/make/unit-tests: varname-empty.mk

Log Message:
make(1): fix undefined behavior when assigning to variable ""

Using a programming language with built-in array bounds checks would
have prevented this bug, and many others as well.


To generate a diff of this commit:
cvs rdiff -u -r1.258 -r1.259 src/usr.bin/make/parse.c
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varname-empty.mk

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



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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 21:02:56 UTC 2020

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

Log Message:
make(1): try a bit harder to set the variable with the empty name

There is not only the != assignment operator, but a few others as well.
Especially the += operator is interesting since it has a different code
path.  But all is good.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varname-empty.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/varname-empty.mk
diff -u src/usr.bin/make/unit-tests/varname-empty.mk:1.2 src/usr.bin/make/unit-tests/varname-empty.mk:1.3
--- src/usr.bin/make/unit-tests/varname-empty.mk:1.2	Sat Aug 22 20:31:50 2020
+++ src/usr.bin/make/unit-tests/varname-empty.mk	Sat Aug 22 21:02:56 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varname-empty.mk,v 1.2 2020/08/22 20:31:50 rillig Exp $
+# $NetBSD: varname-empty.mk,v 1.3 2020/08/22 21:02:56 rillig Exp $
 #
 # Tests for the special variable with the empty name.
 #
@@ -8,6 +8,10 @@
 
 # Until 2020-08-22 it was possible to assign a value to the variable with
 # the empty name, leading to all kinds of unexpected effects.
+?=	default
+#=	assigned	# XXX: probably undefined behavior
++=	appended
+:=	subst
 !=	echo 'value'
 
 # The .for loop expands the expression ${i} to ${:U1}, ${:U2} and so on.



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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 21:02:56 UTC 2020

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

Log Message:
make(1): try a bit harder to set the variable with the empty name

There is not only the != assignment operator, but a few others as well.
Especially the += operator is interesting since it has a different code
path.  But all is good.


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

2020-08-22 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sat Aug 22 20:50:44 UTC 2020

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

Log Message:
Use TEST_MAKE to run unit-tests

This lets us take advantage of new features like ${.SHELL}


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/usr.bin/make/Makefile
cvs rdiff -u -r1.110 -r1.111 src/usr.bin/make/unit-tests/Makefile

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

Modified files:

Index: src/usr.bin/make/Makefile
diff -u src/usr.bin/make/Makefile:1.90 src/usr.bin/make/Makefile:1.91
--- src/usr.bin/make/Makefile:1.90	Wed Aug 19 06:30:37 2020
+++ src/usr.bin/make/Makefile	Sat Aug 22 20:50:43 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.90 2020/08/19 06:30:37 rillig Exp $
+#	$NetBSD: Makefile,v 1.91 2020/08/22 20:50:43 sjg Exp $
 #	@(#)Makefile	5.2 (Berkeley) 12/28/90
 
 PROG=	make
@@ -165,9 +165,10 @@ COPTS.parse.c+=	${GCC_NO_FORMAT_TRUNCATI
 COPTS+=		-Wdeclaration-after-statement
 
 # A simple unit-test driver to help catch regressions
+TEST_MAKE ?= ${.OBJDIR}/${PROG:T}
 test: .MAKE
 	cd ${.CURDIR}/unit-tests \
-	&& MAKEFLAGS= ${.MAKE} -r -m / TEST_MAKE=${TEST_MAKE:U${.OBJDIR}/${PROG:T}} ${.TARGET}
+	&& MAKEFLAGS= ${TEST_MAKE} -r -m / TEST_MAKE=${TEST_MAKE} ${.TARGET}
 .if ${USE_COVERAGE} == yes
 	${GCOV} ${GCOV_OPTS} ${SRCS}
 	sed -i 's,^\([^:]*\): *[0-9]*:,\1: ,' *.gcov

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.110 src/usr.bin/make/unit-tests/Makefile:1.111
--- src/usr.bin/make/unit-tests/Makefile:1.110	Sat Aug 22 20:23:14 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sat Aug 22 20:50:43 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.110 2020/08/22 20:23:14 rillig Exp $
+# $NetBSD: Makefile,v 1.111 2020/08/22 20:50:43 sjg Exp $
 #
 # Unit tests for make(1)
 #
@@ -325,11 +325,11 @@ FLAGS.vardebug=		-k -dv FROM_CMDLINE=
 FLAGS.varmod-match-escape= -dv
 
 # Some tests need extra post-processing.
-SED_CMDS.sh-dots+=	-e '/not found/s,^.*sh: ,,'
+SED_CMDS.sh-dots+=	-e 's,^${.SHELL}: ,,'
 SED_CMDS.varmod-subst-regex+= \
 			-e 's,\(Regex compilation error:\).*,\1 (details omitted),'
 SED_CMDS.varmod-edge+=	-e 's, line [0-9]*:, line omitted:,'
-SED_CMDS.varshell+=	-e 's,^[a-z]*sh: ,,'
+SED_CMDS.varshell+=	-e 's,^${.SHELL:T}: ,,'
 SED_CMDS.varshell+=	-e '/command/s,No such.*,not found,'
 
 # Some tests need an additional round of postprocessing.



CVS commit: src/usr.bin/make

2020-08-22 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sat Aug 22 20:50:44 UTC 2020

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

Log Message:
Use TEST_MAKE to run unit-tests

This lets us take advantage of new features like ${.SHELL}


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/usr.bin/make/Makefile
cvs rdiff -u -r1.110 -r1.111 src/usr.bin/make/unit-tests/Makefile

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



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 20:31:50 UTC 2020

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

Log Message:
make(1): prevent assignment to the variable with the empty name


To generate a diff of this commit:
cvs rdiff -u -r1.457 -r1.458 src/usr.bin/make/var.c
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varname-empty.exp \
src/usr.bin/make/unit-tests/varname-empty.mk

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.457 src/usr.bin/make/var.c:1.458
--- src/usr.bin/make/var.c:1.457	Sat Aug 22 19:30:58 2020
+++ src/usr.bin/make/var.c	Sat Aug 22 20:31:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.457 2020/08/22 19:30:58 sjg Exp $	*/
+/*	$NetBSD: var.c,v 1.458 2020/08/22 20:31:50 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.457 2020/08/22 19:30:58 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.458 2020/08/22 20:31:50 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.457 2020/08/22 19:30:58 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.458 2020/08/22 20:31:50 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -778,6 +778,7 @@ void
 Var_Set_with_flags(const char *name, const char *val, GNode *ctxt,
 		   VarSet_Flags flags)
 {
+const char *unexpanded_name = name;
 char *name_freeIt = NULL;
 Var *v;
 
@@ -786,16 +787,15 @@ Var_Set_with_flags(const char *name, con
  * here will override anything in a lower context, so there's not much
  * point in searching them all just to save a bit of memory...
  */
-if (strchr(name, '$') != NULL) {
-	const char *unexpanded_name = name;
+if (strchr(name, '$') != NULL)
 	name = name_freeIt = Var_Subst(name, ctxt, VARE_WANTRES);
-	if (name[0] == '\0') {
-	VAR_DEBUG("Var_Set(\"%s\", \"%s\", ...) "
-		  "name expands to empty string - ignored\n",
-		  unexpanded_name, val);
-	free(name_freeIt);
-	return;
-	}
+
+if (name[0] == '\0') {
+	VAR_DEBUG("Var_Set(\"%s\", \"%s\", ...) "
+		  "name expands to empty string - ignored\n",
+		  unexpanded_name, val);
+	free(name_freeIt);
+	return;
 }
 
 if (ctxt == VAR_GLOBAL) {

Index: src/usr.bin/make/unit-tests/varname-empty.exp
diff -u src/usr.bin/make/unit-tests/varname-empty.exp:1.1 src/usr.bin/make/unit-tests/varname-empty.exp:1.2
--- src/usr.bin/make/unit-tests/varname-empty.exp:1.1	Sat Aug 22 20:23:14 2020
+++ src/usr.bin/make/unit-tests/varname-empty.exp	Sat Aug 22 20:31:50 2020
@@ -1,3 +1,3 @@
-value
-value value value
+fallback
+1 2 3
 exit status 0
Index: src/usr.bin/make/unit-tests/varname-empty.mk
diff -u src/usr.bin/make/unit-tests/varname-empty.mk:1.1 src/usr.bin/make/unit-tests/varname-empty.mk:1.2
--- src/usr.bin/make/unit-tests/varname-empty.mk:1.1	Sat Aug 22 20:23:14 2020
+++ src/usr.bin/make/unit-tests/varname-empty.mk	Sat Aug 22 20:31:50 2020
@@ -1,4 +1,4 @@
-# $NetBSD: varname-empty.mk,v 1.1 2020/08/22 20:23:14 rillig Exp $
+# $NetBSD: varname-empty.mk,v 1.2 2020/08/22 20:31:50 rillig Exp $
 #
 # Tests for the special variable with the empty name.
 #
@@ -6,7 +6,8 @@
 # This is because it is heavily used in the .for loop expansion,
 # as well as to generate arbitrary strings, as in ${:Ufallback}.
 
-# Oops.
+# Until 2020-08-22 it was possible to assign a value to the variable with
+# the empty name, leading to all kinds of unexpected effects.
 !=	echo 'value'
 
 # The .for loop expands the expression ${i} to ${:U1}, ${:U2} and so on.



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 20:31:50 UTC 2020

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

Log Message:
make(1): prevent assignment to the variable with the empty name


To generate a diff of this commit:
cvs rdiff -u -r1.457 -r1.458 src/usr.bin/make/var.c
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varname-empty.exp \
src/usr.bin/make/unit-tests/varname-empty.mk

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



CVS commit: src

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 20:23:14 UTC 2020

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

Log Message:
make(1): add test for assigning to the variable named ""

This has been possible at least since 2013, probably much longer.


To generate a diff of this commit:
cvs rdiff -u -r1.899 -r1.900 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.109 -r1.110 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/varname-empty.exp \
src/usr.bin/make/unit-tests/varname-empty.mk

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



CVS commit: src

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 20:23:14 UTC 2020

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

Log Message:
make(1): add test for assigning to the variable named ""

This has been possible at least since 2013, probably much longer.


To generate a diff of this commit:
cvs rdiff -u -r1.899 -r1.900 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.109 -r1.110 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/varname-empty.exp \
src/usr.bin/make/unit-tests/varname-empty.mk

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.899 src/distrib/sets/lists/tests/mi:1.900
--- src/distrib/sets/lists/tests/mi:1.899	Sat Aug 22 16:51:25 2020
+++ src/distrib/sets/lists/tests/mi	Sat Aug 22 20:23:14 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.899 2020/08/22 16:51:25 rillig Exp $
+# $NetBSD: mi,v 1.900 2020/08/22 20:23:14 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5051,6 +5051,8 @@
 ./usr/tests/usr.bin/make/unit-tests/varname-dot-path.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varname-dot-targets.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varname-dot-targets.mk	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/varname-empty.exp	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/varname-empty.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varname-make.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varname-make.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/varname-make_print_var_on_error.exp	tests-usr.bin-tests	compattestfile,atf

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.109 src/usr.bin/make/unit-tests/Makefile:1.110
--- src/usr.bin/make/unit-tests/Makefile:1.109	Sat Aug 22 16:51:26 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sat Aug 22 20:23:14 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.109 2020/08/22 16:51:26 rillig Exp $
+# $NetBSD: Makefile,v 1.110 2020/08/22 20:23:14 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -293,6 +293,7 @@ TESTS+=		varname-dot-parsedir
 TESTS+=		varname-dot-parsefile
 TESTS+=		varname-dot-path
 TESTS+=		varname-dot-targets
+TESTS+=		varname-empty
 TESTS+=		varname-make
 TESTS+=		varname-make_print_var_on_error
 TESTS+=		varname-makeflags

Added files:

Index: src/usr.bin/make/unit-tests/varname-empty.exp
diff -u /dev/null src/usr.bin/make/unit-tests/varname-empty.exp:1.1
--- /dev/null	Sat Aug 22 20:23:14 2020
+++ src/usr.bin/make/unit-tests/varname-empty.exp	Sat Aug 22 20:23:14 2020
@@ -0,0 +1,3 @@
+value
+value value value
+exit status 0
Index: src/usr.bin/make/unit-tests/varname-empty.mk
diff -u /dev/null src/usr.bin/make/unit-tests/varname-empty.mk:1.1
--- /dev/null	Sat Aug 22 20:23:14 2020
+++ src/usr.bin/make/unit-tests/varname-empty.mk	Sat Aug 22 20:23:14 2020
@@ -0,0 +1,21 @@
+# $NetBSD: varname-empty.mk,v 1.1 2020/08/22 20:23:14 rillig Exp $
+#
+# Tests for the special variable with the empty name.
+#
+# The variable "" is not supposed to be assigned any value.
+# This is because it is heavily used in the .for loop expansion,
+# as well as to generate arbitrary strings, as in ${:Ufallback}.
+
+# Oops.
+!=	echo 'value'
+
+# The .for loop expands the expression ${i} to ${:U1}, ${:U2} and so on.
+# This only works if the variable with the empty name is guaranteed to
+# be undefined.
+.for i in 1 2 3
+NUMBERS+=	${i}
+.endfor
+
+all:
+	@echo ${:Ufallback}
+	@echo ${NUMBERS}



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 20:03:41 UTC 2020

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

Log Message:
make(1): use Lst_OpenS in make.c

The fields GNode.children, parents and iParents are guaranteed to be
valid lists.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/usr.bin/make/make.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.c
diff -u src/usr.bin/make/make.c:1.118 src/usr.bin/make/make.c:1.119
--- src/usr.bin/make/make.c:1.118	Sat Aug 22 15:43:32 2020
+++ src/usr.bin/make/make.c	Sat Aug 22 20:03:41 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.118 2020/08/22 15:43:32 rillig Exp $	*/
+/*	$NetBSD: make.c,v 1.119 2020/08/22 20:03:41 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: make.c,v 1.118 2020/08/22 15:43:32 rillig Exp $";
+static char rcsid[] = "$NetBSD: make.c,v 1.119 2020/08/22 20:03:41 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)make.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: make.c,v 1.118 2020/08/22 15:43:32 rillig Exp $");
+__RCSID("$NetBSD: make.c,v 1.119 2020/08/22 20:03:41 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -447,35 +447,34 @@ Make_HandleUse(GNode *cgn, GNode *pgn)
 	}
 }
 
-if (Lst_Open(cgn->children) == SUCCESS) {
-	while ((ln = Lst_NextS(cgn->children)) != NULL) {
-	GNode *tgn, *gn = Lst_DatumS(ln);
+Lst_OpenS(cgn->children);
+while ((ln = Lst_NextS(cgn->children)) != NULL) {
+	GNode *gn = Lst_DatumS(ln);
 
-	/*
-	 * Expand variables in the .USE node's name
-	 * and save the unexpanded form.
-	 * We don't need to do this for commands.
-	 * They get expanded properly when we execute.
-	 */
-	if (gn->uname == NULL) {
-		gn->uname = gn->name;
-	} else {
-		free(gn->name);
-	}
-	gn->name = Var_Subst(gn->uname, pgn, VARE_WANTRES);
-	if (gn->name && gn->uname && strcmp(gn->name, gn->uname) != 0) {
-		/* See if we have a target for this node. */
-		tgn = Targ_FindNode(gn->name, TARG_NOCREATE);
-		if (tgn != NULL)
-		gn = tgn;
-	}
-
-	Lst_AppendS(pgn->children, gn);
-	Lst_AppendS(gn->parents, pgn);
-	pgn->unmade += 1;
+	/*
+	 * Expand variables in the .USE node's name
+	 * and save the unexpanded form.
+	 * We don't need to do this for commands.
+	 * They get expanded properly when we execute.
+	 */
+	if (gn->uname == NULL) {
+	gn->uname = gn->name;
+	} else {
+	free(gn->name);
+	}
+	gn->name = Var_Subst(gn->uname, pgn, VARE_WANTRES);
+	if (gn->name && gn->uname && strcmp(gn->name, gn->uname) != 0) {
+	/* See if we have a target for this node. */
+	GNode *tgn = Targ_FindNode(gn->name, TARG_NOCREATE);
+	if (tgn != NULL)
+		gn = tgn;
 	}
-	Lst_CloseS(cgn->children);
+
+	Lst_AppendS(pgn->children, gn);
+	Lst_AppendS(gn->parents, pgn);
+	pgn->unmade += 1;
 }
+Lst_CloseS(cgn->children);
 
 pgn->type |= cgn->type & ~(OP_OPMASK|OP_USE|OP_USEBEFORE|OP_TRANSFORM);
 }
@@ -702,108 +701,108 @@ Make_Update(GNode *cgn)
 Lst_ForEach(centurion->order_succ, MakeBuildParent, Lst_First(toBeMade));
 
 /* Now mark all the parents as having one less unmade child */
-if (Lst_Open(parents) == SUCCESS) {
-	while ((ln = Lst_NextS(parents)) != NULL) {
-	pgn = Lst_DatumS(ln);
-	if (DEBUG(MAKE))
-		fprintf(debug_file, "inspect parent %s%s: flags %x, "
-			"type %x, made %d, unmade %d ",
-			pgn->name, pgn->cohort_num, pgn->flags,
-			pgn->type, pgn->made, pgn->unmade-1);
-
-	if (!(pgn->flags & REMAKE)) {
-		/* This parent isn't needed */
-		if (DEBUG(MAKE))
-		fprintf(debug_file, "- not needed\n");
-		continue;
-	}
-	if (mtime == 0 && !(cgn->type & OP_WAIT))
-		pgn->flags |= FORCE;
+Lst_OpenS(parents);
+while ((ln = Lst_NextS(parents)) != NULL) {
+	pgn = Lst_DatumS(ln);
+	if (DEBUG(MAKE))
+	fprintf(debug_file, "inspect parent %s%s: flags %x, "
+			"type %x, made %d, unmade %d ",
+		pgn->name, pgn->cohort_num, pgn->flags,
+		pgn->type, pgn->made, pgn->unmade-1);
 
-	/*
-	 * If the parent has the .MADE attribute, its timestamp got
-	 * updated to that of its newest child, and its unmake
-	 * child count got set to zero in Make_ExpandUse().
-	 * However other things might cause us to build one of its
-	 * children - and so we mustn't do any processing here when
-	 * the child build finishes.
-	 */
-	if (pgn->type & OP_MADE) {
-		if (DEBUG(MAKE))
-		fprintf(debug_file, "- .MADE\n");
-		continue;
-	}
+	if (!(pgn->flags & REMAKE)) {
+	/* This parent isn't needed */
+	if (DEBUG(MAKE))
+		fprintf(debug_file, "- not needed\n");
+	continue;
+	}
+	if (mtime == 0 && !(cgn->type & OP_WAIT))
+	pgn->flags |= FORCE;
 
-	if ( ! (cgn->type & 

CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 20:03:41 UTC 2020

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

Log Message:
make(1): use Lst_OpenS in make.c

The fields GNode.children, parents and iParents are guaranteed to be
valid lists.


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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 19:57:43 UTC 2020

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

Log Message:
make(1): use Lst_OpenS in Dir_SetPATH

Since dirSearchPath is initialized in Dir_Init, opening the list can
never fail.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/usr.bin/make/dir.c

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



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 19:57:43 UTC 2020

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

Log Message:
make(1): use Lst_OpenS in Dir_SetPATH

Since dirSearchPath is initialized in Dir_Init, opening the list can
never fail.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/usr.bin/make/dir.c

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

Modified files:

Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.106 src/usr.bin/make/dir.c:1.107
--- src/usr.bin/make/dir.c:1.106	Sat Aug 22 17:34:25 2020
+++ src/usr.bin/make/dir.c	Sat Aug 22 19:57:43 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.106 2020/08/22 17:34:25 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.107 2020/08/22 19:57:43 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.106 2020/08/22 17:34:25 rillig Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.107 2020/08/22 19:57:43 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)dir.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: dir.c,v 1.106 2020/08/22 17:34:25 rillig Exp $");
+__RCSID("$NetBSD: dir.c,v 1.107 2020/08/22 19:57:43 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -478,43 +478,42 @@ Dir_SetPATH(void)
 {
 LstNode ln;			/* a list element */
 Path *p;
-Boolean hasLastDot = FALSE;	/* true we should search dot last */
+Boolean hasLastDot = FALSE;	/* true if we should search dot last */
 
 Var_Delete(".PATH", VAR_GLOBAL);
 
-if (Lst_Open(dirSearchPath) == SUCCESS) {
-	if ((ln = Lst_First(dirSearchPath)) != NULL) {
-	p = Lst_DatumS(ln);
-	if (p == dotLast) {
-		hasLastDot = TRUE;
-		Var_Append(".PATH", dotLast->name, VAR_GLOBAL);
-	}
+Lst_OpenS(dirSearchPath);
+if ((ln = Lst_First(dirSearchPath)) != NULL) {
+	p = Lst_DatumS(ln);
+	if (p == dotLast) {
+	hasLastDot = TRUE;
+	Var_Append(".PATH", dotLast->name, VAR_GLOBAL);
 	}
+}
 
-	if (!hasLastDot) {
-	if (dot)
-		Var_Append(".PATH", dot->name, VAR_GLOBAL);
-	if (cur)
-		Var_Append(".PATH", cur->name, VAR_GLOBAL);
-	}
+if (!hasLastDot) {
+	if (dot)
+	Var_Append(".PATH", dot->name, VAR_GLOBAL);
+	if (cur)
+	Var_Append(".PATH", cur->name, VAR_GLOBAL);
+}
 
-	while ((ln = Lst_NextS(dirSearchPath)) != NULL) {
-	p = Lst_DatumS(ln);
-	if (p == dotLast)
-		continue;
-	if (p == dot && hasLastDot)
-		continue;
-	Var_Append(".PATH", p->name, VAR_GLOBAL);
-	}
+while ((ln = Lst_NextS(dirSearchPath)) != NULL) {
+	p = Lst_DatumS(ln);
+	if (p == dotLast)
+	continue;
+	if (p == dot && hasLastDot)
+	continue;
+	Var_Append(".PATH", p->name, VAR_GLOBAL);
+}
 
-	if (hasLastDot) {
-	if (dot)
-		Var_Append(".PATH", dot->name, VAR_GLOBAL);
-	if (cur)
-		Var_Append(".PATH", cur->name, VAR_GLOBAL);
-	}
-	Lst_CloseS(dirSearchPath);
+if (hasLastDot) {
+	if (dot)
+	Var_Append(".PATH", dot->name, VAR_GLOBAL);
+	if (cur)
+	Var_Append(".PATH", cur->name, VAR_GLOBAL);
 }
+Lst_CloseS(dirSearchPath);
 }
 
 /*-



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 19:53:22 UTC 2020

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

Log Message:
make(1): replace segmentation fault with failed assertion

To reproduce: ./make -r -C unit-tests -f sh-dots.mk -j1

Without -j1, the test succeeds.


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 src/usr.bin/make/compat.c

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

Modified files:

Index: src/usr.bin/make/compat.c
diff -u src/usr.bin/make/compat.c:1.124 src/usr.bin/make/compat.c:1.125
--- src/usr.bin/make/compat.c:1.124	Sat Aug 22 15:43:32 2020
+++ src/usr.bin/make/compat.c	Sat Aug 22 19:53:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.124 2020/08/22 15:43:32 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.125 2020/08/22 19:53:22 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: compat.c,v 1.124 2020/08/22 15:43:32 rillig Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.125 2020/08/22 19:53:22 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)compat.c	8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: compat.c,v 1.124 2020/08/22 15:43:32 rillig Exp $");
+__RCSID("$NetBSD: compat.c,v 1.125 2020/08/22 19:53:22 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -99,6 +99,7 @@ __RCSID("$NetBSD: compat.c,v 1.124 2020/
 #include
 #include
 
+#include
 #include
 #include
 #include
@@ -250,6 +251,7 @@ CompatRunCommand(void *cmdp, void *gnp)
 Lst_ReplaceS(cmdNode, cmdStart);
 
 if ((gn->type & OP_SAVE_CMDS) && (gn != ENDNode)) {
+assert(ENDNode != NULL);
 	Lst_AppendS(ENDNode->commands, cmdStart);
 	return 0;
 }



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 19:53:22 UTC 2020

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

Log Message:
make(1): replace segmentation fault with failed assertion

To reproduce: ./make -r -C unit-tests -f sh-dots.mk -j1

Without -j1, the test succeeds.


To generate a diff of this commit:
cvs rdiff -u -r1.124 -r1.125 src/usr.bin/make/compat.c

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



CVS commit: src/usr.bin/make

2020-08-22 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sat Aug 22 19:30:59 UTC 2020

Modified Files:
src/usr.bin/make: job.c make.1 nonints.h var.c
src/usr.bin/make/unit-tests: export.exp

Log Message:
Add .SHELL as read-only variable

The .SHELL variable represents the shellPath used to run
scripts.

Reviewed by: rillig, christos


To generate a diff of this commit:
cvs rdiff -u -r1.212 -r1.213 src/usr.bin/make/job.c
cvs rdiff -u -r1.287 -r1.288 src/usr.bin/make/make.1
cvs rdiff -u -r1.95 -r1.96 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.456 -r1.457 src/usr.bin/make/var.c
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/export.exp

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

Modified files:

Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.212 src/usr.bin/make/job.c:1.213
--- src/usr.bin/make/job.c:1.212	Sat Aug 22 15:43:32 2020
+++ src/usr.bin/make/job.c	Sat Aug 22 19:30:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.212 2020/08/22 15:43:32 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.213 2020/08/22 19:30:58 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.212 2020/08/22 15:43:32 rillig Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.213 2020/08/22 19:30:58 sjg Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)job.c	8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: job.c,v 1.212 2020/08/22 15:43:32 rillig Exp $");
+__RCSID("$NetBSD: job.c,v 1.213 2020/08/22 19:30:58 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2201,6 +2201,7 @@ Shell_Init(void)
 #endif
 	shellPath = str_concat3(_PATH_DEFSHELLDIR, "/", shellName);
 }
+Var_Set_with_flags(".SHELL", shellPath, VAR_CMD, VAR_SET_READONLY);
 if (commandShell->exit == NULL) {
 	commandShell->exit = "";
 }

Index: src/usr.bin/make/make.1
diff -u src/usr.bin/make/make.1:1.287 src/usr.bin/make/make.1:1.288
--- src/usr.bin/make/make.1:1.287	Wed Aug 19 06:10:06 2020
+++ src/usr.bin/make/make.1	Sat Aug 22 19:30:58 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: make.1,v 1.287 2020/08/19 06:10:06 rillig Exp $
+.\"	$NetBSD: make.1,v 1.288 2020/08/22 19:30:58 sjg Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	from: @(#)make.1	8.4 (Berkeley) 3/19/94
 .\"
-.Dd August 19, 2020
+.Dd August 22, 2020
 .Dt MAKE 1
 .Os
 .Sh NAME
@@ -1140,6 +1140,9 @@ is set to the value of
 for all programs which
 .Nm
 executes.
+.It Ev .SHELL
+The pathname of the shell used to run target scripts.
+It is read-only.
 .It Ev .TARGETS
 The list of targets explicitly specified on the command line, if any.
 .It Ev VPATH

Index: src/usr.bin/make/nonints.h
diff -u src/usr.bin/make/nonints.h:1.95 src/usr.bin/make/nonints.h:1.96
--- src/usr.bin/make/nonints.h:1.95	Fri Aug 21 23:28:11 2020
+++ src/usr.bin/make/nonints.h	Sat Aug 22 19:30:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nonints.h,v 1.95 2020/08/21 23:28:11 rillig Exp $	*/
+/*	$NetBSD: nonints.h,v 1.96 2020/08/22 19:30:58 sjg Exp $	*/
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -186,8 +186,15 @@ typedef enum {
 VARE_ASSIGN		= 0x04
 } VarEvalFlags;
 
+typedef enum {
+VAR_NO_EXPORT	= 0x01,	/* do not export */
+VAR_SET_READONLY	= 0x02
+} VarSet_Flags;
+
+
 void Var_Delete(const char *, GNode *);
 void Var_Set(const char *, const char *, GNode *);
+void Var_Set_with_flags(const char *, const char *, GNode *, VarSet_Flags);
 void Var_Append(const char *, const char *, GNode *);
 Boolean Var_Exists(const char *, GNode *);
 const char *Var_Value(const char *, GNode *, char **);

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.456 src/usr.bin/make/var.c:1.457
--- src/usr.bin/make/var.c:1.456	Sat Aug 22 17:34:25 2020
+++ src/usr.bin/make/var.c	Sat Aug 22 19:30:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.456 2020/08/22 17:34:25 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.457 2020/08/22 19:30:58 sjg Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.456 2020/08/22 17:34:25 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.457 2020/08/22 19:30:58 sjg Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.456 2020/08/22 17:34:25 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.457 2020/08/22 19:30:58 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -229,7 +229,8 @@ typedef enum {
  * variable can then be resolved. */
 VAR_REEXPORT = 0x20,
 /* The variable came from command line. */
-VAR_FROM_CMD = 0x40
+VAR_FROM_CMD = 0x40,
+VAR_READONLY = 0x80
 } VarFlags;
 
 ENUM_RTTI_7(VarFlags,
@@ -281,10 +282,6 @@ typedef enum {
 VARP_ANCHOR_END	= 0x08	/* 

CVS commit: src/usr.bin/make

2020-08-22 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sat Aug 22 19:30:59 UTC 2020

Modified Files:
src/usr.bin/make: job.c make.1 nonints.h var.c
src/usr.bin/make/unit-tests: export.exp

Log Message:
Add .SHELL as read-only variable

The .SHELL variable represents the shellPath used to run
scripts.

Reviewed by: rillig, christos


To generate a diff of this commit:
cvs rdiff -u -r1.212 -r1.213 src/usr.bin/make/job.c
cvs rdiff -u -r1.287 -r1.288 src/usr.bin/make/make.1
cvs rdiff -u -r1.95 -r1.96 src/usr.bin/make/nonints.h
cvs rdiff -u -r1.456 -r1.457 src/usr.bin/make/var.c
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/export.exp

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



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 19:27:22 UTC 2020

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

Log Message:
make(1): remove wrong comment about possible Y2038 problem

The "time" that is mentioned is not clock time but a sequence number.


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/usr.bin/make/make.h

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

Modified files:

Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.121 src/usr.bin/make/make.h:1.122
--- src/usr.bin/make/make.h:1.121	Sat Aug 22 18:47:31 2020
+++ src/usr.bin/make/make.h	Sat Aug 22 19:27:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.121 2020/08/22 18:47:31 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.122 2020/08/22 19:27:22 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -298,8 +298,8 @@ typedef struct GNode {
  * list */
 struct GNode *centurion;
 
-/* Last time we tried to make this node */
-unsigned int checked;	/* XXX: year 2038 */
+/* Last time (sequence number) we tried to make this node */
+unsigned int checked;
 
 /* The "local" variables that are specific to this target and this target
  * only, such as $@, $<, $?. */



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 19:27:22 UTC 2020

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

Log Message:
make(1): remove wrong comment about possible Y2038 problem

The "time" that is mentioned is not clock time but a sequence number.


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/usr.bin/make/make.h

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



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 18:47:31 UTC 2020

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

Log Message:
make(1): remove unused variable jobServer


To generate a diff of this commit:
cvs rdiff -u -r1.309 -r1.310 src/usr.bin/make/main.c
cvs rdiff -u -r1.120 -r1.121 src/usr.bin/make/make.h

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

Modified files:

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.309 src/usr.bin/make/main.c:1.310
--- src/usr.bin/make/main.c:1.309	Sat Aug 22 17:34:25 2020
+++ src/usr.bin/make/main.c	Sat Aug 22 18:47:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.309 2020/08/22 17:34:25 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.310 2020/08/22 18:47:31 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.309 2020/08/22 17:34:25 rillig Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.310 2020/08/22 18:47:31 rillig Exp $";
 #else
 #include 
 #ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.309 2020/08/22 17:34:25 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.310 2020/08/22 18:47:31 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -176,7 +176,6 @@ Boolean			beSilent;	/* -s flag */
 Boolean			oldVars;	/* variable substitution style */
 Boolean			checkEnvFirst;	/* -e flag */
 Boolean			parseWarnFatal;	/* -W flag */
-Boolean			jobServer; 	/* -J flag */
 static int jp_0 = -1, jp_1 = -1;	/* ends of parent job pipe */
 Boolean			varNoExportEnv;	/* -X flag */
 Boolean			doing_depend;	/* Set while reading .depend */
@@ -521,7 +520,6 @@ rearg:
 			} else {
 			Var_Append(MAKEFLAGS, "-J", VAR_GLOBAL);
 			Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
-			jobServer = TRUE;
 			}
 			break;
 		case 'N':

Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.120 src/usr.bin/make/make.h:1.121
--- src/usr.bin/make/make.h:1.120	Sat Aug 22 18:44:22 2020
+++ src/usr.bin/make/make.h	Sat Aug 22 18:47:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.120 2020/08/22 18:44:22 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.121 2020/08/22 18:47:31 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -403,7 +403,6 @@ extern Boolean	doing_depend;	/* TRUE if 
 
 extern Boolean	checkEnvFirst;	/* TRUE if environment should be searched for
  * variables before the global context */
-extern Boolean	jobServer;	/* a jobServer already exists */
 
 extern Boolean	parseWarnFatal;	/* TRUE if makefile parsing warnings are
  * treated as errors */



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 18:47:31 UTC 2020

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

Log Message:
make(1): remove unused variable jobServer


To generate a diff of this commit:
cvs rdiff -u -r1.309 -r1.310 src/usr.bin/make/main.c
cvs rdiff -u -r1.120 -r1.121 src/usr.bin/make/make.h

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



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 18:44:22 UTC 2020

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

Log Message:
make(1): convert GNode type constants to enum

This allows debuggers to print symbolic names for the type flags.

The names of these constants need to be revised.  These flags probably
started as the 3 dependency operators (:, !, ::), and at that time, the
prefix OP_ made sense.  The other flags are not related to the type of
the dependency operator and could have been placed in GNode.flags as
well.


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/usr.bin/make/make.h
cvs rdiff -u -r1.107 -r1.108 src/usr.bin/make/suff.c

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

Modified files:

Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.119 src/usr.bin/make/make.h:1.120
--- src/usr.bin/make/make.h:1.119	Sat Aug 22 18:20:31 2020
+++ src/usr.bin/make/make.h	Sat Aug 22 18:44:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.119 2020/08/22 18:20:31 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.120 2020/08/22 18:44:22 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -148,6 +148,89 @@ typedef enum  {
  * making an inferior (compat). */
 } GNodeMade;
 
+/* The OP_ constants are used when parsing a dependency line as a way of
+ * communicating to other parts of the program the way in which a target
+ * should be made.
+ *
+ * These constants are bitwise-OR'ed together and placed in the 'type' field
+ * of each node. Any node that has a 'type' field which satisfies the OP_NOP
+ * function was never never on the left-hand side of an operator, though it
+ * may have been on the right-hand side... */
+typedef enum {
+/* Execution of commands depends on children (:) */
+OP_DEPENDS		= 1 << 0,
+/* Always execute commands (!) */
+OP_FORCE		= 1 << 1,
+/* Execution of commands depends on children per line (::) */
+OP_DOUBLEDEP	= 1 << 2,
+
+OP_OPMASK		= OP_DEPENDS|OP_FORCE|OP_DOUBLEDEP,
+
+/* Don't care if the target doesn't exist and can't be created */
+OP_OPTIONAL		= 1 << 3,
+/* Use associated commands for parents */
+OP_USE		= 1 << 4,
+/* Target is never out of date, but always execute commands anyway.
+ * Its time doesn't matter, so it has none...sort of */
+OP_EXEC	  	= 1 << 5,
+/* Ignore errors when creating the node */
+OP_IGNORE		= 1 << 6,
+/* Don't remove the target when interrupted */
+OP_PRECIOUS		= 1 << 7,
+/* Don't echo commands when executed */
+OP_SILENT		= 1 << 8,
+/* Target is a recursive make so its commands should always be executed
+ * when it is out of date, regardless of the state of the -n or -t flags */
+OP_MAKE		= 1 << 9,
+/* Target is out-of-date only if any of its children was out-of-date */
+OP_JOIN		= 1 << 10,
+/* Assume the children of the node have been already made */
+OP_MADE		= 1 << 11,
+/* Special .BEGIN, .END, .INTERRUPT */
+OP_SPECIAL		= 1 << 12,
+/* Like .USE, only prepend commands */
+OP_USEBEFORE	= 1 << 13,
+/* The node is invisible to its parents. I.e. it doesn't show up in the
+ * parents' local variables. */
+OP_INVISIBLE	= 1 << 14,
+/* The node is exempt from normal 'main target' processing in parse.c */
+OP_NOTMAIN		= 1 << 15,
+/* Not a file target; run always */
+OP_PHONY		= 1 << 16,
+/* Don't search for file in the path */
+OP_NOPATH		= 1 << 17,
+/* .WAIT phony node */
+OP_WAIT		= 1 << 18,
+/* .NOMETA do not create a .meta file */
+OP_NOMETA		= 1 << 19,
+/* .META we _do_ want a .meta file */
+OP_META		= 1 << 20,
+/* Do not compare commands in .meta file */
+OP_NOMETA_CMP	= 1 << 21,
+/* Possibly a submake node */
+OP_SUBMAKE		= 1 << 22,
+
+/* Attributes applied by PMake */
+
+/* The node is a transformation rule */
+OP_TRANSFORM	= 1 << 31,
+/* Target is a member of an archive */
+OP_MEMBER		= 1 << 30,
+/* Target is a library */
+OP_LIB		= 1 << 29,
+/* Target is an archive construct */
+OP_ARCHV		= 1 << 28,
+/* Target has all the commands it should. Used when parsing to catch
+ * multiple commands for a target. */
+OP_HAS_COMMANDS	= 1 << 27,
+/* Saving commands on .END (Compat) */
+OP_SAVE_CMDS	= 1 << 26,
+/* Already processed by Suff_FindDeps */
+OP_DEPS_FOUND	= 1 << 25,
+/* Node found while expanding .ALLSRC */
+OP_MARK		= 1 << 24
+} GNodeType;
+
 typedef enum {
 REMAKE	= 0x0001,	/* this target needs to be (re)made */
 CHILDMADE	= 0x0002,	/* children of this target were made */
@@ -235,67 +318,6 @@ typedef struct GNode {
 int lineno;
 } GNode;
 
-/*
- * The OP_ constants are used when parsing a dependency line as a way of
- * communicating to other parts of the program the way in which a target
- * should be made. These constants are 

CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 18:44:22 UTC 2020

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

Log Message:
make(1): convert GNode type constants to enum

This allows debuggers to print symbolic names for the type flags.

The names of these constants need to be revised.  These flags probably
started as the 3 dependency operators (:, !, ::), and at that time, the
prefix OP_ made sense.  The other flags are not related to the type of
the dependency operator and could have been placed in GNode.flags as
well.


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/usr.bin/make/make.h
cvs rdiff -u -r1.107 -r1.108 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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 18:20:31 UTC 2020

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

Log Message:
make(1): restructure GNode types and documentation

Having a numbered list above the type was not helpful since the numbers
didn't serve any purpose, they just consumed screen space.

Several of these list items didn't have an obvious relationship to the
struct fields.  It's better to have just a rough introduction as the
type level documentation, leaving the details to the individual fields.

Converting the types and flags and other constants into separate types
and defining them outside the struct leaves more space to see the
relationship of the struct fields.

Limiting the documentation of each field to a single line, as suggested
by the end-of-line comments, reduces clarity since several of the fields
need way more documentation to be properly understood.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/usr.bin/make/make.h
cvs rdiff -u -r1.70 -r1.71 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.118 src/usr.bin/make/make.h:1.119
--- src/usr.bin/make/make.h:1.118	Thu Aug 20 17:13:05 2020
+++ src/usr.bin/make/make.h	Sat Aug 22 18:20:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.118 2020/08/20 17:13:05 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.119 2020/08/22 18:20:31 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -134,101 +134,105 @@
 #include "buf.h"
 #include "make_malloc.h"
 
-/*-
- * The structure for an individual graph node. Each node has several
- * pieces of data associated with it.
- *	1) the name of the target it describes
- *	2) the location of the target file in the file system.
- *	3) the type of operator used to define its sources (qv. parse.c)
- *	4) whether it is involved in this invocation of make
- *	5) whether the target has been remade
- *	6) whether any of its children has been remade
- *	7) the number of its children that are, as yet, unmade
- *	8) its modification time
- *	9) the modification time of its youngest child (qv. make.c)
- *	10) a list of nodes for which this is a source (parents)
- *	11) a list of nodes on which this depends (children)
- *	12) a list of nodes that depend on this, as gleaned from the
- *	transformation rules (iParents)
- *	13) a list of ancestor nodes, which includes parents, iParents,
- *	and recursive parents of parents
- *	14) a list of nodes of the same name created by the :: operator
- *	15) a list of nodes that must be made (if they're made) before
- *	this node can be, but that do not enter into the datedness of
- *	this node.
- *	16) a list of nodes that must be made (if they're made) before
- *	this node or any child of this node can be, but that do not
- *	enter into the datedness of this node.
- *	17) a list of nodes that must be made (if they're made) after
- *	this node is, but that do not depend on this node, in the
- *	normal sense.
- *	18) a Lst of ``local'' variables that are specific to this target
- *	   and this target only (qv. var.c [$@ $< $?, etc.])
- *	19) a Lst of strings that are commands to be given to a shell
- *	   to create this target.
- */
-typedef struct GNode {
-char*name; 	/* The target's name */
-char*uname;	/* The unexpanded name of a .USE node */
-char	*path; 	/* The full pathname of the file */
-int type;  	/* Its type (see the OP flags, below) */
-
-int flags;
-#define REMAKE		0x1	/* this target needs to be (re)made */
-#define	CHILDMADE	0x2	/* children of this target were made */
-#define FORCE		0x4	/* children don't exist, and we pretend made */
-#define DONE_WAIT	0x8	/* Set by Make_ProcessWait() */
-#define DONE_ORDER	0x10	/* Build requested by .ORDER processing */
-#define FROM_DEPEND	0x20	/* Node created from .depend */
-#define DONE_ALLSRC	0x40	/* We do it once only */
-#define CYCLE		0x1000  /* Used by MakePrintStatus */
-#define DONECYCLE	0x2000  /* Used by MakePrintStatus */
-#define INTERNAL	0x4000	/* Internal use only */
-enum enum_made {
-	UNMADE, DEFERRED, REQUESTED, BEINGMADE,
-	MADE, UPTODATE, ERROR, ABORTED
-}		made;	/* Set to reflect the state of processing
- * on this node:
- *  UNMADE - Not examined yet
- *  DEFERRED - Examined once (building child)
- *  REQUESTED - on toBeMade list
- *  BEINGMADE - Target is already being made.
- *  	Indicates a cycle in the graph.
- *  MADE - Was out-of-date and has been made
- *  UPTODATE - Was already up-to-date
- *  ERROR - An error occurred while it was being
- *  	made (used only in compat mode)
- *  ABORTED - The target was aborted due to
- *  	an error making an inferior (compat).
- */
-int 

CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 18:20:31 UTC 2020

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

Log Message:
make(1): restructure GNode types and documentation

Having a numbered list above the type was not helpful since the numbers
didn't serve any purpose, they just consumed screen space.

Several of these list items didn't have an obvious relationship to the
struct fields.  It's better to have just a rough introduction as the
type level documentation, leaving the details to the individual fields.

Converting the types and flags and other constants into separate types
and defining them outside the struct leaves more space to see the
relationship of the struct fields.

Limiting the documentation of each field to a single line, as suggested
by the end-of-line comments, reduces clarity since several of the fields
need way more documentation to be properly understood.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/usr.bin/make/make.h
cvs rdiff -u -r1.70 -r1.71 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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 17:34:25 UTC 2020

Modified Files:
src/usr.bin/make: dir.c lst.c main.c meta.c parse.c var.c

Log Message:
make(1): fix indentation


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/usr.bin/make/dir.c
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/make/lst.c
cvs rdiff -u -r1.308 -r1.309 src/usr.bin/make/main.c
cvs rdiff -u -r1.96 -r1.97 src/usr.bin/make/meta.c
cvs rdiff -u -r1.257 -r1.258 src/usr.bin/make/parse.c
cvs rdiff -u -r1.455 -r1.456 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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 17:34:25 UTC 2020

Modified Files:
src/usr.bin/make: dir.c lst.c main.c meta.c parse.c var.c

Log Message:
make(1): fix indentation


To generate a diff of this commit:
cvs rdiff -u -r1.105 -r1.106 src/usr.bin/make/dir.c
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/make/lst.c
cvs rdiff -u -r1.308 -r1.309 src/usr.bin/make/main.c
cvs rdiff -u -r1.96 -r1.97 src/usr.bin/make/meta.c
cvs rdiff -u -r1.257 -r1.258 src/usr.bin/make/parse.c
cvs rdiff -u -r1.455 -r1.456 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/dir.c
diff -u src/usr.bin/make/dir.c:1.105 src/usr.bin/make/dir.c:1.106
--- src/usr.bin/make/dir.c:1.105	Sat Aug 22 15:55:22 2020
+++ src/usr.bin/make/dir.c	Sat Aug 22 17:34:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.105 2020/08/22 15:55:22 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.106 2020/08/22 17:34:25 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.105 2020/08/22 15:55:22 rillig Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.106 2020/08/22 17:34:25 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)dir.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: dir.c,v 1.105 2020/08/22 15:55:22 rillig Exp $");
+__RCSID("$NetBSD: dir.c,v 1.106 2020/08/22 17:34:25 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -650,7 +650,7 @@ closing_brace(const char *p)
 {
 int nest = 0;
 while (*p != '\0') {
-if (*p == '}' && nest == 0)
+	if (*p == '}' && nest == 0)
 	break;
 	if (*p == '{')
 	nest++;
@@ -668,7 +668,7 @@ separator_comma(const char *p)
 {
 int nest = 0;
 while (*p != '\0') {
-if ((*p == '}' || *p == ',') && nest == 0)
+	if ((*p == '}' || *p == ',') && nest == 0)
 	break;
 	if (*p == '{')
 	nest++;

Index: src/usr.bin/make/lst.c
diff -u src/usr.bin/make/lst.c:1.30 src/usr.bin/make/lst.c:1.31
--- src/usr.bin/make/lst.c:1.30	Sat Aug 22 16:00:52 2020
+++ src/usr.bin/make/lst.c	Sat Aug 22 17:34:25 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.30 2020/08/22 16:00:52 skrll Exp $ */
+/* $NetBSD: lst.c,v 1.31 2020/08/22 17:34:25 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -38,11 +38,11 @@
 #include "make.h"
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: lst.c,v 1.30 2020/08/22 16:00:52 skrll Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.31 2020/08/22 17:34:25 rillig Exp $";
 #else
 #include 
 #ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.30 2020/08/22 16:00:52 skrll Exp $");
+__RCSID("$NetBSD: lst.c,v 1.31 2020/08/22 17:34:25 rillig Exp $");
 #endif /* not lint */
 #endif
 
@@ -690,7 +690,7 @@ Lst_PrependAllS(Lst dst, Lst src)
 {
 LstNode node;
 for (node = src->last; node != NULL; node = node->prev)
-Lst_PrependS(dst, node->datum);
+	Lst_PrependS(dst, node->datum);
 }
 
 /* Copy the element data from src to the end of dst. */
@@ -699,7 +699,7 @@ Lst_AppendAllS(Lst dst, Lst src)
 {
 LstNode node;
 for (node = src->first; node != NULL; node = node->next)
-Lst_AppendS(dst, node->datum);
+	Lst_AppendS(dst, node->datum);
 }
 
 /*

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.308 src/usr.bin/make/main.c:1.309
--- src/usr.bin/make/main.c:1.308	Sat Aug 22 15:17:09 2020
+++ src/usr.bin/make/main.c	Sat Aug 22 17:34:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.308 2020/08/22 15:17:09 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.309 2020/08/22 17:34:25 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.308 2020/08/22 15:17:09 rillig Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.309 2020/08/22 17:34:25 rillig Exp $";
 #else
 #include 
 #ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19
 #if 0
 static char sccsid[] = "@(#)main.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.308 2020/08/22 15:17:09 rillig Exp $");
+__RCSID("$NetBSD: main.c,v 1.309 2020/08/22 17:34:25 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1529,7 +1529,7 @@ ReadMakefile(const void *p, const void *
 fname = path;
 goto found;
 			}
-			free(path);
+			free(path);
 
 			/* If curdir failed, try objdir (ala .depend) */
 			path = str_concat3(objdir, "/", fname);

Index: src/usr.bin/make/meta.c
diff -u src/usr.bin/make/meta.c:1.96 src/usr.bin/make/meta.c:1.97
--- src/usr.bin/make/meta.c:1.96	Sat Aug 22 15:17:09 2020
+++ src/usr.bin/make/meta.c	Sat Aug 22 17:34:25 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: meta.c,v 1.96 2020/08/22 15:17:09 rillig Exp $ */
+/*  $NetBSD: meta.c,v 1.97 2020/08/22 17:34:25 rillig Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -1010,8 +1010,8 @@ 

CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 17:32:55 UTC 2020

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

Log Message:
make(1): fix documentation of Var_Parse


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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 17:32:55 UTC 2020

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

Log Message:
make(1): fix documentation of Var_Parse


To generate a diff of this commit:
cvs rdiff -u -r1.454 -r1.455 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.454 src/usr.bin/make/var.c:1.455
--- src/usr.bin/make/var.c:1.454	Thu Aug 20 07:15:52 2020
+++ src/usr.bin/make/var.c	Sat Aug 22 17:32:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.454 2020/08/20 07:15:52 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.455 2020/08/22 17:32:55 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.454 2020/08/20 07:15:52 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.455 2020/08/22 17:32:55 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.454 2020/08/20 07:15:52 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.455 2020/08/22 17:32:55 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3323,12 +3323,14 @@ VarIsDynamic(GNode *ctxt, const char *va
  *	freePtr		OUT: Non-NULL if caller should free *freePtr
  *
  * Results:
- *	The value of the variable expression or var_Error if the
- *	specification is invalid. The length of the specification is
- *	placed in *lengthPtr (for invalid specifications, this is just
- *	2...?).
- *	If *freePtr is non-NULL then it's a pointer that the caller
- *	should pass to free() to free memory used by the result.
+ *	Returns the value of the variable expression.
+ *	var_Error if there was a parse error and VARE_UNDEFERR was set.
+ *	varNoError if there was a parse error and VARE_UNDEFERR was not set.
+ *
+ *	Parsing should continue at str + *lengthPtr.
+ *
+ *	After using the returned value, *freePtr must be freed, preferably
+ *	using bmake_free since it is NULL in most cases.
  *
  * Side Effects:
  *	Any effects from the modifiers, such as :!cmd! or ::=value.
@@ -3686,12 +3688,6 @@ Var_Subst(const char *str, GNode *ctxt, 
 	void *freeIt;
 	const char *val = Var_Parse(str, ctxt, eflags, , );
 
-	/*
-	 * When we come down here, val should either point to the
-	 * value of this variable, suitably modified, or be NULL.
-	 * Length should be the total length of the potential
-	 * variable invocation (from $ to end character...)
-	 */
 	if (val == var_Error || val == varNoError) {
 		/*
 		 * If performing old-time variable substitution, skip over



CVS commit: src

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 16:51:26 UTC 2020

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

Log Message:
make(1): add test for deferred variable expansion in dependencies


To generate a diff of this commit:
cvs rdiff -u -r1.898 -r1.899 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.108 -r1.109 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/dep-var.exp \
src/usr.bin/make/unit-tests/dep-var.mk

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



CVS commit: src

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 16:51:26 UTC 2020

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

Log Message:
make(1): add test for deferred variable expansion in dependencies


To generate a diff of this commit:
cvs rdiff -u -r1.898 -r1.899 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.108 -r1.109 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/dep-var.exp \
src/usr.bin/make/unit-tests/dep-var.mk

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.898 src/distrib/sets/lists/tests/mi:1.899
--- src/distrib/sets/lists/tests/mi:1.898	Sat Aug 22 11:27:02 2020
+++ src/distrib/sets/lists/tests/mi	Sat Aug 22 16:51:25 2020
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.898 2020/08/22 11:27:02 rillig Exp $
+# $NetBSD: mi,v 1.899 2020/08/22 16:51:25 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4593,6 +4593,10 @@
 ./usr/tests/usr.bin/make/unit-tests/dep-double-colon.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/dep-exclam.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/dep-exclam.mk	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/dep-none.exp	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/dep-none.mk	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/dep-var.exp	tests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/dep-var.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/dep-wildcards.exp	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/dep-wildcards.mk	tests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/dep.exp	tests-usr.bin-tests	compattestfile,atf

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.108 src/usr.bin/make/unit-tests/Makefile:1.109
--- src/usr.bin/make/unit-tests/Makefile:1.108	Sat Aug 22 15:25:50 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sat Aug 22 16:51:26 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.108 2020/08/22 15:25:50 sjg Exp $
+# $NetBSD: Makefile,v 1.109 2020/08/22 16:51:26 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -66,6 +66,7 @@ TESTS+=		dep-colon
 TESTS+=		dep-double-colon
 TESTS+=		dep-exclam
 TESTS+=		dep-none
+TESTS+=		dep-var
 TESTS+=		dep-wildcards
 TESTS+=		depsrc
 TESTS+=		depsrc-exec

Added files:

Index: src/usr.bin/make/unit-tests/dep-var.exp
diff -u /dev/null src/usr.bin/make/unit-tests/dep-var.exp:1.1
--- /dev/null	Sat Aug 22 16:51:26 2020
+++ src/usr.bin/make/unit-tests/dep-var.exp	Sat Aug 22 16:51:26 2020
@@ -0,0 +1,2 @@
+def2
+exit status 0
Index: src/usr.bin/make/unit-tests/dep-var.mk
diff -u /dev/null src/usr.bin/make/unit-tests/dep-var.mk:1.1
--- /dev/null	Sat Aug 22 16:51:26 2020
+++ src/usr.bin/make/unit-tests/dep-var.mk	Sat Aug 22 16:51:26 2020
@@ -0,0 +1,33 @@
+# $NetBSD: dep-var.mk,v 1.1 2020/08/22 16:51:26 rillig Exp $
+#
+# Tests for variable references in dependency declarations.
+#
+# Uh oh, this feels so strange that probably nobody uses it. But it seems to
+# be the only way to reach the lower half of SuffExpandChildren.
+
+# XXX: The -dv log says:
+#	Var_Parse: ${UNDEF1} with VARE_UNDEFERR|VARE_WANTRES
+# but no error message is generated for this line.
+# The variable expression ${UNDEF1} simply expands to an empty string.
+all: ${UNDEF1}
+
+# Using a double dollar in order to circumvent immediate variable expansion
+# feels like unintended behavior.  At least the manual page says nothing at
+# all about defined or undefined variables in dependency lines.
+#
+# At the point where the expression ${DEF2} is expanded, the variable DEF2
+# is defined, so everything's fine.
+all: $${DEF2}
+
+# This variable is not defined at all.
+# XXX: The -dv log says:
+#	Var_Parse: ${UNDEF3} with VARE_UNDEFERR|VARE_WANTRES
+# but no error message is generated for this line, just like for UNDEF1.
+# The variable expression ${UNDEF3} simply expands to an empty string.
+all: $${UNDEF3}
+
+UNDEF1=	undef1
+DEF2=	def2
+
+undef1 def2:
+	@echo ${.TARGET}



CVS commit: src/usr.bin/make

2020-08-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug 22 16:00:52 UTC 2020

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

Log Message:
#include  for uint8_t


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

2020-08-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug 22 16:00:52 UTC 2020

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

Log Message:
#include  for uint8_t


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/make/lst.c

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

Modified files:

Index: src/usr.bin/make/lst.c
diff -u src/usr.bin/make/lst.c:1.29 src/usr.bin/make/lst.c:1.30
--- src/usr.bin/make/lst.c:1.29	Sat Aug 22 15:43:32 2020
+++ src/usr.bin/make/lst.c	Sat Aug 22 16:00:52 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.29 2020/08/22 15:43:32 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.30 2020/08/22 16:00:52 skrll Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -33,15 +33,16 @@
  */
 
 #include 
+#include 
 
 #include "make.h"
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: lst.c,v 1.29 2020/08/22 15:43:32 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.30 2020/08/22 16:00:52 skrll Exp $";
 #else
 #include 
 #ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.29 2020/08/22 15:43:32 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.30 2020/08/22 16:00:52 skrll Exp $");
 #endif /* not lint */
 #endif
 



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 15:55:22 UTC 2020

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

Log Message:
make(1): extract percentage calculation out of Dir_PrintDirectories


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/usr.bin/make/dir.c

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

Modified files:

Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.104 src/usr.bin/make/dir.c:1.105
--- src/usr.bin/make/dir.c:1.104	Sat Aug 22 15:43:32 2020
+++ src/usr.bin/make/dir.c	Sat Aug 22 15:55:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.104 2020/08/22 15:43:32 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.105 2020/08/22 15:55:22 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.104 2020/08/22 15:43:32 rillig Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.105 2020/08/22 15:55:22 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)dir.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: dir.c,v 1.104 2020/08/22 15:43:32 rillig Exp $");
+__RCSID("$NetBSD: dir.c,v 1.105 2020/08/22 15:55:22 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1771,6 +1771,12 @@ Dir_Concat(Lst path1, Lst path2)
 }
 }
 
+static int
+percentage(int num, int den)
+{
+return den != 0 ? num * 100 / den : 0;
+}
+
 /** DEBUG INFO **/
 void
 Dir_PrintDirectories(void)
@@ -1782,8 +1788,7 @@ Dir_PrintDirectories(void)
 fprintf(debug_file,
 	"# Stats: %d hits %d misses %d near misses %d losers (%d%%)\n",
 	hits, misses, nearmisses, bigmisses,
-	(hits + bigmisses + nearmisses ?
-	 hits * 100 / (hits + bigmisses + nearmisses) : 0));
+	percentage(hits, hits + bigmisses + nearmisses));
 fprintf(debug_file, "# %-20s referenced\thits\n", "directory");
 if (Lst_Open(openDirectories) == SUCCESS) {
 	while ((ln = Lst_NextS(openDirectories)) != NULL) {



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 15:55:22 UTC 2020

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

Log Message:
make(1): extract percentage calculation out of Dir_PrintDirectories


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 src/usr.bin/make/dir.c

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



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 15:46:28 UTC 2020

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

Log Message:
make(1): declare unused argument in Arch_TouchLib in a simpler way


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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 15:46:28 UTC 2020

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

Log Message:
make(1): declare unused argument in Arch_TouchLib in a simpler way


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/usr.bin/make/arch.c

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

Modified files:

Index: src/usr.bin/make/arch.c
diff -u src/usr.bin/make/arch.c:1.89 src/usr.bin/make/arch.c:1.90
--- src/usr.bin/make/arch.c:1.89	Sat Aug 22 15:17:09 2020
+++ src/usr.bin/make/arch.c	Sat Aug 22 15:46:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.89 2020/08/22 15:17:09 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.90 2020/08/22 15:46:28 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.89 2020/08/22 15:17:09 rillig Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.90 2020/08/22 15:46:28 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)arch.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: arch.c,v 1.89 2020/08/22 15:17:09 rillig Exp $");
+__RCSID("$NetBSD: arch.c,v 1.90 2020/08/22 15:46:28 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1038,11 +1038,7 @@ Arch_Touch(GNode *gn)
  *---
  */
 void
-#if !defined(RANLIBMAG)
-Arch_TouchLib(GNode *gn MAKE_ATTR_UNUSED)
-#else
 Arch_TouchLib(GNode *gn)
-#endif
 {
 #ifdef RANLIBMAG
 FILE *	arch;	/* Stream open to archive */
@@ -1059,6 +1055,8 @@ Arch_TouchLib(GNode *gn)
 	times.actime = times.modtime = now;
 	utime(gn->path, );
 }
+#else
+(void)gn;
 #endif
 }
 



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 15:43:32 UTC 2020

Modified Files:
src/usr.bin/make: compat.c dir.c job.c lst.c lst.h make.c suff.c

Log Message:
make(1): require argument of Lst_Member to be non-null

Since the lists don't contain null pointers, it doesn't make sense to
search for a null pointer.  All calls but one already had obviously
non-null arguments.  The one remaining call using targ->suff has been
guarded for now.

The code for Lst_Member became much simpler than before.  Partly because
the old code had an extra condition for circular lists, which are not
used by make.


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/usr.bin/make/compat.c
cvs rdiff -u -r1.103 -r1.104 src/usr.bin/make/dir.c
cvs rdiff -u -r1.211 -r1.212 src/usr.bin/make/job.c
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/make/lst.c
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/make/lst.h
cvs rdiff -u -r1.117 -r1.118 src/usr.bin/make/make.c
cvs rdiff -u -r1.106 -r1.107 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/compat.c
diff -u src/usr.bin/make/compat.c:1.123 src/usr.bin/make/compat.c:1.124
--- src/usr.bin/make/compat.c:1.123	Sat Aug 22 14:39:12 2020
+++ src/usr.bin/make/compat.c	Sat Aug 22 15:43:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.123 2020/08/22 14:39:12 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.124 2020/08/22 15:43:32 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: compat.c,v 1.123 2020/08/22 14:39:12 rillig Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.124 2020/08/22 15:43:32 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)compat.c	8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: compat.c,v 1.123 2020/08/22 14:39:12 rillig Exp $");
+__RCSID("$NetBSD: compat.c,v 1.124 2020/08/22 15:43:32 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -232,7 +232,7 @@ CompatRunCommand(void *cmdp, void *gnp)
 errCheck = !(gn->type & OP_IGNORE);
 doIt = FALSE;
 
-cmdNode = Lst_Member(gn->commands, cmd);
+cmdNode = Lst_MemberS(gn->commands, cmd);
 cmdStart = Var_Subst(cmd, gn, VARE_WANTRES);
 
 /*
@@ -538,7 +538,7 @@ Compat_Make(void *gnp, void *pgnp)
 	goto cohorts;
 	}
 
-	if (Lst_Member(gn->iParents, pgn) != NULL) {
+	if (Lst_MemberS(gn->iParents, pgn) != NULL) {
 	char *p1;
 	Var_Set(IMPSRC, Var_Value(TARGET, gn, ), pgn);
 	bmake_free(p1);
@@ -642,7 +642,7 @@ Compat_Make(void *gnp, void *pgnp)
 	 */
 	pgn->flags &= ~REMAKE;
 } else {
-	if (Lst_Member(gn->iParents, pgn) != NULL) {
+	if (Lst_MemberS(gn->iParents, pgn) != NULL) {
 	char *p1;
 	Var_Set(IMPSRC, Var_Value(TARGET, gn, ), pgn);
 	bmake_free(p1);

Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.103 src/usr.bin/make/dir.c:1.104
--- src/usr.bin/make/dir.c:1.103	Sat Aug 22 15:17:09 2020
+++ src/usr.bin/make/dir.c	Sat Aug 22 15:43:32 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.103 2020/08/22 15:17:09 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.104 2020/08/22 15:43:32 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.103 2020/08/22 15:17:09 rillig Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.104 2020/08/22 15:43:32 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)dir.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: dir.c,v 1.103 2020/08/22 15:17:09 rillig Exp $");
+__RCSID("$NetBSD: dir.c,v 1.104 2020/08/22 15:43:32 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -417,7 +417,7 @@ Dir_InitDot(void)
 	LstNode ln;
 
 	/* Remove old entry from openDirectories, but do not destroy. */
-	ln = Lst_Member(openDirectories, dot);
+	ln = Lst_MemberS(openDirectories, dot);
 	Lst_RemoveS(openDirectories, ln);
 }
 
@@ -1574,7 +1574,7 @@ Dir_AddDir(Lst path, const char *name)
 	ln = Lst_Find(openDirectories, name, DirFindName);
 if (ln != NULL) {
 	p = Lst_DatumS(ln);
-	if (path && Lst_Member(path, p) == NULL) {
+	if (path && Lst_MemberS(path, p) == NULL) {
 	p->refCount += 1;
 	Lst_AppendS(path, p);
 	}
@@ -1702,7 +1702,7 @@ Dir_Destroy(void *pp)
 if (p->refCount == 0) {
 	LstNode ln;
 
-	ln = Lst_Member(openDirectories, p);
+	ln = Lst_MemberS(openDirectories, p);
 	Lst_RemoveS(openDirectories, ln);
 
 	Hash_DeleteTable(>files);
@@ -1764,7 +1764,7 @@ Dir_Concat(Lst path1, Lst path2)
 
 for (ln = Lst_First(path2); ln != NULL; ln = Lst_Succ(ln)) {
 	p = Lst_DatumS(ln);
-	if (Lst_Member(path1, p) == NULL) {
+	if (Lst_MemberS(path1, p) == NULL) {
 	p->refCount += 1;
 	Lst_AppendS(path1, p);
 	}

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

CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 15:43:32 UTC 2020

Modified Files:
src/usr.bin/make: compat.c dir.c job.c lst.c lst.h make.c suff.c

Log Message:
make(1): require argument of Lst_Member to be non-null

Since the lists don't contain null pointers, it doesn't make sense to
search for a null pointer.  All calls but one already had obviously
non-null arguments.  The one remaining call using targ->suff has been
guarded for now.

The code for Lst_Member became much simpler than before.  Partly because
the old code had an extra condition for circular lists, which are not
used by make.


To generate a diff of this commit:
cvs rdiff -u -r1.123 -r1.124 src/usr.bin/make/compat.c
cvs rdiff -u -r1.103 -r1.104 src/usr.bin/make/dir.c
cvs rdiff -u -r1.211 -r1.212 src/usr.bin/make/job.c
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/make/lst.c
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/make/lst.h
cvs rdiff -u -r1.117 -r1.118 src/usr.bin/make/make.c
cvs rdiff -u -r1.106 -r1.107 src/usr.bin/make/suff.c

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



CVS commit: src/sys

2020-08-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug 22 15:34:52 UTC 2020

Modified Files:
src/sys/arch/mips/include: pte.h
src/sys/arch/powerpc/include/booke: pte.h
src/sys/uvm/pmap: pmap_segtab.c

Log Message:
Remove pte_zero_p and simply check against 0.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/mips/include/pte.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/powerpc/include/booke/pte.h
cvs rdiff -u -r1.22 -r1.23 src/sys/uvm/pmap/pmap_segtab.c

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

Modified files:

Index: src/sys/arch/mips/include/pte.h
diff -u src/sys/arch/mips/include/pte.h:1.26 src/sys/arch/mips/include/pte.h:1.27
--- src/sys/arch/mips/include/pte.h:1.26	Sun Jul 26 08:08:41 2020
+++ src/sys/arch/mips/include/pte.h	Sat Aug 22 15:34:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pte.h,v 1.26 2020/07/26 08:08:41 simonb Exp $	*/
+/*	$NetBSD: pte.h,v 1.27 2020/08/22 15:34:51 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -306,12 +306,6 @@ pte_readonly_p(pt_entry_t pte)
 }
 
 static inline bool
-pte_zero_p(pt_entry_t pte)
-{
-	return pte == 0;
-}
-
-static inline bool
 pte_cached_p(pt_entry_t pte)
 {
 	if (MIPS_HAS_R4K_MMU) {

Index: src/sys/arch/powerpc/include/booke/pte.h
diff -u src/sys/arch/powerpc/include/booke/pte.h:1.10 src/sys/arch/powerpc/include/booke/pte.h:1.11
--- src/sys/arch/powerpc/include/booke/pte.h:1.10	Thu Apr 19 21:50:07 2018
+++ src/sys/arch/powerpc/include/booke/pte.h	Sat Aug 22 15:34:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pte.h,v 1.10 2018/04/19 21:50:07 christos Exp $	*/
+/*	$NetBSD: pte.h,v 1.11 2020/08/22 15:34:51 skrll Exp $	*/
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -102,12 +102,6 @@ pte_valid_p(pt_entry_t pt_entry)
 }
 
 static __inline bool
-pte_zero_p(pt_entry_t pt_entry)
-{
-	return pt_entry == 0;
-}
-
-static __inline bool
 pte_exec_p(pt_entry_t pt_entry)
 {
 	return (pt_entry & PTE_xX) != 0;

Index: src/sys/uvm/pmap/pmap_segtab.c
diff -u src/sys/uvm/pmap/pmap_segtab.c:1.22 src/sys/uvm/pmap/pmap_segtab.c:1.23
--- src/sys/uvm/pmap/pmap_segtab.c:1.22	Sat Aug 22 15:32:36 2020
+++ src/sys/uvm/pmap/pmap_segtab.c	Sat Aug 22 15:34:51 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_segtab.c,v 1.22 2020/08/22 15:32:36 skrll Exp $	*/
+/*	$NetBSD: pmap_segtab.c,v 1.23 2020/08/22 15:34:51 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pmap_segtab.c,v 1.22 2020/08/22 15:32:36 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_segtab.c,v 1.23 2020/08/22 15:34:51 skrll Exp $");
 
 /*
  *	Manages physical address maps.
@@ -180,13 +180,13 @@ pmap_check_ptes(pt_entry_t *pte, const c
 
 #ifdef DEBUG
 	for (size_t i = 0; i < NPTEPG; i++)
-		if (!pte_zero_p(pte[i])) {
+		if (pte[i] != 0) {
 #ifdef DEBUG_NOISY
 			UVMHIST_FUNC(__func__);
 			UVMHIST_CALLARGS(pmapsegtabhist, "pte=%#jx",
 			(uintptr_t)pte, 0, 0, 0);
 			for (size_t j = i + 1; j < NPTEPG; j++)
-if (!pte_zero_p(pte[j]))
+if (pte[j] != 0)
 	UVMHIST_LOG(pmapsegtabhist,
 	"pte[%zu] = %#"PRIxPTE,
 	j, pte_value(pte[j]), 0, 0);



CVS commit: src/sys

2020-08-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug 22 15:34:52 UTC 2020

Modified Files:
src/sys/arch/mips/include: pte.h
src/sys/arch/powerpc/include/booke: pte.h
src/sys/uvm/pmap: pmap_segtab.c

Log Message:
Remove pte_zero_p and simply check against 0.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/mips/include/pte.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/powerpc/include/booke/pte.h
cvs rdiff -u -r1.22 -r1.23 src/sys/uvm/pmap/pmap_segtab.c

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



CVS commit: src/sys/uvm/pmap

2020-08-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug 22 15:32:36 UTC 2020

Modified Files:
src/sys/uvm/pmap: pmap_segtab.c

Log Message:
Remove the #if defined(__mips_n64) && PAGE_SIZE == 8192 and make the
check MI - all PTs are PAGE_SIZE aligned


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/uvm/pmap/pmap_segtab.c

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

Modified files:

Index: src/sys/uvm/pmap/pmap_segtab.c
diff -u src/sys/uvm/pmap/pmap_segtab.c:1.21 src/sys/uvm/pmap/pmap_segtab.c:1.22
--- src/sys/uvm/pmap/pmap_segtab.c:1.21	Sat Aug 22 13:59:16 2020
+++ src/sys/uvm/pmap/pmap_segtab.c	Sat Aug 22 15:32:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_segtab.c,v 1.21 2020/08/22 13:59:16 skrll Exp $	*/
+/*	$NetBSD: pmap_segtab.c,v 1.22 2020/08/22 15:32:36 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pmap_segtab.c,v 1.21 2020/08/22 13:59:16 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_segtab.c,v 1.22 2020/08/22 15:32:36 skrll Exp $");
 
 /*
  *	Manages physical address maps.
@@ -171,6 +171,13 @@ pmap_check_stp(pmap_segtab_t *stp, const
 static void
 pmap_check_ptes(pt_entry_t *pte, const char *caller)
 {
+	/*
+	 * All pte arrays should be page aligned.
+	 */
+	if (((uintptr_t)pte & PAGE_MASK) != 0) {
+		panic("%s: pte entry at %p not page aligned", caller, pte);
+	}
+
 #ifdef DEBUG
 	for (size_t i = 0; i < NPTEPG; i++)
 		if (!pte_zero_p(pte[i])) {
@@ -283,17 +290,6 @@ pmap_segtab_release(pmap_t pmap, pmap_se
 			continue;
 		pmap_check_ptes(pte, __func__);
 
-#if defined(__mips_n64) && PAGE_SIZE == 8192
-		/*
-		 * XXX This is evil.  If vinc is 100 we are in
-		 * the last level, and this pte should be page aligned.
-		 */
-		if (vinc == 0x100 && ((uintptr_t)pte & PAGE_MASK) != 0) {
-			panic("%s: pte entry at %p not page aligned",
-			__func__, pte);
-		}
-#endif
-
 		/*
 		 * If our caller wants a callback, do so.
 		 */



CVS commit: src/sys/uvm/pmap

2020-08-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug 22 15:32:36 UTC 2020

Modified Files:
src/sys/uvm/pmap: pmap_segtab.c

Log Message:
Remove the #if defined(__mips_n64) && PAGE_SIZE == 8192 and make the
check MI - all PTs are PAGE_SIZE aligned


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/uvm/pmap/pmap_segtab.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

2020-08-22 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sat Aug 22 15:25:50 UTC 2020

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

Log Message:
Supress /bin/sh: in error for sh-dots


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

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

Modified files:

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.107 src/usr.bin/make/unit-tests/Makefile:1.108
--- src/usr.bin/make/unit-tests/Makefile:1.107	Sat Aug 22 12:51:11 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sat Aug 22 15:25:50 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.107 2020/08/22 12:51:11 rillig Exp $
+# $NetBSD: Makefile,v 1.108 2020/08/22 15:25:50 sjg Exp $
 #
 # Unit tests for make(1)
 #
@@ -323,6 +323,7 @@ FLAGS.vardebug=		-k -dv FROM_CMDLINE=
 FLAGS.varmod-match-escape= -dv
 
 # Some tests need extra post-processing.
+SED_CMDS.sh-dots+=	-e '/not found/s,^.*sh: ,,'
 SED_CMDS.varmod-subst-regex+= \
 			-e 's,\(Regex compilation error:\).*,\1 (details omitted),'
 SED_CMDS.varmod-edge+=	-e 's, line [0-9]*:, line omitted:,'



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

2020-08-22 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sat Aug 22 15:25:50 UTC 2020

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

Log Message:
Supress /bin/sh: in error for sh-dots


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

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



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 15:17:09 UTC 2020

Modified Files:
src/usr.bin/make: arch.c dir.c lst.c lst.h main.c make.c meta.c parse.c
suff.c targ.c

Log Message:
make(1): replace Lst_Datum with non-null guaranteeing Lst_DatumS


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/usr.bin/make/arch.c
cvs rdiff -u -r1.102 -r1.103 src/usr.bin/make/dir.c
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/make/lst.c
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/make/lst.h
cvs rdiff -u -r1.307 -r1.308 src/usr.bin/make/main.c
cvs rdiff -u -r1.116 -r1.117 src/usr.bin/make/make.c
cvs rdiff -u -r1.95 -r1.96 src/usr.bin/make/meta.c
cvs rdiff -u -r1.256 -r1.257 src/usr.bin/make/parse.c
cvs rdiff -u -r1.105 -r1.106 src/usr.bin/make/suff.c
cvs rdiff -u -r1.69 -r1.70 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/arch.c
diff -u src/usr.bin/make/arch.c:1.88 src/usr.bin/make/arch.c:1.89
--- src/usr.bin/make/arch.c:1.88	Sat Aug 22 14:39:12 2020
+++ src/usr.bin/make/arch.c	Sat Aug 22 15:17:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.88 2020/08/22 14:39:12 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.89 2020/08/22 15:17:09 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.88 2020/08/22 14:39:12 rillig Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.89 2020/08/22 15:17:09 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)arch.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: arch.c,v 1.88 2020/08/22 14:39:12 rillig Exp $");
+__RCSID("$NetBSD: arch.c,v 1.89 2020/08/22 15:17:09 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -544,7 +544,7 @@ ArchStatMember(const char *archive, cons
 
 ln = Lst_Find(archives, archive, ArchFindArchive);
 if (ln != NULL) {
-	ar = (Arch *)Lst_Datum(ln);
+	ar = Lst_DatumS(ln);
 
 	he = Hash_FindEntry(>members, member);
 
@@ -1130,7 +1130,7 @@ Arch_MemMTime(GNode *gn)
 	return 0;
 }
 while ((ln = Lst_NextS(gn->parents)) != NULL) {
-	pgn = (GNode *)Lst_Datum(ln);
+	pgn = Lst_DatumS(ln);
 
 	if (pgn->type & OP_ARCHV) {
 	/*

Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.102 src/usr.bin/make/dir.c:1.103
--- src/usr.bin/make/dir.c:1.102	Sat Aug 22 14:39:12 2020
+++ src/usr.bin/make/dir.c	Sat Aug 22 15:17:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.102 2020/08/22 14:39:12 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.103 2020/08/22 15:17:09 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.102 2020/08/22 14:39:12 rillig Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.103 2020/08/22 15:17:09 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)dir.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: dir.c,v 1.102 2020/08/22 14:39:12 rillig Exp $");
+__RCSID("$NetBSD: dir.c,v 1.103 2020/08/22 15:17:09 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -484,7 +484,7 @@ Dir_SetPATH(void)
 
 if (Lst_Open(dirSearchPath) == SUCCESS) {
 	if ((ln = Lst_First(dirSearchPath)) != NULL) {
-	p = (Path *)Lst_Datum(ln);
+	p = Lst_DatumS(ln);
 	if (p == dotLast) {
 		hasLastDot = TRUE;
 		Var_Append(".PATH", dotLast->name, VAR_GLOBAL);
@@ -499,7 +499,7 @@ Dir_SetPATH(void)
 	}
 
 	while ((ln = Lst_NextS(dirSearchPath)) != NULL) {
-	p = (Path *)Lst_Datum(ln);
+	p = Lst_DatumS(ln);
 	if (p == dotLast)
 		continue;
 	if (p == dot && hasLastDot)
@@ -795,11 +795,10 @@ static void
 DirExpandInt(const char *word, Lst path, Lst expansions)
 {
 LstNode ln;			/* Current node */
-Path *p;			/* Directory in the node */
 
 if (Lst_Open(path) == SUCCESS) {
 	while ((ln = Lst_NextS(path)) != NULL) {
-	p = (Path *)Lst_Datum(ln);
+	Path *p = Lst_DatumS(ln);
 	DirMatchFiles(word, p, expansions);
 	}
 	Lst_CloseS(path);
@@ -1137,7 +1136,7 @@ Dir_FindFile(const char *name, Lst path)
 }
 
 if ((ln = Lst_First(path)) != NULL) {
-	p = (Path *)Lst_Datum(ln);
+	p = Lst_DatumS(ln);
 	if (p == dotLast) {
 	hasLastDot = TRUE;
 	DIR_DEBUG0("[dot last]...");
@@ -1171,7 +1170,7 @@ Dir_FindFile(const char *name, Lst path)
 	}
 
 	while ((ln = Lst_NextS(path)) != NULL) {
-	p = (Path *)Lst_Datum(ln);
+	p = Lst_DatumS(ln);
 	if (p == dotLast)
 		continue;
 	if ((file = DirLookup(p, name, cp, hasSlash)) != NULL) {
@@ -1229,7 +1228,7 @@ Dir_FindFile(const char *name, Lst path)
 
 	Lst_OpenS(path);
 	while ((ln = Lst_NextS(path)) != NULL) {
-	p = (Path *)Lst_Datum(ln);
+	p = Lst_DatumS(ln);
 	if (p == dotLast)
 		continue;
 	if (p == dot) {
@@ -1287,7 +1286,7 @@ Dir_FindFile(const char *name, Lst path)
 
 	

CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 15:17:09 UTC 2020

Modified Files:
src/usr.bin/make: arch.c dir.c lst.c lst.h main.c make.c meta.c parse.c
suff.c targ.c

Log Message:
make(1): replace Lst_Datum with non-null guaranteeing Lst_DatumS


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/usr.bin/make/arch.c
cvs rdiff -u -r1.102 -r1.103 src/usr.bin/make/dir.c
cvs rdiff -u -r1.27 -r1.28 src/usr.bin/make/lst.c
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/make/lst.h
cvs rdiff -u -r1.307 -r1.308 src/usr.bin/make/main.c
cvs rdiff -u -r1.116 -r1.117 src/usr.bin/make/make.c
cvs rdiff -u -r1.95 -r1.96 src/usr.bin/make/meta.c
cvs rdiff -u -r1.256 -r1.257 src/usr.bin/make/parse.c
cvs rdiff -u -r1.105 -r1.106 src/usr.bin/make/suff.c
cvs rdiff -u -r1.69 -r1.70 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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 14:56:45 UTC 2020

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

Log Message:
make(1): unexport Lst_InsertBefore and Lst_InsertAfter


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/make/lst.c
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/make/lst.h

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



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 14:56:45 UTC 2020

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

Log Message:
make(1): unexport Lst_InsertBefore and Lst_InsertAfter


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/usr.bin/make/lst.c
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/make/lst.h

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

Modified files:

Index: src/usr.bin/make/lst.c
diff -u src/usr.bin/make/lst.c:1.26 src/usr.bin/make/lst.c:1.27
--- src/usr.bin/make/lst.c:1.26	Sat Aug 22 14:54:48 2020
+++ src/usr.bin/make/lst.c	Sat Aug 22 14:56:45 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.26 2020/08/22 14:54:48 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.27 2020/08/22 14:56:45 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -37,11 +37,11 @@
 #include "make.h"
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: lst.c,v 1.26 2020/08/22 14:54:48 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.27 2020/08/22 14:56:45 rillig Exp $";
 #else
 #include 
 #ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.26 2020/08/22 14:54:48 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.27 2020/08/22 14:56:45 rillig Exp $");
 #endif /* not lint */
 #endif
 
@@ -193,7 +193,7 @@ Lst_Destroy(Lst list, FreeProc *freeProc
 /* Insert a new node with the given piece of data before the given node in the
  * given list. */
 static ReturnStatus
-Lst_InsertBefore(Lst list, LstNode node, void *datum)
+LstInsertBefore(Lst list, LstNode node, void *datum)
 {
 LstNode newNode;
 
@@ -258,8 +258,8 @@ Lst_InsertBeforeS(Lst list, LstNode node
 
 /* Insert a new node with the given piece of data after the given node in the
  * given list. */
-ReturnStatus
-Lst_InsertAfter(Lst list, LstNode node, void *datum)
+static ReturnStatus
+LstInsertAfter(Lst list, LstNode node, void *datum)
 {
 LstNode newNode;
 
@@ -299,7 +299,7 @@ ReturnStatus
 Lst_AtFront(Lst list, void *datum)
 {
 LstNode front = Lst_First(list);
-return Lst_InsertBefore(list, front, datum);
+return LstInsertBefore(list, front, datum);
 }
 
 /* Add a piece of data at the end of the given list. */
@@ -307,7 +307,7 @@ ReturnStatus
 Lst_AtEnd(Lst list, void *datum)
 {
 LstNode end = Lst_Last(list);
-return Lst_InsertAfter(list, end, datum);
+return LstInsertAfter(list, end, datum);
 }
 
 /* Add a piece of data at the start of the given list. */

Index: src/usr.bin/make/lst.h
diff -u src/usr.bin/make/lst.h:1.32 src/usr.bin/make/lst.h:1.33
--- src/usr.bin/make/lst.h:1.32	Sat Aug 22 14:54:48 2020
+++ src/usr.bin/make/lst.h	Sat Aug 22 14:56:45 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lst.h,v 1.32 2020/08/22 14:54:48 rillig Exp $	*/
+/*	$NetBSD: lst.h,v 1.33 2020/08/22 14:56:45 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -115,8 +115,6 @@ Boolean		Lst_IsEmpty(Lst);
  */
 /* Insert an element before another */
 void		Lst_InsertBeforeS(Lst, LstNode, void *);
-/* Insert an element after another */
-ReturnStatus	Lst_InsertAfter(Lst, LstNode, void *);
 /* Place an element at the front of a lst. */
 ReturnStatus	Lst_AtFront(Lst, void *);
 void		Lst_PrependS(Lst, void *);



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 14:54:48 UTC 2020

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

Log Message:
make(1): add strict argument checks for Lst_InsertBefore

As with the other modifying operations on lists, the callers already
made sure that the arguments are valid.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/make/lst.c
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/make/lst.h
cvs rdiff -u -r1.115 -r1.116 src/usr.bin/make/make.c
cvs rdiff -u -r1.104 -r1.105 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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 14:54:48 UTC 2020

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

Log Message:
make(1): add strict argument checks for Lst_InsertBefore

As with the other modifying operations on lists, the callers already
made sure that the arguments are valid.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/usr.bin/make/lst.c
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/make/lst.h
cvs rdiff -u -r1.115 -r1.116 src/usr.bin/make/make.c
cvs rdiff -u -r1.104 -r1.105 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/lst.c
diff -u src/usr.bin/make/lst.c:1.25 src/usr.bin/make/lst.c:1.26
--- src/usr.bin/make/lst.c:1.25	Sat Aug 22 14:39:12 2020
+++ src/usr.bin/make/lst.c	Sat Aug 22 14:54:48 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.25 2020/08/22 14:39:12 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.26 2020/08/22 14:54:48 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -37,11 +37,11 @@
 #include "make.h"
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: lst.c,v 1.25 2020/08/22 14:39:12 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.26 2020/08/22 14:54:48 rillig Exp $";
 #else
 #include 
 #ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.25 2020/08/22 14:39:12 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.26 2020/08/22 14:54:48 rillig Exp $");
 #endif /* not lint */
 #endif
 
@@ -192,7 +192,7 @@ Lst_Destroy(Lst list, FreeProc *freeProc
 
 /* Insert a new node with the given piece of data before the given node in the
  * given list. */
-ReturnStatus
+static ReturnStatus
 Lst_InsertBefore(Lst list, LstNode node, void *datum)
 {
 LstNode newNode;
@@ -230,6 +230,32 @@ Lst_InsertBefore(Lst list, LstNode node,
 return SUCCESS;
 }
 
+/* Insert a new node with the given piece of data before the given node in the
+ * given list. */
+void
+Lst_InsertBeforeS(Lst list, LstNode node, void *datum)
+{
+LstNode newNode;
+
+assert(LstIsValid(list));
+assert(!LstIsEmpty(list));
+assert(LstNodeIsValid(node));
+assert(datum != NULL);
+
+newNode = LstNodeNew(datum);
+newNode->prev = node->prev;
+newNode->next = node;
+
+if (node->prev != NULL) {
+	node->prev->next = newNode;
+}
+node->prev = newNode;
+
+if (node == list->first) {
+	list->first = newNode;
+}
+}
+
 /* Insert a new node with the given piece of data after the given node in the
  * given list. */
 ReturnStatus

Index: src/usr.bin/make/lst.h
diff -u src/usr.bin/make/lst.h:1.31 src/usr.bin/make/lst.h:1.32
--- src/usr.bin/make/lst.h:1.31	Sat Aug 22 14:39:12 2020
+++ src/usr.bin/make/lst.h	Sat Aug 22 14:54:48 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lst.h,v 1.31 2020/08/22 14:39:12 rillig Exp $	*/
+/*	$NetBSD: lst.h,v 1.32 2020/08/22 14:54:48 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -114,7 +114,7 @@ Boolean		Lst_IsEmpty(Lst);
  * Functions to modify a list
  */
 /* Insert an element before another */
-ReturnStatus	Lst_InsertBefore(Lst, LstNode, void *);
+void		Lst_InsertBeforeS(Lst, LstNode, void *);
 /* Insert an element after another */
 ReturnStatus	Lst_InsertAfter(Lst, LstNode, void *);
 /* Place an element at the front of a lst. */

Index: src/usr.bin/make/make.c
diff -u src/usr.bin/make/make.c:1.115 src/usr.bin/make/make.c:1.116
--- src/usr.bin/make/make.c:1.115	Sat Aug 22 14:39:12 2020
+++ src/usr.bin/make/make.c	Sat Aug 22 14:54:48 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.115 2020/08/22 14:39:12 rillig Exp $	*/
+/*	$NetBSD: make.c,v 1.116 2020/08/22 14:54:48 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: make.c,v 1.115 2020/08/22 14:39:12 rillig Exp $";
+static char rcsid[] = "$NetBSD: make.c,v 1.116 2020/08/22 14:54:48 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)make.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: make.c,v 1.115 2020/08/22 14:39:12 rillig Exp $");
+__RCSID("$NetBSD: make.c,v 1.116 2020/08/22 14:54:48 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1015,7 +1015,7 @@ MakeBuildChild(void *v_cn, void *toBeMad
 if (toBeMade_next == NULL)
 	Lst_AppendS(toBeMade, cn);
 else
-	Lst_InsertBefore(toBeMade, toBeMade_next, cn);
+	Lst_InsertBeforeS(toBeMade, toBeMade_next, cn);
 
 if (cn->unmade_cohorts != 0)
 	Lst_ForEach(cn->cohorts, MakeBuildChild, toBeMade_next);

Index: src/usr.bin/make/suff.c
diff -u src/usr.bin/make/suff.c:1.104 src/usr.bin/make/suff.c:1.105
--- src/usr.bin/make/suff.c:1.104	Sat Aug 22 14:39:12 2020
+++ src/usr.bin/make/suff.c	Sat Aug 22 14:54:48 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: suff.c,v 1.104 2020/08/22 14:39:12 rillig Exp $	*/
+/*	$NetBSD: suff.c,v 1.105 2020/08/22 14:54:48 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 

CVS commit: src/sys/uvm/pmap

2020-08-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug 22 14:51:44 UTC 2020

Modified Files:
src/sys/uvm/pmap: pmap_tlb.c

Log Message:
Whitespace - line continutation alignment


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/uvm/pmap/pmap_tlb.c

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

Modified files:

Index: src/sys/uvm/pmap/pmap_tlb.c
diff -u src/sys/uvm/pmap/pmap_tlb.c:1.39 src/sys/uvm/pmap/pmap_tlb.c:1.40
--- src/sys/uvm/pmap/pmap_tlb.c:1.39	Wed Aug 19 06:11:49 2020
+++ src/sys/uvm/pmap/pmap_tlb.c	Sat Aug 22 14:51:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_tlb.c,v 1.39 2020/08/19 06:11:49 skrll Exp $	*/
+/*	$NetBSD: pmap_tlb.c,v 1.40 2020/08/22 14:51:44 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pmap_tlb.c,v 1.39 2020/08/19 06:11:49 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_tlb.c,v 1.40 2020/08/22 14:51:44 skrll Exp $");
 
 /*
  * Manages address spaces in a TLB.
@@ -629,7 +629,7 @@ pmap_tlb_shootdown_process(void)
 	   (nobody) << 3 * TLBINV_NOBODY)			\
 	 | (  (one) << 3 * TLBINV_ONE)			\
 	 | (  (alluser) << 3 * TLBINV_ALLUSER)			\
-	 | ((allkernel) << 3 * TLBINV_ALLKERNEL)			\
+	 | ((allkernel) << 3 * TLBINV_ALLKERNEL)		\
 	 | (  (all) << 3 * TLBINV_ALL)) >> 3 * (op)) & 7)
 
 #define	TLBINV_USER_MAP(op)	\



CVS commit: src/sys/uvm/pmap

2020-08-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug 22 14:51:44 UTC 2020

Modified Files:
src/sys/uvm/pmap: pmap_tlb.c

Log Message:
Whitespace - line continutation alignment


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/uvm/pmap/pmap_tlb.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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 14:39:12 UTC 2020

Modified Files:
src/usr.bin/make: arch.c compat.c dir.c lst.c lst.h make.c parse.c
suff.c

Log Message:
make(1): convert Lst_Enqueue and Lst_Dequeue to nonnull variants

Except for once instance in parse.c, the usage pattern for Lst_Dequeue
was to first test whether the list is empty.  This pattern allowed the
implementation of Lst_Dequeue to become simpler since the null check is
not needed anymore.

The calls to Lst_Enqueue never pass an invalid list or a null pointer,
therefore making them strict was trivial.


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/usr.bin/make/arch.c
cvs rdiff -u -r1.122 -r1.123 src/usr.bin/make/compat.c
cvs rdiff -u -r1.101 -r1.102 src/usr.bin/make/dir.c
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/make/lst.c
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/make/lst.h
cvs rdiff -u -r1.114 -r1.115 src/usr.bin/make/make.c
cvs rdiff -u -r1.255 -r1.256 src/usr.bin/make/parse.c
cvs rdiff -u -r1.103 -r1.104 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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 14:39:12 UTC 2020

Modified Files:
src/usr.bin/make: arch.c compat.c dir.c lst.c lst.h make.c parse.c
suff.c

Log Message:
make(1): convert Lst_Enqueue and Lst_Dequeue to nonnull variants

Except for once instance in parse.c, the usage pattern for Lst_Dequeue
was to first test whether the list is empty.  This pattern allowed the
implementation of Lst_Dequeue to become simpler since the null check is
not needed anymore.

The calls to Lst_Enqueue never pass an invalid list or a null pointer,
therefore making them strict was trivial.


To generate a diff of this commit:
cvs rdiff -u -r1.87 -r1.88 src/usr.bin/make/arch.c
cvs rdiff -u -r1.122 -r1.123 src/usr.bin/make/compat.c
cvs rdiff -u -r1.101 -r1.102 src/usr.bin/make/dir.c
cvs rdiff -u -r1.24 -r1.25 src/usr.bin/make/lst.c
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/make/lst.h
cvs rdiff -u -r1.114 -r1.115 src/usr.bin/make/make.c
cvs rdiff -u -r1.255 -r1.256 src/usr.bin/make/parse.c
cvs rdiff -u -r1.103 -r1.104 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/arch.c
diff -u src/usr.bin/make/arch.c:1.87 src/usr.bin/make/arch.c:1.88
--- src/usr.bin/make/arch.c:1.87	Sat Aug 22 11:35:00 2020
+++ src/usr.bin/make/arch.c	Sat Aug 22 14:39:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.87 2020/08/22 11:35:00 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.88 2020/08/22 14:39:12 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.87 2020/08/22 11:35:00 rillig Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.88 2020/08/22 14:39:12 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)arch.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: arch.c,v 1.87 2020/08/22 11:35:00 rillig Exp $");
+__RCSID("$NetBSD: arch.c,v 1.88 2020/08/22 14:39:12 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -393,13 +393,12 @@ Arch_ParseArchive(char **linePtr, Lst no
 	free(buf);
 	} else if (Dir_HasWildcards(memName)) {
 	Lst	  members = Lst_Init();
-	char  *member;
 	size_t sz = MAXPATHLEN, nsz;
 	nameBuf = bmake_malloc(sz);
 
 	Dir_Expand(memName, dirSearchPath, members);
 	while (!Lst_IsEmpty(members)) {
-		member = (char *)Lst_DeQueue(members);
+		char *member = Lst_DequeueS(members);
 		nsz = strlen(libName) + strlen(member) + 3;
 		if (sz > nsz)
 		nameBuf = bmake_realloc(nameBuf, sz = nsz * 2);

Index: src/usr.bin/make/compat.c
diff -u src/usr.bin/make/compat.c:1.122 src/usr.bin/make/compat.c:1.123
--- src/usr.bin/make/compat.c:1.122	Sat Aug 22 11:35:00 2020
+++ src/usr.bin/make/compat.c	Sat Aug 22 14:39:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.122 2020/08/22 11:35:00 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.123 2020/08/22 14:39:12 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: compat.c,v 1.122 2020/08/22 11:35:00 rillig Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.123 2020/08/22 14:39:12 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)compat.c	8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: compat.c,v 1.122 2020/08/22 11:35:00 rillig Exp $");
+__RCSID("$NetBSD: compat.c,v 1.123 2020/08/22 14:39:12 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -746,8 +746,8 @@ Compat_Run(Lst targs)
  *		  	could not be made due to errors.
  */
 errors = 0;
-while (!Lst_IsEmpty (targs)) {
-	gn = (GNode *)Lst_DeQueue(targs);
+while (!Lst_IsEmpty(targs)) {
+	gn = Lst_DequeueS(targs);
 	Compat_Make(gn, gn);
 
 	if (gn->made == UPTODATE) {

Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.101 src/usr.bin/make/dir.c:1.102
--- src/usr.bin/make/dir.c:1.101	Sat Aug 22 14:04:22 2020
+++ src/usr.bin/make/dir.c	Sat Aug 22 14:39:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.101 2020/08/22 14:04:22 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.102 2020/08/22 14:39:12 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.101 2020/08/22 14:04:22 rillig Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.102 2020/08/22 14:39:12 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)dir.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: dir.c,v 1.101 2020/08/22 14:04:22 rillig Exp $");
+__RCSID("$NetBSD: dir.c,v 1.102 2020/08/22 14:39:12 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1732,9 +1732,8 @@ Dir_Destroy(void *pp)
 void
 Dir_ClearPath(Lst path)
 {
-Path *p;
 while (!Lst_IsEmpty(path)) {
-	p = (Path 

CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 14:04:22 UTC 2020

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

Log Message:
make(1): remove wrong comment for Dir_Init

Neither the list nor the hash table modules have anything to do with
opening directories.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/usr.bin/make/dir.c

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

Modified files:

Index: src/usr.bin/make/dir.c
diff -u src/usr.bin/make/dir.c:1.100 src/usr.bin/make/dir.c:1.101
--- src/usr.bin/make/dir.c:1.100	Sat Aug 22 11:35:00 2020
+++ src/usr.bin/make/dir.c	Sat Aug 22 14:04:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: dir.c,v 1.100 2020/08/22 11:35:00 rillig Exp $	*/
+/*	$NetBSD: dir.c,v 1.101 2020/08/22 14:04:22 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.100 2020/08/22 11:35:00 rillig Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.101 2020/08/22 14:04:22 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)dir.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: dir.c,v 1.100 2020/08/22 11:35:00 rillig Exp $");
+__RCSID("$NetBSD: dir.c,v 1.101 2020/08/22 14:04:22 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -143,7 +143,6 @@ __RCSID("$NetBSD: dir.c,v 1.100 2020/08/
 #include 
 
 #include "make.h"
-#include "hash.h"
 #include "dir.h"
 #include "job.h"
 
@@ -350,11 +349,7 @@ cached_lstat(const char *pathname, void 
 return cached_stats(, pathname, st, CST_LSTAT);
 }
 
-/* Initialize things for this module.
- *
- * Side Effects:
- *	some directories may be opened.
- */
+/* Initialize things for this module. */
 void
 Dir_Init(void)
 {



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 14:04:22 UTC 2020

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

Log Message:
make(1): remove wrong comment for Dir_Init

Neither the list nor the hash table modules have anything to do with
opening directories.


To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/usr.bin/make/dir.c

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



CVS commit: src/sys/uvm/pmap

2020-08-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug 22 13:59:16 UTC 2020

Modified Files:
src/sys/uvm/pmap: pmap_segtab.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/uvm/pmap/pmap_segtab.c

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

Modified files:

Index: src/sys/uvm/pmap/pmap_segtab.c
diff -u src/sys/uvm/pmap/pmap_segtab.c:1.20 src/sys/uvm/pmap/pmap_segtab.c:1.21
--- src/sys/uvm/pmap/pmap_segtab.c:1.20	Thu Aug 20 23:36:45 2020
+++ src/sys/uvm/pmap/pmap_segtab.c	Sat Aug 22 13:59:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_segtab.c,v 1.20 2020/08/20 23:36:45 mrg Exp $	*/
+/*	$NetBSD: pmap_segtab.c,v 1.21 2020/08/22 13:59:16 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pmap_segtab.c,v 1.20 2020/08/20 23:36:45 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_segtab.c,v 1.21 2020/08/22 13:59:16 skrll Exp $");
 
 /*
  *	Manages physical address maps.
@@ -132,7 +132,7 @@ struct pmap_segtab_info {
 kmutex_t pmap_segtab_lock __cacheline_aligned;
 
 /*
- * Check that a seg_tab[] array is empty.  
+ * Check that a seg_tab[] array is empty.
  *
  * This is used when allocating or freeing a pmap_segtab_t.  The stp
  * should be unused -- meaning, none of the seg_tab[] pointers are
@@ -182,7 +182,7 @@ pmap_check_ptes(pt_entry_t *pte, const c
 if (!pte_zero_p(pte[j]))
 	UVMHIST_LOG(pmapsegtabhist,
 	"pte[%zu] = %#"PRIxPTE,
-	j, pte_value(pte[j]), 0, 0); 
+	j, pte_value(pte[j]), 0, 0);
 #endif
 			panic("%s: pte[%zu] entry at %p not 0 (%#"PRIxPTE")",
 			  caller, i, [i], pte_value(pte[i]));
@@ -281,7 +281,7 @@ pmap_segtab_release(pmap_t pmap, pmap_se
 		pt_entry_t *pte = stp->seg_tab[i];
 		if (pte == NULL)
 			continue;
-		pmap_check_ptes(pte, __func__); 
+		pmap_check_ptes(pte, __func__);
 
 #if defined(__mips_n64) && PAGE_SIZE == 8192
 		/*



CVS commit: src/sys/uvm/pmap

2020-08-22 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug 22 13:59:16 UTC 2020

Modified Files:
src/sys/uvm/pmap: pmap_segtab.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/uvm/pmap/pmap_segtab.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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 13:49:40 UTC 2020

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

Log Message:
make(1): allow the inconsistency with Lst_OpenS to be discovered

The -dL option is intended to find bugs in Makefiles and in make itself,
therefore enabling the consistency check is ok there.  Having this check
available by default increases the chances of the bug being found and
finally fixed.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/lst.c

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

Modified files:

Index: src/usr.bin/make/lst.c
diff -u src/usr.bin/make/lst.c:1.23 src/usr.bin/make/lst.c:1.24
--- src/usr.bin/make/lst.c:1.23	Sat Aug 22 13:28:20 2020
+++ src/usr.bin/make/lst.c	Sat Aug 22 13:49:40 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.23 2020/08/22 13:28:20 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.24 2020/08/22 13:49:40 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -37,11 +37,11 @@
 #include "make.h"
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: lst.c,v 1.23 2020/08/22 13:28:20 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.24 2020/08/22 13:49:40 rillig Exp $";
 #else
 #include 
 #ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.23 2020/08/22 13:28:20 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.24 2020/08/22 13:49:40 rillig Exp $");
 #endif /* not lint */
 #endif
 
@@ -712,14 +712,12 @@ void
 Lst_OpenS(Lst list)
 {
 assert(LstIsValid(list));
-#if 0
+
 /* XXX: This assertion fails for NetBSD's "build.sh -j1 tools", somewhere
  * between "dependall ===> compat" and "dependall ===> binstall".
  * Building without the "-j1" succeeds though. */
-if (list->isOpen)
+if (DEBUG(LINT) && list->isOpen)
 	Parse_Error(PARSE_WARNING, "Internal inconsistency: list opened twice");
-assert(!list->isOpen);
-#endif
 
 list->isOpen = TRUE;
 list->lastAccess = LstIsEmpty(list) ? Head : Unknown;



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 13:49:40 UTC 2020

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

Log Message:
make(1): allow the inconsistency with Lst_OpenS to be discovered

The -dL option is intended to find bugs in Makefiles and in make itself,
therefore enabling the consistency check is ok there.  Having this check
available by default increases the chances of the bug being found and
finally fixed.


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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 13:44:17 UTC 2020

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

Log Message:
make(1): replace two instances of Lst_AtFront with Lst_Prepend

In these cases, the list is guaranteed to be valid, therefore no
assertion is expected.

For comparison, the Lst_AtFront in dir.c needs to be kept since the path
may be null there.


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/usr.bin/make/make.c
cvs rdiff -u -r1.254 -r1.255 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/make.c
diff -u src/usr.bin/make/make.c:1.113 src/usr.bin/make/make.c:1.114
--- src/usr.bin/make/make.c:1.113	Sat Aug 22 13:28:20 2020
+++ src/usr.bin/make/make.c	Sat Aug 22 13:44:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.113 2020/08/22 13:28:20 rillig Exp $	*/
+/*	$NetBSD: make.c,v 1.114 2020/08/22 13:44:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: make.c,v 1.113 2020/08/22 13:28:20 rillig Exp $";
+static char rcsid[] = "$NetBSD: make.c,v 1.114 2020/08/22 13:44:17 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)make.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: make.c,v 1.113 2020/08/22 13:28:20 rillig Exp $");
+__RCSID("$NetBSD: make.c,v 1.114 2020/08/22 13:44:17 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1395,7 +1395,7 @@ Make_ProcessWait(Lst targs)
 pgn->flags = REMAKE;
 pgn->type = OP_PHONY | OP_DEPENDS;
 /* Get it displayed in the diag dumps */
-Lst_AtFront(Targ_List(), pgn);
+Lst_PrependS(Targ_List(), pgn);
 
 Lst_ForEach(targs, link_parent, pgn);
 

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.254 src/usr.bin/make/parse.c:1.255
--- src/usr.bin/make/parse.c:1.254	Sat Aug 22 13:28:20 2020
+++ src/usr.bin/make/parse.c	Sat Aug 22 13:44:17 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.254 2020/08/22 13:28:20 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.255 2020/08/22 13:44:17 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.254 2020/08/22 13:28:20 rillig Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.255 2020/08/22 13:44:17 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)parse.c	8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: parse.c,v 1.254 2020/08/22 13:28:20 rillig Exp $");
+__RCSID("$NetBSD: parse.c,v 1.255 2020/08/22 13:44:17 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -2479,7 +2479,7 @@ Parse_SetInput(const char *name, int lin
 
 if (curFile != NULL)
 	/* Save exiting file info */
-	Lst_AtFront(includes, curFile);
+	Lst_PrependS(includes, curFile);
 
 /* Allocate and fill in new structure */
 curFile = bmake_malloc(sizeof *curFile);



CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 13:44:17 UTC 2020

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

Log Message:
make(1): replace two instances of Lst_AtFront with Lst_Prepend

In these cases, the list is guaranteed to be valid, therefore no
assertion is expected.

For comparison, the Lst_AtFront in dir.c needs to be kept since the path
may be null there.


To generate a diff of this commit:
cvs rdiff -u -r1.113 -r1.114 src/usr.bin/make/make.c
cvs rdiff -u -r1.254 -r1.255 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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 13:28:20 UTC 2020

Modified Files:
src/usr.bin/make: job.c lst.c lst.h make.c meta.c parse.c suff.c targ.c

Log Message:
make(1): convert remaining Lst_AtEnd to the stricter Lst_Append

The general-purpose list library that is included in make allows to call
Lst_AtEnd for invalid lists, silently ignoring this programming error.
This is a flexibility that make doesn't need.

Another unneeded "feature" is that list items can theoretically be null
pointers.  This doesn't make sense as well and is therefore not needed
by make.

These programming errors are now caught early by assertions.


To generate a diff of this commit:
cvs rdiff -u -r1.210 -r1.211 src/usr.bin/make/job.c
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/lst.c
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/make/lst.h
cvs rdiff -u -r1.112 -r1.113 src/usr.bin/make/make.c
cvs rdiff -u -r1.94 -r1.95 src/usr.bin/make/meta.c
cvs rdiff -u -r1.253 -r1.254 src/usr.bin/make/parse.c
cvs rdiff -u -r1.102 -r1.103 src/usr.bin/make/suff.c
cvs rdiff -u -r1.68 -r1.69 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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 13:28:20 UTC 2020

Modified Files:
src/usr.bin/make: job.c lst.c lst.h make.c meta.c parse.c suff.c targ.c

Log Message:
make(1): convert remaining Lst_AtEnd to the stricter Lst_Append

The general-purpose list library that is included in make allows to call
Lst_AtEnd for invalid lists, silently ignoring this programming error.
This is a flexibility that make doesn't need.

Another unneeded "feature" is that list items can theoretically be null
pointers.  This doesn't make sense as well and is therefore not needed
by make.

These programming errors are now caught early by assertions.


To generate a diff of this commit:
cvs rdiff -u -r1.210 -r1.211 src/usr.bin/make/job.c
cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/lst.c
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/make/lst.h
cvs rdiff -u -r1.112 -r1.113 src/usr.bin/make/make.c
cvs rdiff -u -r1.94 -r1.95 src/usr.bin/make/meta.c
cvs rdiff -u -r1.253 -r1.254 src/usr.bin/make/parse.c
cvs rdiff -u -r1.102 -r1.103 src/usr.bin/make/suff.c
cvs rdiff -u -r1.68 -r1.69 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/job.c
diff -u src/usr.bin/make/job.c:1.210 src/usr.bin/make/job.c:1.211
--- src/usr.bin/make/job.c:1.210	Sat Aug 22 11:35:00 2020
+++ src/usr.bin/make/job.c	Sat Aug 22 13:28:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.210 2020/08/22 11:35:00 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.211 2020/08/22 13:28:20 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.210 2020/08/22 11:35:00 rillig Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.211 2020/08/22 13:28:20 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)job.c	8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: job.c,v 1.210 2020/08/22 11:35:00 rillig Exp $");
+__RCSID("$NetBSD: job.c,v 1.211 2020/08/22 13:28:20 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1972,7 +1972,7 @@ JobRun(GNode *targ)
  * the nice side effect that it avoids a lot of other problems.
  */
 Lst lst = Lst_Init();
-Lst_AtEnd(lst, targ);
+Lst_AppendS(lst, targ);
 (void)Make_Run(lst);
 Lst_Destroy(lst, NULL);
 JobStart(targ, JOB_SPECIAL);

Index: src/usr.bin/make/lst.c
diff -u src/usr.bin/make/lst.c:1.22 src/usr.bin/make/lst.c:1.23
--- src/usr.bin/make/lst.c:1.22	Sat Aug 22 13:06:39 2020
+++ src/usr.bin/make/lst.c	Sat Aug 22 13:28:20 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.22 2020/08/22 13:06:39 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.23 2020/08/22 13:28:20 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -37,11 +37,11 @@
 #include "make.h"
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: lst.c,v 1.22 2020/08/22 13:06:39 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.23 2020/08/22 13:28:20 rillig Exp $";
 #else
 #include 
 #ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.22 2020/08/22 13:06:39 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.23 2020/08/22 13:28:20 rillig Exp $");
 #endif /* not lint */
 #endif
 
@@ -71,6 +71,8 @@ struct List {
 LstNode prev;		/* Previous node, if open. Used by Lst_Remove */
 };
 
+static ReturnStatus Lst_AtEnd(Lst, void *);
+
 static Boolean
 LstIsValid(Lst list)
 {

Index: src/usr.bin/make/lst.h
diff -u src/usr.bin/make/lst.h:1.29 src/usr.bin/make/lst.h:1.30
--- src/usr.bin/make/lst.h:1.29	Sat Aug 22 13:06:39 2020
+++ src/usr.bin/make/lst.h	Sat Aug 22 13:28:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lst.h,v 1.29 2020/08/22 13:06:39 rillig Exp $	*/
+/*	$NetBSD: lst.h,v 1.30 2020/08/22 13:28:20 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -121,7 +121,6 @@ ReturnStatus	Lst_InsertAfter(Lst, LstNod
 ReturnStatus	Lst_AtFront(Lst, void *);
 void		Lst_PrependS(Lst, void *);
 /* Place an element at the end of a lst. */
-ReturnStatus	Lst_AtEnd(Lst, void *);
 void		Lst_AppendS(Lst, void *);
 /* Remove an element */
 void		Lst_RemoveS(Lst, LstNode);

Index: src/usr.bin/make/make.c
diff -u src/usr.bin/make/make.c:1.112 src/usr.bin/make/make.c:1.113
--- src/usr.bin/make/make.c:1.112	Sat Aug 22 13:06:39 2020
+++ src/usr.bin/make/make.c	Sat Aug 22 13:28:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.112 2020/08/22 13:06:39 rillig Exp $	*/
+/*	$NetBSD: make.c,v 1.113 2020/08/22 13:28:20 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: make.c,v 1.112 2020/08/22 13:06:39 rillig Exp $";
+static char rcsid[] = "$NetBSD: make.c,v 1.113 2020/08/22 13:28:20 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)make.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: make.c,v 1.112 2020/08/22 13:06:39 

CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 13:06:40 UTC 2020

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

Log Message:
make(1): make Make_HandleUse simpler

Since the function names now contain the text from the comments, the
comments can be shortened a bit.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/lst.c
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/make/lst.h
cvs rdiff -u -r1.111 -r1.112 src/usr.bin/make/make.c

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

Modified files:

Index: src/usr.bin/make/lst.c
diff -u src/usr.bin/make/lst.c:1.21 src/usr.bin/make/lst.c:1.22
--- src/usr.bin/make/lst.c:1.21	Sat Aug 22 09:40:18 2020
+++ src/usr.bin/make/lst.c	Sat Aug 22 13:06:39 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: lst.c,v 1.21 2020/08/22 09:40:18 rillig Exp $ */
+/* $NetBSD: lst.c,v 1.22 2020/08/22 13:06:39 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -37,11 +37,11 @@
 #include "make.h"
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: lst.c,v 1.21 2020/08/22 09:40:18 rillig Exp $";
+static char rcsid[] = "$NetBSD: lst.c,v 1.22 2020/08/22 13:06:39 rillig Exp $";
 #else
 #include 
 #ifndef lint
-__RCSID("$NetBSD: lst.c,v 1.21 2020/08/22 09:40:18 rillig Exp $");
+__RCSID("$NetBSD: lst.c,v 1.22 2020/08/22 13:06:39 rillig Exp $");
 #endif /* not lint */
 #endif
 
@@ -83,12 +83,14 @@ LstNodeIsValid(LstNode node)
 return node != NULL;
 }
 
+/* Allocate and initialize a list node.
+ *
+ * The fields 'prev' and 'next' must be initialized by the caller.
+ */
 static LstNode
 LstNodeNew(void *datum)
 {
 LstNode node = bmake_malloc(sizeof *node);
-/* prev will be initialized by the calling code. */
-/* next will be initialized by the calling code. */
 node->useCount = 0;
 node->deleted = FALSE;
 node->datum = datum;
@@ -280,6 +282,28 @@ Lst_AtEnd(Lst list, void *datum)
 return Lst_InsertAfter(list, end, datum);
 }
 
+/* Add a piece of data at the start of the given list. */
+void
+Lst_PrependS(Lst list, void *datum)
+{
+LstNode node;
+
+assert(LstIsValid(list));
+assert(datum != NULL);
+
+node = LstNodeNew(datum);
+node->prev = NULL;
+node->next = list->first;
+
+if (list->first == NULL) {
+	list->first = node;
+	list->last = node;
+} else {
+	list->first->prev = node;
+	list->first = node;
+}
+}
+
 /* Add a piece of data at the end of the given list. */
 void
 Lst_AppendS(Lst list, void *datum)
@@ -640,6 +664,23 @@ Lst_Concat(Lst list1, Lst list2, int fla
 return SUCCESS;
 }
 
+/* Copy the element data from src to the start of dst. */
+void
+Lst_PrependAllS(Lst dst, Lst src)
+{
+LstNode node;
+for (node = src->last; node != NULL; node = node->prev)
+Lst_PrependS(dst, node->datum);
+}
+
+/* Copy the element data from src to the end of dst. */
+void
+Lst_AppendAllS(Lst dst, Lst src)
+{
+LstNode node;
+for (node = src->first; node != NULL; node = node->next)
+Lst_AppendS(dst, node->datum);
+}
 
 /*
  * these functions are for dealing with a list as a table, of sorts.

Index: src/usr.bin/make/lst.h
diff -u src/usr.bin/make/lst.h:1.28 src/usr.bin/make/lst.h:1.29
--- src/usr.bin/make/lst.h:1.28	Sat Aug 22 09:40:18 2020
+++ src/usr.bin/make/lst.h	Sat Aug 22 13:06:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: lst.h,v 1.28 2020/08/22 09:40:18 rillig Exp $	*/
+/*	$NetBSD: lst.h,v 1.29 2020/08/22 13:06:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -119,6 +119,7 @@ ReturnStatus	Lst_InsertBefore(Lst, LstNo
 ReturnStatus	Lst_InsertAfter(Lst, LstNode, void *);
 /* Place an element at the front of a lst. */
 ReturnStatus	Lst_AtFront(Lst, void *);
+void		Lst_PrependS(Lst, void *);
 /* Place an element at the end of a lst. */
 ReturnStatus	Lst_AtEnd(Lst, void *);
 void		Lst_AppendS(Lst, void *);
@@ -128,6 +129,8 @@ void		Lst_RemoveS(Lst, LstNode);
 void		Lst_ReplaceS(LstNode, void *);
 /* Concatenate two lists */
 ReturnStatus	Lst_Concat(Lst, Lst, int);
+void		Lst_PrependAllS(Lst, Lst);
+void		Lst_AppendAllS(Lst, Lst);
 
 /*
  * Node-specific functions

Index: src/usr.bin/make/make.c
diff -u src/usr.bin/make/make.c:1.111 src/usr.bin/make/make.c:1.112
--- src/usr.bin/make/make.c:1.111	Sat Aug 22 11:57:18 2020
+++ src/usr.bin/make/make.c	Sat Aug 22 13:06:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.c,v 1.111 2020/08/22 11:57:18 rillig Exp $	*/
+/*	$NetBSD: make.c,v 1.112 2020/08/22 13:06:39 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: make.c,v 1.111 2020/08/22 11:57:18 rillig Exp $";
+static char rcsid[] = "$NetBSD: make.c,v 1.112 2020/08/22 13:06:39 rillig Exp $";
 #else
 #include 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)make.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: make.c,v 1.111 2020/08/22 11:57:18 rillig 

CVS commit: src/usr.bin/make

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 13:06:40 UTC 2020

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

Log Message:
make(1): make Make_HandleUse simpler

Since the function names now contain the text from the comments, the
comments can be shortened a bit.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/lst.c
cvs rdiff -u -r1.28 -r1.29 src/usr.bin/make/lst.h
cvs rdiff -u -r1.111 -r1.112 src/usr.bin/make/make.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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 12:51:11 UTC 2020

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

Log Message:
make(1): add test for "no target to make"


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/dep-none.exp \
src/usr.bin/make/unit-tests/dep-none.mk

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

Modified files:

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.106 src/usr.bin/make/unit-tests/Makefile:1.107
--- src/usr.bin/make/unit-tests/Makefile:1.106	Sat Aug 22 11:27:02 2020
+++ src/usr.bin/make/unit-tests/Makefile	Sat Aug 22 12:51:11 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.106 2020/08/22 11:27:02 rillig Exp $
+# $NetBSD: Makefile,v 1.107 2020/08/22 12:51:11 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -65,6 +65,7 @@ TESTS+=		dep
 TESTS+=		dep-colon
 TESTS+=		dep-double-colon
 TESTS+=		dep-exclam
+TESTS+=		dep-none
 TESTS+=		dep-wildcards
 TESTS+=		depsrc
 TESTS+=		depsrc-exec

Added files:

Index: src/usr.bin/make/unit-tests/dep-none.exp
diff -u /dev/null src/usr.bin/make/unit-tests/dep-none.exp:1.1
--- /dev/null	Sat Aug 22 12:51:11 2020
+++ src/usr.bin/make/unit-tests/dep-none.exp	Sat Aug 22 12:51:11 2020
@@ -0,0 +1,4 @@
+make: no target to make.
+
+make: stopped in unit-tests
+exit status 2
Index: src/usr.bin/make/unit-tests/dep-none.mk
diff -u /dev/null src/usr.bin/make/unit-tests/dep-none.mk:1.1
--- /dev/null	Sat Aug 22 12:51:11 2020
+++ src/usr.bin/make/unit-tests/dep-none.mk	Sat Aug 22 12:51:11 2020
@@ -0,0 +1,3 @@
+# $NetBSD: dep-none.mk,v 1.1 2020/08/22 12:51:11 rillig Exp $
+#
+# Test for a Makefile that declares no target at all.



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

2020-08-22 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Aug 22 12:51:11 UTC 2020

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

Log Message:
make(1): add test for "no target to make"


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/dep-none.exp \
src/usr.bin/make/unit-tests/dep-none.mk

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



  1   2   >