CVS commit: src/sys/arch/evbmips/stand/sbmips

2021-03-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar 14 22:58:11 UTC 2021

Modified Files:
src/sys/arch/evbmips/stand/sbmips: Makefile.bootprogs Makefile.bootxx
src/sys/arch/evbmips/stand/sbmips/boot: Makefile
src/sys/arch/evbmips/stand/sbmips/netboot: Makefile

Log Message:
Specify the emulation explicitly (n32) so this builds when the default
emulation changes.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/evbmips/stand/sbmips/Makefile.bootprogs
cvs rdiff -u -r1.1.1.1 -r1.2 \
src/sys/arch/evbmips/stand/sbmips/Makefile.bootxx
cvs rdiff -u -r1.1.1.1 -r1.2 src/sys/arch/evbmips/stand/sbmips/boot/Makefile
cvs rdiff -u -r1.1.1.1 -r1.2 \
src/sys/arch/evbmips/stand/sbmips/netboot/Makefile

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



CVS commit: src/sys/arch/evbmips/stand/sbmips

2021-03-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar 14 22:58:11 UTC 2021

Modified Files:
src/sys/arch/evbmips/stand/sbmips: Makefile.bootprogs Makefile.bootxx
src/sys/arch/evbmips/stand/sbmips/boot: Makefile
src/sys/arch/evbmips/stand/sbmips/netboot: Makefile

Log Message:
Specify the emulation explicitly (n32) so this builds when the default
emulation changes.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/evbmips/stand/sbmips/Makefile.bootprogs
cvs rdiff -u -r1.1.1.1 -r1.2 \
src/sys/arch/evbmips/stand/sbmips/Makefile.bootxx
cvs rdiff -u -r1.1.1.1 -r1.2 src/sys/arch/evbmips/stand/sbmips/boot/Makefile
cvs rdiff -u -r1.1.1.1 -r1.2 \
src/sys/arch/evbmips/stand/sbmips/netboot/Makefile

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

Modified files:

Index: src/sys/arch/evbmips/stand/sbmips/Makefile.bootprogs
diff -u src/sys/arch/evbmips/stand/sbmips/Makefile.bootprogs:1.3 src/sys/arch/evbmips/stand/sbmips/Makefile.bootprogs:1.4
--- src/sys/arch/evbmips/stand/sbmips/Makefile.bootprogs:1.3	Mon Aug 21 12:36:00 2017
+++ src/sys/arch/evbmips/stand/sbmips/Makefile.bootprogs	Sun Mar 14 18:58:10 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.bootprogs,v 1.3 2017/08/21 16:36:00 christos Exp $
+# $NetBSD: Makefile.bootprogs,v 1.4 2021/03/14 22:58:10 christos Exp $
 
 NOSSP=yes
 NOPIE=yes
@@ -11,6 +11,14 @@ COMMON=	${.CURDIR}/../common
 
 .PATH:	${COMMON}
 
+.if ${MACHINE_ARCH:M*64*}
+.	if ${MACHINE_ARCH:M*eb}
+LDABI=	-melf32btsmipn32
+.	else
+LDABI=	-melf32ltsmipn32
+.	endif
+.endif
+
 STRIPFLAG=
 BINMODE= 444
 
@@ -31,6 +39,7 @@ CPPFLAGS+=	-nostdinc -I${.OBJDIR} -D_STA
 CFLAGS=		-Os -g -ffreestanding -mno-abicalls -msoft-float -G 0
 CFLAGS+=	-mips64
 CFLAGS+=	-Werror ${CWARNFLAGS}
+CPUFLAGS+=	-mabi=n32
 
 NETBSD_VERS!=${HOST_SH} ${S}/conf/osrelease.sh
 CPPFLAGS+= -DNETBSD_VERS='"${NETBSD_VERS}"'

Index: src/sys/arch/evbmips/stand/sbmips/Makefile.bootxx
diff -u src/sys/arch/evbmips/stand/sbmips/Makefile.bootxx:1.1.1.1 src/sys/arch/evbmips/stand/sbmips/Makefile.bootxx:1.2
--- src/sys/arch/evbmips/stand/sbmips/Makefile.bootxx:1.1.1.1	Mon Jul 24 04:56:29 2017
+++ src/sys/arch/evbmips/stand/sbmips/Makefile.bootxx	Sun Mar 14 18:58:10 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.bootxx,v 1.1.1.1 2017/07/24 08:56:29 mrg Exp $
+# $NetBSD: Makefile.bootxx,v 1.2 2021/03/14 22:58:10 christos Exp $
 
 SRCS = start.S bootxx.c booted_dev.c blkdev.c cfe.c cfe_api.c \
putstr.c panic_putstr.c 
@@ -31,7 +31,7 @@ SAMISCMAKEFLAGS= SA_INCLUDE_NET=no SA_US
 
 ${PROG}.sym: ${OBJS} ${LIBSA} ${LIBKERN}
 	${_MKTARGET_LINK}
-	${LD} -Ttext ${BOOT_RELOC} -N -e start -o ${PROG}.sym \
+	${LD} ${LDABI} -Ttext ${BOOT_RELOC} -N -e start -o ${PROG}.sym \
 	${OBJS} ${LIBSA} ${LIBKERN}
 	@chmod 644 ${PROG}.sym
 	@${SIZE} ${PROG}.sym

Index: src/sys/arch/evbmips/stand/sbmips/boot/Makefile
diff -u src/sys/arch/evbmips/stand/sbmips/boot/Makefile:1.1.1.1 src/sys/arch/evbmips/stand/sbmips/boot/Makefile:1.2
--- src/sys/arch/evbmips/stand/sbmips/boot/Makefile:1.1.1.1	Mon Jul 24 04:56:29 2017
+++ src/sys/arch/evbmips/stand/sbmips/boot/Makefile	Sun Mar 14 18:58:11 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.1.1.1 2017/07/24 08:56:29 mrg Exp $
+# $NetBSD: Makefile,v 1.2 2021/03/14 22:58:11 christos Exp $
 
 PROG = boot
 
@@ -27,6 +27,6 @@ SAMISCMAKEFLAGS= SA_INCLUDE_NET=no SA_US
 
 ${PROG}.sym: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${LDSCRIPT}
 	${_MKTARGET_LINK}
-	${LD} -T ${LDSCRIPT} -N -e start -o ${PROG}.sym \
+	${LD} ${LDABI} -T ${LDSCRIPT} -N -e start -o ${PROG}.sym \
 	${OBJS} ${LIBSA} ${LIBZ} ${LIBSA} ${LIBKERN}
 	${SIZE} ${PROG}.sym

Index: src/sys/arch/evbmips/stand/sbmips/netboot/Makefile
diff -u src/sys/arch/evbmips/stand/sbmips/netboot/Makefile:1.1.1.1 src/sys/arch/evbmips/stand/sbmips/netboot/Makefile:1.2
--- src/sys/arch/evbmips/stand/sbmips/netboot/Makefile:1.1.1.1	Mon Jul 24 04:56:29 2017
+++ src/sys/arch/evbmips/stand/sbmips/netboot/Makefile	Sun Mar 14 18:58:11 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.1.1.1 2017/07/24 08:56:29 mrg Exp $
+# $NetBSD: Makefile,v 1.2 2021/03/14 22:58:11 christos Exp $
 
 PROG = netboot
 
@@ -27,6 +27,6 @@ SAMISCMAKEFLAGS= SA_INCLUDE_NET=yes SA_U
 
 ${PROG}.sym: ${OBJS} ${LIBSA} ${LIBZ} ${LIBKERN} ${LDSCRIPT}
 	${_MKTARGET_LINK}
-	${LD} -T ${LDSCRIPT} -N -e start -o ${PROG}.sym \
+	${LD} ${LDABI} -T ${LDSCRIPT} -N -e start -o ${PROG}.sym \
 	${OBJS} ${LIBSA} ${LIBZ} ${LIBSA} ${LIBKERN} 
 	${SIZE} ${PROG}.sym



CVS commit: src/sys/rump/librump/rumpkern

2021-03-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar 14 22:56:39 UTC 2021

Modified Files:
src/sys/rump/librump/rumpkern: atomic_cas_generic.c

Log Message:
provide generic cas for _LP64


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/rump/librump/rumpkern/atomic_cas_generic.c

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



CVS commit: src/sys/rump/librump/rumpkern

2021-03-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar 14 22:56:39 UTC 2021

Modified Files:
src/sys/rump/librump/rumpkern: atomic_cas_generic.c

Log Message:
provide generic cas for _LP64


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/rump/librump/rumpkern/atomic_cas_generic.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/rump/librump/rumpkern/atomic_cas_generic.c
diff -u src/sys/rump/librump/rumpkern/atomic_cas_generic.c:1.2 src/sys/rump/librump/rumpkern/atomic_cas_generic.c:1.3
--- src/sys/rump/librump/rumpkern/atomic_cas_generic.c:1.2	Fri Dec 18 17:37:18 2009
+++ src/sys/rump/librump/rumpkern/atomic_cas_generic.c	Sun Mar 14 18:56:39 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: atomic_cas_generic.c,v 1.2 2009/12/18 22:37:18 pooka Exp $	*/
+/*	$NetBSD: atomic_cas_generic.c,v 1.3 2021/03/14 22:56:39 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: atomic_cas_generic.c,v 1.2 2009/12/18 22:37:18 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atomic_cas_generic.c,v 1.3 2021/03/14 22:56:39 christos Exp $");
 
 /*
  * This is basically common/lib/libc/atomic/atomic_init_testset.c
@@ -45,7 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: atomic_cas_g
 #define	I16	I2 I2 I2 I2 I2 I2 I2 I2
 #define	I128	I16 I16 I16 I16 I16 I16 I16 I16
 
-static __cpu_simple_lock_t atomic_locks[128] = { I128 };
+static __cpu_simple_lock_t atomic_locks32[128] = { I128 };
 
 uint32_t
 _atomic_cas_32(volatile uint32_t *ptr, uint32_t old, uint32_t new)
@@ -53,7 +53,7 @@ _atomic_cas_32(volatile uint32_t *ptr, u
 	__cpu_simple_lock_t *lock;
 	uint32_t ret;
 
-	lock = _locks[((uintptr_t)ptr >> 3) & 127];
+	lock = _locks32[((uintptr_t)ptr >> 3) & 127];
 	__cpu_simple_lock(lock);
 	ret = *ptr;
 	if (__predict_true(ret == old)) {
@@ -65,23 +65,62 @@ _atomic_cas_32(volatile uint32_t *ptr, u
 }
 
 #undef atomic_cas_32
+atomic_op_alias(atomic_cas_32,_atomic_cas_32)
+atomic_op_alias(atomic_cas_32_ni,_atomic_cas_32)
+__strong_alias(_atomic_cas_32_ni,_atomic_cas_32)
+
+#ifdef _LP64
+static __cpu_simple_lock_t atomic_locks64[128] = { I128 };
+
+uint64_t
+_atomic_cas_64(volatile uint64_t *ptr, uint64_t old, uint64_t new)
+{
+	__cpu_simple_lock_t *lock;
+	uint64_t ret;
+
+	lock = _locks64[((uintptr_t)ptr >> 4) & 127];
+	__cpu_simple_lock(lock);
+	ret = *ptr;
+	if (__predict_true(ret == old)) {
+		*ptr = new;
+	}
+	__cpu_simple_unlock(lock);
+
+	return ret;
+}
+
+#undef atomic_cas_64
+atomic_op_alias(atomic_cas_64,_atomic_cas_64)
+atomic_op_alias(atomic_cas_64_ni,_atomic_cas_64)
+__strong_alias(_atomic_cas_64_ni,_atomic_cas_64)
+
+#endif
+
 #undef atomic_cas_uint
 #undef atomic_cas_ulong
 #undef atomic_cas_ptr
 
-atomic_op_alias(atomic_cas_32,_atomic_cas_32)
 atomic_op_alias(atomic_cas_uint,_atomic_cas_32)
 __strong_alias(_atomic_cas_uint,_atomic_cas_32)
-atomic_op_alias(atomic_cas_ulong,_atomic_cas_32)
-__strong_alias(_atomic_cas_ulong,_atomic_cas_32)
-atomic_op_alias(atomic_cas_ptr,_atomic_cas_32)
-__strong_alias(_atomic_cas_ptr,_atomic_cas_32)
-
-atomic_op_alias(atomic_cas_32_ni,_atomic_cas_32)
-__strong_alias(_atomic_cas_32_ni,_atomic_cas_32)
 atomic_op_alias(atomic_cas_uint_ni,_atomic_cas_32)
 __strong_alias(_atomic_cas_uint_ni,_atomic_cas_32)
+
+#ifdef _LP64
+atomic_op_alias(atomic_cas_ulong,_atomic_cas_64)
+__strong_alias(_atomic_cas_ulong,_atomic_cas_64)
+atomic_op_alias(atomic_cas_ulong_ni,_atomic_cas_64)
+__strong_alias(_atomic_cas_ulong_ni,_atomic_cas_64)
+atomic_op_alias(atomic_cas_ptr,_atomic_cas_64)
+__strong_alias(_atomic_cas_ptr,_atomic_cas_64)
+atomic_op_alias(atomic_cas_ptr_ni,_atomic_cas_64)
+__strong_alias(_atomic_cas_ptr_ni,_atomic_cas_64)
+#else
+atomic_op_alias(atomic_cas_ulong,_atomic_cas_32)
+__strong_alias(_atomic_cas_ulong,_atomic_cas_32)
 atomic_op_alias(atomic_cas_ulong_ni,_atomic_cas_32)
 __strong_alias(_atomic_cas_ulong_ni,_atomic_cas_32)
+atomic_op_alias(atomic_cas_ptr,_atomic_cas_32)
+__strong_alias(_atomic_cas_ptr,_atomic_cas_32)
 atomic_op_alias(atomic_cas_ptr_ni,_atomic_cas_32)
 __strong_alias(_atomic_cas_ptr_ni,_atomic_cas_32)
+#endif



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

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 22:24:24 UTC 2021

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

Log Message:
tests/lint: document how lint discards the typedef name in 247


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_247.c
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_247.exp

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_247.c
diff -u src/tests/usr.bin/xlint/lint1/msg_247.c:1.4 src/tests/usr.bin/xlint/lint1/msg_247.c:1.5
--- src/tests/usr.bin/xlint/lint1/msg_247.c:1.4	Sun Mar 14 21:44:35 2021
+++ src/tests/usr.bin/xlint/lint1/msg_247.c	Sun Mar 14 22:24:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: msg_247.c,v 1.4 2021/03/14 21:44:35 rillig Exp $	*/
+/*	$NetBSD: msg_247.c,v 1.5 2021/03/14 22:24:24 rillig Exp $	*/
 # 3 "msg_247.c"
 
 // Test for message: pointer cast from '%s' to '%s' may be troublesome [247]
@@ -17,5 +17,16 @@ struct Other {
 void
 example(struct Other *arg)
 {
-	PDisplay display = (PDisplay)arg;	/* expect: 247 */
+	PDisplay display;
+
+	/*
+	 * XXX: The target type is reported as 'struct '.  In cases
+	 *  like these, it would be helpful to print at least the type name
+	 *  of the pointer.  This type name though is discarded immediately
+	 *  when the parser reduces 'T_TYPENAME clrtyp' to 'clrtyp_typespec'.
+	 *  After that, the target type of the cast is just an unnamed struct,
+	 *  with no hint at all that there is a typedef for a pointer to the
+	 *  struct.
+	 */
+	display = (PDisplay)arg;	/* expect: 247 */
 }

Index: src/tests/usr.bin/xlint/lint1/msg_247.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_247.exp:1.2 src/tests/usr.bin/xlint/lint1/msg_247.exp:1.3
--- src/tests/usr.bin/xlint/lint1/msg_247.exp:1.2	Sun Mar 14 21:44:35 2021
+++ src/tests/usr.bin/xlint/lint1/msg_247.exp	Sun Mar 14 22:24:24 2021
@@ -1 +1 @@
-msg_247.c(20): warning: pointer cast from 'pointer to struct Other' to 'pointer to struct ' may be troublesome [247]
+msg_247.c(31): warning: pointer cast from 'pointer to struct Other' to 'pointer to struct ' may be troublesome [247]



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

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 22:24:24 UTC 2021

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

Log Message:
tests/lint: document how lint discards the typedef name in 247


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/msg_247.c
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/msg_247.exp

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



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

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 21:44:35 UTC 2021

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

Log Message:
tests/lint: add test for message 247 for pointer to unnamed struct


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_247.c
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_247.exp

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/msg_247.c
diff -u src/tests/usr.bin/xlint/lint1/msg_247.c:1.3 src/tests/usr.bin/xlint/lint1/msg_247.c:1.4
--- src/tests/usr.bin/xlint/lint1/msg_247.c:1.3	Sun Feb 28 12:40:00 2021
+++ src/tests/usr.bin/xlint/lint1/msg_247.c	Sun Mar 14 21:44:35 2021
@@ -1,7 +1,21 @@
-/*	$NetBSD: msg_247.c,v 1.3 2021/02/28 12:40:00 rillig Exp $	*/
+/*	$NetBSD: msg_247.c,v 1.4 2021/03/14 21:44:35 rillig Exp $	*/
 # 3 "msg_247.c"
 
 // Test for message: pointer cast from '%s' to '%s' may be troublesome [247]
 
-TODO: "Add example code that triggers the above message." /* expect: 249 */
-TODO: "Add example code that almost triggers the above message."
+/* lint1-extra-flags: -c */
+
+/* example taken from Xlib.h */
+typedef struct {
+	int id;
+} *PDisplay;
+
+struct Other {
+	int id;
+};
+
+void
+example(struct Other *arg)
+{
+	PDisplay display = (PDisplay)arg;	/* expect: 247 */
+}

Index: src/tests/usr.bin/xlint/lint1/msg_247.exp
diff -u src/tests/usr.bin/xlint/lint1/msg_247.exp:1.1 src/tests/usr.bin/xlint/lint1/msg_247.exp:1.2
--- src/tests/usr.bin/xlint/lint1/msg_247.exp:1.1	Sat Jan  2 10:22:44 2021
+++ src/tests/usr.bin/xlint/lint1/msg_247.exp	Sun Mar 14 21:44:35 2021
@@ -1 +1 @@
-msg_247.c(6): syntax error ':' [249]
+msg_247.c(20): warning: pointer cast from 'pointer to struct Other' to 'pointer to struct ' may be troublesome [247]



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

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 21:44:35 UTC 2021

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

Log Message:
tests/lint: add test for message 247 for pointer to unnamed struct


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/msg_247.c
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/msg_247.exp

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



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

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 20:41:39 UTC 2021

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

Log Message:
tests/make: document today's bug fixes in the test


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/var-eval-short.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/var-eval-short.mk

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

Modified files:

Index: src/usr.bin/make/unit-tests/var-eval-short.exp
diff -u src/usr.bin/make/unit-tests/var-eval-short.exp:1.6 src/usr.bin/make/unit-tests/var-eval-short.exp:1.7
--- src/usr.bin/make/unit-tests/var-eval-short.exp:1.6	Sun Mar 14 19:29:37 2021
+++ src/usr.bin/make/unit-tests/var-eval-short.exp	Sun Mar 14 20:41:39 2021
@@ -1,14 +1,14 @@
-make: "var-eval-short.mk" line 63: Invalid time value: ${FAIL}}
-make: "var-eval-short.mk" line 63: Malformed conditional (0 && ${:Uword:gmtime=${FAIL}})
 make: "var-eval-short.mk" line 77: Invalid time value: ${FAIL}}
