CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Oct 31 09:12:14 UTC 2024 Modified Files: src/usr.bin/make: parse.c src/usr.bin/make/unit-tests: Makefile deptgt-order.exp deptgt.exp directive-export-impl.exp directive-for-escape.exp include-main.exp opt-debug-parse.exp suff-incomplete.exp suff-main-several.exp suff-rebuild.exp var-eval-short.exp varmod-indirect.exp varmod-loop.exp varname-dot-shell.exp Log Message: make: in the debug log, always qualify line number with filename Previously, to find out the filename corresponding to a line number from a 'Parsing' line, it was necessary to find the preceding 'SetFilenameVars' line, which was unnecessarily time-consuming and distracting. The 'filename:line' format matches the one used in PrintStackTrace, and it differs from the one used in PrintLocation, as the former format is more common in other tools. Most of the affected unit tests only use the 'Parsing' lines to give additional context to their debug log, so no structural changes there. To generate a diff of this commit: cvs rdiff -u -r1.735 -r1.736 src/usr.bin/make/parse.c cvs rdiff -u -r1.351 -r1.352 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/deptgt-order.exp cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/deptgt.exp \ src/usr.bin/make/unit-tests/directive-export-impl.exp cvs rdiff -u -r1.31 -r1.32 \ src/usr.bin/make/unit-tests/directive-for-escape.exp \ src/usr.bin/make/unit-tests/var-eval-short.exp cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/include-main.exp \ src/usr.bin/make/unit-tests/suff-main-several.exp cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/opt-debug-parse.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/suff-incomplete.exp cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/suff-rebuild.exp cvs rdiff -u -r1.30 -r1.31 src/usr.bin/make/unit-tests/varmod-indirect.exp cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/varmod-loop.exp \ src/usr.bin/make/unit-tests/varname-dot-shell.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Oct 31 09:12:14 UTC 2024 Modified Files: src/usr.bin/make: parse.c src/usr.bin/make/unit-tests: Makefile deptgt-order.exp deptgt.exp directive-export-impl.exp directive-for-escape.exp include-main.exp opt-debug-parse.exp suff-incomplete.exp suff-main-several.exp suff-rebuild.exp var-eval-short.exp varmod-indirect.exp varmod-loop.exp varname-dot-shell.exp Log Message: make: in the debug log, always qualify line number with filename Previously, to find out the filename corresponding to a line number from a 'Parsing' line, it was necessary to find the preceding 'SetFilenameVars' line, which was unnecessarily time-consuming and distracting. The 'filename:line' format matches the one used in PrintStackTrace, and it differs from the one used in PrintLocation, as the former format is more common in other tools. Most of the affected unit tests only use the 'Parsing' lines to give additional context to their debug log, so no structural changes there. To generate a diff of this commit: cvs rdiff -u -r1.735 -r1.736 src/usr.bin/make/parse.c cvs rdiff -u -r1.351 -r1.352 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/deptgt-order.exp cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/deptgt.exp \ src/usr.bin/make/unit-tests/directive-export-impl.exp cvs rdiff -u -r1.31 -r1.32 \ src/usr.bin/make/unit-tests/directive-for-escape.exp \ src/usr.bin/make/unit-tests/var-eval-short.exp cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/include-main.exp \ src/usr.bin/make/unit-tests/suff-main-several.exp cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/opt-debug-parse.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/suff-incomplete.exp cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/suff-rebuild.exp cvs rdiff -u -r1.30 -r1.31 src/usr.bin/make/unit-tests/varmod-indirect.exp cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/varmod-loop.exp \ src/usr.bin/make/unit-tests/varname-dot-shell.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/parse.c diff -u src/usr.bin/make/parse.c:1.735 src/usr.bin/make/parse.c:1.736 --- src/usr.bin/make/parse.c:1.735 Thu Aug 29 20:20:35 2024 +++ src/usr.bin/make/parse.c Thu Oct 31 09:12:13 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.735 2024/08/29 20:20:35 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.736 2024/10/31 09:12:13 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -105,7 +105,7 @@ #include "pathnames.h" /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: parse.c,v 1.735 2024/08/29 20:20:35 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.736 2024/10/31 09:12:13 rillig Exp $"); /* Detects a multiple-inclusion guard in a makefile. */ typedef enum { @@ -2617,7 +2617,8 @@ ReadHighLevelLine(void) if (line == NULL) return NULL; - DEBUG2(PARSE, "Parsing line %u: %s\n", curFile->lineno, line); + DEBUG3(PARSE, "Parsing %s:%u: %s\n", + curFile->name.str, curFile->lineno, line); if (curFile->guardState != GS_NO && ((curFile->guardState == GS_START && line[0] != '.') || curFile->guardState == GS_DONE)) Index: src/usr.bin/make/unit-tests/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.351 src/usr.bin/make/unit-tests/Makefile:1.352 --- src/usr.bin/make/unit-tests/Makefile:1.351 Sun Aug 18 13:40:51 2024 +++ src/usr.bin/make/unit-tests/Makefile Thu Oct 31 09:12:13 2024 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.351 2024/08/18 13:40:51 rillig Exp $ +# $NetBSD: Makefile,v 1.352 2024/10/31 09:12:13 rillig Exp $ # # Unit tests for make(1) # @@ -508,7 +508,7 @@ SED_CMDS.deptgt-phony= ${STD_SED_CMDS.dd SED_CMDS.dir= ${STD_SED_CMDS.dd} SED_CMDS.directive-include-guard= \ -e '/\.MAKEFLAGS/d' \ - -e '/^Parsing line/d' \ + -e '/^Parsing .*:[1-9][0-9]*:/d' \ -e '/^SetFilenameVars:/d' \ -e '/^ParseDependency/d' \ -e '/^ParseEOF:/d' Index: src/usr.bin/make/unit-tests/deptgt-order.exp diff -u src/usr.bin/make/unit-tests/deptgt-order.exp:1.5 src/usr.bin/make/unit-tests/deptgt-order.exp:1.6 --- src/usr.bin/make/unit-tests/deptgt-order.exp:1.5 Tue Dec 28 16:11:00 2021 +++ src/usr.bin/make/unit-tests/deptgt-order.exp Thu Oct 31 09:12:13 2024 @@ -1,9 +1,9 @@ -Parsing line 15: .ORDER: three one +Parsing deptgt-order.mk:15: .ORDER: three one ParseDependency(.ORDER: three one) # .ORDER forces 'three' to be made before 'one' # three, unmade, type OP_DEPENDS|OP_PHONY|OP_HAS_COMMANDS, flags none # one, unmade, type OP_DEPENDS|OP_PHONY, flags none -Parsing line 16: .MAKEFLAGS: -d0 +Parsing deptgt-order.mk:16: .MAKEFLAGS: -d0 ParseDependency(.MAKEFLAGS: -d0) : 'Making two out of one.' : 'Making three out of two.' Index: src/usr.bin/make/unit-tests/deptgt.exp diff -u src/usr.bin/make/unit-tests/deptgt.exp:1.18
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sat Sep 21 23:42:53 UTC 2024 Modified Files: src/usr.bin/make: make.1 Log Message: Only list the defaults for MAKEFILE_PREFERENCE once To generate a diff of this commit: cvs rdiff -u -r1.378 -r1.379 src/usr.bin/make/make.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/make.1 diff -u src/usr.bin/make/make.1:1.378 src/usr.bin/make/make.1:1.379 --- src/usr.bin/make/make.1:1.378 Mon Jul 1 21:02:26 2024 +++ src/usr.bin/make/make.1 Sat Sep 21 23:42:53 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.378 2024/07/01 21:02:26 sjg Exp $ +.\" $NetBSD: make.1,v 1.379 2024/09/21 23:42:53 sjg Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 .\" -.Dd July 1, 2024 +.Dd September 21, 2024 .Dt MAKE 1 .Os .Sh NAME @@ -233,10 +233,8 @@ so the actual commands are printed as th .It Fl e Let environment variables override global variables within makefiles. .It Fl f Ar makefile -Specify a makefile to read instead of the default -.Pa makefile -or -.Pa Makefile . +Specify a makefile to read instead of one of the defaults listed in +.Va .MAKE.MAKEFILE_PREFERENCE . If .Ar makefile is
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sat Sep 21 23:42:53 UTC 2024 Modified Files: src/usr.bin/make: make.1 Log Message: Only list the defaults for MAKEFILE_PREFERENCE once To generate a diff of this commit: cvs rdiff -u -r1.378 -r1.379 src/usr.bin/make/make.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Aug 31 06:21:27 UTC 2024 Modified Files: src/usr.bin/make: var.c Log Message: make: simplify printing of an evaluation stack element To generate a diff of this commit: cvs rdiff -u -r1.1139 -r1.1140 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
Module Name:src Committed By: rillig Date: Sat Aug 31 06:21:27 UTC 2024 Modified Files: src/usr.bin/make: var.c Log Message: make: simplify printing of an evaluation stack element To generate a diff of this commit: cvs rdiff -u -r1.1139 -r1.1140 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.1139 src/usr.bin/make/var.c:1.1140 --- src/usr.bin/make/var.c:1.1139 Thu Aug 29 20:20:35 2024 +++ src/usr.bin/make/var.c Sat Aug 31 06:21:27 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1139 2024/08/29 20:20:35 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1140 2024/08/31 06:21:27 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -128,7 +128,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1139 2024/08/29 20:20:35 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1140 2024/08/31 06:21:27 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -275,7 +275,6 @@ typedef struct { EvalStackElement *elems; size_t len; size_t cap; - Buffer details; } EvalStack; /* Whether we have replaced the original environ (which we cannot free). */ @@ -372,7 +371,6 @@ void EvalStack_PrintDetails(void) { size_t i; - Buffer *buf = &evalStack.details; for (i = evalStack.len; i > 0; i--) { static const char descr[][42] = { @@ -386,18 +384,13 @@ EvalStack_PrintDetails(void) }; EvalStackElement *elem = evalStack.elems + i - 1; EvalStackElementKind kind = elem->kind; - - buf->len = 0; - Buf_AddStr(buf, descr[kind]); - Buf_AddStr(buf, " \""); - Buf_AddStr(buf, elem->str); - if (elem->value != NULL - && (kind == VSK_VARNAME || kind == VSK_EXPR)) { - Buf_AddStr(buf, "\" with value \""); - Buf_AddStr(buf, elem->value->str); - } - Buf_AddStr(buf, "\""); - debug_printf("\t%s\n", buf->data); + const char* value = elem->value != NULL + && (kind == VSK_VARNAME || kind == VSK_EXPR) + ? elem->value->str : NULL; + + debug_printf("\t%s \"%s%s%s\"\n", descr[kind], elem->str, + value != NULL ? "\" with value \"" : "", + value != NULL ? value : ""); } }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Aug 29 20:20:37 UTC 2024 Modified Files: src/usr.bin/make: make.h parse.c var.c src/usr.bin/make/unit-tests: cmd-errors-jobs.exp cmd-errors-jobs.mk cmd-errors-lint.exp cmd-errors-lint.mk cmd-errors.exp cmd-errors.mk cond-late.exp cond-late.mk cond-token-string.exp cond-token-string.mk deptgt.exp deptgt.mk directive-for-errors.exp directive-for-errors.mk directive-for-escape.exp directive-for-escape.mk directive-for.exp directive-for.mk directive-include.exp directive-include.mk directive-undef.exp directive-undef.mk lint.exp moderrs.exp moderrs.mk opt-debug-lint.exp opt-debug-lint.mk var-eval-short.exp var-eval-short.mk var-op-expand.exp var-op-expand.mk var-recursive.exp var-recursive.mk vardebug.exp vardebug.mk varmisc.exp varmisc.mk varmod-assign-shell.exp varmod-assign-shell.mk varmod-assign.exp varmod-assign.mk varmod-edge.exp varmod-edge.mk varmod-gmtime.exp varmod-gmtime.mk varmod-hash.exp varmod-ifelse.exp varmod-ifelse.mk varmod-indirect.exp varmod-indirect.mk varmod-localtime.exp varmod-localtime.mk varmod-loop-delete.exp varmod-loop-delete.mk varmod-loop-varname.exp varmod-loop-varname.mk varmod-match-escape.exp varmod-match-escape.mk varmod-match.exp varmod-match.mk varmod-mtime.exp varmod-mtime.mk varmod-order.exp varmod-order.mk varmod-range.exp varmod-range.mk varmod-select-words.exp varmod-select-words.mk varmod-shell.exp varmod-shell.mk varmod-subst-regex.exp varmod-subst.exp varmod-subst.mk varmod-sun-shell.exp varmod-sun-shell.mk varmod-sysv.exp varmod-sysv.mk varmod-to-separator.exp varmod-to-separator.mk varmod.exp varmod.mk varparse-errors.exp varparse-errors.mk Log Message: make: reduce line length in error messages The error messages for deeply nested parse errors were hard to decipher, due to the large amount of text. Split these messages into individual lines, just as in the backtrace for .include files and .for loops. This unified backtrace makes the output more uniform. To generate a diff of this commit: cvs rdiff -u -r1.346 -r1.347 src/usr.bin/make/make.h cvs rdiff -u -r1.734 -r1.735 src/usr.bin/make/parse.c cvs rdiff -u -r1.1138 -r1.1139 src/usr.bin/make/var.c cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp \ src/usr.bin/make/unit-tests/cmd-errors.exp \ src/usr.bin/make/unit-tests/directive-for-errors.mk cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/cmd-errors-jobs.mk \ src/usr.bin/make/unit-tests/cond-token-string.mk \ src/usr.bin/make/unit-tests/directive-undef.exp \ src/usr.bin/make/unit-tests/var-recursive.exp \ src/usr.bin/make/unit-tests/vardebug.mk \ src/usr.bin/make/unit-tests/varmod-mtime.mk cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cmd-errors-lint.exp \ src/usr.bin/make/unit-tests/var-recursive.mk cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cmd-errors-lint.mk \ src/usr.bin/make/unit-tests/varmod-select-words.exp \ src/usr.bin/make/unit-tests/varmod-select-words.mk \ src/usr.bin/make/unit-tests/varmod-sun-shell.mk cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cmd-errors.mk \ src/usr.bin/make/unit-tests/varmod-loop-varname.mk \ src/usr.bin/make/unit-tests/varmod-mtime.exp \ src/usr.bin/make/unit-tests/varmod-shell.mk cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/cond-late.exp \ src/usr.bin/make/unit-tests/cond-late.mk \ src/usr.bin/make/unit-tests/directive-for-errors.exp \ src/usr.bin/make/unit-tests/varmod-assign-shell.exp \ src/usr.bin/make/unit-tests/varmod-assign-shell.mk \ src/usr.bin/make/unit-tests/varmod-shell.exp \ src/usr.bin/make/unit-tests/varmod-subst.exp cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/cond-token-string.exp \ src/usr.bin/make/unit-tests/directive-include.mk \ src/usr.bin/make/unit-tests/directive-undef.mk \ src/usr.bin/make/unit-tests/var-eval-short.mk \ src/usr.bin/make/unit-tests/varmod-order.exp \ src/usr.bin/make/unit-tests/varmod-subst.mk \ src/usr.bin/make/unit-tests/varmod-sysv.exp \ src/usr.bin/make/unit-tests/varparse-errors.exp cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/deptgt.exp \ src/usr.bin/make/unit-tests/varmod-match-escape.mk \ src/usr.bin/make/unit-tests/varmod-to-separator.exp cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/deptgt.mk \ src/usr.bin/make/unit-tests/varmod-indirect.mk \ src/usr.bin/make/unit-tests/varmod-sysv.mk cvs rdiff -u -r1.30 -r1.31 \ src/usr.bin/make/unit-tests/directive-for-escape.exp \ src/usr.bin/make/unit-tests/var-eval-short.exp \ src/usr.bin/make/unit-tests/varmod-edge.mk
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Thu Aug 29 17:56:37 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: cmdline.exp cmdline.mk Log Message: make: unit-tests/cmdline do not remove TMPDIR When running unit-tests in meta mode, removing TMPDIR while still in use is fatal. Ensure that TMPBASE used by cmdline.mk is a subdir of TMPDIR. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cmdline.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cmdline.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/cmdline.exp diff -u src/usr.bin/make/unit-tests/cmdline.exp:1.4 src/usr.bin/make/unit-tests/cmdline.exp:1.5 --- src/usr.bin/make/unit-tests/cmdline.exp:1.4 Fri Jun 10 18:58:07 2022 +++ src/usr.bin/make/unit-tests/cmdline.exp Thu Aug 29 17:56:37 2024 @@ -1,7 +1,7 @@ makeobjdir-direct: -show-objdir: /6a8899d2-d227-4b55-9b6b-f3c8eeb83fd5 +show-objdir: /cmdline/6a8899d2-d227-4b55-9b6b-f3c8eeb83fd5 makeobjdir-indirect: -show-objdir: /a7b41170-53f8-4cc2-bc5c-e4c3dd93ec45/ +show-objdir: /cmdline/a7b41170-53f8-4cc2-bc5c-e4c3dd93ec45/ space-and-comment: value # no comment $ value # no comment $ Index: src/usr.bin/make/unit-tests/cmdline.mk diff -u src/usr.bin/make/unit-tests/cmdline.mk:1.6 src/usr.bin/make/unit-tests/cmdline.mk:1.7 --- src/usr.bin/make/unit-tests/cmdline.mk:1.6 Sun Aug 18 13:40:51 2024 +++ src/usr.bin/make/unit-tests/cmdline.mk Thu Aug 29 17:56:37 2024 @@ -1,8 +1,8 @@ -# $NetBSD: cmdline.mk,v 1.6 2024/08/18 13:40:51 rillig Exp $ +# $NetBSD: cmdline.mk,v 1.7 2024/08/29 17:56:37 sjg Exp $ # # Tests for command line parsing and related special variables. -TMPBASE?= ${TMPDIR:U/tmp/uid${.MAKE.UID}} +TMPBASE?= ${TMPDIR:U/tmp/uid${.MAKE.UID}}/cmdline SUB1= a7b41170-53f8-4cc2-bc5c-e4c3dd93ec45 # just a random UUID SUB2= 6a8899d2-d227-4b55-9b6b-f3c8eeb83fd5 # just a random UUID MAKE_CMD= env TMPBASE=${TMPBASE}/${SUB1} ${.MAKE} -f ${MAKEFILE} -r
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Thu Aug 29 17:56:37 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: cmdline.exp cmdline.mk Log Message: make: unit-tests/cmdline do not remove TMPDIR When running unit-tests in meta mode, removing TMPDIR while still in use is fatal. Ensure that TMPBASE used by cmdline.mk is a subdir of TMPDIR. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cmdline.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cmdline.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
Module Name:src Committed By: rillig Date: Tue Aug 27 05:01:03 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: var-recursive.exp var-recursive.mk Log Message: tests/make: add stricter checks to test for recursive variables To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/var-recursive.exp cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/var-recursive.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
Module Name:src Committed By: rillig Date: Tue Aug 27 05:01:03 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: var-recursive.exp var-recursive.mk Log Message: tests/make: add stricter checks to test for recursive variables To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/var-recursive.exp cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/var-recursive.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-recursive.exp diff -u src/usr.bin/make/unit-tests/var-recursive.exp:1.11 src/usr.bin/make/unit-tests/var-recursive.exp:1.12 --- src/usr.bin/make/unit-tests/var-recursive.exp:1.11 Tue Aug 27 04:52:14 2024 +++ src/usr.bin/make/unit-tests/var-recursive.exp Tue Aug 27 05:01:03 2024 @@ -14,7 +14,7 @@ make: "var-recursive.mk" line 43: <> make: Fatal errors encountered -- cannot continue make: stopped making "loadtime" in unit-tests sub-exit status 1 -: OK +: before-recursive make: in target "runtime": while evaluating variable "VAR" with value "${VAR}": Variable VAR is recursive. sub-exit status 2 exit status 0 Index: src/usr.bin/make/unit-tests/var-recursive.mk diff -u src/usr.bin/make/unit-tests/var-recursive.mk:1.8 src/usr.bin/make/unit-tests/var-recursive.mk:1.9 --- src/usr.bin/make/unit-tests/var-recursive.mk:1.8 Tue Aug 27 04:52:14 2024 +++ src/usr.bin/make/unit-tests/var-recursive.mk Tue Aug 27 05:01:03 2024 @@ -1,4 +1,4 @@ -# $NetBSD: var-recursive.mk,v 1.8 2024/08/27 04:52:14 rillig Exp $ +# $NetBSD: var-recursive.mk,v 1.9 2024/08/27 05:01:03 rillig Exp $ # # Tests for expressions that refer to themselves and thus cannot be # evaluated, as that would lead to an endless loop. @@ -44,16 +44,16 @@ V= $V .elif make(runtime) -# If a recursive variable is accessed in a command of a target, the makefiles -# have already been fully parsed, so there is no location information from the -# .include and .for directives. In such a case, use the location of the last -# command of the target to provide at least a hint to the location. VAR= ${VAR} runtime: - : OK +# expect: : before-recursive + : before-recursive # expect: make: in target "runtime": while evaluating variable "VAR" with value "${VAR}": Variable VAR is recursive. - : <${VAR}> - : OK +# expect-not: recursive-line-before +# expect-not: recursive-line-after + : recursive-line-before <${VAR}> recursive-line-after +# expect-not: after-recursive + : after-recursive .else
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Tue Aug 27 04:52:14 UTC 2024 Modified Files: src/usr.bin/make: main.c make.h var.c src/usr.bin/make/unit-tests: var-recursive.exp var-recursive.mk Log Message: make: treat recursive variables non-fatally A recursive variable is no worse than an unknown modifier, so treat them in the same way by continuing parsing until the end of the makefile. To generate a diff of this commit: cvs rdiff -u -r1.633 -r1.634 src/usr.bin/make/main.c cvs rdiff -u -r1.345 -r1.346 src/usr.bin/make/make.h cvs rdiff -u -r1.1137 -r1.1138 src/usr.bin/make/var.c cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/var-recursive.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/var-recursive.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/main.c diff -u src/usr.bin/make/main.c:1.633 src/usr.bin/make/main.c:1.634 --- src/usr.bin/make/main.c:1.633 Sun Aug 25 20:44:31 2024 +++ src/usr.bin/make/main.c Tue Aug 27 04:52:14 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.633 2024/08/25 20:44:31 rillig Exp $ */ +/* $NetBSD: main.c,v 1.634 2024/08/27 04:52:14 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -111,7 +111,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.633 2024/08/25 20:44:31 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.634 2024/08/27 04:52:14 rillig Exp $"); #if defined(MAKE_NATIVE) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -1859,13 +1859,6 @@ Error(const char *fmt, ...) main_errors++; } -void -WaitForJobs(void) -{ - if (jobsRunning) - Job_Wait(); -} - /* * Wait for any running jobs to finish, then produce an error message, * finally exit immediately. @@ -1878,7 +1871,8 @@ Fatal(const char *fmt, ...) { va_list ap; - WaitForJobs(); + if (jobsRunning) + Job_Wait(); (void)fflush(stdout); fprintf(stderr, "%s: ", progname); Index: src/usr.bin/make/make.h diff -u src/usr.bin/make/make.h:1.345 src/usr.bin/make/make.h:1.346 --- src/usr.bin/make/make.h:1.345 Sun Aug 25 20:44:31 2024 +++ src/usr.bin/make/make.h Tue Aug 27 04:52:14 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.345 2024/08/25 20:44:31 rillig Exp $ */ +/* $NetBSD: make.h,v 1.346 2024/08/27 04:52:14 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -864,7 +864,6 @@ char *getTmpdir(void) MAKE_ATTR_USE; bool ParseBoolean(const char *, bool) MAKE_ATTR_USE; const char *cached_realpath(const char *, char *); bool GetBooleanExpr(const char *, bool); -void WaitForJobs(void); /* parse.c */ extern int parseErrors; Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.1137 src/usr.bin/make/var.c:1.1138 --- src/usr.bin/make/var.c:1.1137 Sun Aug 25 20:44:31 2024 +++ src/usr.bin/make/var.c Tue Aug 27 04:52:14 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1137 2024/08/25 20:44:31 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1138 2024/08/27 04:52:14 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -129,7 +129,7 @@ #include "trace.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1137 2024/08/25 20:44:31 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1138 2024/08/27 04:52:14 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -4573,16 +4573,13 @@ Var_Parse(const char **pp, GNode *scope, expr.name = v->name.str; if (v->inUse && VarEvalMode_ShouldEval(emode)) { - if (scope->fname != NULL) { - fprintf(stderr, "In a command near "); - PrintLocation(stderr, false, scope); - } - WaitForJobs(); Parse_Error(PARSE_FATAL, "Variable %s is recursive.", v->name.str); - PrintOnError(NULL, "\n"); - Trace_Log(MAKEERROR, NULL); - exit(2); /* Not 1 so -q can distinguish error */ + FStr_Done(&val); + if (*p != '\0') + p++; + *pp = p; + return FStr_InitRefer(var_Error); } /* Index: src/usr.bin/make/unit-tests/var-recursive.exp diff -u src/usr.bin/make/unit-tests/var-recursive.exp:1.10 src/usr.bin/make/unit-tests/var-recursive.exp:1.11 --- src/usr.bin/make/unit-tests/var-recursive.exp:1.10 Sun Aug 25 20:44:31 2024 +++ src/usr.bin/make/unit-tests/var-recursive.exp Tue Aug 27 04:52:14 2024 @@ -1,23 +1,20 @@ -make: "var-recursive.mk" line 21: still there -make: "var-recursive.mk" line 23: while evaluating variable "DIRECT" with value "${DIRECT}": Variable DIRECT is recursive. +make: "var-recursive.mk" line 11: while evaluating variable "DIRECT" with value "${DIRECT}": Variable DIRECT is recursive. in directory - -make: stopped in unit-tests -sub-exit status 2 -make: "var-recursive.mk" line 31: while evaluating variable "INDIRECT1" with value "${INDIRECT2}": while evaluating variable "INDIRECT2" with value "${INDIRECT1}": Variable INDIRECT1 is recursive. +make: "var-recursive.mk" line 11: <> +mak
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Tue Aug 27 04:52:14 UTC 2024 Modified Files: src/usr.bin/make: main.c make.h var.c src/usr.bin/make/unit-tests: var-recursive.exp var-recursive.mk Log Message: make: treat recursive variables non-fatally A recursive variable is no worse than an unknown modifier, so treat them in the same way by continuing parsing until the end of the makefile. To generate a diff of this commit: cvs rdiff -u -r1.633 -r1.634 src/usr.bin/make/main.c cvs rdiff -u -r1.345 -r1.346 src/usr.bin/make/make.h cvs rdiff -u -r1.1137 -r1.1138 src/usr.bin/make/var.c cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/var-recursive.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/var-recursive.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: Sun Aug 25 20:44:31 UTC 2024 Modified Files: src/usr.bin/make: main.c make.h var.c src/usr.bin/make/unit-tests: var-recursive.exp var-recursive.mk Log Message: make: add more context to error message about recursive variables To generate a diff of this commit: cvs rdiff -u -r1.632 -r1.633 src/usr.bin/make/main.c cvs rdiff -u -r1.344 -r1.345 src/usr.bin/make/make.h cvs rdiff -u -r1.1136 -r1.1137 src/usr.bin/make/var.c cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/var-recursive.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/var-recursive.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: Sun Aug 25 20:44:31 UTC 2024 Modified Files: src/usr.bin/make: main.c make.h var.c src/usr.bin/make/unit-tests: var-recursive.exp var-recursive.mk Log Message: make: add more context to error message about recursive variables To generate a diff of this commit: cvs rdiff -u -r1.632 -r1.633 src/usr.bin/make/main.c cvs rdiff -u -r1.344 -r1.345 src/usr.bin/make/make.h cvs rdiff -u -r1.1136 -r1.1137 src/usr.bin/make/var.c cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/var-recursive.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/var-recursive.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/main.c diff -u src/usr.bin/make/main.c:1.632 src/usr.bin/make/main.c:1.633 --- src/usr.bin/make/main.c:1.632 Thu Jul 11 20:09:16 2024 +++ src/usr.bin/make/main.c Sun Aug 25 20:44:31 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.632 2024/07/11 20:09:16 sjg Exp $ */ +/* $NetBSD: main.c,v 1.633 2024/08/25 20:44:31 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -111,7 +111,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.632 2024/07/11 20:09:16 sjg Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.633 2024/08/25 20:44:31 rillig Exp $"); #if defined(MAKE_NATIVE) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -1859,6 +1859,13 @@ Error(const char *fmt, ...) main_errors++; } +void +WaitForJobs(void) +{ + if (jobsRunning) + Job_Wait(); +} + /* * Wait for any running jobs to finish, then produce an error message, * finally exit immediately. @@ -1871,8 +1878,7 @@ Fatal(const char *fmt, ...) { va_list ap; - if (jobsRunning) - Job_Wait(); + WaitForJobs(); (void)fflush(stdout); fprintf(stderr, "%s: ", progname); Index: src/usr.bin/make/make.h diff -u src/usr.bin/make/make.h:1.344 src/usr.bin/make/make.h:1.345 --- src/usr.bin/make/make.h:1.344 Thu Jul 11 20:09:16 2024 +++ src/usr.bin/make/make.h Sun Aug 25 20:44:31 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.344 2024/07/11 20:09:16 sjg Exp $ */ +/* $NetBSD: make.h,v 1.345 2024/08/25 20:44:31 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -864,6 +864,7 @@ char *getTmpdir(void) MAKE_ATTR_USE; bool ParseBoolean(const char *, bool) MAKE_ATTR_USE; const char *cached_realpath(const char *, char *); bool GetBooleanExpr(const char *, bool); +void WaitForJobs(void); /* parse.c */ extern int parseErrors; Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.1136 src/usr.bin/make/var.c:1.1137 --- src/usr.bin/make/var.c:1.1136 Sat Jul 20 08:54:19 2024 +++ src/usr.bin/make/var.c Sun Aug 25 20:44:31 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1136 2024/07/20 08:54:19 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1137 2024/08/25 20:44:31 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -126,9 +126,10 @@ #include "dir.h" #include "job.h" #include "metachar.h" +#include "trace.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1136 2024/07/20 08:54:19 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1137 2024/08/25 20:44:31 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -4576,7 +4577,12 @@ Var_Parse(const char **pp, GNode *scope, fprintf(stderr, "In a command near "); PrintLocation(stderr, false, scope); } - Fatal("Variable %s is recursive.", v->name.str); + WaitForJobs(); + Parse_Error(PARSE_FATAL, "Variable %s is recursive.", + v->name.str); + PrintOnError(NULL, "\n"); + Trace_Log(MAKEERROR, NULL); + exit(2); /* Not 1 so -q can distinguish error */ } /* Index: src/usr.bin/make/unit-tests/var-recursive.exp diff -u src/usr.bin/make/unit-tests/var-recursive.exp:1.9 src/usr.bin/make/unit-tests/var-recursive.exp:1.10 --- src/usr.bin/make/unit-tests/var-recursive.exp:1.9 Thu Jul 4 20:18:40 2024 +++ src/usr.bin/make/unit-tests/var-recursive.exp Sun Aug 25 20:44:31 2024 @@ -1,22 +1,23 @@ make: "var-recursive.mk" line 21: still there -make: Variable DIRECT is recursive. - in var-recursive.mk:22 +make: "var-recursive.mk" line 23: while evaluating variable "DIRECT" with value "${DIRECT}": Variable DIRECT is recursive. in directory make: stopped in unit-tests -make: Variable INDIRECT1 is recursive. - in var-recursive.mk:29 +sub-exit status 2 +make: "var-recursive.mk" line 31: while evaluating variable "INDIRECT1" with value "${INDIRECT2}": while evaluating variable "INDIRECT2" with value "${INDIRECT1}": Variable INDIRECT1 is recursive. in directory make: stopped in unit-tests -make: "var-recursive.mk" line 37: ok -make: Variable V is recursive. - in var-recursive.mk:45 +sub-exit status 2 +make: "var-recursive.mk" line 39: ok +make: "var-recursive.mk" line 48: while evaluating variable "V" with
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sun Aug 18 13:40:51 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: Makefile cmdline.mk Log Message: tests/make: clean up private temporary directory after running tests Fixes PR bin/58569. To generate a diff of this commit: cvs rdiff -u -r1.350 -r1.351 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cmdline.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
Module Name:src Committed By: rillig Date: Sun Aug 18 13:40:51 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: Makefile cmdline.mk Log Message: tests/make: clean up private temporary directory after running tests Fixes PR bin/58569. To generate a diff of this commit: cvs rdiff -u -r1.350 -r1.351 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cmdline.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.350 src/usr.bin/make/unit-tests/Makefile:1.351 --- src/usr.bin/make/unit-tests/Makefile:1.350 Sun Jul 7 09:37:00 2024 +++ src/usr.bin/make/unit-tests/Makefile Sun Aug 18 13:40:51 2024 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.350 2024/07/07 09:37:00 rillig Exp $ +# $NetBSD: Makefile,v 1.351 2024/08/18 13:40:51 rillig Exp $ # # Unit tests for make(1) # @@ -779,6 +779,7 @@ test: ${OUTFILES} .PHONY if [ "$$have_lua" = "yes" ]; then \ (cd ${.CURDIR} && "$$lua" ./check-expect.lua *.mk); \ fi; \ + rm -rf ${TMPDIR}; \ fi accept: Index: src/usr.bin/make/unit-tests/cmdline.mk diff -u src/usr.bin/make/unit-tests/cmdline.mk:1.5 src/usr.bin/make/unit-tests/cmdline.mk:1.6 --- src/usr.bin/make/unit-tests/cmdline.mk:1.5 Tue Apr 23 22:51:28 2024 +++ src/usr.bin/make/unit-tests/cmdline.mk Sun Aug 18 13:40:51 2024 @@ -1,4 +1,4 @@ -# $NetBSD: cmdline.mk,v 1.5 2024/04/23 22:51:28 rillig Exp $ +# $NetBSD: cmdline.mk,v 1.6 2024/08/18 13:40:51 rillig Exp $ # # Tests for command line parsing and related special variables. @@ -12,6 +12,7 @@ DIR12= ${TMPBASE}/${SUB1}/${SUB2} all: prepare-dirs all: makeobjdir-direct makeobjdir-indirect all: space-and-comment +all: cleanup prepare-dirs: @rm -rf ${DIR2} ${DIR12} @@ -56,3 +57,6 @@ space-and-comment: .PHONY @env -i MAKEFLAGS="' VAR= value # no comment '" \ ${MAKE} -r -f /dev/null -v VAR \ | sed 's,$$,$$,' + +cleanup: + @rm -rf ${TMPBASE}
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Wed Aug 7 05:48:45 UTC 2024 Modified Files: src/usr.bin/make: cond.c src/usr.bin/make/unit-tests: cond-func.exp cond-func.mk directive-include-guard.exp directive-include-guard.mk Log Message: make: in erroneous conditions, report the non-expanded text In a condition, when a function call expression is missing its closing parenthesis, there's no point in having the expanded argument text in the error message. When parsing a bare word in a condition, the trailing space was included in that word, which was inconsistent, as the leading space was not included either. Removing the trailing space from the word reduces the cases where a multiple-inclusion guard steps in, but only in an edge case that is irrelevant in practice. To generate a diff of this commit: cvs rdiff -u -r1.368 -r1.369 src/usr.bin/make/cond.c cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/cond-func.exp cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/cond-func.mk \ src/usr.bin/make/unit-tests/directive-include-guard.mk cvs rdiff -u -r1.15 -r1.16 \ src/usr.bin/make/unit-tests/directive-include-guard.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/cond.c diff -u src/usr.bin/make/cond.c:1.368 src/usr.bin/make/cond.c:1.369 --- src/usr.bin/make/cond.c:1.368 Tue Aug 6 18:00:16 2024 +++ src/usr.bin/make/cond.c Wed Aug 7 05:48:45 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.368 2024/08/06 18:00:16 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.369 2024/08/07 05:48:45 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -91,7 +91,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.368 2024/08/06 18:00:16 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.369 2024/08/07 05:48:45 rillig Exp $"); /* * Conditional expressions conform to this grammar: @@ -242,7 +242,6 @@ ParseWord(const char **pp, bool doEval) p++; } - cpp_skip_hspace(&p); *pp = p; return Buf_DoneData(&word); @@ -252,12 +251,14 @@ ParseWord(const char **pp, bool doEval) static char * ParseFuncArg(CondParser *par, const char **pp, bool doEval, const char *func) { - const char *p = *pp; + const char *p = *pp, *argStart, *argEnd; char *res; p++; /* skip the '(' */ cpp_skip_hspace(&p); + argStart = p; res = ParseWord(&p, doEval); + argEnd = p; cpp_skip_hspace(&p); if (*p++ != ')') { @@ -266,8 +267,8 @@ ParseFuncArg(CondParser *par, const char len++; Parse_Error(PARSE_FATAL, - "Missing ')' after argument '%s' for '%.*s'", - res, len, func); + "Missing ')' after argument '%.*s' for '%.*s'", + (int)(argEnd - argStart), argStart, len, func); par->printedError = true; free(res); return NULL; @@ -735,6 +736,7 @@ CondParser_ComparisonOrLeaf(CondParser * */ arg = ParseWord(&p, doEval); assert(arg[0] != '\0'); + cpp_skip_hspace(&p); if (*p == '=' || *p == '!' || *p == '<' || *p == '>') { free(arg); Index: src/usr.bin/make/unit-tests/cond-func.exp diff -u src/usr.bin/make/unit-tests/cond-func.exp:1.12 src/usr.bin/make/unit-tests/cond-func.exp:1.13 --- src/usr.bin/make/unit-tests/cond-func.exp:1.12 Wed Aug 7 05:37:11 2024 +++ src/usr.bin/make/unit-tests/cond-func.exp Wed Aug 7 05:48:45 2024 @@ -7,7 +7,7 @@ make: "cond-func.mk" line 115: A plain f make: "cond-func.mk" line 126: Symbols may start with a function name. make: "cond-func.mk" line 132: Symbols may start with a function name. make: "cond-func.mk" line 138: Missing ')' after argument '' for 'defined' -make: "cond-func.mk" line 146: Missing ')' after argument 'VARNAME.param' for 'defined' +make: "cond-func.mk" line 145: Missing ')' after argument '${:UVARNAME}.param' for 'defined' make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/cond-func.mk diff -u src/usr.bin/make/unit-tests/cond-func.mk:1.17 src/usr.bin/make/unit-tests/cond-func.mk:1.18 --- src/usr.bin/make/unit-tests/cond-func.mk:1.17 Wed Aug 7 05:37:11 2024 +++ src/usr.bin/make/unit-tests/cond-func.mk Wed Aug 7 05:48:45 2024 @@ -1,4 +1,4 @@ -# $NetBSD: cond-func.mk,v 1.17 2024/08/07 05:37:11 rillig Exp $ +# $NetBSD: cond-func.mk,v 1.18 2024/08/07 05:48:45 rillig Exp $ # # Tests for those parts of the functions in .if conditions that are common # among several functions. @@ -141,8 +141,7 @@ defined-var= # defined but empty . error .endif -# XXX: Don't use the expanded argument in the diagnostic. -# expect+1: Missing ')' after argument 'VARNAME.param' for 'defined' +# expect+1: Missing ')' after argument '${:UVARNAME}.param' for 'defined' .if defined(${:UVARNAME}.param extra) . error .else Index: src/usr.bin/make/unit-tests/directive-include-guard.mk diff -u src/usr.bin/make/unit-tests/dire
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Wed Aug 7 05:48:45 UTC 2024 Modified Files: src/usr.bin/make: cond.c src/usr.bin/make/unit-tests: cond-func.exp cond-func.mk directive-include-guard.exp directive-include-guard.mk Log Message: make: in erroneous conditions, report the non-expanded text In a condition, when a function call expression is missing its closing parenthesis, there's no point in having the expanded argument text in the error message. When parsing a bare word in a condition, the trailing space was included in that word, which was inconsistent, as the leading space was not included either. Removing the trailing space from the word reduces the cases where a multiple-inclusion guard steps in, but only in an edge case that is irrelevant in practice. To generate a diff of this commit: cvs rdiff -u -r1.368 -r1.369 src/usr.bin/make/cond.c cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/cond-func.exp cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/cond-func.mk \ src/usr.bin/make/unit-tests/directive-include-guard.mk cvs rdiff -u -r1.15 -r1.16 \ src/usr.bin/make/unit-tests/directive-include-guard.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: Wed Aug 7 05:37:11 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: cond-func.exp cond-func.mk directive-include-guard.exp directive-include-guard.mk Log Message: tests/make: demonstrate unintended parsing of words in conditions A word is not supposed to include its trailing space, as it doesn't contain its leading space either. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/cond-func.exp cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/cond-func.mk \ src/usr.bin/make/unit-tests/directive-include-guard.mk cvs rdiff -u -r1.14 -r1.15 \ src/usr.bin/make/unit-tests/directive-include-guard.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-func.exp diff -u src/usr.bin/make/unit-tests/cond-func.exp:1.11 src/usr.bin/make/unit-tests/cond-func.exp:1.12 --- src/usr.bin/make/unit-tests/cond-func.exp:1.11 Tue Aug 6 17:46:01 2024 +++ src/usr.bin/make/unit-tests/cond-func.exp Wed Aug 7 05:37:11 2024 @@ -7,6 +7,7 @@ make: "cond-func.mk" line 115: A plain f make: "cond-func.mk" line 126: Symbols may start with a function name. make: "cond-func.mk" line 132: Symbols may start with a function name. make: "cond-func.mk" line 138: Missing ')' after argument '' for 'defined' +make: "cond-func.mk" line 146: Missing ')' after argument 'VARNAME.param' for 'defined' make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/cond-func.mk diff -u src/usr.bin/make/unit-tests/cond-func.mk:1.16 src/usr.bin/make/unit-tests/cond-func.mk:1.17 --- src/usr.bin/make/unit-tests/cond-func.mk:1.16 Tue Aug 6 17:46:01 2024 +++ src/usr.bin/make/unit-tests/cond-func.mk Wed Aug 7 05:37:11 2024 @@ -1,4 +1,4 @@ -# $NetBSD: cond-func.mk,v 1.16 2024/08/06 17:46:01 rillig Exp $ +# $NetBSD: cond-func.mk,v 1.17 2024/08/07 05:37:11 rillig Exp $ # # Tests for those parts of the functions in .if conditions that are common # among several functions. @@ -140,3 +140,11 @@ defined-var= # defined but empty .else . error .endif + +# XXX: Don't use the expanded argument in the diagnostic. +# expect+1: Missing ')' after argument 'VARNAME.param' for 'defined' +.if defined(${:UVARNAME}.param extra) +. error +.else +. error +.endif Index: src/usr.bin/make/unit-tests/directive-include-guard.mk diff -u src/usr.bin/make/unit-tests/directive-include-guard.mk:1.16 src/usr.bin/make/unit-tests/directive-include-guard.mk:1.17 --- src/usr.bin/make/unit-tests/directive-include-guard.mk:1.16 Sun Dec 17 14:07:22 2023 +++ src/usr.bin/make/unit-tests/directive-include-guard.mk Wed Aug 7 05:37:11 2024 @@ -1,4 +1,4 @@ -# $NetBSD: directive-include-guard.mk,v 1.16 2023/12/17 14:07:22 rillig Exp $ +# $NetBSD: directive-include-guard.mk,v 1.17 2024/08/07 05:37:11 rillig Exp $ # # Tests for multiple-inclusion guards in makefiles. # @@ -583,13 +583,21 @@ LINES.target-name-exclamation= \ # If the guard target name is enclosed in spaces, it does not have an effect, # as that form is not common in practice. -CASES+= target-name-parenthesized -LINES.target-name-parenthesized= \ - '.if !target( target-name-parenthesized )' \ - 'target-name-parenthesized: .NOTMAIN' \ +CASES+= target-name-leading-space +LINES.target-name-leading-space= \ + '.if !target( target-name-leading-space)' \ + 'target-name-leading-space: .NOTMAIN' \ + '.endif' +# expect: Parse_PushInput: file target-name-leading-space.tmp, line 1 +# expect: Parse_PushInput: file target-name-leading-space.tmp, line 1 + +CASES+= target-name-trailing-space +LINES.target-name-trailing-space= \ + '.if !target(target-name-trailing-space )' \ + 'target-name-trailing-space: .NOTMAIN' \ '.endif' -# expect: Parse_PushInput: file target-name-parenthesized.tmp, line 1 -# expect: Parse_PushInput: file target-name-parenthesized.tmp, line 1 +# expect: Parse_PushInput: file target-name-trailing-space.tmp, line 1 +# expect: Skipping 'target-name-trailing-space.tmp' because 'target-name-trailing-space' is defined # If the guard target condition is enclosed in parentheses, it does not have # an effect, as that form is not common in practice. Index: src/usr.bin/make/unit-tests/directive-include-guard.exp diff -u src/usr.bin/make/unit-tests/directive-include-guard.exp:1.14 src/usr.bin/make/unit-tests/directive-include-guard.exp:1.15 --- src/usr.bin/make/unit-tests/directive-include-guard.exp:1.14 Sun Dec 17 14:07:22 2023 +++ src/usr.bin/make/unit-tests/directive-include-guard.exp Wed Aug 7 05:37:11 2024 @@ -95,8 +95,10 @@ Parse_PushInput: file target-already-def Skipping 'target-already-defined.tmp' because 'target-already-defined' is defined Parse_PushInput: file target-name-exclamation.tmp, line 1 Parse_PushInput: file target-name-exclamation.tmp, line 1 -Parse_PushInput: file target-name
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Wed Aug 7 05:37:11 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: cond-func.exp cond-func.mk directive-include-guard.exp directive-include-guard.mk Log Message: tests/make: demonstrate unintended parsing of words in conditions A word is not supposed to include its trailing space, as it doesn't contain its leading space either. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/cond-func.exp cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/cond-func.mk \ src/usr.bin/make/unit-tests/directive-include-guard.mk cvs rdiff -u -r1.14 -r1.15 \ src/usr.bin/make/unit-tests/directive-include-guard.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
Module Name:src Committed By: rillig Date: Tue Aug 6 18:00:17 UTC 2024 Modified Files: src/usr.bin/make: cond.c src/usr.bin/make/unit-tests: cond-cmp-numeric-eq.exp cond-cmp-numeric-eq.mk cond-cmp-numeric.exp cond-cmp-numeric.mk cond-cmp-string.exp cond-cmp-string.mk cond-eof.exp cond-eof.mk cond-func-empty.exp cond-func-empty.mk cond-op-and.exp cond-op-and.mk cond-op-not.exp cond-op-not.mk cond-op-or.exp cond-op-or.mk cond-op-parentheses.exp cond-op-parentheses.mk cond-op.exp cond-op.mk cond-token-number.exp cond-token-number.mk cond-token-plain.exp cond-token-plain.mk cond-token-string.exp cond-token-string.mk cond-token-var.exp cond-token-var.mk cond-undef-lint.exp cond-undef-lint.mk directive-if.exp directive-if.mk directive-include-fatal.exp directive-include-fatal.mk opt-debug-lint.exp opt-debug-lint.mk var-eval-short.exp var-eval-short.mk vardebug.exp vardebug.mk varmod-edge.exp varmod-edge.mk varmod-gmtime.exp varmod-gmtime.mk varmod-ifelse.exp varmod-ifelse.mk varmod-localtime.exp varmod-localtime.mk varmod-loop-varname.exp varmod-loop-varname.mk varmod-match.exp varmod-match.mk varmod-mtime.exp varmod-mtime.mk varmod-order.exp varmod-order.mk varmod-range.exp varmod-range.mk varmod-sysv.exp varmod-sysv.mk varmod-to-separator.exp varmod-to-separator.mk varmod.exp varmod.mk varparse-dynamic.exp varparse-dynamic.mk Log Message: make: in error message about conditionals, use single quotes Single quotes are used less often in the conditionals themselves, which leads to fewer confusions. To generate a diff of this commit: cvs rdiff -u -r1.367 -r1.368 src/usr.bin/make/cond.c cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.exp \ src/usr.bin/make/unit-tests/cond-eof.exp \ src/usr.bin/make/unit-tests/cond-op-and.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk \ src/usr.bin/make/unit-tests/cond-cmp-numeric.mk \ src/usr.bin/make/unit-tests/cond-func-empty.exp \ src/usr.bin/make/unit-tests/cond-op-parentheses.exp \ src/usr.bin/make/unit-tests/cond-op-parentheses.mk cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cond-cmp-numeric.exp \ src/usr.bin/make/unit-tests/cond-op-and.mk \ src/usr.bin/make/unit-tests/cond-token-number.mk \ src/usr.bin/make/unit-tests/varmod-loop-varname.exp cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/cond-cmp-string.exp \ src/usr.bin/make/unit-tests/cond-op.exp \ src/usr.bin/make/unit-tests/varmod-range.mk cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/cond-cmp-string.mk \ src/usr.bin/make/unit-tests/cond-token-plain.mk \ src/usr.bin/make/unit-tests/varmod-sysv.mk cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cond-eof.mk \ src/usr.bin/make/unit-tests/cond-op-not.exp \ src/usr.bin/make/unit-tests/cond-op-or.exp \ src/usr.bin/make/unit-tests/cond-undef-lint.exp cvs rdiff -u -r1.25 -r1.26 src/usr.bin/make/unit-tests/cond-func-empty.mk cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/cond-op-not.mk \ src/usr.bin/make/unit-tests/cond-token-number.exp \ src/usr.bin/make/unit-tests/cond-token-var.mk \ src/usr.bin/make/unit-tests/varparse-dynamic.mk cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/cond-op-or.mk \ src/usr.bin/make/unit-tests/directive-if.mk cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/cond-op.mk \ src/usr.bin/make/unit-tests/varmod-to-separator.exp cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/cond-token-plain.exp \ src/usr.bin/make/unit-tests/opt-debug-lint.exp \ src/usr.bin/make/unit-tests/varmod-gmtime.exp \ src/usr.bin/make/unit-tests/varmod-match.exp cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/cond-token-string.exp \ src/usr.bin/make/unit-tests/var-eval-short.mk \ src/usr.bin/make/unit-tests/varmod-order.exp \ src/usr.bin/make/unit-tests/varmod-sysv.exp cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/cond-token-string.mk \ src/usr.bin/make/unit-tests/directive-if.exp \ src/usr.bin/make/unit-tests/vardebug.mk \ src/usr.bin/make/unit-tests/varmod-mtime.mk cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cond-token-var.exp \ src/usr.bin/make/unit-tests/cond-undef-lint.mk \ src/usr.bin/make/unit-tests/directive-include-fatal.exp \ src/usr.bin/make/unit-tests/directive-include-fatal.mk cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/opt-debug-lint.mk \ src/usr.bin/make/unit-tests/varmod-to-separator.mk \ src/usr.bin/make/unit-tests/varmod.mk cvs rdiff -u -r1.29 -r1.30 src/usr.bin/make/unit-tests/var-eval-short.exp \ src/usr.bin/make/unit-tests/varmod-edge.mk cvs rdiff -u -r1.36 -r1.37 src/usr.bin/make/unit-tests/vardebu
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Tue Aug 6 18:00:17 UTC 2024 Modified Files: src/usr.bin/make: cond.c src/usr.bin/make/unit-tests: cond-cmp-numeric-eq.exp cond-cmp-numeric-eq.mk cond-cmp-numeric.exp cond-cmp-numeric.mk cond-cmp-string.exp cond-cmp-string.mk cond-eof.exp cond-eof.mk cond-func-empty.exp cond-func-empty.mk cond-op-and.exp cond-op-and.mk cond-op-not.exp cond-op-not.mk cond-op-or.exp cond-op-or.mk cond-op-parentheses.exp cond-op-parentheses.mk cond-op.exp cond-op.mk cond-token-number.exp cond-token-number.mk cond-token-plain.exp cond-token-plain.mk cond-token-string.exp cond-token-string.mk cond-token-var.exp cond-token-var.mk cond-undef-lint.exp cond-undef-lint.mk directive-if.exp directive-if.mk directive-include-fatal.exp directive-include-fatal.mk opt-debug-lint.exp opt-debug-lint.mk var-eval-short.exp var-eval-short.mk vardebug.exp vardebug.mk varmod-edge.exp varmod-edge.mk varmod-gmtime.exp varmod-gmtime.mk varmod-ifelse.exp varmod-ifelse.mk varmod-localtime.exp varmod-localtime.mk varmod-loop-varname.exp varmod-loop-varname.mk varmod-match.exp varmod-match.mk varmod-mtime.exp varmod-mtime.mk varmod-order.exp varmod-order.mk varmod-range.exp varmod-range.mk varmod-sysv.exp varmod-sysv.mk varmod-to-separator.exp varmod-to-separator.mk varmod.exp varmod.mk varparse-dynamic.exp varparse-dynamic.mk Log Message: make: in error message about conditionals, use single quotes Single quotes are used less often in the conditionals themselves, which leads to fewer confusions. To generate a diff of this commit: cvs rdiff -u -r1.367 -r1.368 src/usr.bin/make/cond.c cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.exp \ src/usr.bin/make/unit-tests/cond-eof.exp \ src/usr.bin/make/unit-tests/cond-op-and.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cond-cmp-numeric-eq.mk \ src/usr.bin/make/unit-tests/cond-cmp-numeric.mk \ src/usr.bin/make/unit-tests/cond-func-empty.exp \ src/usr.bin/make/unit-tests/cond-op-parentheses.exp \ src/usr.bin/make/unit-tests/cond-op-parentheses.mk cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cond-cmp-numeric.exp \ src/usr.bin/make/unit-tests/cond-op-and.mk \ src/usr.bin/make/unit-tests/cond-token-number.mk \ src/usr.bin/make/unit-tests/varmod-loop-varname.exp cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/cond-cmp-string.exp \ src/usr.bin/make/unit-tests/cond-op.exp \ src/usr.bin/make/unit-tests/varmod-range.mk cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/cond-cmp-string.mk \ src/usr.bin/make/unit-tests/cond-token-plain.mk \ src/usr.bin/make/unit-tests/varmod-sysv.mk cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cond-eof.mk \ src/usr.bin/make/unit-tests/cond-op-not.exp \ src/usr.bin/make/unit-tests/cond-op-or.exp \ src/usr.bin/make/unit-tests/cond-undef-lint.exp cvs rdiff -u -r1.25 -r1.26 src/usr.bin/make/unit-tests/cond-func-empty.mk cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/cond-op-not.mk \ src/usr.bin/make/unit-tests/cond-token-number.exp \ src/usr.bin/make/unit-tests/cond-token-var.mk \ src/usr.bin/make/unit-tests/varparse-dynamic.mk cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/cond-op-or.mk \ src/usr.bin/make/unit-tests/directive-if.mk cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/cond-op.mk \ src/usr.bin/make/unit-tests/varmod-to-separator.exp cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/cond-token-plain.exp \ src/usr.bin/make/unit-tests/opt-debug-lint.exp \ src/usr.bin/make/unit-tests/varmod-gmtime.exp \ src/usr.bin/make/unit-tests/varmod-match.exp cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/cond-token-string.exp \ src/usr.bin/make/unit-tests/var-eval-short.mk \ src/usr.bin/make/unit-tests/varmod-order.exp \ src/usr.bin/make/unit-tests/varmod-sysv.exp cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/cond-token-string.mk \ src/usr.bin/make/unit-tests/directive-if.exp \ src/usr.bin/make/unit-tests/vardebug.mk \ src/usr.bin/make/unit-tests/varmod-mtime.mk cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cond-token-var.exp \ src/usr.bin/make/unit-tests/cond-undef-lint.mk \ src/usr.bin/make/unit-tests/directive-include-fatal.exp \ src/usr.bin/make/unit-tests/directive-include-fatal.mk cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/opt-debug-lint.mk \ src/usr.bin/make/unit-tests/varmod-to-separator.mk \ src/usr.bin/make/unit-tests/varmod.mk cvs rdiff -u -r1.29 -r1.30 src/usr.bin/make/unit-tests/var-eval-short.exp \ src/usr.bin/make/unit-tests/varmod-edge.mk cvs rdiff -u -r1.36 -r1.37 src/usr.bin/make/unit-tests/vardebu
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Tue Aug 6 17:46:01 UTC 2024 Modified Files: src/usr.bin/make: arch.c cond.c src/usr.bin/make/unit-tests: cond-func-defined.exp cond-func-defined.mk cond-func.exp cond-func.mk varname.exp varname.mk Log Message: make: add details to error messages about missing ')' To generate a diff of this commit: cvs rdiff -u -r1.221 -r1.222 src/usr.bin/make/arch.c cvs rdiff -u -r1.366 -r1.367 src/usr.bin/make/cond.c cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cond-func-defined.exp \ src/usr.bin/make/unit-tests/cond-func.exp cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/cond-func-defined.mk cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/cond-func.mk cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/varname.exp cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/varname.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/arch.c diff -u src/usr.bin/make/arch.c:1.221 src/usr.bin/make/arch.c:1.222 --- src/usr.bin/make/arch.c:1.221 Sun Jul 7 07:50:57 2024 +++ src/usr.bin/make/arch.c Tue Aug 6 17:46:01 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.221 2024/07/07 07:50:57 rillig Exp $ */ +/* $NetBSD: arch.c,v 1.222 2024/08/06 17:46:01 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -126,7 +126,7 @@ #include "config.h" /* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: arch.c,v 1.221 2024/07/07 07:50:57 rillig Exp $"); +MAKE_RCSID("$NetBSD: arch.c,v 1.222 2024/08/06 17:46:01 rillig Exp $"); typedef struct List ArchList; typedef struct ListNode ArchListNode; @@ -266,8 +266,7 @@ Arch_ParseArchive(char **pp, GNodeList * if (*cp == '\0') { Parse_Error(PARSE_FATAL, - "No closing parenthesis " - "in archive specification"); + "Missing ')' in archive specification"); return false; } Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.366 src/usr.bin/make/cond.c:1.367 --- src/usr.bin/make/cond.c:1.366 Sat Jul 6 21:21:09 2024 +++ src/usr.bin/make/cond.c Tue Aug 6 17:46:01 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.366 2024/07/06 21:21:09 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.367 2024/08/06 17:46:01 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -91,7 +91,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.366 2024/07/06 21:21:09 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.367 2024/08/06 17:46:01 rillig Exp $"); /* * Conditional expressions conform to this grammar: @@ -266,7 +266,8 @@ ParseFuncArg(CondParser *par, const char len++; Parse_Error(PARSE_FATAL, - "Missing closing parenthesis for %.*s()", len, func); + "Missing ')' after argument '%s' for '%.*s'", + res, len, func); par->printedError = true; free(res); return NULL; Index: src/usr.bin/make/unit-tests/cond-func-defined.exp diff -u src/usr.bin/make/unit-tests/cond-func-defined.exp:1.10 src/usr.bin/make/unit-tests/cond-func-defined.exp:1.11 --- src/usr.bin/make/unit-tests/cond-func-defined.exp:1.10 Thu Jul 4 20:18:40 2024 +++ src/usr.bin/make/unit-tests/cond-func-defined.exp Tue Aug 6 17:46:01 2024 @@ -1,5 +1,5 @@ -make: "cond-func-defined.mk" line 24: Missing closing parenthesis for defined() -make: "cond-func-defined.mk" line 34: Missing closing parenthesis for defined() +make: "cond-func-defined.mk" line 24: Missing ')' after argument 'A' for 'defined' +make: "cond-func-defined.mk" line 34: Missing ')' after argument 'DEF' for 'defined' make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/cond-func.exp diff -u src/usr.bin/make/unit-tests/cond-func.exp:1.10 src/usr.bin/make/unit-tests/cond-func.exp:1.11 --- src/usr.bin/make/unit-tests/cond-func.exp:1.10 Sat Jul 6 21:21:10 2024 +++ src/usr.bin/make/unit-tests/cond-func.exp Tue Aug 6 17:46:01 2024 @@ -1,12 +1,12 @@ -make: "cond-func.mk" line 37: Missing closing parenthesis for defined() -make: "cond-func.mk" line 53: Missing closing parenthesis for defined() -make: "cond-func.mk" line 57: Missing closing parenthesis for defined() +make: "cond-func.mk" line 37: Missing ')' after argument 'A' for 'defined' +make: "cond-func.mk" line 53: Missing ')' after argument 'A' for 'defined' +make: "cond-func.mk" line 57: Missing ')' after argument 'A' for 'defined' make: "cond-func.mk" line 91: Unknown operator '&' make: "cond-func.mk" line 107: A plain function name is parsed as defined(...). make: "cond-func.mk" line 115: A plain function name is parsed as defined(...). make: "cond-func.mk" line 126: Symbols may start with a function name. make: "cond-func.mk" line 132: Symbols may start with a function name. -make: "cond-func.mk" line 138: Missing closing parenthesis for
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Tue Aug 6 17:46:01 UTC 2024 Modified Files: src/usr.bin/make: arch.c cond.c src/usr.bin/make/unit-tests: cond-func-defined.exp cond-func-defined.mk cond-func.exp cond-func.mk varname.exp varname.mk Log Message: make: add details to error messages about missing ')' To generate a diff of this commit: cvs rdiff -u -r1.221 -r1.222 src/usr.bin/make/arch.c cvs rdiff -u -r1.366 -r1.367 src/usr.bin/make/cond.c cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cond-func-defined.exp \ src/usr.bin/make/unit-tests/cond-func.exp cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/cond-func-defined.mk cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/cond-func.mk cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/varname.exp cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/varname.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: Mon Jul 22 18:15:04 UTC 2024 Modified Files: src/usr.bin/make: job.c Log Message: make: remove dead code To generate a diff of this commit: cvs rdiff -u -r1.482 -r1.483 src/usr.bin/make/job.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.482 src/usr.bin/make/job.c:1.483 --- src/usr.bin/make/job.c:1.482 Mon Jul 22 18:11:15 2024 +++ src/usr.bin/make/job.c Mon Jul 22 18:15:04 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.482 2024/07/22 18:11:15 rillig Exp $ */ +/* $NetBSD: job.c,v 1.483 2024/07/22 18:15:04 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -141,7 +141,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.482 2024/07/22 18:11:15 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.483 2024/07/22 18:15:04 rillig Exp $"); /* * A shell defines how the commands are run. All commands for a target are @@ -1943,30 +1943,12 @@ again: static void JobRun(GNode *targ) { -#if 0 - /* - * Unfortunately it is too complicated to run .BEGIN, .END, and - * .INTERRUPT job in the parallel job module. As of 2020-09-25, - * unit-tests/deptgt-end-jobs.mk hangs in an endless loop. - * - * Running these jobs in compat mode also guarantees that these - * jobs do not overlap with other unrelated jobs. - */ - GNodeList lst = LST_INIT; - Lst_Append(&lst, targ); - (void)Make_Run(&lst); - Lst_Done(&lst); - JobStart(targ, true); - while (jobTokensRunning != 0) { - Job_CatchOutput(); - } -#else + /* Don't let these special jobs overlap with other unrelated jobs. */ Compat_Make(targ, targ); if (GNode_IsError(targ)) { PrintOnError(targ, "\n\nStop.\n"); exit(1); } -#endif } /* @@ -2905,11 +2887,6 @@ Job_RunTarget(const char *target, const Var_Set(gn, ALLSRC, fname); JobRun(gn); - /* XXX: Replace with GNode_IsError(gn) */ - if (gn->made == ERROR) { - PrintOnError(gn, "\n\nStop.\n"); - exit(1); - } return true; }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Mon Jul 22 18:15:04 UTC 2024 Modified Files: src/usr.bin/make: job.c Log Message: make: remove dead code To generate a diff of this commit: cvs rdiff -u -r1.482 -r1.483 src/usr.bin/make/job.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Mon Jul 22 18:11:15 UTC 2024 Modified Files: src/usr.bin/make: job.c src/usr.bin/make/unit-tests: cmd-errors-jobs.exp cmd-errors-jobs.mk Log Message: make: fix exit status for error in .BEGIN/.END prerequisite To generate a diff of this commit: cvs rdiff -u -r1.481 -r1.482 src/usr.bin/make/job.c cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/cmd-errors-jobs.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.481 src/usr.bin/make/job.c:1.482 --- src/usr.bin/make/job.c:1.481 Sat Jul 20 14:09:27 2024 +++ src/usr.bin/make/job.c Mon Jul 22 18:11:15 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.481 2024/07/20 14:09:27 rillig Exp $ */ +/* $NetBSD: job.c,v 1.482 2024/07/22 18:11:15 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -141,7 +141,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.481 2024/07/20 14:09:27 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.482 2024/07/22 18:11:15 rillig Exp $"); /* * A shell defines how the commands are run. All commands for a target are @@ -1962,8 +1962,7 @@ JobRun(GNode *targ) } #else Compat_Make(targ, targ); - /* XXX: Replace with GNode_IsError(gn) */ - if (targ->made == ERROR) { + if (GNode_IsError(targ)) { PrintOnError(targ, "\n\nStop.\n"); exit(1); } Index: src/usr.bin/make/unit-tests/cmd-errors-jobs.exp diff -u src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.12 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.13 --- src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.12 Mon Jul 22 18:02:51 2024 +++ src/usr.bin/make/unit-tests/cmd-errors-jobs.exp Mon Jul 22 18:11:15 2024 @@ -30,7 +30,11 @@ end begin-direct with status 1 begin begin-indirect (exit 13) # before-begin *** Error code 13 (continuing) -end begin-indirect with status 0 + + +Stop. +make: stopped making "begin-indirect" in unit-tests +end begin-indirect with status 1 begin end-direct (exit 13) # .END @@ -44,6 +48,10 @@ end end-direct with status 1 begin end-indirect (exit 13) # before-end *** Error code 13 (continuing) -end end-indirect with status 0 + + +Stop. +make: stopped making "end-indirect" in unit-tests +end end-indirect with status 1 exit status 0 Index: src/usr.bin/make/unit-tests/cmd-errors-jobs.mk diff -u src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.11 src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.12 --- src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.11 Mon Jul 22 18:02:51 2024 +++ src/usr.bin/make/unit-tests/cmd-errors-jobs.mk Mon Jul 22 18:11:15 2024 @@ -1,4 +1,4 @@ -# $NetBSD: cmd-errors-jobs.mk,v 1.11 2024/07/22 18:02:51 rillig Exp $ +# $NetBSD: cmd-errors-jobs.mk,v 1.12 2024/07/22 18:11:15 rillig Exp $ # # Demonstrate how errors in expressions affect whether the commands # are actually executed in jobs mode. @@ -76,11 +76,9 @@ before-begin: (exit 13) # $@ .endif # expect: begin begin-indirect -# TODO: Show the "stopped making" message. -# expect-not: stopped making "begin-indirect" # expect: *** Error code 13 (continuing) -# TODO: Exit with a non-zero status due to the failed target. -# expect: end begin-indirect with status 0 +# expect: make: stopped making "begin-indirect" in unit-tests +# expect: end begin-indirect with status 1 .if make(end-direct) @@ -102,8 +100,6 @@ before-end: (exit 13) # $@ .endif # expect: begin end-indirect -# TODO: Show the "stopped making" message. -# expect-not: stopped making "end-indirect" # expect: *** Error code 13 (continuing) -# TODO: Exit with a non-zero status due to the failed target. -# expect: end end-indirect with status 0 +# expect: make: stopped making "end-indirect" in unit-tests +# expect: end end-indirect with status 1
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Mon Jul 22 18:11:15 UTC 2024 Modified Files: src/usr.bin/make: job.c src/usr.bin/make/unit-tests: cmd-errors-jobs.exp cmd-errors-jobs.mk Log Message: make: fix exit status for error in .BEGIN/.END prerequisite To generate a diff of this commit: cvs rdiff -u -r1.481 -r1.482 src/usr.bin/make/job.c cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/cmd-errors-jobs.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
Module Name:src Committed By: rillig Date: Mon Jul 22 18:02:51 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: cmd-errors-jobs.exp cmd-errors-jobs.mk Log Message: tests/make: demonstrate wrong exit status for .END dependency To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cmd-errors-jobs.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/cmd-errors-jobs.exp diff -u src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.11 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.12 --- src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.11 Sat Jul 20 14:09:27 2024 +++ src/usr.bin/make/unit-tests/cmd-errors-jobs.exp Mon Jul 22 18:02:51 2024 @@ -1,9 +1,49 @@ -: undefined--eol -make: in target "unclosed-expression": Unclosed variable "UNCLOSED" -make: in target "unclosed-modifier": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}' -make: in target "unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z" -make: in target "depend-source": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}' -: end-eol -: Making depend-target -: .END-eol -exit status 2 +begin undefined-direct +: undefined-direct--eol +end undefined-direct with status 0 + +begin undefined-indirect +: undefined-direct--eol +end undefined-indirect with status 0 + +begin parse-error-direct +make: in target "parse-error-unclosed-expression": Unclosed variable "UNCLOSED" +make: in target "parse-error-unclosed-modifier": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}' +make: in target "parse-error-unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z" +end parse-error-direct with status 2 + +begin parse-error-indirect +make: in target "parse-error-unclosed-expression": Unclosed variable "UNCLOSED" +make: in target "parse-error-unclosed-modifier": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}' +make: in target "parse-error-unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z" +end parse-error-indirect with status 2 + +begin begin-direct +(exit 13) # .BEGIN +*** Error code 13 (continuing) + + +Stop. +make: stopped making "begin-direct" in unit-tests +end begin-direct with status 1 + +begin begin-indirect +(exit 13) # before-begin +*** Error code 13 (continuing) +end begin-indirect with status 0 + +begin end-direct +(exit 13) # .END +*** Error code 13 (continuing) + + +Stop. +make: stopped making "end-direct" in unit-tests +end end-direct with status 1 + +begin end-indirect +(exit 13) # before-end +*** Error code 13 (continuing) +end end-indirect with status 0 + +exit status 0 Index: src/usr.bin/make/unit-tests/cmd-errors-jobs.mk diff -u src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.10 src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.11 --- src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.10 Sat Jul 20 14:09:27 2024 +++ src/usr.bin/make/unit-tests/cmd-errors-jobs.mk Mon Jul 22 18:02:51 2024 @@ -1,51 +1,109 @@ -# $NetBSD: cmd-errors-jobs.mk,v 1.10 2024/07/20 14:09:27 rillig Exp $ +# $NetBSD: cmd-errors-jobs.mk,v 1.11 2024/07/22 18:02:51 rillig Exp $ # # Demonstrate how errors in expressions affect whether the commands # are actually executed in jobs mode. -.MAKEFLAGS: -j1 +RUN= @ run() { \ + echo "begin $$*" \ + && ${MAKE} -f ${MAKEFILE} -j1 "$$*" \ + && echo "end $$* with status $$?" \ + || echo "end $$* with status $$?" \ + && echo;\ + } && run + +all: + ${RUN} undefined-direct + ${RUN} undefined-indirect + ${RUN} parse-error-direct + ${RUN} parse-error-indirect + ${RUN} begin-direct + ${RUN} begin-indirect + ${RUN} end-direct + ${RUN} end-indirect -all: undefined unclosed-expression unclosed-modifier unknown-modifier -all: depend-target -all: end # Undefined variables in expressions are not an error. They expand to empty # strings. -# expect: : undefined--eol -undefined: +# expect: : undefined-direct--eol +# expect: end undefined-direct with status 0 +# expect: : undefined-direct--eol +# expect: end undefined-indirect with status 0 +undefined-indirect: undefined-direct +undefined-direct: : $@-${UNDEFINED}-eol -unclosed-expression: -# expect: make: in target "unclosed-expression": Unclosed variable "UNCLOSED" -# expect-not: : unclosed-expression- - : $@-${UNCLOSED - -unclosed-modifier: -# expect: make: in target "unclosed-modifier": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}' -# expect-not: : unclosed-modifier- - : $@-${UNCLOSED: - -unknown-modifier: -# expect: make: in target "unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z" -# expect
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Mon Jul 22 18:02:51 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: cmd-errors-jobs.exp cmd-errors-jobs.mk Log Message: tests/make: demonstrate wrong exit status for .END dependency To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cmd-errors-jobs.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 Jul 20 14:09:27 UTC 2024 Modified Files: src/usr.bin/make: job.c src/usr.bin/make/unit-tests: cmd-errors-jobs.exp cmd-errors-jobs.mk Log Message: make: don't run erroneous commands in parallel mode To generate a diff of this commit: cvs rdiff -u -r1.480 -r1.481 src/usr.bin/make/job.c cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cmd-errors-jobs.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.480 src/usr.bin/make/job.c:1.481 --- src/usr.bin/make/job.c:1.480 Sun Jul 7 07:50:57 2024 +++ src/usr.bin/make/job.c Sat Jul 20 14:09:27 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.480 2024/07/07 07:50:57 rillig Exp $ */ +/* $NetBSD: job.c,v 1.481 2024/07/20 14:09:27 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -141,7 +141,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.480 2024/07/07 07:50:57 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.481 2024/07/20 14:09:27 rillig Exp $"); /* * A shell defines how the commands are run. All commands for a target are @@ -1680,6 +1680,8 @@ JobStart(GNode *gn, bool special) * virtual targets. */ + int parseErrorsBefore; + /* * We're serious here, but if the commands were bogus, we're * also dead... @@ -1689,7 +1691,10 @@ JobStart(GNode *gn, bool special) DieHorribly(); } + parseErrorsBefore = parseErrors; JobWriteShellCommands(job, gn, &run); + if (parseErrors != parseErrorsBefore) + run = false; (void)fflush(job->cmdFILE); } else if (!GNode_ShouldExecute(gn)) { /* Index: src/usr.bin/make/unit-tests/cmd-errors-jobs.exp diff -u src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.10 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.11 --- src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.10 Sat Jul 20 13:59:31 2024 +++ src/usr.bin/make/unit-tests/cmd-errors-jobs.exp Sat Jul 20 14:09:27 2024 @@ -1,12 +1,8 @@ : undefined--eol make: in target "unclosed-expression": Unclosed variable "UNCLOSED" -: unclosed-expression- make: in target "unclosed-modifier": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}' -: unclosed-modifier- make: in target "unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z" -: unknown-modifier--eol make: in target "depend-source": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}' -: depend-source- : end-eol : Making depend-target : .END-eol Index: src/usr.bin/make/unit-tests/cmd-errors-jobs.mk diff -u src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.9 src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.10 --- src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.9 Sat Jul 20 13:59:31 2024 +++ src/usr.bin/make/unit-tests/cmd-errors-jobs.mk Sat Jul 20 14:09:27 2024 @@ -1,4 +1,4 @@ -# $NetBSD: cmd-errors-jobs.mk,v 1.9 2024/07/20 13:59:31 rillig Exp $ +# $NetBSD: cmd-errors-jobs.mk,v 1.10 2024/07/20 14:09:27 rillig Exp $ # # Demonstrate how errors in expressions affect whether the commands # are actually executed in jobs mode. @@ -17,20 +17,17 @@ undefined: unclosed-expression: # expect: make: in target "unclosed-expression": Unclosed variable "UNCLOSED" -# XXX: This command is executed even though it contains parse errors. -# expect: : unclosed-expression- +# expect-not: : unclosed-expression- : $@-${UNCLOSED unclosed-modifier: # expect: make: in target "unclosed-modifier": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}' -# XXX: This command is executed even though it contains parse errors. -# expect: : unclosed-modifier- +# expect-not: : unclosed-modifier- : $@-${UNCLOSED: unknown-modifier: # expect: make: in target "unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z" -# XXX: This command is executed even though it contains parse errors. -# expect: : unknown-modifier--eol +# expect-not: : unknown-modifier--eol : $@-${UNKNOWN:Z}-eol depend-target: depend-source
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Jul 20 14:09:27 UTC 2024 Modified Files: src/usr.bin/make: job.c src/usr.bin/make/unit-tests: cmd-errors-jobs.exp cmd-errors-jobs.mk Log Message: make: don't run erroneous commands in parallel mode To generate a diff of this commit: cvs rdiff -u -r1.480 -r1.481 src/usr.bin/make/job.c cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cmd-errors-jobs.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
Module Name:src Committed By: rillig Date: Sat Jul 20 13:59:31 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: cmd-errors-jobs.exp cmd-errors-jobs.mk Log Message: tests/make: demonstrate failing dependency in parallel mode In parallel mode, when generating the commands for a target, parse or evaluation errors still continue generating and executing the commands. And if the commands succeed, the targets that depend on this target are still made. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/cmd-errors-jobs.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/cmd-errors-jobs.exp diff -u src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.9 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.10 --- src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.9 Tue Jul 9 19:43:01 2024 +++ src/usr.bin/make/unit-tests/cmd-errors-jobs.exp Sat Jul 20 13:59:31 2024 @@ -5,5 +5,9 @@ make: in target "unclosed-modifier": whi : unclosed-modifier- make: in target "unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z" : unknown-modifier--eol +make: in target "depend-source": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}' +: depend-source- : end-eol +: Making depend-target +: .END-eol exit status 2 Index: src/usr.bin/make/unit-tests/cmd-errors-jobs.mk diff -u src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.8 src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.9 --- src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.8 Tue Jul 9 19:43:01 2024 +++ src/usr.bin/make/unit-tests/cmd-errors-jobs.mk Sat Jul 20 13:59:31 2024 @@ -1,11 +1,13 @@ -# $NetBSD: cmd-errors-jobs.mk,v 1.8 2024/07/09 19:43:01 rillig Exp $ +# $NetBSD: cmd-errors-jobs.mk,v 1.9 2024/07/20 13:59:31 rillig Exp $ # # Demonstrate how errors in expressions affect whether the commands # are actually executed in jobs mode. .MAKEFLAGS: -j1 -all: undefined unclosed-expression unclosed-modifier unknown-modifier end +all: undefined unclosed-expression unclosed-modifier unknown-modifier +all: depend-target +all: end # Undefined variables in expressions are not an error. They expand to empty # strings. @@ -31,8 +33,22 @@ unknown-modifier: # expect: : unknown-modifier--eol : $@-${UNKNOWN:Z}-eol +depend-target: depend-source +# TODO: don't make the target, as its source failed to generate the commands. +# expect: : Making depend-target +# expect-reset + : Making $@ + +depend-source: +# expect: make: in target "depend-source": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}' + : $@-${UNCLOSED: + # expect: : end-eol end: : $@-eol +# expect: : .END-eol +.END: + : $@-eol + # expect: exit status 2
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sat Jul 20 13:59:31 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: cmd-errors-jobs.exp cmd-errors-jobs.mk Log Message: tests/make: demonstrate failing dependency in parallel mode In parallel mode, when generating the commands for a target, parse or evaluation errors still continue generating and executing the commands. And if the commands succeed, the targets that depend on this target are still made. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/cmd-errors-jobs.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 Jul 20 11:05:12 UTC 2024 Modified Files: src/usr.bin/make: compat.c src/usr.bin/make/unit-tests: check-expect.lua cmd-errors-lint.exp cmd-errors-lint.mk cmd-errors.exp cmd-errors.mk lint.exp moderrs.exp moderrs.mk varmisc.exp varmisc.mk varmod-assign.exp varmod-assign.mk varmod-hash.exp varmod-hash.mk varmod-select-words.exp varmod-select-words.mk varmod-subst-regex.exp varmod-subst-regex.mk varmod-subst.exp varmod-subst.mk Log Message: make: don't run erroneous commands in compat mode When there is a parse or evaluation error in an expression that becomes part of the command, don't run that command, as the result of the failed evaluation typically contains garbage characters. Skip the remaining commands from that target as well, as they may depend on the erroneous command. To generate a diff of this commit: cvs rdiff -u -r1.260 -r1.261 src/usr.bin/make/compat.c cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/check-expect.lua \ src/usr.bin/make/unit-tests/cmd-errors-lint.exp cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cmd-errors-lint.mk \ src/usr.bin/make/unit-tests/varmod-select-words.exp \ src/usr.bin/make/unit-tests/varmod-select-words.mk cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/cmd-errors.exp cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cmd-errors.mk cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/lint.exp \ src/usr.bin/make/unit-tests/varmod-hash.mk cvs rdiff -u -r1.43 -r1.44 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.39 -r1.40 src/usr.bin/make/unit-tests/moderrs.mk cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/varmisc.exp \ src/usr.bin/make/unit-tests/varmod-assign.mk cvs rdiff -u -r1.35 -r1.36 src/usr.bin/make/unit-tests/varmisc.mk cvs rdiff -u -r1.27 -r1.28 src/usr.bin/make/unit-tests/varmod-assign.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-hash.exp cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/varmod-subst-regex.exp cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/varmod-subst-regex.mk cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-subst.exp cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/varmod-subst.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/compat.c diff -u src/usr.bin/make/compat.c:1.260 src/usr.bin/make/compat.c:1.261 --- src/usr.bin/make/compat.c:1.260 Thu Jul 11 20:09:16 2024 +++ src/usr.bin/make/compat.c Sat Jul 20 11:05:11 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.260 2024/07/11 20:09:16 sjg Exp $ */ +/* $NetBSD: compat.c,v 1.261 2024/07/20 11:05:11 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -91,7 +91,7 @@ #include "pathnames.h" /* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: compat.c,v 1.260 2024/07/11 20:09:16 sjg Exp $"); +MAKE_RCSID("$NetBSD: compat.c,v 1.261 2024/07/20 11:05:11 rillig Exp $"); static GNode *curTarg = NULL; static pid_t compatChild; @@ -248,13 +248,18 @@ Compat_RunCommand(const char *cmdp, GNod const char *cmd = cmdp; char cmd_file[MAXPATHLEN]; size_t cmd_len; + int parseErrorsBefore; silent = (gn->type & OP_SILENT) != OP_NONE; errCheck = !(gn->type & OP_IGNORE); doIt = false; + parseErrorsBefore = parseErrors; cmdStart = Var_SubstInTarget(cmd, gn); - /* TODO: handle errors */ + if (parseErrors != parseErrorsBefore) { + free(cmdStart); + return false; + } if (cmdStart[0] == '\0') { free(cmdStart); Index: src/usr.bin/make/unit-tests/check-expect.lua diff -u src/usr.bin/make/unit-tests/check-expect.lua:1.8 src/usr.bin/make/unit-tests/check-expect.lua:1.9 --- src/usr.bin/make/unit-tests/check-expect.lua:1.8 Sun Dec 17 09:44:00 2023 +++ src/usr.bin/make/unit-tests/check-expect.lua Sat Jul 20 11:05:11 2024 @@ -1,5 +1,5 @@ #! /usr/bin/lua --- $NetBSD: check-expect.lua,v 1.8 2023/12/17 09:44:00 rillig Exp $ +-- $NetBSD: check-expect.lua,v 1.9 2024/07/20 11:05:11 rillig Exp $ --[[ @@ -19,6 +19,10 @@ expected text in the corresponding .exp # expect[+-]offset: Each message must occur in the .exp file and refer back to the source line in the .mk file. + +# expect-not: +The substring must not occur as part of any line of the .exp file. + ]] @@ -104,6 +108,18 @@ local function check_mk(mk_fname) local prev_expect_line = 0 for mk_lineno, mk_line in ipairs(mk_lines) do + +for text in mk_line:gmatch("#%s*expect%-not:%s*(.*)") do + local i = 1 + while i <= #exp_lines and not exp_lines[i]:find(text, 1, true) do +i = i + 1 + end + if i <= #exp_lines then +print_error("error: %s:%d: %s must not contain '%s'", + mk_fname, mk_lineno, exp_fname, text) + end +end
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Jul 20 11:05:12 UTC 2024 Modified Files: src/usr.bin/make: compat.c src/usr.bin/make/unit-tests: check-expect.lua cmd-errors-lint.exp cmd-errors-lint.mk cmd-errors.exp cmd-errors.mk lint.exp moderrs.exp moderrs.mk varmisc.exp varmisc.mk varmod-assign.exp varmod-assign.mk varmod-hash.exp varmod-hash.mk varmod-select-words.exp varmod-select-words.mk varmod-subst-regex.exp varmod-subst-regex.mk varmod-subst.exp varmod-subst.mk Log Message: make: don't run erroneous commands in compat mode When there is a parse or evaluation error in an expression that becomes part of the command, don't run that command, as the result of the failed evaluation typically contains garbage characters. Skip the remaining commands from that target as well, as they may depend on the erroneous command. To generate a diff of this commit: cvs rdiff -u -r1.260 -r1.261 src/usr.bin/make/compat.c cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/check-expect.lua \ src/usr.bin/make/unit-tests/cmd-errors-lint.exp cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cmd-errors-lint.mk \ src/usr.bin/make/unit-tests/varmod-select-words.exp \ src/usr.bin/make/unit-tests/varmod-select-words.mk cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/cmd-errors.exp cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cmd-errors.mk cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/lint.exp \ src/usr.bin/make/unit-tests/varmod-hash.mk cvs rdiff -u -r1.43 -r1.44 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.39 -r1.40 src/usr.bin/make/unit-tests/moderrs.mk cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/varmisc.exp \ src/usr.bin/make/unit-tests/varmod-assign.mk cvs rdiff -u -r1.35 -r1.36 src/usr.bin/make/unit-tests/varmisc.mk cvs rdiff -u -r1.27 -r1.28 src/usr.bin/make/unit-tests/varmod-assign.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-hash.exp cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/varmod-subst-regex.exp cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/varmod-subst-regex.mk cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-subst.exp cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/varmod-subst.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
Module Name:src Committed By: rillig Date: Sat Jul 20 09:22:19 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: moderrs.exp moderrs.mk Log Message: tests/make: remove redundant context information The affected target is already mentioned in the line containing the error message. To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.38 -r1.39 src/usr.bin/make/unit-tests/moderrs.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/moderrs.exp diff -u src/usr.bin/make/unit-tests/moderrs.exp:1.42 src/usr.bin/make/unit-tests/moderrs.exp:1.43 --- src/usr.bin/make/unit-tests/moderrs.exp:1.42 Tue Jul 9 19:43:01 2024 +++ src/usr.bin/make/unit-tests/moderrs.exp Sat Jul 20 09:22:19 2024 @@ -1,31 +1,21 @@ make: in target "mod-unknown-direct": while evaluating variable "VAR" with value "TheVariable": Unknown modifier "Z" VAR:Z=before--after - make: in target "mod-unknown-indirect": while evaluating variable "VAR" with value "TheVariable": Unknown modifier "Z" VAR:Z=before-inner}-after - -unclosed-direct: make: in target "unclosed-direct": while evaluating variable "VAR" with value "Thevariable": Unclosed expression, expecting '}' for modifier "S,V,v," VAR:S,V,v,=Thevariable - -unclosed-indirect: make: in target "unclosed-indirect": while evaluating variable "VAR" with value "Thevariable": Unclosed expression after indirect modifier, expecting '}' VAR:S,V,v,=Thevariable - make: in target "unfinished-indirect": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing) VAR:S,V,v= - make: in target "unfinished-loop": while evaluating variable "UNDEF" with value "1 2 3": Unfinished modifier ('@' missing) make: in target "unfinished-loop": while evaluating variable "UNDEF" with value "1 2 3": Unfinished modifier ('@' missing) 1 2 3 - -loop-close: make: in target "loop-close": while evaluating variable "UNDEF" with value "1}... 2}... 3}...": Unclosed expression, expecting '}' for modifier "@var@${var}}...@" 1}... 2}... 3}... 1}... 2}... 3}... - make: in target "words": while evaluating variable "UNDEF" with value "1 2 3": Unfinished modifier (']' missing) make: in target "words": while evaluating variable "UNDEF" with value "1 2 3": Unfinished modifier (']' missing) @@ -33,12 +23,10 @@ make: in target "words": while evaluatin 13= make: in target "words": while evaluating variable "UNDEF" with value "1 2 3": Bad modifier ":[123451234512345123451234512345]" 12345=S,^ok,:S,^3ok,} - make: in target "exclam": while evaluating variable "VARNAME" with value "": Unfinished modifier ('!' missing) make: in target "exclam": while evaluating variable "!" with value "!": Unfinished modifier ('!' missing) - make: in target "mod-subst-delimiter": while evaluating variable "VAR" with value "TheVariable": Missing delimiter for modifier ':S' 1: make: in target "mod-subst-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing) @@ -52,7 +40,6 @@ make: in target "mod-subst-delimiter": w make: in target "mod-subst-delimiter": while evaluating variable "VAR" with value "TheVariable": Unclosed expression, expecting '}' for modifier "S,from,to," 6: TheVariable 7: TheVariable - make: in target "mod-regex-delimiter": while evaluating variable "VAR" with value "TheVariable": Missing delimiter for modifier ':C' 1: make: in target "mod-regex-delimiter": while evaluating variable "VAR" with value "TheVariable": Unfinished modifier (',' missing) @@ -66,8 +53,6 @@ make: in target "mod-regex-delimiter": w make: in target "mod-regex-delimiter": while evaluating variable "VAR" with value "TheVariable": Unclosed expression, expecting '}' for modifier "C,from,to," 6: TheVariable 7: TheVariable - -mod-ts-parse: 112358132134 15152535558513521534 make: in target "mod-ts-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":ts\65oct" @@ -76,8 +61,6 @@ make: in target "mod-ts-parse": while ev 65oct} make: in target "mod-ts-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":tsxy" xy} - -mod-t-parse: make: in target "mod-t-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":t" make: in target "mod-t-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":txy" @@ -86,7 +69,6 @@ make: in target "mod-t-parse": while eva make: in target "mod-t-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":t" M*} - make: in target "mod-ifelse-parse": while evaluating then-branch of condition "FIB": Unfinished modifier (':' missing) make: in target "mod-ifelse-parse": while evaluating then-branch of condition "FIB": Unfinished modifier (':' missing) @@
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sat Jul 20 09:22:19 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: moderrs.exp moderrs.mk Log Message: tests/make: remove redundant context information The affected target is already mentioned in the line containing the error message. To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.38 -r1.39 src/usr.bin/make/unit-tests/moderrs.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 Jul 20 08:54:19 UTC 2024 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varmod-order.exp varmod-order.mk varparse-errors.exp varparse-errors.mk Log Message: make: remove wrong error message about an undefined variable To generate a diff of this commit: cvs rdiff -u -r1.1135 -r1.1136 src/usr.bin/make/var.c cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-order.exp cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/varmod-order.mk \ src/usr.bin/make/unit-tests/varparse-errors.exp cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/varparse-errors.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 Jul 20 08:54:19 UTC 2024 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varmod-order.exp varmod-order.mk varparse-errors.exp varparse-errors.mk Log Message: make: remove wrong error message about an undefined variable To generate a diff of this commit: cvs rdiff -u -r1.1135 -r1.1136 src/usr.bin/make/var.c cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-order.exp cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/varmod-order.mk \ src/usr.bin/make/unit-tests/varparse-errors.exp cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/varparse-errors.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.1135 src/usr.bin/make/var.c:1.1136 --- src/usr.bin/make/var.c:1.1135 Tue Jul 9 17:07:23 2024 +++ src/usr.bin/make/var.c Sat Jul 20 08:54:19 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1135 2024/07/09 17:07:23 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1136 2024/07/20 08:54:19 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -128,7 +128,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1135 2024/07/09 17:07:23 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1136 2024/07/20 08:54:19 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -4677,8 +4677,7 @@ VarSubstDollarDollar(const char **pp, Bu } static void -VarSubstExpr(const char **pp, Buffer *buf, GNode *scope, - VarEvalMode emode, bool *inout_errorReported) +VarSubstExpr(const char **pp, Buffer *buf, GNode *scope, VarEvalMode emode) { const char *p = *pp; const char *nested_p = p; @@ -4686,28 +4685,8 @@ VarSubstExpr(const char **pp, Buffer *bu /* TODO: handle errors */ if (val.str == var_Error || val.str == varUndefined) { - if (!VarEvalMode_ShouldKeepUndef(emode)) { - p = nested_p; - } else if (val.str == var_Error) { - - /* - * FIXME: The condition 'val.str == var_Error' doesn't - * mean there was an undefined variable. It could - * equally well be a parse error; see - * unit-tests/varmod-order.mk. - */ - - /* - * If variable is undefined, complain and skip the - * variable. The complaint will stop us from doing - * anything when the file is parsed. - */ - if (!*inout_errorReported) { -Parse_Error(PARSE_FATAL, -"Undefined variable \"%.*s\"", -(int)(nested_p - p), p); -*inout_errorReported = true; - } + if (!VarEvalMode_ShouldKeepUndef(emode) + || val.str == var_Error) { p = nested_p; } else { /* @@ -4761,20 +4740,13 @@ Var_Subst(const char *str, GNode *scope, const char *p = str; Buffer res; - /* - * Set true if an error has already been reported, to prevent a - * plethora of messages when recursing - */ - static bool errorReported; - Buf_Init(&res); - errorReported = false; while (*p != '\0') { if (p[0] == '$' && p[1] == '$') VarSubstDollarDollar(&p, &res, emode); else if (p[0] == '$') - VarSubstExpr(&p, &res, scope, emode, &errorReported); + VarSubstExpr(&p, &res, scope, emode); else VarSubstPlain(&p, &res); } Index: src/usr.bin/make/unit-tests/varmod-order.exp diff -u src/usr.bin/make/unit-tests/varmod-order.exp:1.13 src/usr.bin/make/unit-tests/varmod-order.exp:1.14 --- src/usr.bin/make/unit-tests/varmod-order.exp:1.13 Fri Jul 5 18:59:33 2024 +++ src/usr.bin/make/unit-tests/varmod-order.exp Sat Jul 20 08:54:19 2024 @@ -1,26 +1,24 @@ -make: "varmod-order.mk" line 17: while evaluating variable "WORDS" with value "one two three four five six seven eight nine ten": Bad modifier ":OX" -make: "varmod-order.mk" line 17: Undefined variable "${WORDS:OX" -make: "varmod-order.mk" line 23: while evaluating variable "WORDS" with value "one two three four five six seven eight nine ten": Bad modifier ":OxXX" -make: "varmod-order.mk" line 23: Undefined variable "${WORDS:Ox" -make: "varmod-order.mk" line 27: while evaluating variable "WORDS" with value "eight five four nine one seven six ten three two": Unclosed expression, expecting '}' for modifier "O" -make: "varmod-order.mk" line 29: while evaluating variable "NUMBERS" with value "1 2 3 4 5 6 7 8 9 10": Unclosed expression, expecting '}' for modifier "On" -make: "varmod-order.mk" line 31: while evaluating variable "NUMBERS" with value "10 9 8 7 6 5 4 3 2 1": Unclosed expression, expecting '}' for modifier "Onr" -make: "varmod-order.mk" line 38: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":Oxn" -make: "varmod-order.mk" line 38: Malformed conditional (${NUMBERS:Oxn}) -make: "varmod-order.mk" line 48: while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2": Bad modifier ":On_typo" -make: "varmod-order.mk" line 48: Malformed conditional (${NU
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sat Jul 13 15:10:06 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: cmd-interrupt.exp cmd-interrupt.mk Log Message: tests/make: demonstrate interrupting make in compat mode To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cmd-interrupt.exp cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cmd-interrupt.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/cmd-interrupt.exp diff -u src/usr.bin/make/unit-tests/cmd-interrupt.exp:1.3 src/usr.bin/make/unit-tests/cmd-interrupt.exp:1.4 --- src/usr.bin/make/unit-tests/cmd-interrupt.exp:1.3 Sat Mar 18 22:20:12 2023 +++ src/usr.bin/make/unit-tests/cmd-interrupt.exp Sat Jul 13 15:10:06 2024 @@ -5,4 +5,5 @@ interrupt-ordinary: ok interrupt-phony: ok > cmd-interrupt-precious interrupt-precious: ok +interrupt-compat expected-fail exit status 0 Index: src/usr.bin/make/unit-tests/cmd-interrupt.mk diff -u src/usr.bin/make/unit-tests/cmd-interrupt.mk:1.4 src/usr.bin/make/unit-tests/cmd-interrupt.mk:1.5 --- src/usr.bin/make/unit-tests/cmd-interrupt.mk:1.4 Sat Mar 18 22:20:12 2023 +++ src/usr.bin/make/unit-tests/cmd-interrupt.mk Sat Jul 13 15:10:06 2024 @@ -1,4 +1,4 @@ -# $NetBSD: cmd-interrupt.mk,v 1.4 2023/03/18 22:20:12 sjg Exp $ +# $NetBSD: cmd-interrupt.mk,v 1.5 2024/07/13 15:10:06 rillig Exp $ # # Tests for interrupting a command. # @@ -17,10 +17,16 @@ # See also: # CompatDeleteTarget -all: clean-before interrupt-ordinary interrupt-phony interrupt-precious clean-after +all: clean-before +all: interrupt-ordinary +all: interrupt-phony +all: interrupt-precious +all: interrupt-compat +all: clean-after clean-before clean-after: .PHONY - @rm -f cmd-interrupt-ordinary cmd-interrupt-phony cmd-interrupt-precious + @rm -f cmd-interrupt-ordinary cmd-interrupt-phony + @rm -f cmd-interrupt-precious cmd-interrupt-compat interrupt-ordinary: @${.MAKE} ${MAKEFLAGS} -f ${MAKEFILE} cmd-interrupt-ordinary || true @@ -37,6 +43,10 @@ interrupt-precious: .PRECIOUS # The ././ is necessary to work around the file cache. @echo ${.TARGET}: ${exists(././cmd-interrupt-precious) :? ok : error } +interrupt-compat: + @${MAKE} -f ${MAKEFILE} cmd-interrupt-compat || true + @echo ${.TARGET} ${exists(././cmd-interrupt-compat) :? expected-fail : unexpected-ok } + cmd-interrupt-ordinary: > ${.TARGET} @kill -INT ${.MAKE.PID} @@ -48,3 +58,11 @@ cmd-interrupt-phony: .PHONY cmd-interrupt-precious: .PRECIOUS > ${.TARGET} @kill -INT ${.MAKE.PID} + +# When the make process (and not the process group) is interrupted in compat +# mode, it first tries to interrupt the process group of the currently running +# child command, but that fails since there is no such process group, rather +# the child command runs in the same process group as make itself. The child +# command then continues, and after sleeping a bit creates the target file. +cmd-interrupt-compat: + @kill -INT ${.MAKE.PID} && sleep 1 && > ${.TARGET}
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sat Jul 13 15:10:06 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: cmd-interrupt.exp cmd-interrupt.mk Log Message: tests/make: demonstrate interrupting make in compat mode To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cmd-interrupt.exp cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cmd-interrupt.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: sjg Date: Thu Jul 11 20:09:16 UTC 2024 Modified Files: src/usr.bin/make: compat.c main.c make.h src/usr.bin/make/unit-tests: var-op-shell.mk Log Message: Compat_RunCommand use tempfile if cmd too big Extract the logic recently added to Cmd_Exec to handle long commands via temp file to Cmd_Argv, so it can also be leveraged by Compat_RunCommand Reviewed by: christos To generate a diff of this commit: cvs rdiff -u -r1.259 -r1.260 src/usr.bin/make/compat.c cvs rdiff -u -r1.631 -r1.632 src/usr.bin/make/main.c cvs rdiff -u -r1.343 -r1.344 src/usr.bin/make/make.h cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/var-op-shell.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/compat.c diff -u src/usr.bin/make/compat.c:1.259 src/usr.bin/make/compat.c:1.260 --- src/usr.bin/make/compat.c:1.259 Sat Jun 15 20:02:45 2024 +++ src/usr.bin/make/compat.c Thu Jul 11 20:09:16 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.259 2024/06/15 20:02:45 rillig Exp $ */ +/* $NetBSD: compat.c,v 1.260 2024/07/11 20:09:16 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -91,7 +91,7 @@ #include "pathnames.h" /* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: compat.c,v 1.259 2024/06/15 20:02:45 rillig Exp $"); +MAKE_RCSID("$NetBSD: compat.c,v 1.260 2024/07/11 20:09:16 sjg Exp $"); static GNode *curTarg = NULL; static pid_t compatChild; @@ -246,6 +246,8 @@ Compat_RunCommand(const char *cmdp, GNod bool useShell; /* True if command should be executed using a * shell */ const char *cmd = cmdp; + char cmd_file[MAXPATHLEN]; + size_t cmd_len; silent = (gn->type & OP_SILENT) != OP_NONE; errCheck = !(gn->type & OP_IGNORE); @@ -316,20 +318,20 @@ Compat_RunCommand(const char *cmdp, GNod DEBUG1(JOB, "Execute: '%s'\n", cmd); - if (useShell && shellPath == NULL) - Shell_Init(); /* we need shellPath */ + cmd_len = strlen(cmd); + if (cmd_len > MAKE_CMDLEN_LIMIT) + useShell = true; + else + cmd_file[0] = '\0'; if (useShell) { static const char *shargv[5]; - /* The following work for any of the builtin shell specs. */ - int shargc = 0; - shargv[shargc++] = shellPath; - if (errCheck && shellErrFlag != NULL) - shargv[shargc++] = shellErrFlag; - shargv[shargc++] = DEBUG(SHELL) ? "-xc" : "-c"; - shargv[shargc++] = cmd; - shargv[shargc] = NULL; + if (Cmd_Argv(cmd, cmd_len, shargv, 5, + cmd_file, sizeof(cmd_file), + (errCheck && shellErrFlag != NULL), + DEBUG(SHELL)) < 0) + Fatal("cannot run \"%s\"", cmd); av = shargv; bp = NULL; mav = NULL; @@ -422,6 +424,8 @@ Compat_RunCommand(const char *cmdp, GNod } free(cmdStart); + if (cmd_file[0] != '\0') + unlink(cmd_file); compatChild = 0; if (compatSigno != 0) { bmake_signal(compatSigno, SIG_DFL); Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.631 src/usr.bin/make/main.c:1.632 --- src/usr.bin/make/main.c:1.631 Tue Jul 9 19:43:01 2024 +++ src/usr.bin/make/main.c Thu Jul 11 20:09:16 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.631 2024/07/09 19:43:01 rillig Exp $ */ +/* $NetBSD: main.c,v 1.632 2024/07/11 20:09:16 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -111,7 +111,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.631 2024/07/09 19:43:01 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.632 2024/07/11 20:09:16 sjg Exp $"); #if defined(MAKE_NATIVE) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -1685,6 +1685,56 @@ found: return true; } +/* populate av for Cmd_Exec and Compat_RunCommand */ +int +Cmd_Argv(const char *cmd, size_t cmd_len, const char **av, size_t avsz, +char *cmd_file, size_t cmd_filesz, bool eflag, bool xflag) +{ + int ac = 0; + int cmd_fd = -1; + + if (shellPath == NULL) + Shell_Init(); + + if (cmd_file != NULL) { + if (cmd_len == 0) + cmd_len = strlen(cmd); + + if (cmd_len > MAKE_CMDLEN_LIMIT) { + cmd_fd = mkTempFile(NULL, cmd_file, cmd_filesz); + if (cmd_fd >= 0) { +ssize_t n; + +n = write(cmd_fd, cmd, cmd_len); +close(cmd_fd); +if (n < (ssize_t)cmd_len) { + unlink(cmd_file); + cmd_fd = -1; +} + } + } else + cmd_file[0] = '\0'; + } + + if (avsz < 4 || (eflag && avsz < 5)) + return -1; + + /* The following works for any of the builtin shell specs. */ + av[ac++] = shellPath; + if (eflag) + av[ac++] = shellErrFlag; + if (cmd_fd >= 0) { + if (xflag) + av[ac++] = "-x"; + av[ac++] = cmd_file; + } else { + av[ac++] = xflag ? "-xc" : "-c"; + av[ac++] = cmd; + } + av[ac] = NULL; + return ac; +} + /* * Execute the command in cmd, and return its output (only stdout, not * stderr, possibly empty). In the output, replace newlines with spaces. @@ -1703,40 +1753,11 @@ Cm
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Thu Jul 11 20:09:16 UTC 2024 Modified Files: src/usr.bin/make: compat.c main.c make.h src/usr.bin/make/unit-tests: var-op-shell.mk Log Message: Compat_RunCommand use tempfile if cmd too big Extract the logic recently added to Cmd_Exec to handle long commands via temp file to Cmd_Argv, so it can also be leveraged by Compat_RunCommand Reviewed by: christos To generate a diff of this commit: cvs rdiff -u -r1.259 -r1.260 src/usr.bin/make/compat.c cvs rdiff -u -r1.631 -r1.632 src/usr.bin/make/main.c cvs rdiff -u -r1.343 -r1.344 src/usr.bin/make/make.h cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/var-op-shell.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Tue Jul 9 19:43:02 UTC 2024 Modified Files: src/usr.bin/make: main.c make.h parse.c src/usr.bin/make/unit-tests: cmd-errors-jobs.exp cmd-errors-jobs.mk cmd-errors.exp cmd-errors.mk dep-var.exp moderrs.exp varmisc.exp varmod-assign.exp varmod-hash.exp varmod-select-words.exp varmod-subst.exp Log Message: make: error out on parse/evaluation errors in shell commands The expression ${VAR:X} has an unknown modifier ':X'. Previously, this expression errored out when the expression was evaluated at parse time, but not when the expression was evaluated when generating the commands to bring a target up to date. The errors were previously reported, they didn't affect the exit status, though. Now, errors in expressions are handled in the same way, regardless of the time at which they are evaluated. To generate a diff of this commit: cvs rdiff -u -r1.630 -r1.631 src/usr.bin/make/main.c cvs rdiff -u -r1.342 -r1.343 src/usr.bin/make/make.h cvs rdiff -u -r1.733 -r1.734 src/usr.bin/make/parse.c cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp \ src/usr.bin/make/unit-tests/cmd-errors.mk cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cmd-errors-jobs.mk \ src/usr.bin/make/unit-tests/dep-var.exp cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/cmd-errors.exp cvs rdiff -u -r1.41 -r1.42 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/varmisc.exp cvs rdiff -u -r1.26 -r1.27 src/usr.bin/make/unit-tests/varmod-assign.exp cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-hash.exp cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-select-words.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-subst.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/main.c diff -u src/usr.bin/make/main.c:1.630 src/usr.bin/make/main.c:1.631 --- src/usr.bin/make/main.c:1.630 Sun Jul 7 09:54:12 2024 +++ src/usr.bin/make/main.c Tue Jul 9 19:43:01 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.630 2024/07/07 09:54:12 rillig Exp $ */ +/* $NetBSD: main.c,v 1.631 2024/07/09 19:43:01 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -111,7 +111,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.630 2024/07/07 09:54:12 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.631 2024/07/09 19:43:01 rillig Exp $"); #if defined(MAKE_NATIVE) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -1604,7 +1604,7 @@ main_CleanUp(void) static int main_Exit(bool outOfDate) { - if (opts.strict && (main_errors > 0 || Parse_NumErrors() > 0)) + if ((opts.strict && main_errors > 0) || parseErrors > 0) return 2; /* Not 1 so -q can distinguish error */ return outOfDate ? 1 : 0; } Index: src/usr.bin/make/make.h diff -u src/usr.bin/make/make.h:1.342 src/usr.bin/make/make.h:1.343 --- src/usr.bin/make/make.h:1.342 Sun Jul 7 09:54:12 2024 +++ src/usr.bin/make/make.h Tue Jul 9 19:43:01 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.342 2024/07/07 09:54:12 rillig Exp $ */ +/* $NetBSD: make.h,v 1.343 2024/07/09 19:43:01 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -861,6 +861,7 @@ const char *cached_realpath(const char * bool GetBooleanExpr(const char *, bool); /* parse.c */ +extern int parseErrors; void Parse_Init(void); #ifdef CLEANUP void Parse_End(void); @@ -874,7 +875,6 @@ void Parse_File(const char *, int); void Parse_PushInput(const char *, unsigned, unsigned, Buffer, struct ForLoop *); void Parse_MainName(GNodeList *); -int Parse_NumErrors(void) MAKE_ATTR_USE; unsigned int CurFile_CondMinDepth(void) MAKE_ATTR_USE; void Parse_GuardElse(void); void Parse_GuardEndif(void); Index: src/usr.bin/make/parse.c diff -u src/usr.bin/make/parse.c:1.733 src/usr.bin/make/parse.c:1.734 --- src/usr.bin/make/parse.c:1.733 Sun Jul 7 07:50:57 2024 +++ src/usr.bin/make/parse.c Tue Jul 9 19:43:01 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.733 2024/07/07 07:50:57 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.734 2024/07/09 19:43:01 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -105,7 +105,7 @@ #include "pathnames.h" /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: parse.c,v 1.733 2024/07/07 07:50:57 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.734 2024/07/09 19:43:01 rillig Exp $"); /* Detects a multiple-inclusion guard in a makefile. */ typedef enum { @@ -231,7 +231,7 @@ static StringList targCmds = LST_INIT; */ static GNode *order_pred; -static int parseErrors; +int parseErrors; /* * The include chain of makefiles. At index 0 is the top-level makefile from @@ -3012,9 +3012,3 @@ Parse_MainName(GNodeList *mainList) Glob
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Tue Jul 9 19:43:02 UTC 2024 Modified Files: src/usr.bin/make: main.c make.h parse.c src/usr.bin/make/unit-tests: cmd-errors-jobs.exp cmd-errors-jobs.mk cmd-errors.exp cmd-errors.mk dep-var.exp moderrs.exp varmisc.exp varmod-assign.exp varmod-hash.exp varmod-select-words.exp varmod-subst.exp Log Message: make: error out on parse/evaluation errors in shell commands The expression ${VAR:X} has an unknown modifier ':X'. Previously, this expression errored out when the expression was evaluated at parse time, but not when the expression was evaluated when generating the commands to bring a target up to date. The errors were previously reported, they didn't affect the exit status, though. Now, errors in expressions are handled in the same way, regardless of the time at which they are evaluated. To generate a diff of this commit: cvs rdiff -u -r1.630 -r1.631 src/usr.bin/make/main.c cvs rdiff -u -r1.342 -r1.343 src/usr.bin/make/make.h cvs rdiff -u -r1.733 -r1.734 src/usr.bin/make/parse.c cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp \ src/usr.bin/make/unit-tests/cmd-errors.mk cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cmd-errors-jobs.mk \ src/usr.bin/make/unit-tests/dep-var.exp cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/cmd-errors.exp cvs rdiff -u -r1.41 -r1.42 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/varmisc.exp cvs rdiff -u -r1.26 -r1.27 src/usr.bin/make/unit-tests/varmod-assign.exp cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-hash.exp cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-select-words.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-subst.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
Module Name:src Committed By: rillig Date: Tue Jul 9 17:07:23 UTC 2024 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varmod-edge.exp varmod-edge.mk varmod-match-escape.exp varmod-match-escape.mk varmod-match.exp varmod-match.mk Log Message: make: error out on syntax errors in ':M' and ':N' modifiers More than a year ago, the warning has been added. Now it has been promoted to an error. To generate a diff of this commit: cvs rdiff -u -r1.1134 -r1.1135 src/usr.bin/make/var.c cvs rdiff -u -r1.25 -r1.26 src/usr.bin/make/unit-tests/varmod-edge.exp \ src/usr.bin/make/unit-tests/varmod-match.mk cvs rdiff -u -r1.28 -r1.29 src/usr.bin/make/unit-tests/varmod-edge.mk cvs rdiff -u -r1.23 -r1.24 \ src/usr.bin/make/unit-tests/varmod-match-escape.exp cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varmod-match-escape.mk cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/varmod-match.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.1134 src/usr.bin/make/var.c:1.1135 --- src/usr.bin/make/var.c:1.1134 Sun Jul 7 09:54:12 2024 +++ src/usr.bin/make/var.c Tue Jul 9 17:07:23 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1134 2024/07/07 09:54:12 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1135 2024/07/09 17:07:23 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -128,7 +128,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1134 2024/07/07 09:54:12 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1135 2024/07/09 17:07:23 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -2801,7 +2801,7 @@ ModifyWord_Match(Substring word, SepBuf res = Str_Match(word.start, args->pattern); if (res.error != NULL && !args->error_reported) { args->error_reported = true; - Parse_Error(PARSE_WARNING, + Parse_Error(PARSE_FATAL, "%s in pattern '%s' of modifier '%s'", res.error, args->pattern, args->neg ? ":N" : ":M"); } Index: src/usr.bin/make/unit-tests/varmod-edge.exp diff -u src/usr.bin/make/unit-tests/varmod-edge.exp:1.25 src/usr.bin/make/unit-tests/varmod-edge.exp:1.26 --- src/usr.bin/make/unit-tests/varmod-edge.exp:1.25 Sat Jul 6 10:36:23 2024 +++ src/usr.bin/make/unit-tests/varmod-edge.exp Tue Jul 9 17:07:23 2024 @@ -1,5 +1,5 @@ make: "varmod-edge.mk" line 60: while evaluating variable "MOD" with value "${INP:M${:U*)}}": while evaluating variable "INP" with value "(parentheses)": while evaluating "${:U*)" with value "*)": Unclosed expression, expecting '}' for modifier "U*)" -make: "varmod-edge.mk" line 88: warning: while evaluating variable "MOD" with value "${INP:M${:U[[}}": while evaluating variable "INP" with value "[ [[ [[[": Unfinished character list in pattern '[[' of modifier ':M' +make: "varmod-edge.mk" line 88: while evaluating variable "MOD" with value "${INP:M${:U[[}}": while evaluating variable "INP" with value "[ [[ [[[": Unfinished character list in pattern '[[' of modifier ':M' make: "varmod-edge.mk" line 178: while evaluating variable "MOD" with value "${INP:a\=b}": while evaluating variable "INP" with value "file.c file...": Unfinished modifier ('=' missing) make: "varmod-edge.mk" line 194: while evaluating variable "MOD" with value "${INP}": while evaluating variable "INP" with value "value": Unknown modifier ":" make: "varmod-edge.mk" line 194: while evaluating variable "MOD" with value "${INP}": while evaluating variable "INP" with value "": Unknown modifier ":" Index: src/usr.bin/make/unit-tests/varmod-match.mk diff -u src/usr.bin/make/unit-tests/varmod-match.mk:1.25 src/usr.bin/make/unit-tests/varmod-match.mk:1.26 --- src/usr.bin/make/unit-tests/varmod-match.mk:1.25 Thu Jul 4 17:47:54 2024 +++ src/usr.bin/make/unit-tests/varmod-match.mk Tue Jul 9 17:07:23 2024 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-match.mk,v 1.25 2024/07/04 17:47:54 rillig Exp $ +# $NetBSD: varmod-match.mk,v 1.26 2024/07/09 17:07:23 rillig Exp $ # # Tests for the ':M' modifier, which keeps only those words that match the # given pattern. @@ -285,7 +285,7 @@ ${:U*}= asterisk # [ Incomplete empty character list, never matches. WORDS= a a[ -# expect+1: warning: while evaluating variable "WORDS" with value "a a[": Unfinished character list in pattern 'a[' of modifier ':M' +# expect+1: while evaluating variable "WORDS" with value "a a[": Unfinished character list in pattern 'a[' of modifier ':M' .if ${WORDS:Ma[} != "" . error .endif @@ -293,7 +293,7 @@ WORDS= a a[ # [^ Incomplete negated empty character list, matches any single # character. WORDS= a a[ aX -# expect+1: warning: while evaluating variable "WORDS" with value "a a[ aX": Unfinished character list in pattern 'a[^' of modifier ':M' +# expect+1: while evaluating variable "WORDS" with value "
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Tue Jul 9 17:07:23 UTC 2024 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varmod-edge.exp varmod-edge.mk varmod-match-escape.exp varmod-match-escape.mk varmod-match.exp varmod-match.mk Log Message: make: error out on syntax errors in ':M' and ':N' modifiers More than a year ago, the warning has been added. Now it has been promoted to an error. To generate a diff of this commit: cvs rdiff -u -r1.1134 -r1.1135 src/usr.bin/make/var.c cvs rdiff -u -r1.25 -r1.26 src/usr.bin/make/unit-tests/varmod-edge.exp \ src/usr.bin/make/unit-tests/varmod-match.mk cvs rdiff -u -r1.28 -r1.29 src/usr.bin/make/unit-tests/varmod-edge.mk cvs rdiff -u -r1.23 -r1.24 \ src/usr.bin/make/unit-tests/varmod-match-escape.exp cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varmod-match-escape.mk cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/varmod-match.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: Sun Jul 7 11:20:10 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: directive-for-escape.exp directive-for-escape.mk Log Message: tests/make: remove '# expect' lines from .exp file These lines are only supposed to occur in .mk files. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 \ src/usr.bin/make/unit-tests/directive-for-escape.exp cvs rdiff -u -r1.27 -r1.28 \ src/usr.bin/make/unit-tests/directive-for-escape.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/directive-for-escape.exp diff -u src/usr.bin/make/unit-tests/directive-for-escape.exp:1.29 src/usr.bin/make/unit-tests/directive-for-escape.exp:1.30 --- src/usr.bin/make/unit-tests/directive-for-escape.exp:1.29 Sat Jul 6 10:14:35 2024 +++ src/usr.bin/make/unit-tests/directive-for-escape.exp Sun Jul 7 11:20:10 2024 @@ -1,134 +1,45 @@ For: end for 1 For: loop body with chars = !"#$%&'()*+,-./0-9:;<=>?@A-Z[\]_^a-z{|}~: -# expect+2: while evaluating "${:U!"" with value "!"": Unclosed expression, expecting '}' for modifier "U!"" -# expect+1: !" . info ${:U!"#$%&'()*+,-./0-9\:;<=>?@A-Z[\\]_^a-z{|\}~} make: "directive-for-escape.mk" line 21: while evaluating "${:U!"" with value "!"": Unclosed expression, expecting '}' for modifier "U!"" - in .for loop from directive-for-escape.mk:18 with chars = !"#$%&'()*+,-./0-9:;<=>?@A-Z[\]_^a-z{|}~ + in .for loop from directive-for-escape.mk:20 with chars = !"#$%&'()*+,-./0-9:;<=>?@A-Z[\]_^a-z{|}~ make: "directive-for-escape.mk" line 21: !" For: end for 1 For: loop body with chars = !"\\#$%&'()*+,-./0-9:;<=>?@A-Z[\]_^a-z{|}~: -# expect+2: while evaluating "${:U!"" with value "!"\\": Unclosed expression, expecting '}' for modifier "U!"" -# expect+1: !"\\ . info ${:U!"#$%&'()*+,-./0-9\:;<=>?@A-Z[\\]_^a-z{|\}~} make: "directive-for-escape.mk" line 33: while evaluating "${:U!"" with value "!"\\": Unclosed expression, expecting '}' for modifier "U!"" - in .for loop from directive-for-escape.mk:30 with chars = !"\\#$%&'()*+,-./0-9:;<=>?@A-Z[\]_^a-z{|}~ + in .for loop from directive-for-escape.mk:32 with chars = !"\\#$%&'()*+,-./0-9:;<=>?@A-Z[\]_^a-z{|}~ make: "directive-for-escape.mk" line 33: !"\\ For: end for 1 For: loop body with i = $: -# expect: . info ${:U\$} -# expect+9: $ -# expect: . info ${:U${V}} -# expect+7: value -# expect: . info ${:U${V:=-with-modifier}} -# expect+5: value-with-modifier -# expect: . info ${:U$(V)} -# expect+3: value -# expect: . info ${:U$(V:=-with-modifier)} -# expect+1: value-with-modifier . info ${:U\$} make: "directive-for-escape.mk" line 57: $ For: loop body with i = ${V}: -# expect: . info ${:U\$} -# expect+9: $ -# expect: . info ${:U${V}} -# expect+7: value -# expect: . info ${:U${V:=-with-modifier}} -# expect+5: value-with-modifier -# expect: . info ${:U$(V)} -# expect+3: value -# expect: . info ${:U$(V:=-with-modifier)} -# expect+1: value-with-modifier . info ${:U${V}} make: "directive-for-escape.mk" line 57: value For: loop body with i = ${V:=-with-modifier}: -# expect: . info ${:U\$} -# expect+9: $ -# expect: . info ${:U${V}} -# expect+7: value -# expect: . info ${:U${V:=-with-modifier}} -# expect+5: value-with-modifier -# expect: . info ${:U$(V)} -# expect+3: value -# expect: . info ${:U$(V:=-with-modifier)} -# expect+1: value-with-modifier . info ${:U${V:=-with-modifier}} make: "directive-for-escape.mk" line 57: value-with-modifier For: loop body with i = $(V): -# expect: . info ${:U\$} -# expect+9: $ -# expect: . info ${:U${V}} -# expect+7: value -# expect: . info ${:U${V:=-with-modifier}} -# expect+5: value-with-modifier -# expect: . info ${:U$(V)} -# expect+3: value -# expect: . info ${:U$(V:=-with-modifier)} -# expect+1: value-with-modifier . info ${:U$(V)} make: "directive-for-escape.mk" line 57: value For: loop body with i = $(V:=-with-modifier): -# expect: . info ${:U\$} -# expect+9: $ -# expect: . info ${:U${V}} -# expect+7: value -# expect: . info ${:U${V:=-with-modifier}} -# expect+5: value-with-modifier -# expect: . info ${:U$(V)} -# expect+3: value -# expect: . info ${:U$(V:=-with-modifier)} -# expect+1: value-with-modifier . info ${:U$(V:=-with-modifier)} make: "directive-for-escape.mk" line 57: value-with-modifier For: end for 1 For: loop body with i = $: -# expect: . info ${:U\$} -# expect+6: $ -# expect: . info ${:U${V}} -# expect+4: value -# expect+3: value-with-modifier -# expect+2: value -# expect+1: value-with-modifier . info ${:U\$} make: "directive-for-escape.mk" line 69: $ For: loop body with i = ${V}: -# expect: . info ${:U\$} -# expect+6: $ -# expect: . info ${:U${V}} -# expect+4: value -# expect+3: value-with-modifier -# expect+2: value -# expect+1: value-with-modifier . info ${:U${V}} make: "directive-for-escape.mk" line 69: value For: l
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sun Jul 7 11:20:10 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: directive-for-escape.exp directive-for-escape.mk Log Message: tests/make: remove '# expect' lines from .exp file These lines are only supposed to occur in .mk files. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 \ src/usr.bin/make/unit-tests/directive-for-escape.exp cvs rdiff -u -r1.27 -r1.28 \ src/usr.bin/make/unit-tests/directive-for-escape.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: Sun Jul 7 09:54:13 UTC 2024 Modified Files: src/usr.bin/make: main.c make.h targ.c var.c Log Message: make: move initialization of variable scopes to targ.c The variable scopes are freed by Targ_End, so initialize them there as well. Separate printing statistics and freeing memory, which makes Var_End unnecessary. To generate a diff of this commit: cvs rdiff -u -r1.629 -r1.630 src/usr.bin/make/main.c cvs rdiff -u -r1.341 -r1.342 src/usr.bin/make/make.h cvs rdiff -u -r1.183 -r1.184 src/usr.bin/make/targ.c cvs rdiff -u -r1.1133 -r1.1134 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.629 src/usr.bin/make/main.c:1.630 --- src/usr.bin/make/main.c:1.629 Sun Jul 7 07:50:57 2024 +++ src/usr.bin/make/main.c Sun Jul 7 09:54:12 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.629 2024/07/07 07:50:57 rillig Exp $ */ +/* $NetBSD: main.c,v 1.630 2024/07/07 09:54:12 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -111,7 +111,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.629 2024/07/07 07:50:57 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.630 2024/07/07 09:54:12 rillig Exp $"); #if defined(MAKE_NATIVE) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -1342,7 +1342,6 @@ main_Init(int argc, char **argv) /* Just in case MAKEOBJDIR wants us to do something tricky. */ Targ_Init(); - Var_Init(); Global_Set_ReadOnly(".MAKE.OS", utsname.sysname); Global_Set("MACHINE", machine); Global_Set("MACHINE_ARCH", machine_arch); @@ -1581,15 +1580,15 @@ main_CleanUp(void) if (opts.enterFlag) printf("%s: Leaving directory `%s'\n", progname, curdir); + Var_Stats(); + Targ_Stats(); + #ifdef USE_META meta_finish(); #endif #ifdef CLEANUP Suff_End(); -#endif - Var_End(); Targ_End(); -#ifdef CLEANUP Arch_End(); Parse_End(); Dir_End(); Index: src/usr.bin/make/make.h diff -u src/usr.bin/make/make.h:1.341 src/usr.bin/make/make.h:1.342 --- src/usr.bin/make/make.h:1.341 Sun Jul 7 07:50:57 2024 +++ src/usr.bin/make/make.h Sun Jul 7 09:54:12 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.341 2024/07/07 07:50:57 rillig Exp $ */ +/* $NetBSD: make.h,v 1.342 2024/07/07 09:54:12 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -931,8 +931,6 @@ void Parse_RegisterCommand(char *cmd MAK #endif /* var.c */ -void Var_Init(void); -void Var_End(void); typedef enum VarEvalMode { Index: src/usr.bin/make/targ.c diff -u src/usr.bin/make/targ.c:1.183 src/usr.bin/make/targ.c:1.184 --- src/usr.bin/make/targ.c:1.183 Sat May 25 21:07:48 2024 +++ src/usr.bin/make/targ.c Sun Jul 7 09:54:12 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: targ.c,v 1.183 2024/05/25 21:07:48 rillig Exp $ */ +/* $NetBSD: targ.c,v 1.184 2024/07/07 09:54:12 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -107,7 +107,7 @@ #include "dir.h" /* "@(#)targ.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: targ.c,v 1.183 2024/05/25 21:07:48 rillig Exp $"); +MAKE_RCSID("$NetBSD: targ.c,v 1.184 2024/07/07 09:54:12 rillig Exp $"); /* * All target nodes that appeared on the left-hand side of one of the @@ -126,23 +126,24 @@ void Targ_Init(void) { HashTable_Init(&allTargetsByName); + SCOPE_INTERNAL = GNode_New("Internal"); + SCOPE_GLOBAL = GNode_New("Global"); + SCOPE_CMDLINE = GNode_New("Command"); } +#ifdef CLEANUP void Targ_End(void) { -#ifdef CLEANUP GNodeListNode *ln; -#endif - Targ_Stats(); -#ifdef CLEANUP + Lst_Done(&allTargets); HashTable_Done(&allTargetsByName); for (ln = allNodes.first; ln != NULL; ln = ln->next) GNode_Free(ln->datum); Lst_Done(&allNodes); -#endif } +#endif void Targ_Stats(void) Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.1133 src/usr.bin/make/var.c:1.1134 --- src/usr.bin/make/var.c:1.1133 Fri Jul 5 20:01:52 2024 +++ src/usr.bin/make/var.c Sun Jul 7 09:54:12 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1133 2024/07/05 20:01:52 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1134 2024/07/07 09:54:12 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -76,10 +76,6 @@ * expressions like ${VAR}, ${VAR:Modifiers}, ${${VARNAME}} or ${VAR:${MODS}}. * * Interface: - * Var_Init Initialize this module. - * - * Var_End Clean up the module. - * * Var_Set * Var_SetExpand Set the value of the variable, creating it if * necessary. @@ -132,7 +128,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1133 2024/07/05 20:01:52 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1134 2024/07/07 09:54:12 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -4809,22 +4805,6 @@ Var_Expand(FStr
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Jul 7 09:54:13 UTC 2024 Modified Files: src/usr.bin/make: main.c make.h targ.c var.c Log Message: make: move initialization of variable scopes to targ.c The variable scopes are freed by Targ_End, so initialize them there as well. Separate printing statistics and freeing memory, which makes Var_End unnecessary. To generate a diff of this commit: cvs rdiff -u -r1.629 -r1.630 src/usr.bin/make/main.c cvs rdiff -u -r1.341 -r1.342 src/usr.bin/make/make.h cvs rdiff -u -r1.183 -r1.184 src/usr.bin/make/targ.c cvs rdiff -u -r1.1133 -r1.1134 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
Module Name:src Committed By: rillig Date: Sun Jul 7 09:37:00 UTC 2024 Modified Files: src/usr.bin/make: hash.c hash.h src/usr.bin/make/unit-tests: Makefile opt-debug-hash.exp Log Message: make: don't track hash table chain lengths during lookup The chain lengths are only used for debugging purposes, so avoid the extra cost at each lookup. Instead, calculate the maximum chain length only when it is actually requested in -dh mode. The reported number changes slightly: Before, it was the length of the chain that was actually traversed to find an entry, up to that entry, now it is the length of the largest chain in the table, no matter if it was actually accessed or not. To generate a diff of this commit: cvs rdiff -u -r1.78 -r1.79 src/usr.bin/make/hash.c cvs rdiff -u -r1.50 -r1.51 src/usr.bin/make/hash.h cvs rdiff -u -r1.349 -r1.350 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/opt-debug-hash.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
Module Name:src Committed By: rillig Date: Sun Jul 7 09:37:00 UTC 2024 Modified Files: src/usr.bin/make: hash.c hash.h src/usr.bin/make/unit-tests: Makefile opt-debug-hash.exp Log Message: make: don't track hash table chain lengths during lookup The chain lengths are only used for debugging purposes, so avoid the extra cost at each lookup. Instead, calculate the maximum chain length only when it is actually requested in -dh mode. The reported number changes slightly: Before, it was the length of the chain that was actually traversed to find an entry, up to that entry, now it is the length of the largest chain in the table, no matter if it was actually accessed or not. To generate a diff of this commit: cvs rdiff -u -r1.78 -r1.79 src/usr.bin/make/hash.c cvs rdiff -u -r1.50 -r1.51 src/usr.bin/make/hash.h cvs rdiff -u -r1.349 -r1.350 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/opt-debug-hash.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/hash.c diff -u src/usr.bin/make/hash.c:1.78 src/usr.bin/make/hash.c:1.79 --- src/usr.bin/make/hash.c:1.78 Wed Jun 5 22:06:53 2024 +++ src/usr.bin/make/hash.c Sun Jul 7 09:37:00 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: hash.c,v 1.78 2024/06/05 22:06:53 rillig Exp $ */ +/* $NetBSD: hash.c,v 1.79 2024/07/07 09:37:00 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -74,7 +74,7 @@ #include "make.h" /* "@(#)hash.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: hash.c,v 1.78 2024/06/05 22:06:53 rillig Exp $"); +MAKE_RCSID("$NetBSD: hash.c,v 1.79 2024/07/07 09:37:00 rillig Exp $"); /* * The ratio of # entries to # buckets at which we rebuild the table to @@ -114,7 +114,6 @@ static HashEntry * HashTable_Find(HashTable *t, Substring key, unsigned int h) { HashEntry *he; - unsigned int chainlen = 0; size_t keyLen = Substring_Length(key); #ifdef DEBUG_HASH_LOOKUP @@ -123,16 +122,12 @@ HashTable_Find(HashTable *t, Substring k #endif for (he = t->buckets[h & t->bucketsMask]; he != NULL; he = he->next) { - chainlen++; if (he->hash == h && strncmp(he->key, key.start, keyLen) == 0 && he->key[keyLen] == '\0') break; } - if (chainlen > t->maxchain) - t->maxchain = chainlen; - return he; } @@ -149,7 +144,6 @@ HashTable_Init(HashTable *t) t->bucketsSize = n; t->numEntries = 0; t->bucketsMask = n - 1; - t->maxchain = 0; } /* @@ -205,6 +199,20 @@ HashTable_FindValueBySubstringHash(HashT return he != NULL ? he->value : NULL; } +static unsigned +HashTable_MaxChain(const HashTable *t) +{ + unsigned b, cl, max_cl = 0; + for (b = 0; b < t->bucketsSize; b++) { + const HashEntry *he = t->buckets[b]; + for (cl = 0; he != NULL; he = he->next) + cl++; + if (cl > max_cl) + max_cl = cl; + } + return max_cl; +} + /* * Make the hash table larger. Any bucket numbers from the old table become * invalid; the hash values stay valid though. @@ -238,8 +246,7 @@ HashTable_Enlarge(HashTable *t) t->bucketsMask = newMask; t->buckets = newBuckets; DEBUG4(HASH, "HashTable_Enlarge: %p size=%d entries=%d maxchain=%d\n", - (void *)t, t->bucketsSize, t->numEntries, t->maxchain); - t->maxchain = 0; + (void *)t, t->bucketsSize, t->numEntries, HashTable_MaxChain(t)); } /* @@ -321,8 +328,8 @@ HashIter_Next(HashIter *hi) } void -HashTable_DebugStats(HashTable *t, const char *name) +HashTable_DebugStats(const HashTable *t, const char *name) { - DEBUG4(HASH, "HashTable %s: size=%u numEntries=%u maxchain=%u\n", - name, t->bucketsSize, t->numEntries, t->maxchain); + DEBUG4(HASH, "HashTable \"%s\": size=%u entries=%u maxchain=%u\n", + name, t->bucketsSize, t->numEntries, HashTable_MaxChain(t)); } Index: src/usr.bin/make/hash.h diff -u src/usr.bin/make/hash.h:1.50 src/usr.bin/make/hash.h:1.51 --- src/usr.bin/make/hash.h:1.50 Sat Jun 1 10:10:50 2024 +++ src/usr.bin/make/hash.h Sun Jul 7 09:37:00 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: hash.h,v 1.50 2024/06/01 10:10:50 rillig Exp $ */ +/* $NetBSD: hash.h,v 1.51 2024/07/07 09:37:00 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -92,7 +92,6 @@ typedef struct HashTable { unsigned int bucketsSize; unsigned int numEntries; unsigned int bucketsMask; /* Used to select the bucket for a hash. */ - unsigned int maxchain; /* Maximum length of chain seen. */ } HashTable; /* State of an iteration over all entries in a table. */ @@ -138,7 +137,7 @@ void *HashTable_FindValueBySubstringHash HashEntry *HashTable_CreateEntry(HashTable *, const char *, bool *); void HashTable_Set(HashTable *, const char *, void *); void HashTable_DeleteEntry(HashTable *, HashEntry *); -void HashTable_DebugStats(HashTable *, const char *); +void HashTable_DebugStats(const HashTable *, const char *); b
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Jul 7 07:50:58 UTC 2024 Modified Files: src/usr.bin/make: arch.c dir.c dir.h job.c job.h main.c make.h parse.c str.c str.h suff.c Log Message: make: only generate code for cleanup functions in CLEANUP mode To generate a diff of this commit: cvs rdiff -u -r1.220 -r1.221 src/usr.bin/make/arch.c cvs rdiff -u -r1.294 -r1.295 src/usr.bin/make/dir.c cvs rdiff -u -r1.48 -r1.49 src/usr.bin/make/dir.h cvs rdiff -u -r1.479 -r1.480 src/usr.bin/make/job.c cvs rdiff -u -r1.79 -r1.80 src/usr.bin/make/job.h cvs rdiff -u -r1.628 -r1.629 src/usr.bin/make/main.c cvs rdiff -u -r1.340 -r1.341 src/usr.bin/make/make.h cvs rdiff -u -r1.732 -r1.733 src/usr.bin/make/parse.c cvs rdiff -u -r1.104 -r1.105 src/usr.bin/make/str.c cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/str.h cvs rdiff -u -r1.381 -r1.382 src/usr.bin/make/suff.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/arch.c diff -u src/usr.bin/make/arch.c:1.220 src/usr.bin/make/arch.c:1.221 --- src/usr.bin/make/arch.c:1.220 Fri Jul 5 05:11:25 2024 +++ src/usr.bin/make/arch.c Sun Jul 7 07:50:57 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.220 2024/07/05 05:11:25 rillig Exp $ */ +/* $NetBSD: arch.c,v 1.221 2024/07/07 07:50:57 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -126,7 +126,7 @@ #include "config.h" /* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: arch.c,v 1.220 2024/07/05 05:11:25 rillig Exp $"); +MAKE_RCSID("$NetBSD: arch.c,v 1.221 2024/07/07 07:50:57 rillig Exp $"); typedef struct List ArchList; typedef struct ListNode ArchListNode; @@ -949,18 +949,18 @@ Arch_Init(void) Lst_Init(&archives); } +#ifdef CLEANUP /* Clean up the archives module. */ void Arch_End(void) { -#ifdef CLEANUP ArchListNode *ln; for (ln = archives.first; ln != NULL; ln = ln->next) ArchFree(ln->datum); Lst_Done(&archives); -#endif } +#endif bool Arch_IsLib(GNode *gn) Index: src/usr.bin/make/dir.c diff -u src/usr.bin/make/dir.c:1.294 src/usr.bin/make/dir.c:1.295 --- src/usr.bin/make/dir.c:1.294 Fri May 31 05:50:11 2024 +++ src/usr.bin/make/dir.c Sun Jul 7 07:50:57 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.294 2024/05/31 05:50:11 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.295 2024/07/07 07:50:57 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -132,7 +132,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.294 2024/05/31 05:50:11 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.295 2024/07/07 07:50:57 rillig Exp $"); /* * A search path is a list of CachedDir structures. A CachedDir has in it the @@ -511,13 +511,11 @@ FreeCachedTable(HashTable *tbl) free(hi.entry->value); HashTable_Done(tbl); } -#endif /* Clean up the directories module. */ void Dir_End(void) { -#ifdef CLEANUP CachedDir_Assign(&cur, NULL); CachedDir_Assign(&dot, NULL); CachedDir_Assign(&dotLast, NULL); @@ -525,8 +523,8 @@ Dir_End(void) OpenDirs_Done(&openDirs); FreeCachedTable(&mtimes); FreeCachedTable(&lmtimes); -#endif } +#endif /* * We want ${.PATH} to indicate the order in which we will actually Index: src/usr.bin/make/dir.h diff -u src/usr.bin/make/dir.h:1.48 src/usr.bin/make/dir.h:1.49 --- src/usr.bin/make/dir.h:1.48 Sun May 19 20:09:40 2024 +++ src/usr.bin/make/dir.h Sun Jul 7 07:50:57 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.h,v 1.48 2024/05/19 20:09:40 sjg Exp $ */ +/* $NetBSD: dir.h,v 1.49 2024/07/07 07:50:57 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -80,7 +80,9 @@ typedef struct CachedDir CachedDir; void Dir_Init(void); void Dir_InitCur(const char *); void Dir_InitDot(void); +#ifdef CLEANUP void Dir_End(void); +#endif void Dir_SetPATH(void); void Dir_SetSYSPATH(void); bool Dir_HasWildcards(const char *) MAKE_ATTR_USE; Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.479 src/usr.bin/make/job.c:1.480 --- src/usr.bin/make/job.c:1.479 Fri Jul 5 05:11:25 2024 +++ src/usr.bin/make/job.c Sun Jul 7 07:50:57 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.479 2024/07/05 05:11:25 rillig Exp $ */ +/* $NetBSD: job.c,v 1.480 2024/07/07 07:50:57 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -141,7 +141,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.479 2024/07/05 05:11:25 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.480 2024/07/07 07:50:57 rillig Exp $"); /* * A shell defines how the commands are run. All commands for a target are @@ -2585,14 +2585,14 @@ Job_Finish(void) return job_errors; } +#ifdef CLEANUP /* Clean up any memory used by the jobs module. */ void Job_End(void) { -#ifdef CLEANUP free(shell_freeIt); -#endif } +#endif
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Jul 7 07:50:58 UTC 2024 Modified Files: src/usr.bin/make: arch.c dir.c dir.h job.c job.h main.c make.h parse.c str.c str.h suff.c Log Message: make: only generate code for cleanup functions in CLEANUP mode To generate a diff of this commit: cvs rdiff -u -r1.220 -r1.221 src/usr.bin/make/arch.c cvs rdiff -u -r1.294 -r1.295 src/usr.bin/make/dir.c cvs rdiff -u -r1.48 -r1.49 src/usr.bin/make/dir.h cvs rdiff -u -r1.479 -r1.480 src/usr.bin/make/job.c cvs rdiff -u -r1.79 -r1.80 src/usr.bin/make/job.h cvs rdiff -u -r1.628 -r1.629 src/usr.bin/make/main.c cvs rdiff -u -r1.340 -r1.341 src/usr.bin/make/make.h cvs rdiff -u -r1.732 -r1.733 src/usr.bin/make/parse.c cvs rdiff -u -r1.104 -r1.105 src/usr.bin/make/str.c cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/str.h cvs rdiff -u -r1.381 -r1.382 src/usr.bin/make/suff.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Jul 6 21:35:48 UTC 2024 Modified Files: src/usr.bin/make: main.c Log Message: make: clean up condition when printing an error To generate a diff of this commit: cvs rdiff -u -r1.627 -r1.628 src/usr.bin/make/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.627 src/usr.bin/make/main.c:1.628 --- src/usr.bin/make/main.c:1.627 Fri Jul 5 05:11:25 2024 +++ src/usr.bin/make/main.c Sat Jul 6 21:35:48 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.627 2024/07/05 05:11:25 rillig Exp $ */ +/* $NetBSD: main.c,v 1.628 2024/07/06 21:35:48 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -111,7 +111,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.627 2024/07/05 05:11:25 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.628 2024/07/06 21:35:48 rillig Exp $"); #if defined(MAKE_NATIVE) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -2084,8 +2084,7 @@ PrintOnError(GNode *gn, const char *msg) printf("%s", (const char *)ln->datum); for (ln = ln->next; ln != NULL; ln = ln->next) printf(" %s", (const char *)ln->datum); - } - if (opts.create.first == NULL && mainNode != NULL) + } else printf("%s", mainNode->name); printf("\""); }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Jul 6 21:35:48 UTC 2024 Modified Files: src/usr.bin/make: main.c Log Message: make: clean up condition when printing an error To generate a diff of this commit: cvs rdiff -u -r1.627 -r1.628 src/usr.bin/make/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Jul 6 21:21:10 UTC 2024 Modified Files: src/usr.bin/make: cond.c src/usr.bin/make/unit-tests: cond-func.exp cond-func.mk cond-op-and.exp cond-op-and.mk cond-op-or.exp cond-op-or.mk Log Message: make: error out on conditions containing the operators '&' and '|' These abbreviated variants of the '&&' and '||' operators were never documented, so error out in non-lint mode as well. To generate a diff of this commit: cvs rdiff -u -r1.365 -r1.366 src/usr.bin/make/cond.c cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cond-func.exp \ src/usr.bin/make/unit-tests/cond-op-and.mk cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/cond-func.mk cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cond-op-and.exp cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cond-op-or.exp cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/cond-op-or.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
Module Name:src Committed By: rillig Date: Sat Jul 6 11:09:17 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: varmod-edge.mk Log Message: tests/make: sync a comment with reality To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/usr.bin/make/unit-tests/varmod-edge.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-edge.mk diff -u src/usr.bin/make/unit-tests/varmod-edge.mk:1.27 src/usr.bin/make/unit-tests/varmod-edge.mk:1.28 --- src/usr.bin/make/unit-tests/varmod-edge.mk:1.27 Sat Jul 6 10:36:23 2024 +++ src/usr.bin/make/unit-tests/varmod-edge.mk Sat Jul 6 11:09:17 2024 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-edge.mk,v 1.27 2024/07/06 10:36:23 rillig Exp $ +# $NetBSD: varmod-edge.mk,v 1.28 2024/07/06 11:09:17 rillig Exp $ # # Tests for edge cases in variable modifiers. # @@ -74,8 +74,8 @@ EXP= [ . warning expected "${EXP}", got "${MOD}" .endif + # The pattern in the nested variable has an unclosed character class. -# No error is reported though, and the pattern is closed implicitly. # # Before str.c 1.104 from 2024-07-06, no error was reported. #
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sat Jul 6 11:09:17 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: varmod-edge.mk Log Message: tests/make: sync a comment with reality To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/usr.bin/make/unit-tests/varmod-edge.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 Jul 6 10:36:23 UTC 2024 Modified Files: src/usr.bin/make: str.c src/usr.bin/make/unit-tests: varmod-edge.exp varmod-edge.mk Log Message: make: error out on a matching malformed matching pattern '[[' To generate a diff of this commit: cvs rdiff -u -r1.103 -r1.104 src/usr.bin/make/str.c cvs rdiff -u -r1.24 -r1.25 src/usr.bin/make/unit-tests/varmod-edge.exp cvs rdiff -u -r1.26 -r1.27 src/usr.bin/make/unit-tests/varmod-edge.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 Jul 6 10:36:23 UTC 2024 Modified Files: src/usr.bin/make: str.c src/usr.bin/make/unit-tests: varmod-edge.exp varmod-edge.mk Log Message: make: error out on a matching malformed matching pattern '[[' To generate a diff of this commit: cvs rdiff -u -r1.103 -r1.104 src/usr.bin/make/str.c cvs rdiff -u -r1.24 -r1.25 src/usr.bin/make/unit-tests/varmod-edge.exp cvs rdiff -u -r1.26 -r1.27 src/usr.bin/make/unit-tests/varmod-edge.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/str.c diff -u src/usr.bin/make/str.c:1.103 src/usr.bin/make/str.c:1.104 --- src/usr.bin/make/str.c:1.103 Sun Apr 14 15:21:20 2024 +++ src/usr.bin/make/str.c Sat Jul 6 10:36:23 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: str.c,v 1.103 2024/04/14 15:21:20 rillig Exp $ */ +/* $NetBSD: str.c,v 1.104 2024/07/06 10:36:23 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -71,7 +71,7 @@ #include "make.h" /* "@(#)str.c 5.8 (Berkeley) 6/1/90" */ -MAKE_RCSID("$NetBSD: str.c,v 1.103 2024/04/14 15:21:20 rillig Exp $"); +MAKE_RCSID("$NetBSD: str.c,v 1.104 2024/07/06 10:36:23 rillig Exp $"); static HashTable interned_strings; @@ -356,8 +356,10 @@ match_fixed_length: goto no_match; while (*pat != ']' && *pat != '\0') pat++; - if (*pat == '\0') + if (*pat == '\0') { +res.error = "Unfinished character list"; pat--; + } continue; } Index: src/usr.bin/make/unit-tests/varmod-edge.exp diff -u src/usr.bin/make/unit-tests/varmod-edge.exp:1.24 src/usr.bin/make/unit-tests/varmod-edge.exp:1.25 --- src/usr.bin/make/unit-tests/varmod-edge.exp:1.24 Sat Jul 6 10:14:35 2024 +++ src/usr.bin/make/unit-tests/varmod-edge.exp Sat Jul 6 10:36:23 2024 @@ -1,4 +1,5 @@ make: "varmod-edge.mk" line 60: while evaluating variable "MOD" with value "${INP:M${:U*)}}": while evaluating variable "INP" with value "(parentheses)": while evaluating "${:U*)" with value "*)": Unclosed expression, expecting '}' for modifier "U*)" +make: "varmod-edge.mk" line 88: warning: while evaluating variable "MOD" with value "${INP:M${:U[[}}": while evaluating variable "INP" with value "[ [[ [[[": Unfinished character list in pattern '[[' of modifier ':M' make: "varmod-edge.mk" line 178: while evaluating variable "MOD" with value "${INP:a\=b}": while evaluating variable "INP" with value "file.c file...": Unfinished modifier ('=' missing) make: "varmod-edge.mk" line 194: while evaluating variable "MOD" with value "${INP}": while evaluating variable "INP" with value "value": Unknown modifier ":" make: "varmod-edge.mk" line 194: while evaluating variable "MOD" with value "${INP}": while evaluating variable "INP" with value "": Unknown modifier ":" Index: src/usr.bin/make/unit-tests/varmod-edge.mk diff -u src/usr.bin/make/unit-tests/varmod-edge.mk:1.26 src/usr.bin/make/unit-tests/varmod-edge.mk:1.27 --- src/usr.bin/make/unit-tests/varmod-edge.mk:1.26 Sat Jul 6 10:14:35 2024 +++ src/usr.bin/make/unit-tests/varmod-edge.mk Sat Jul 6 10:36:23 2024 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-edge.mk,v 1.26 2024/07/06 10:14:35 rillig Exp $ +# $NetBSD: varmod-edge.mk,v 1.27 2024/07/06 10:36:23 rillig Exp $ # # Tests for edge cases in variable modifiers. # @@ -77,14 +77,14 @@ EXP= [ # The pattern in the nested variable has an unclosed character class. # No error is reported though, and the pattern is closed implicitly. # -# XXX: It is unexpected that no error is reported. -# See str.c, function Str_Match. +# Before str.c 1.104 from 2024-07-06, no error was reported. # # Before 2019-12-02, this test case triggered an out-of-bounds read # in Str_Match. INP= [ [[ [[[ MOD= ${INP:M${:U[[}} EXP= [ +# expect+1: warning: while evaluating variable "MOD" with value "${INP:M${:U[[}}": while evaluating variable "INP" with value "[ [[ [[[": Unfinished character list in pattern '[[' of modifier ':M' .if ${MOD} != ${EXP} . warning expected "${EXP}", got "${MOD}" .endif
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sat Jul 6 10:14:35 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: deptgt.exp deptgt.mk directive-for-errors.exp directive-for-errors.mk directive-for-escape.exp directive-for-escape.mk directive-for.exp directive-for.mk varmod-edge.exp varmod-edge.mk Log Message: tests/make: clean up tests Prefer "expect+X" directives to be above the code generating them, instead of "expect-X" directives below the code. In varmod-edge.mk, separate the tests, as the common loop does not pull its weight. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/deptgt.exp cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/deptgt.mk cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/directive-for-errors.exp cvs rdiff -u -r1.12 -r1.13 \ src/usr.bin/make/unit-tests/directive-for-errors.mk cvs rdiff -u -r1.28 -r1.29 \ src/usr.bin/make/unit-tests/directive-for-escape.exp cvs rdiff -u -r1.26 -r1.27 \ src/usr.bin/make/unit-tests/directive-for-escape.mk \ src/usr.bin/make/unit-tests/directive-for.mk cvs rdiff -u -r1.24 -r1.25 src/usr.bin/make/unit-tests/directive-for.exp cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/varmod-edge.exp cvs rdiff -u -r1.25 -r1.26 src/usr.bin/make/unit-tests/varmod-edge.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/deptgt.exp diff -u src/usr.bin/make/unit-tests/deptgt.exp:1.16 src/usr.bin/make/unit-tests/deptgt.exp:1.17 --- src/usr.bin/make/unit-tests/deptgt.exp:1.16 Fri Jul 5 20:01:52 2024 +++ src/usr.bin/make/unit-tests/deptgt.exp Sat Jul 6 10:14:35 2024 @@ -8,6 +8,7 @@ ParseDependency(: empty-source) Parsing line 39: : command for empty targets list Parsing line 40: .MAKEFLAGS: -d0 ParseDependency(.MAKEFLAGS: -d0) +make: "deptgt.mk" line 45: while evaluating "${:U:Z}:" with value "": Unknown modifier "Z" make: "deptgt.mk" line 49: while parsing "${:U:Z}:": Unknown modifier "Z" make: "deptgt.mk" line 52: warning: Extra target 'ordinary' ignored make: "deptgt.mk" line 55: warning: Extra target (ordinary) ignored Index: src/usr.bin/make/unit-tests/deptgt.mk diff -u src/usr.bin/make/unit-tests/deptgt.mk:1.19 src/usr.bin/make/unit-tests/deptgt.mk:1.20 --- src/usr.bin/make/unit-tests/deptgt.mk:1.19 Fri Jul 5 20:01:52 2024 +++ src/usr.bin/make/unit-tests/deptgt.mk Sat Jul 6 10:14:35 2024 @@ -1,4 +1,4 @@ -# $NetBSD: deptgt.mk,v 1.19 2024/07/05 20:01:52 rillig Exp $ +# $NetBSD: deptgt.mk,v 1.20 2024/07/06 10:14:35 rillig Exp $ # # Tests for special targets like .BEGIN or .SUFFIXES in dependency # declarations. @@ -39,14 +39,14 @@ ${:U}: empty-source : command for empty targets list .MAKEFLAGS: -d0 -# Just to show that a malformed expression is only expanded once in -# ParseDependencyTargetWord. The only way to produce an expression that -# is well-formed on the first expansion and ill-formed on the second -# expansion would be to use the variable modifier '::=' to modify the -# targets. This in turn would be such an extreme and unreliable edge case -# that nobody uses it. +# In a dependency declaration, the whole line is expanded before interpreting +# the line. +# expect+1: while evaluating "${:U:Z}:" with value "": Unknown modifier "Z" +${:U:Z}: +# After expanding the line as a whole, each target is parsed but not +# evaluated, separately, in ParseDependencyTargetWord. # expect+1: while parsing "${:U:Z}:": Unknown modifier "Z" -{:U:Z}: +$${:U:Z}: # expect+1: warning: Extra target 'ordinary' ignored .END ordinary: @@ -56,6 +56,3 @@ {:U:Z}: # expect+1: warning: Special and mundane targets don't mix. Mundane ones ignored ordinary .PATH: - -all: - @:; Index: src/usr.bin/make/unit-tests/directive-for-errors.exp diff -u src/usr.bin/make/unit-tests/directive-for-errors.exp:1.7 src/usr.bin/make/unit-tests/directive-for-errors.exp:1.8 --- src/usr.bin/make/unit-tests/directive-for-errors.exp:1.7 Fri Jul 5 19:47:22 2024 +++ src/usr.bin/make/unit-tests/directive-for-errors.exp Sat Jul 6 10:14:35 2024 @@ -1,17 +1,17 @@ make: "directive-for-errors.mk" line 9: Unknown directive "fori" -make: "directive-for-errors.mk" line 10: warning: <> -make: "directive-for-errors.mk" line 11: for-less endfor +make: "directive-for-errors.mk" line 11: warning: <> +make: "directive-for-errors.mk" line 13: for-less endfor make: "directive-for-errors.mk" line 25: Unknown directive "for" -make: "directive-for-errors.mk" line 26: warning: <> -make: "directive-for-errors.mk" line 27: for-less endfor +make: "directive-for-errors.mk" line 27: warning: <> +make: "directive-for-errors.mk" line 29: for-less endfor make: "directive-for-errors.mk" line 44: invalid character '$' in .for loop variable name make: "directive-for-errors.mk" line 52: no iteration variables in for make: "directive-for-errors.
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sat Jul 6 10:14:35 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: deptgt.exp deptgt.mk directive-for-errors.exp directive-for-errors.mk directive-for-escape.exp directive-for-escape.mk directive-for.exp directive-for.mk varmod-edge.exp varmod-edge.mk Log Message: tests/make: clean up tests Prefer "expect+X" directives to be above the code generating them, instead of "expect-X" directives below the code. In varmod-edge.mk, separate the tests, as the common loop does not pull its weight. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/deptgt.exp cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/deptgt.mk cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/directive-for-errors.exp cvs rdiff -u -r1.12 -r1.13 \ src/usr.bin/make/unit-tests/directive-for-errors.mk cvs rdiff -u -r1.28 -r1.29 \ src/usr.bin/make/unit-tests/directive-for-escape.exp cvs rdiff -u -r1.26 -r1.27 \ src/usr.bin/make/unit-tests/directive-for-escape.mk \ src/usr.bin/make/unit-tests/directive-for.mk cvs rdiff -u -r1.24 -r1.25 src/usr.bin/make/unit-tests/directive-for.exp cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/varmod-edge.exp cvs rdiff -u -r1.25 -r1.26 src/usr.bin/make/unit-tests/varmod-edge.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: Fri Jul 5 20:01:53 UTC 2024 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: deptgt.exp deptgt.mk var-eval-short.exp var-eval-short.mk varmod-ifelse.exp varmod-ifelse.mk Log Message: make: in error messages, distinguish parsing from evaluating To generate a diff of this commit: cvs rdiff -u -r1.1132 -r1.1133 src/usr.bin/make/var.c cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/deptgt.exp cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/deptgt.mk cvs rdiff -u -r1.28 -r1.29 src/usr.bin/make/unit-tests/var-eval-short.exp cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/var-eval-short.mk cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/varmod-ifelse.exp cvs rdiff -u -r1.31 -r1.32 src/usr.bin/make/unit-tests/varmod-ifelse.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: Fri Jul 5 19:47:22 UTC 2024 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: cond-token-string.exp cond-token-string.mk deptgt.exp deptgt.mk directive-for-errors.exp directive-for-errors.mk directive-for-escape.exp directive-for-escape.mk directive-for.exp directive-for.mk directive-include.exp directive-include.mk moderrs.exp moderrs.mk var-eval-short.exp var-eval-short.mk vardebug.exp vardebug.mk varmod-assign.exp varmod-edge.exp varmod-edge.mk varmod-gmtime.exp varmod-gmtime.mk varmod-ifelse.exp varmod-ifelse.mk varmod-localtime.exp varmod-localtime.mk varmod-loop-delete.exp varmod-loop-delete.mk varmod-loop-varname.exp varmod-loop-varname.mk varmod-match-escape.exp varmod-match-escape.mk varmod-range.exp varmod-range.mk varmod-shell.exp varmod-shell.mk varmod-subst-regex.exp varmod-subst.exp varmod-to-separator.exp varmod-to-separator.mk varmod.exp varmod.mk varparse-errors.exp varparse-errors.mk Log Message: make: in error messages for anonymous variables, log the value To generate a diff of this commit: cvs rdiff -u -r1.1131 -r1.1132 src/usr.bin/make/var.c cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/cond-token-string.exp \ src/usr.bin/make/unit-tests/directive-include.exp \ src/usr.bin/make/unit-tests/varparse-errors.exp cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cond-token-string.mk \ src/usr.bin/make/unit-tests/vardebug.mk cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/deptgt.exp \ src/usr.bin/make/unit-tests/directive-include.mk \ src/usr.bin/make/unit-tests/varmod-range.exp \ src/usr.bin/make/unit-tests/varmod.exp cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/deptgt.mk \ src/usr.bin/make/unit-tests/varmod-to-separator.mk \ src/usr.bin/make/unit-tests/varmod.mk cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/directive-for-errors.exp \ src/usr.bin/make/unit-tests/varmod-loop-delete.exp cvs rdiff -u -r1.11 -r1.12 \ src/usr.bin/make/unit-tests/directive-for-errors.mk cvs rdiff -u -r1.27 -r1.28 \ src/usr.bin/make/unit-tests/directive-for-escape.exp \ src/usr.bin/make/unit-tests/var-eval-short.exp cvs rdiff -u -r1.25 -r1.26 \ src/usr.bin/make/unit-tests/directive-for-escape.mk \ src/usr.bin/make/unit-tests/directive-for.mk \ src/usr.bin/make/unit-tests/varmod-assign.exp cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/directive-for.exp \ src/usr.bin/make/unit-tests/varmod-gmtime.mk cvs rdiff -u -r1.40 -r1.41 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.37 -r1.38 src/usr.bin/make/unit-tests/moderrs.mk cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/var-eval-short.mk \ src/usr.bin/make/unit-tests/varmod-range.mk cvs rdiff -u -r1.35 -r1.36 src/usr.bin/make/unit-tests/vardebug.exp cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/varmod-edge.exp \ src/usr.bin/make/unit-tests/varmod-match-escape.exp cvs rdiff -u -r1.24 -r1.25 src/usr.bin/make/unit-tests/varmod-edge.mk cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/varmod-gmtime.exp cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/varmod-ifelse.exp cvs rdiff -u -r1.30 -r1.31 src/usr.bin/make/unit-tests/varmod-ifelse.mk cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varmod-localtime.exp \ src/usr.bin/make/unit-tests/varmod-localtime.mk \ src/usr.bin/make/unit-tests/varparse-errors.mk cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-loop-delete.mk \ src/usr.bin/make/unit-tests/varmod-subst.exp cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/varmod-loop-varname.exp \ src/usr.bin/make/unit-tests/varmod-shell.mk \ src/usr.bin/make/unit-tests/varmod-subst-regex.exp cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-loop-varname.mk cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/varmod-match-escape.mk \ src/usr.bin/make/unit-tests/varmod-to-separator.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-shell.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.1131 src/usr.bin/make/var.c:1.1132 --- src/usr.bin/make/var.c:1.1131 Fri Jul 5 18:59:33 2024 +++ src/usr.bin/make/var.c Fri Jul 5 19:47:22 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1131 2024/07/05 18:59:33 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1132 2024/07/05 19:47:22 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -132,7 +132,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1131 2024/07/05 18:59:33 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1132 2024/07/05 19:47:22 rillig Exp $"); /* *
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Jul 5 19:47:22 UTC 2024 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: cond-token-string.exp cond-token-string.mk deptgt.exp deptgt.mk directive-for-errors.exp directive-for-errors.mk directive-for-escape.exp directive-for-escape.mk directive-for.exp directive-for.mk directive-include.exp directive-include.mk moderrs.exp moderrs.mk var-eval-short.exp var-eval-short.mk vardebug.exp vardebug.mk varmod-assign.exp varmod-edge.exp varmod-edge.mk varmod-gmtime.exp varmod-gmtime.mk varmod-ifelse.exp varmod-ifelse.mk varmod-localtime.exp varmod-localtime.mk varmod-loop-delete.exp varmod-loop-delete.mk varmod-loop-varname.exp varmod-loop-varname.mk varmod-match-escape.exp varmod-match-escape.mk varmod-range.exp varmod-range.mk varmod-shell.exp varmod-shell.mk varmod-subst-regex.exp varmod-subst.exp varmod-to-separator.exp varmod-to-separator.mk varmod.exp varmod.mk varparse-errors.exp varparse-errors.mk Log Message: make: in error messages for anonymous variables, log the value To generate a diff of this commit: cvs rdiff -u -r1.1131 -r1.1132 src/usr.bin/make/var.c cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/cond-token-string.exp \ src/usr.bin/make/unit-tests/directive-include.exp \ src/usr.bin/make/unit-tests/varparse-errors.exp cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cond-token-string.mk \ src/usr.bin/make/unit-tests/vardebug.mk cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/deptgt.exp \ src/usr.bin/make/unit-tests/directive-include.mk \ src/usr.bin/make/unit-tests/varmod-range.exp \ src/usr.bin/make/unit-tests/varmod.exp cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/deptgt.mk \ src/usr.bin/make/unit-tests/varmod-to-separator.mk \ src/usr.bin/make/unit-tests/varmod.mk cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/directive-for-errors.exp \ src/usr.bin/make/unit-tests/varmod-loop-delete.exp cvs rdiff -u -r1.11 -r1.12 \ src/usr.bin/make/unit-tests/directive-for-errors.mk cvs rdiff -u -r1.27 -r1.28 \ src/usr.bin/make/unit-tests/directive-for-escape.exp \ src/usr.bin/make/unit-tests/var-eval-short.exp cvs rdiff -u -r1.25 -r1.26 \ src/usr.bin/make/unit-tests/directive-for-escape.mk \ src/usr.bin/make/unit-tests/directive-for.mk \ src/usr.bin/make/unit-tests/varmod-assign.exp cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/directive-for.exp \ src/usr.bin/make/unit-tests/varmod-gmtime.mk cvs rdiff -u -r1.40 -r1.41 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.37 -r1.38 src/usr.bin/make/unit-tests/moderrs.mk cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/var-eval-short.mk \ src/usr.bin/make/unit-tests/varmod-range.mk cvs rdiff -u -r1.35 -r1.36 src/usr.bin/make/unit-tests/vardebug.exp cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/varmod-edge.exp \ src/usr.bin/make/unit-tests/varmod-match-escape.exp cvs rdiff -u -r1.24 -r1.25 src/usr.bin/make/unit-tests/varmod-edge.mk cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/varmod-gmtime.exp cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/varmod-ifelse.exp cvs rdiff -u -r1.30 -r1.31 src/usr.bin/make/unit-tests/varmod-ifelse.mk cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varmod-localtime.exp \ src/usr.bin/make/unit-tests/varmod-localtime.mk \ src/usr.bin/make/unit-tests/varparse-errors.mk cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-loop-delete.mk \ src/usr.bin/make/unit-tests/varmod-subst.exp cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/varmod-loop-varname.exp \ src/usr.bin/make/unit-tests/varmod-shell.mk \ src/usr.bin/make/unit-tests/varmod-subst-regex.exp cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-loop-varname.mk cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/varmod-match-escape.mk \ src/usr.bin/make/unit-tests/varmod-to-separator.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-shell.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Jul 5 18:59:33 UTC 2024 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: cmd-errors-jobs.exp cmd-errors-jobs.mk cmd-errors-lint.exp cmd-errors-lint.mk cmd-errors.exp cmd-errors.mk directive-for-escape.exp directive-for-escape.mk moderrs.exp moderrs.mk varmisc.exp varmisc.mk varmod-edge.exp varmod-edge.mk varmod-order.exp varmod-order.mk varparse-errors.exp varparse-errors.mk Log Message: make: error out on unclosed expressions during parse time In exchange, this adds location information. For unnamed expressions, the value is no longer printed. This will be added back in a follow-up commit. To generate a diff of this commit: cvs rdiff -u -r1.1130 -r1.1131 src/usr.bin/make/var.c cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp \ src/usr.bin/make/unit-tests/cmd-errors-lint.exp \ src/usr.bin/make/unit-tests/cmd-errors.mk cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cmd-errors-jobs.mk cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cmd-errors-lint.mk cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cmd-errors.exp cvs rdiff -u -r1.26 -r1.27 \ src/usr.bin/make/unit-tests/directive-for-escape.exp cvs rdiff -u -r1.24 -r1.25 \ src/usr.bin/make/unit-tests/directive-for-escape.mk cvs rdiff -u -r1.39 -r1.40 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.36 -r1.37 src/usr.bin/make/unit-tests/moderrs.mk cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/varmisc.exp \ src/usr.bin/make/unit-tests/varmod-edge.exp cvs rdiff -u -r1.34 -r1.35 src/usr.bin/make/unit-tests/varmisc.mk cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/varmod-edge.mk cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/varmod-order.exp \ src/usr.bin/make/unit-tests/varparse-errors.exp cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-order.mk cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/varparse-errors.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.1130 src/usr.bin/make/var.c:1.1131 --- src/usr.bin/make/var.c:1.1130 Fri Jul 5 05:11:25 2024 +++ src/usr.bin/make/var.c Fri Jul 5 18:59:33 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1130 2024/07/05 05:11:25 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1131 2024/07/05 18:59:33 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -132,7 +132,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1130 2024/07/05 05:11:25 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1131 2024/07/05 18:59:33 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -3964,9 +3964,10 @@ ApplyModifiersIndirect(ModChain *ch, con if (*p == ':') p++; else if (*p == '\0' && ch->endc != '\0') { - Error("Unclosed expression after indirect modifier, " - "expecting '%c' for variable \"%s\"", - ch->endc, expr->name); + Parse_Error(PARSE_FATAL, + "Unclosed expression after indirect modifier, " + "expecting '%c'", + ch->endc); *pp = p; return AMIR_OUT; } @@ -4014,12 +4015,10 @@ ApplySingleModifier(const char **pp, Mod LogAfterApply(ch, p, mod); if (*p == '\0' && ch->endc != '\0') { - Error( + Parse_Error(PARSE_FATAL, "Unclosed expression, expecting '%c' for " - "modifier \"%.*s\" of variable \"%s\" with value \"%s\"", - ch->endc, - (int)(p - mod), mod, - ch->expr->name, Expr_Str(ch->expr)); + "modifier \"%.*s\"", + ch->endc, (int)(p - mod), mod); } else if (*p == ':') { p++; } else if (opts.strict && *p != '\0' && *p != ch->endc) { @@ -4072,9 +4071,8 @@ ApplyModifiers( p = *pp; if (*p == '\0' && endc != '\0') { - Error( - "Unclosed expression, expecting '%c' for \"%s\"", - ch.endc, expr->name); + Parse_Error(PARSE_FATAL, + "Unclosed expression, expecting '%c'", ch.endc); goto cleanup; } Index: src/usr.bin/make/unit-tests/cmd-errors-jobs.exp diff -u src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.7 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.8 --- src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.7 Thu Jul 4 17:47:54 2024 +++ src/usr.bin/make/unit-tests/cmd-errors-jobs.exp Fri Jul 5 18:59:33 2024 @@ -1,7 +1,7 @@ : undefined--eol make: in target "unclosed-expression": Unclosed variable "UNCLOSED" : unclosed-expression- -make: Unclosed expression, expecting '}' for "UNCLOSED" +make: in target "unclosed-modifier": while evaluating variable "UNCLOSED" with value "": Unclosed expression, expecting '}' : unclosed-modifier- make: in target "unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z" : unknown-modifier--eol Index: src/usr.bin/make/unit-tests/
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Jul 5 18:59:33 UTC 2024 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: cmd-errors-jobs.exp cmd-errors-jobs.mk cmd-errors-lint.exp cmd-errors-lint.mk cmd-errors.exp cmd-errors.mk directive-for-escape.exp directive-for-escape.mk moderrs.exp moderrs.mk varmisc.exp varmisc.mk varmod-edge.exp varmod-edge.mk varmod-order.exp varmod-order.mk varparse-errors.exp varparse-errors.mk Log Message: make: error out on unclosed expressions during parse time In exchange, this adds location information. For unnamed expressions, the value is no longer printed. This will be added back in a follow-up commit. To generate a diff of this commit: cvs rdiff -u -r1.1130 -r1.1131 src/usr.bin/make/var.c cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp \ src/usr.bin/make/unit-tests/cmd-errors-lint.exp \ src/usr.bin/make/unit-tests/cmd-errors.mk cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cmd-errors-jobs.mk cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cmd-errors-lint.mk cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cmd-errors.exp cvs rdiff -u -r1.26 -r1.27 \ src/usr.bin/make/unit-tests/directive-for-escape.exp cvs rdiff -u -r1.24 -r1.25 \ src/usr.bin/make/unit-tests/directive-for-escape.mk cvs rdiff -u -r1.39 -r1.40 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.36 -r1.37 src/usr.bin/make/unit-tests/moderrs.mk cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/varmisc.exp \ src/usr.bin/make/unit-tests/varmod-edge.exp cvs rdiff -u -r1.34 -r1.35 src/usr.bin/make/unit-tests/varmisc.mk cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/varmod-edge.mk cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/varmod-order.exp \ src/usr.bin/make/unit-tests/varparse-errors.exp cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-order.mk cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/varparse-errors.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
Module Name:src Committed By: rillig Date: Fri Jul 5 17:41:50 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: cmd-errors-jobs.mk cmd-errors-lint.mk cmd-errors.mk directive-for-escape.exp directive-for-escape.mk moderrs.mk varmisc.mk varmod-edge.exp varmod-edge.mk varmod-order.exp varmod-order.mk varparse-errors.mk Log Message: tests/make: add expected messages for "Unclosed expression" To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cmd-errors-jobs.mk cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cmd-errors-lint.mk cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cmd-errors.mk cvs rdiff -u -r1.25 -r1.26 \ src/usr.bin/make/unit-tests/directive-for-escape.exp cvs rdiff -u -r1.23 -r1.24 \ src/usr.bin/make/unit-tests/directive-for-escape.mk cvs rdiff -u -r1.35 -r1.36 src/usr.bin/make/unit-tests/moderrs.mk cvs rdiff -u -r1.33 -r1.34 src/usr.bin/make/unit-tests/varmisc.mk cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/varmod-edge.exp cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/varmod-edge.mk cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/varmod-order.exp cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/varmod-order.mk cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/varparse-errors.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/cmd-errors-jobs.mk diff -u src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.5 src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.6 --- src/usr.bin/make/unit-tests/cmd-errors-jobs.mk:1.5 Thu Jul 4 17:47:54 2024 +++ src/usr.bin/make/unit-tests/cmd-errors-jobs.mk Fri Jul 5 17:41:50 2024 @@ -1,4 +1,4 @@ -# $NetBSD: cmd-errors-jobs.mk,v 1.5 2024/07/04 17:47:54 rillig Exp $ +# $NetBSD: cmd-errors-jobs.mk,v 1.6 2024/07/05 17:41:50 rillig Exp $ # # Demonstrate how errors in expressions affect whether the commands # are actually executed in jobs mode. @@ -13,22 +13,22 @@ all: undefined unclosed-expression unclo undefined: : $@-${UNDEFINED}-eol -# XXX: This command is executed even though it contains parse errors. +unclosed-expression: # expect: make: in target "unclosed-expression": Unclosed variable "UNCLOSED" +# XXX: This command is executed even though it contains parse errors. # expect: : unclosed-expression- -unclosed-expression: : $@-${UNCLOSED -# XXX: This command is executed even though it contains parse errors. +unclosed-modifier: # expect: make: Unclosed expression, expecting '}' for "UNCLOSED" +# XXX: This command is executed even though it contains parse errors. # expect: : unclosed-modifier- -unclosed-modifier: : $@-${UNCLOSED: -# XXX: This command is executed even though it contains parse errors. +unknown-modifier: # expect: make: in target "unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z" +# XXX: This command is executed even though it contains parse errors. # expect: : unknown-modifier--eol -unknown-modifier: : $@-${UNKNOWN:Z}-eol # expect: : end-eol Index: src/usr.bin/make/unit-tests/cmd-errors-lint.mk diff -u src/usr.bin/make/unit-tests/cmd-errors-lint.mk:1.2 src/usr.bin/make/unit-tests/cmd-errors-lint.mk:1.3 --- src/usr.bin/make/unit-tests/cmd-errors-lint.mk:1.2 Tue Apr 23 22:51:28 2024 +++ src/usr.bin/make/unit-tests/cmd-errors-lint.mk Fri Jul 5 17:41:50 2024 @@ -1,4 +1,4 @@ -# $NetBSD: cmd-errors-lint.mk,v 1.2 2024/04/23 22:51:28 rillig Exp $ +# $NetBSD: cmd-errors-lint.mk,v 1.3 2024/07/05 17:41:50 rillig Exp $ # # Demonstrate how errors in expressions affect whether the commands # are actually executed. @@ -10,24 +10,29 @@ all: undefined unclosed-expression unclo # Undefined variables in expressions are not an error. They expand to empty # strings. undefined: +# expect: : undefined : $@ ${UNDEFINED} -# XXX: As of 2020-11-01, this obvious syntax error is not detected. -# XXX: As of 2020-11-01, this command is executed even though it contains -# parse errors. unclosed-expression: +# expect: make: in target "unclosed-expression": Unclosed variable "UNCLOSED" +# XXX: This command is executed even though it contains parse errors. +# expect: : unclosed-expression : $@ ${UNCLOSED -# XXX: As of 2020-11-01, this obvious syntax error is not detected. -# XXX: As of 2020-11-01, this command is executed even though it contains -# parse errors. unclosed-modifier: +# expect: make: Unclosed expression, expecting '}' for "UNCLOSED" +# XXX: This command is executed even though it contains parse errors. +# expect: : unclosed-modifier : $@ ${UNCLOSED: -# XXX: As of 2020-11-01, this command is executed even though it contains -# parse errors. unknown-modifier: +# expect: make: in target "unknown-modifier": while evaluating variable "UNKNOWN" with value "": Unknown modifier "Z" +# XXX: This command is executed even though
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Fri Jul 5 17:41:50 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: cmd-errors-jobs.mk cmd-errors-lint.mk cmd-errors.mk directive-for-escape.exp directive-for-escape.mk moderrs.mk varmisc.mk varmod-edge.exp varmod-edge.mk varmod-order.exp varmod-order.mk varparse-errors.mk Log Message: tests/make: add expected messages for "Unclosed expression" To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cmd-errors-jobs.mk cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cmd-errors-lint.mk cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cmd-errors.mk cvs rdiff -u -r1.25 -r1.26 \ src/usr.bin/make/unit-tests/directive-for-escape.exp cvs rdiff -u -r1.23 -r1.24 \ src/usr.bin/make/unit-tests/directive-for-escape.mk cvs rdiff -u -r1.35 -r1.36 src/usr.bin/make/unit-tests/moderrs.mk cvs rdiff -u -r1.33 -r1.34 src/usr.bin/make/unit-tests/varmisc.mk cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/varmod-edge.exp cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/varmod-edge.mk cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/varmod-order.exp cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/varmod-order.mk cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/varparse-errors.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: Fri Jul 5 05:11:25 UTC 2024 Modified Files: src/usr.bin/make: arch.c job.c main.c make.h suff.c var.c Log Message: make: reduce lint-specific comments about ARGSUSED To generate a diff of this commit: cvs rdiff -u -r1.219 -r1.220 src/usr.bin/make/arch.c cvs rdiff -u -r1.478 -r1.479 src/usr.bin/make/job.c cvs rdiff -u -r1.626 -r1.627 src/usr.bin/make/main.c cvs rdiff -u -r1.339 -r1.340 src/usr.bin/make/make.h cvs rdiff -u -r1.380 -r1.381 src/usr.bin/make/suff.c cvs rdiff -u -r1.1129 -r1.1130 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/arch.c diff -u src/usr.bin/make/arch.c:1.219 src/usr.bin/make/arch.c:1.220 --- src/usr.bin/make/arch.c:1.219 Sun Jun 2 15:31:25 2024 +++ src/usr.bin/make/arch.c Fri Jul 5 05:11:25 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.219 2024/06/02 15:31:25 rillig Exp $ */ +/* $NetBSD: arch.c,v 1.220 2024/07/05 05:11:25 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -126,7 +126,7 @@ #include "config.h" /* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: arch.c,v 1.219 2024/06/02 15:31:25 rillig Exp $"); +MAKE_RCSID("$NetBSD: arch.c,v 1.220 2024/07/05 05:11:25 rillig Exp $"); typedef struct List ArchList; typedef struct ListNode ArchListNode; @@ -770,7 +770,6 @@ Arch_Touch(GNode *gn) * Both the modification time of the library and of the RANLIBMAG member are * set to 'now'. */ -/*ARGSUSED*/ void Arch_TouchLib(GNode *gn MAKE_ATTR_UNUSED) { @@ -871,7 +870,6 @@ Arch_FindLib(GNode *gn, SearchPath *path Var_Set(gn, TARGET, gn->name); } -/* ARGSUSED */ static bool RanlibOODate(const GNode *gn MAKE_ATTR_UNUSED) { Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.478 src/usr.bin/make/job.c:1.479 --- src/usr.bin/make/job.c:1.478 Fri Jun 28 15:20:57 2024 +++ src/usr.bin/make/job.c Fri Jul 5 05:11:25 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.478 2024/06/28 15:20:57 rillig Exp $ */ +/* $NetBSD: job.c,v 1.479 2024/07/05 05:11:25 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -141,7 +141,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.478 2024/06/28 15:20:57 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.479 2024/07/05 05:11:25 rillig Exp $"); /* * A shell defines how the commands are run. All commands for a target are @@ -594,7 +594,6 @@ JobCondPassSig(int signo) * * Sends a token on the child exit pipe to wake us up from select()/poll(). */ -/*ARGSUSED*/ static void JobChildSig(int signo MAKE_ATTR_UNUSED) { @@ -606,7 +605,6 @@ JobChildSig(int signo MAKE_ATTR_UNUSED) /* Resume all stopped jobs. */ -/*ARGSUSED*/ static void JobContinueSig(int signo MAKE_ATTR_UNUSED) { Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.626 src/usr.bin/make/main.c:1.627 --- src/usr.bin/make/main.c:1.626 Thu Jul 4 20:18:40 2024 +++ src/usr.bin/make/main.c Fri Jul 5 05:11:25 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.626 2024/07/04 20:18:40 rillig Exp $ */ +/* $NetBSD: main.c,v 1.627 2024/07/05 05:11:25 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -111,7 +111,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.626 2024/07/04 20:18:40 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.627 2024/07/05 05:11:25 rillig Exp $"); #if defined(MAKE_NATIVE) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -789,7 +789,6 @@ AppendWords(StringList *lp, char *str) } #ifdef SIGINFO -/*ARGSUSED*/ static void siginfo(int signo MAKE_ATTR_UNUSED) { Index: src/usr.bin/make/make.h diff -u src/usr.bin/make/make.h:1.339 src/usr.bin/make/make.h:1.340 --- src/usr.bin/make/make.h:1.339 Sat Jun 15 20:02:45 2024 +++ src/usr.bin/make/make.h Fri Jul 5 05:11:25 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.339 2024/06/15 20:02:45 rillig Exp $ */ +/* $NetBSD: make.h,v 1.340 2024/07/05 05:11:25 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -109,7 +109,7 @@ #define MAKE_GNUC_PREREQ(x, y) 0 #endif -#if MAKE_GNUC_PREREQ(2, 7) +#if MAKE_GNUC_PREREQ(2, 7) || lint #define MAKE_ATTR_UNUSED __attribute__((__unused__)) #else #define MAKE_ATTR_UNUSED /* delete */ @@ -918,7 +918,6 @@ const char *GNodeMade_Name(GNodeMade) MA #ifdef CLEANUP void Parse_RegisterCommand(char *); #else -/* ARGSUSED */ MAKE_INLINE void Parse_RegisterCommand(char *cmd MAKE_ATTR_UNUSED) { Index: src/usr.bin/make/suff.c diff -u src/usr.bin/make/suff.c:1.380 src/usr.bin/make/suff.c:1.381 --- src/usr.bin/make/suff.c:1.380 Sun Jun 2 15:31:26 2024 +++ src/usr.bin/make/suff.c Fri Jul 5 05:11:25 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.380 2024/06/02 15:31:26 rillig Exp $ */ +/* $NetBSD: s
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Jul 5 05:11:25 UTC 2024 Modified Files: src/usr.bin/make: arch.c job.c main.c make.h suff.c var.c Log Message: make: reduce lint-specific comments about ARGSUSED To generate a diff of this commit: cvs rdiff -u -r1.219 -r1.220 src/usr.bin/make/arch.c cvs rdiff -u -r1.478 -r1.479 src/usr.bin/make/job.c cvs rdiff -u -r1.626 -r1.627 src/usr.bin/make/main.c cvs rdiff -u -r1.339 -r1.340 src/usr.bin/make/make.h cvs rdiff -u -r1.380 -r1.381 src/usr.bin/make/suff.c cvs rdiff -u -r1.1129 -r1.1130 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
Module Name:src Committed By: rillig Date: Thu Jul 4 20:18:40 UTC 2024 Modified Files: src/usr.bin/make: main.c src/usr.bin/make/unit-tests: Makefile compat-error.exp cond-cmp-numeric.exp cond-func-defined.exp cond-late.exp cond-op-not.exp cond-op-parentheses.exp cond-op.exp cond-short.exp cond-token-number.exp cond-token-string.exp dep-percent.exp dep.exp depsrc-ignore.exp deptgt-begin-fail-indirect.exp deptgt-begin-fail.exp deptgt-delete_on_error.exp deptgt-end-fail-all.exp deptgt-end-fail-indirect.exp deptgt-end-fail.exp deptgt-error.exp deptgt-ignore.exp deptgt-path-suffix.exp deptgt.exp directive-dinclude.exp directive-elif.exp directive-else.exp directive-for-generating-endif.exp directive-for-if.exp directive-for-null.exp directive-hyphen-include.exp directive-ifmake.exp directive-include-fatal.exp directive-include.exp directive-info.exp directive-sinclude.exp directive-undef.exp directive-unexport-env.exp directive-warning.exp directive.exp doterror.exp jobs-empty-commands-error.exp jobs-error-indirect.exp jobs-error-nested-make.exp jobs-error-nested.exp opt-debug-errors-jobs.exp opt-debug-errors.exp opt-debug-graph2.exp opt-debug-graph3.exp opt-file.exp opt-keep-going-indirect.exp opt-keep-going-multiple.exp opt-keep-going.exp opt-warnings-as-errors.exp opt.exp parse.exp posix.exp sh-jobs.exp suff-add-later.exp suff-clear-regular.exp suff-clear-single.exp suff-main-several.exp suff-self.exp suff-transform-endless.exp suff-transform-expand.exp suff-transform-select.exp suff-use.exp use-inference.exp var-eval-short.exp var-op-assign.exp var-op-expand.exp var-recursive.exp varmod-edge.exp varmod-gmtime.exp varmod-localtime.exp varmod-loop-delete.exp varmod-loop-varname.exp varmod-match-escape.exp varmod-order.exp varmod-range.exp varmod-sysv.exp varname-dot-newline.exp varname-make_print_var_on_error-jobs.exp varname-make_print_var_on_error.exp varname.exp Log Message: make: on error, print the targets to be made This helps to understand situations with several nested sub-makes in varying directories. To generate a diff of this commit: cvs rdiff -u -r1.625 -r1.626 src/usr.bin/make/main.c cvs rdiff -u -r1.348 -r1.349 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/compat-error.exp \ src/usr.bin/make/unit-tests/depsrc-ignore.exp \ src/usr.bin/make/unit-tests/directive-include-fatal.exp \ src/usr.bin/make/unit-tests/opt-debug-errors.exp \ src/usr.bin/make/unit-tests/varname-make_print_var_on_error.exp cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cond-cmp-numeric.exp \ src/usr.bin/make/unit-tests/cond-func-defined.exp \ src/usr.bin/make/unit-tests/directive.exp \ src/usr.bin/make/unit-tests/opt-file.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cond-late.exp \ src/usr.bin/make/unit-tests/cond-token-number.exp \ src/usr.bin/make/unit-tests/directive-elif.exp \ src/usr.bin/make/unit-tests/directive-ifmake.exp \ src/usr.bin/make/unit-tests/var-op-assign.exp cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cond-op-not.exp \ src/usr.bin/make/unit-tests/opt-debug-errors-jobs.exp \ src/usr.bin/make/unit-tests/opt-warnings-as-errors.exp \ src/usr.bin/make/unit-tests/varmod-loop-delete.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cond-op-parentheses.exp \ src/usr.bin/make/unit-tests/deptgt-end-fail.exp \ src/usr.bin/make/unit-tests/directive-else.exp \ src/usr.bin/make/unit-tests/directive-warning.exp \ src/usr.bin/make/unit-tests/parse.exp \ src/usr.bin/make/unit-tests/varname-dot-newline.exp cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/cond-op.exp \ src/usr.bin/make/unit-tests/cond-token-string.exp \ src/usr.bin/make/unit-tests/directive-include.exp \ src/usr.bin/make/unit-tests/suff-main-several.exp cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/cond-short.exp \ src/usr.bin/make/unit-tests/deptgt.exp \ src/usr.bin/make/unit-tests/directive-unexport-env.exp \ src/usr.bin/make/unit-tests/varmod-range.exp \ src/usr.bin/make/unit-tests/varmod-sysv.exp cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/dep-percent.exp \ src/usr.bin/make/unit-tests/dep.exp \ src/usr.bin/make/unit-tests/deptgt-begin-fail-indirect.exp \ src/usr.bin/make/unit-tests/deptgt-end-fail-all.exp \ src/usr.bin/make/unit-tests/deptgt-end-fail-indirect.exp \ src/usr.bin/make/unit-tests/deptgt-error.exp \ src/usr.bin/make/unit-tests/deptgt-ignore.exp \ src/usr.bin/make/unit-tests/deptgt-path-suffix.exp \ src/usr.b
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Jul 4 20:18:40 UTC 2024 Modified Files: src/usr.bin/make: main.c src/usr.bin/make/unit-tests: Makefile compat-error.exp cond-cmp-numeric.exp cond-func-defined.exp cond-late.exp cond-op-not.exp cond-op-parentheses.exp cond-op.exp cond-short.exp cond-token-number.exp cond-token-string.exp dep-percent.exp dep.exp depsrc-ignore.exp deptgt-begin-fail-indirect.exp deptgt-begin-fail.exp deptgt-delete_on_error.exp deptgt-end-fail-all.exp deptgt-end-fail-indirect.exp deptgt-end-fail.exp deptgt-error.exp deptgt-ignore.exp deptgt-path-suffix.exp deptgt.exp directive-dinclude.exp directive-elif.exp directive-else.exp directive-for-generating-endif.exp directive-for-if.exp directive-for-null.exp directive-hyphen-include.exp directive-ifmake.exp directive-include-fatal.exp directive-include.exp directive-info.exp directive-sinclude.exp directive-undef.exp directive-unexport-env.exp directive-warning.exp directive.exp doterror.exp jobs-empty-commands-error.exp jobs-error-indirect.exp jobs-error-nested-make.exp jobs-error-nested.exp opt-debug-errors-jobs.exp opt-debug-errors.exp opt-debug-graph2.exp opt-debug-graph3.exp opt-file.exp opt-keep-going-indirect.exp opt-keep-going-multiple.exp opt-keep-going.exp opt-warnings-as-errors.exp opt.exp parse.exp posix.exp sh-jobs.exp suff-add-later.exp suff-clear-regular.exp suff-clear-single.exp suff-main-several.exp suff-self.exp suff-transform-endless.exp suff-transform-expand.exp suff-transform-select.exp suff-use.exp use-inference.exp var-eval-short.exp var-op-assign.exp var-op-expand.exp var-recursive.exp varmod-edge.exp varmod-gmtime.exp varmod-localtime.exp varmod-loop-delete.exp varmod-loop-varname.exp varmod-match-escape.exp varmod-order.exp varmod-range.exp varmod-sysv.exp varname-dot-newline.exp varname-make_print_var_on_error-jobs.exp varname-make_print_var_on_error.exp varname.exp Log Message: make: on error, print the targets to be made This helps to understand situations with several nested sub-makes in varying directories. To generate a diff of this commit: cvs rdiff -u -r1.625 -r1.626 src/usr.bin/make/main.c cvs rdiff -u -r1.348 -r1.349 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/compat-error.exp \ src/usr.bin/make/unit-tests/depsrc-ignore.exp \ src/usr.bin/make/unit-tests/directive-include-fatal.exp \ src/usr.bin/make/unit-tests/opt-debug-errors.exp \ src/usr.bin/make/unit-tests/varname-make_print_var_on_error.exp cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cond-cmp-numeric.exp \ src/usr.bin/make/unit-tests/cond-func-defined.exp \ src/usr.bin/make/unit-tests/directive.exp \ src/usr.bin/make/unit-tests/opt-file.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cond-late.exp \ src/usr.bin/make/unit-tests/cond-token-number.exp \ src/usr.bin/make/unit-tests/directive-elif.exp \ src/usr.bin/make/unit-tests/directive-ifmake.exp \ src/usr.bin/make/unit-tests/var-op-assign.exp cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cond-op-not.exp \ src/usr.bin/make/unit-tests/opt-debug-errors-jobs.exp \ src/usr.bin/make/unit-tests/opt-warnings-as-errors.exp \ src/usr.bin/make/unit-tests/varmod-loop-delete.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cond-op-parentheses.exp \ src/usr.bin/make/unit-tests/deptgt-end-fail.exp \ src/usr.bin/make/unit-tests/directive-else.exp \ src/usr.bin/make/unit-tests/directive-warning.exp \ src/usr.bin/make/unit-tests/parse.exp \ src/usr.bin/make/unit-tests/varname-dot-newline.exp cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/cond-op.exp \ src/usr.bin/make/unit-tests/cond-token-string.exp \ src/usr.bin/make/unit-tests/directive-include.exp \ src/usr.bin/make/unit-tests/suff-main-several.exp cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/cond-short.exp \ src/usr.bin/make/unit-tests/deptgt.exp \ src/usr.bin/make/unit-tests/directive-unexport-env.exp \ src/usr.bin/make/unit-tests/varmod-range.exp \ src/usr.bin/make/unit-tests/varmod-sysv.exp cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/dep-percent.exp \ src/usr.bin/make/unit-tests/dep.exp \ src/usr.bin/make/unit-tests/deptgt-begin-fail-indirect.exp \ src/usr.bin/make/unit-tests/deptgt-end-fail-all.exp \ src/usr.bin/make/unit-tests/deptgt-end-fail-indirect.exp \ src/usr.bin/make/unit-tests/deptgt-error.exp \ src/usr.bin/make/unit-tests/deptgt-ignore.exp \ src/usr.bin/make/unit-tests/deptgt-path-suffix.exp \ src/usr.b
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Jul 4 18:53:38 UTC 2024 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: moderrs.exp moderrs.mk varmod-assign.exp varmod-order.exp varmod-order.mk varmod-select-words.exp varmod-to-separator.exp varmod-to-separator.mk varmod.exp varmod.mk varparse-errors.exp varparse-errors.mk Log Message: make: error out on the "Bad modifier" error message Previously, the "Bad modifier" error message did not affect make's exit status. As a side effect, this kind of error now gets more context information. To generate a diff of this commit: cvs rdiff -u -r1.1128 -r1.1129 src/usr.bin/make/var.c cvs rdiff -u -r1.38 -r1.39 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.34 -r1.35 src/usr.bin/make/unit-tests/moderrs.mk cvs rdiff -u -r1.24 -r1.25 src/usr.bin/make/unit-tests/varmod-assign.exp cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/varmod-order.exp cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/varmod-order.mk \ src/usr.bin/make/unit-tests/varparse-errors.exp cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-select-words.exp cvs rdiff -u -r1.14 -r1.15 \ src/usr.bin/make/unit-tests/varmod-to-separator.exp cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varmod-to-separator.mk \ src/usr.bin/make/unit-tests/varmod.mk cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod.exp \ src/usr.bin/make/unit-tests/varparse-errors.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.1128 src/usr.bin/make/var.c:1.1129 --- src/usr.bin/make/var.c:1.1128 Thu Jul 4 17:47:53 2024 +++ src/usr.bin/make/var.c Thu Jul 4 18:53:37 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1128 2024/07/04 17:47:53 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1129 2024/07/04 18:53:37 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -132,7 +132,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1128 2024/07/04 17:47:53 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1129 2024/07/04 18:53:37 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -1965,11 +1965,9 @@ FormatTime(const char *fmt, time_t t, bo * and stores the result back in ch->expr->value via Expr_SetValueOwn or * Expr_SetValueRefer. * - * If evaluating fails, the fallback error message "Bad modifier" is printed - * using Error. This function has no side effects, it really just prints the - * error message, continuing as if nothing had happened. TODO: This should be - * fixed by adding proper error handling to Var_Subst, Var_Parse, - * ApplyModifiers and ModifyWords. + * If evaluating fails, the fallback error message "Bad modifier" is printed. + * TODO: Add proper error handling to Var_Subst, Var_Parse, ApplyModifiers and + * ModifyWords. * * Some modifiers such as :D and :U turn undefined expressions into defined * expressions using Expr_Define. @@ -4118,8 +4116,8 @@ ApplyModifiers( bad_modifier: /* Take a guess at where the modifier ends. */ - Error("Bad modifier \":%.*s\" for variable \"%s\"", - (int)strcspn(mod, ":)}"), mod, expr->name); + Parse_Error(PARSE_FATAL, "Bad modifier \":%.*s\"", + (int)strcspn(mod, ":)}"), mod); cleanup: /* Index: src/usr.bin/make/unit-tests/moderrs.exp diff -u src/usr.bin/make/unit-tests/moderrs.exp:1.38 src/usr.bin/make/unit-tests/moderrs.exp:1.39 --- src/usr.bin/make/unit-tests/moderrs.exp:1.38 Thu Jul 4 17:47:54 2024 +++ src/usr.bin/make/unit-tests/moderrs.exp Thu Jul 4 18:53:37 2024 @@ -31,7 +31,7 @@ make: in target "words": while evaluatin make: in target "words": while evaluating variable "UNDEF" with value "1 2 3": Unfinished modifier (']' missing) 13= -make: Bad modifier ":[123451234512345123451234512345]" for variable "UNDEF" +make: in target "words": while evaluating variable "UNDEF" with value "1 2 3": Bad modifier ":[123451234512345123451234512345]" 12345=S,^ok,:S,^3ok,} make: in target "exclam": while evaluating variable "VARNAME" with value "": Unfinished modifier ('!' missing) @@ -70,21 +70,21 @@ make: Unclosed expression, expecting '}' mod-ts-parse: 112358132134 15152535558513521534 -make: Bad modifier ":ts\65oct" for variable "FIB" +make: in target "mod-ts-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":ts\65oct" 65oct} -make: Bad modifier ":ts\65oct" for variable "" +make: in target "mod-ts-parse": while evaluating "${:U${FIB}:ts\65oct} # bad modifier, variable name is """: Bad modifier ":ts\65oct" 65oct} -make: Bad modifier ":tsxy" for variable "FIB" +make: in target "mod-ts-parse": while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34": Bad modifier ":tsxy" xy} mod-t-parse: -make: Bad modifier ":t"
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Jul 4 18:53:38 UTC 2024 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: moderrs.exp moderrs.mk varmod-assign.exp varmod-order.exp varmod-order.mk varmod-select-words.exp varmod-to-separator.exp varmod-to-separator.mk varmod.exp varmod.mk varparse-errors.exp varparse-errors.mk Log Message: make: error out on the "Bad modifier" error message Previously, the "Bad modifier" error message did not affect make's exit status. As a side effect, this kind of error now gets more context information. To generate a diff of this commit: cvs rdiff -u -r1.1128 -r1.1129 src/usr.bin/make/var.c cvs rdiff -u -r1.38 -r1.39 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.34 -r1.35 src/usr.bin/make/unit-tests/moderrs.mk cvs rdiff -u -r1.24 -r1.25 src/usr.bin/make/unit-tests/varmod-assign.exp cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/varmod-order.exp cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/varmod-order.mk \ src/usr.bin/make/unit-tests/varparse-errors.exp cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-select-words.exp cvs rdiff -u -r1.14 -r1.15 \ src/usr.bin/make/unit-tests/varmod-to-separator.exp cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varmod-to-separator.mk \ src/usr.bin/make/unit-tests/varmod.mk cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod.exp \ src/usr.bin/make/unit-tests/varparse-errors.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: Thu Jul 4 17:47:54 UTC 2024 Modified Files: src/usr.bin/make: parse.c var.c src/usr.bin/make/unit-tests: cmd-errors-jobs.exp cmd-errors-jobs.mk cmd-errors-lint.exp cmd-errors.exp cond-late.exp cond-late.mk dep-op-missing.exp directive-dinclude.exp directive-export-gmake.exp directive-for-break.exp directive-for-escape.exp directive-for-generating-endif.exp directive-for-if.exp directive-for-null.exp directive-for.exp directive-hyphen-include.exp directive-sinclude.exp directive-undef.exp directive-undef.mk lint.exp moderrs.exp moderrs.mk opt-debug-lint.exp opt-debug-lint.mk opt-file.exp var-op-expand.exp var-op-expand.mk var-recursive.exp varmisc.exp varmod-assign-shell.exp varmod-assign-shell.mk varmod-assign.exp varmod-assign.mk varmod-edge.exp varmod-edge.mk varmod-gmtime.exp varmod-gmtime.mk varmod-hash.exp varmod-indirect.exp varmod-indirect.mk varmod-localtime.exp varmod-localtime.mk varmod-loop-delete.exp varmod-loop-delete.mk varmod-loop-varname.exp varmod-loop-varname.mk varmod-match-escape.exp varmod-match-escape.mk varmod-match.exp varmod-match.mk varmod-mtime.exp varmod-mtime.mk varmod-range.exp varmod-range.mk varmod-subst-regex.exp varmod-sun-shell.exp varmod-sun-shell.mk varmod-sysv.exp varmod-sysv.mk varmod-to-separator.exp varmod-to-separator.mk varmod.exp varmod.mk varname-dot-newline.exp Log Message: make: add more context information to error messages In case of a parse error or evaluation error, print the variable value in addition to the variable name, to see the effects of previous expression modifiers. In nested make calls, print the current directory at the bottom of a stack trace, as that information is otherwise hard to get in a parallel build spanning multiple directories. To generate a diff of this commit: cvs rdiff -u -r1.731 -r1.732 src/usr.bin/make/parse.c cvs rdiff -u -r1.1127 -r1.1128 src/usr.bin/make/var.c cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp \ src/usr.bin/make/unit-tests/cmd-errors-lint.exp \ src/usr.bin/make/unit-tests/cond-late.exp \ src/usr.bin/make/unit-tests/directive-export-gmake.exp cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cmd-errors-jobs.mk \ src/usr.bin/make/unit-tests/directive-for-break.exp \ src/usr.bin/make/unit-tests/lint.exp \ src/usr.bin/make/unit-tests/varmod-hash.exp \ src/usr.bin/make/unit-tests/varmod-loop-delete.exp \ src/usr.bin/make/unit-tests/varmod-loop-delete.mk \ src/usr.bin/make/unit-tests/varmod-sun-shell.mk cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cmd-errors.exp \ src/usr.bin/make/unit-tests/var-op-expand.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cond-late.mk \ src/usr.bin/make/unit-tests/var-recursive.exp \ src/usr.bin/make/unit-tests/varmod-assign-shell.exp \ src/usr.bin/make/unit-tests/varmod-assign-shell.mk \ src/usr.bin/make/unit-tests/varmod-loop-varname.exp \ src/usr.bin/make/unit-tests/varmod-loop-varname.mk cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/dep-op-missing.exp cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/directive-dinclude.exp \ src/usr.bin/make/unit-tests/directive-for-generating-endif.exp \ src/usr.bin/make/unit-tests/directive-for-if.exp \ src/usr.bin/make/unit-tests/directive-for-null.exp \ src/usr.bin/make/unit-tests/directive-hyphen-include.exp \ src/usr.bin/make/unit-tests/directive-sinclude.exp cvs rdiff -u -r1.24 -r1.25 \ src/usr.bin/make/unit-tests/directive-for-escape.exp \ src/usr.bin/make/unit-tests/varmod-match.mk cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/directive-for.exp \ src/usr.bin/make/unit-tests/varmod-assign.mk \ src/usr.bin/make/unit-tests/varmod-gmtime.mk cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/directive-undef.exp \ src/usr.bin/make/unit-tests/varmod-mtime.mk cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/directive-undef.mk \ src/usr.bin/make/unit-tests/varmod-localtime.exp \ src/usr.bin/make/unit-tests/varmod-match-escape.mk cvs rdiff -u -r1.37 -r1.38 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.33 -r1.34 src/usr.bin/make/unit-tests/moderrs.mk cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/opt-debug-lint.exp \ src/usr.bin/make/unit-tests/varmod-indirect.mk cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/opt-debug-lint.mk \ src/usr.bin/make/unit-tests/varmod-gmtime.exp cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/opt-file.exp \ src/usr.bin/make/unit-tests/varmod-mtime.exp \ src/usr.bin/make/unit-tests/varmod-subst-regex.exp cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/var-op-expan
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Jul 4 17:47:54 UTC 2024 Modified Files: src/usr.bin/make: parse.c var.c src/usr.bin/make/unit-tests: cmd-errors-jobs.exp cmd-errors-jobs.mk cmd-errors-lint.exp cmd-errors.exp cond-late.exp cond-late.mk dep-op-missing.exp directive-dinclude.exp directive-export-gmake.exp directive-for-break.exp directive-for-escape.exp directive-for-generating-endif.exp directive-for-if.exp directive-for-null.exp directive-for.exp directive-hyphen-include.exp directive-sinclude.exp directive-undef.exp directive-undef.mk lint.exp moderrs.exp moderrs.mk opt-debug-lint.exp opt-debug-lint.mk opt-file.exp var-op-expand.exp var-op-expand.mk var-recursive.exp varmisc.exp varmod-assign-shell.exp varmod-assign-shell.mk varmod-assign.exp varmod-assign.mk varmod-edge.exp varmod-edge.mk varmod-gmtime.exp varmod-gmtime.mk varmod-hash.exp varmod-indirect.exp varmod-indirect.mk varmod-localtime.exp varmod-localtime.mk varmod-loop-delete.exp varmod-loop-delete.mk varmod-loop-varname.exp varmod-loop-varname.mk varmod-match-escape.exp varmod-match-escape.mk varmod-match.exp varmod-match.mk varmod-mtime.exp varmod-mtime.mk varmod-range.exp varmod-range.mk varmod-subst-regex.exp varmod-sun-shell.exp varmod-sun-shell.mk varmod-sysv.exp varmod-sysv.mk varmod-to-separator.exp varmod-to-separator.mk varmod.exp varmod.mk varname-dot-newline.exp Log Message: make: add more context information to error messages In case of a parse error or evaluation error, print the variable value in addition to the variable name, to see the effects of previous expression modifiers. In nested make calls, print the current directory at the bottom of a stack trace, as that information is otherwise hard to get in a parallel build spanning multiple directories. To generate a diff of this commit: cvs rdiff -u -r1.731 -r1.732 src/usr.bin/make/parse.c cvs rdiff -u -r1.1127 -r1.1128 src/usr.bin/make/var.c cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp \ src/usr.bin/make/unit-tests/cmd-errors-lint.exp \ src/usr.bin/make/unit-tests/cond-late.exp \ src/usr.bin/make/unit-tests/directive-export-gmake.exp cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cmd-errors-jobs.mk \ src/usr.bin/make/unit-tests/directive-for-break.exp \ src/usr.bin/make/unit-tests/lint.exp \ src/usr.bin/make/unit-tests/varmod-hash.exp \ src/usr.bin/make/unit-tests/varmod-loop-delete.exp \ src/usr.bin/make/unit-tests/varmod-loop-delete.mk \ src/usr.bin/make/unit-tests/varmod-sun-shell.mk cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cmd-errors.exp \ src/usr.bin/make/unit-tests/var-op-expand.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cond-late.mk \ src/usr.bin/make/unit-tests/var-recursive.exp \ src/usr.bin/make/unit-tests/varmod-assign-shell.exp \ src/usr.bin/make/unit-tests/varmod-assign-shell.mk \ src/usr.bin/make/unit-tests/varmod-loop-varname.exp \ src/usr.bin/make/unit-tests/varmod-loop-varname.mk cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/dep-op-missing.exp cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/directive-dinclude.exp \ src/usr.bin/make/unit-tests/directive-for-generating-endif.exp \ src/usr.bin/make/unit-tests/directive-for-if.exp \ src/usr.bin/make/unit-tests/directive-for-null.exp \ src/usr.bin/make/unit-tests/directive-hyphen-include.exp \ src/usr.bin/make/unit-tests/directive-sinclude.exp cvs rdiff -u -r1.24 -r1.25 \ src/usr.bin/make/unit-tests/directive-for-escape.exp \ src/usr.bin/make/unit-tests/varmod-match.mk cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/directive-for.exp \ src/usr.bin/make/unit-tests/varmod-assign.mk \ src/usr.bin/make/unit-tests/varmod-gmtime.mk cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/directive-undef.exp \ src/usr.bin/make/unit-tests/varmod-mtime.mk cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/directive-undef.mk \ src/usr.bin/make/unit-tests/varmod-localtime.exp \ src/usr.bin/make/unit-tests/varmod-match-escape.mk cvs rdiff -u -r1.37 -r1.38 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.33 -r1.34 src/usr.bin/make/unit-tests/moderrs.mk cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/opt-debug-lint.exp \ src/usr.bin/make/unit-tests/varmod-indirect.mk cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/opt-debug-lint.mk \ src/usr.bin/make/unit-tests/varmod-gmtime.exp cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/opt-file.exp \ src/usr.bin/make/unit-tests/varmod-mtime.exp \ src/usr.bin/make/unit-tests/varmod-subst-regex.exp cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/var-op-expan
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Tue Jul 2 20:10:45 UTC 2024 Modified Files: src/usr.bin/make: var.c Log Message: make: trim trailing whitespace To generate a diff of this commit: cvs rdiff -u -r1.1126 -r1.1127 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.1126 src/usr.bin/make/var.c:1.1127 --- src/usr.bin/make/var.c:1.1126 Mon Jul 1 21:02:26 2024 +++ src/usr.bin/make/var.c Tue Jul 2 20:10:45 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1126 2024/07/01 21:02:26 sjg Exp $ */ +/* $NetBSD: var.c,v 1.1127 2024/07/02 20:10:45 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -132,7 +132,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1126 2024/07/01 21:02:26 sjg Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1127 2024/07/02 20:10:45 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -3209,7 +3209,7 @@ ApplyModifier_To(const char **pp, ModCha Expr_SetValueOwn(expr, str_totitle(Expr_Str(expr))); return AMR_OK; } - + if (mod[1] == 'u') {/* :tu */ *pp = mod + 2; if (Expr_ShouldEval(expr))
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Tue Jul 2 20:10:45 UTC 2024 Modified Files: src/usr.bin/make: var.c Log Message: make: trim trailing whitespace To generate a diff of this commit: cvs rdiff -u -r1.1126 -r1.1127 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
Module Name:src Committed By: sjg Date: Mon Jul 1 21:02:26 UTC 2024 Modified Files: src/usr.bin/make: make.1 var.c src/usr.bin/make/unit-tests: Makefile Added Files: src/usr.bin/make/unit-tests: varmod-to-title.exp varmod-to-title.mk Log Message: make: add :tc to capitalize first letter of each word This is very hard to do without :tc Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.377 -r1.378 src/usr.bin/make/make.1 cvs rdiff -u -r1.1125 -r1.1126 src/usr.bin/make/var.c cvs rdiff -u -r1.347 -r1.348 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/varmod-to-title.exp \ src/usr.bin/make/unit-tests/varmod-to-title.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/make.1 diff -u src/usr.bin/make/make.1:1.377 src/usr.bin/make/make.1:1.378 --- src/usr.bin/make/make.1:1.377 Sat Jun 1 06:26:36 2024 +++ src/usr.bin/make/make.1 Mon Jul 1 21:02:26 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.377 2024/06/01 06:26:36 sjg Exp $ +.\" $NetBSD: make.1,v 1.378 2024/07/01 21:02:26 sjg Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 .\" -.Dd June 1, 2024 +.Dd July 1, 2024 .Dt MAKE 1 .Os .Sh NAME @@ -1574,6 +1574,9 @@ If .Ar c is omitted, no separator is used. The common escapes (including octal numeric codes) work as expected. +.It Cm \&:tt +Converts the first character of each word to upper-case, +and the rest to lower-case letters. .It Cm \&:tu Converts the value to upper-case letters. .It Cm \&:tW Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.1125 src/usr.bin/make/var.c:1.1126 --- src/usr.bin/make/var.c:1.1125 Sun Jun 30 15:21:23 2024 +++ src/usr.bin/make/var.c Mon Jul 1 21:02:26 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1125 2024/06/30 15:21:23 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1126 2024/07/01 21:02:26 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -132,7 +132,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1125 2024/06/30 15:21:23 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1126 2024/07/01 21:02:26 sjg Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -3142,6 +3142,21 @@ ok: } static char * +str_totitle(const char *str) +{ + size_t i, n = strlen(str) + 1; + char *res = bmake_malloc(n); + for (i = 0; i < n; i++) { + if (i == 0 || ch_isspace(res[i - 1])) + res[i] = ch_toupper(str[i]); + else + res[i] = ch_tolower(str[i]); + } + return res; +} + + +static char * str_toupper(const char *str) { size_t i, n = strlen(str) + 1; @@ -3188,6 +3203,13 @@ ApplyModifier_To(const char **pp, ModCha return AMR_OK; } + if (mod[1] == 't') {/* :tt */ + *pp = mod + 2; + if (Expr_ShouldEval(expr)) + Expr_SetValueOwn(expr, str_totitle(Expr_Str(expr))); + return AMR_OK; + } + if (mod[1] == 'u') {/* :tu */ *pp = mod + 2; if (Expr_ShouldEval(expr)) Index: src/usr.bin/make/unit-tests/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.347 src/usr.bin/make/unit-tests/Makefile:1.348 --- src/usr.bin/make/unit-tests/Makefile:1.347 Sat Jun 1 15:54:40 2024 +++ src/usr.bin/make/unit-tests/Makefile Mon Jul 1 21:02:26 2024 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.347 2024/06/01 15:54:40 sjg Exp $ +# $NetBSD: Makefile,v 1.348 2024/07/01 21:02:26 sjg Exp $ # # Unit tests for make(1) # @@ -397,6 +397,7 @@ TESTS+= varmod-to-lower TESTS+= varmod-to-many-words TESTS+= varmod-to-one-word TESTS+= varmod-to-separator +TESTS+= varmod-to-title TESTS+= varmod-to-upper TESTS+= varmod-undefined TESTS+= varmod-unique Added files: Index: src/usr.bin/make/unit-tests/varmod-to-title.exp diff -u /dev/null src/usr.bin/make/unit-tests/varmod-to-title.exp:1.1 --- /dev/null Mon Jul 1 21:02:26 2024 +++ src/usr.bin/make/unit-tests/varmod-to-title.exp Mon Jul 1 21:02:26 2024 @@ -0,0 +1 @@ +exit status 0 Index: src/usr.bin/make/unit-tests/varmod-to-title.mk diff -u /dev/null src/usr.bin/make/unit-tests/varmod-to-title.mk:1.1 --- /dev/null Mon Jul 1 21:02:26 2024 +++ src/usr.bin/make/unit-tests/varmod-to-title.mk Mon Jul 1 21:02:26 2024 @@ -0,0 +1,31 @@ +# $NetBSD: varmod-to-title.mk,v 1.1 2024/07/01 21:02:26 sjg Exp $ +# +# Tests for the :tc variable modifier, which converts the expression value +# to lowercase. +# +# TODO: What about non-ASCII characters? ISO-8859-1, UTF-8? + +.if ${:UUPPER:tt} != "Upper" +. error +.endif + +.if ${:Ulower:tt} != "Lower" +. error +.endif + +.if ${:UMixeD case.:tt} != "Mixed Case." +. error +.endif + +# The ':tt' modifier works on the whole string, without splitting it into +# words. +.if ${:Umultiple spaces:tt} != "Multiple Spaces" +. error +.endif + +# Note words only
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Mon Jul 1 21:02:26 UTC 2024 Modified Files: src/usr.bin/make: make.1 var.c src/usr.bin/make/unit-tests: Makefile Added Files: src/usr.bin/make/unit-tests: varmod-to-title.exp varmod-to-title.mk Log Message: make: add :tc to capitalize first letter of each word This is very hard to do without :tc Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.377 -r1.378 src/usr.bin/make/make.1 cvs rdiff -u -r1.1125 -r1.1126 src/usr.bin/make/var.c cvs rdiff -u -r1.347 -r1.348 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/varmod-to-title.exp \ src/usr.bin/make/unit-tests/varmod-to-title.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: Sun Jun 30 15:21:24 UTC 2024 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: moderrs.exp moderrs.mk opt-debug-file.exp opt-debug-file.mk varmod-assign.exp varmod-assign.mk varmod-edge.exp varmod-edge.mk varmod-subst-regex.exp varmod-sysv.exp varmod-sysv.mk Log Message: make: error out on some more syntax errors Previously, these errors only produced a message on stderr. They only affected make's exit status when they were evaluated at parse time, but not when evaluating the commands for a specific target right before executing them. The affected syntax errors are: * invalid regular expressions in the ':C' modifier * out-of-range references to regex groups in the ':C' modifier * unfinished modifiers To generate a diff of this commit: cvs rdiff -u -r1.1124 -r1.1125 src/usr.bin/make/var.c cvs rdiff -u -r1.36 -r1.37 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.32 -r1.33 src/usr.bin/make/unit-tests/moderrs.mk cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/opt-debug-file.exp \ src/usr.bin/make/unit-tests/varmod-subst-regex.exp cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/opt-debug-file.mk cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/varmod-assign.exp cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/varmod-assign.mk cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/varmod-edge.exp \ src/usr.bin/make/unit-tests/varmod-sysv.mk cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/varmod-edge.mk cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/varmod-sysv.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.1124 src/usr.bin/make/var.c:1.1125 --- src/usr.bin/make/var.c:1.1124 Sun Jun 30 13:01:01 2024 +++ src/usr.bin/make/var.c Sun Jun 30 15:21:23 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1124 2024/06/30 13:01:01 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1125 2024/06/30 15:21:23 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -132,7 +132,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1124 2024/06/30 13:01:01 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1125 2024/06/30 15:21:23 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -1567,7 +1567,7 @@ RegexError(int reerr, const regex_t *pat size_t errlen = regerror(reerr, pat, NULL, 0); char *errbuf = bmake_malloc(errlen); regerror(reerr, pat, errbuf, errlen); - Error("%s: %s", str, errbuf); + Parse_Error(PARSE_FATAL, "%s: %s", str, errbuf); free(errbuf); } @@ -1579,7 +1579,7 @@ RegexReplaceBackref(char ref, SepBuf *bu unsigned int n = (unsigned)ref - '0'; if (n >= nsub) - Error("No subexpression \\%u", n); + Parse_Error(PARSE_FATAL, "No subexpression \\%u", n); else if (m[n].rm_so == -1) { if (opts.strict) Error("No match for subexpression \\%u", n); @@ -2230,8 +2230,8 @@ ParseModifierPart( *pp = p; if (*p != end1 && *p != end2) { - Error("Unfinished modifier for \"%s\" ('%c' missing)", - ch->expr->name, end2); + Parse_Error(PARSE_FATAL, + "Unfinished modifier ('%c' missing)", end2); LazyBuf_Done(part); return false; } @@ -2933,7 +2933,8 @@ ApplyModifier_Subst(const char **pp, Mod char delim = (*pp)[1]; if (delim == '\0') { - Error("Missing delimiter for modifier ':S'"); + Parse_Error(PARSE_FATAL, + "Missing delimiter for modifier ':S'"); (*pp)++; return AMR_CLEANUP; } @@ -2982,7 +2983,8 @@ ApplyModifier_Regex(const char **pp, Mod char delim = (*pp)[1]; if (delim == '\0') { - Error("Missing delimiter for :C modifier"); + Parse_Error(PARSE_FATAL, + "Missing delimiter for modifier ':C'"); (*pp)++; return AMR_CLEANUP; } Index: src/usr.bin/make/unit-tests/moderrs.exp diff -u src/usr.bin/make/unit-tests/moderrs.exp:1.36 src/usr.bin/make/unit-tests/moderrs.exp:1.37 --- src/usr.bin/make/unit-tests/moderrs.exp:1.36 Sun Jun 30 14:23:18 2024 +++ src/usr.bin/make/unit-tests/moderrs.exp Sun Jun 30 15:21:24 2024 @@ -1,8 +1,6 @@ -mod-unknown-direct: make: in target "mod-unknown-direct": while evaluating variable "VAR": Unknown modifier "Z" VAR:Z=before--after -mod-unknown-indirect: make: in target "mod-unknown-indirect": while evaluating variable "VAR": Unknown modifier "Z" VAR:Z=before-inner}-after @@ -14,14 +12,12 @@ unclosed-indirect: make: Unclosed expression after indirect modifier, expecting '}' for variable "VAR" VAR:S,V,v,=Thevariable -unfinished-indirect: -make: Unfinished modifier for "VAR" (',' missing) +make: in target "unfinished-indirect": while evaluating variable "VAR": Unfinished modifier (',' missing) VAR:S,V,v= -unfinished-loop: -make: Unfinished modifier for "UNDEF" ('@' missing) +make: in targ
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Jun 30 15:21:24 UTC 2024 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: moderrs.exp moderrs.mk opt-debug-file.exp opt-debug-file.mk varmod-assign.exp varmod-assign.mk varmod-edge.exp varmod-edge.mk varmod-subst-regex.exp varmod-sysv.exp varmod-sysv.mk Log Message: make: error out on some more syntax errors Previously, these errors only produced a message on stderr. They only affected make's exit status when they were evaluated at parse time, but not when evaluating the commands for a specific target right before executing them. The affected syntax errors are: * invalid regular expressions in the ':C' modifier * out-of-range references to regex groups in the ':C' modifier * unfinished modifiers To generate a diff of this commit: cvs rdiff -u -r1.1124 -r1.1125 src/usr.bin/make/var.c cvs rdiff -u -r1.36 -r1.37 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.32 -r1.33 src/usr.bin/make/unit-tests/moderrs.mk cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/opt-debug-file.exp \ src/usr.bin/make/unit-tests/varmod-subst-regex.exp cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/opt-debug-file.mk cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/varmod-assign.exp cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/varmod-assign.mk cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/varmod-edge.exp \ src/usr.bin/make/unit-tests/varmod-sysv.mk cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/varmod-edge.mk cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/varmod-sysv.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: Sun Jun 30 14:23:18 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: moderrs.exp moderrs.mk Log Message: tests/make: replace 'want' comments with 'expect' directives The 'want' comments needed to be cross-checked manually, which was error-prone, as can be seen in the "Unknown modifier" messages that got out of sync. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.31 -r1.32 src/usr.bin/make/unit-tests/moderrs.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/moderrs.exp diff -u src/usr.bin/make/unit-tests/moderrs.exp:1.35 src/usr.bin/make/unit-tests/moderrs.exp:1.36 --- src/usr.bin/make/unit-tests/moderrs.exp:1.35 Sat Apr 20 10:18:55 2024 +++ src/usr.bin/make/unit-tests/moderrs.exp Sun Jun 30 14:23:18 2024 @@ -1,33 +1,26 @@ mod-unknown-direct: -want: Unknown modifier 'Z' make: in target "mod-unknown-direct": while evaluating variable "VAR": Unknown modifier "Z" VAR:Z=before--after mod-unknown-indirect: -want: Unknown modifier 'Z' make: in target "mod-unknown-indirect": while evaluating variable "VAR": Unknown modifier "Z" VAR:Z=before-inner}-after unclosed-direct: -want: Unclosed expression, expecting '}' for modifier "S,V,v," of variable "VAR" with value "Thevariable" make: Unclosed expression, expecting '}' for modifier "S,V,v," of variable "VAR" with value "Thevariable" VAR:S,V,v,=Thevariable unclosed-indirect: -want: Unclosed expression after indirect modifier, expecting '}' for variable "VAR" make: Unclosed expression after indirect modifier, expecting '}' for variable "VAR" VAR:S,V,v,=Thevariable unfinished-indirect: -want: Unfinished modifier for VAR (',' missing) make: Unfinished modifier for "VAR" (',' missing) VAR:S,V,v= unfinished-loop: -want: Unfinished modifier for UNDEF ('@' missing) make: Unfinished modifier for "UNDEF" ('@' missing) -want: Unfinished modifier for UNDEF ('@' missing) make: Unfinished modifier for "UNDEF" ('@' missing) 1 2 3 @@ -38,10 +31,8 @@ make: Unclosed expression, expecting '}' 1}... 2}... 3}... words: -want: Unfinished modifier for UNDEF (']' missing) make: Unfinished modifier for "UNDEF" (']' missing) -want: Unfinished modifier for UNDEF (']' missing) make: Unfinished modifier for "UNDEF" (']' missing) 13= @@ -49,10 +40,8 @@ make: Bad modifier ":[123451234512345123 12345=S,^ok,:S,^3ok,} exclam: -want: Unfinished modifier for VARNAME ('!' missing) make: Unfinished modifier for "VARNAME" ('!' missing) -want: Unfinished modifier for ! ('!' missing) make: Unfinished modifier for "!" ('!' missing) Index: src/usr.bin/make/unit-tests/moderrs.mk diff -u src/usr.bin/make/unit-tests/moderrs.mk:1.31 src/usr.bin/make/unit-tests/moderrs.mk:1.32 --- src/usr.bin/make/unit-tests/moderrs.mk:1.31 Sun Nov 19 22:32:44 2023 +++ src/usr.bin/make/unit-tests/moderrs.mk Sun Jun 30 14:23:18 2024 @@ -1,8 +1,7 @@ -# $NetBSD: moderrs.mk,v 1.31 2023/11/19 22:32:44 rillig Exp $ +# $NetBSD: moderrs.mk,v 1.32 2024/06/30 14:23:18 rillig Exp $ # # various modifier error tests -'= '\'' VAR= TheVariable # in case we have to change it ;-) MOD_UNKN= Z @@ -26,29 +25,29 @@ all: mod-remember-parse all: mod-sysv-parse mod-unknown-direct: print-header print-footer - @echo 'want: Unknown modifier $'Z$'' +# expect: make: in target "mod-unknown-direct": while evaluating variable "VAR": Unknown modifier "Z" @echo 'VAR:Z=before-${VAR:Z}-after' mod-unknown-indirect: print-header print-footer - @echo 'want: Unknown modifier $'Z$'' +# expect: make: in target "mod-unknown-indirect": while evaluating variable "VAR": Unknown modifier "Z" @echo 'VAR:${MOD_UNKN}=before-${VAR:${MOD_UNKN}:inner}-after' unclosed-direct: print-header print-footer - @echo 'want: Unclosed expression, expecting $'}$' for modifier "S,V,v," of variable "VAR" with value "Thevariable"' +# expect: make: Unclosed expression, expecting '}' for modifier "S,V,v," of variable "VAR" with value "Thevariable" @echo VAR:S,V,v,=${VAR:S,V,v, unclosed-indirect: print-header print-footer - @echo 'want: Unclosed expression after indirect modifier, expecting $'}$' for variable "VAR"' +# expect: make: Unclosed expression after indirect modifier, expecting '}' for variable "VAR" @echo VAR:${MOD_TERM},=${VAR:${MOD_S} unfinished-indirect: print-header print-footer - @echo 'want: Unfinished modifier for VAR ($',$' missing)' +# expect: make: Unfinished modifier for "VAR" (',' missing) -@echo "VAR:${MOD_TERM}=${VAR:${MOD_TERM}}" unfinished-loop: print-header print-footer - @echo 'want: Unfinished modifier for UNDEF ($'@$' missing)' +# expect: make: Unfinished modifier for "UNDEF" ('@' missing) @echo ${UNDEF:U1 2 3:@var} - @echo 'want: Unfinished modifier for UNDEF ($'@$' missing)' +# expect: make: Unfinished modifier f
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sun Jun 30 14:23:18 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: moderrs.exp moderrs.mk Log Message: tests/make: replace 'want' comments with 'expect' directives The 'want' comments needed to be cross-checked manually, which was error-prone, as can be seen in the "Unknown modifier" messages that got out of sync. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.31 -r1.32 src/usr.bin/make/unit-tests/moderrs.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: Sun Jun 30 13:01:01 UTC 2024 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: cond-late.exp cond-late.mk varmod-ifelse.exp varmod-ifelse.mk Log Message: make: error out on syntax error in conditions in ':?then:else' modifier The 'Error' function only reports errors but does not affect the exit status, the 'Parse_Error' function does, while providing more details to find the cause of the syntax error. To generate a diff of this commit: cvs rdiff -u -r1.1123 -r1.1124 src/usr.bin/make/var.c cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cond-late.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cond-late.mk cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/varmod-ifelse.exp cvs rdiff -u -r1.29 -r1.30 src/usr.bin/make/unit-tests/varmod-ifelse.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.1123 src/usr.bin/make/var.c:1.1124 --- src/usr.bin/make/var.c:1.1123 Sun Jun 30 11:44:14 2024 +++ src/usr.bin/make/var.c Sun Jun 30 13:01:01 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1123 2024/06/30 11:44:14 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1124 2024/06/30 13:01:01 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -132,7 +132,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1123 2024/06/30 11:44:14 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1124 2024/06/30 13:01:01 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -262,6 +262,9 @@ typedef struct SepBuf { typedef enum { VSK_TARGET, VSK_VARNAME, + VSK_COND, + VSK_COND_THEN, + VSK_COND_ELSE, VSK_EXPR } EvalStackElementKind; @@ -375,11 +378,17 @@ EvalStack_Details(void) buf->len = 0; for (i = 0; i < evalStack.len; i++) { + static const char descr[][42] = { + "in target", + "while evaluating variable", + "while evaluating condition", + "while evaluating then-branch of condition", + "while evaluating else-branch of condition", + "while evaluating", + }; EvalStackElement *elem = evalStack.elems + i; - Buf_AddStr(buf, - elem->kind == VSK_TARGET ? "in target \"" : - elem->kind == VSK_EXPR ? "while evaluating \"" : - "while evaluating variable \""); + Buf_AddStr(buf, descr[elem->kind]); + Buf_AddStr(buf, " \""); Buf_AddStr(buf, elem->str); Buf_AddStr(buf, "\": "); } @@ -3443,6 +3452,7 @@ ApplyModifier_IfElse(const char **pp, Mo CondResult cond_rc = CR_TRUE; /* just not CR_ERROR */ if (Expr_ShouldEval(expr)) { + evalStack.elems[evalStack.len - 1].kind = VSK_COND; cond_rc = Cond_EvalCondition(expr->name); if (cond_rc == CR_TRUE) then_emode = expr->emode; @@ -3450,11 +3460,13 @@ ApplyModifier_IfElse(const char **pp, Mo else_emode = expr->emode; } + evalStack.elems[evalStack.len - 1].kind = VSK_COND_THEN; (*pp)++; /* skip past the '?' */ if (!ParseModifierPart(pp, ':', ':', then_emode, ch, &thenBuf, NULL, NULL)) return AMR_CLEANUP; + evalStack.elems[evalStack.len - 1].kind = VSK_COND_ELSE; if (!ParseModifierPart(pp, ch->endc, ch->endc, else_emode, ch, &elseBuf, NULL, NULL)) { LazyBuf_Done(&thenBuf); @@ -3464,12 +3476,8 @@ ApplyModifier_IfElse(const char **pp, Mo (*pp)--; /* Go back to the ch->endc. */ if (cond_rc == CR_ERROR) { - Substring thenExpr = LazyBuf_Get(&thenBuf); - Substring elseExpr = LazyBuf_Get(&elseBuf); - Error("Bad conditional expression '%s' before '?%.*s:%.*s'", - expr->name, - (int)Substring_Length(thenExpr), thenExpr.start, - (int)Substring_Length(elseExpr), elseExpr.start); + evalStack.elems[evalStack.len - 1].kind = VSK_COND; + Parse_Error(PARSE_FATAL, "Bad condition"); LazyBuf_Done(&thenBuf); LazyBuf_Done(&elseBuf); return AMR_CLEANUP; Index: src/usr.bin/make/unit-tests/cond-late.exp diff -u src/usr.bin/make/unit-tests/cond-late.exp:1.5 src/usr.bin/make/unit-tests/cond-late.exp:1.6 --- src/usr.bin/make/unit-tests/cond-late.exp:1.5 Sun Dec 10 20:12:28 2023 +++ src/usr.bin/make/unit-tests/cond-late.exp Sun Jun 30 13:01:01 2024 @@ -1,4 +1,6 @@ -make: Bad conditional expression ' != "no"' before '?:' +make: "cond-late.mk" line 38: while evaluating variable "VAR": while evaluating condition " != "no"": Bad condition +make: Fatal errors encountered -- cannot continue +make: stopped in unit-tests yes no exit status 0 Index: src/usr.bin/make/unit-tests/cond-late.mk diff -u src/usr.bin/make/unit-tests/cond-late.mk:1.6 src/usr.bin/make/unit-tests/cond-late.mk:1.7 --- src/usr.bin/make/unit-tests/cond-late.mk:1.6 Sun Dec 10 20:12:28 2023 +++ src/usr.bin/make/unit-tests/cond-late.mk Sun Jun 30 13:01:01 2024 @@ -1,4 +1,4 @@ -# $NetBSD: cond-late.mk,v 1.6 2023/12/10 20:12:28 rillig Exp $ +# $NetBSD: cond-late.mk,v 1.7 2024/06/30
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Jun 30 13:01:01 UTC 2024 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: cond-late.exp cond-late.mk varmod-ifelse.exp varmod-ifelse.mk Log Message: make: error out on syntax error in conditions in ':?then:else' modifier The 'Error' function only reports errors but does not affect the exit status, the 'Parse_Error' function does, while providing more details to find the cause of the syntax error. To generate a diff of this commit: cvs rdiff -u -r1.1123 -r1.1124 src/usr.bin/make/var.c cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cond-late.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cond-late.mk cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/varmod-ifelse.exp cvs rdiff -u -r1.29 -r1.30 src/usr.bin/make/unit-tests/varmod-ifelse.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: Sun Jun 30 11:44:14 UTC 2024 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varmod-assign-shell.exp varmod-assign-shell.mk varmod-assign.exp Log Message: make: sync error handling between '!=' assignment and '::!=' modifier To generate a diff of this commit: cvs rdiff -u -r1.1122 -r1.1123 src/usr.bin/make/var.c cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-assign-shell.exp \ src/usr.bin/make/unit-tests/varmod-assign-shell.mk cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/varmod-assign.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
Module Name:src Committed By: rillig Date: Sun Jun 30 11:44:14 UTC 2024 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varmod-assign-shell.exp varmod-assign-shell.mk varmod-assign.exp Log Message: make: sync error handling between '!=' assignment and '::!=' modifier To generate a diff of this commit: cvs rdiff -u -r1.1122 -r1.1123 src/usr.bin/make/var.c cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-assign-shell.exp \ src/usr.bin/make/unit-tests/varmod-assign-shell.mk cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/varmod-assign.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.1122 src/usr.bin/make/var.c:1.1123 --- src/usr.bin/make/var.c:1.1122 Sun Jun 30 11:00:06 2024 +++ src/usr.bin/make/var.c Sun Jun 30 11:44:14 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1122 2024/06/30 11:00:06 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1123 2024/06/30 11:44:14 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -132,7 +132,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1122 2024/06/30 11:00:06 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1123 2024/06/30 11:44:14 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -3557,7 +3557,7 @@ found_op: char *output, *error; output = Cmd_Exec(val.str, &error); if (error != NULL) { - Error("%s", error); + Parse_Error(PARSE_WARNING, "%s", error); free(error); } else Var_Set(scope, expr->name, output); Index: src/usr.bin/make/unit-tests/varmod-assign-shell.exp diff -u src/usr.bin/make/unit-tests/varmod-assign-shell.exp:1.6 src/usr.bin/make/unit-tests/varmod-assign-shell.exp:1.7 --- src/usr.bin/make/unit-tests/varmod-assign-shell.exp:1.6 Sun Jun 30 11:37:21 2024 +++ src/usr.bin/make/unit-tests/varmod-assign-shell.exp Sun Jun 30 11:44:14 2024 @@ -1,10 +1,10 @@ -make: "varmod-assign-shell.mk" line 28: warning: Command "echo output; (exit 13)" exited with status 13 +make: "varmod-assign-shell.mk" line 21: warning: Command "echo output; (exit 13)" exited with status 13 Global: _ = # (empty) Var_Parse: ${ASSIGNED::!=echo output; ${:U(exit 13)}} (eval-keep-dollar-and-undefined) Evaluating modifier ${ASSIGNED::...} on value "previous" (eval-keep-dollar-and-undefined, regular) Modifier part: "echo output; (exit 13)" Capturing the output of command "echo output; (exit 13)" -make: Command "echo output; (exit 13)" exited with status 13 +make: "varmod-assign-shell.mk" line 26: warning: while evaluating variable "ASSIGNED": Command "echo output; (exit 13)" exited with status 13 Result of ${ASSIGNED::!=echo output; ${:U(exit 13)}} is "" (eval-keep-dollar-and-undefined, regular) Global: _ = # (empty) Global: .MAKEFLAGS = -r -k -d v -d Index: src/usr.bin/make/unit-tests/varmod-assign-shell.mk diff -u src/usr.bin/make/unit-tests/varmod-assign-shell.mk:1.6 src/usr.bin/make/unit-tests/varmod-assign-shell.mk:1.7 --- src/usr.bin/make/unit-tests/varmod-assign-shell.mk:1.6 Sun Jun 30 11:37:21 2024 +++ src/usr.bin/make/unit-tests/varmod-assign-shell.mk Sun Jun 30 11:44:14 2024 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-assign-shell.mk,v 1.6 2024/06/30 11:37:21 rillig Exp $ +# $NetBSD: varmod-assign-shell.mk,v 1.7 2024/06/30 11:44:14 rillig Exp $ # # Tests for the variable modifier '::!=', which assigns the output of a shell # command to the variable, but only if the command exited successfully. This @@ -15,20 +15,14 @@ # error message instead of the command that was executed. That's where the # counterintuitive error message 'make: "previous" returned non-zero status' # comes from. -# -# BUGS -# Even though the variable modifier '::!=' produces an error message, -# the exit status of make is still 0. -# -# Having an error message instead of a warning like for the variable -# assignment operator '!=' is another unnecessary inconsistency. DIRECT= previous # expect+1: warning: Command "echo output; (exit 13)" exited with status 13 DIRECT!= echo output; (exit 13) ASSIGNED= previous -.MAKEFLAGS: -dv # to see the actual command +.MAKEFLAGS: -dv # to see the "Capturing" debug output +# expect+1: warning: while evaluating variable "ASSIGNED": Command "echo output; (exit 13)" exited with status 13 _:= ${ASSIGNED::!=echo output; ${:U(exit 13)}} .MAKEFLAGS: -d0 Index: src/usr.bin/make/unit-tests/varmod-assign.exp diff -u src/usr.bin/make/unit-tests/varmod-assign.exp:1.21 src/usr.bin/make/unit-tests/varmod-assign.exp:1.22 --- src/usr.bin/make/unit-tests/varmod-assign.exp:1.21 Sun Jun 30 11:37:21 2024 +++ src/usr.bin/make/unit-tests/varmod-assign.exp Sun Jun 30 11:44:14 2024 @@ -48,7 +48,7 @@ sysv:y make: Unfinished modifier for "ASSIGN" ('}' missing) ok=word -make: Command " echo word; (exit 13) " exited with s
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Jun 30 11:37:21 UTC 2024 Modified Files: src/usr.bin/make: main.c src/usr.bin/make/unit-tests: var-op-shell.exp var-op-shell.mk varmod-assign-shell.exp varmod-assign-shell.mk varmod-assign.exp varmod-assign.mk varmod-shell.exp varmod-shell.mk varmod-sun-shell.exp varmod-sun-shell.mk Log Message: make: add detailed exit status to message for failed sub-commands Several commands communicate via the exit status and not only distinguish between zero and non-zero, so make this information available to ease investigations. The command "false" is not guaranteed to exit with a consistent status, so use "(exit 13)" instead in the tests, to keep these tests portable across different operating systems. The exit status 127 is required for a shell that cannot find a command, so keep that one. To generate a diff of this commit: cvs rdiff -u -r1.624 -r1.625 src/usr.bin/make/main.c cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/var-op-shell.exp \ src/usr.bin/make/unit-tests/varmod-shell.exp cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/var-op-shell.mk \ src/usr.bin/make/unit-tests/varmod-shell.mk cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-assign-shell.exp \ src/usr.bin/make/unit-tests/varmod-assign-shell.mk cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/varmod-assign.exp \ src/usr.bin/make/unit-tests/varmod-assign.mk cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-sun-shell.exp cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-sun-shell.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.624 src/usr.bin/make/main.c:1.625 --- src/usr.bin/make/main.c:1.624 Sun Jun 2 15:31:26 2024 +++ src/usr.bin/make/main.c Sun Jun 30 11:37:21 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.624 2024/06/02 15:31:26 rillig Exp $ */ +/* $NetBSD: main.c,v 1.625 2024/06/30 11:37:21 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -111,7 +111,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.624 2024/06/02 15:31:26 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.625 2024/06/30 11:37:21 rillig Exp $"); #if defined(MAKE_NATIVE) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -1784,10 +1784,15 @@ Cmd_Exec(const char *cmd, char **error) if (WIFSIGNALED(status)) *error = str_concat3("\"", cmd, "\" exited on a signal"); - else if (WEXITSTATUS(status) != 0) - *error = str_concat3( - "\"", cmd, "\" returned non-zero status"); - else if (saved_errno != 0) + else if (WEXITSTATUS(status) != 0) { + Buffer errBuf; + Buf_Init(&errBuf); + Buf_AddStr(&errBuf, "Command \""); + Buf_AddStr(&errBuf, cmd); + Buf_AddStr(&errBuf, "\" exited with status "); + Buf_AddInt(&errBuf, WEXITSTATUS(status)); + *error = Buf_DoneData(&errBuf); + } else if (saved_errno != 0) *error = str_concat3( "Couldn't read shell's output for \"", cmd, "\""); else Index: src/usr.bin/make/unit-tests/var-op-shell.exp diff -u src/usr.bin/make/unit-tests/var-op-shell.exp:1.6 src/usr.bin/make/unit-tests/var-op-shell.exp:1.7 --- src/usr.bin/make/unit-tests/var-op-shell.exp:1.6 Thu Jun 1 20:56:35 2023 +++ src/usr.bin/make/unit-tests/var-op-shell.exp Sun Jun 30 11:37:21 2024 @@ -1,8 +1,8 @@ -make: "var-op-shell.mk" line 32: warning: "echo "failed"; false" returned non-zero status -make: "var-op-shell.mk" line 39: warning: "false" returned non-zero status +make: "var-op-shell.mk" line 32: warning: Command "echo "failed"; (exit 13)" exited with status 13 +make: "var-op-shell.mk" line 39: warning: Command "exit 13" exited with status 13 make: "var-op-shell.mk" line 62: warning: "kill $$" exited on a signal /bin/no/such/command: not found -make: "var-op-shell.mk" line 69: warning: "/bin/no/such/command" returned non-zero status +make: "var-op-shell.mk" line 69: warning: Command "/bin/no/such/command" exited with status 127 stderr Capturing the output of command "echo ''" Global: OUTPUT = Index: src/usr.bin/make/unit-tests/varmod-shell.exp diff -u src/usr.bin/make/unit-tests/varmod-shell.exp:1.6 src/usr.bin/make/unit-tests/varmod-shell.exp:1.7 --- src/usr.bin/make/unit-tests/varmod-shell.exp:1.6 Sun Jun 30 11:00:06 2024 +++ src/usr.bin/make/unit-tests/varmod-shell.exp Sun Jun 30 11:37:21 2024 @@ -1,12 +1,12 @@ -make: "varmod-shell.mk" line 25: warning: while evaluating "${:!echo word; false!} != "word"": "echo word; false" returned non-zero status -make: "varmod-shell.mk" line 29: warning: while evaluating "${:Uprevious value:!echo word; false!} != "word"": "echo word; false" returned non-zero status +make: "varmod-shell.mk" line 25: warning: while evaluating "${:!echo word; (exit 13)!}
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Jun 30 11:37:21 UTC 2024 Modified Files: src/usr.bin/make: main.c src/usr.bin/make/unit-tests: var-op-shell.exp var-op-shell.mk varmod-assign-shell.exp varmod-assign-shell.mk varmod-assign.exp varmod-assign.mk varmod-shell.exp varmod-shell.mk varmod-sun-shell.exp varmod-sun-shell.mk Log Message: make: add detailed exit status to message for failed sub-commands Several commands communicate via the exit status and not only distinguish between zero and non-zero, so make this information available to ease investigations. The command "false" is not guaranteed to exit with a consistent status, so use "(exit 13)" instead in the tests, to keep these tests portable across different operating systems. The exit status 127 is required for a shell that cannot find a command, so keep that one. To generate a diff of this commit: cvs rdiff -u -r1.624 -r1.625 src/usr.bin/make/main.c cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/var-op-shell.exp \ src/usr.bin/make/unit-tests/varmod-shell.exp cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/var-op-shell.mk \ src/usr.bin/make/unit-tests/varmod-shell.mk cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-assign-shell.exp \ src/usr.bin/make/unit-tests/varmod-assign-shell.mk cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/varmod-assign.exp \ src/usr.bin/make/unit-tests/varmod-assign.mk cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-sun-shell.exp cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-sun-shell.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Jun 30 11:00:06 UTC 2024 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varmod-shell.exp varmod-shell.mk varmod-sun-shell.exp varmod-sun-shell.mk Log Message: make: add more context to "returned non-zero status" message Previously, this message was an "error" but had no influence on the exit status, so make it a warning instead. In the seldom used -W mode that treats warnings as errors, this change influences the exit status. To generate a diff of this commit: cvs rdiff -u -r1.1121 -r1.1122 src/usr.bin/make/var.c cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-shell.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-shell.mk cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-sun-shell.exp cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-sun-shell.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.1121 src/usr.bin/make/var.c:1.1122 --- src/usr.bin/make/var.c:1.1121 Sat Jun 15 22:06:30 2024 +++ src/usr.bin/make/var.c Sun Jun 30 11:00:06 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1121 2024/06/15 22:06:30 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1122 2024/06/30 11:00:06 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -132,7 +132,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1121 2024/06/15 22:06:30 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1122 2024/06/30 11:00:06 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -2632,8 +2632,7 @@ ApplyModifier_ShellCommand(const char ** output = Cmd_Exec(cmd.str, &error); Expr_SetValueOwn(expr, output); if (error != NULL) { - /* XXX: why still return AMR_OK? */ - Error("%s", error); + Parse_Error(PARSE_WARNING, "%s", error); free(error); } } else @@ -3746,7 +3745,7 @@ ApplyModifier_SunShell(const char **pp, char *output, *error; output = Cmd_Exec(Expr_Str(expr), &error); if (error != NULL) { - Error("%s", error); + Parse_Error(PARSE_WARNING, "%s", error); free(error); } Expr_SetValueOwn(expr, output); Index: src/usr.bin/make/unit-tests/varmod-shell.exp diff -u src/usr.bin/make/unit-tests/varmod-shell.exp:1.5 src/usr.bin/make/unit-tests/varmod-shell.exp:1.6 --- src/usr.bin/make/unit-tests/varmod-shell.exp:1.5 Sat Mar 26 14:34:07 2022 +++ src/usr.bin/make/unit-tests/varmod-shell.exp Sun Jun 30 11:00:06 2024 @@ -1,11 +1,11 @@ -make: "echo word; false" returned non-zero status -make: "echo word; false" returned non-zero status +make: "varmod-shell.mk" line 25: warning: while evaluating "${:!echo word; false!} != "word"": "echo word; false" returned non-zero status +make: "varmod-shell.mk" line 29: warning: while evaluating "${:Uprevious value:!echo word; false!} != "word"": "echo word; false" returned non-zero status Global: _ = # (empty) Var_Parse: ${:!echo word; ${:Ufalse}!} (eval-keep-dollar-and-undefined) Evaluating modifier ${:!...} on value "" (eval-keep-dollar-and-undefined, undefined) Modifier part: "echo word; false" Capturing the output of command "echo word; false" -make: "echo word; false" returned non-zero status +make: "varmod-shell.mk" line 36: warning: while evaluating "${:!echo word; ${:Ufalse}!}": "echo word; false" returned non-zero status Result of ${:!echo word; ${:Ufalse}!} is "word" (eval-keep-dollar-and-undefined, defined) Global: _ = word Global: .MAKEFLAGS = -r -k -d v -d Index: src/usr.bin/make/unit-tests/varmod-shell.mk diff -u src/usr.bin/make/unit-tests/varmod-shell.mk:1.7 src/usr.bin/make/unit-tests/varmod-shell.mk:1.8 --- src/usr.bin/make/unit-tests/varmod-shell.mk:1.7 Mon Jan 10 20:32:29 2022 +++ src/usr.bin/make/unit-tests/varmod-shell.mk Sun Jun 30 11:00:06 2024 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-shell.mk,v 1.7 2022/01/10 20:32:29 rillig Exp $ +# $NetBSD: varmod-shell.mk,v 1.8 2024/06/30 11:00:06 rillig Exp $ # # Tests for the ':!cmd!' variable modifier, which runs the shell command # given by the variable modifier and returns its output. @@ -21,16 +21,20 @@ # Between 2000-04-29 and 2020-11-17, the error message mentioned the previous # value of the expression (which is usually an empty string) instead of the # command that was executed. +# expect+1: warning: while evaluating "${:!echo word; false!} != "word"": "echo word; false" returned non-zero status .if ${:!echo word; false!} != "word" . error .endif +# expect+1: warning: while evaluating "${:Uprevious value:!echo word; false!} != "word"": "echo word; false" returned non-zero status .if ${:Uprevious value:!echo word; false!} != "word" . error .endif -.MAKEFLAGS: -dv # to see the actual command +.MAKEFLAGS: -dv # to see the "Capturing" debug output +# expect+1: warning: while evalu
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Jun 30 11:00:06 UTC 2024 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varmod-shell.exp varmod-shell.mk varmod-sun-shell.exp varmod-sun-shell.mk Log Message: make: add more context to "returned non-zero status" message Previously, this message was an "error" but had no influence on the exit status, so make it a warning instead. In the seldom used -W mode that treats warnings as errors, this change influences the exit status. To generate a diff of this commit: cvs rdiff -u -r1.1121 -r1.1122 src/usr.bin/make/var.c cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-shell.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-shell.mk cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-sun-shell.exp cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varmod-sun-shell.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Jun 28 15:20:57 UTC 2024 Modified Files: src/usr.bin/make: job.c job.h Log Message: make: reduce usage of the UNCONST hack To generate a diff of this commit: cvs rdiff -u -r1.477 -r1.478 src/usr.bin/make/job.c cvs rdiff -u -r1.78 -r1.79 src/usr.bin/make/job.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Fri Jun 28 15:20:57 UTC 2024 Modified Files: src/usr.bin/make: job.c job.h Log Message: make: reduce usage of the UNCONST hack To generate a diff of this commit: cvs rdiff -u -r1.477 -r1.478 src/usr.bin/make/job.c cvs rdiff -u -r1.78 -r1.79 src/usr.bin/make/job.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.477 src/usr.bin/make/job.c:1.478 --- src/usr.bin/make/job.c:1.477 Tue Jun 25 05:18:38 2024 +++ src/usr.bin/make/job.c Fri Jun 28 15:20:57 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.477 2024/06/25 05:18:38 rillig Exp $ */ +/* $NetBSD: job.c,v 1.478 2024/06/28 15:20:57 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -141,7 +141,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.477 2024/06/25 05:18:38 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.478 2024/06/28 15:20:57 rillig Exp $"); /* * A shell defines how the commands are run. All commands for a target are @@ -399,7 +399,7 @@ static Shell shells[] = { * It is set by the Job_ParseShell function. */ static Shell *shell = &shells[DEFSHELL_INDEX]; -const char *shellPath = NULL; /* full pathname of executable image */ +char *shellPath; /* full pathname of executable image */ const char *shellName = NULL; /* last component of shellPath */ char *shellErrFlag = NULL; static char *shell_freeIt = NULL; /* Allocated memory for custom .SHELL */ @@ -2473,13 +2473,13 @@ Job_ParseShell(char *line) * Shell_Init has already been called! * Do it again. */ -free(UNCONST(shellPath)); +free(shellPath); shellPath = NULL; Shell_Init(); } } } else { - free(UNCONST(shellPath)); + free(shellPath); shellPath = bmake_strdup(path); shellName = newShell.name != NULL ? newShell.name : str_basename(path); Index: src/usr.bin/make/job.h diff -u src/usr.bin/make/job.h:1.78 src/usr.bin/make/job.h:1.79 --- src/usr.bin/make/job.h:1.78 Tue Dec 19 19:33:39 2023 +++ src/usr.bin/make/job.h Fri Jun 28 15:20:57 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: job.h,v 1.78 2023/12/19 19:33:39 rillig Exp $ */ +/* $NetBSD: job.h,v 1.79 2024/06/28 15:20:57 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -179,7 +179,7 @@ typedef struct Job { #endif } Job; -extern const char *shellPath; +extern char *shellPath; extern const char *shellName; extern char *shellErrFlag;
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Tue Jun 25 05:18:39 UTC 2024 Modified Files: src/usr.bin/make: job.c test-variants.mk Log Message: make: fix invalid-free for custom shell definitions Don't try to free a pointer that is taken from the middle of a string, in this case a shell specification. To generate a diff of this commit: cvs rdiff -u -r1.476 -r1.477 src/usr.bin/make/job.c cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/test-variants.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.476 src/usr.bin/make/job.c:1.477 --- src/usr.bin/make/job.c:1.476 Sat Jun 15 20:02:45 2024 +++ src/usr.bin/make/job.c Tue Jun 25 05:18:38 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.476 2024/06/15 20:02:45 rillig Exp $ */ +/* $NetBSD: job.c,v 1.477 2024/06/25 05:18:38 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -141,7 +141,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.476 2024/06/15 20:02:45 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.477 2024/06/25 05:18:38 rillig Exp $"); /* * A shell defines how the commands are run. All commands for a target are @@ -2137,7 +2137,7 @@ InitShellNameAndPath(void) #ifdef DEFSHELL_CUSTOM if (shellName[0] == '/') { - shellPath = shellName; + shellPath = bmake_strdup(shellName); shellName = str_basename(shellPath); return; } @@ -2480,7 +2480,7 @@ Job_ParseShell(char *line) } } else { free(UNCONST(shellPath)); - shellPath = path; + shellPath = bmake_strdup(path); shellName = newShell.name != NULL ? newShell.name : str_basename(path); if (!fullSpec) { Index: src/usr.bin/make/test-variants.mk diff -u src/usr.bin/make/test-variants.mk:1.8 src/usr.bin/make/test-variants.mk:1.9 --- src/usr.bin/make/test-variants.mk:1.8 Sat May 25 00:00:25 2024 +++ src/usr.bin/make/test-variants.mk Tue Jun 25 05:18:38 2024 @@ -1,4 +1,4 @@ -# $NetBSD: test-variants.mk,v 1.8 2024/05/25 00:00:25 rillig Exp $ +# $NetBSD: test-variants.mk,v 1.9 2024/06/25 05:18:38 rillig Exp $ # # Build several variants of make and run the tests on them. # @@ -200,8 +200,15 @@ CFLAGS.gcc-warn+= -Wno-error=duplicated- .for shell in /usr/pkg/bin/bash /usr/pkg/bin/dash . if exists(${shell}) -TESTS+= ${shell:T} +TESTS+= ${shell:T} CPPFLAGS.${shell:T}= -DDEFSHELL_CUSTOM="\"${shell}\"" + +.for name in ${shell:T}-sanitize +TESTS+= ${name} +ENV.${name}= MKSANITIZER=yes LIMIT_RESOURCES=: +CPPFLAGS.${name}= -DDEFSHELL_CUSTOM="\"${shell}\"" -DCLEANUP +CFLAGS.${name}= -ggdb -O0 +.endfor . endif .endfor