CVS commit: src/share/man/man9
Module Name:src Committed By: riastradh Date: Sat Dec 11 23:47:53 UTC 2021 Modified Files: src/share/man/man9: crashme.9 Log Message: crashme(9): Touch up man page markup. Better consistency with sysctl(7), less random widthing and offsetting. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/share/man/man9/crashme.9 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/share/man/man9
Module Name:src Committed By: riastradh Date: Sat Dec 11 23:47:53 UTC 2021 Modified Files: src/share/man/man9: crashme.9 Log Message: crashme(9): Touch up man page markup. Better consistency with sysctl(7), less random widthing and offsetting. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/share/man/man9/crashme.9 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/crashme.9 diff -u src/share/man/man9/crashme.9:1.4 src/share/man/man9/crashme.9:1.5 --- src/share/man/man9/crashme.9:1.4 Sat Dec 11 19:24:19 2021 +++ src/share/man/man9/crashme.9 Sat Dec 11 23:47:53 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: crashme.9,v 1.4 2021/12/11 19:24:19 mrg Exp $ +.\" $NetBSD: crashme.9,v 1.5 2021/12/11 23:47:53 riastradh Exp $ .\" .\" Copyright (c) 2019 Matthew R. Green .\" All rights reserved. @@ -81,8 +81,8 @@ The following variables are provided by the .Nm subsystem: -.Bl -tag -width "123456" -offset indent -.It Ic debug.crashme_enable +.Bl -tag -width Li +.It Li debug.crashme_enable Must be set to 1 for any .Nm node to be executed. @@ -91,16 +91,16 @@ node to be executed. The following .Xr sysctl 8 nodes trigger crashes in different ways when written: -.Bl -tag -width "123456" -offset indent -.It Ic debug.crashme.panic +.Bl -tag -width ".Li debug.crashme.null_deref" +.It Li debug.crashme.panic Call .Xr panic 9 . -.It Ic debug.crashme.null_deref +.It Li debug.crashme.null_deref Dereference a null pointer. -.It Ic debug.crashme.null_jump +.It Li debug.crashme.null_jump Call a null function pointer, i.e., jump to the instruction address zero. -.It Ic debug.crashme.ddb +.It Li debug.crashme.ddb Enter .Xr ddb 9 directly by calling
CVS commit: src/share/man/man4/man4.evbarm
Module Name:src Committed By: wiz Date: Sat Dec 11 20:42:49 UTC 2021 Modified Files: src/share/man/man4/man4.evbarm: vchiq.4 Log Message: Document vchiq@acpi To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/share/man/man4/man4.evbarm/vchiq.4 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man4/man4.evbarm/vchiq.4 diff -u src/share/man/man4/man4.evbarm/vchiq.4:1.2 src/share/man/man4/man4.evbarm/vchiq.4:1.3 --- src/share/man/man4/man4.evbarm/vchiq.4:1.2 Thu Sep 16 02:53:28 2021 +++ src/share/man/man4/man4.evbarm/vchiq.4 Sat Dec 11 20:42:48 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: vchiq.4,v 1.2 2021/09/16 02:53:28 nat Exp $ +.\" $NetBSD: vchiq.4,v 1.3 2021/12/11 20:42:48 wiz Exp $ .\" .\" Copyright (c) 2021 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -24,7 +24,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd February 26, 2021 +.Dd December 11, 2021 .Dt VCHIQ 4 .Os .Sh NAME @@ -32,6 +32,7 @@ .Nd Broadcom VideoCore Host Interface device driver .Sh SYNOPSIS .Cd "vchiq* at simplebus?" +.Cd "vchiq* at acpi?" .Sh DESCRIPTION The .Nm @@ -56,6 +57,7 @@ Information such as slots and usage by p device are displayed. .Sh SEE ALSO .Xr cat 1 , +.Xr acpi 4 , .Xr bcmgpio 4 , .Xr vcaudio 4 , .Pa pkgsrc/misc/raspberrypi-userland ,
CVS commit: src/share/man/man4/man4.evbarm
Module Name:src Committed By: wiz Date: Sat Dec 11 20:42:49 UTC 2021 Modified Files: src/share/man/man4/man4.evbarm: vchiq.4 Log Message: Document vchiq@acpi To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/share/man/man4/man4.evbarm/vchiq.4 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: mrg Date: Sat Dec 11 19:24:22 UTC 2021 Modified Files: src/distrib/utils/embedded/files: creds_msdos src/external/bsd/libuuid_ul/lib/libuuid_ul: randutils.h src/external/gpl3/gcc.old/lib/libstdc++-v3/include/bits/arch: mkcxxconfig_h.sh src/external/gpl3/gcc/lib/libstdc++-v3/include/bits/arch: mkcxxconfig_h.sh src/lib/libkvm: kvm_ia64.c src/lib/libpci: pci_drvname.c src/share/man/man4: usbnet.4 src/share/man/man4/man4.evbarm: rktsadc.4 src/share/man/man8: creds_msdos.8 src/share/man/man9: crashme.9 kernhist.9 usbd_status.9 usbdi.9 usbnet.9 src/sys/arch/arm/arm: arm_cpu_topology.c src/sys/arch/arm/dts: sun8i-a83t-cubietruck-plus.dts src/sys/arch/arm/include: cpu_topology.h src/sys/arch/arm/rockchip: rk_tsadc.c src/sys/arch/mips/include: stacktrace.h src/sys/arch/sparc/include: locore.h src/sys/arch/sparc64/sparc64: cache.c cache.h src/sys/compat/netbsd32: netbsd32_nfssvc.c src/sys/dev/raidframe: rf_compat32.c rf_compat32.h rf_compat80.c rf_compat80.h src/sys/dev/usb: usbhist.h usbnet.c usbnet.h src/sys/uvm: uvm_stat.h src/tests/usr.bin/cc: t_libgomp.sh src/usr.bin/ldd: ldd.h src/usr.sbin/cpuctl/arch: sparc.c sparc64.c src/usr.sbin/crash/arch: mips.c Log Message: remove clause 3 from all my licenses that aren't conflicting with another copyright claim line. again. (i did this in 2008 and then did not update all of my personal templates.) To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/distrib/utils/embedded/files/creds_msdos cvs rdiff -u -r1.1 -r1.2 \ src/external/bsd/libuuid_ul/lib/libuuid_ul/randutils.h cvs rdiff -u -r1.7 -r1.8 \ src/external/gpl3/gcc.old/lib/libstdc++-v3/include/bits/arch/mkcxxconfig_h.sh cvs rdiff -u -r1.1 -r1.2 \ src/external/gpl3/gcc/lib/libstdc++-v3/include/bits/arch/mkcxxconfig_h.sh cvs rdiff -u -r1.2 -r1.3 src/lib/libkvm/kvm_ia64.c cvs rdiff -u -r1.2 -r1.3 src/lib/libpci/pci_drvname.c cvs rdiff -u -r1.5 -r1.6 src/share/man/man4/usbnet.4 cvs rdiff -u -r1.2 -r1.3 src/share/man/man4/man4.evbarm/rktsadc.4 cvs rdiff -u -r1.1 -r1.2 src/share/man/man8/creds_msdos.8 cvs rdiff -u -r1.3 -r1.4 src/share/man/man9/crashme.9 cvs rdiff -u -r1.9 -r1.10 src/share/man/man9/kernhist.9 cvs rdiff -u -r1.2 -r1.3 src/share/man/man9/usbd_status.9 cvs rdiff -u -r1.35 -r1.36 src/share/man/man9/usbdi.9 cvs rdiff -u -r1.13 -r1.14 src/share/man/man9/usbnet.9 cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/arm/arm_cpu_topology.c cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/dts/sun8i-a83t-cubietruck-plus.dts cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/include/cpu_topology.h cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/rockchip/rk_tsadc.c cvs rdiff -u -r1.1 -r1.2 src/sys/arch/mips/include/stacktrace.h cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sparc/include/locore.h cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sparc64/sparc64/cache.c cvs rdiff -u -r1.29 -r1.30 src/sys/arch/sparc64/sparc64/cache.h cvs rdiff -u -r1.8 -r1.9 src/sys/compat/netbsd32/netbsd32_nfssvc.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/raidframe/rf_compat32.c cvs rdiff -u -r1.3 -r1.4 src/sys/dev/raidframe/rf_compat32.h \ src/sys/dev/raidframe/rf_compat80.h cvs rdiff -u -r1.15 -r1.16 src/sys/dev/raidframe/rf_compat80.c cvs rdiff -u -r1.7 -r1.8 src/sys/dev/usb/usbhist.h cvs rdiff -u -r1.42 -r1.43 src/sys/dev/usb/usbnet.c cvs rdiff -u -r1.21 -r1.22 src/sys/dev/usb/usbnet.h cvs rdiff -u -r1.55 -r1.56 src/sys/uvm/uvm_stat.h cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/cc/t_libgomp.sh cvs rdiff -u -r1.8 -r1.9 src/usr.bin/ldd/ldd.h cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/cpuctl/arch/sparc.c \ src/usr.sbin/cpuctl/arch/sparc64.c cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/crash/arch/mips.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/utils/embedded/files/creds_msdos diff -u src/distrib/utils/embedded/files/creds_msdos:1.4 src/distrib/utils/embedded/files/creds_msdos:1.5 --- src/distrib/utils/embedded/files/creds_msdos:1.4 Sat Oct 5 09:25:11 2019 +++ src/distrib/utils/embedded/files/creds_msdos Sat Dec 11 19:24:18 2021 @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: creds_msdos,v 1.4 2019/10/05 09:25:11 mlelstv Exp $ +# $NetBSD: creds_msdos,v 1.5 2021/12/11 19:24:18 mrg Exp $ # # Copyright (c) 2019 Matthew R. Green # All rights reserved. @@ -13,8 +13,6 @@ # 2. Redistributions in binary form must reproduce the above copyright #notice, this list of conditions and the following disclaimer in the #documentation and/or other materials provided with the distribution. -# 3. The name of the author may not be used to endorse or promote products -#derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS
CVS commit: src
Module Name:src Committed By: mrg Date: Sat Dec 11 19:24:22 UTC 2021 Modified Files: src/distrib/utils/embedded/files: creds_msdos src/external/bsd/libuuid_ul/lib/libuuid_ul: randutils.h src/external/gpl3/gcc.old/lib/libstdc++-v3/include/bits/arch: mkcxxconfig_h.sh src/external/gpl3/gcc/lib/libstdc++-v3/include/bits/arch: mkcxxconfig_h.sh src/lib/libkvm: kvm_ia64.c src/lib/libpci: pci_drvname.c src/share/man/man4: usbnet.4 src/share/man/man4/man4.evbarm: rktsadc.4 src/share/man/man8: creds_msdos.8 src/share/man/man9: crashme.9 kernhist.9 usbd_status.9 usbdi.9 usbnet.9 src/sys/arch/arm/arm: arm_cpu_topology.c src/sys/arch/arm/dts: sun8i-a83t-cubietruck-plus.dts src/sys/arch/arm/include: cpu_topology.h src/sys/arch/arm/rockchip: rk_tsadc.c src/sys/arch/mips/include: stacktrace.h src/sys/arch/sparc/include: locore.h src/sys/arch/sparc64/sparc64: cache.c cache.h src/sys/compat/netbsd32: netbsd32_nfssvc.c src/sys/dev/raidframe: rf_compat32.c rf_compat32.h rf_compat80.c rf_compat80.h src/sys/dev/usb: usbhist.h usbnet.c usbnet.h src/sys/uvm: uvm_stat.h src/tests/usr.bin/cc: t_libgomp.sh src/usr.bin/ldd: ldd.h src/usr.sbin/cpuctl/arch: sparc.c sparc64.c src/usr.sbin/crash/arch: mips.c Log Message: remove clause 3 from all my licenses that aren't conflicting with another copyright claim line. again. (i did this in 2008 and then did not update all of my personal templates.) To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/distrib/utils/embedded/files/creds_msdos cvs rdiff -u -r1.1 -r1.2 \ src/external/bsd/libuuid_ul/lib/libuuid_ul/randutils.h cvs rdiff -u -r1.7 -r1.8 \ src/external/gpl3/gcc.old/lib/libstdc++-v3/include/bits/arch/mkcxxconfig_h.sh cvs rdiff -u -r1.1 -r1.2 \ src/external/gpl3/gcc/lib/libstdc++-v3/include/bits/arch/mkcxxconfig_h.sh cvs rdiff -u -r1.2 -r1.3 src/lib/libkvm/kvm_ia64.c cvs rdiff -u -r1.2 -r1.3 src/lib/libpci/pci_drvname.c cvs rdiff -u -r1.5 -r1.6 src/share/man/man4/usbnet.4 cvs rdiff -u -r1.2 -r1.3 src/share/man/man4/man4.evbarm/rktsadc.4 cvs rdiff -u -r1.1 -r1.2 src/share/man/man8/creds_msdos.8 cvs rdiff -u -r1.3 -r1.4 src/share/man/man9/crashme.9 cvs rdiff -u -r1.9 -r1.10 src/share/man/man9/kernhist.9 cvs rdiff -u -r1.2 -r1.3 src/share/man/man9/usbd_status.9 cvs rdiff -u -r1.35 -r1.36 src/share/man/man9/usbdi.9 cvs rdiff -u -r1.13 -r1.14 src/share/man/man9/usbnet.9 cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/arm/arm_cpu_topology.c cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/dts/sun8i-a83t-cubietruck-plus.dts cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/include/cpu_topology.h cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/rockchip/rk_tsadc.c cvs rdiff -u -r1.1 -r1.2 src/sys/arch/mips/include/stacktrace.h cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sparc/include/locore.h cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sparc64/sparc64/cache.c cvs rdiff -u -r1.29 -r1.30 src/sys/arch/sparc64/sparc64/cache.h cvs rdiff -u -r1.8 -r1.9 src/sys/compat/netbsd32/netbsd32_nfssvc.c cvs rdiff -u -r1.8 -r1.9 src/sys/dev/raidframe/rf_compat32.c cvs rdiff -u -r1.3 -r1.4 src/sys/dev/raidframe/rf_compat32.h \ src/sys/dev/raidframe/rf_compat80.h cvs rdiff -u -r1.15 -r1.16 src/sys/dev/raidframe/rf_compat80.c cvs rdiff -u -r1.7 -r1.8 src/sys/dev/usb/usbhist.h cvs rdiff -u -r1.42 -r1.43 src/sys/dev/usb/usbnet.c cvs rdiff -u -r1.21 -r1.22 src/sys/dev/usb/usbnet.h cvs rdiff -u -r1.55 -r1.56 src/sys/uvm/uvm_stat.h cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/cc/t_libgomp.sh cvs rdiff -u -r1.8 -r1.9 src/usr.bin/ldd/ldd.h cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/cpuctl/arch/sparc.c \ src/usr.sbin/cpuctl/arch/sparc64.c cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/crash/arch/mips.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/share/man/man9
Module Name:src Committed By: riastradh Date: Sat Dec 11 19:16:48 UTC 2021 Modified Files: src/share/man/man9: crashme.9 Log Message: Update crashme(9) man page for recent additions. Reorganize slightly. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/share/man/man9/crashme.9 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/crashme.9 diff -u src/share/man/man9/crashme.9:1.2 src/share/man/man9/crashme.9:1.3 --- src/share/man/man9/crashme.9:1.2 Wed Jan 9 09:48:44 2019 +++ src/share/man/man9/crashme.9 Sat Dec 11 19:16:48 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: crashme.9,v 1.2 2019/01/09 09:48:44 wiz Exp $ +.\" $NetBSD: crashme.9,v 1.3 2021/12/11 19:16:48 riastradh Exp $ .\" .\" Copyright (c) 2019 Matthew R. Green .\" All rights reserved. @@ -88,12 +88,28 @@ subsystem: Must be set to 1 for any .Nm node to be executed. +.El +.Pp +The following +.Xr sysctl 8 +nodes trigger crashes in different ways when written: +.Bl -tag -width "123456" -offset indent .It Ic debug.crashme.panic -Basic panic node. +Call +.Xr panic 9 . .It Ic debug.crashme.null_deref -Dereference -.Dv NULL -node. +Dereference a null pointer. +.It Ic debug.crashme.null_jump +Call a null function pointer, i.e., jump to the instruction address +zero. +.It Ic debug.crashme.ddb +Enter +.Xr ddb 9 +directly by calling +.Xr Debugger 9 . +Requires +.Xr options 4 +.Dv DDB . .El .Sh SEE ALSO .Xr options 4 ,
CVS commit: src/share/man/man9
Module Name:src Committed By: riastradh Date: Sat Dec 11 19:16:48 UTC 2021 Modified Files: src/share/man/man9: crashme.9 Log Message: Update crashme(9) man page for recent additions. Reorganize slightly. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/share/man/man9/crashme.9 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/dev/pci
Module Name:src Committed By: skrll Date: Sat Dec 11 17:05:50 UTC 2021 Modified Files: src/sys/dev/pci: if_wm.c Log Message: Typo in comment To generate a diff of this commit: cvs rdiff -u -r1.721 -r1.722 src/sys/dev/pci/if_wm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/pci/if_wm.c diff -u src/sys/dev/pci/if_wm.c:1.721 src/sys/dev/pci/if_wm.c:1.722 --- src/sys/dev/pci/if_wm.c:1.721 Fri Dec 10 05:55:06 2021 +++ src/sys/dev/pci/if_wm.c Sat Dec 11 17:05:50 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_wm.c,v 1.721 2021/12/10 05:55:06 skrll Exp $ */ +/* $NetBSD: if_wm.c,v 1.722 2021/12/11 17:05:50 skrll Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. @@ -82,7 +82,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.721 2021/12/10 05:55:06 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.722 2021/12/11 17:05:50 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -6209,7 +6209,7 @@ wm_init_locked(struct ifnet *ifp) * 82574's EITR should be set same throttling value as ITR. * * For N interrupts/sec, set this value to: - * 1,000,000 / N in contrast to ITR throttoling value. + * 1,000,000 / N in contrast to ITR throttling value. */ sc->sc_itr_init = 450; } else if (sc->sc_type >= WM_T_82543) {
CVS commit: src/sys/dev/pci
Module Name:src Committed By: skrll Date: Sat Dec 11 17:05:50 UTC 2021 Modified Files: src/sys/dev/pci: if_wm.c Log Message: Typo in comment To generate a diff of this commit: cvs rdiff -u -r1.721 -r1.722 src/sys/dev/pci/if_wm.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
Module Name:src Committed By: rillig Date: Sat Dec 11 11:13:30 UTC 2021 Modified Files: src/usr.bin/make: cond.c Log Message: make: remove dead code in CondParser_FuncCall The return value (size_t)-1 was only used by the function 'empty', which moved to CondParser_FuncCallEmpty. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.297 -r1.298 src/usr.bin/make/cond.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.297 src/usr.bin/make/cond.c:1.298 --- src/usr.bin/make/cond.c:1.297 Sat Dec 11 10:57:10 2021 +++ src/usr.bin/make/cond.c Sat Dec 11 11:13:30 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.297 2021/12/11 10:57:10 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.298 2021/12/11 11:13:30 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -95,7 +95,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.297 2021/12/11 10:57:10 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.298 2021/12/11 11:13:30 rillig Exp $"); /* * The parsing of conditional expressions is based on this grammar: @@ -777,9 +777,9 @@ CondParser_FuncCall(CondParser *par, boo return false; arglen = ParseFuncArg(par, , doEval, fn->fn_name, ); - if (arglen == 0 || arglen == (size_t)-1) { + if (arglen == 0) { par->p = cp; - *out_token = arglen == 0 ? TOK_FALSE : TOK_ERROR; + *out_token = TOK_FALSE; return true; }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Dec 11 11:13:30 UTC 2021 Modified Files: src/usr.bin/make: cond.c Log Message: make: remove dead code in CondParser_FuncCall The return value (size_t)-1 was only used by the function 'empty', which moved to CondParser_FuncCallEmpty. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.297 -r1.298 src/usr.bin/make/cond.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Dec 11 10:57:10 UTC 2021 Modified Files: src/usr.bin/make: cond.c Log Message: make: remove unused function parameter in conditional handling No functional change. To generate a diff of this commit: cvs rdiff -u -r1.296 -r1.297 src/usr.bin/make/cond.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.296 src/usr.bin/make/cond.c:1.297 --- src/usr.bin/make/cond.c:1.296 Sat Dec 11 10:51:03 2021 +++ src/usr.bin/make/cond.c Sat Dec 11 10:57:10 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.296 2021/12/11 10:51:03 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.297 2021/12/11 10:57:10 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -95,7 +95,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.296 2021/12/11 10:51:03 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.297 2021/12/11 10:57:10 rillig Exp $"); /* * The parsing of conditional expressions is based on this grammar: @@ -149,7 +149,7 @@ typedef struct CondParser { bool plain; /* The function to apply on unquoted bare words. */ - bool (*evalBare)(size_t, const char *); + bool (*evalBare)(const char *); bool negateEvalBare; /* @@ -290,9 +290,8 @@ ParseFuncArg(CondParser *par, const char } /* Test whether the given variable is defined. */ -/*ARGSUSED*/ static bool -FuncDefined(size_t argLen MAKE_ATTR_UNUSED, const char *arg) +FuncDefined(const char *arg) { FStr value = Var_Value(SCOPE_CMDLINE, arg); bool result = value.str != NULL; @@ -301,9 +300,8 @@ FuncDefined(size_t argLen MAKE_ATTR_UNUS } /* See if the given target is requested to be made. */ -/*ARGSUSED*/ static bool -FuncMake(size_t argLen MAKE_ATTR_UNUSED, const char *arg) +FuncMake(const char *arg) { StringListNode *ln; @@ -314,9 +312,8 @@ FuncMake(size_t argLen MAKE_ATTR_UNUSED, } /* See if the given file exists. */ -/*ARGSUSED*/ static bool -FuncExists(size_t argLen MAKE_ATTR_UNUSED, const char *arg) +FuncExists(const char *arg) { bool result; char *path; @@ -330,9 +327,8 @@ FuncExists(size_t argLen MAKE_ATTR_UNUSE } /* See if the given node exists and is an actual target. */ -/*ARGSUSED*/ static bool -FuncTarget(size_t argLen MAKE_ATTR_UNUSED, const char *arg) +FuncTarget(const char *arg) { GNode *gn = Targ_FindNode(arg); return gn != NULL && GNode_IsTarget(gn); @@ -342,9 +338,8 @@ FuncTarget(size_t argLen MAKE_ATTR_UNUSE * See if the given node exists and is an actual target with commands * associated with it. */ -/*ARGSUSED*/ static bool -FuncCommands(size_t argLen MAKE_ATTR_UNUSED, const char *arg) +FuncCommands(const char *arg) { GNode *gn = Targ_FindNode(arg); return gn != NULL && GNode_IsTarget(gn) && !Lst_IsEmpty(>commands); @@ -537,9 +532,9 @@ cleanup: } static bool -EvalBare(const CondParser *par, const char *arg, size_t arglen) +EvalBare(const CondParser *par, const char *arg) { - bool res = par->evalBare(arglen, arg); + bool res = par->evalBare(arg); return par->negateEvalBare ? !res : res; } @@ -570,7 +565,7 @@ EvalNotEmpty(CondParser *par, const char if (par->plain) return value[0] != '\0'; - return EvalBare(par, value, strlen(value)); + return EvalBare(par, value); } /* Evaluate a numerical comparison, such as in ".if ${VAR} >= 9". */ @@ -758,7 +753,7 @@ CondParser_FuncCall(CondParser *par, boo static const struct fn_def { const char fn_name[9]; unsigned char fn_name_len; - bool (*fn_eval)(size_t, const char *); + bool (*fn_eval)(const char *); } fns[] = { { "defined", 7, FuncDefined }, { "make", 4, FuncMake }, @@ -789,7 +784,7 @@ CondParser_FuncCall(CondParser *par, boo } /* Evaluate the argument using the required function. */ - *out_token = ToToken(!doEval || fn->fn_eval(arglen, arg)); + *out_token = ToToken(!doEval || fn->fn_eval(arg)); free(arg); par->p = cp; return true; @@ -804,7 +799,6 @@ CondParser_ComparisonOrLeaf(CondParser * { Token t; char *arg = NULL; - size_t arglen; const char *cp; const char *cp1; @@ -825,7 +819,7 @@ CondParser_ComparisonOrLeaf(CondParser * * XXX: Is it possible to have a variable expression evaluated twice * at this point? */ - arglen = ParseFuncArg(par, , doEval, NULL, ); + (void)ParseFuncArg(par, , doEval, NULL, ); cp1 = cp; cpp_skip_whitespace(); if (*cp1 == '=' || *cp1 == '!' || *cp1 == '<' || *cp1 == '>') @@ -838,7 +832,7 @@ CondParser_ComparisonOrLeaf(CondParser * * after .if must have been taken literally, so the argument cannot * be empty - even if it contained a variable expansion. */ - t = ToToken(!doEval || EvalBare(par, arg, arglen)); + t = ToToken(!doEval || EvalBare(par, arg)); free(arg); return t; } @@ -1040,7 +1034,7 @@ CondParser_Eval(CondParser *par, bool *o
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Dec 11 10:57:10 UTC 2021 Modified Files: src/usr.bin/make: cond.c Log Message: make: remove unused function parameter in conditional handling No functional change. To generate a diff of this commit: cvs rdiff -u -r1.296 -r1.297 src/usr.bin/make/cond.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Dec 11 10:51:03 UTC 2021 Modified Files: src/usr.bin/make: cond.c Log Message: make: clean up CondParser_FuncCallEmpty No functional change. To generate a diff of this commit: cvs rdiff -u -r1.295 -r1.296 src/usr.bin/make/cond.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.295 src/usr.bin/make/cond.c:1.296 --- src/usr.bin/make/cond.c:1.295 Sat Dec 11 10:41:31 2021 +++ src/usr.bin/make/cond.c Sat Dec 11 10:51:03 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.295 2021/12/11 10:41:31 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.296 2021/12/11 10:51:03 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -95,7 +95,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.295 2021/12/11 10:41:31 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.296 2021/12/11 10:51:03 rillig Exp $"); /* * The parsing of conditional expressions is based on this grammar: @@ -737,18 +737,15 @@ CondParser_FuncCallEmpty(CondParser *par (void)Var_Parse(, SCOPE_CMDLINE, doEval ? VARE_WANTRES : VARE_PARSE_ONLY, ); /* TODO: handle errors */ - /* If successful, cp points beyond the closing ')' now. */ if (val.str == var_Error) tok = TOK_ERROR; else { cpp_skip_whitespace(); - tok = val.str[0] != '\0' ? TOK_FALSE : TOK_TRUE; + tok = val.str[0] != '\0' && doEval ? TOK_FALSE : TOK_TRUE; } FStr_Done(); - if (tok == TOK_FALSE && !doEval) - tok = TOK_TRUE; *out_token = tok; par->p = cp; return true;
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Dec 11 10:51:03 UTC 2021 Modified Files: src/usr.bin/make: cond.c Log Message: make: clean up CondParser_FuncCallEmpty No functional change. To generate a diff of this commit: cvs rdiff -u -r1.295 -r1.296 src/usr.bin/make/cond.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Dec 11 10:41:31 UTC 2021 Modified Files: src/usr.bin/make: cond.c var.c src/usr.bin/make/unit-tests: cond-func-empty.mk Log Message: make: inline ParseEmptyArg into CondParser_FuncCallEmpty No functional change. To generate a diff of this commit: cvs rdiff -u -r1.294 -r1.295 src/usr.bin/make/cond.c cvs rdiff -u -r1.970 -r1.971 src/usr.bin/make/var.c cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/cond-func-empty.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.294 src/usr.bin/make/cond.c:1.295 --- src/usr.bin/make/cond.c:1.294 Sat Dec 11 10:28:59 2021 +++ src/usr.bin/make/cond.c Sat Dec 11 10:41:31 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.294 2021/12/11 10:28:59 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.295 2021/12/11 10:41:31 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -95,7 +95,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.294 2021/12/11 10:28:59 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.295 2021/12/11 10:41:31 rillig Exp $"); /* * The parsing of conditional expressions is based on this grammar: @@ -563,7 +563,10 @@ EvalNotEmpty(CondParser *par, const char /* For .if ${...}, check for non-empty string. This is different from * the evaluation function from that .if variant, which would test * whether a variable of the given name were defined. */ - /* XXX: Whitespace should count as empty, just as in ParseEmptyArg. */ + /* + * XXX: Whitespace should count as empty, just as in + * CondParser_FuncCallEmpty. + */ if (par->plain) return value[0] != '\0'; @@ -715,17 +718,26 @@ done_lhs: * The argument to empty() is a variable name, optionally followed by * variable modifiers. */ -static Token -ParseEmptyArg(const char **pp, bool doEval) +static bool +CondParser_FuncCallEmpty(CondParser *par, bool doEval, Token *out_token) { - FStr val; + const char *cp = par->p; Token tok; + FStr val; + + if (!is_token(cp, "empty", 5)) + return false; + cp += 5; + + cpp_skip_whitespace(); + if (*cp != '(') + return false; - (*pp)--; /* Make (*pp)[1] point to the '('. */ - (void)Var_Parse(pp, SCOPE_CMDLINE, + cp--; /* Make cp[1] point to the '('. */ + (void)Var_Parse(, SCOPE_CMDLINE, doEval ? VARE_WANTRES : VARE_PARSE_ONLY, ); /* TODO: handle errors */ - /* If successful, *pp points beyond the closing ')' now. */ + /* If successful, cp points beyond the closing ')' now. */ if (val.str == var_Error) tok = TOK_ERROR; @@ -735,24 +747,6 @@ ParseEmptyArg(const char **pp, bool doEv } FStr_Done(); - return tok; -} - -static bool -CondParser_FuncCallEmpty(CondParser *par, bool doEval, Token *out_token) -{ - Token tok; - const char *cp = par->p; - - if (!is_token(cp, "empty", 5)) - return false; - cp += 5; - - cpp_skip_whitespace(); - if (*cp != '(') - return false; - - tok = ParseEmptyArg(, doEval); if (tok == TOK_FALSE && !doEval) tok = TOK_TRUE; *out_token = tok; Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.970 src/usr.bin/make/var.c:1.971 --- src/usr.bin/make/var.c:1.970 Thu Dec 9 20:27:01 2021 +++ src/usr.bin/make/var.c Sat Dec 11 10:41:31 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.970 2021/12/09 20:27:01 rillig Exp $ */ +/* $NetBSD: var.c,v 1.971 2021/12/11 10:41: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.970 2021/12/09 20:27:01 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.971 2021/12/11 10:41:31 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -4517,9 +4517,9 @@ Var_Parse_FastLane(const char **pp, VarE * * Input: * *pp The string to parse. - * When parsing a condition in ParseEmptyArg, it may also - * point to the "y" of "empty(VARNAME:Modifiers)", which - * is syntactically the same. + * In CondParser_FuncCallEmpty, it may also point to the + * "y" of "empty(VARNAME:Modifiers)", which is + * syntactically the same. * scope The scope for finding variables * emode Controls the exact details of parsing and evaluation * Index: src/usr.bin/make/unit-tests/cond-func-empty.mk diff -u src/usr.bin/make/unit-tests/cond-func-empty.mk:1.15 src/usr.bin/make/unit-tests/cond-func-empty.mk:1.16 --- src/usr.bin/make/unit-tests/cond-func-empty.mk:1.15 Sat Dec 11 09:53:53 2021 +++ src/usr.bin/make/unit-tests/cond-func-empty.mk Sat Dec 11 10:41:31 2021 @@ -1,4 +1,4 @@ -# $NetBSD: cond-func-empty.mk,v 1.15 2021/12/11 09:53:53 rillig Exp $ +# $NetBSD: cond-func-empty.mk,v 1.16 2021/12/11 10:41:31 rillig Exp $ # # Tests for the empty() function in .if conditions, which tests a variable
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Dec 11 10:41:31 UTC 2021 Modified Files: src/usr.bin/make: cond.c var.c src/usr.bin/make/unit-tests: cond-func-empty.mk Log Message: make: inline ParseEmptyArg into CondParser_FuncCallEmpty No functional change. To generate a diff of this commit: cvs rdiff -u -r1.294 -r1.295 src/usr.bin/make/cond.c cvs rdiff -u -r1.970 -r1.971 src/usr.bin/make/var.c cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/cond-func-empty.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Dec 11 10:28:59 UTC 2021 Modified Files: src/usr.bin/make: cond.c Log Message: make: simplify evaluation of function 'empty' No functional change. To generate a diff of this commit: cvs rdiff -u -r1.293 -r1.294 src/usr.bin/make/cond.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Dec 11 10:28:59 UTC 2021 Modified Files: src/usr.bin/make: cond.c Log Message: make: simplify evaluation of function 'empty' No functional change. To generate a diff of this commit: cvs rdiff -u -r1.293 -r1.294 src/usr.bin/make/cond.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.293 src/usr.bin/make/cond.c:1.294 --- src/usr.bin/make/cond.c:1.293 Sat Dec 11 10:21:02 2021 +++ src/usr.bin/make/cond.c Sat Dec 11 10:28:59 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.293 2021/12/11 10:21:02 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.294 2021/12/11 10:28:59 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -95,7 +95,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.293 2021/12/11 10:21:02 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.294 2021/12/11 10:28:59 rillig Exp $"); /* * The parsing of conditional expressions is based on this grammar: @@ -753,13 +753,9 @@ CondParser_FuncCallEmpty(CondParser *par return false; tok = ParseEmptyArg(, doEval); - if (tok == TOK_ERROR) { - par->p = cp; - *out_token = TOK_ERROR; - return true; - } - - *out_token = ToToken(!doEval || tok == TOK_TRUE); + if (tok == TOK_FALSE && !doEval) + tok = TOK_TRUE; + *out_token = tok; par->p = cp; return true; }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Dec 11 10:21:02 UTC 2021 Modified Files: src/usr.bin/make: cond.c Log Message: make: merge duplicate code in ParseEmptyArg No functional change. To generate a diff of this commit: cvs rdiff -u -r1.292 -r1.293 src/usr.bin/make/cond.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.292 src/usr.bin/make/cond.c:1.293 --- src/usr.bin/make/cond.c:1.292 Sat Dec 11 10:14:32 2021 +++ src/usr.bin/make/cond.c Sat Dec 11 10:21:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.292 2021/12/11 10:14:32 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.293 2021/12/11 10:21:02 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -95,7 +95,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.292 2021/12/11 10:14:32 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.293 2021/12/11 10:21:02 rillig Exp $"); /* * The parsing of conditional expressions is based on this grammar: @@ -727,18 +727,13 @@ ParseEmptyArg(const char **pp, bool doEv /* TODO: handle errors */ /* If successful, *pp points beyond the closing ')' now. */ - if (val.str == var_Error) { - FStr_Done(); - return TOK_ERROR; + if (val.str == var_Error) + tok = TOK_ERROR; + else { + cpp_skip_whitespace(); + tok = val.str[0] != '\0' ? TOK_FALSE : TOK_TRUE; } - /* - * A variable is empty when it just contains spaces... - * 4/15/92, christos - */ - cpp_skip_whitespace(); - - tok = val.str[0] != '\0' ? TOK_FALSE : TOK_TRUE; FStr_Done(); return tok; }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Dec 11 10:21:02 UTC 2021 Modified Files: src/usr.bin/make: cond.c Log Message: make: merge duplicate code in ParseEmptyArg No functional change. To generate a diff of this commit: cvs rdiff -u -r1.292 -r1.293 src/usr.bin/make/cond.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Dec 11 10:14:33 UTC 2021 Modified Files: src/usr.bin/make: cond.c Log Message: make: use proper return type for ParseEmptyArg Now that ParseEmptyArg is no longer bound to have the same prototype as ParseFuncArg, it can use a more appropriate return type instead of encoding everything in a size_t. Since ParseEmptyArg never returned 0, that code path was unused. It was only used for all other functions. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.291 -r1.292 src/usr.bin/make/cond.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.291 src/usr.bin/make/cond.c:1.292 --- src/usr.bin/make/cond.c:1.291 Sat Dec 11 10:07:31 2021 +++ src/usr.bin/make/cond.c Sat Dec 11 10:14:32 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.291 2021/12/11 10:07:31 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.292 2021/12/11 10:14:32 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -95,7 +95,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.291 2021/12/11 10:07:31 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.292 2021/12/11 10:14:32 rillig Exp $"); /* * The parsing of conditional expressions is based on this grammar: @@ -715,11 +715,11 @@ done_lhs: * The argument to empty() is a variable name, optionally followed by * variable modifiers. */ -static size_t +static Token ParseEmptyArg(const char **pp, bool doEval) { FStr val; - size_t magic_res; + Token tok; (*pp)--; /* Make (*pp)[1] point to the '('. */ (void)Var_Parse(pp, SCOPE_CMDLINE, @@ -729,7 +729,7 @@ ParseEmptyArg(const char **pp, bool doEv if (val.str == var_Error) { FStr_Done(); - return (size_t)-1; + return TOK_ERROR; } /* @@ -738,19 +738,15 @@ ParseEmptyArg(const char **pp, bool doEv */ cpp_skip_whitespace(); - /* - * For consistency with the other functions we can't generate the - * true/false here. - */ - magic_res = val.str[0] != '\0' ? 2 : 1; + tok = val.str[0] != '\0' ? TOK_FALSE : TOK_TRUE; FStr_Done(); - return magic_res; + return tok; } static bool CondParser_FuncCallEmpty(CondParser *par, bool doEval, Token *out_token) { - size_t arglen; + Token tok; const char *cp = par->p; if (!is_token(cp, "empty", 5)) @@ -761,14 +757,14 @@ CondParser_FuncCallEmpty(CondParser *par if (*cp != '(') return false; - arglen = ParseEmptyArg(, doEval); - if (arglen == 0 || arglen == (size_t)-1) { + tok = ParseEmptyArg(, doEval); + if (tok == TOK_ERROR) { par->p = cp; - *out_token = arglen == 0 ? TOK_FALSE : TOK_ERROR; + *out_token = TOK_ERROR; return true; } - *out_token = ToToken(!doEval || arglen == 1); + *out_token = ToToken(!doEval || tok == TOK_TRUE); par->p = cp; return true; }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Dec 11 10:14:33 UTC 2021 Modified Files: src/usr.bin/make: cond.c Log Message: make: use proper return type for ParseEmptyArg Now that ParseEmptyArg is no longer bound to have the same prototype as ParseFuncArg, it can use a more appropriate return type instead of encoding everything in a size_t. Since ParseEmptyArg never returned 0, that code path was unused. It was only used for all other functions. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.291 -r1.292 src/usr.bin/make/cond.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Dec 11 10:07:31 UTC 2021 Modified Files: src/usr.bin/make: cond.c Log Message: make: remove unused arguments from CondParser_FuncCallEmpty No functional change. To generate a diff of this commit: cvs rdiff -u -r1.290 -r1.291 src/usr.bin/make/cond.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.290 src/usr.bin/make/cond.c:1.291 --- src/usr.bin/make/cond.c:1.290 Sat Dec 11 10:01:16 2021 +++ src/usr.bin/make/cond.c Sat Dec 11 10:07:31 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.290 2021/12/11 10:01:16 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.291 2021/12/11 10:07:31 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -95,7 +95,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.290 2021/12/11 10:01:16 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.291 2021/12/11 10:07:31 rillig Exp $"); /* * The parsing of conditional expressions is based on this grammar: @@ -715,18 +715,12 @@ done_lhs: * The argument to empty() is a variable name, optionally followed by * variable modifiers. */ -/*ARGSUSED*/ static size_t -ParseEmptyArg(CondParser *par MAKE_ATTR_UNUSED, const char **pp, - bool doEval, const char *func MAKE_ATTR_UNUSED, - char **out_arg) +ParseEmptyArg(const char **pp, bool doEval) { FStr val; size_t magic_res; - /* We do all the work here and return the result as the length */ - *out_arg = NULL; - (*pp)--; /* Make (*pp)[1] point to the '('. */ (void)Var_Parse(pp, SCOPE_CMDLINE, doEval ? VARE_WANTRES : VARE_PARSE_ONLY, ); @@ -753,18 +747,9 @@ ParseEmptyArg(CondParser *par MAKE_ATTR_ return magic_res; } -/*ARGSUSED*/ -static bool -FuncEmpty(size_t arglen, const char *arg MAKE_ATTR_UNUSED) -{ - /* Magic values ahead, see ParseEmptyArg. */ - return arglen == 1; -} - static bool CondParser_FuncCallEmpty(CondParser *par, bool doEval, Token *out_token) { - char *arg = NULL; size_t arglen; const char *cp = par->p; @@ -776,16 +761,14 @@ CondParser_FuncCallEmpty(CondParser *par if (*cp != '(') return false; - arglen = ParseEmptyArg(par, , doEval, "empty", ); + arglen = ParseEmptyArg(, doEval); if (arglen == 0 || arglen == (size_t)-1) { par->p = cp; *out_token = arglen == 0 ? TOK_FALSE : TOK_ERROR; return true; } - /* Evaluate the argument using the required function. */ - *out_token = ToToken(!doEval || FuncEmpty(arglen, arg)); - free(arg); + *out_token = ToToken(!doEval || arglen == 1); par->p = cp; return true; }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Dec 11 10:07:31 UTC 2021 Modified Files: src/usr.bin/make: cond.c Log Message: make: remove unused arguments from CondParser_FuncCallEmpty No functional change. To generate a diff of this commit: cvs rdiff -u -r1.290 -r1.291 src/usr.bin/make/cond.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Dec 11 10:01:16 UTC 2021 Modified Files: src/usr.bin/make: cond.c Log Message: make: separate handling of 'empty' and the other functions No functional change. To generate a diff of this commit: cvs rdiff -u -r1.289 -r1.290 src/usr.bin/make/cond.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Dec 11 10:01:16 UTC 2021 Modified Files: src/usr.bin/make: cond.c Log Message: make: separate handling of 'empty' and the other functions No functional change. To generate a diff of this commit: cvs rdiff -u -r1.289 -r1.290 src/usr.bin/make/cond.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.289 src/usr.bin/make/cond.c:1.290 --- src/usr.bin/make/cond.c:1.289 Fri Dec 10 23:56:17 2021 +++ src/usr.bin/make/cond.c Sat Dec 11 10:01:16 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.289 2021/12/10 23:56:17 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.290 2021/12/11 10:01:16 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -95,7 +95,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.289 2021/12/10 23:56:17 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.290 2021/12/11 10:01:16 rillig Exp $"); /* * The parsing of conditional expressions is based on this grammar: @@ -761,6 +761,35 @@ FuncEmpty(size_t arglen, const char *arg return arglen == 1; } +static bool +CondParser_FuncCallEmpty(CondParser *par, bool doEval, Token *out_token) +{ + char *arg = NULL; + size_t arglen; + const char *cp = par->p; + + if (!is_token(cp, "empty", 5)) + return false; + cp += 5; + + cpp_skip_whitespace(); + if (*cp != '(') + return false; + + arglen = ParseEmptyArg(par, , doEval, "empty", ); + if (arglen == 0 || arglen == (size_t)-1) { + par->p = cp; + *out_token = arglen == 0 ? TOK_FALSE : TOK_ERROR; + return true; + } + + /* Evaluate the argument using the required function. */ + *out_token = ToToken(!doEval || FuncEmpty(arglen, arg)); + free(arg); + par->p = cp; + return true; +} + /* Parse a function call expression, such as 'defined(${file})'. */ static bool CondParser_FuncCall(CondParser *par, bool doEval, Token *out_token) @@ -768,16 +797,13 @@ CondParser_FuncCall(CondParser *par, boo static const struct fn_def { const char fn_name[9]; unsigned char fn_name_len; - size_t (*fn_parse)(CondParser *, const char **, bool, - const char *, char **); bool (*fn_eval)(size_t, const char *); } fns[] = { - { "defined", 7, ParseFuncArg, FuncDefined }, - { "make", 4, ParseFuncArg, FuncMake }, - { "exists", 6, ParseFuncArg, FuncExists }, - { "empty",5, ParseEmptyArg, FuncEmpty }, - { "target", 6, ParseFuncArg, FuncTarget }, - { "commands", 8, ParseFuncArg, FuncCommands } + { "defined", 7, FuncDefined }, + { "make", 4, FuncMake }, + { "exists", 6, FuncExists }, + { "target", 6, FuncTarget }, + { "commands", 8, FuncCommands } }; const struct fn_def *fn; char *arg = NULL; @@ -794,7 +820,7 @@ CondParser_FuncCall(CondParser *par, boo if (*cp != '(') return false; - arglen = fn->fn_parse(par, , doEval, fn->fn_name, ); + arglen = ParseFuncArg(par, , doEval, fn->fn_name, ); if (arglen == 0 || arglen == (size_t)-1) { par->p = cp; *out_token = arglen == 0 ? TOK_FALSE : TOK_ERROR; @@ -917,6 +943,8 @@ CondParser_Token(CondParser *par, bool d return CondParser_Comparison(par, doEval); default: + if (CondParser_FuncCallEmpty(par, doEval, )) + return t; if (CondParser_FuncCall(par, doEval, )) return t; return CondParser_ComparisonOrLeaf(par, doEval);
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sat Dec 11 09:53:53 UTC 2021 Modified Files: src/usr.bin/make/unit-tests: cond-cmp-string.mk cond-func-empty.exp cond-func-empty.mk Log Message: tests/make: proofread and clean up comments for function 'empty' This prepares a refactoring for handling the function 'empty' in conditionals like '.if'. The function 'empty' is fundamentally different from all other functions since it is parsed differently and passes its result on different path than the other functions. Splitting up these code paths will untangle the control flow of parsing a condition like 'empty(VARNAME)'. It will also remove several ARGSUSED and MAKE_ATTR_UNUSED that make the current code smell. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/cond-cmp-string.mk \ src/usr.bin/make/unit-tests/cond-func-empty.mk cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cond-func-empty.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
Module Name:src Committed By: rillig Date: Sat Dec 11 09:53:53 UTC 2021 Modified Files: src/usr.bin/make/unit-tests: cond-cmp-string.mk cond-func-empty.exp cond-func-empty.mk Log Message: tests/make: proofread and clean up comments for function 'empty' This prepares a refactoring for handling the function 'empty' in conditionals like '.if'. The function 'empty' is fundamentally different from all other functions since it is parsed differently and passes its result on different path than the other functions. Splitting up these code paths will untangle the control flow of parsing a condition like 'empty(VARNAME)'. It will also remove several ARGSUSED and MAKE_ATTR_UNUSED that make the current code smell. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/cond-cmp-string.mk \ src/usr.bin/make/unit-tests/cond-func-empty.mk cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cond-func-empty.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/unit-tests/cond-cmp-string.mk diff -u src/usr.bin/make/unit-tests/cond-cmp-string.mk:1.14 src/usr.bin/make/unit-tests/cond-cmp-string.mk:1.15 --- src/usr.bin/make/unit-tests/cond-cmp-string.mk:1.14 Tue Jan 19 19:54:57 2021 +++ src/usr.bin/make/unit-tests/cond-cmp-string.mk Sat Dec 11 09:53:53 2021 @@ -1,4 +1,4 @@ -# $NetBSD: cond-cmp-string.mk,v 1.14 2021/01/19 19:54:57 rillig Exp $ +# $NetBSD: cond-cmp-string.mk,v 1.15 2021/12/11 09:53:53 rillig Exp $ # # Tests for string comparisons in .if conditions. @@ -26,7 +26,7 @@ # starting point for variable expressions. Applying the :U modifier to such # an undefined expression turns it into a defined expression. # -# See ApplyModifier_Defined and VEF_DEF. +# See ApplyModifier_Defined and DEF_DEFINED. .if ${:Ustr} != "str" . error .endif Index: src/usr.bin/make/unit-tests/cond-func-empty.mk diff -u src/usr.bin/make/unit-tests/cond-func-empty.mk:1.14 src/usr.bin/make/unit-tests/cond-func-empty.mk:1.15 --- src/usr.bin/make/unit-tests/cond-func-empty.mk:1.14 Sun Apr 11 13:35:56 2021 +++ src/usr.bin/make/unit-tests/cond-func-empty.mk Sat Dec 11 09:53:53 2021 @@ -1,10 +1,10 @@ -# $NetBSD: cond-func-empty.mk,v 1.14 2021/04/11 13:35:56 rillig Exp $ +# $NetBSD: cond-func-empty.mk,v 1.15 2021/12/11 09:53:53 rillig Exp $ # # Tests for the empty() function in .if conditions, which tests a variable # expression for emptiness. # -# Note that the argument in the parentheses is indeed a variable name, -# optionally followed by variable modifiers. +# Note that the argument in the parentheses is a variable name, not a variable +# expression, optionally followed by variable modifiers. # .undef UNDEF @@ -25,14 +25,10 @@ WORD= word .endif # The :S modifier replaces the empty value with an actual word. The -# expression is now no longer empty, but it is still possible to see whether -# the expression was based on an undefined variable. The expression has the -# flag VEF_UNDEF. -# -# The expression does not have the flag VEF_DEF though, therefore it is still -# considered undefined. Yes, indeed, undefined but not empty. There are a -# few variable modifiers that turn an undefined expression into a defined -# expression, among them :U and :D, but not :S. +# expression is now no longer empty, but it is still based on an undefined +# variable (DEF_UNDEF). There are a few variable modifiers that turn an +# undefined expression into a defined expression, among them :U and :D, but +# not :S. # # XXX: This is hard to explain to someone who doesn't know these # implementation details. @@ -41,19 +37,19 @@ WORD= word . error .endif -# The :U modifier modifies expressions based on undefined variables -# (DEF_UNDEF) by adding the DEF_DEFINED flag, which marks the expression -# as "being interesting enough to be further processed". +# The :U modifier changes the state of a previously undefined expression from +# DEF_UNDEF to DEF_DEFINED. This marks the expression as "being interesting +# enough to be further processed". # .if empty(UNDEF:S,^$,value,W:Ufallback) . error .endif # And now to the surprising part. Applying the following :S modifier to the -# undefined expression makes it non-empty, but the marker VEF_UNDEF is -# preserved nevertheless. The :U modifier that follows only looks at the -# VEF_UNDEF flag to decide whether the variable is defined or not. This kind -# of makes sense since the :U modifier tests the _variable_, not the +# undefined expression makes it non-empty, but the expression is still in +# state DEF_UNDEF. The :U modifier that follows only looks at the state +# DEF_UNDEF to decide whether the variable is defined or not. This kind of +# makes sense since the :U modifier tests the _variable_, not the # _expression_. # # But since the variable was undefined to begin with, the fallback value from @@