-make: "var-eval-short.mk" line 77: Malformed conditional (0 && ${:Uword:localtime=${FAIL}})
+make: "var-eval-short.mk" line 77: Malformed conditional (0 && ${:Uword:gmtime=${FAIL}})
+make: "var-eval-short.mk" line 91: Invalid time value: ${FAIL}}
+make: "var-eval-short.mk" line 91: Malformed conditional (0 && ${:Uword:localtime=${FAIL}})
 CondParser_Eval: 0 && ${0:?${FAIL}then:${FAIL}else}
 Var_Parse: ${0:?${FAIL}then:${FAIL}else} with none
 Applying ${0:?...} to "" (none, none, undefined)
 Modifier part: "${FAIL}then"
 Modifier part: "${FAIL}else"
 Result of ${0:?${FAIL}then:${FAIL}else} is "" (none, none, defined)
-ParseReadLine (142): 'DEFINED=	defined'
+ParseReadLine (156): 'DEFINED=	defined'
 Global:DEFINED = defined
 CondParser_Eval: 0 && ${DEFINED:L:?${FAIL}then:${FAIL}else}
 Var_Parse: ${DEFINED:L:?${FAIL}then:${FAIL}else} with none
@@ -18,7 +18,7 @@ Applying ${DEFINED:?...} to "defined" (n
 Modifier part: "${FAIL}then"
 Modifier part: "${FAIL}else"
 Result of ${DEFINED:?${FAIL}then:${FAIL}else} is "defined" (none, none, regular)
-ParseReadLine (145): '.MAKEFLAGS: -d0'
+ParseReadLine (159): '.MAKEFLAGS: -d0'
 ParseDoDependency(.MAKEFLAGS: -d0)
 Global:.MAKEFLAGS =  -r -k -d cpv -d
 Global:.MAKEFLAGS =  -r -k -d cpv -d 0

Index: src/usr.bin/make/unit-tests/var-eval-short.mk
diff -u src/usr.bin/make/unit-tests/var-eval-short.mk:1.3 src/usr.bin/make/unit-tests/var-eval-short.mk:1.4
--- src/usr.bin/make/unit-tests/var-eval-short.mk:1.3	Sun Mar 14 19:21:28 2021
+++ src/usr.bin/make/unit-tests/var-eval-short.mk	Sun Mar 14 20:41:39 2021
@@ -1,4 +1,4 @@
-# $NetBSD: var-eval-short.mk,v 1.3 2021/03/14 19:21:28 rillig Exp $
+# $NetBSD: var-eval-short.mk,v 1.4 2021/03/14 20:41:39 rillig Exp $
 #
 # Tests for each variable modifier to ensure that they only do the minimum
 # necessary computations.  If the result of the expression is not needed, they
@@ -34,20 +34,34 @@ FAIL=	${:!echo unexpected 1>&2!}
 .if 0 && ${0:?${FAIL}:${FAIL}}
 .endif
 
+# Before var.c,v 1.870 from 2021-03-14, the expression ${FAIL} was evaluated
+# after the loop, when undefining the temporary global loop variable.
 .if 0 && ${:Uword:@${FAIL}@expr@}
 .endif
 
 .if 0 && ${:Uword:@var@${FAIL}@}
 .endif
 
+# Before var.c,v 1.877 from 2021-03-14, the modifier ':[...]' did not expand
+# the nested expression ${FAIL} and then tried to parse the unexpanded text,
+# which failed since '$' is not a valid range character.
 .if 0 && ${:Uword:[${FAIL}]}
 .endif
 
+# Before var.c,v 1.867 from 2021-03-14, the modifier ':_' defined the variable
+# even though the whole expression should have only been parsed, not
+# evaluated.
 .if 0 && ${:Uword:_=VAR}
 .elif defined(VAR)
 .  error
 .endif
 
+# Before var.c,v 1.856 from 2021-03-14, the modifier ':C' did not expand the
+# nested expression ${FAIL} and then tried to compile the unexpanded text as a
+# regular expression, which failed both because of the '{FAIL}', which is not
+# a valid repetition, and because of the '', which are repeated
+# repetitions as well.
+# '${FAIL}'
 .if 0 && ${:Uword:C,${FAIL},,}
 .endif
 



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

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 20:41:39 UTC 2021

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

Log Message:
tests/make: document today's bug fixes in the test


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/var-eval-short.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/var-eval-short.mk

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 20:23:29 UTC 2021

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

Log Message:
make: fix documentation of VarFreeEnv

No functional change.


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

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 20:23:29 UTC 2021

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

Log Message:
make: fix documentation of VarFreeEnv

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.882 -r1.883 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.882 src/usr.bin/make/var.c:1.883
--- src/usr.bin/make/var.c:1.882	Sun Mar 14 20:18:33 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 20:23:29 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.882 2021/03/14 20:18:33 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.883 2021/03/14 20:23:29 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.882 2021/03/14 20:18:33 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.883 2021/03/14 20:23:29 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -461,13 +461,7 @@ VarFind(const char *name, GNode *scope, 
 	return var;
 }
 
-/*
- * If the variable is an environment variable, free it, including its value.
- *
- * Results:
- *	TRUE if it was an environment variable,
- *	FALSE if it is still a regular variable.
- */
+/* If the variable is an environment variable, free it, including its value. */
 static void
 VarFreeEnv(Var *v)
 {



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 20:18:33 UTC 2021

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

Log Message:
make: skip variable lookup for '::=' modifiers in parse-only mode

This is just to keep the code consistent among the various variable
modifiers.  The performance gain is negligible.

The actual assignment to the variable had already been skipped
previously.

No functional change.


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

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 20:18:33 UTC 2021

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

Log Message:
make: skip variable lookup for '::=' modifiers in parse-only mode

This is just to keep the code consistent among the various variable
modifiers.  The performance gain is negligible.

The actual assignment to the variable had already been skipped
previously.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.881 -r1.882 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.881 src/usr.bin/make/var.c:1.882
--- src/usr.bin/make/var.c:1.881	Sun Mar 14 20:12:16 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 20:18:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.881 2021/03/14 20:12:16 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.882 2021/03/14 20:18:33 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.881 2021/03/14 20:12:16 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.882 2021/03/14 20:18:33 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -3404,6 +3404,9 @@ ok:
 
 	(*pp)--;		/* Go back to the st->endc. */
 
+	if (!(expr->eflags & VARE_WANTRES))
+		goto done;
+
 	scope = expr->scope;	/* scope where v belongs */
 	if (expr->defined == DEF_REGULAR && expr->scope != SCOPE_GLOBAL) {
 		Var *gv = VarFind(expr->var->name.str, expr->scope, FALSE);
@@ -3414,33 +3417,32 @@ ok:
 	}
 
 	/* XXX: Expanding the variable name at this point sounds wrong. */
-	if (expr->eflags & VARE_WANTRES) {
-		switch (op[0]) {
-		case '+':
-			Var_AppendExpand(scope, expr->var->name.str, val);
-			break;
-		case '!': {
-			const char *errfmt;
-			char *cmd_output = Cmd_Exec(val, );
-			if (errfmt != NULL)
-Error(errfmt, val);
-			else
-Var_SetExpand(scope,
-expr->var->name.str, cmd_output);
-			free(cmd_output);
-			break;
-		}
-		case '?':
-			if (expr->defined == DEF_REGULAR)
-break;
-			/* FALLTHROUGH */
-		default:
-			Var_SetExpand(scope, expr->var->name.str, val);
+	switch (op[0]) {
+	case '+':
+		Var_AppendExpand(scope, expr->var->name.str, val);
+		break;
+	case '!': {
+		const char *errfmt;
+		char *cmd_output = Cmd_Exec(val, );
+		if (errfmt != NULL)
+			Error(errfmt, val);
+		else
+			Var_SetExpand(scope, expr->var->name.str, cmd_output);
+		free(cmd_output);
+		break;
+	}
+	case '?':
+		if (expr->defined == DEF_REGULAR)
 			break;
-		}
+		/* FALLTHROUGH */
+	default:
+		Var_SetExpand(scope, expr->var->name.str, val);
+		break;
 	}
-	free(val);
 	Expr_SetValueRefer(expr, "");
+
+done:
+	free(val);
 	return AMR_OK;
 }
 



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 20:12:16 UTC 2021

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

Log Message:
make: separate parsing and evaluating for modifier '::='

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.880 -r1.881 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.880 src/usr.bin/make/var.c:1.881
--- src/usr.bin/make/var.c:1.880	Sun Mar 14 20:09:26 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 20:12:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.880 2021/03/14 20:09:26 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.881 2021/03/14 20:12:16 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.880 2021/03/14 20:09:26 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.881 2021/03/14 20:12:16 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -3372,8 +3372,6 @@ ApplyModifier_Assign(const char **pp, Ap
 	char *val;
 	VarParseResult res;
 
-	/* TODO: separate parsing from evaluating */
-
 	const char *mod = *pp;
 	const char *op = mod + 1;
 
@@ -3389,15 +3387,6 @@ ok:
 		return AMR_BAD;
 	}
 
-	scope = expr->scope;	/* scope where v belongs */
-	if (expr->defined == DEF_REGULAR && expr->scope != SCOPE_GLOBAL) {
-		Var *gv = VarFind(expr->var->name.str, expr->scope, FALSE);
-		if (gv == NULL)
-			scope = SCOPE_GLOBAL;
-		else
-			VarFreeEnv(gv);
-	}
-
 	switch (op[0]) {
 	case '+':
 	case '?':
@@ -3415,6 +3404,15 @@ ok:
 
 	(*pp)--;		/* Go back to the st->endc. */
 
+	scope = expr->scope;	/* scope where v belongs */
+	if (expr->defined == DEF_REGULAR && expr->scope != SCOPE_GLOBAL) {
+		Var *gv = VarFind(expr->var->name.str, expr->scope, FALSE);
+		if (gv == NULL)
+			scope = SCOPE_GLOBAL;
+		else
+			VarFreeEnv(gv);
+	}
+
 	/* XXX: Expanding the variable name at this point sounds wrong. */
 	if (expr->eflags & VARE_WANTRES) {
 		switch (op[0]) {



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 20:12:16 UTC 2021

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

Log Message:
make: separate parsing and evaluating for modifier '::='

No functional change.


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

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 20:09:26 UTC 2021

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

Log Message:
make: in parse-only mode, do not update the expression value in ':sh'

No functional change outside debug mode.  The other variable modifiers
behave in the same way.


To generate a diff of this commit:
cvs rdiff -u -r1.879 -r1.880 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.879 src/usr.bin/make/var.c:1.880
--- src/usr.bin/make/var.c:1.879	Sun Mar 14 20:03:56 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 20:09:26 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.879 2021/03/14 20:03:56 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.880 2021/03/14 20:09:26 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.879 2021/03/14 20:03:56 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.880 2021/03/14 20:09:26 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -3586,15 +3586,6 @@ ApplyModifier_SunShell(const char **pp, 
 		if (errfmt != NULL)
 			Error(errfmt, expr->value.str);
 		Expr_SetValueOwn(expr, output);
-	} else {
-		/*
-		 * TODO: Check whether returning ":sh" would be
-		 *  more consistent with the other modifiers.
-		 *
-		 * TODO: Add a unit test demonstrating that the
-		 *  actual value of this expression has any effect.
-		 */
-		Expr_SetValueRefer(expr, "");
 	}
 
 	return AMR_OK;



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 20:09:26 UTC 2021

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

Log Message:
make: in parse-only mode, do not update the expression value in ':sh'

No functional change outside debug mode.  The other variable modifiers
behave in the same way.


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

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 20:03:56 UTC 2021

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

Log Message:
make: do not evaluate the ':O' modifiers in parse-only mode

No functional change in practical usage.  Theoretically this change can
be observed by looking at the generated random numbers for the ':Ox'
modifier, but the quality or exact sequence of these random numbers is
not guaranteed anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.878 -r1.879 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.878 src/usr.bin/make/var.c:1.879
--- src/usr.bin/make/var.c:1.878	Sun Mar 14 20:00:48 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 20:03:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.878 2021/03/14 20:00:48 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.879 2021/03/14 20:03:56 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.878 2021/03/14 20:00:48 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.879 2021/03/14 20:03:56 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -3275,6 +3275,9 @@ ApplyModifier_Order(const char **pp, App
 	} else
 		return AMR_BAD;
 
+	if (!(st->expr->eflags & VARE_WANTRES))
+		return AMR_OK;
+
 	words = Str_Words(st->expr->value.str, FALSE);
 	if (mode == SHUFFLE)
 		ShuffleStrings(words.words, words.len);



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 20:03:56 UTC 2021

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

Log Message:
make: do not evaluate the ':O' modifiers in parse-only mode

No functional change in practical usage.  Theoretically this change can
be observed by looking at the generated random numbers for the ':Ox'
modifier, but the quality or exact sequence of these random numbers is
not guaranteed anyway.


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

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 20:00:48 UTC 2021

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

Log Message:
make: separate parsing and evaluating in the ':O' modifiers

No functional change.


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

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 20:00:48 UTC 2021

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

Log Message:
make: separate parsing and evaluating in the ':O' modifiers

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.877 -r1.878 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.877 src/usr.bin/make/var.c:1.878
--- src/usr.bin/make/var.c:1.877	Sun Mar 14 19:29:37 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 20:00:48 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.877 2021/03/14 19:29:37 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.878 2021/03/14 20:00:48 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.877 2021/03/14 19:29:37 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.878 2021/03/14 20:00:48 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -3261,31 +3261,28 @@ static ApplyModifierResult
 ApplyModifier_Order(const char **pp, ApplyModifiersState *st)
 {
 	const char *mod = (*pp)++;	/* skip past the 'O' in any case */
-
-	/* TODO: separate parsing from evaluating */
-
-	Words words = Str_Words(st->expr->value.str, FALSE);
+	Words words;
+	enum SortMode {
+		ASC, DESC, SHUFFLE
+	} mode;
 
 	if (IsDelimiter(mod[1], st)) {
-		/* :O sorts ascending */
-		qsort(words.words, words.len, sizeof words.words[0],
-		str_cmp_asc);
-
+		mode = ASC;
 	} else if ((mod[1] == 'r' || mod[1] == 'x') &&
 	IsDelimiter(mod[2], st)) {
 		(*pp)++;
-
-		if (mod[1] == 'r') {	/* :Or sorts descending */
-			qsort(words.words, words.len, sizeof words.words[0],
-			str_cmp_desc);
-		} else
-			ShuffleStrings(words.words, words.len);
-	} else {
-		Words_Free(words);
+		mode = mod[1] == 'r' ? DESC : SHUFFLE;
+	} else
 		return AMR_BAD;
-	}
 
+	words = Str_Words(st->expr->value.str, FALSE);
+	if (mode == SHUFFLE)
+		ShuffleStrings(words.words, words.len);
+	else
+		qsort(words.words, words.len, sizeof words.words[0],
+		mode == ASC ? str_cmp_asc : str_cmp_desc);
 	Expr_SetValueOwn(st->expr, Words_JoinFree(words));
+
 	return AMR_OK;
 }
 



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 19:29:37 UTC 2021

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

Log Message:
make: do not evaluate modifier ':[...]' in parse-only mode

In parse-only mode, variable expressions in the argument to that
modifier are not resolved.  This led to the error message about the 'Bad
modifier' in var-eval-short.mk.


To generate a diff of this commit:
cvs rdiff -u -r1.876 -r1.877 src/usr.bin/make/var.c
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/var-eval-short.exp

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 19:29:37 UTC 2021

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

Log Message:
make: do not evaluate modifier ':[...]' in parse-only mode

In parse-only mode, variable expressions in the argument to that
modifier are not resolved.  This led to the error message about the 'Bad
modifier' in var-eval-short.mk.


To generate a diff of this commit:
cvs rdiff -u -r1.876 -r1.877 src/usr.bin/make/var.c
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/var-eval-short.exp

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.876 src/usr.bin/make/var.c:1.877
--- src/usr.bin/make/var.c:1.876	Sun Mar 14 19:25:05 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 19:29:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.876 2021/03/14 19:25:05 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.877 2021/03/14 19:29:37 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.876 2021/03/14 19:25:05 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.877 2021/03/14 19:29:37 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -3151,6 +3151,9 @@ ApplyModifier_Words(const char **pp, App
 	if (!IsDelimiter(**pp, st))
 		goto bad_modifier;		/* Found junk after ']' */
 
+	if (!(expr->eflags & VARE_WANTRES))
+		goto ok;
+
 	if (estr[0] == '\0')
 		goto bad_modifier;			/* Found ":[]". */
 

Index: src/usr.bin/make/unit-tests/var-eval-short.exp
diff -u src/usr.bin/make/unit-tests/var-eval-short.exp:1.5 src/usr.bin/make/unit-tests/var-eval-short.exp:1.6
--- src/usr.bin/make/unit-tests/var-eval-short.exp:1.5	Sun Mar 14 19:21:28 2021
+++ src/usr.bin/make/unit-tests/var-eval-short.exp	Sun Mar 14 19:29:37 2021
@@ -1,5 +1,3 @@
-make: Bad modifier ":[${FAIL" for variable ""
-make: "var-eval-short.mk" line 43: Malformed conditional (0 && ${:Uword:[${FAIL}]})
 make: "var-eval-short.mk" line 63: Invalid time value: ${FAIL}}
 make: "var-eval-short.mk" line 63: Malformed conditional (0 && ${:Uword:gmtime=${FAIL}})
 make: "var-eval-short.mk" line 77: Invalid time value: ${FAIL}}



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 19:25:05 UTC 2021

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

Log Message:
make: do not evaluate modifiers ':M' and ':N' in parse-only mode

No functional change outside debug mode (-dv for ModifyWord_Match).


To generate a diff of this commit:
cvs rdiff -u -r1.875 -r1.876 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.875 src/usr.bin/make/var.c:1.876
--- src/usr.bin/make/var.c:1.875	Sun Mar 14 19:21:28 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 19:25:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.875 2021/03/14 19:21:28 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.876 2021/03/14 19:25:05 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.875 2021/03/14 19:21:28 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.876 2021/03/14 19:25:05 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -2811,14 +2811,17 @@ ParseModifier_Match(const char **pp, con
 static ApplyModifierResult
 ApplyModifier_Match(const char **pp, ApplyModifiersState *st)
 {
-	const char *mod = *pp;
+	const char mod = **pp;
 	char *pattern;
-	ModifyWordProc modifyWord;
 
 	ParseModifier_Match(pp, st, );
 
-	modifyWord = mod[0] == 'M' ? ModifyWord_Match : ModifyWord_NoMatch;
-	ModifyWords(st, modifyWord, pattern, st->oneBigWord);
+	if (st->expr->eflags & VARE_WANTRES) {
+		ModifyWordProc modifyWord =
+		mod == 'M' ? ModifyWord_Match : ModifyWord_NoMatch;
+		ModifyWords(st, modifyWord, pattern, st->oneBigWord);
+	}
+
 	free(pattern);
 	return AMR_OK;
 }



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 19:25:05 UTC 2021

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

Log Message:
make: do not evaluate modifiers ':M' and ':N' in parse-only mode

No functional change outside debug mode (-dv for ModifyWord_Match).


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

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 19:21:29 UTC 2021

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

Log Message:
make: do not return unevaluated 'else' part from the ':?' modifier

No functional change outside debug mode.


To generate a diff of this commit:
cvs rdiff -u -r1.874 -r1.875 src/usr.bin/make/var.c
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/var-eval-short.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-eval-short.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.874 src/usr.bin/make/var.c:1.875
--- src/usr.bin/make/var.c:1.874	Sun Mar 14 18:30:24 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 19:21:28 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.874 2021/03/14 18:30:24 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.875 2021/03/14 19:21:28 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.874 2021/03/14 18:30:24 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.875 2021/03/14 19:21:28 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -3322,7 +3322,10 @@ ApplyModifier_IfElse(const char **pp, Ap
 		return AMR_CLEANUP;
 	}
 
-	if (value) {
+	if (!(expr->eflags & VARE_WANTRES)) {
+		free(then_expr);
+		free(else_expr);
+	} else if (value) {
 		Expr_SetValueOwn(expr, then_expr);
 		free(else_expr);
 	} else {

Index: src/usr.bin/make/unit-tests/var-eval-short.exp
diff -u src/usr.bin/make/unit-tests/var-eval-short.exp:1.4 src/usr.bin/make/unit-tests/var-eval-short.exp:1.5
--- src/usr.bin/make/unit-tests/var-eval-short.exp:1.4	Sun Mar 14 19:16:41 2021
+++ src/usr.bin/make/unit-tests/var-eval-short.exp	Sun Mar 14 19:21:28 2021
@@ -9,8 +9,8 @@ Var_Parse: ${0:?${FAIL}then:${FAIL}else}
 Applying ${0:?...} to "" (none, none, undefined)
 Modifier part: "${FAIL}then"
 Modifier part: "${FAIL}else"
-Result of ${0:?${FAIL}then:${FAIL}else} is "${FAIL}else" (none, none, defined)
-ParseReadLine (141): 'DEFINED=	defined'
+Result of ${0:?${FAIL}then:${FAIL}else} is "" (none, none, defined)
+ParseReadLine (142): 'DEFINED=	defined'
 Global:DEFINED = defined
 CondParser_Eval: 0 && ${DEFINED:L:?${FAIL}then:${FAIL}else}
 Var_Parse: ${DEFINED:L:?${FAIL}then:${FAIL}else} with none
@@ -19,8 +19,8 @@ Result of ${DEFINED:L} is "defined" (non
 Applying ${DEFINED:?...} to "defined" (none, none, regular)
 Modifier part: "${FAIL}then"
 Modifier part: "${FAIL}else"
-Result of ${DEFINED:?${FAIL}then:${FAIL}else} is "${FAIL}else" (none, none, regular)
-ParseReadLine (144): '.MAKEFLAGS: -d0'
+Result of ${DEFINED:?${FAIL}then:${FAIL}else} is "defined" (none, none, regular)
+ParseReadLine (145): '.MAKEFLAGS: -d0'
 ParseDoDependency(.MAKEFLAGS: -d0)
 Global:.MAKEFLAGS =  -r -k -d cpv -d
 Global:.MAKEFLAGS =  -r -k -d cpv -d 0

Index: src/usr.bin/make/unit-tests/var-eval-short.mk
diff -u src/usr.bin/make/unit-tests/var-eval-short.mk:1.2 src/usr.bin/make/unit-tests/var-eval-short.mk:1.3
--- src/usr.bin/make/unit-tests/var-eval-short.mk:1.2	Sun Mar 14 19:16:41 2021
+++ src/usr.bin/make/unit-tests/var-eval-short.mk	Sun Mar 14 19:21:28 2021
@@ -1,4 +1,4 @@
-# $NetBSD: var-eval-short.mk,v 1.2 2021/03/14 19:16:41 rillig Exp $
+# $NetBSD: var-eval-short.mk,v 1.3 2021/03/14 19:21:28 rillig Exp $
 #
 # Tests for each variable modifier to ensure that they only do the minimum
 # necessary computations.  If the result of the expression is not needed, they
@@ -125,7 +125,7 @@ DEFINED=	# defined
 .if 0 && ${:Uword:word=replacement}
 .endif
 
-# Before var.c 1.XXX from 2021-03-14, Var_Parse returned "${FAIL}else" for the
+# Before var.c 1.875 from 2021-03-14, Var_Parse returned "${FAIL}else" for the
 # irrelevant right-hand side of the condition, even though this was not
 # necessary.  Since the return value from Var_Parse is supposed to be ignored
 # anyway, and since it is actually ignored in an overly complicated way,
@@ -137,7 +137,8 @@ DEFINED=	# defined
 # The ':L' is applied before the ':?' modifier, giving the expression a name
 # and a value, just to see whether this value gets passed through or whether
 # the parse-only mode results in an empty string (only visible in the debug
-# log).
+# log).  As of var.c 1.875 from 2021-03-14, the value of the variable gets
+# through, even though an empty string would suffice.
 DEFINED=	defined
 .if 0 && ${DEFINED:L:?${FAIL}then:${FAIL}else}
 .endif



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 19:21:29 UTC 2021

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

Log Message:
make: do not return unevaluated 'else' part from the ':?' modifier

No functional change outside debug mode.


To generate a diff of this commit:
cvs rdiff -u -r1.874 -r1.875 src/usr.bin/make/var.c
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/var-eval-short.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-eval-short.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

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 19:16:41 UTC 2021

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

Log Message:
tests/make: add test for the ':?' modifier in parse-only mode

The debug output for this scenario will change a bit in an upcoming
commit, but that will not affect anything outside the debug log.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/var-eval-short.exp
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-eval-short.mk

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

Modified files:

Index: src/usr.bin/make/unit-tests/var-eval-short.exp
diff -u src/usr.bin/make/unit-tests/var-eval-short.exp:1.3 src/usr.bin/make/unit-tests/var-eval-short.exp:1.4
--- src/usr.bin/make/unit-tests/var-eval-short.exp:1.3	Sun Mar 14 18:02:44 2021
+++ src/usr.bin/make/unit-tests/var-eval-short.exp	Sun Mar 14 19:16:41 2021
@@ -4,6 +4,26 @@ make: "var-eval-short.mk" line 63: Inval
 make: "var-eval-short.mk" line 63: Malformed conditional (0 && ${:Uword:gmtime=${FAIL}})
 make: "var-eval-short.mk" line 77: Invalid time value: ${FAIL}}
 make: "var-eval-short.mk" line 77: Malformed conditional (0 && ${:Uword:localtime=${FAIL}})
+CondParser_Eval: 0 && ${0:?${FAIL}then:${FAIL}else}
+Var_Parse: ${0:?${FAIL}then:${FAIL}else} with none
+Applying ${0:?...} to "" (none, none, undefined)
+Modifier part: "${FAIL}then"
+Modifier part: "${FAIL}else"
+Result of ${0:?${FAIL}then:${FAIL}else} is "${FAIL}else" (none, none, defined)
+ParseReadLine (141): 'DEFINED=	defined'
+Global:DEFINED = defined
+CondParser_Eval: 0 && ${DEFINED:L:?${FAIL}then:${FAIL}else}
+Var_Parse: ${DEFINED:L:?${FAIL}then:${FAIL}else} with none
+Applying ${DEFINED:L} to "defined" (none, none, regular)
+Result of ${DEFINED:L} is "defined" (none, none, regular)
+Applying ${DEFINED:?...} to "defined" (none, none, regular)
+Modifier part: "${FAIL}then"
+Modifier part: "${FAIL}else"
+Result of ${DEFINED:?${FAIL}then:${FAIL}else} is "${FAIL}else" (none, none, regular)
+ParseReadLine (144): '.MAKEFLAGS: -d0'
+ParseDoDependency(.MAKEFLAGS: -d0)
+Global:.MAKEFLAGS =  -r -k -d cpv -d
+Global:.MAKEFLAGS =  -r -k -d cpv -d 0
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/var-eval-short.mk
diff -u src/usr.bin/make/unit-tests/var-eval-short.mk:1.1 src/usr.bin/make/unit-tests/var-eval-short.mk:1.2
--- src/usr.bin/make/unit-tests/var-eval-short.mk:1.1	Sun Mar 14 11:49:37 2021
+++ src/usr.bin/make/unit-tests/var-eval-short.mk	Sun Mar 14 19:16:41 2021
@@ -1,4 +1,4 @@
-# $NetBSD: var-eval-short.mk,v 1.1 2021/03/14 11:49:37 rillig Exp $
+# $NetBSD: var-eval-short.mk,v 1.2 2021/03/14 19:16:41 rillig Exp $
 #
 # Tests for each variable modifier to ensure that they only do the minimum
 # necessary computations.  If the result of the expression is not needed, they
@@ -125,4 +125,22 @@ DEFINED=	# defined
 .if 0 && ${:Uword:word=replacement}
 .endif
 
+# Before var.c 1.XXX from 2021-03-14, Var_Parse returned "${FAIL}else" for the
+# irrelevant right-hand side of the condition, even though this was not
+# necessary.  Since the return value from Var_Parse is supposed to be ignored
+# anyway, and since it is actually ignored in an overly complicated way,
+# an empty string suffices.
+.MAKEFLAGS: -dcpv
+.if 0 && ${0:?${FAIL}then:${FAIL}else}
+.endif
+
+# The ':L' is applied before the ':?' modifier, giving the expression a name
+# and a value, just to see whether this value gets passed through or whether
+# the parse-only mode results in an empty string (only visible in the debug
+# log).
+DEFINED=	defined
+.if 0 && ${DEFINED:L:?${FAIL}then:${FAIL}else}
+.endif
+.MAKEFLAGS: -d0
+
 all:



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

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 19:16:41 UTC 2021

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

Log Message:
tests/make: add test for the ':?' modifier in parse-only mode

The debug output for this scenario will change a bit in an upcoming
commit, but that will not affect anything outside the debug log.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/var-eval-short.exp
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-eval-short.mk

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 18:30:24 UTC 2021

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

Log Message:
make: do not evaluate ':gmtime' and ':localtime' in parse-only mode

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.873 -r1.874 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.873 src/usr.bin/make/var.c:1.874
--- src/usr.bin/make/var.c:1.873	Sun Mar 14 18:23:44 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 18:30:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.873 2021/03/14 18:23:44 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.874 2021/03/14 18:30:24 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.873 2021/03/14 18:23:44 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.874 2021/03/14 18:30:24 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -2568,8 +2568,9 @@ ApplyModifier_Gmtime(const char **pp, Ap
 		*pp = mod + 6;
 	}
 
-	Expr_SetValueOwn(st->expr,
-	VarStrftime(st->expr->value.str, TRUE, utc));
+	if (st->expr->eflags & VARE_WANTRES)
+		Expr_SetValueOwn(st->expr,
+		VarStrftime(st->expr->value.str, TRUE, utc));
 
 	return AMR_OK;
 }
@@ -2597,8 +2598,9 @@ ApplyModifier_Localtime(const char **pp,
 		*pp = mod + 9;
 	}
 
-	Expr_SetValueOwn(st->expr,
-	VarStrftime(st->expr->value.str, FALSE, utc));
+	if (st->expr->eflags & VARE_WANTRES)
+		Expr_SetValueOwn(st->expr,
+		VarStrftime(st->expr->value.str, FALSE, utc));
 
 	return AMR_OK;
 }



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 18:30:24 UTC 2021

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

Log Message:
make: do not evaluate ':gmtime' and ':localtime' in parse-only mode

No functional change.


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

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 18:23:44 UTC 2021

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

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

This affects the modifiers ':E', ':H', ':P', ':Q', ':R', ':T', ':hash',
':q', ':range', ':tl', ':ts', ':tu', and ':u'.  All these modifiers are
side-effect free.

Skipping the evaluation for these modifiers is purely for code
consistency and performance.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.872 -r1.873 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.872 src/usr.bin/make/var.c:1.873
--- src/usr.bin/make/var.c:1.872	Sun Mar 14 18:10:57 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 18:23:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.872 2021/03/14 18:10:57 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.873 2021/03/14 18:23:44 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.872 2021/03/14 18:10:57 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.873 2021/03/14 18:23:44 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -2611,7 +2611,8 @@ ApplyModifier_Hash(const char **pp, Appl
 		return AMR_UNKNOWN;
 	*pp += 4;
 
-	Expr_SetValueOwn(st->expr, VarHash(st->expr->value.str));
+	if (st->expr->eflags & VARE_WANTRES)
+		Expr_SetValueOwn(st->expr, VarHash(st->expr->value.str));
 
 	return AMR_OK;
 }
@@ -2626,6 +2627,9 @@ ApplyModifier_Path(const char **pp, Appl
 
 	(*pp)++;
 
+	if (!(st->expr->eflags & VARE_WANTRES))
+		return AMR_OK;
+
 	Expr_Define(expr);
 
 	gn = Targ_FindNode(expr->var->name.str);
@@ -2700,6 +2704,9 @@ ApplyModifier_Range(const char **pp, App
 		*pp = mod + 5;
 	}
 
+	if (!(st->expr->eflags & VARE_WANTRES))
+		return AMR_OK;
+
 	if (n == 0) {
 		Words words = Str_Words(st->expr->value.str, FALSE);
 		n = words.len;
@@ -2949,7 +2956,9 @@ ApplyModifier_Quote(const char **pp, App
 		return AMR_UNKNOWN;
 	(*pp)++;
 
-	Expr_SetValueOwn(st->expr, VarQuote(st->expr->value.str, quoteDollar));
+	if (st->expr->eflags & VARE_WANTRES)
+		Expr_SetValueOwn(st->expr,
+		VarQuote(st->expr->value.str, quoteDollar));
 
 	return AMR_OK;
 }
@@ -2967,6 +2976,13 @@ ApplyModifier_ToSep(const char **pp, App
 {
 	const char *sep = *pp + 2;
 
+	/*
+	 * Even if VARE_WANTRES is not set, proceed as normal since there is
+	 * neither any observable side effect nor a performance penalty.
+	 * Checking for VARE_WANTRES for every single piece of code in here
+	 * would make the code in this function too hard to read.
+	 */
+
 	/* ":ts" or ":ts:" */
 	if (sep[0] != st->endc && IsDelimiter(sep[1], st)) {
 		*pp = sep + 1;
@@ -3089,13 +3105,15 @@ ApplyModifier_To(const char **pp, ApplyM
 
 	if (mod[1] == 'u') {/* :tu */
 		*pp = mod + 2;
-		Expr_SetValueOwn(expr, str_toupper(expr->value.str));
+		if (st->expr->eflags & VARE_WANTRES)
+			Expr_SetValueOwn(expr, str_toupper(expr->value.str));
 		return AMR_OK;
 	}
 
 	if (mod[1] == 'l') {/* :tl */
 		*pp = mod + 2;
-		Expr_SetValueOwn(expr, str_tolower(expr->value.str));
+		if (st->expr->eflags & VARE_WANTRES)
+			Expr_SetValueOwn(expr, str_tolower(expr->value.str));
 		return AMR_OK;
 	}
 
@@ -3464,7 +3482,8 @@ ApplyModifier_WordFunc(const char **pp, 
 		return AMR_UNKNOWN;
 	(*pp)++;
 
-	ModifyWords(st, modifyWord, NULL, st->oneBigWord);
+	if (st->expr->eflags & VARE_WANTRES)
+		ModifyWords(st, modifyWord, NULL, st->oneBigWord);
 
 	return AMR_OK;
 }
@@ -3476,7 +3495,8 @@ ApplyModifier_Unique(const char **pp, Ap
 		return AMR_UNKNOWN;
 	(*pp)++;
 
-	Expr_SetValueOwn(st->expr, VarUniq(st->expr->value.str));
+	if (st->expr->eflags & VARE_WANTRES)
+		Expr_SetValueOwn(st->expr, VarUniq(st->expr->value.str));
 
 	return AMR_OK;
 }



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 18:23:44 UTC 2021

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

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

This affects the modifiers ':E', ':H', ':P', ':Q', ':R', ':T', ':hash',
':q', ':range', ':tl', ':ts', ':tu', and ':u'.  All these modifiers are
side-effect free.

Skipping the evaluation for these modifiers is purely for code
consistency and performance.

No functional change.


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

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 18:10:57 UTC 2021

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

Log Message:
make: skip strdup when parsing an irrelevant ':L' modifier

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.871 -r1.872 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.871 src/usr.bin/make/var.c:1.872
--- src/usr.bin/make/var.c:1.871	Sun Mar 14 18:08:25 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 18:10:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.871 2021/03/14 18:08:25 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.872 2021/03/14 18:10:57 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.871 2021/03/14 18:08:25 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.872 2021/03/14 18:10:57 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -2518,8 +2518,10 @@ ApplyModifier_Literal(const char **pp, A
 
 	(*pp)++;
 
-	Expr_Define(expr);
-	Expr_SetValueOwn(expr, bmake_strdup(expr->var->name.str));
+	if (expr->eflags & VARE_WANTRES) {
+		Expr_Define(expr);
+		Expr_SetValueOwn(expr, bmake_strdup(expr->var->name.str));
+	}
 
 	return AMR_OK;
 }



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 18:10:57 UTC 2021

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

Log Message:
make: skip strdup when parsing an irrelevant ':L' modifier

No functional change.


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

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 18:08:25 UTC 2021

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

Log Message:
make: skip memcpy when parsing but not evaluating ':D' and ':U'

No functional change, just a tiny bit of performance improvement,
probably not even measurable.  Having the code nevertheless serves as a
copy-and-paste template for implementing other modifiers that might
perform more costly tasks.


To generate a diff of this commit:
cvs rdiff -u -r1.870 -r1.871 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.870 src/usr.bin/make/var.c:1.871
--- src/usr.bin/make/var.c:1.870	Sun Mar 14 18:02:44 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 18:08:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.870 2021/03/14 18:02:44 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.871 2021/03/14 18:08:25 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.870 2021/03/14 18:02:44 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.871 2021/03/14 18:08:25 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -2488,7 +2488,8 @@ ApplyModifier_Defined(const char **pp, A
 
 			(void)Var_Parse(, expr->scope, eflags, _val);
 			/* TODO: handle errors */
-			Buf_AddStr(, nested_val.str);
+			if (expr->eflags & VARE_WANTRES)
+Buf_AddStr(, nested_val.str);
 			FStr_Done(_val);
 			continue;
 		}



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 18:08:25 UTC 2021

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

Log Message:
make: skip memcpy when parsing but not evaluating ':D' and ':U'

No functional change, just a tiny bit of performance improvement,
probably not even measurable.  Having the code nevertheless serves as a
copy-and-paste template for implementing other modifiers that might
perform more costly tasks.


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

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 18:02:44 UTC 2021

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

Log Message:
make: only evaluate the ':@' modifier if the result is actually used

The test 'var-eval-short' had produced the output 'unexpected' before,
on stderr.  It had been generated by '${:Uword:@${FAIL}@expr@}' by
combining the following obscure "features" of make:

1.  the ':@' modifier loops over the words of the variable.  This
modifier is not really obscure, it still takes some time to get used
to it.

2.  the ':@' modifier allows a '$' sign in the variable name, which is
useless in practice.

3.  the ':@' modifier creates a temporary loop variable in the global
namespace.  Luckily there are only few collisions with other
variable names since their naming conventions differ.

4.  after looping over the words of the expression, the temporary global
loop variable is deleted, and at that point the '$' is expanded,
being interpreted as the start of a variable expression.

5.  The ':@' modifier deleted the global variable even when it was
called in parse-only mode (without VARE_WANTRES).

When the modifier ':@' was initially added to make in var.c 1.40 from
2000-04-29, Var_Delete didn't expand the variable name.  That feature
was added in var.c 1.174 from 2013-05-18, probably without thinking of
this very edge-casey combination of features.

This commit fixes item 5 from the above list.  The other obscurities
remain for now.


To generate a diff of this commit:
cvs rdiff -u -r1.869 -r1.870 src/usr.bin/make/var.c
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-eval-short.exp

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.869 src/usr.bin/make/var.c:1.870
--- src/usr.bin/make/var.c:1.869	Sun Mar 14 17:38:24 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 18:02:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.869 2021/03/14 17:38:24 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.870 2021/03/14 18:02:44 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.869 2021/03/14 17:38:24 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.870 2021/03/14 18:02:44 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -2429,6 +2429,9 @@ ApplyModifier_Loop(const char **pp, Appl
 	if (res != VPR_OK)
 		return AMR_CLEANUP;
 
+	if (!(expr->eflags & VARE_WANTRES))
+		goto done;
+
 	args.eflags = expr->eflags & ~(unsigned)VARE_KEEP_DOLLAR;
 	prev_sep = st->sep;
 	st->sep = ' ';		/* XXX: should be st->sep for consistency */
@@ -2440,6 +2443,8 @@ ApplyModifier_Loop(const char **pp, Appl
 	 * ModifyWord_Loop.
 	 */
 	Var_DeleteExpand(expr->scope, args.tvar);
+
+done:
 	free(args.tvar);
 	free(args.str);
 	return AMR_OK;

Index: src/usr.bin/make/unit-tests/var-eval-short.exp
diff -u src/usr.bin/make/unit-tests/var-eval-short.exp:1.2 src/usr.bin/make/unit-tests/var-eval-short.exp:1.3
--- src/usr.bin/make/unit-tests/var-eval-short.exp:1.2	Sun Mar 14 16:43:30 2021
+++ src/usr.bin/make/unit-tests/var-eval-short.exp	Sun Mar 14 18:02:44 2021
@@ -1,4 +1,3 @@
-unexpected
 make: Bad modifier ":[${FAIL" for variable ""
 make: "var-eval-short.mk" line 43: Malformed conditional (0 && ${:Uword:[${FAIL}]})
 make: "var-eval-short.mk" line 63: Invalid time value: ${FAIL}}



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 18:02:44 UTC 2021

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

Log Message:
make: only evaluate the ':@' modifier if the result is actually used

The test 'var-eval-short' had produced the output 'unexpected' before,
on stderr.  It had been generated by '${:Uword:@${FAIL}@expr@}' by
combining the following obscure "features" of make:

1.  the ':@' modifier loops over the words of the variable.  This
modifier is not really obscure, it still takes some time to get used
to it.

2.  the ':@' modifier allows a '$' sign in the variable name, which is
useless in practice.

3.  the ':@' modifier creates a temporary loop variable in the global
namespace.  Luckily there are only few collisions with other
variable names since their naming conventions differ.

4.  after looping over the words of the expression, the temporary global
loop variable is deleted, and at that point the '$' is expanded,
being interpreted as the start of a variable expression.

5.  The ':@' modifier deleted the global variable even when it was
called in parse-only mode (without VARE_WANTRES).

When the modifier ':@' was initially added to make in var.c 1.40 from
2000-04-29, Var_Delete didn't expand the variable name.  That feature
was added in var.c 1.174 from 2013-05-18, probably without thinking of
this very edge-casey combination of features.

This commit fixes item 5 from the above list.  The other obscurities
remain for now.


To generate a diff of this commit:
cvs rdiff -u -r1.869 -r1.870 src/usr.bin/make/var.c
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-eval-short.exp

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 17:38:24 UTC 2021

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

Log Message:
make: eliminate common subexpression in ApplyModifier_Remember

No functional change.


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

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 17:38:24 UTC 2021

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

Log Message:
make: eliminate common subexpression in ApplyModifier_Remember

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.868 -r1.869 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.868 src/usr.bin/make/var.c:1.869
--- src/usr.bin/make/var.c:1.868	Sun Mar 14 17:34:50 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 17:38:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.868 2021/03/14 17:34:50 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.869 2021/03/14 17:38:24 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.868 2021/03/14 17:34:50 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.869 2021/03/14 17:38:24 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -3430,9 +3430,10 @@ ApplyModifier_Remember(const char **pp, 
 		 * behavior defined in ParseModifierPart.  This creates an
 		 * unnecessary, undocumented inconsistency in make.
 		 */
-		size_t n = strcspn(mod + 2, ":)}");
-		*pp = mod + 2 + n;
-		name = FStr_InitOwn(bmake_strldup(mod + 2, n));
+		const char *arg = mod + 2;
+		size_t argLen = strcspn(arg, ":)}");
+		*pp = arg + argLen;
+		name = FStr_InitOwn(bmake_strldup(arg, argLen));
 	} else
 		*pp = mod + 1;
 



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 17:34:50 UTC 2021

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

Log Message:
make: merge duplicate code in ApplyModifier_Remember

This way, parsing and evaluating the modifier is only written once in
the code.  The downside is that the variable name is allocated even if
VARE_WANTRES is not set, but since this modifier is so obscure and
seldom used this doesn't matter in practice.


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

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 17:34:50 UTC 2021

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

Log Message:
make: merge duplicate code in ApplyModifier_Remember

This way, parsing and evaluating the modifier is only written once in
the code.  The downside is that the variable name is allocated even if
VARE_WANTRES is not set, but since this modifier is so obscure and
seldom used this doesn't matter in practice.


To generate a diff of this commit:
cvs rdiff -u -r1.867 -r1.868 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.867 src/usr.bin/make/var.c:1.868
--- src/usr.bin/make/var.c:1.867	Sun Mar 14 17:27:27 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 17:34:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.867 2021/03/14 17:27:27 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.868 2021/03/14 17:34:50 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.867 2021/03/14 17:27:27 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.868 2021/03/14 17:34:50 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -3418,10 +3418,12 @@ ApplyModifier_Remember(const char **pp, 
 {
 	Expr *expr = st->expr;
 	const char *mod = *pp;
+	FStr name;
 
 	if (!ModMatchEq(mod, "_", st))
 		return AMR_UNKNOWN;
 
+	name = FStr_InitRefer("_");
 	if (mod[1] == '=') {
 		/*
 		 * XXX: This ad-hoc call to strcspn deviates from the usual
@@ -3430,18 +3432,14 @@ ApplyModifier_Remember(const char **pp, 
 		 */
 		size_t n = strcspn(mod + 2, ":)}");
 		*pp = mod + 2 + n;
-
-		if (expr->eflags & VARE_WANTRES) {
-			char *name = bmake_strldup(mod + 2, n);
-			Var_Set(expr->scope, name, expr->value.str);
-			free(name);
-		}
-	} else {
+		name = FStr_InitOwn(bmake_strldup(mod + 2, n));
+	} else
 		*pp = mod + 1;
 
-		if (expr->eflags & VARE_WANTRES)
-			Var_Set(expr->scope, "_", expr->value.str);
-	}
+	if (expr->eflags & VARE_WANTRES)
+		Var_Set(expr->scope, name.str, expr->value.str);
+	FStr_Done();
+
 	return AMR_OK;
 }
 



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 17:27:28 UTC 2021

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

Log Message:
make: do not expand the variable name in the ':_' modifier

This edge case had been so obscure that even discovering this takes
quite some time and requires reading the source code of make.

The manual page doesn't document whether the variable name is expanded
or not, it doesn't even give an example.  When this obscure modifier was
initially added in var.c 1.210 from 2017-01-30, Var_Set always expanded
the variable name once, and there was no way around it.  Therefore this
expansion has probably been unintentional.


To generate a diff of this commit:
cvs rdiff -u -r1.866 -r1.867 src/usr.bin/make/var.c
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-remember.mk

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 17:27:28 UTC 2021

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

Log Message:
make: do not expand the variable name in the ':_' modifier

This edge case had been so obscure that even discovering this takes
quite some time and requires reading the source code of make.

The manual page doesn't document whether the variable name is expanded
or not, it doesn't even give an example.  When this obscure modifier was
initially added in var.c 1.210 from 2017-01-30, Var_Set always expanded
the variable name once, and there was no way around it.  Therefore this
expansion has probably been unintentional.


To generate a diff of this commit:
cvs rdiff -u -r1.866 -r1.867 src/usr.bin/make/var.c
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-remember.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.866 src/usr.bin/make/var.c:1.867
--- src/usr.bin/make/var.c:1.866	Sun Mar 14 16:43:30 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 17:27:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.866 2021/03/14 16:43:30 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.867 2021/03/14 17:27:27 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.866 2021/03/14 16:43:30 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.867 2021/03/14 17:27:27 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -3433,13 +3433,7 @@ ApplyModifier_Remember(const char **pp, 
 
 		if (expr->eflags & VARE_WANTRES) {
 			char *name = bmake_strldup(mod + 2, n);
-
-			/*
-			 * FIXME: do not expand the variable name here; it
-			 * would only work for single-character variable names
-			 * anyway.
-			 */
-			Var_SetExpand(expr->scope, name, expr->value.str);
+			Var_Set(expr->scope, name, expr->value.str);
 			free(name);
 		}
 	} else {

Index: src/usr.bin/make/unit-tests/varmod-remember.mk
diff -u src/usr.bin/make/unit-tests/varmod-remember.mk:1.5 src/usr.bin/make/unit-tests/varmod-remember.mk:1.6
--- src/usr.bin/make/unit-tests/varmod-remember.mk:1.5	Sun Mar 14 17:14:15 2021
+++ src/usr.bin/make/unit-tests/varmod-remember.mk	Sun Mar 14 17:27:27 2021
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-remember.mk,v 1.5 2021/03/14 17:14:15 rillig Exp $
+# $NetBSD: varmod-remember.mk,v 1.6 2021/03/14 17:27:27 rillig Exp $
 #
 # Tests for the :_ modifier, which saves the current variable value
 # in the _ variable or another, to be used later again.
@@ -22,10 +22,13 @@
 # oversight than an intended feature.  The variable name stops at the first
 # '}' or ')' and thus cannot use the usual form ${VARNAME} of long variable
 # names.
+#
+# Because of all these edge-casey conditions, this "feature" has been removed
+# in var.c 1.867 from 2021-03-14.
 S=	INDIRECT_VARNAME
 .if ${value:L:@var@${var:_=$S}@} != "value"
 .  error
-.elif ${INDIRECT_VARNAME} != "value"
+.elif defined(INDIRECT_VARNAME)
 .  error
 .endif
 



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

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 17:14:16 UTC 2021

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

Log Message:
tests/make: demonstrate unintended edge case for the ':_' modifier


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-remember.mk

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

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-remember.mk
diff -u src/usr.bin/make/unit-tests/varmod-remember.mk:1.4 src/usr.bin/make/unit-tests/varmod-remember.mk:1.5
--- src/usr.bin/make/unit-tests/varmod-remember.mk:1.4	Sun Mar 14 17:07:11 2021
+++ src/usr.bin/make/unit-tests/varmod-remember.mk	Sun Mar 14 17:14:15 2021
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-remember.mk,v 1.4 2021/03/14 17:07:11 rillig Exp $
+# $NetBSD: varmod-remember.mk,v 1.5 2021/03/14 17:14:15 rillig Exp $
 #
 # Tests for the :_ modifier, which saves the current variable value
 # in the _ variable or another, to be used later again.
@@ -17,4 +17,16 @@
 .  error
 .endif
 
+# The ':_' modifier takes a variable name as optional argument.  This variable
+# name can refer to other variables, though this was rather an implementation
+# oversight than an intended feature.  The variable name stops at the first
+# '}' or ')' and thus cannot use the usual form ${VARNAME} of long variable
+# names.
+S=	INDIRECT_VARNAME
+.if ${value:L:@var@${var:_=$S}@} != "value"
+.  error
+.elif ${INDIRECT_VARNAME} != "value"
+.  error
+.endif
+
 all:



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

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 17:14:16 UTC 2021

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

Log Message:
tests/make: demonstrate unintended edge case for the ':_' modifier


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

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 17:07:11 UTC 2021

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

Log Message:
tests/make: convert test for ':_' modifier to parse time


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

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 17:07:11 UTC 2021

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

Log Message:
tests/make: convert test for ':_' modifier to parse time


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-remember.exp
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-remember.mk

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

Modified files:

Index: src/usr.bin/make/unit-tests/varmod-remember.exp
diff -u src/usr.bin/make/unit-tests/varmod-remember.exp:1.2 src/usr.bin/make/unit-tests/varmod-remember.exp:1.3
--- src/usr.bin/make/unit-tests/varmod-remember.exp:1.2	Sun Aug 23 15:18:43 2020
+++ src/usr.bin/make/unit-tests/varmod-remember.exp	Sun Mar 14 17:07:11 2021
@@ -1,3 +1 @@
-1 2 3 1 2 3 1 2 3
-1 2 3, SAVED=3
 exit status 0

Index: src/usr.bin/make/unit-tests/varmod-remember.mk
diff -u src/usr.bin/make/unit-tests/varmod-remember.mk:1.3 src/usr.bin/make/unit-tests/varmod-remember.mk:1.4
--- src/usr.bin/make/unit-tests/varmod-remember.mk:1.3	Sun Aug 23 15:18:43 2020
+++ src/usr.bin/make/unit-tests/varmod-remember.mk	Sun Mar 14 17:07:11 2021
@@ -1,12 +1,20 @@
-# $NetBSD: varmod-remember.mk,v 1.3 2020/08/23 15:18:43 rillig Exp $
+# $NetBSD: varmod-remember.mk,v 1.4 2021/03/14 17:07:11 rillig Exp $
 #
 # Tests for the :_ modifier, which saves the current variable value
 # in the _ variable or another, to be used later again.
 
+.if ${1 2 3:L:_:@var@${_}@} != "1 2 3 1 2 3 1 2 3"
+.  error
+.endif
+
 # In the parameterized form, having the variable name on the right side of
 # the = assignment operator is confusing.  In almost all other situations
 # the variable name is on the left-hand side of the = operator.  Luckily
 # this modifier is only rarely needed.
+.if ${1 2 3:L:@var@${var:_=SAVED:}@} != "1 2 3"
+.  error
+.elif ${SAVED} != "3"
+.  error
+.endif
+
 all:
-	@echo ${1 2 3:L:_:@var@${_}@}
-	@echo ${1 2 3:L:@var@${var:_=SAVED:}@}, SAVED=${SAVED}



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 16:43:31 UTC 2021

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

Log Message:
make: only evaluate the ':_' modifier if the expression is needed

See var-eval-short.mk:46 for the test demonstrating this change.
Previously, the expression ${:Uword:_=VAR} was evaluated including all
its side effects even though it was in an irrelevant branch of the
condition.


To generate a diff of this commit:
cvs rdiff -u -r1.865 -r1.866 src/usr.bin/make/var.c
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-eval-short.exp

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

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.865 src/usr.bin/make/var.c:1.866
--- src/usr.bin/make/var.c:1.865	Sun Mar 14 16:03:04 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 16:43:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.865 2021/03/14 16:03:04 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.866 2021/03/14 16:43:30 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.865 2021/03/14 16:03:04 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.866 2021/03/14 16:43:30 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -3418,6 +3418,7 @@ ApplyModifier_Remember(const char **pp, 
 {
 	Expr *expr = st->expr;
 	const char *mod = *pp;
+
 	if (!ModMatchEq(mod, "_", st))
 		return AMR_UNKNOWN;
 
@@ -3428,19 +3429,24 @@ ApplyModifier_Remember(const char **pp, 
 		 * unnecessary, undocumented inconsistency in make.
 		 */
 		size_t n = strcspn(mod + 2, ":)}");
-		char *name = bmake_strldup(mod + 2, n);
 		*pp = mod + 2 + n;
 
-		/*
-		 * FIXME: do not expand the variable name here; it would only
-		 *  work for single-character variable names anyway.
-		 */
-		Var_SetExpand(expr->scope, name, expr->value.str);
-		free(name);
+		if (expr->eflags & VARE_WANTRES) {
+			char *name = bmake_strldup(mod + 2, n);
+
+			/*
+			 * FIXME: do not expand the variable name here; it
+			 * would only work for single-character variable names
+			 * anyway.
+			 */
+			Var_SetExpand(expr->scope, name, expr->value.str);
+			free(name);
+		}
 	} else {
 		*pp = mod + 1;
 
-		Var_Set(expr->scope, "_", expr->value.str);
+		if (expr->eflags & VARE_WANTRES)
+			Var_Set(expr->scope, "_", expr->value.str);
 	}
 	return AMR_OK;
 }

Index: src/usr.bin/make/unit-tests/var-eval-short.exp
diff -u src/usr.bin/make/unit-tests/var-eval-short.exp:1.1 src/usr.bin/make/unit-tests/var-eval-short.exp:1.2
--- src/usr.bin/make/unit-tests/var-eval-short.exp:1.1	Sun Mar 14 11:49:37 2021
+++ src/usr.bin/make/unit-tests/var-eval-short.exp	Sun Mar 14 16:43:30 2021
@@ -1,7 +1,6 @@
 unexpected
 make: Bad modifier ":[${FAIL" for variable ""
 make: "var-eval-short.mk" line 43: Malformed conditional (0 && ${:Uword:[${FAIL}]})
-make: "var-eval-short.mk" line 48: Missing argument for ".error"
 make: "var-eval-short.mk" line 63: Invalid time value: ${FAIL}}
 make: "var-eval-short.mk" line 63: Malformed conditional (0 && ${:Uword:gmtime=${FAIL}})
 make: "var-eval-short.mk" line 77: Invalid time value: ${FAIL}}



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 16:43:31 UTC 2021

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

Log Message:
make: only evaluate the ':_' modifier if the expression is needed

See var-eval-short.mk:46 for the test demonstrating this change.
Previously, the expression ${:Uword:_=VAR} was evaluated including all
its side effects even though it was in an irrelevant branch of the
condition.


To generate a diff of this commit:
cvs rdiff -u -r1.865 -r1.866 src/usr.bin/make/var.c
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/var-eval-short.exp

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 16:03:04 UTC 2021

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

Log Message:
make: return failure in TryParseIntBase0 for empty string

No functional change since the only caller of TryParseIntBase0 already
handles all possible parse errors.  Without this check, the code just
looked wrong though.


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

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 16:03:04 UTC 2021

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

Log Message:
make: return failure in TryParseIntBase0 for empty string

No functional change since the only caller of TryParseIntBase0 already
handles all possible parse errors.  Without this check, the code just
looked wrong though.


To generate a diff of this commit:
cvs rdiff -u -r1.864 -r1.865 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.864 src/usr.bin/make/var.c:1.865
--- src/usr.bin/make/var.c:1.864	Sun Mar 14 15:43:31 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 16:03:04 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.864 2021/03/14 15:43:31 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.865 2021/03/14 16:03:04 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.864 2021/03/14 15:43:31 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.865 2021/03/14 16:03:04 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -2308,6 +2308,9 @@ TryParseIntBase0(const char **pp, int *o
 
 	errno = 0;
 	n = strtol(*pp, , 0);
+
+	if (end == *pp)
+		return FALSE;
 	if ((n == LONG_MIN || n == LONG_MAX) && errno == ERANGE)
 		return FALSE;
 	if (n < INT_MIN || n > INT_MAX)



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

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 16:00:07 UTC 2021

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

Log Message:
make: add test for edge case in modifier ':[...]'

TryParseIntBase0 wrongly returns successful for a string that does not
start with a number at all.  Its only caller, ApplyModifier_Words,
already handles all error cases properly.

No functional change.


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

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 16:00:07 UTC 2021

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

Log Message:
make: add test for edge case in modifier ':[...]'

TryParseIntBase0 wrongly returns successful for a string that does not
start with a number at all.  Its only caller, ApplyModifier_Words,
already handles all error cases properly.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/modword.exp
cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/modword.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/modword.exp
diff -u src/usr.bin/make/unit-tests/modword.exp:1.3 src/usr.bin/make/unit-tests/modword.exp:1.4
--- src/usr.bin/make/unit-tests/modword.exp:1.3	Tue Feb 23 16:07:14 2021
+++ src/usr.bin/make/unit-tests/modword.exp	Sun Mar 14 16:00:07 2021
@@ -71,6 +71,8 @@ make: Bad modifier ":[1.]" for variable 
 LIST:[1.]="" is an error
 make: Bad modifier ":[1..]" for variable "LIST"
 LIST:[1..]="" is an error
+make: Bad modifier ":[1.. ]" for variable "LIST"
+LIST:[1.. ]="" is an error
 LIST:[1..1]="one"
 make: Bad modifier ":[1..1.]" for variable "LIST"
 LIST:[1..1.]="" is an error

Index: src/usr.bin/make/unit-tests/modword.mk
diff -u src/usr.bin/make/unit-tests/modword.mk:1.5 src/usr.bin/make/unit-tests/modword.mk:1.6
--- src/usr.bin/make/unit-tests/modword.mk:1.5	Sun Nov 15 20:20:58 2020
+++ src/usr.bin/make/unit-tests/modword.mk	Sun Mar 14 16:00:07 2021
@@ -1,4 +1,4 @@
-# $NetBSD: modword.mk,v 1.5 2020/11/15 20:20:58 rillig Exp $
+# $NetBSD: modword.mk,v 1.6 2021/03/14 16:00:07 rillig Exp $
 #
 # Test behaviour of new :[] modifier
 # TODO: When was this modifier new?
@@ -99,6 +99,7 @@ mod-squarebrackets-n:
 mod-squarebrackets-start-end:
 	@echo 'LIST:[1.]="${LIST:[1.]}" is an error'
 	@echo 'LIST:[1..]="${LIST:[1..]}" is an error'
+	@echo 'LIST:[1.. ]="${LIST:[1.. ]}" is an error'
 	@echo 'LIST:[1..1]="${LIST:[1..1]}"'
 	@echo 'LIST:[1..1.]="${LIST:[1..1.]}" is an error'
 	@echo 'LIST:[1..2]="${LIST:[1..2]}"'



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 15:43:31 UTC 2021

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

Log Message:
make: separate parsing from evaluating for several modifiers

This aligns the implementation of these modifiers with the requirements
in the long comment starting with 'The ApplyModifier functions'.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.863 -r1.864 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.863 src/usr.bin/make/var.c:1.864
--- src/usr.bin/make/var.c:1.863	Sun Mar 14 15:24:37 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 15:43:31 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.863 2021/03/14 15:24:37 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.864 2021/03/14 15:43:31 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.863 2021/03/14 15:24:37 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.864 2021/03/14 15:43:31 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -2506,9 +2506,12 @@ static ApplyModifierResult
 ApplyModifier_Literal(const char **pp, ApplyModifiersState *st)
 {
 	Expr *expr = st->expr;
+
+	(*pp)++;
+
 	Expr_Define(expr);
 	Expr_SetValueOwn(expr, bmake_strdup(expr->var->name.str));
-	(*pp)++;
+
 	return AMR_OK;
 }
 
@@ -2553,8 +2556,10 @@ ApplyModifier_Gmtime(const char **pp, Ap
 		utc = 0;
 		*pp = mod + 6;
 	}
+
 	Expr_SetValueOwn(st->expr,
 	VarStrftime(st->expr->value.str, TRUE, utc));
+
 	return AMR_OK;
 }
 
@@ -2580,8 +2585,10 @@ ApplyModifier_Localtime(const char **pp,
 		utc = 0;
 		*pp = mod + 9;
 	}
+
 	Expr_SetValueOwn(st->expr,
 	VarStrftime(st->expr->value.str, FALSE, utc));
+
 	return AMR_OK;
 }
 
@@ -2591,9 +2598,10 @@ ApplyModifier_Hash(const char **pp, Appl
 {
 	if (!ModMatch(*pp, "hash", st))
 		return AMR_UNKNOWN;
+	*pp += 4;
 
 	Expr_SetValueOwn(st->expr, VarHash(st->expr->value.str));
-	*pp += 4;
+
 	return AMR_OK;
 }
 
@@ -2605,6 +2613,8 @@ ApplyModifier_Path(const char **pp, Appl
 	GNode *gn;
 	char *path;
 
+	(*pp)++;
+
 	Expr_Define(expr);
 
 	gn = Targ_FindNode(expr->var->name.str);
@@ -2620,7 +2630,6 @@ ApplyModifier_Path(const char **pp, Appl
 		path = bmake_strdup(expr->var->name.str);
 	Expr_SetValueOwn(expr, path);
 
-	(*pp)++;
 	return AMR_OK;
 }
 
@@ -2646,8 +2655,8 @@ ApplyModifier_ShellCommand(const char **
 	if (errfmt != NULL)
 		Error(errfmt, cmd);	/* XXX: why still return AMR_OK? */
 	free(cmd);
-
 	Expr_Define(expr);
+
 	return AMR_OK;
 }
 
@@ -2949,15 +2958,15 @@ ApplyModifier_ToSep(const char **pp, App
 
 	/* ":ts" or ":ts:" */
 	if (sep[0] != st->endc && IsDelimiter(sep[1], st)) {
-		st->sep = sep[0];
 		*pp = sep + 1;
+		st->sep = sep[0];
 		goto ok;
 	}
 
 	/* ":ts" or ":ts:" */
 	if (IsDelimiter(sep[0], st)) {
-		st->sep = '\0';	/* no separator */
 		*pp = sep;
+		st->sep = '\0';	/* no separator */
 		goto ok;
 	}
 
@@ -2969,15 +2978,15 @@ ApplyModifier_ToSep(const char **pp, App
 
 	/* ":ts\n" */
 	if (sep[1] == 'n') {
-		st->sep = '\n';
 		*pp = sep + 2;
+		st->sep = '\n';
 		goto ok;
 	}
 
 	/* ":ts\t" */
 	if (sep[1] == 't') {
-		st->sep = '\t';
 		*pp = sep + 2;
+		st->sep = '\t';
 		goto ok;
 	}
 
@@ -3062,31 +3071,31 @@ ApplyModifier_To(const char **pp, ApplyM
 	}
 
 	if (mod[1] == 'A') {/* :tA */
-		ModifyWords(st, ModifyWord_Realpath, NULL, st->oneBigWord);
 		*pp = mod + 2;
+		ModifyWords(st, ModifyWord_Realpath, NULL, st->oneBigWord);
 		return AMR_OK;
 	}
 
 	if (mod[1] == 'u') {/* :tu */
-		Expr_SetValueOwn(expr, str_toupper(expr->value.str));
 		*pp = mod + 2;
+		Expr_SetValueOwn(expr, str_toupper(expr->value.str));
 		return AMR_OK;
 	}
 
 	if (mod[1] == 'l') {/* :tl */
-		Expr_SetValueOwn(expr, str_tolower(expr->value.str));
 		*pp = mod + 2;
+		Expr_SetValueOwn(expr, str_tolower(expr->value.str));
 		return AMR_OK;
 	}
 
 	if (mod[1] == 'W' || mod[1] == 'w') {		/* :tW, :tw */
-		st->oneBigWord = mod[1] == 'W';
 		*pp = mod + 2;
+		st->oneBigWord = mod[1] == 'W';
 		return AMR_OK;
 	}
 
 	/* Found ":t:" or ":t". */
-	*pp = mod + 1;
+	*pp = mod + 1;		/* XXX: unnecessary but observable */
 	return AMR_BAD;
 }
 
@@ -3216,6 +3225,8 @@ ApplyModifier_Order(const char **pp, App
 {
 	const char *mod = (*pp)++;	/* skip past the 'O' in any case */
 
+	/* TODO: separate parsing from evaluating */
+
 	Words words = Str_Words(st->expr->value.str, FALSE);
 
 	if (IsDelimiter(mod[1], st)) {
@@ -3321,6 +3332,8 @@ ApplyModifier_Assign(const char **pp, Ap
 	char *val;
 	VarParseResult res;
 
+	/* TODO: separate parsing from evaluating */
+
 	const char *mod = *pp;
 	const char *op = mod + 1;
 
@@ -3413,12 +3426,18 @@ ApplyModifier_Remember(const char **pp, 
 		 */
 		size_t n = strcspn(mod + 2, ":)}");
 		char *name = bmake_strldup(mod + 2, n);
+		

CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 15:43:31 UTC 2021

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

Log Message:
make: separate parsing from evaluating for several modifiers

This aligns the implementation of these modifiers with the requirements
in the long comment starting with 'The ApplyModifier functions'.

No functional change.


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

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 15:24:37 UTC 2021

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

Log Message:
make: reduce indentation in ApplyModifier_SunShell

No functional change.


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

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 15:24:37 UTC 2021

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

Log Message:
make: reduce indentation in ApplyModifier_SunShell

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.862 -r1.863 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.862 src/usr.bin/make/var.c:1.863
--- src/usr.bin/make/var.c:1.862	Sun Mar 14 15:22:21 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 15:24:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.862 2021/03/14 15:22:21 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.863 2021/03/14 15:24:37 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.862 2021/03/14 15:22:21 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.863 2021/03/14 15:24:37 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -3515,27 +3515,27 @@ ApplyModifier_SunShell(const char **pp, 
 {
 	Expr *expr = st->expr;
 	const char *p = *pp;
-	if (p[1] == 'h' && IsDelimiter(p[2], st)) {
-		if (expr->eflags & VARE_WANTRES) {
-			const char *errfmt;
-			char *output = Cmd_Exec(expr->value.str, );
-			if (errfmt != NULL)
-Error(errfmt, expr->value.str);
-			Expr_SetValueOwn(expr, output);
-		} else {
-			/*
-			 * TODO: Check whether returning ":sh" would be
-			 *  more consistent with the other modifiers.
-			 *
-			 * TODO: Add a unit test demonstrating that the
-			 *  actual value of this expression has any effect.
-			 */
-			Expr_SetValueRefer(expr, "");
-		}
-		*pp = p + 2;
-		return AMR_OK;
-	} else
+	if (!(p[1] == 'h' && IsDelimiter(p[2], st)))
 		return AMR_UNKNOWN;
+
+	if (expr->eflags & VARE_WANTRES) {
+		const char *errfmt;
+		char *output = Cmd_Exec(expr->value.str, );
+		if (errfmt != NULL)
+			Error(errfmt, expr->value.str);
+		Expr_SetValueOwn(expr, output);
+	} else {
+		/*
+		 * TODO: Check whether returning ":sh" would be
+		 *  more consistent with the other modifiers.
+		 *
+		 * TODO: Add a unit test demonstrating that the
+		 *  actual value of this expression has any effect.
+		 */
+		Expr_SetValueRefer(expr, "");
+	}
+	*pp = p + 2;
+	return AMR_OK;
 }
 #endif
 



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 15:22:21 UTC 2021

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

Log Message:
make: separate parsing and evaluating for modifier ':u'

No functional change.


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

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 15:22:21 UTC 2021

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

Log Message:
make: separate parsing and evaluating for modifier ':u'

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.861 -r1.862 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.861 src/usr.bin/make/var.c:1.862
--- src/usr.bin/make/var.c:1.861	Sun Mar 14 15:19:15 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 15:22:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.861 2021/03/14 15:19:15 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.862 2021/03/14 15:22:21 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.861 2021/03/14 15:19:15 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.862 2021/03/14 15:22:21 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -3329,8 +3329,8 @@ ApplyModifier_Assign(const char **pp, Ap
 	if ((op[0] == '!' || op[0] == '+' || op[0] == '?') && op[1] == '=')
 		goto ok;
 	return AMR_UNKNOWN;	/* "::" */
-ok:
 
+ok:
 	if (expr->var->name.str[0] == '\0') {
 		*pp = mod + 1;
 		return AMR_BAD;
@@ -3442,12 +3442,13 @@ ApplyModifier_WordFunc(const char **pp, 
 static ApplyModifierResult
 ApplyModifier_Unique(const char **pp, ApplyModifiersState *st)
 {
-	if (IsDelimiter((*pp)[1], st)) {
-		Expr_SetValueOwn(st->expr, VarUniq(st->expr->value.str));
-		(*pp)++;
-		return AMR_OK;
-	} else
+	if (!IsDelimiter((*pp)[1], st))
 		return AMR_UNKNOWN;
+	(*pp)++;
+
+	Expr_SetValueOwn(st->expr, VarUniq(st->expr->value.str));
+
+	return AMR_OK;
 }
 
 #ifdef SYSVVARSUB



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 15:19:15 UTC 2021

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

Log Message:
make: separate parsing and evaluating for modifiers ':Q' and ':q'

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.860 -r1.861 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.860 src/usr.bin/make/var.c:1.861
--- src/usr.bin/make/var.c:1.860	Sun Mar 14 15:15:28 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 15:19:15 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.860 2021/03/14 15:15:28 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.861 2021/03/14 15:19:15 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.860 2021/03/14 15:15:28 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.861 2021/03/14 15:19:15 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -2924,13 +2924,14 @@ ApplyModifier_Regex(const char **pp, App
 static ApplyModifierResult
 ApplyModifier_Quote(const char **pp, ApplyModifiersState *st)
 {
-	if (IsDelimiter((*pp)[1], st)) {
-		Expr_SetValueOwn(st->expr,
-		VarQuote(st->expr->value.str, **pp == 'q'));
-		(*pp)++;
-		return AMR_OK;
-	} else
+	Boolean quoteDollar = **pp == 'q';
+	if (!IsDelimiter((*pp)[1], st))
 		return AMR_UNKNOWN;
+	(*pp)++;
+
+	Expr_SetValueOwn(st->expr, VarQuote(st->expr->value.str, quoteDollar));
+
+	return AMR_OK;
 }
 
 /*ARGSUSED*/



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 15:19:15 UTC 2021

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

Log Message:
make: separate parsing and evaluating for modifiers ':Q' and ':q'

No functional change.


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

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 15:15:29 UTC 2021

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

Log Message:
make: extract duplicate code for parsing ':S' and ':C'

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.859 -r1.860 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.859 src/usr.bin/make/var.c:1.860
--- src/usr.bin/make/var.c:1.859	Sun Mar 14 15:06:19 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 15:15:28 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.859 2021/03/14 15:06:19 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.860 2021/03/14 15:15:28 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.859 2021/03/14 15:06:19 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.860 2021/03/14 15:15:28 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -2794,6 +2794,21 @@ ApplyModifier_Match(const char **pp, App
 	return AMR_OK;
 }
 
+static void
+ParsePatternFlags(const char **pp, VarPatternFlags *pflags, Boolean *oneBigWord)
+{
+	for (;; (*pp)++) {
+		if (**pp == 'g')
+			pflags->subGlobal = TRUE;
+		else if (**pp == '1')
+			pflags->subOnce = TRUE;
+		else if (**pp == 'W')
+			*oneBigWord = TRUE;
+		else
+			break;
+	}
+}
+
 /* :S,from,to, */
 static ApplyModifierResult
 ApplyModifier_Subst(const char **pp, ApplyModifiersState *st)
@@ -2833,16 +2848,7 @@ ApplyModifier_Subst(const char **pp, App
 	args.rhs = rhs;
 
 	oneBigWord = st->oneBigWord;
-	for (;; (*pp)++) {
-		if (**pp == 'g')
-			args.pflags.subGlobal = TRUE;
-		else if (**pp == '1')
-			args.pflags.subOnce = TRUE;
-		else if (**pp == 'W')
-			oneBigWord = TRUE;
-		else
-			break;
-	}
+	ParsePatternFlags(pp, , );
 
 	ModifyWords(st, ModifyWord_Subst, , oneBigWord);
 
@@ -2885,16 +2891,7 @@ ApplyModifier_Regex(const char **pp, App
 	args.pflags = (VarPatternFlags){ FALSE, FALSE, FALSE, FALSE };
 	args.matched = FALSE;
 	oneBigWord = st->oneBigWord;
-	for (;; (*pp)++) {
-		if (**pp == 'g')
-			args.pflags.subGlobal = TRUE;
-		else if (**pp == '1')
-			args.pflags.subOnce = TRUE;
-		else if (**pp == 'W')
-			oneBigWord = TRUE;
-		else
-			break;
-	}
+	ParsePatternFlags(pp, , );
 
 	if (!(st->expr->eflags & VARE_WANTRES)) {
 		free(args.replace);



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 15:15:29 UTC 2021

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

Log Message:
make: extract duplicate code for parsing ':S' and ':C'

No functional change.


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

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 15:06:19 UTC 2021

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

Log Message:
make: extract duplicate code for detecting a modifier's end

No functional change.


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

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 15:06:19 UTC 2021

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

Log Message:
make: extract duplicate code for detecting a modifier's end

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.858 -r1.859 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.858 src/usr.bin/make/var.c:1.859
--- src/usr.bin/make/var.c:1.858	Sun Mar 14 15:04:13 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 15:06:19 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.858 2021/03/14 15:04:13 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.859 2021/03/14 15:06:19 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.858 2021/03/14 15:04:13 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.859 2021/03/14 15:06:19 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -2277,22 +2277,27 @@ ParseModifierPart(
 	NULL, NULL, NULL);
 }
 
+MAKE_INLINE Boolean
+IsDelimiter(char ch, const ApplyModifiersState *st)
+{
+	return ch == ':' || ch == st->endc;
+}
+
 /* Test whether mod starts with modname, followed by a delimiter. */
 MAKE_INLINE Boolean
-ModMatch(const char *mod, const char *modname, char endc)
+ModMatch(const char *mod, const char *modname, const ApplyModifiersState *st)
 {
 	size_t n = strlen(modname);
-	return strncmp(mod, modname, n) == 0 &&
-	   (mod[n] == endc || mod[n] == ':');
+	return strncmp(mod, modname, n) == 0 && IsDelimiter(mod[n], st);
 }
 
 /* Test whether mod starts with modname, followed by a delimiter or '='. */
 MAKE_INLINE Boolean
-ModMatchEq(const char *mod, const char *modname, char endc)
+ModMatchEq(const char *mod, const char *modname, const ApplyModifiersState *st)
 {
 	size_t n = strlen(modname);
 	return strncmp(mod, modname, n) == 0 &&
-	   (mod[n] == endc || mod[n] == ':' || mod[n] == '=');
+	   (IsDelimiter(mod[n], st) || mod[n] == '=');
 }
 
 static Boolean
@@ -2452,7 +2457,7 @@ ApplyModifier_Defined(const char **pp, A
 
 	Buf_Init();
 	p = *pp + 1;
-	while (*p != st->endc && *p != ':' && *p != '\0') {
+	while (!IsDelimiter(*p, st) && *p != '\0') {
 
 		/* XXX: This code is similar to the one in Var_Parse.
 		 * See if the code can be merged.
@@ -2462,8 +2467,7 @@ ApplyModifier_Defined(const char **pp, A
 		/* See Buf_AddEscaped in for.c. */
 		if (*p == '\\') {
 			char c = p[1];
-			if (c == st->endc || c == ':' || c == '$' ||
-			c == '\\') {
+			if (IsDelimiter(c, st) || c == '$' || c == '\\') {
 Buf_AddByte(, c);
 p += 2;
 continue;
@@ -2534,7 +2538,7 @@ ApplyModifier_Gmtime(const char **pp, Ap
 	time_t utc;
 
 	const char *mod = *pp;
-	if (!ModMatchEq(mod, "gmtime", st->endc))
+	if (!ModMatchEq(mod, "gmtime", st))
 		return AMR_UNKNOWN;
 
 	if (mod[6] == '=') {
@@ -2561,7 +2565,7 @@ ApplyModifier_Localtime(const char **pp,
 	time_t utc;
 
 	const char *mod = *pp;
-	if (!ModMatchEq(mod, "localtime", st->endc))
+	if (!ModMatchEq(mod, "localtime", st))
 		return AMR_UNKNOWN;
 
 	if (mod[9] == '=') {
@@ -2585,7 +2589,7 @@ ApplyModifier_Localtime(const char **pp,
 static ApplyModifierResult
 ApplyModifier_Hash(const char **pp, ApplyModifiersState *st)
 {
-	if (!ModMatch(*pp, "hash", st->endc))
+	if (!ModMatch(*pp, "hash", st))
 		return AMR_UNKNOWN;
 
 	Expr_SetValueOwn(st->expr, VarHash(st->expr->value.str));
@@ -2659,7 +2663,7 @@ ApplyModifier_Range(const char **pp, App
 	size_t i;
 
 	const char *mod = *pp;
-	if (!ModMatchEq(mod, "range", st->endc))
+	if (!ModMatchEq(mod, "range", st))
 		return AMR_UNKNOWN;
 
 	if (mod[5] == '=') {
@@ -2722,7 +2726,7 @@ ParseModifier_Match(const char **pp, con
 	const char *p;
 	for (p = mod + 1; *p != '\0' && !(*p == ':' && nest == 0); p++) {
 		if (*p == '\\' &&
-		(p[1] == ':' || p[1] == st->endc || p[1] == st->startc)) {
+		(IsDelimiter(p[1], st) || p[1] == st->startc)) {
 			if (!needSubst)
 copy = TRUE;
 			p++;
@@ -2752,7 +2756,7 @@ ParseModifier_Match(const char **pp, con
 		for (; src < endpat; src++, dst++) {
 			if (src[0] == '\\' && src + 1 < endpat &&
 			/* XXX: st->startc is missing here; see above */
-			(src[1] == ':' || src[1] == st->endc))
+			IsDelimiter(src[1], st))
 src++;
 			*dst = *src;
 		}
@@ -2923,7 +2927,7 @@ ApplyModifier_Regex(const char **pp, App
 static ApplyModifierResult
 ApplyModifier_Quote(const char **pp, ApplyModifiersState *st)
 {
-	if ((*pp)[1] == st->endc || (*pp)[1] == ':') {
+	if (IsDelimiter((*pp)[1], st)) {
 		Expr_SetValueOwn(st->expr,
 		VarQuote(st->expr->value.str, **pp == 'q'));
 		(*pp)++;
@@ -2946,14 +2950,14 @@ ApplyModifier_ToSep(const char **pp, App
 	const char *sep = *pp + 2;
 
 	/* ":ts" or ":ts:" */
-	if (sep[0] != st->endc && (sep[1] == st->endc || sep[1] == ':')) {
+	if 

CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 15:04:13 UTC 2021

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

Log Message:
make: document how error handling should be done correctly

Right now, when a variable expression cannot be parsed, the result of
calling Var_Subst is a string containing garbage, and no error is
reported.  In addition, there are some silent errors that are not
reported at all.  This combination makes it difficult to change the
error handling without introducing subtle breakage in some edge cases.

An example for garbage output is in varmod-subst-regex.mk, in target
mod-regex-compile-error.

No functional change.


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

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 15:04:13 UTC 2021

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

Log Message:
make: document how error handling should be done correctly

Right now, when a variable expression cannot be parsed, the result of
calling Var_Subst is a string containing garbage, and no error is
reported.  In addition, there are some silent errors that are not
reported at all.  This combination makes it difficult to change the
error handling without introducing subtle breakage in some edge cases.

An example for garbage output is in varmod-subst-regex.mk, in target
mod-regex-compile-error.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.857 -r1.858 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.857 src/usr.bin/make/var.c:1.858
--- src/usr.bin/make/var.c:1.857	Sun Mar 14 11:15:37 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 15:04:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.857 2021/03/14 11:15:37 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.858 2021/03/14 15:04:13 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.857 2021/03/14 11:15:37 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.858 2021/03/14 15:04:13 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -3837,6 +3837,16 @@ bad_modifier:
 	(int)strcspn(mod, ":)}"), mod, expr->var->name.str);
 
 cleanup:
+	/*
+	 * TODO: Use p + strlen(p) instead, to stop parsing immediately.
+	 *
+	 * In the unit tests, this generates a few unterminated strings in the
+	 * shell commands though.  Instead of producing these unfinished
+	 * strings, commands with evaluation errors should not be run at all.
+	 *
+	 * To make that happen, Var_Subst must report the actual errors
+	 * instead of returning VPR_OK unconditionally.
+	 */
 	*pp = p;
 	Expr_SetValueRefer(expr, var_Error);
 }



CVS commit: src/sys/rump

2021-03-14 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Mar 14 13:11:59 UTC 2021

Modified Files:
src/sys/rump: Makefile.rump

Log Message:
Build rump for PPC_OEA64 on evbppc64.


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/rump/Makefile.rump

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

Modified files:

Index: src/sys/rump/Makefile.rump
diff -u src/sys/rump/Makefile.rump:1.129 src/sys/rump/Makefile.rump:1.130
--- src/sys/rump/Makefile.rump:1.129	Fri Jun 12 11:04:45 2020
+++ src/sys/rump/Makefile.rump	Sun Mar 14 13:11:59 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.rump,v 1.129 2020/06/12 11:04:45 roy Exp $
+#	$NetBSD: Makefile.rump,v 1.130 2021/03/14 13:11:59 rin Exp $
 #
 
 .if !defined(_RUMP_MK)
@@ -136,8 +136,12 @@ CPPFLAGS+=	${RUMPKERN_UNDEF}
 RUMPKERNEL=	This is NetBSD and I am the rump.  Good evening.
 
 # workaround: evbppc is not a well-defined arch
-.if (${MACHINE} == "evbppc")
+.if ${MACHINE} == "evbppc"
+.  if ${MACHINE_ARCH} == "powerpc"
 CPPFLAGS+=	-DPPC_OEA
+.  else
+CPPFLAGS+=	-DPPC_OEA64
+.  endif
 .endif
 
 # If any of these files change, we need a full rebuild



CVS commit: src/sys/rump

2021-03-14 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Mar 14 13:11:59 UTC 2021

Modified Files:
src/sys/rump: Makefile.rump

Log Message:
Build rump for PPC_OEA64 on evbppc64.


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 src/sys/rump/Makefile.rump

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



CVS commit: src

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 11:49:37 UTC 2021

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

Log Message:
tests/make: add test for short-circuit evaluation of modifiers


To generate a diff of this commit:
cvs rdiff -u -r1.1031 -r1.1032 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.272 -r1.273 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/cond-short.mk
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/var-eval-short.exp \
src/usr.bin/make/unit-tests/var-eval-short.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.1031 src/distrib/sets/lists/tests/mi:1.1032
--- src/distrib/sets/lists/tests/mi:1.1031	Fri Mar 12 00:13:06 2021
+++ src/distrib/sets/lists/tests/mi	Sun Mar 14 11:49:37 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1031 2021/03/12 00:13:06 rillig Exp $
+# $NetBSD: mi,v 1.1032 2021/03/14 11:49:37 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5727,6 +5727,8 @@
 ./usr/tests/usr.bin/make/unit-tests/var-class-local.mktests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/var-class.exptests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/var-class.mktests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/var-eval-short.exptests-usr.bin-tests	compattestfile,atf
+./usr/tests/usr.bin/make/unit-tests/var-eval-short.mktests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/var-op-append.exptests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/var-op-append.mktests-usr.bin-tests	compattestfile,atf
 ./usr/tests/usr.bin/make/unit-tests/var-op-assign.exptests-usr.bin-tests	compattestfile,atf

Index: src/usr.bin/make/unit-tests/Makefile
diff -u src/usr.bin/make/unit-tests/Makefile:1.272 src/usr.bin/make/unit-tests/Makefile:1.273
--- src/usr.bin/make/unit-tests/Makefile:1.272	Sun Mar 14 10:45:51 2021
+++ src/usr.bin/make/unit-tests/Makefile	Sun Mar 14 11:49:37 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.272 2021/03/14 10:45:51 rillig Exp $
+# $NetBSD: Makefile,v 1.273 2021/03/14 11:49:37 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -320,6 +320,7 @@ TESTS+=		var-class-env
 TESTS+=		var-class-global
 TESTS+=		var-class-local
 TESTS+=		var-class-local-legacy
+TESTS+=		var-eval-short
 TESTS+=		var-op
 TESTS+=		var-op-append
 TESTS+=		var-op-assign

Index: src/usr.bin/make/unit-tests/cond-short.mk
diff -u src/usr.bin/make/unit-tests/cond-short.mk:1.15 src/usr.bin/make/unit-tests/cond-short.mk:1.16
--- src/usr.bin/make/unit-tests/cond-short.mk:1.15	Tue Dec  1 19:37:23 2020
+++ src/usr.bin/make/unit-tests/cond-short.mk	Sun Mar 14 11:49:37 2021
@@ -1,4 +1,4 @@
-# $NetBSD: cond-short.mk,v 1.15 2020/12/01 19:37:23 rillig Exp $
+# $NetBSD: cond-short.mk,v 1.16 2021/03/14 11:49:37 rillig Exp $
 #
 # Demonstrates that in conditions, the right-hand side of an && or ||
 # is only evaluated if it can actually influence the result.
@@ -13,8 +13,11 @@
 # parse them.  They were still evaluated though, the only difference to
 # relevant variable expressions was that in the irrelevant variable
 # expressions, undefined variables were allowed.
+#
+# See also:
+#	var-eval-short.mk, for short-circuited variable modifiers
 
-# The && operator.
+# The && operator:
 
 .if 0 && ${echo "unexpected and" 1>&2 :L:sh}
 .endif
@@ -86,7 +89,7 @@ VAR=	# empty again, for the following te
 .  warning first=${FIRST} last=${LAST} appended=${APPENDED} ran=${RAN}
 .endif
 
-# The || operator.
+# The || operator:
 
 .if 1 || ${echo "unexpected or" 1>&2 :L:sh}
 .endif
@@ -208,9 +211,4 @@ x!=	echo '0 || $${iV2:U2} < $${V42}: $x'
 .  error
 .endif
 
-# TODO: Test each modifier to make sure it is skipped when it is irrelevant
-# for the result.  Since this test is already quite long, do that in another
-# test.
-
 all:
-	@:;:

Added files:

Index: src/usr.bin/make/unit-tests/var-eval-short.exp
diff -u /dev/null src/usr.bin/make/unit-tests/var-eval-short.exp:1.1
--- /dev/null	Sun Mar 14 11:49:38 2021
+++ src/usr.bin/make/unit-tests/var-eval-short.exp	Sun Mar 14 11:49:37 2021
@@ -0,0 +1,11 @@
+unexpected
+make: Bad modifier ":[${FAIL" for variable ""
+make: "var-eval-short.mk" line 43: Malformed conditional (0 && ${:Uword:[${FAIL}]})
+make: "var-eval-short.mk" line 48: Missing argument for ".error"
+make: "var-eval-short.mk" line 63: Invalid time value: ${FAIL}}
+make: "var-eval-short.mk" line 63: Malformed conditional (0 && ${:Uword:gmtime=${FAIL}})
+make: "var-eval-short.mk" line 77: Invalid time value: ${FAIL}}
+make: "var-eval-short.mk" line 77: Malformed 

CVS commit: src

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 11:49:37 UTC 2021

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

Log Message:
tests/make: add test for short-circuit evaluation of modifiers


To generate a diff of this commit:
cvs rdiff -u -r1.1031 -r1.1032 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.272 -r1.273 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/cond-short.mk
cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/var-eval-short.exp \
src/usr.bin/make/unit-tests/var-eval-short.mk

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 11:15:37 UTC 2021

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

Log Message:
make: sort modifiers in ApplyModifier alphabetically

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.856 -r1.857 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.856 src/usr.bin/make/var.c:1.857
--- src/usr.bin/make/var.c:1.856	Sun Mar 14 10:57:12 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 11:15:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.856 2021/03/14 10:57:12 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.857 2021/03/14 11:15:37 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.856 2021/03/14 10:57:12 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.857 2021/03/14 11:15:37 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -3577,63 +3577,64 @@ static ApplyModifierResult
 ApplyModifier(const char **pp, ApplyModifiersState *st)
 {
 	switch (**pp) {
+	case '!':
+		return ApplyModifier_ShellCommand(pp, st);
 	case ':':
 		return ApplyModifier_Assign(pp, st);
+	case '?':
+		return ApplyModifier_IfElse(pp, st);
 	case '@':
 		return ApplyModifier_Loop(pp, st);
+	case '[':
+		return ApplyModifier_Words(pp, st);
 	case '_':
 		return ApplyModifier_Remember(pp, st);
+#ifndef NO_REGEX
+	case 'C':
+		return ApplyModifier_Regex(pp, st);
+#endif
 	case 'D':
-	case 'U':
 		return ApplyModifier_Defined(pp, st);
-	case 'L':
-		return ApplyModifier_Literal(pp, st);
-	case 'P':
-		return ApplyModifier_Path(pp, st);
-	case '!':
-		return ApplyModifier_ShellCommand(pp, st);
-	case '[':
-		return ApplyModifier_Words(pp, st);
+	case 'E':
+		return ApplyModifier_WordFunc(pp, st, ModifyWord_Suffix);
 	case 'g':
 		return ApplyModifier_Gmtime(pp, st);
+	case 'H':
+		return ApplyModifier_WordFunc(pp, st, ModifyWord_Head);
 	case 'h':
 		return ApplyModifier_Hash(pp, st);
+	case 'L':
+		return ApplyModifier_Literal(pp, st);
 	case 'l':
 		return ApplyModifier_Localtime(pp, st);
-	case 't':
-		return ApplyModifier_To(pp, st);
-	case 'N':
 	case 'M':
+	case 'N':
 		return ApplyModifier_Match(pp, st);
-	case 'S':
-		return ApplyModifier_Subst(pp, st);
-	case '?':
-		return ApplyModifier_IfElse(pp, st);
-#ifndef NO_REGEX
-	case 'C':
-		return ApplyModifier_Regex(pp, st);
-#endif
-	case 'q':
+	case 'O':
+		return ApplyModifier_Order(pp, st);
+	case 'P':
+		return ApplyModifier_Path(pp, st);
 	case 'Q':
+	case 'q':
 		return ApplyModifier_Quote(pp, st);
-	case 'T':
-		return ApplyModifier_WordFunc(pp, st, ModifyWord_Tail);
-	case 'H':
-		return ApplyModifier_WordFunc(pp, st, ModifyWord_Head);
-	case 'E':
-		return ApplyModifier_WordFunc(pp, st, ModifyWord_Suffix);
 	case 'R':
 		return ApplyModifier_WordFunc(pp, st, ModifyWord_Root);
 	case 'r':
 		return ApplyModifier_Range(pp, st);
-	case 'O':
-		return ApplyModifier_Order(pp, st);
-	case 'u':
-		return ApplyModifier_Unique(pp, st);
+	case 'S':
+		return ApplyModifier_Subst(pp, st);
 #ifdef SUNSHCMD
 	case 's':
 		return ApplyModifier_SunShell(pp, st);
 #endif
+	case 'T':
+		return ApplyModifier_WordFunc(pp, st, ModifyWord_Tail);
+	case 't':
+		return ApplyModifier_To(pp, st);
+	case 'U':
+		return ApplyModifier_Defined(pp, st);
+	case 'u':
+		return ApplyModifier_Unique(pp, st);
 	default:
 		return AMR_UNKNOWN;
 	}



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 11:15:37 UTC 2021

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

Log Message:
make: sort modifiers in ApplyModifier alphabetically

No functional change.


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

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



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 10:57:13 UTC 2021

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

Log Message:
make: fix wrong expression evaluation in -dL mode

The modifier ':C' now only compiles the regular expression if the result
of the expression is actually needed.

Several other modifiers have the same bug of evaluating the expression
in cases where this is not needed.  It just doesn't show up because they
don't have any noticeable side effects, other than wasting CPU time.
This affects irrelevant conditions as well.


To generate a diff of this commit:
cvs rdiff -u -r1.855 -r1.856 src/usr.bin/make/var.c
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/opt-debug-lint.exp
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/opt-debug-lint.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.855 src/usr.bin/make/var.c:1.856
--- src/usr.bin/make/var.c:1.855	Tue Feb 23 16:29:52 2021
+++ src/usr.bin/make/var.c	Sun Mar 14 10:57:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.855 2021/02/23 16:29:52 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.856 2021/03/14 10:57:12 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.855 2021/02/23 16:29:52 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.856 2021/03/14 10:57:12 rillig Exp $");
 
 typedef enum VarFlags {
 	VFL_NONE	= 0,
@@ -2892,6 +2892,12 @@ ApplyModifier_Regex(const char **pp, App
 			break;
 	}
 
+	if (!(st->expr->eflags & VARE_WANTRES)) {
+		free(args.replace);
+		free(re);
+		return AMR_OK;
+	}
+
 	error = regcomp(, re, REG_EXTENDED);
 	free(re);
 	if (error != 0) {

Index: src/usr.bin/make/unit-tests/opt-debug-lint.exp
diff -u src/usr.bin/make/unit-tests/opt-debug-lint.exp:1.15 src/usr.bin/make/unit-tests/opt-debug-lint.exp:1.16
--- src/usr.bin/make/unit-tests/opt-debug-lint.exp:1.15	Sun Mar 14 10:45:51 2021
+++ src/usr.bin/make/unit-tests/opt-debug-lint.exp	Sun Mar 14 10:57:12 2021
@@ -3,7 +3,6 @@ make: "opt-debug-lint.mk" line 41: Varia
 make: "opt-debug-lint.mk" line 61: Missing delimiter ':' after modifier "L"
 make: "opt-debug-lint.mk" line 61: Missing delimiter ':' after modifier "P"
 make: "opt-debug-lint.mk" line 69: Unknown modifier "${"
-make: Regex compilation error: (details omitted)
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/opt-debug-lint.mk
diff -u src/usr.bin/make/unit-tests/opt-debug-lint.mk:1.13 src/usr.bin/make/unit-tests/opt-debug-lint.mk:1.14
--- src/usr.bin/make/unit-tests/opt-debug-lint.mk:1.13	Sun Mar 14 10:45:51 2021
+++ src/usr.bin/make/unit-tests/opt-debug-lint.mk	Sun Mar 14 10:57:12 2021
@@ -1,4 +1,4 @@
-# $NetBSD: opt-debug-lint.mk,v 1.13 2021/03/14 10:45:51 rillig Exp $
+# $NetBSD: opt-debug-lint.mk,v 1.14 2021/03/14 10:57:12 rillig Exp $
 #
 # Tests for the -dL command line option, which runs additional checks
 # to catch common mistakes, such as unclosed variable expressions.
@@ -77,12 +77,15 @@ ${UNDEF}: ${UNDEF}
 .  error
 .endif
 
-# Before var.c 1.XXX from 2021-03-14, the whole variable text was evaluated
-# to check for unclosed expressions and unknown operators.  During this check,
-# the subexpression '${:U2}' was not expanded, instead it was copied verbatim
-# into the regular expression, which was '.*=.{1,${:U2}}$'.  This regular
-# expression was then compiled (despite VARE_WANTRES being unset), which
-# resulted in a wrong error message.
+# In lint mode, the whole variable text is evaluated to check for unclosed
+# expressions and unknown operators.  During this check, the subexpression
+# '${:U2}' is not expanded, instead it is copied verbatim into the regular
+# expression, leading to '.*=.{1,${:U2}}$'.
+#
+# Before var.c 1.856 from 2021-03-14, this regular expression was then
+# compiled even though that was not necessary for checking the syntax at the
+# level of variable expressions.  The unexpanded '$' then resulted in a wrong
+# error message.
 #
 # This only happened in lint mode since in default mode the early check for
 # unclosed expressions and unknown modifiers is skipped.



CVS commit: src/usr.bin/make

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 10:57:13 UTC 2021

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

Log Message:
make: fix wrong expression evaluation in -dL mode

The modifier ':C' now only compiles the regular expression if the result
of the expression is actually needed.

Several other modifiers have the same bug of evaluating the expression
in cases where this is not needed.  It just doesn't show up because they
don't have any noticeable side effects, other than wasting CPU time.
This affects irrelevant conditions as well.


To generate a diff of this commit:
cvs rdiff -u -r1.855 -r1.856 src/usr.bin/make/var.c
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/opt-debug-lint.exp
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/opt-debug-lint.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

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 10:45:51 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: Makefile opt-debug-lint.exp
opt-debug-lint.mk

Log Message:
make: demonstrate wrong expression evaluation in -dL mode


To generate a diff of this commit:
cvs rdiff -u -r1.271 -r1.272 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/opt-debug-lint.exp
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/opt-debug-lint.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

2021-03-14 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 10:45:51 UTC 2021

Modified Files:
src/usr.bin/make/unit-tests: Makefile opt-debug-lint.exp
opt-debug-lint.mk

Log Message:
make: demonstrate wrong expression evaluation in -dL mode


To generate a diff of this commit:
cvs rdiff -u -r1.271 -r1.272 src/usr.bin/make/unit-tests/Makefile
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/opt-debug-lint.exp
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/opt-debug-lint.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.271 src/usr.bin/make/unit-tests/Makefile:1.272
--- src/usr.bin/make/unit-tests/Makefile:1.271	Sun Feb 14 20:16:17 2021
+++ src/usr.bin/make/unit-tests/Makefile	Sun Mar 14 10:45:51 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.271 2021/02/14 20:16:17 rillig Exp $
+# $NetBSD: Makefile,v 1.272 2021/03/14 10:45:51 rillig Exp $
 #
 # Unit tests for make(1)
 #
@@ -493,6 +493,7 @@ SED_CMDS.opt-debug-jobs+=	-e 's,JobFinis
 SED_CMDS.opt-debug-jobs+=	-e 's,Command: ${.SHELL:T},Command: ,'
 # The "-q" may be there or not, see jobs.c, variable shells.
 SED_CMDS.opt-debug-jobs+=	-e 's,^\(.Command: \) -q,\1,'
+SED_CMDS.opt-debug-lint+=	${STD_SED_CMDS.regex}
 SED_CMDS.opt-jobs-no-action=	${STD_SED_CMDS.hide-from-output}
 SED_CMDS.opt-no-action-runflags= ${STD_SED_CMDS.hide-from-output}
 # For Compat_RunCommand, useShell == FALSE.
@@ -508,8 +509,7 @@ SED_CMDS.suff-transform-debug+=	${STD_SE
 SED_CMDS.var-op-shell+=		${STD_SED_CMDS.shell}
 SED_CMDS.var-op-shell+=		-e '/command/s,No such.*,not found,'
 SED_CMDS.vardebug+=		-e 's,${.SHELL},,'
-SED_CMDS.varmod-subst-regex+= \
-			-e 's,\(Regex compilation error:\).*,\1 (details omitted),'
+SED_CMDS.varmod-subst-regex+=	${STD_SED_CMDS.regex}
 SED_CMDS.varname-dot-parsedir=	-e '/in some cases/ s,^make: "[^"]*,make: ",'
 SED_CMDS.varname-dot-parsefile=	-e '/in some cases/ s,^make: "[^"]*,make: ",'
 SED_CMDS.varname-dot-shell=	-e 's, = /[^ ]*, = (details omitted),g'
@@ -587,6 +587,11 @@ STD_SED_CMDS.shell+=		-e 's,^${.SHELL:T}
 STD_SED_CMDS.shell+=		-e 's,^${.SHELL:T}: [0-9][0-9]*: ,,'
 STD_SED_CMDS.shell+=		-e 's,^${.SHELL:T}: ,,'
 
+# The actual error messages for a failed regcomp or regexec differ between the
+# implementations.
+STD_SED_CMDS.regex= \
+	-e 's,\(Regex compilation error:\).*,\1 (details omitted),'
+
 # End of the configuration helpers section.
 
 UNIT_TESTS:=	${.PARSEDIR}

Index: src/usr.bin/make/unit-tests/opt-debug-lint.exp
diff -u src/usr.bin/make/unit-tests/opt-debug-lint.exp:1.14 src/usr.bin/make/unit-tests/opt-debug-lint.exp:1.15
--- src/usr.bin/make/unit-tests/opt-debug-lint.exp:1.14	Tue Feb 23 15:19:41 2021
+++ src/usr.bin/make/unit-tests/opt-debug-lint.exp	Sun Mar 14 10:45:51 2021
@@ -3,6 +3,7 @@ make: "opt-debug-lint.mk" line 41: Varia
 make: "opt-debug-lint.mk" line 61: Missing delimiter ':' after modifier "L"
 make: "opt-debug-lint.mk" line 61: Missing delimiter ':' after modifier "P"
 make: "opt-debug-lint.mk" line 69: Unknown modifier "${"
+make: Regex compilation error: (details omitted)
 make: Fatal errors encountered -- cannot continue
 make: stopped in unit-tests
 exit status 1

Index: src/usr.bin/make/unit-tests/opt-debug-lint.mk
diff -u src/usr.bin/make/unit-tests/opt-debug-lint.mk:1.12 src/usr.bin/make/unit-tests/opt-debug-lint.mk:1.13
--- src/usr.bin/make/unit-tests/opt-debug-lint.mk:1.12	Sun Dec 20 19:10:53 2020
+++ src/usr.bin/make/unit-tests/opt-debug-lint.mk	Sun Mar 14 10:45:51 2021
@@ -1,4 +1,4 @@
-# $NetBSD: opt-debug-lint.mk,v 1.12 2020/12/20 19:10:53 rillig Exp $
+# $NetBSD: opt-debug-lint.mk,v 1.13 2021/03/14 10:45:51 rillig Exp $
 #
 # Tests for the -dL command line option, which runs additional checks
 # to catch common mistakes, such as unclosed variable expressions.
@@ -77,5 +77,16 @@ ${UNDEF}: ${UNDEF}
 .  error
 .endif
 
-all:
-	@:;
+# Before var.c 1.XXX from 2021-03-14, the whole variable text was evaluated
+# to check for unclosed expressions and unknown operators.  During this check,
+# the subexpression '${:U2}' was not expanded, instead it was copied verbatim
+# into the regular expression, which was '.*=.{1,${:U2}}$'.  This regular
+# expression was then compiled (despite VARE_WANTRES being unset), which
+# resulted in a wrong error message.
+#
+# This only happened in lint mode since in default mode the early check for
+# unclosed expressions and unknown modifiers is skipped.
+#
+# See VarCheckSyntax, ApplyModifier_Regex.
+#
+VARMOD_REGEX=	${:UA=111 B=222 C=33:C/.*=.{1,${:U2}}$//g}



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

2021-03-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Mar 14 10:36:46 UTC 2021

Modified Files:
src/sys/arch/arm/arm32: pmap.c

Log Message:
Sprinkle kpreempt_{dis,en}able ready for when preemption gets turned on.


To generate a diff of this commit:
cvs rdiff -u -r1.425 -r1.426 src/sys/arch/arm/arm32/pmap.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/arm/arm32/pmap.c
diff -u src/sys/arch/arm/arm32/pmap.c:1.425 src/sys/arch/arm/arm32/pmap.c:1.426
--- src/sys/arch/arm/arm32/pmap.c:1.425	Mon Feb  1 19:02:28 2021
+++ src/sys/arch/arm/arm32/pmap.c	Sun Mar 14 10:36:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.425 2021/02/01 19:02:28 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.426 2021/03/14 10:36:46 skrll Exp $	*/
 
 /*
  * Copyright 2003 Wasabi Systems, Inc.
@@ -192,7 +192,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.425 2021/02/01 19:02:28 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.426 2021/03/14 10:36:46 skrll Exp $");
 
 #include 
 #include 
@@ -2837,6 +2837,7 @@ pmap_page_remove(struct vm_page_md *md, 
 	UVMHIST_FUNC(__func__);
 	UVMHIST_CALLARGS(maphist, "md %#jx pa %#jx", (uintptr_t)md, pa, 0, 0);
 
+	kpreempt_disable();
 	pmap_acquire_page_lock(md);
 	struct pv_entry **pvp = _FIRST(>pvh_list);
 	if (*pvp == NULL) {
@@ -2851,6 +2852,8 @@ pmap_page_remove(struct vm_page_md *md, 
 		PMAP_VALIDATE_MD_PAGE(md);
 #endif
 		pmap_release_page_lock(md);
+		kpreempt_enable();
+
 		return;
 	}
 #if defined(PMAP_CACHE_VIPT) && !defined(ARM_MMU_EXTENDED)
@@ -3004,6 +3007,8 @@ pmap_page_remove(struct vm_page_md *md, 
 	}
 	cpu_cpwait();
 #endif /* ARM_MMU_EXTENDED */
+
+	kpreempt_enable();
 }
 
 /*
@@ -3111,6 +3116,7 @@ pmap_enter(pmap_t pm, vaddr_t va, paddr_
 	if (flags & PMAP_WIRED)
 		nflags |= PVF_WIRED;
 
+	kpreempt_disable();
 	pmap_acquire_pmap_lock(pm);
 
 	/*
@@ -3125,6 +3131,8 @@ pmap_enter(pmap_t pm, vaddr_t va, paddr_
 	if (l2b == NULL) {
 		if (flags & PMAP_CANFAIL) {
 			pmap_release_pmap_lock(pm);
+			kpreempt_enable();
+
 			error = ENOMEM;
 			goto free_pv;
 		}
@@ -3419,13 +3427,14 @@ pmap_enter(pmap_t pm, vaddr_t va, paddr_
 #endif
 
 	pmap_release_pmap_lock(pm);
-
+	kpreempt_enable();
 
 	if (old_pv)
 		pool_put(_pv_pool, old_pv);
 free_pv:
 	if (new_pv)
 		pool_put(_pv_pool, new_pv);
+
 	return error;
 }
 
@@ -3470,6 +3479,7 @@ pmap_remove(pmap_t pm, vaddr_t sva, vadd
 	/*
 	 * we lock in the pmap => pv_head direction
 	 */
+	kpreempt_disable();
 	pmap_acquire_pmap_lock(pm);
 
 #ifndef ARM_MMU_EXTENDED
@@ -3637,6 +3647,8 @@ pmap_remove(pmap_t pm, vaddr_t sva, vadd
 	}
 
 	pmap_release_pmap_lock(pm);
+	kpreempt_enable();
+
 	SLIST_FOREACH_SAFE(pv, _list, pv_link, npv) {
 		pool_put(_pv_pool, pv);
 	}
@@ -3709,6 +3721,7 @@ pmap_kenter_pa(vaddr_t va, paddr_t pa, v
 		 flags);
 	}
 
+	kpreempt_disable();
 	pmap_t kpm = pmap_kernel();
 	pmap_acquire_pmap_lock(kpm);
 	struct l2_bucket * const l2b = pmap_get_l2_bucket(kpm, va);
@@ -3845,6 +3858,8 @@ pmap_kenter_pa(vaddr_t va, paddr_t pa, v
 			pool_put(_pv_pool, pv);
 #endif
 	}
+	kpreempt_enable();
+
 	if (pmap_initialized) {
 		UVMHIST_LOG(maphist, "  <-- done (ptep %#jx: %#jx -> %#jx)",
 		(uintptr_t)ptep, opte, npte, 0);
@@ -3867,6 +3882,7 @@ pmap_kremove(vaddr_t va, vsize_t len)
 	const vaddr_t eva = va + len;
 	pmap_t kpm = pmap_kernel();
 
+	kpreempt_disable();
 	pmap_acquire_pmap_lock(kpm);
 
 	while (va < eva) {
@@ -3931,6 +3947,8 @@ pmap_kremove(vaddr_t va, vsize_t len)
 	}
 	pmap_release_pmap_lock(kpm);
 	cpu_cpwait();
+	kpreempt_enable();
+
 	UVMHIST_LOG(maphist, "  <--- done (%ju mappings removed)",
 	total_mappings, 0, 0, 0);
 }
@@ -3952,6 +3970,7 @@ pmap_extract_coherency(pmap_t pm, vaddr_
 	u_int l1slot;
 	bool coherent;
 
+	kpreempt_disable();
 	pmap_acquire_pmap_lock(pm);
 
 	l1slot = l1pte_index(va);
@@ -3982,11 +4001,14 @@ pmap_extract_coherency(pmap_t pm, vaddr_
 		if (l2 == NULL ||
 		(ptep = l2->l2_bucket[L2_BUCKET(l1slot)].l2b_kva) == NULL) {
 			pmap_release_pmap_lock(pm);
+			kpreempt_enable();
+
 			return false;
 		}
 
 		pte = ptep[l2pte_index(va)];
 		pmap_release_pmap_lock(pm);
+		kpreempt_enable();
 
 		if (pte == 0)
 			return false;
@@ -4023,6 +4045,7 @@ pmap_pv_remove(paddr_t pa)
 {
 	struct pmap_page *pp;
 
+	KASSERT(kpreempt_disabled());
 	pp = pmap_pv_tracked(pa);
 	if (pp == NULL)
 		panic("pmap_pv_protect: page not pv-tracked: 0x%"PRIxPADDR,
@@ -4064,6 +4087,7 @@ pmap_protect(pmap_t pm, vaddr_t sva, vad
 		return;
 	}
 
+	kpreempt_disable();
 	pmap_acquire_pmap_lock(pm);
 
 #ifndef ARM_MMU_EXTENDED
@@ -4154,6 +4178,7 @@ pmap_protect(pmap_t pm, vaddr_t sva, vad
 #endif
 
 	pmap_release_pmap_lock(pm);
+	kpreempt_enable();
 }
 
 void
@@ -4364,6 +4389,7 @@ pmap_prefetchabt_fixup(void *v)
 
   out:
 	kpreempt_enable();
+
 	return rv;
 }
 #endif
@@ -4392,6 +4418,7 @@ pmap_fault_fixup(pmap_t pm, vaddr_t va, 
 	(uintptr_t)PMAP_PAI(pm, 

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

2021-03-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Mar 14 10:36:46 UTC 2021

Modified Files:
src/sys/arch/arm/arm32: pmap.c

Log Message:
Sprinkle kpreempt_{dis,en}able ready for when preemption gets turned on.


To generate a diff of this commit:
cvs rdiff -u -r1.425 -r1.426 src/sys/arch/arm/arm32/pmap.c

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



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

2021-03-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Mar 14 08:16:57 UTC 2021

Modified Files:
src/sys/arch/arm/samsung: exynos_combiner.c exynos_dwcmmc.c
exynos_ehci.c exynos_i2c.c exynos_ohci.c exynos_uart.c mct.c

Log Message:
Use fdtbus_intr_establish_xname


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/samsung/exynos_combiner.c
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/samsung/exynos_dwcmmc.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/samsung/exynos_ehci.c
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/samsung/exynos_i2c.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/samsung/exynos_ohci.c \
src/sys/arch/arm/samsung/exynos_uart.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/samsung/mct.c

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



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

2021-03-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Mar 14 08:16:57 UTC 2021

Modified Files:
src/sys/arch/arm/samsung: exynos_combiner.c exynos_dwcmmc.c
exynos_ehci.c exynos_i2c.c exynos_ohci.c exynos_uart.c mct.c

Log Message:
Use fdtbus_intr_establish_xname


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/samsung/exynos_combiner.c
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/samsung/exynos_dwcmmc.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/samsung/exynos_ehci.c
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/samsung/exynos_i2c.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/samsung/exynos_ohci.c \
src/sys/arch/arm/samsung/exynos_uart.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/samsung/mct.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/arm/samsung/exynos_combiner.c
diff -u src/sys/arch/arm/samsung/exynos_combiner.c:1.13 src/sys/arch/arm/samsung/exynos_combiner.c:1.14
--- src/sys/arch/arm/samsung/exynos_combiner.c:1.13	Wed Jan 27 03:10:19 2021
+++ src/sys/arch/arm/samsung/exynos_combiner.c	Sun Mar 14 08:16:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: exynos_combiner.c,v 1.13 2021/01/27 03:10:19 thorpej Exp $ */
+/*	$NetBSD: exynos_combiner.c,v 1.14 2021/03/14 08:16:57 skrll Exp $ */
 
 /*-
 * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #include "gpio.h"
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: exynos_combiner.c,v 1.13 2021/01/27 03:10:19 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: exynos_combiner.c,v 1.14 2021/03/14 08:16:57 skrll Exp $");
 
 #include 
 #include 
@@ -254,12 +254,13 @@ exynos_combiner_establish(device_t dev, 
 	if (!groupp) {
 		groupp = exynos_combiner_new_group(sc, group);
 		if (arg == NULL) {
-			groupp->irq_ih = fdtbus_intr_establish(sc->sc_phandle,
-			group, ipl /* XXX */, flags, func, NULL);
+			groupp->irq_ih = fdtbus_intr_establish_xname(
+			sc->sc_phandle, group, ipl /* XXX */, flags, func, NULL,
+			device_xname(dev));
 		} else {
-			groupp->irq_ih = fdtbus_intr_establish(sc->sc_phandle,
-			group, ipl /* XXX */, FDT_INTR_MPSAFE,
-			exynos_combiner_irq, groupp);
+			groupp->irq_ih = fdtbus_intr_establish_xname(
+			sc->sc_phandle,  group, ipl /* XXX */, FDT_INTR_MPSAFE,
+			exynos_combiner_irq, groupp, device_xname(dev));
 		}
 		KASSERT(groupp->irq_ih != NULL);
 		groupp->irq_ipl = ipl;

Index: src/sys/arch/arm/samsung/exynos_dwcmmc.c
diff -u src/sys/arch/arm/samsung/exynos_dwcmmc.c:1.14 src/sys/arch/arm/samsung/exynos_dwcmmc.c:1.15
--- src/sys/arch/arm/samsung/exynos_dwcmmc.c:1.14	Wed Jan 27 03:10:19 2021
+++ src/sys/arch/arm/samsung/exynos_dwcmmc.c	Sun Mar 14 08:16:57 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: exynos_dwcmmc.c,v 1.14 2021/01/27 03:10:19 thorpej Exp $ */
+/* $NetBSD: exynos_dwcmmc.c,v 1.15 2021/03/14 08:16:57 skrll Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: exynos_dwcmmc.c,v 1.14 2021/01/27 03:10:19 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exynos_dwcmmc.c,v 1.15 2021/03/14 08:16:57 skrll Exp $");
 
 #include 
 #include 
@@ -165,8 +165,8 @@ exynos_dwcmmc_attach(device_t parent, de
 	if (dwc_mmc_init(sc) != 0)
 		return;
 
-	sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_BIO, 0,
-	dwc_mmc_intr, sc);
+	sc->sc_ih = fdtbus_intr_establish_xname(phandle, 0, IPL_BIO, 0,
+	dwc_mmc_intr, sc, device_xname(self));
 	if (sc->sc_ih == NULL) {
 		aprint_error_dev(self, "couldn't establish interrupt on %s\n",
 		intrstr);

Index: src/sys/arch/arm/samsung/exynos_ehci.c
diff -u src/sys/arch/arm/samsung/exynos_ehci.c:1.5 src/sys/arch/arm/samsung/exynos_ehci.c:1.6
--- src/sys/arch/arm/samsung/exynos_ehci.c:1.5	Wed Jan 27 03:10:19 2021
+++ src/sys/arch/arm/samsung/exynos_ehci.c	Sun Mar 14 08:16:57 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: exynos_ehci.c,v 1.5 2021/01/27 03:10:19 thorpej Exp $ */
+/* $NetBSD: exynos_ehci.c,v 1.6 2021/03/14 08:16:57 skrll Exp $ */
 
 /*-
  * Copyright (c) 2015-2018 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: exynos_ehci.c,v 1.5 2021/01/27 03:10:19 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exynos_ehci.c,v 1.6 2021/03/14 08:16:57 skrll Exp $");
 
 #include 
 #include 
@@ -126,8 +126,8 @@ exynos_ehci_attach(device_t parent, devi
 		return;
 	}
 
-	ih = fdtbus_intr_establish(phandle, 0, IPL_USB, FDT_INTR_MPSAFE,
-	ehci_intr, sc);
+	ih = fdtbus_intr_establish_xname(phandle, 0, IPL_USB, FDT_INTR_MPSAFE,
+	ehci_intr, sc, device_xname(self));
 	if (ih == NULL) {
 		aprint_error_dev(self, "couldn't establish interrupt on %s\n",
 		intrstr);

Index: src/sys/arch/arm/samsung/exynos_i2c.c
diff -u src/sys/arch/arm/samsung/exynos_i2c.c:1.21 src/sys/arch/arm/samsung/exynos_i2c.c:1.22
--- src/sys/arch/arm/samsung/exynos_i2c.c:1.21	Wed Jan 27 03:10:19 2021
+++ src/sys/arch/arm/samsung/exynos_i2c.c	Sun Mar 14 08:16:57 2021
@@ 

CVS commit: src/sys/dev/ic

2021-03-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Mar 14 08:13:58 UTC 2021

Modified Files:
src/sys/dev/ic: sti.c

Log Message:
No need to have an MD #ifdef in an MI file, so remove it.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/ic/sti.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/ic/sti.c
diff -u src/sys/dev/ic/sti.c:1.28 src/sys/dev/ic/sti.c:1.29
--- src/sys/dev/ic/sti.c:1.28	Sun Mar  7 14:31:20 2021
+++ src/sys/dev/ic/sti.c	Sun Mar 14 08:13:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sti.c,v 1.28 2021/03/07 14:31:20 skrll Exp $	*/
+/*	$NetBSD: sti.c,v 1.29 2021/03/14 08:13:58 skrll Exp $	*/
 
 /*	$OpenBSD: sti.c,v 1.61 2009/09/05 14:09:35 miod Exp $	*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sti.c,v 1.28 2021/03/07 14:31:20 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sti.c,v 1.29 2021/03/14 08:13:58 skrll Exp $");
 
 #include "wsdisplay.h"
 
@@ -1427,9 +1427,8 @@ sti_alloc_attr(void *v, int fg, int bg, 
 	return 0;
 }
 
-#ifdef hp300	/* XXX */
 /*
- * Early console support.  Only used on hp300.
+ * Early console support.  Only used on hp300, currently
  */
 int
 sti_cnattach(struct sti_rom *rom, struct sti_screen *scr, bus_space_tag_t memt,
@@ -1465,7 +1464,6 @@ sti_cnattach(struct sti_rom *rom, struct
 
 	return 0;
 }
-#endif
 
 int
 ngle_default_putcmap(struct sti_screen *scr, u_int idx, u_int count)



CVS commit: src/sys/dev/ic

2021-03-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Mar 14 08:13:58 UTC 2021

Modified Files:
src/sys/dev/ic: sti.c

Log Message:
No need to have an MD #ifdef in an MI file, so remove it.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/ic/sti.c

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



CVS commit: src/sys/arch/x86/pci

2021-03-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Mar 14 08:10:23 UTC 2021

Modified Files:
src/sys/arch/x86/pci: pci_msi_machdep.c

Log Message:
Remoave an extra space from a comment


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/x86/pci/pci_msi_machdep.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/x86/pci/pci_msi_machdep.c
diff -u src/sys/arch/x86/pci/pci_msi_machdep.c:1.14 src/sys/arch/x86/pci/pci_msi_machdep.c:1.15
--- src/sys/arch/x86/pci/pci_msi_machdep.c:1.14	Sun Jul 19 14:27:07 2020
+++ src/sys/arch/x86/pci/pci_msi_machdep.c	Sun Mar 14 08:10:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_msi_machdep.c,v 1.14 2020/07/19 14:27:07 jdolecek Exp $	*/
+/*	$NetBSD: pci_msi_machdep.c,v 1.15 2021/03/14 08:10:23 skrll Exp $	*/
 
 /*
  * Copyright (c) 2015 Internet Initiative Japan Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.14 2020/07/19 14:27:07 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_msi_machdep.c,v 1.15 2021/03/14 08:10:23 skrll Exp $");
 
 #include "opt_intrdebug.h"
 #include "ioapic.h"
@@ -509,7 +509,7 @@ x86_pci_msix_disestablish(pci_chipset_ta
 /*
  * This function is used by device drivers like pci_intr_map().
  *
- * "ihps" is the array  of vector numbers which MSI used instead of IRQ number.
+ * "ihps" is the array of vector numbers which MSI used instead of IRQ number.
  * "count" must be power of 2.
  * "count" can decrease if struct intrsource cannot be allocated.
  * if count == 0, return non-zero value.



CVS commit: src/sys/arch/x86/pci

2021-03-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Mar 14 08:10:23 UTC 2021

Modified Files:
src/sys/arch/x86/pci: pci_msi_machdep.c

Log Message:
Remoave an extra space from a comment


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/x86/pci/pci_msi_machdep.c

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



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

2021-03-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Mar 14 08:09:20 UTC 2021

Modified Files:
src/sys/arch/arm/cortex: gic_v2m.c

Log Message:
Remove an unnecessary if statement in gic_v2m_msi_alloc when finding a
'count' that fits the available.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/cortex/gic_v2m.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/arm/cortex/gic_v2m.c
diff -u src/sys/arch/arm/cortex/gic_v2m.c:1.10 src/sys/arch/arm/cortex/gic_v2m.c:1.11
--- src/sys/arch/arm/cortex/gic_v2m.c:1.10	Fri Dec 11 21:40:50 2020
+++ src/sys/arch/arm/cortex/gic_v2m.c	Sun Mar 14 08:09:20 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: gic_v2m.c,v 1.10 2020/12/11 21:40:50 jmcneill Exp $ */
+/* $NetBSD: gic_v2m.c,v 1.11 2021/03/14 08:09:20 skrll Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #define _INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gic_v2m.c,v 1.10 2020/12/11 21:40:50 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic_v2m.c,v 1.11 2021/03/14 08:09:20 skrll Exp $");
 
 #include 
 #include 
@@ -240,10 +240,9 @@ gic_v2m_msi_alloc(struct arm_pci_msi *ms
 	if (exact && *count > avail)
 		return NULL;
 
-	while (*count > avail) {
-		if (avail < *count)
-			(*count) >>= 1;
-	}
+	while (*count > avail)
+		(*count) >>= 1;
+
 	if (*count == 0)
 		return NULL;
 



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

2021-03-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Mar 14 08:09:20 UTC 2021

Modified Files:
src/sys/arch/arm/cortex: gic_v2m.c

Log Message:
Remove an unnecessary if statement in gic_v2m_msi_alloc when finding a
'count' that fits the available.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/cortex/gic_v2m.c

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