diff options
| author | Simon J. Gerraty <sjg@FreeBSD.org> | 2025-04-19 13:53:59 -0700 |
|---|---|---|
| committer | Simon J. Gerraty <sjg@FreeBSD.org> | 2025-04-19 13:53:59 -0700 |
| commit | 284d1f7d496806b18558ab55e4654fd5e96d6a3e (patch) | |
| tree | 34c26b43e9c0301e845bc296a229845401e93787 | |
| parent | 397f57656d61ec830291c670fb8e33b18bf36ce9 (diff) | |
Import bmake-20250414vendor/NetBSD/bmake/20250414
Intersting/relevant changes since bmake-20250308
ChangeLog since bmake-20250308
2025-04-14 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20250414
Merge with NetBSD make, pick up
o job.c: clean up job and output handling
o parse.c: after entering POSIX mode, don't leave it again
2025-04-11 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20250411
Merge with NetBSD make, pick up
o convert more messages to file:line: format
o for.c: condense code for parsing variable names in .for loops
2025-04-10 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20250410
Merge with NetBSD make, pick up
o cond.c: remove redundant error counter when parsing a condition
2025-04-04 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20250404
Merge with NetBSD make, pick up
o make.1: better document meta mode.
o var.c: fix error message for undefined variable in conditional.
2025-03-30 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20250330
Merge with NetBSD make, pick up
o in POSIX compatability mode, give preference to sysV style modifiers.
o in stack trace with details and includes, list the current file
o parse.c: report file location in more common file:line: format.
o var.c: simplify error handling for unknown modifiers
let the ":O" and ":t" modifiers fall back to the ":from=to" modifier
stop parsing after seeing an unknown modifier in an expression
fix error message for unclosed expression and invalid :[...]
add details to errors about ::= modifier
add details about indirect modifiers to the stack traces
in stack traces from target commands, add the command level
2025-03-23 Simon J Gerraty <sjg@beast.crufty.net>
* VERSION (_MAKE_VERSION): 20250323
Merge with NetBSD make, pick up
o var.c: just ignore attempts to override a read-only global with
the same value.
mk/ChangeLog since bmake-20250308
2025-04-18 Simon J Gerraty <sjg@beast.crufty.net>
* init.mk: include Skipping ${RELDIR} when _SKIP_BUILD is not empty.
2025-04-14 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20250414
* init.mk: check ONLY_*_LIST and NOT_*_LIST for SKIP_BUILD_VAR_LIST
to set _SKIP_BUILD
* genfiles.mk: add FILTER support
* rst2htm.mk: latest docutils drops .py extensions
2025-03-26 Simon J Gerraty <sjg@beast.crufty.net>
* install-mk (MK_VERSION): 20250326
* auto.obj.mk: fix and simplify handling of relative __objdir,
convert it to absolute before checking against .OBJDIR
191 files changed, 2021 insertions, 1463 deletions
diff --git a/ChangeLog b/ChangeLog index 15a58e2a0924..1ec90b7bccc8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,52 @@ +2025-04-14 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION (_MAKE_VERSION): 20250414 + Merge with NetBSD make, pick up + o job.c: clean up job and output handling + o parse.c: after entering POSIX mode, don't leave it again + +2025-04-11 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION (_MAKE_VERSION): 20250411 + Merge with NetBSD make, pick up + o convert more messages to file:line: format + o for.c: condense code for parsing variable names in .for loops + +2025-04-10 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION (_MAKE_VERSION): 20250410 + Merge with NetBSD make, pick up + o cond.c: remove redundant error counter when parsing a condition + +2025-04-04 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION (_MAKE_VERSION): 20250404 + Merge with NetBSD make, pick up + o make.1: better document meta mode. + o var.c: fix error message for undefined variable in conditional. + +2025-03-30 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION (_MAKE_VERSION): 20250330 + Merge with NetBSD make, pick up + o in POSIX compatability mode, give preference to sysV style modifiers. + o in stack trace with details and includes, list the current file + o parse.c: report file location in more common file:line: format. + o var.c: simplify error handling for unknown modifiers + let the ":O" and ":t" modifiers fall back to the ":from=to" modifier + stop parsing after seeing an unknown modifier in an expression + fix error message for unclosed expression and invalid :[...] + add details to errors about ::= modifier + add details about indirect modifiers to the stack traces + in stack traces from target commands, add the command level + +2025-03-23 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION (_MAKE_VERSION): 20250323 + Merge with NetBSD make, pick up + o var.c: just ignore attempts to override a read-only global with + the same value. + 2025-03-08 Simon J Gerraty <sjg@beast.crufty.net> * bsd.after-import.mk: by default generate makefiles @@ -555,6 +555,12 @@ unit-tests/parse.exp unit-tests/parse.mk unit-tests/phony-end.exp unit-tests/phony-end.mk +unit-tests/posix-execution.exp +unit-tests/posix-execution.mk +unit-tests/posix-expansion.exp +unit-tests/posix-expansion.mk +unit-tests/posix-varassign.exp +unit-tests/posix-varassign.mk unit-tests/posix.exp unit-tests/posix.mk unit-tests/posix1.exp @@ -1,2 +1,2 @@ # keep this compatible with sh and make -_MAKE_VERSION=20250308 +_MAKE_VERSION=20250414 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.381 2024/11/14 19:30:13 sjg Exp $ +.\" $NetBSD: make.1,v 1.384 2025/04/04 18:36:47 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 November 14, 2024 +.Dd April 4, 2025 .Dt BMAKE 1 .Os .Sh NAME @@ -1087,11 +1087,61 @@ Puts into .Dq meta mode, where meta files are created for each target -to capture the command run, the output generated, and if +to capture the commands run, the output generated, and if .Xr filemon 4 is available, the system calls which are of interest to .Nm . The captured output can be useful when diagnosing errors. +.Pp +.Nm +will use the information in the meta file to help determine if +a target is out-of-date when the normal dependency rules +indicate it is not. +.Pp +First, +the commands to be executed, +will be compared to those captured previously, +if any differ, +the target is out-of-date. +.Pp +This allows for a huge improvement in the reliability +and efficiency of update builds. +It is no longer necessary for targets to depend on makefiles +just in-case they set a variable that might be relevant. +Mechanisms such as +.Va .MAKE.META.CMP_FILTER +and +.Ic .NOMETA_CMP , +allow limiting or disabling that comparison on a per target basis. +A reference to the variable +.Va .OODATE +can be leveraged to block comparison of certain commands. +For example: +.Ql ${.OODATE:M} +will expand to nothing and have no impact on the target, +its side-effect though, +will be to prevent comparison of any command line it appears on. +For documentation purposes +.Ql ${.OODATE:MNOMETA_CMP} +is useful. +.Pp +If necessary, +.Nm +will then use the information captured by +.Xr filemon 4 , +to check the modification time of any file used in generating +the target, +if any is newer, +the target is out-of-date. +.Pp +Such deep inspection can easily lead to cases where a target is +.Em always +considered out-of-date, which is why +.Va .MAKE.META.IGNORE_FILTER , +.Va .MAKE.META.IGNORE_PATHS +and +.Va .MAKE.META.IGNORE_PATTERNS , +are provided to limit that inspection when necessary. .It Cm curdirOk= Ns Ar bf By default, .Nm @@ -2536,6 +2586,8 @@ is run with the flag, only .Ql posix.mk contributes to the default rules. +In POSIX-compatible mode, the AT&T System V UNIX style substitution +modifier is checked first rather than as a fallback. .It Ic .PRECIOUS Apply the .Ic .PRECIOUS diff --git a/bmake.cat1 b/bmake.cat1 index 7e6f25524a05..e1340e1c78e0 100644 --- a/bmake.cat1 +++ b/bmake.cat1 @@ -709,11 +709,44 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS ccoommppaatt Like --BB, puts bbmmaakkee into "compat" mode. mmeettaa Puts bbmmaakkee into "meta" mode, where meta files are created - for each target to capture the command run, the output + for each target to capture the commands run, the output generated, and if filemon(4) is available, the system calls which are of interest to bbmmaakkee. The captured output can be useful when diagnosing errors. + bbmmaakkee will use the information in the meta file to help + determine if a target is out-of-date when the normal + dependency rules indicate it is not. + + First, the commands to be executed, will be compared to + those captured previously, if any differ, the target is + out-of-date. + + This allows for a huge improvement in the reliability and + efficiency of update builds. It is no longer necessary + for targets to depend on makefiles just in-case they set + a variable that might be relevant. Mechanisms such as + _._M_A_K_E_._M_E_T_A_._C_M_P___F_I_L_T_E_R and ..NNOOMMEETTAA__CCMMPP, allow limiting or + disabling that comparison on a per target basis. A + reference to the variable _._O_O_D_A_T_E can be leveraged to + block comparison of certain commands. For example: + `${.OODATE:M}' will expand to nothing and have no impact + on the target, its side-effect though, will be to prevent + comparison of any command line it appears on. For + documentation purposes `${.OODATE:MNOMETA_CMP}' is + useful. + + If necessary, bbmmaakkee will then use the information + captured by filemon(4), to check the modification time of + any file used in generating the target, if any is newer, + the target is out-of-date. + + Such deep inspection can easily lead to cases where a + target is _a_l_w_a_y_s considered out-of-date, which is why + _._M_A_K_E_._M_E_T_A_._I_G_N_O_R_E___F_I_L_T_E_R, _._M_A_K_E_._M_E_T_A_._I_G_N_O_R_E___P_A_T_H_S and + _._M_A_K_E_._M_E_T_A_._I_G_N_O_R_E___P_A_T_T_E_R_N_S, are provided to limit that + inspection when necessary. + ccuurrddiirrOOkk==_b_f By default, bbmmaakkee does not create _._m_e_t_a files in `_._C_U_R_D_I_R'. This can be overridden by setting _b_f to a @@ -1618,7 +1651,9 @@ SSPPEECCIIAALL TTAARRGGEETTSS variable _%_P_O_S_I_X is set to the value `1003.2' and the makefile `<posix.mk>' is included if it exists, to provide POSIX- compatible default rules. If bbmmaakkee is run with the --rr flag, - only `posix.mk' contributes to the default rules. + only `posix.mk' contributes to the default rules. In POSIX- + compatible mode, the AT&T System V UNIX style substitution + modifier is checked first rather than as a fallback. ..PPRREECCIIOOUUSS Apply the ..PPRREECCIIOOUUSS attribute to any specified sources. If no @@ -1793,4 +1828,4 @@ BBUUGGSS attempt to suppress a cascade of unnecessary errors, can result in a seemingly unexplained `*** Error code 6' -FreeBSD 14.1-RELEASE-p7 November 14, 2024 FreeBSD 14.1-RELEASE-p7 +FreeBSD 14.2-RELEASE-p1 April 4, 2025 FreeBSD 14.2-RELEASE-p1 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.371 2025/01/11 21:21:33 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.372 2025/04/10 21:41:35 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.371 2025/01/11 21:21:33 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.372 2025/04/10 21:41:35 rillig Exp $"); /* * Conditional expressions conform to this grammar: @@ -162,12 +162,6 @@ typedef struct CondParser { const char *p; /* The remaining condition to parse */ Token curr; /* Single push-back token used in parsing */ - - /* - * Whether an error message has already been printed for this - * condition. - */ - bool printedError; } CondParser; static CondResult CondParser_Or(CondParser *, bool); @@ -243,7 +237,7 @@ ParseWord(const char **pp, bool doEval) /* Parse the function argument, including the surrounding parentheses. */ static char * -ParseFuncArg(CondParser *par, const char **pp, bool doEval, const char *func) +ParseFuncArg(const char **pp, bool doEval, const char *func) { const char *p = *pp, *argStart, *argEnd; char *res; @@ -263,7 +257,6 @@ ParseFuncArg(CondParser *par, const char **pp, bool doEval, const char *func) Parse_Error(PARSE_FATAL, "Missing ')' after argument '%.*s' for '%.*s'", (int)(argEnd - argStart), argStart, len, func); - par->printedError = true; free(res); return NULL; } @@ -531,15 +524,13 @@ EvalCompareNum(double lhs, ComparisonOp op, double rhs) } static Token -EvalCompareStr(CondParser *par, const char *lhs, - ComparisonOp op, const char *rhs) +EvalCompareStr(const char *lhs, ComparisonOp op, const char *rhs) { if (op != EQ && op != NE) { Parse_Error(PARSE_FATAL, "Comparison with '%s' requires both operands " "'%s' and '%s' to be numeric", opname[op], lhs, rhs); - par->printedError = true; return TOK_ERROR; } @@ -549,7 +540,7 @@ EvalCompareStr(CondParser *par, const char *lhs, /* Evaluate a comparison, such as "${VAR} == 12345". */ static Token -EvalCompare(CondParser *par, const char *lhs, bool lhsQuoted, +EvalCompare(const char *lhs, bool lhsQuoted, ComparisonOp op, const char *rhs, bool rhsQuoted) { double left, right; @@ -558,7 +549,7 @@ EvalCompare(CondParser *par, const char *lhs, bool lhsQuoted, if (TryParseNumber(lhs, &left) && TryParseNumber(rhs, &right)) return ToToken(EvalCompareNum(left, op, right)); - return EvalCompareStr(par, lhs, op, rhs); + return EvalCompareStr(lhs, op, rhs); } static bool @@ -613,14 +604,13 @@ CondParser_Comparison(CondParser *par, bool doEval) if (par->p[0] == '\0') { Parse_Error(PARSE_FATAL, "Missing right-hand side of operator '%s'", opname[op]); - par->printedError = true; goto done_lhs; } rhs = CondParser_Leaf(par, doEval, true, &rhsQuoted); t = rhs.str == NULL ? TOK_ERROR : !doEval ? TOK_FALSE - : EvalCompare(par, lhs.str, lhsQuoted, op, rhs.str, rhsQuoted); + : EvalCompare(lhs.str, lhsQuoted, op, rhs.str, rhsQuoted); FStr_Done(&rhs); done_lhs: @@ -689,7 +679,7 @@ CondParser_FuncCall(CondParser *par, bool doEval, Token *out_token) if (*p != '(') return false; - arg = ParseFuncArg(par, &p, doEval, fn_name); + arg = ParseFuncArg(&p, doEval, fn_name); *out_token = ToToken(doEval && arg != NULL && arg[0] != '\0' && fn(arg)); free(arg); @@ -779,7 +769,6 @@ CondParser_Token(CondParser *par, bool doEval) par->p++; else { Parse_Error(PARSE_FATAL, "Unknown operator '|'"); - par->printedError = true; return TOK_ERROR; } return TOK_OR; @@ -790,7 +779,6 @@ CondParser_Token(CondParser *par, bool doEval) par->p++; else { Parse_Error(PARSE_FATAL, "Unknown operator '&'"); - par->printedError = true; return TOK_ERROR; } return TOK_AND; @@ -929,15 +917,13 @@ CondEvalExpression(const char *cond, bool plain, par.leftUnquotedOK = leftUnquotedOK; par.p = cond; par.curr = TOK_NONE; - par.printedError = false; DEBUG1(COND, "CondParser_Eval: %s\n", par.p); rval = CondParser_Or(&par, true); if (par.curr != TOK_EOF) rval = CR_ERROR; - if (rval == CR_ERROR && eprint && !par.printedError - && parseErrors == parseErrorsBefore) + if (rval == CR_ERROR && eprint && parseErrors == parseErrorsBefore) Parse_Error(PARSE_FATAL, "Malformed conditional '%s'", cond); return rval; @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.295 2024/07/07 07:50:57 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.296 2025/04/11 17:21:31 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.295 2024/07/07 07:50:57 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.296 2025/04/11 17:21:31 rillig Exp $"); /* * A search path is a list of CachedDir structures. A CachedDir has in it the @@ -1365,7 +1365,7 @@ ResolveMovedDepends(GNode *gn) gn->path = bmake_strdup(fullName); if (!Job_RunTarget(".STALE", gn->fname)) fprintf(stdout, /* XXX: Why stdout? */ - "%s: %s, %u: ignoring stale %s for %s, found %s\n", + "%s: %s:%u: ignoring stale %s for %s, found %s\n", progname, gn->fname, gn->lineno, makeDependfile, gn->name, fullName); @@ -1,4 +1,4 @@ -/* $NetBSD: for.c,v 1.182 2024/06/07 18:57:30 rillig Exp $ */ +/* $NetBSD: for.c,v 1.184 2025/04/11 18:08:17 rillig Exp $ */ /* * Copyright (c) 1992, The Regents of the University of California. @@ -58,7 +58,7 @@ #include "make.h" /* "@(#)for.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: for.c,v 1.182 2024/06/07 18:57:30 rillig Exp $"); +MAKE_RCSID("$NetBSD: for.c,v 1.184 2025/04/11 18:08:17 rillig Exp $"); typedef struct ForLoop { @@ -148,38 +148,23 @@ IsValidInVarname(char c) static void ForLoop_ParseVarnames(ForLoop *f, const char **pp) { - const char *p = *pp; + const char *p = *pp, *start; for (;;) { - size_t len; - cpp_skip_whitespace(&p); if (*p == '\0') { Parse_Error(PARSE_FATAL, "missing `in' in for"); - while (f->vars.len > 0) - free(*(char **)Vector_Pop(&f->vars)); - return; + goto cleanup; } - for (len = 0; p[len] != '\0' && !ch_isspace(p[len]); len++) { - if (!IsValidInVarname(p[len])) { - Parse_Error(PARSE_FATAL, - "invalid character '%c' " - "in .for loop variable name", - p[len]); - while (f->vars.len > 0) - free(*(char **)Vector_Pop(&f->vars)); - return; - } - } + for (start = p; *p != '\0' && !ch_isspace(*p); p++) + if (!IsValidInVarname(*p)) + goto invalid_variable_name; - if (len == 2 && p[0] == 'i' && p[1] == 'n') { - p += 2; + if (p - start == 2 && memcmp(start, "in", 2) == 0) break; - } - *(char **)Vector_Push(&f->vars) = bmake_strldup(p, len); - p += len; + *(char **)Vector_Push(&f->vars) = bmake_strsedup(start, p); } if (f->vars.len == 0) { @@ -188,19 +173,27 @@ ForLoop_ParseVarnames(ForLoop *f, const char **pp) } *pp = p; + return; + +invalid_variable_name: + Parse_Error(PARSE_FATAL, + "invalid character '%c' in .for loop variable name", *p); +cleanup: + while (f->vars.len > 0) + free(*(char **)Vector_Pop(&f->vars)); } static bool ForLoop_ParseItems(ForLoop *f, const char *p) { char *items; + int parseErrorsBefore = parseErrors; cpp_skip_whitespace(&p); items = Var_Subst(p, SCOPE_GLOBAL, VARE_EVAL); - /* TODO: handle errors */ - - f->items = Substring_Words(items, false); + f->items = Substring_Words( + parseErrors == parseErrorsBefore ? items : "", false); free(items); if (f->items.len == 1 && Substring_IsEmpty(f->items.words[0])) @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.489 2025/03/08 20:15:03 rillig Exp $ */ +/* $NetBSD: job.c,v 1.492 2025/04/12 13:00:21 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -151,7 +151,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.489 2025/03/08 20:15:03 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.492 2025/04/12 13:00:21 rillig Exp $"); /* * A shell defines how the commands are run. All commands for a target are @@ -411,7 +411,7 @@ static char *shell_freeIt = NULL; /* Allocated memory for custom .SHELL */ static Job *job_table; /* The structures that describe them */ static Job *job_table_end; /* job_table + maxJobs */ -static unsigned int wantToken; +static bool wantToken; static bool lurking_children = false; static bool make_suspended = false; /* Whether we've seen a SIGTSTP (etc) */ @@ -424,7 +424,6 @@ static Job **jobByFdIndex = NULL; static nfds_t fdsLen = 0; static void watchfd(Job *); static void clearfd(Job *); -static bool readyfd(Job *); static char *targPrefix = NULL; /* To identify a job change in the output. */ static Job tokenWaitJob; /* token wait pseudo-job */ @@ -1234,10 +1233,7 @@ JobFinish (Job *job, WAIT_T status) if (aborting == ABORT_ERROR && jobTokensRunning == 0) { if (shouldDieQuietly(NULL, -1)) { - /* - * TODO: better clean up properly, to avoid killing - * child processes by SIGPIPE. - */ + Job_Wait(); exit(2); } Fatal("%d error%s", job_errors, job_errors == 1 ? "" : "s"); @@ -1371,7 +1367,7 @@ Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...)) if (gn->flags.fromDepend) { if (!Job_RunTarget(".STALE", gn->fname)) fprintf(stdout, - "%s: %s, %u: ignoring stale %s for %s\n", + "%s: %s:%u: ignoring stale %s for %s\n", progname, gn->fname, gn->lineno, makeDependfile, gn->name); return true; @@ -2029,17 +2025,17 @@ Job_CatchOutput(void) (void)fflush(stdout); - /* Skip the first fd in the list, as it is the job token pipe. */ do { - nready = poll(fds + 1 - wantToken, fdsLen - 1 + wantToken, - POLL_MSEC); + /* Maybe skip the job token pipe. */ + nfds_t skip = wantToken ? 0 : 1; + nready = poll(fds + skip, fdsLen - skip, POLL_MSEC); } while (nready < 0 && errno == EINTR); if (nready < 0) Punt("poll: %s", strerror(errno)); - if (nready > 0 && readyfd(&childExitJob)) { - char token = 0; + if (nready > 0 && childExitJob.inPollfd->revents & POLLIN) { + char token; ssize_t count = read(childExitJob.inPipe, &token, 1); if (count == 1) { if (token == DO_JOB_RESUME[0]) @@ -2163,7 +2159,7 @@ Job_Init(void) job_table = bmake_malloc((size_t)opts.maxJobs * sizeof *job_table); memset(job_table, 0, (size_t)opts.maxJobs * sizeof *job_table); job_table_end = job_table + opts.maxJobs; - wantToken = 0; + wantToken = false; caught_sigchld = 0; aborting = ABORT_NONE; @@ -2636,14 +2632,6 @@ clearfd(Job *job) job->inPollfd = NULL; } -static bool -readyfd(Job *job) -{ - if (job->inPollfd == NULL) - Punt("Polling unwatched job"); - return (job->inPollfd->revents & POLLIN) != 0; -} - /* * Put a token (back) into the job pipe. * This allows a make process to start a build job. @@ -2739,7 +2727,7 @@ Job_TokenWithdraw(void) char tok, tok1; ssize_t count; - wantToken = 0; + wantToken = false; DEBUG3(JOB, "Job_TokenWithdraw(%d): aborting %d, running %d\n", getpid(), aborting, jobTokensRunning); @@ -2753,7 +2741,7 @@ Job_TokenWithdraw(void) if (errno != EAGAIN) Fatal("job pipe read: %s", strerror(errno)); DEBUG1(JOB, "(%d) blocked for token\n", getpid()); - wantToken = 1; + wantToken = true; return false; } @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.639 2025/03/07 06:50:34 rillig Exp $ */ +/* $NetBSD: main.c,v 1.641 2025/03/31 14:35:22 riastradh Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -108,7 +108,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.639 2025/03/07 06:50:34 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.641 2025/03/31 14:35:22 riastradh Exp $"); #if defined(MAKE_NATIVE) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -2136,12 +2136,17 @@ PrintOnError(GNode *gn, const char *msg) SetErrorVars(gn); { - char *errorVarsValues = Var_Subst( + char *errorVarsValues; + enum PosixState p_s = posix_state; + + posix_state = PS_TOO_LATE; + errorVarsValues = Var_Subst( "${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'\n@}", SCOPE_GLOBAL, VARE_EVAL); /* TODO: handle errors */ printf("%s", errorVarsValues); free(errorVarsValues); + posix_state = p_s; } fflush(stdout); @@ -2160,12 +2165,15 @@ void Main_ExportMAKEFLAGS(bool first) { static bool once = true; + enum PosixState p_s; char *flags; if (once != first) return; once = false; + p_s = posix_state; + posix_state = PS_TOO_LATE; flags = Var_Subst( "${.MAKEFLAGS} ${.MAKEOVERRIDES:O:u:@v@$v=${$v:Q}@}", SCOPE_CMDLINE, VARE_EVAL); @@ -2173,6 +2181,7 @@ Main_ExportMAKEFLAGS(bool first) if (flags[0] != '\0') setenv("MAKEFLAGS", flags, 1); free(flags); + posix_state = p_s; } char * @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.381 2024/11/14 19:30:13 sjg Exp $ +.\" $NetBSD: make.1,v 1.384 2025/04/04 18:36:47 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 November 14, 2024 +.Dd April 4, 2025 .Dt MAKE 1 .Os .Sh NAME @@ -1087,11 +1087,61 @@ Puts into .Dq meta mode, where meta files are created for each target -to capture the command run, the output generated, and if +to capture the commands run, the output generated, and if .Xr filemon 4 is available, the system calls which are of interest to .Nm . The captured output can be useful when diagnosing errors. +.Pp +.Nm +will use the information in the meta file to help determine if +a target is out-of-date when the normal dependency rules +indicate it is not. +.Pp +First, +the commands to be executed, +will be compared to those captured previously, +if any differ, +the target is out-of-date. +.Pp +This allows for a huge improvement in the reliability +and efficiency of update builds. +It is no longer necessary for targets to depend on makefiles +just in-case they set a variable that might be relevant. +Mechanisms such as +.Va .MAKE.META.CMP_FILTER +and +.Ic .NOMETA_CMP , +allow limiting or disabling that comparison on a per target basis. +A reference to the variable +.Va .OODATE +can be leveraged to block comparison of certain commands. +For example: +.Ql ${.OODATE:M} +will expand to nothing and have no impact on the target, +its side-effect though, +will be to prevent comparison of any command line it appears on. +For documentation purposes +.Ql ${.OODATE:MNOMETA_CMP} +is useful. +.Pp +If necessary, +.Nm +will then use the information captured by +.Xr filemon 4 , +to check the modification time of any file used in generating +the target, +if any is newer, +the target is out-of-date. +.Pp +Such deep inspection can easily lead to cases where a target is +.Em always +considered out-of-date, which is why +.Va .MAKE.META.IGNORE_FILTER , +.Va .MAKE.META.IGNORE_PATHS +and +.Va .MAKE.META.IGNORE_PATTERNS , +are provided to limit that inspection when necessary. .It Cm curdirOk= Ns Ar bf By default, .Nm @@ -2536,6 +2586,8 @@ is run with the flag, only .Ql posix.mk contributes to the default rules. +In POSIX-compatible mode, the AT&T System V UNIX style substitution +modifier is checked first rather than as a fallback. .It Ic .PRECIOUS Apply the .Ic .PRECIOUS @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.350 2025/03/07 06:50:34 rillig Exp $ */ +/* $NetBSD: make.h,v 1.352 2025/03/30 21:24:57 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -553,6 +553,7 @@ extern enum PosixState { PS_NOT_YET, PS_MAYBE_NEXT_LINE, PS_NOW_OR_NEVER, + PS_SET, PS_TOO_LATE } posix_state; @@ -1078,7 +1079,7 @@ void Global_Append(const char *, const char *); void Global_Delete(const char *); void Global_Set_ReadOnly(const char *, const char *); -void EvalStack_PrintDetails(void); +bool EvalStack_PrintDetails(void) MAKE_ATTR_USE; /* util.c */ typedef void (*SignalProc)(int); @@ -1,4 +1,4 @@ -/* $NetBSD: meta.c,v 1.210 2024/06/02 15:31:26 rillig Exp $ */ +/* $NetBSD: meta.c,v 1.211 2025/04/11 17:33:47 rillig Exp $ */ /* * Implement 'meta' mode. @@ -1017,7 +1017,7 @@ meta_ignore(GNode *gn, const char *p) * Setting oodate true will have that effect. */ #define CHECK_VALID_META(p) if (!(p != NULL && *p != '\0')) { \ - warnx("%s: %u: malformed", fname, lineno); \ + warnx("%s:%u: malformed", fname, lineno); \ oodate = true; \ continue; \ } @@ -1162,7 +1162,7 @@ meta_oodate(GNode *gn, bool oodate) if (buf[x - 1] == '\n') buf[x - 1] = '\0'; else { - warnx("%s: %u: line truncated at %u", fname, lineno, x); + warnx("%s:%u: line truncated at %u", fname, lineno, x); oodate = true; break; } @@ -1183,7 +1183,7 @@ meta_oodate(GNode *gn, bool oodate) /* Delimit the record type. */ p = buf; #ifdef DEBUG_META_MODE - DEBUG3(META, "%s: %u: %s\n", fname, lineno, buf); + DEBUG3(META, "%s:%u: %s\n", fname, lineno, buf); #endif strsep(&p, " "); if (have_filemon) { @@ -1251,7 +1251,7 @@ meta_oodate(GNode *gn, bool oodate) continue; #ifdef DEBUG_META_MODE if (DEBUG(META)) - debug_printf("%s: %u: %d: %c: cwd=%s lcwd=%s ldir=%s\n", + debug_printf("%s:%u: %d: %c: cwd=%s lcwd=%s ldir=%s\n", fname, lineno, pid, buf[0], cwd, lcwd, latestdir); #endif @@ -1282,7 +1282,7 @@ meta_oodate(GNode *gn, bool oodate) #ifdef DEBUG_META_MODE if (DEBUG(META)) debug_printf( - "%s: %u: %d: cwd=%s lcwd=%s ldir=%s\n", + "%s:%u: %d: cwd=%s lcwd=%s ldir=%s\n", fname, lineno, child, cwd, lcwd, latestdir); #endif @@ -1297,7 +1297,7 @@ meta_oodate(GNode *gn, bool oodate) Global_Set(lcwd_vname, lcwd); Global_Set(ldir_vname, lcwd); #ifdef DEBUG_META_MODE - DEBUG4(META, "%s: %u: cwd=%s ldir=%s\n", + DEBUG4(META, "%s:%u: cwd=%s ldir=%s\n", fname, lineno, cwd, lcwd); #endif break; @@ -1450,7 +1450,7 @@ meta_oodate(GNode *gn, bool oodate) for (sdp = sdirs; *sdp != NULL && !found; sdp++) { #ifdef DEBUG_META_MODE - DEBUG3(META, "%s: %u: looking for: %s\n", + DEBUG3(META, "%s:%u: looking for: %s\n", fname, lineno, *sdp); #endif if (cached_stat(*sdp, &cst) == 0) { @@ -1460,12 +1460,12 @@ meta_oodate(GNode *gn, bool oodate) } if (found) { #ifdef DEBUG_META_MODE - DEBUG3(META, "%s: %u: found: %s\n", + DEBUG3(META, "%s:%u: found: %s\n", fname, lineno, p); #endif if (!S_ISDIR(cst.cst_mode) && cst.cst_mtime > gn->mtime) { - DEBUG3(META, "%s: %u: file '%s' is newer than the target...\n", + DEBUG3(META, "%s:%u: file '%s' is newer than the target...\n", fname, lineno, p); oodate = true; } else if (S_ISDIR(cst.cst_mode)) { @@ -1497,7 +1497,7 @@ meta_oodate(GNode *gn, bool oodate) * meta data file. */ if (cmdNode == NULL) { - DEBUG2(META, "%s: %u: there were more build commands in the meta data file than there are now...\n", + DEBUG2(META, "%s:%u: there were more build commands in the meta data file than there are now...\n", fname, lineno); oodate = true; } else { @@ -1514,7 +1514,7 @@ meta_oodate(GNode *gn, bool oodate) } if (hasOODATE) { needOODATE = true; - DEBUG2(META, "%s: %u: cannot compare command using .OODATE\n", + DEBUG2(META, "%s:%u: cannot compare command using .OODATE\n", fname, lineno); } cmd = Var_Subst(cmd, gn, VARE_EVAL_DEFINED); @@ -1537,7 +1537,7 @@ meta_oodate(GNode *gn, bool oodate) x = n; lineno++; if (buf[x - 1] != '\n') { - warnx("%s: %u: line truncated at %u", fname, lineno, x); + warnx("%s:%u: line truncated at %u", fname, lineno, x); break; } cp = strchr(cp + 1, '\n'); @@ -1549,7 +1549,7 @@ meta_oodate(GNode *gn, bool oodate) !hasOODATE && !(gn->type & OP_NOMETA_CMP) && (meta_cmd_cmp(gn, p, cmd, cmp_filter) != 0)) { - DEBUG4(META, "%s: %u: a build command has changed\n%s\nvs\n%s\n", + DEBUG4(META, "%s:%u: a build command has changed\n%s\nvs\n%s\n", fname, lineno, p, cmd); if (!metaIgnoreCMDs) oodate = true; @@ -1563,13 +1563,13 @@ meta_oodate(GNode *gn, bool oodate) * that weren't in the meta data file. */ if (!oodate && cmdNode != NULL) { - DEBUG2(META, "%s: %u: there are extra build commands now that weren't in the meta data file\n", + DEBUG2(META, "%s:%u: there are extra build commands now that weren't in the meta data file\n", fname, lineno); oodate = true; } CHECK_VALID_META(p); if (strcmp(p, cwd) != 0) { - DEBUG4(META, "%s: %u: the current working directory has changed from '%s' to '%s'\n", + DEBUG4(META, "%s:%u: the current working directory has changed from '%s' to '%s'\n", fname, lineno, p, curdir); oodate = true; } diff --git a/mk/ChangeLog b/mk/ChangeLog index 99f4b05be61c..c457d3aab9c2 100644 --- a/mk/ChangeLog +++ b/mk/ChangeLog @@ -1,3 +1,25 @@ +2025-04-18 Simon J Gerraty <sjg@beast.crufty.net> + + * init.mk: include Skipping ${RELDIR} when _SKIP_BUILD is not empty. + +2025-04-14 Simon J Gerraty <sjg@beast.crufty.net> + + * install-mk (MK_VERSION): 20250414 + + * init.mk: check ONLY_*_LIST and NOT_*_LIST for SKIP_BUILD_VAR_LIST + to set _SKIP_BUILD + + * genfiles.mk: add FILTER support + + * rst2htm.mk: latest docutils drops .py extensions + +2025-03-26 Simon J Gerraty <sjg@beast.crufty.net> + + * install-mk (MK_VERSION): 20250326 + + * auto.obj.mk: fix and simplify handling of relative __objdir, + convert it to absolute before checking against .OBJDIR + 2025-03-14 Simon J Gerraty <sjg@beast.crufty.net> * install-mk (MK_VERSION): 20250314 diff --git a/mk/auto.obj.mk b/mk/auto.obj.mk index cfe60ef9c4d6..9ae7ebe3af56 100644 --- a/mk/auto.obj.mk +++ b/mk/auto.obj.mk @@ -1,6 +1,6 @@ # SPDX-License-Identifier: BSD-2-Clause # -# $Id: auto.obj.mk,v 1.17 2024/02/17 17:26:57 sjg Exp $ +# $Id: auto.obj.mk,v 1.19 2025/03/27 15:51:06 sjg Exp $ # # @(#) Copyright (c) 2004, Simon J. Gerraty # @@ -50,7 +50,12 @@ __objdir?= ${.CURDIR} __objdir?= ${MAKEOBJDIRPREFIX}${.CURDIR} .endif __objdir?= ${MAKEOBJDIR:Uobj} -__objdir:= ${__objdir} +# relative dirs can cause trouble below +# keep it simple and convert to absolute path now if needed +.if ${__objdir:M/*} == "" +# avoid ugly ${.CURDIR}/./obj etc. +__objdir:= ${.CURDIR}/${__objdir:S,^./,,} +.endif .if ${.OBJDIR:tA} != ${__objdir:tA} # We need to chdir, make the directory if needed .if !exists(${__objdir}/) && \ @@ -65,11 +70,9 @@ __objdir_made != echo ${__objdir}/; umask ${OBJDIR_UMASK:U002}; \ .if ${.OBJDIR:tA} != ${__objdir:tA} # we did not get what we want - do we care? .if ${__objdir_made:Uno:M${__objdir}/*} != "" -# watch out for __objdir being relative path -.if !(${__objdir:M/*} == "" && ${.OBJDIR:tA} == ${${.CURDIR}/${__objdir}:L:tA}) +# we attempted to make ${__objdir} and failed .error could not use ${__objdir}: .OBJDIR=${.OBJDIR} .endif -.endif # apparently we can live with it # make sure we know what we have .OBJDIR: ${.CURDIR} diff --git a/mk/genfiles.mk b/mk/genfiles.mk index d35e8be74763..4299206cca9f 100644 --- a/mk/genfiles.mk +++ b/mk/genfiles.mk @@ -1,8 +1,8 @@ # SPDX-License-Identifier: BSD-2-Clause # -# $Id: genfiles.mk,v 1.3 2024/09/21 21:14:19 sjg Exp $ +# $Id: genfiles.mk,v 1.4 2025/04/18 00:04:41 sjg Exp $ # -# @(#) Copyright (c) 2024, Simon J. Gerraty +# @(#) Copyright (c) 2024-2025, Simon J. Gerraty # # This file is provided in the hope that it will # be of use. There is absolutely NO WARRANTY. @@ -23,4 +23,5 @@ _GENFILES_USE: .USE @cat ${SRCS.${.TARGET}:U${.ALLSRC:u}} \ ${EXCLUDES.${.TARGET}:D| ${EGREP:Uegrep} -v '${EXCLUDS.${.TARGET}:ts|}'} \ ${SED_CMDS.${.TARGET}:D| ${SED:Used} ${SED_CMDS.${.TARGET}}} \ + ${FILTER.${.TARGET}:D| ${FILTER.${.TARGET}}} \ > ${.TARGET} diff --git a/mk/init.mk b/mk/init.mk index acccf8d5cf6b..7d044af3d791 100644 --- a/mk/init.mk +++ b/mk/init.mk @@ -1,6 +1,6 @@ # SPDX-License-Identifier: BSD-2-Clause # -# $Id: init.mk,v 1.39 2024/12/12 19:56:36 sjg Exp $ +# $Id: init.mk,v 1.41 2025/04/18 20:49:54 sjg Exp $ # # @(#) Copyright (c) 2002-2024, Simon J. Gerraty # @@ -112,6 +112,23 @@ _SKIP_BUILD = not building at level 0 .WAIT: .endif +# allow makefiles to set ONLY_*_LIST and NOT_*_LIST +# to control _SKIP_BUILD +SKIP_BUILD_VAR_LIST += TARGET_SPEC ${TARGET_SPEC_VARS:UMACHINE} +.for v in ${SKIP_BUILD_VAR_LIST} +.if !empty(ONLY_$v_LIST) && ${ONLY_$v_LIST:Uno:M${$v}} == "" +_SKIP_BUILD ?= ${$v} not in ONLY_$v_LIST (${ONLY_$v_LIST}) +.if ${MAKE_VERSION} > 20220924 +.break +.endif +.elif !empty(NOT_$v_LIST) && ${NOT_$v_LIST:U:M${$v}} != "" +_SKIP_BUILD ?= ${$v} in NOT_$v_LIST (${NOT_$v_LIST}) +.if ${MAKE_VERSION} > 20220924 +.break +.endif +.endif +.endfor + # define this once for consistency .if !defined(_SKIP_BUILD) # beforebuild is a hook for things that must be done early @@ -119,7 +136,7 @@ all: beforebuild .WAIT realbuild .else all: .PHONY .if !empty(_SKIP_BUILD) && ${.MAKEFLAGS:M-V} == "" -.warning ${_SKIP_BUILD} +.warning Skipping ${RELDIR} ${_SKIP_BUILD} .endif .endif beforebuild: diff --git a/mk/install-mk b/mk/install-mk index d765fbba2251..de5056a37042 100644..100755 --- a/mk/install-mk +++ b/mk/install-mk @@ -59,7 +59,7 @@ # Simon J. Gerraty <sjg@crufty.net> # RCSid: -# $Id: install-mk,v 1.263 2025/03/14 20:29:35 sjg Exp $ +# $Id: install-mk,v 1.264 2025/03/26 18:30:18 sjg Exp $ # # @(#) Copyright (c) 1994-2025 Simon J. Gerraty # @@ -74,7 +74,7 @@ # sjg@crufty.net # -MK_VERSION=20250314 +MK_VERSION=20250326 OWNER= GROUP= MODE=444 diff --git a/mk/rst2htm.mk b/mk/rst2htm.mk index 4da16f144e9e..5dbc8ddaf960 100644 --- a/mk/rst2htm.mk +++ b/mk/rst2htm.mk @@ -1,6 +1,6 @@ # SPDX-License-Identifier: BSD-2-Clause # -# $Id: rst2htm.mk,v 1.15 2024/02/17 17:26:57 sjg Exp $ +# $Id: rst2htm.mk,v 1.16 2025/04/16 00:42:07 sjg Exp $ # # @(#) Copyright (c) 2009, Simon J. Gerraty # @@ -29,9 +29,9 @@ HTMFILES ?= ${RSTSRCS:R:T:O:u:%=%.htm} PDFFILES ?= ${RSTSRCS:R:T:O:u:%=%.pdf} # can be empty, 4 or 5 HTML_VERSION ?= -RST2HTML ?= rst2html${HTML_VERSION}.py +RST2HTML ?= rst2html${HTML_VERSION} RST2PDF ?= rst2pdf -RST2S5 ?= rst2s5.py +RST2S5 ?= rst2s5 # the following will run RST2S5 if the target name contains the word 'slides' # otherwise it uses RST2HTML RST2HTM = ${"${.TARGET:T:M*slides*}":?${RST2S5}:${RST2HTML}} @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.738 2025/01/14 21:34:09 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.743 2025/04/13 09:34:43 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -110,7 +110,7 @@ #include "pathnames.h" /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: parse.c,v 1.738 2025/01/14 21:34:09 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.743 2025/04/13 09:34:43 rillig Exp $"); /* Detects a multiple-inclusion guard in a makefile. */ typedef enum { @@ -400,14 +400,15 @@ PrintStackTrace(bool includingInnermost) const IncludedFile *entries; size_t i, n; - EvalStack_PrintDetails(); + bool hasDetails = EvalStack_PrintDetails(); n = includes.len; if (n == 0) return; entries = GetInclude(0); - if (!includingInnermost && entries[n - 1].forLoop == NULL) + if (!includingInnermost && !(hasDetails && n > 1) + && entries[n - 1].forLoop == NULL) n--; /* already in the diagnostic */ for (i = n; i-- > 0;) { @@ -501,7 +502,7 @@ PrintLocation(FILE *f, bool useVars, const GNode *gn) return; if (!useVars || fname[0] == '/' || strcmp(fname, "(stdin)") == 0) { - (void)fprintf(f, "\"%s\" line %u: ", fname, lineno); + (void)fprintf(f, "%s:%u: ", fname, lineno); return; } @@ -515,7 +516,7 @@ PrintLocation(FILE *f, bool useVars, const GNode *gn) if (base.str == NULL) base.str = str_basename(fname); - (void)fprintf(f, "\"%s/%s\" line %u: ", dir.str, base.str, lineno); + (void)fprintf(f, "%s/%s:%u: ", dir.str, base.str, lineno); FStr_Done(&base); FStr_Done(&dir); @@ -1317,6 +1318,7 @@ HandleDependencySourcesEmpty(ParseSpecial special, SearchPathList *paths) * otherwise it is an extension. */ Global_Set("%POSIX", "1003.2"); + posix_state = PS_SET; IncludeFile("posix.mk", true, false, true); } break; @@ -2161,8 +2163,8 @@ Parse_PushInput(const char *name, unsigned lineno, unsigned readLines, else TrackInput(name); - DEBUG3(PARSE, "Parse_PushInput: %s %s, line %u\n", - forLoop != NULL ? ".for loop in": "file", name, lineno); + DEBUG3(PARSE, "Parse_PushInput: %s%s:%u\n", + forLoop != NULL ? ".for loop in ": "", name, lineno); curFile = Vector_Push(&includes); curFile->name = FStr_InitOwn(bmake_strdup(name)); @@ -2340,7 +2342,7 @@ ParseEOF(void) } curFile = CurFile(); - DEBUG2(PARSE, "ParseEOF: returning to file %s, line %u\n", + DEBUG2(PARSE, "ParseEOF: returning to %s:%u\n", curFile->name.str, curFile->readLines + 1); SetParseFile(curFile->name.str); @@ -2617,7 +2619,7 @@ ReadHighLevelLine(void) line = ReadLowLevelLine(LK_NONEMPTY); if (posix_state == PS_MAYBE_NEXT_LINE) posix_state = PS_NOW_OR_NEVER; - else + else if (posix_state != PS_SET) posix_state = PS_TOO_LATE; if (line == NULL) return NULL; diff --git a/unit-tests/Makefile b/unit-tests/Makefile index e83758871bba..7f1fe0a26c29 100644 --- a/unit-tests/Makefile +++ b/unit-tests/Makefile @@ -1,6 +1,6 @@ -# $Id: Makefile,v 1.230 2025/01/30 18:04:20 sjg Exp $ +# $Id: Makefile,v 1.233 2025/04/14 16:02:33 sjg Exp $ # -# $NetBSD: Makefile,v 1.355 2025/01/25 22:46:30 sjg Exp $ +# $NetBSD: Makefile,v 1.358 2025/04/13 09:29:32 rillig Exp $ # # Unit tests for make(1) # @@ -299,6 +299,9 @@ TESTS+= parse TESTS+= parse-var TESTS+= phony-end TESTS+= posix +TESTS+= posix-execution +TESTS+= posix-expansion +TESTS+= posix-varassign TESTS+= # posix1 # broken by reverting POSIX changes TESTS+= recursive TESTS+= sh @@ -609,7 +612,9 @@ SED_CMDS.opt-chdir= -e 's,\(nonexistent\).[1-9][0-9]*,\1,' \ -e 's,Filename,File name,' # meta line numbers can vary based on filemon implementation -SED_CMDS.meta-ignore= -e 's,\(\.meta:\) [1-9][0-9]*:,\1 <line>:,' +SED_CMDS.meta-ignore= -e 's,\(\.meta:\)[1-9][0-9]*:,\1<line>:,' + +SED_CMDS.opt-chdir= -e 's,\(nonexistent\).[1-9][0-9]*,\1,' SED_CMDS.opt-debug-graph1= ${STD_SED_CMDS.dg1} SED_CMDS.opt-debug-graph2= ${STD_SED_CMDS.dg2} SED_CMDS.opt-debug-graph3= ${STD_SED_CMDS.dg3} @@ -647,8 +652,8 @@ SED_CMDS.varparse-errors+= ${STD_SED_CMDS.timestamp} SED_CMDS.varname-dot-make-meta-ignore_filter+= ${SED_CMDS.meta-ignore} SED_CMDS.varname-dot-make-meta-ignore_paths+= ${SED_CMDS.meta-ignore} SED_CMDS.varname-dot-make-meta-ignore_patterns+= ${SED_CMDS.meta-ignore} -SED_CMDS.varname-dot-parsedir= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,' -SED_CMDS.varname-dot-parsefile= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,' +SED_CMDS.varname-dot-parsedir= -e '/in some cases/ s,^make: [^:]*:,make: <normalized>:,' +SED_CMDS.varname-dot-parsefile= -e '/in some cases/ s,^make: [^:]*:,make: <normalized>:,' SED_CMDS.varname-dot-shell= -e 's, = /[^ ]*, = (details omitted),g' SED_CMDS.varname-dot-shell+= -e 's,"/[^" ]*","(details omitted)",g' SED_CMDS.varname-dot-shell+= -e 's,\[/[^] ]*\],[(details omitted)],g' diff --git a/unit-tests/archive.exp b/unit-tests/archive.exp index 89e7b7878b4e..67b3d60ea9db 100644 --- a/unit-tests/archive.exp +++ b/unit-tests/archive.exp @@ -18,13 +18,13 @@ list-archive-wildcard: archive-suffix.mk list-archive-wildcard: archive.mk list-archive-wildcard: ternary.mk -make: "archive.mk" line 61: Error in source archive spec "libprog.a${UNDEF}(archive.mk) pre post" +make: archive.mk:61: Error in source archive spec "libprog.a${UNDEF}(archive.mk) pre post" in directory <curdir> make: Fatal errors encountered -- cannot continue make: stopped making "list-archive-undef-archive" in unit-tests exit 1 -make: "archive.mk" line 68: Error in source archive spec "libprog.a" +make: archive.mk:68: Error in source archive spec "libprog.a" in directory <curdir> make: Fatal errors encountered -- cannot continue make: stopped making "list-archive-undef-member" in unit-tests diff --git a/unit-tests/cmd-errors-jobs.exp b/unit-tests/cmd-errors-jobs.exp index 7177cd4d18f8..a535f428e890 100644 --- a/unit-tests/cmd-errors-jobs.exp +++ b/unit-tests/cmd-errors-jobs.exp @@ -8,23 +8,29 @@ end undefined-indirect with status 0 begin parse-error-direct make: Unclosed variable "UNCLOSED" + in command ": unexpected $@-${UNCLOSED" in target "parse-error-unclosed-expression" make: Unclosed expression, expecting '}' while evaluating variable "UNCLOSED" with value "" + in command ": unexpected $@-${UNCLOSED:" in target "parse-error-unclosed-modifier" -make: Unknown modifier "Z" +make: Unknown modifier ":Z" while evaluating variable "UNKNOWN" with value "" + in command ": unexpected $@-${UNKNOWN:Z}-eol" in target "parse-error-unknown-modifier" end parse-error-direct with status 2 begin parse-error-indirect make: Unclosed variable "UNCLOSED" + in command ": unexpected $@-${UNCLOSED" in target "parse-error-unclosed-expression" make: Unclosed expression, expecting '}' while evaluating variable "UNCLOSED" with value "" + in command ": unexpected $@-${UNCLOSED:" in target "parse-error-unclosed-modifier" -make: Unknown modifier "Z" +make: Unknown modifier ":Z" while evaluating variable "UNKNOWN" with value "" + in command ": unexpected $@-${UNKNOWN:Z}-eol" in target "parse-error-unknown-modifier" end parse-error-indirect with status 2 diff --git a/unit-tests/cmd-errors-jobs.mk b/unit-tests/cmd-errors-jobs.mk index 471f2cbb327c..a29883fc6676 100644 --- a/unit-tests/cmd-errors-jobs.mk +++ b/unit-tests/cmd-errors-jobs.mk @@ -1,4 +1,4 @@ -# $NetBSD: cmd-errors-jobs.mk,v 1.13 2024/08/29 20:20:35 rillig Exp $ +# $NetBSD: cmd-errors-jobs.mk,v 1.15 2025/03/29 19:08:52 rillig Exp $ # # Demonstrate how errors in expressions affect whether the commands # are actually executed in jobs mode. @@ -47,14 +47,15 @@ parse-error-unclosed-modifier: parse-error-unknown-modifier: : unexpected $@-${UNKNOWN:Z}-eol -# expect-not: : unexpected +# expect-not-matches: ^: unexpected # expect: make: Unclosed variable "UNCLOSED" +# expect: in command ": unexpected $@-${UNCLOSED" # expect: make: Unclosed expression, expecting '}' -# expect: make: Unknown modifier "Z" +# expect: make: Unknown modifier ":Z" # expect: end parse-error-direct with status 2 # expect: make: Unclosed variable "UNCLOSED" # expect: make: Unclosed expression, expecting '}' -# expect: make: Unknown modifier "Z" +# expect: make: Unknown modifier ":Z" # expect: end parse-error-indirect with status 2 diff --git a/unit-tests/cmd-errors-lint.exp b/unit-tests/cmd-errors-lint.exp index 116e9957a2c5..ec7336f618b8 100644 --- a/unit-tests/cmd-errors-lint.exp +++ b/unit-tests/cmd-errors-lint.exp @@ -1,11 +1,14 @@ : undefined make: Unclosed variable "UNCLOSED" + in command ": $@ ${UNCLOSED" in target "unclosed-expression" make: Unclosed expression, expecting '}' while evaluating variable "UNCLOSED" with value "" + in command ": $@ ${UNCLOSED:" in target "unclosed-modifier" -make: Unknown modifier "Z" +make: Unknown modifier ":Z" while evaluating variable "UNKNOWN" with value "" + in command ": $@ ${UNKNOWN:Z}" in target "unknown-modifier" : end exit status 2 diff --git a/unit-tests/cmd-errors-lint.mk b/unit-tests/cmd-errors-lint.mk index 873f05c6186f..eb2ec1171545 100644 --- a/unit-tests/cmd-errors-lint.mk +++ b/unit-tests/cmd-errors-lint.mk @@ -1,4 +1,4 @@ -# $NetBSD: cmd-errors-lint.mk,v 1.6 2024/08/29 20:20:35 rillig Exp $ +# $NetBSD: cmd-errors-lint.mk,v 1.7 2025/03/29 19:08:52 rillig Exp $ # # Demonstrate how errors in expressions affect whether the commands # are actually executed. @@ -24,7 +24,7 @@ unclosed-modifier: : $@ ${UNCLOSED: unknown-modifier: -# expect: make: Unknown modifier "Z" +# expect: make: Unknown modifier ":Z" # expect-not: : unknown-modifier : $@ ${UNKNOWN:Z} diff --git a/unit-tests/cmd-errors.exp b/unit-tests/cmd-errors.exp index 865072ecbf86..62da47ff42c5 100644 --- a/unit-tests/cmd-errors.exp +++ b/unit-tests/cmd-errors.exp @@ -1,11 +1,14 @@ : undefined--eol make: Unclosed variable "UNCLOSED" + in command ": $@-${UNCLOSED" in target "unclosed-expression" make: Unclosed expression, expecting '}' while evaluating variable "UNCLOSED" with value "" + in command ": $@-${UNCLOSED:" in target "unclosed-modifier" -make: Unknown modifier "Z" +make: Unknown modifier ":Z" while evaluating variable "UNKNOWN" with value "" + in command ": $@-${UNKNOWN:Z}-eol" in target "unknown-modifier" : end-eol exit status 2 diff --git a/unit-tests/cmd-errors.mk b/unit-tests/cmd-errors.mk index 0acc811d43bc..8766b6a856c7 100644 --- a/unit-tests/cmd-errors.mk +++ b/unit-tests/cmd-errors.mk @@ -1,4 +1,4 @@ -# $NetBSD: cmd-errors.mk,v 1.11 2024/08/29 20:20:35 rillig Exp $ +# $NetBSD: cmd-errors.mk,v 1.12 2025/03/29 19:08:52 rillig Exp $ # # Demonstrate how errors in expressions affect whether the commands # are actually executed in compat mode. @@ -22,7 +22,7 @@ unclosed-modifier: : $@-${UNCLOSED: unknown-modifier: -# expect: make: Unknown modifier "Z" +# expect: make: Unknown modifier ":Z" # expect-not: : unknown-modifier--eol : $@-${UNKNOWN:Z}-eol diff --git a/unit-tests/cmdline-undefined.exp b/unit-tests/cmdline-undefined.exp index 197f6da60131..12fc45e50822 100644 --- a/unit-tests/cmdline-undefined.exp +++ b/unit-tests/cmdline-undefined.exp @@ -1,17 +1,17 @@ The = assignment operator -make: "cmdline-undefined.mk" line 31: From the command line: Undefined is . -make: "cmdline-undefined.mk" line 34: From .MAKEFLAGS '=': Undefined is . -make: "cmdline-undefined.mk" line 37: From .MAKEFLAGS ':=': Undefined is . -make: "cmdline-undefined.mk" line 43: From the command line: Undefined is now defined. -make: "cmdline-undefined.mk" line 46: From .MAKEFLAGS '=': Undefined is now defined. -make: "cmdline-undefined.mk" line 49: From .MAKEFLAGS ':=': Undefined is now defined. +make: cmdline-undefined.mk:31: From the command line: Undefined is . +make: cmdline-undefined.mk:34: From .MAKEFLAGS '=': Undefined is . +make: cmdline-undefined.mk:37: From .MAKEFLAGS ':=': Undefined is . +make: cmdline-undefined.mk:43: From the command line: Undefined is now defined. +make: cmdline-undefined.mk:46: From .MAKEFLAGS '=': Undefined is now defined. +make: cmdline-undefined.mk:49: From .MAKEFLAGS ':=': Undefined is now defined. The := assignment operator -make: "cmdline-undefined.mk" line 31: From the command line: Undefined is . -make: "cmdline-undefined.mk" line 34: From .MAKEFLAGS '=': Undefined is . -make: "cmdline-undefined.mk" line 37: From .MAKEFLAGS ':=': Undefined is . -make: "cmdline-undefined.mk" line 43: From the command line: Undefined is now defined. -make: "cmdline-undefined.mk" line 46: From .MAKEFLAGS '=': Undefined is now defined. -make: "cmdline-undefined.mk" line 49: From .MAKEFLAGS ':=': Undefined is now defined. +make: cmdline-undefined.mk:31: From the command line: Undefined is . +make: cmdline-undefined.mk:34: From .MAKEFLAGS '=': Undefined is . +make: cmdline-undefined.mk:37: From .MAKEFLAGS ':=': Undefined is . +make: cmdline-undefined.mk:43: From the command line: Undefined is now defined. +make: cmdline-undefined.mk:46: From .MAKEFLAGS '=': Undefined is now defined. +make: cmdline-undefined.mk:49: From .MAKEFLAGS ':=': Undefined is now defined. exit status 0 diff --git a/unit-tests/cond-cmp-numeric-eq.exp b/unit-tests/cond-cmp-numeric-eq.exp index e05961f14f87..1a386d53dbef 100644 --- a/unit-tests/cond-cmp-numeric-eq.exp +++ b/unit-tests/cond-cmp-numeric-eq.exp @@ -1,5 +1,5 @@ -make: "cond-cmp-numeric-eq.mk" line 68: Malformed conditional '!(12345 = 12345)' -make: "cond-cmp-numeric-eq.mk" line 76: Malformed conditional '!(12345 === 12345)' +make: cond-cmp-numeric-eq.mk:68: Malformed conditional '!(12345 = 12345)' +make: cond-cmp-numeric-eq.mk:76: Malformed conditional '!(12345 === 12345)' make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 diff --git a/unit-tests/cond-cmp-numeric.exp b/unit-tests/cond-cmp-numeric.exp index 8bec6ed55216..0945bef72300 100644 --- a/unit-tests/cond-cmp-numeric.exp +++ b/unit-tests/cond-cmp-numeric.exp @@ -1,15 +1,15 @@ CondParser_Eval: !(${:UINF} > 1e100) -make: "cond-cmp-numeric.mk" line 15: Comparison with '>' requires both operands 'INF' and '1e100' to be numeric +make: cond-cmp-numeric.mk:15: Comparison with '>' requires both operands 'INF' and '1e100' to be numeric CondParser_Eval: ${:UNaN} > NaN -make: "cond-cmp-numeric.mk" line 21: Comparison with '>' requires both operands 'NaN' and 'NaN' to be numeric +make: cond-cmp-numeric.mk:21: Comparison with '>' requires both operands 'NaN' and 'NaN' to be numeric CondParser_Eval: !(${:UNaN} == NaN) Comparing "NaN" == "NaN" CondParser_Eval: 123 ! 123 -make: "cond-cmp-numeric.mk" line 38: Malformed conditional '123 ! 123' +make: cond-cmp-numeric.mk:38: Malformed conditional '123 ! 123' CondParser_Eval: ${:U 123} < 124 Comparing 123.000000 < 124.000000 CondParser_Eval: ${:U123 } < 124 -make: "cond-cmp-numeric.mk" line 54: Comparison with '<' requires both operands '123 ' and '124' to be numeric +make: cond-cmp-numeric.mk:54: Comparison with '<' requires both operands '123 ' and '124' to be numeric make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests exit status 1 diff --git a/unit-tests/cond-cmp-string.exp b/unit-tests/cond-cmp-string.exp index ce58422afd7e..b55f30182442 100644 --- a/unit-tests/cond-cmp-string.exp +++ b/unit-tests/cond-cmp-string.exp @@ -1,11 +1,11 @@ -make: "cond-cmp-string.mk" line 19: Malformed conditional 'str != str' -make: "cond-cmp-string.mk" line 44: Malformed conditional '"string" != "str""ing"' -make: "cond-cmp-string.mk" line 52: Malformed conditional '!("value" = "value")' -make: "cond-cmp-string.mk" line 60: Malformed conditional '!("value" === "value")' -make: "cond-cmp-string.mk" line 118: Comparison with '<' requires both operands 'string' and 'string' to be numeric -make: "cond-cmp-string.mk" line 126: Comparison with '<=' requires both operands 'string' and 'string' to be numeric -make: "cond-cmp-string.mk" line 134: Comparison with '>' requires both operands 'string' and 'string' to be numeric -make: "cond-cmp-string.mk" line 142: Comparison with '>=' requires both operands 'string' and 'string' to be numeric +make: cond-cmp-string.mk:19: Malformed conditional 'str != str' +make: cond-cmp-string.mk:44: Malformed conditional '"string" != "str""ing"' +make: cond-cmp-string.mk:52: Malformed conditional '!("value" = "value")' +make: cond-cmp-string.mk:60: Malformed conditional '!("value" === "value")' +make: cond-cmp-string.mk:118: Comparison with '<' requires both operands 'string' and 'string' to be numeric +make: cond-cmp-string.mk:126: Comparison with '<=' requires both operands 'string' and 'string' to be numeric +make: cond-cmp-string.mk:134: Comparison with '>' requires both operands 'string' and 'string' to be numeric +make: cond-cmp-string.mk:142: Comparison with '>=' requires both operands 'string' and 'string' to be numeric make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 diff --git a/unit-tests/cond-cmp-unary.exp b/unit-tests/cond-cmp-unary.exp index c5b800122eb9..5a1bead87d0a 100755 --- a/unit-tests/cond-cmp-unary.exp +++ b/unit-tests/cond-cmp-unary.exp @@ -1,2 +1,2 @@ -make: "cond-cmp-unary.mk" line 54: This is only reached because of a bug in EvalTruthy. +make: cond-cmp-unary.mk:54: This is only reached because of a bug in EvalTruthy. exit status 0 diff --git a/unit-tests/cond-eof.exp b/unit-tests/cond-eof.exp index 9e19dca175bd..44e481745a24 100644 --- a/unit-tests/cond-eof.exp +++ b/unit-tests/cond-eof.exp @@ -1,6 +1,6 @@ -make: "cond-eof.mk" line 17: Malformed conditional '0 ${SIDE_EFFECT} ${SIDE_EFFECT2}' -make: "cond-eof.mk" line 20: Malformed conditional '1 ${SIDE_EFFECT} ${SIDE_EFFECT2}' -make: "cond-eof.mk" line 23: Malformed conditional '(0) ${SIDE_EFFECT} ${SIDE_EFFECT2}' +make: cond-eof.mk:17: Malformed conditional '0 ${SIDE_EFFECT} ${SIDE_EFFECT2}' +make: cond-eof.mk:20: Malformed conditional '1 ${SIDE_EFFECT} ${SIDE_EFFECT2}' +make: cond-eof.mk:23: Malformed conditional '(0) ${SIDE_EFFECT} ${SIDE_EFFECT2}' make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 diff --git a/unit-tests/cond-func-defined.exp b/unit-tests/cond-func-defined.exp index 0b48906ce83f..ea3ced9398e8 100644 --- a/unit-tests/cond-func-defined.exp +++ b/unit-tests/cond-func-defined.exp @@ -1,5 +1,5 @@ -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: cond-func-defined.mk:24: Missing ')' after argument 'A' for 'defined' +make: cond-func-defined.mk:34: Missing ')' after argument 'DEF' for 'defined' make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests exit status 1 diff --git a/unit-tests/cond-func-empty.exp b/unit-tests/cond-func-empty.exp index 9102d4a35ae4..fce2bc443f6b 100644 --- a/unit-tests/cond-func-empty.exp +++ b/unit-tests/cond-func-empty.exp @@ -1,4 +1,4 @@ -make: "cond-func-empty.mk" line 167: Unclosed variable "WORD" +make: cond-func-empty.mk:167: Unclosed variable "WORD" make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 diff --git a/unit-tests/cond-func-make.exp b/unit-tests/cond-func-make.exp index 04ef6e29fee1..4d493b3c3ccb 100644 --- a/unit-tests/cond-func-make.exp +++ b/unit-tests/cond-func-make.exp @@ -1,4 +1,4 @@ -make: "cond-func-make.mk" line 24: warning: Unfinished character list in pattern argument '[' to function 'make' +make: cond-func-make.mk:24: warning: Unfinished character list in pattern argument '[' to function 'make' : via-cmdline : via-dot-makeflags exit status 0 diff --git a/unit-tests/cond-func.exp b/unit-tests/cond-func.exp index 0570a1c4fabc..c80f95f39c0b 100644 --- a/unit-tests/cond-func.exp +++ b/unit-tests/cond-func.exp @@ -1,13 +1,13 @@ -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 ')' after argument '' for 'defined' -make: "cond-func.mk" line 145: Missing ')' after argument '${:UVARNAME}.param' for 'defined' +make: cond-func.mk:37: Missing ')' after argument 'A' for 'defined' +make: cond-func.mk:53: Missing ')' after argument 'A' for 'defined' +make: cond-func.mk:57: Missing ')' after argument 'A' for 'defined' +make: cond-func.mk:91: Unknown operator '&' +make: cond-func.mk:107: A plain function name is parsed as defined(...). +make: cond-func.mk:115: A plain function name is parsed as defined(...). +make: cond-func.mk:126: Symbols may start with a function name. +make: cond-func.mk:132: Symbols may start with a function name. +make: cond-func.mk:138: Missing ')' after argument '' for 'defined' +make: cond-func.mk:145: Missing ')' after argument '${:UVARNAME}.param' for 'defined' make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 diff --git a/unit-tests/cond-late.exp b/unit-tests/cond-late.exp index d8a24143c2b9..6cd20d797d3e 100644 --- a/unit-tests/cond-late.exp +++ b/unit-tests/cond-late.exp @@ -1,4 +1,4 @@ -make: "cond-late.mk" line 38: Bad condition +make: cond-late.mk:38: Bad condition while evaluating condition " != "no"" while evaluating variable "VAR" with value "${${UNDEF} != "no":?:}" in directory <curdir> diff --git a/unit-tests/cond-op-and-lint.exp b/unit-tests/cond-op-and-lint.exp index 0f2cdb0028f9..8896fea5c9b6 100644 --- a/unit-tests/cond-op-and-lint.exp +++ b/unit-tests/cond-op-and-lint.exp @@ -1,4 +1,4 @@ -make: "cond-op-and-lint.mk" line 10: Unknown operator '&' +make: cond-op-and-lint.mk:10: Unknown operator '&' make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 diff --git a/unit-tests/cond-op-and.exp b/unit-tests/cond-op-and.exp index ac085e77ce74..1ada96a00bdd 100644 --- a/unit-tests/cond-op-and.exp +++ b/unit-tests/cond-op-and.exp @@ -1,11 +1,11 @@ -make: "cond-op-and.mk" line 36: Variable "UNDEF" is undefined -make: "cond-op-and.mk" line 41: Variable "UNDEF" is undefined -make: "cond-op-and.mk" line 44: Variable "UNDEF" is undefined -make: "cond-op-and.mk" line 60: Unknown operator '&' -make: "cond-op-and.mk" line 66: Unknown operator '&' -make: "cond-op-and.mk" line 72: Unknown operator '&' -make: "cond-op-and.mk" line 78: Unknown operator '&' -make: "cond-op-and.mk" line 87: Unknown operator '&' +make: cond-op-and.mk:36: Variable "UNDEF" is undefined +make: cond-op-and.mk:41: Variable "UNDEF" is undefined +make: cond-op-and.mk:44: Variable "UNDEF" is undefined +make: cond-op-and.mk:60: Unknown operator '&' +make: cond-op-and.mk:66: Unknown operator '&' +make: cond-op-and.mk:72: Unknown operator '&' +make: cond-op-and.mk:78: Unknown operator '&' +make: cond-op-and.mk:87: Unknown operator '&' make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 diff --git a/unit-tests/cond-op-not.exp b/unit-tests/cond-op-not.exp index 747720159906..63aa928eabc3 100644 --- a/unit-tests/cond-op-not.exp +++ b/unit-tests/cond-op-not.exp @@ -1,9 +1,9 @@ -make: "cond-op-not.mk" line 30: Not empty evaluates to true. -make: "cond-op-not.mk" line 39: Not space evaluates to false. -make: "cond-op-not.mk" line 44: Not 0 evaluates to true. -make: "cond-op-not.mk" line 53: Not 1 evaluates to false. -make: "cond-op-not.mk" line 60: Not word evaluates to false. -make: "cond-op-not.mk" line 65: Malformed conditional '!' +make: cond-op-not.mk:30: Not empty evaluates to true. +make: cond-op-not.mk:39: Not space evaluates to false. +make: cond-op-not.mk:44: Not 0 evaluates to true. +make: cond-op-not.mk:53: Not 1 evaluates to false. +make: cond-op-not.mk:60: Not word evaluates to false. +make: cond-op-not.mk:65: Malformed conditional '!' make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests exit status 1 diff --git a/unit-tests/cond-op-or-lint.exp b/unit-tests/cond-op-or-lint.exp index 0fb1d0dae166..1c5837a9aca6 100644 --- a/unit-tests/cond-op-or-lint.exp +++ b/unit-tests/cond-op-or-lint.exp @@ -1,4 +1,4 @@ -make: "cond-op-or-lint.mk" line 10: Unknown operator '|' +make: cond-op-or-lint.mk:10: Unknown operator '|' make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 diff --git a/unit-tests/cond-op-or.exp b/unit-tests/cond-op-or.exp index f8b6de761755..6213759c24f7 100644 --- a/unit-tests/cond-op-or.exp +++ b/unit-tests/cond-op-or.exp @@ -1,11 +1,11 @@ -make: "cond-op-or.mk" line 36: Variable "UNDEF" is undefined -make: "cond-op-or.mk" line 41: Variable "UNDEF" is undefined -make: "cond-op-or.mk" line 44: Variable "UNDEF" is undefined -make: "cond-op-or.mk" line 60: Unknown operator '|' -make: "cond-op-or.mk" line 66: Unknown operator '|' -make: "cond-op-or.mk" line 72: Unknown operator '|' -make: "cond-op-or.mk" line 78: Unknown operator '|' -make: "cond-op-or.mk" line 87: Unknown operator '|' +make: cond-op-or.mk:36: Variable "UNDEF" is undefined +make: cond-op-or.mk:41: Variable "UNDEF" is undefined +make: cond-op-or.mk:44: Variable "UNDEF" is undefined +make: cond-op-or.mk:60: Unknown operator '|' +make: cond-op-or.mk:66: Unknown operator '|' +make: cond-op-or.mk:72: Unknown operator '|' +make: cond-op-or.mk:78: Unknown operator '|' +make: cond-op-or.mk:87: Unknown operator '|' make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 diff --git a/unit-tests/cond-op-parentheses.exp b/unit-tests/cond-op-parentheses.exp index c11c9eb1be1d..a4091226ec34 100644 --- a/unit-tests/cond-op-parentheses.exp +++ b/unit-tests/cond-op-parentheses.exp @@ -1,7 +1,7 @@ -make: "cond-op-parentheses.mk" line 22: Comparison with '>' requires both operands '3' and '(2' to be numeric -make: "cond-op-parentheses.mk" line 25: Malformed conditional '(3) > 2' -make: "cond-op-parentheses.mk" line 44: Malformed conditional '(' -make: "cond-op-parentheses.mk" line 58: Malformed conditional ')' +make: cond-op-parentheses.mk:22: Comparison with '>' requires both operands '3' and '(2' to be numeric +make: cond-op-parentheses.mk:25: Malformed conditional '(3) > 2' +make: cond-op-parentheses.mk:44: Malformed conditional '(' +make: cond-op-parentheses.mk:58: Malformed conditional ')' make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests exit status 1 diff --git a/unit-tests/cond-op.exp b/unit-tests/cond-op.exp index 3747557789a7..1125a35fa3b3 100644 --- a/unit-tests/cond-op.exp +++ b/unit-tests/cond-op.exp @@ -1,21 +1,21 @@ -make: "cond-op.mk" line 51: Malformed conditional '"!word" == !word' -make: "cond-op.mk" line 72: Malformed conditional '0 ${ERR::=evaluated}' -make: "cond-op.mk" line 77: A misplaced expression after 0 is not evaluated. -make: "cond-op.mk" line 82: Malformed conditional '1 ${ERR::=evaluated}' -make: "cond-op.mk" line 87: A misplaced expression after 1 is not evaluated. -make: "cond-op.mk" line 93: A B C => (A || B) && C A || B && C A || (B && C) -make: "cond-op.mk" line 108: 0 0 0 => 0 0 0 -make: "cond-op.mk" line 108: 0 0 1 => 0 0 0 -make: "cond-op.mk" line 108: 0 1 0 => 0 0 0 -make: "cond-op.mk" line 108: 0 1 1 => 1 1 1 -make: "cond-op.mk" line 108: 1 0 0 => 0 1 1 -make: "cond-op.mk" line 108: 1 0 1 => 1 1 1 -make: "cond-op.mk" line 108: 1 1 0 => 0 1 1 -make: "cond-op.mk" line 108: 1 1 1 => 1 1 1 -make: "cond-op.mk" line 120: Malformed conditional '1 &&' -make: "cond-op.mk" line 129: Malformed conditional '0 &&' -make: "cond-op.mk" line 138: Malformed conditional '1 ||' -make: "cond-op.mk" line 148: Malformed conditional '0 ||' +make: cond-op.mk:51: Malformed conditional '"!word" == !word' +make: cond-op.mk:72: Malformed conditional '0 ${ERR::=evaluated}' +make: cond-op.mk:77: A misplaced expression after 0 is not evaluated. +make: cond-op.mk:82: Malformed conditional '1 ${ERR::=evaluated}' +make: cond-op.mk:87: A misplaced expression after 1 is not evaluated. +make: cond-op.mk:93: A B C => (A || B) && C A || B && C A || (B && C) +make: cond-op.mk:108: 0 0 0 => 0 0 0 +make: cond-op.mk:108: 0 0 1 => 0 0 0 +make: cond-op.mk:108: 0 1 0 => 0 0 0 +make: cond-op.mk:108: 0 1 1 => 1 1 1 +make: cond-op.mk:108: 1 0 0 => 0 1 1 +make: cond-op.mk:108: 1 0 1 => 1 1 1 +make: cond-op.mk:108: 1 1 0 => 0 1 1 +make: cond-op.mk:108: 1 1 1 => 1 1 1 +make: cond-op.mk:120: Malformed conditional '1 &&' +make: cond-op.mk:129: Malformed conditional '0 &&' +make: cond-op.mk:138: Malformed conditional '1 ||' +make: cond-op.mk:148: Malformed conditional '0 ||' make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests exit status 1 diff --git a/unit-tests/cond-short.exp b/unit-tests/cond-short.exp index e9c13d979233..19c7ef3d0b89 100644 --- a/unit-tests/cond-short.exp +++ b/unit-tests/cond-short.exp @@ -7,7 +7,7 @@ expected M pattern expected or expected or exists expected or empty -make: "cond-short.mk" line 231: Comparison with '<' requires both operands '' and '42' to be numeric +make: cond-short.mk:231: Comparison with '<' requires both operands '' and '42' to be numeric make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests exit status 1 diff --git a/unit-tests/cond-token-number.exp b/unit-tests/cond-token-number.exp index eb0870521af1..401f8a2364b7 100644 --- a/unit-tests/cond-token-number.exp +++ b/unit-tests/cond-token-number.exp @@ -1,7 +1,7 @@ -make: "cond-token-number.mk" line 16: Malformed conditional '-0' -make: "cond-token-number.mk" line 27: Malformed conditional '+0' -make: "cond-token-number.mk" line 38: Malformed conditional '!-1' -make: "cond-token-number.mk" line 49: Malformed conditional '!+1' +make: cond-token-number.mk:16: Malformed conditional '-0' +make: cond-token-number.mk:27: Malformed conditional '+0' +make: cond-token-number.mk:38: Malformed conditional '!-1' +make: cond-token-number.mk:49: Malformed conditional '!+1' make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests exit status 1 diff --git a/unit-tests/cond-token-plain.exp b/unit-tests/cond-token-plain.exp index f3425e7f899d..52d7e6fcddaa 100644 --- a/unit-tests/cond-token-plain.exp +++ b/unit-tests/cond-token-plain.exp @@ -27,37 +27,37 @@ Comparing "var&&name" != "var&&name" CondParser_Eval: ${:Uvar}||name != "var||name" Comparing "var||name" != "var||name" CondParser_Eval: bare -make: "cond-token-plain.mk" line 106: A bare word is treated like defined(...), and the variable 'bare' is not defined. +make: cond-token-plain.mk:106: A bare word is treated like defined(...), and the variable 'bare' is not defined. CondParser_Eval: VAR -make: "cond-token-plain.mk" line 113: A bare word is treated like defined(...). +make: cond-token-plain.mk:113: A bare word is treated like defined(...). CondParser_Eval: V${:UA}R -make: "cond-token-plain.mk" line 121: ok +make: cond-token-plain.mk:121: ok CondParser_Eval: V${UNDEF}AR -make: "cond-token-plain.mk" line 130: Undefined variables in bare words expand to an empty string. +make: cond-token-plain.mk:130: Undefined variables in bare words expand to an empty string. CondParser_Eval: 0${:Ux00} -make: "cond-token-plain.mk" line 139: Numbers can be composed from literals and expressions. +make: cond-token-plain.mk:139: Numbers can be composed from literals and expressions. CondParser_Eval: 0${:Ux01} -make: "cond-token-plain.mk" line 144: Numbers can be composed from literals and expressions. +make: cond-token-plain.mk:144: Numbers can be composed from literals and expressions. CondParser_Eval: "" == -make: "cond-token-plain.mk" line 151: Missing right-hand side of operator '==' +make: cond-token-plain.mk:151: Missing right-hand side of operator '==' CondParser_Eval: == "" -make: "cond-token-plain.mk" line 160: Malformed conditional '== ""' +make: cond-token-plain.mk:160: Malformed conditional '== ""' CondParser_Eval: \\ -make: "cond-token-plain.mk" line 176: The variable '\\' is not defined. +make: cond-token-plain.mk:176: The variable '\\' is not defined. CondParser_Eval: \\ -make: "cond-token-plain.mk" line 182: Now the variable '\\' is defined. +make: cond-token-plain.mk:182: Now the variable '\\' is defined. CondParser_Eval: "unquoted\"quoted" != unquoted"quoted Comparing "unquoted"quoted" != "unquoted"quoted" CondParser_Eval: $$$$$$$$ != "" -make: "cond-token-plain.mk" line 197: Malformed conditional '$$$$$$$$ != ""' +make: cond-token-plain.mk:197: Malformed conditional '$$$$$$$$ != ""' CondParser_Eval: left == right -make: "cond-token-plain.mk" line 206: Malformed conditional 'left == right' +make: cond-token-plain.mk:206: Malformed conditional 'left == right' CondParser_Eval: ${0:?:} || left == right CondParser_Eval: 0 -make: "cond-token-plain.mk" line 212: Malformed conditional '${0:?:} || left == right' +make: cond-token-plain.mk:212: Malformed conditional '${0:?:} || left == right' CondParser_Eval: left == right || ${0:?:} -make: "cond-token-plain.mk" line 217: Malformed conditional 'left == right || ${0:?:}' -make: "cond-token-plain.mk" line 236: Malformed conditional 'VAR.${IF_COUNT::+=1} != ""' +make: cond-token-plain.mk:217: Malformed conditional 'left == right || ${0:?:}' +make: cond-token-plain.mk:236: Malformed conditional 'VAR.${IF_COUNT::+=1} != ""' make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 diff --git a/unit-tests/cond-token-string.exp b/unit-tests/cond-token-string.exp index e48244a457e9..d0a5a25f2aa4 100644 --- a/unit-tests/cond-token-string.exp +++ b/unit-tests/cond-token-string.exp @@ -1,18 +1,18 @@ -make: "cond-token-string.mk" line 14: Unknown modifier "Z" +make: cond-token-string.mk:14: Unknown modifier ":Z" while evaluating "${:Uvalue:Z}"" with value "value" -make: "cond-token-string.mk" line 24: xvalue is not defined. -make: "cond-token-string.mk" line 31: Malformed conditional 'x${:Uvalue} == ""' -make: "cond-token-string.mk" line 41: Expected. +make: cond-token-string.mk:24: xvalue is not defined. +make: cond-token-string.mk:31: Malformed conditional 'x${:Uvalue} == ""' +make: cond-token-string.mk:41: Expected. CondParser_Eval: "UNDEF" -make: "cond-token-string.mk" line 51: The string literal "UNDEF" is not empty. +make: cond-token-string.mk:51: The string literal "UNDEF" is not empty. CondParser_Eval: " " -make: "cond-token-string.mk" line 60: The string literal " " is not empty, even though it consists of whitespace only. +make: cond-token-string.mk:60: The string literal " " is not empty, even though it consists of whitespace only. CondParser_Eval: "${UNDEF}" -make: "cond-token-string.mk" line 70: An undefined variable in quotes expands to an empty string, which then evaluates to false. +make: cond-token-string.mk:70: An undefined variable in quotes expands to an empty string, which then evaluates to false. CondParser_Eval: "${:Uvalue}" -make: "cond-token-string.mk" line 76: A nonempty expression evaluates to true. +make: cond-token-string.mk:76: A nonempty expression evaluates to true. CondParser_Eval: "${:U}" -make: "cond-token-string.mk" line 85: An empty variable evaluates to false. +make: cond-token-string.mk:85: An empty variable evaluates to false. CondParser_Eval: ("${VAR}") CondParser_Eval: "quoted" == quoted Comparing "quoted" == "quoted" diff --git a/unit-tests/cond-token-string.mk b/unit-tests/cond-token-string.mk index 45e9cf8a8469..fb069f830582 100644 --- a/unit-tests/cond-token-string.mk +++ b/unit-tests/cond-token-string.mk @@ -1,4 +1,4 @@ -# $NetBSD: cond-token-string.mk,v 1.15 2025/01/11 20:54:45 rillig Exp $ +# $NetBSD: cond-token-string.mk,v 1.16 2025/03/29 19:08:52 rillig Exp $ # # Tests for quoted string literals in .if conditions. # @@ -10,7 +10,7 @@ # Cover the code in CondParser_String that frees the memory after parsing # an expression based on an undefined variable. -# expect+1: Unknown modifier "Z" +# expect+1: Unknown modifier ":Z" .if "" != "${:Uvalue:Z}" . error .else diff --git a/unit-tests/cond-token-var.exp b/unit-tests/cond-token-var.exp index a7e5c8ab5531..1bf61e79ca61 100644 --- a/unit-tests/cond-token-var.exp +++ b/unit-tests/cond-token-var.exp @@ -1,21 +1,27 @@ -make: "cond-token-var.mk" line 23: ok -make: "cond-token-var.mk" line 30: Variable "UNDEF" is undefined -make: "cond-token-var.mk" line 36: Variable "UNDEF" is undefined -make: "cond-token-var.mk" line 46: Variable "UNDEF" is undefined -make: "cond-token-var.mk" line 64: Variable "U" is undefined -make: "cond-token-var.mk" line 69: Variable "U" is undefined -make: "cond-token-var.mk" line 78: Variable "U" is undefined +make: cond-token-var.mk:23: ok +make: cond-token-var.mk:30: Variable "UNDEF" is undefined +make: cond-token-var.mk:36: Variable "UNDEF" is undefined +make: cond-token-var.mk:46: Variable "UNDEF" is undefined +make: cond-token-var.mk:64: Variable "U" is undefined +make: cond-token-var.mk:69: Variable "U" is undefined +make: cond-token-var.mk:78: Variable "U" is undefined Var_Parse: ${UNDEF1}y == "${UNDEF2}" || 0x${UNDEF3} (eval) -make: "cond-token-var.mk" line 106: Malformed conditional 'x${UNDEF1}y == "${UNDEF2}" || 0x${UNDEF3}' +make: cond-token-var.mk:106: Malformed conditional 'x${UNDEF1}y == "${UNDEF2}" || 0x${UNDEF3}' Var_Parse: ${DEF}y == "${UNDEF2}" || 0x${UNDEF3} (eval) -make: "cond-token-var.mk" line 111: Malformed conditional 'x${DEF}y == "${UNDEF2}" || 0x${UNDEF3}' +make: cond-token-var.mk:111: Malformed conditional 'x${DEF}y == "${UNDEF2}" || 0x${UNDEF3}' Var_Parse: ${DEF}y == "${DEF}" || 0x${UNDEF3} (eval) -make: "cond-token-var.mk" line 116: Malformed conditional 'x${DEF}y == "${DEF}" || 0x${UNDEF3}' +make: cond-token-var.mk:116: Malformed conditional 'x${DEF}y == "${DEF}" || 0x${UNDEF3}' Global: VAR.param = value of VAR.param Var_Parse: ${VAR.param$U} (eval-defined-loud) Var_Parse: $U} (eval) Global: .MAKEFLAGS = -r -k -d v -d Global: .MAKEFLAGS = -r -k -d v -d 0 +make: cond-token-var.mk:133: Variable "UNDEF" is undefined + while evaluating variable "UNDEF" with value "" +make: cond-token-var.mk:142: Variable "UNDEF" is undefined + while evaluating variable "UNDEF" with value "" +make: cond-token-var.mk:151: Variable "UNDEF" is undefined + while evaluating variable "UNDEF" with value "" make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 diff --git a/unit-tests/cond-token-var.mk b/unit-tests/cond-token-var.mk index 972a6b3c3d4b..8da8a2436390 100644 --- a/unit-tests/cond-token-var.mk +++ b/unit-tests/cond-token-var.mk @@ -1,4 +1,4 @@ -# $NetBSD: cond-token-var.mk,v 1.11 2025/01/11 21:21:33 rillig Exp $ +# $NetBSD: cond-token-var.mk,v 1.13 2025/04/04 18:57:01 rillig Exp $ # # Tests for expressions in .if conditions. # @@ -126,3 +126,30 @@ VAR.param= value of VAR.param .endif .MAKEFLAGS: -d0 + + +# An expression in a comparison must not be undefined and have modifiers. +# expect+1: Variable "UNDEF" is undefined +.if ${UNDEF:M*} +. error +.else +. error +.endif + +# The left-hand side of a comparison must not be an undefined expression with +# modifiers. +# expect+1: Variable "UNDEF" is undefined +.if ${UNDEF:M*} != "" +. error +.else +. error +.endif + +# The right-hand side of a comparison must not be an undefined expression with +# modifiers. +# expect+1: Variable "UNDEF" is undefined +.if ${:U} != ${UNDEF:M*} +. error +.else +. error +.endif diff --git a/unit-tests/cond-undef-lint.exp b/unit-tests/cond-undef-lint.exp index ce619293a35b..6ffefa6a0243 100755 --- a/unit-tests/cond-undef-lint.exp +++ b/unit-tests/cond-undef-lint.exp @@ -1,6 +1,6 @@ -make: "cond-undef-lint.mk" line 24: Variable "UNDEF" is undefined -make: "cond-undef-lint.mk" line 35: Variable "VAR." is undefined -make: "cond-undef-lint.mk" line 45: Variable "VAR.defined" is undefined +make: cond-undef-lint.mk:24: Variable "UNDEF" is undefined +make: cond-undef-lint.mk:35: Variable "VAR." is undefined +make: cond-undef-lint.mk:45: Variable "VAR.defined" is undefined make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 diff --git a/unit-tests/dep-colon-bug-cross-file.exp b/unit-tests/dep-colon-bug-cross-file.exp index a8ef9d0707af..b3b5cd753b02 100644 --- a/unit-tests/dep-colon-bug-cross-file.exp +++ b/unit-tests/dep-colon-bug-cross-file.exp @@ -1,4 +1,4 @@ -make: "dep-colon-bug-cross-file.mk" line 32: warning: duplicate script for target "all" ignored -make: "dep-colon-bug-cross-file.mk" line 42: warning: using previous script for "all" defined here +make: dep-colon-bug-cross-file.mk:32: warning: duplicate script for target "all" ignored +make: dep-colon-bug-cross-file.mk:42: warning: using previous script for "all" defined here : pass 1 exit status 0 diff --git a/unit-tests/dep-duplicate.exp b/unit-tests/dep-duplicate.exp index dc3b40214d85..3eaa8a4ce5d1 100644 --- a/unit-tests/dep-duplicate.exp +++ b/unit-tests/dep-duplicate.exp @@ -1,4 +1,4 @@ -make: "dep-duplicate.tmp" line 1: warning: duplicate script for target "all" ignored -make: "dep-duplicate.main" line 3: warning: using previous script for "all" defined here +make: dep-duplicate.tmp:1: warning: duplicate script for target "all" ignored +make: dep-duplicate.main:3: warning: using previous script for "all" defined here main-output exit status 0 diff --git a/unit-tests/dep-op-missing.exp b/unit-tests/dep-op-missing.exp index 2a25286aa407..5ae39b5fd256 100644 --- a/unit-tests/dep-op-missing.exp +++ b/unit-tests/dep-op-missing.exp @@ -1,4 +1,4 @@ -make: "dep-op-missing.tmp" line 1: Invalid line 'target' +make: dep-op-missing.tmp:1: Invalid line 'target' in directory <curdir> make: Fatal errors encountered -- cannot continue make: stopped in unit-tests diff --git a/unit-tests/dep.exp b/unit-tests/dep.exp index c12fa3f90b3e..c08f86bc73db 100644 --- a/unit-tests/dep.exp +++ b/unit-tests/dep.exp @@ -1,5 +1,5 @@ -make: "dep.mk" line 11: Inconsistent operator for only-colon -make: "dep.mk" line 13: Inconsistent operator for only-colon +make: dep.mk:11: Inconsistent operator for only-colon +make: dep.mk:13: Inconsistent operator for only-colon make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests exit status 1 diff --git a/unit-tests/deptgt-begin.exp b/unit-tests/deptgt-begin.exp index db4c7d7dfa13..bf6f61a51e72 100644 --- a/unit-tests/deptgt-begin.exp +++ b/unit-tests/deptgt-begin.exp @@ -1,5 +1,5 @@ -make: "deptgt-begin.mk" line 19: warning: duplicate script for target ".BEGIN" ignored -make: "deptgt-begin.mk" line 9: warning: using previous script for ".BEGIN" defined here +make: deptgt-begin.mk:19: warning: duplicate script for target ".BEGIN" ignored +make: deptgt-begin.mk:9: warning: using previous script for ".BEGIN" defined here : parse time : Making before-begin before .BEGIN. : .BEGIN diff --git a/unit-tests/deptgt-path-suffix.exp b/unit-tests/deptgt-path-suffix.exp index 8c2437f3010f..6294d8a39dc0 100644 --- a/unit-tests/deptgt-path-suffix.exp +++ b/unit-tests/deptgt-path-suffix.exp @@ -1,4 +1,4 @@ -make: "deptgt-path-suffix.mk" line 8: Suffix '.c' not defined (yet) +make: deptgt-path-suffix.mk:8: Suffix '.c' not defined (yet) make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests exit status 1 diff --git a/unit-tests/deptgt.exp b/unit-tests/deptgt.exp index 8a70e2495038..4c7cb4e50ddc 100644 --- a/unit-tests/deptgt.exp +++ b/unit-tests/deptgt.exp @@ -1,5 +1,5 @@ -make: "deptgt.mk" line 11: warning: Extra target '.PHONY' ignored -make: "deptgt.mk" line 30: Unassociated shell command ": command3 # parse error, since targets == NULL" +make: deptgt.mk:11: warning: Extra target '.PHONY' ignored +make: deptgt.mk:30: Unassociated shell command ": command3 # parse error, since targets == NULL" Parsing deptgt.mk:36: ${:U}: empty-source ParseDependency(: empty-source) Parsing deptgt.mk:37: : command for empty targets list @@ -14,13 +14,13 @@ Global: .ALLTARGETS = target1 target2 sources empty-source deptgt- Global: .ALLTARGETS = target1 target2 sources empty-source deptgt- depsrc- Global: .MAKEFLAGS = -r -k -d p -d 0 -d v -d Global: .MAKEFLAGS = -r -k -d p -d 0 -d v -d 0 -make: "deptgt.mk" line 51: Unknown modifier "Z" +make: deptgt.mk:51: Unknown modifier ":Z" while evaluating "${:U:Z}:" with value "" -make: "deptgt.mk" line 55: Unknown modifier "Z" +make: deptgt.mk:55: Unknown modifier ":Z" while parsing "${:U:Z}:" -make: "deptgt.mk" line 58: warning: Extra target 'ordinary' ignored -make: "deptgt.mk" line 61: warning: Extra target (ordinary) ignored -make: "deptgt.mk" line 64: warning: Special and mundane targets don't mix. Mundane ones ignored +make: deptgt.mk:58: warning: Extra target 'ordinary' ignored +make: deptgt.mk:61: warning: Extra target (ordinary) ignored +make: deptgt.mk:64: warning: Special and mundane targets don't mix. Mundane ones ignored make: Fatal errors encountered -- cannot continue make: stopped making "target1" in unit-tests exit status 1 diff --git a/unit-tests/deptgt.mk b/unit-tests/deptgt.mk index f841f24e8984..779a1faf7115 100644 --- a/unit-tests/deptgt.mk +++ b/unit-tests/deptgt.mk @@ -1,4 +1,4 @@ -# $NetBSD: deptgt.mk,v 1.22 2025/01/10 23:00:38 rillig Exp $ +# $NetBSD: deptgt.mk,v 1.23 2025/03/29 19:08:52 rillig Exp $ # # Tests for special targets like .BEGIN or .SUFFIXES in dependency # declarations. @@ -47,11 +47,11 @@ deptgt-${UNDEF}: depsrc-${UNDEF} # In a dependency declaration, the whole line is expanded before interpreting # the line. -# expect+1: Unknown modifier "Z" +# expect+1: Unknown modifier ":Z" ${:U:Z}: # After expanding the line as a whole, each target is parsed but not # evaluated, separately, in ParseDependencyTargetWord. -# expect+1: Unknown modifier "Z" +# expect+1: Unknown modifier ":Z" $${:U:Z}: # expect+1: warning: Extra target 'ordinary' ignored diff --git a/unit-tests/directive-dinclude.exp b/unit-tests/directive-dinclude.exp index 58bcb105b829..5f5fec4d403e 100755 --- a/unit-tests/directive-dinclude.exp +++ b/unit-tests/directive-dinclude.exp @@ -1,4 +1,4 @@ -make: "directive-dinclude-error.inc" line 1: Invalid line 'syntax error' +make: directive-dinclude-error.inc:1: Invalid line 'syntax error' in directive-dinclude.mk:21 make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests diff --git a/unit-tests/directive-dinclude.mk b/unit-tests/directive-dinclude.mk index 7fccff413cd6..c363209579ad 100755 --- a/unit-tests/directive-dinclude.mk +++ b/unit-tests/directive-dinclude.mk @@ -1,4 +1,4 @@ -# $NetBSD: directive-dinclude.mk,v 1.3 2023/08/19 10:52:13 rillig Exp $ +# $NetBSD: directive-dinclude.mk,v 1.4 2025/03/30 09:51:50 rillig Exp $ # # Tests for the .dinclude directive, which includes another file, # silently skipping it if it cannot be opened. This is primarily used for @@ -16,7 +16,7 @@ .dinclude "${MAKEFILE}/subdir" # Errors that are not related to opening the file are still reported. -# expect: make: "directive-dinclude-error.inc" line 1: Invalid line 'syntax error' +# expect: make: directive-dinclude-error.inc:1: Invalid line 'syntax error' _!= echo 'syntax error' > directive-dinclude-error.inc .dinclude "${.CURDIR}/directive-dinclude-error.inc" _!= rm directive-dinclude-error.inc diff --git a/unit-tests/directive-elif.exp b/unit-tests/directive-elif.exp index fc0e749ed61a..0160665b3c01 100644 --- a/unit-tests/directive-elif.exp +++ b/unit-tests/directive-elif.exp @@ -1,21 +1,21 @@ -make: "directive-elif.mk" line 48: Unknown directive "elsif" -make: "directive-elif.mk" line 54: This branch is taken. -make: "directive-elif.mk" line 62: Unknown directive "elsif" -make: "directive-elif.mk" line 66: This branch is taken. -make: "directive-elif.mk" line 73: This branch is taken. -make: "directive-elif.mk" line 94: Unknown directive "elsif" -make: "directive-elif.mk" line 96: This misspelling is detected. -make: "directive-elif.mk" line 98: This branch is taken because of the .else. -make: "directive-elif.mk" line 117: What happens on misspelling in a skipped branch? -make: "directive-elif.mk" line 128: else -make: "directive-elif.mk" line 132: What happens on misspelling in a taken branch? -make: "directive-elif.mk" line 135: 1-then -make: "directive-elif.mk" line 137: Unknown directive "elsif" -make: "directive-elif.mk" line 139: 1-elsif -make: "directive-elif.mk" line 141: Unknown directive "elsif" -make: "directive-elif.mk" line 143: 2-elsif -make: "directive-elif.mk" line 149: if-less elif -make: "directive-elif.mk" line 154: warning: extra elif +make: directive-elif.mk:48: Unknown directive "elsif" +make: directive-elif.mk:54: This branch is taken. +make: directive-elif.mk:62: Unknown directive "elsif" +make: directive-elif.mk:66: This branch is taken. +make: directive-elif.mk:73: This branch is taken. +make: directive-elif.mk:94: Unknown directive "elsif" +make: directive-elif.mk:96: This misspelling is detected. +make: directive-elif.mk:98: This branch is taken because of the .else. +make: directive-elif.mk:117: What happens on misspelling in a skipped branch? +make: directive-elif.mk:128: else +make: directive-elif.mk:132: What happens on misspelling in a taken branch? +make: directive-elif.mk:135: 1-then +make: directive-elif.mk:137: Unknown directive "elsif" +make: directive-elif.mk:139: 1-elsif +make: directive-elif.mk:141: Unknown directive "elsif" +make: directive-elif.mk:143: 2-elsif +make: directive-elif.mk:149: if-less elif +make: directive-elif.mk:154: warning: extra elif make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests exit status 1 diff --git a/unit-tests/directive-else.exp b/unit-tests/directive-else.exp index 8d34f94aa12f..ce50b9d9d33e 100644 --- a/unit-tests/directive-else.exp +++ b/unit-tests/directive-else.exp @@ -1,11 +1,11 @@ -make: "directive-else.mk" line 14: The .else directive does not take arguments -make: "directive-else.mk" line 16: ok -make: "directive-else.mk" line 21: ok -make: "directive-else.mk" line 23: The .else directive does not take arguments -make: "directive-else.mk" line 29: if-less else -make: "directive-else.mk" line 36: ok -make: "directive-else.mk" line 38: warning: extra else -make: "directive-else.mk" line 51: The .else directive does not take arguments +make: directive-else.mk:14: The .else directive does not take arguments +make: directive-else.mk:16: ok +make: directive-else.mk:21: ok +make: directive-else.mk:23: The .else directive does not take arguments +make: directive-else.mk:29: if-less else +make: directive-else.mk:36: ok +make: directive-else.mk:38: warning: extra else +make: directive-else.mk:51: The .else directive does not take arguments make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests exit status 1 diff --git a/unit-tests/directive-endfor.exp b/unit-tests/directive-endfor.exp index 8b77c0b31307..a78ab1013a6b 100644 --- a/unit-tests/directive-endfor.exp +++ b/unit-tests/directive-endfor.exp @@ -1,4 +1,4 @@ -make: "directive-endfor.mk" line 10: for-less endfor +make: directive-endfor.mk:10: for-less endfor make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 diff --git a/unit-tests/directive-endif.exp b/unit-tests/directive-endif.exp index c88cc97c44c5..6a8f0bbf446f 100644 --- a/unit-tests/directive-endif.exp +++ b/unit-tests/directive-endif.exp @@ -1,8 +1,8 @@ -make: "directive-endif.mk" line 16: The .endif directive does not take arguments -make: "directive-endif.mk" line 21: The .endif directive does not take arguments -make: "directive-endif.mk" line 32: The .endif directive does not take arguments -make: "directive-endif.mk" line 39: The .endif directive does not take arguments -make: "directive-endif.mk" line 44: Unknown directive "endifx" +make: directive-endif.mk:16: The .endif directive does not take arguments +make: directive-endif.mk:21: The .endif directive does not take arguments +make: directive-endif.mk:32: The .endif directive does not take arguments +make: directive-endif.mk:39: The .endif directive does not take arguments +make: directive-endif.mk:44: Unknown directive "endifx" make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 diff --git a/unit-tests/directive-error.exp b/unit-tests/directive-error.exp index 8ce33160e67f..4181592e4835 100644 --- a/unit-tests/directive-error.exp +++ b/unit-tests/directive-error.exp @@ -1,4 +1,4 @@ -make: "directive-error.mk" line 14: message +make: directive-error.mk:14: message make: stopped in unit-tests exit status 1 diff --git a/unit-tests/directive-export-gmake.exp b/unit-tests/directive-export-gmake.exp index fe966893f4a9..f7bb07ab9da2 100644 --- a/unit-tests/directive-export-gmake.exp +++ b/unit-tests/directive-export-gmake.exp @@ -1,7 +1,7 @@ -make: "directive-export-gmake.mk" line 71: Invalid line 'export VAR=${:U1}', expanded to 'export VAR=1' +make: directive-export-gmake.mk:71: Invalid line 'export VAR=${:U1}', expanded to 'export VAR=1' in .for loop from directive-export-gmake.mk:67 with value = 1 -make: "directive-export-gmake.mk" line 85: 16:00:00 -make: "directive-export-gmake.mk" line 92: Variable/Value missing from "export" +make: directive-export-gmake.mk:85: 16:00:00 +make: directive-export-gmake.mk:92: Variable/Value missing from "export" make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 diff --git a/unit-tests/directive-export.exp b/unit-tests/directive-export.exp index 02271508cf42..b4bada820ccd 100644 --- a/unit-tests/directive-export.exp +++ b/unit-tests/directive-export.exp @@ -1,5 +1,5 @@ -make: "directive-export.mk" line 36: warning: .export requires an argument. -make: "directive-export.mk" line 60: 00:00:00 -make: "directive-export.mk" line 65: 00:00:00 -make: "directive-export.mk" line 68: 16:00:00 +make: directive-export.mk:36: warning: .export requires an argument. +make: directive-export.mk:60: 00:00:00 +make: directive-export.mk:65: 00:00:00 +make: directive-export.mk:68: 16:00:00 exit status 0 diff --git a/unit-tests/directive-for-break.exp b/unit-tests/directive-for-break.exp index df2064a4eca0..cf46837df6c6 100644 --- a/unit-tests/directive-for-break.exp +++ b/unit-tests/directive-for-break.exp @@ -1,5 +1,5 @@ -make: "directive-for-break.mk" line 45: break outside of for loop -make: "directive-for-break.mk" line 65: The .break directive does not take arguments +make: directive-for-break.mk:45: break outside of for loop +make: directive-for-break.mk:65: The .break directive does not take arguments in .for loop from directive-for-break.mk:63 with i = 1 make: Fatal errors encountered -- cannot continue make: stopped in unit-tests diff --git a/unit-tests/directive-for-empty.exp b/unit-tests/directive-for-empty.exp index f0389d329341..ae8e97edb777 100644 --- a/unit-tests/directive-for-empty.exp +++ b/unit-tests/directive-for-empty.exp @@ -1,4 +1,4 @@ -make: "directive-for-empty.mk" line 22: 2 +make: directive-for-empty.mk:22: 2 For: end for 1 For: loop body with i = value: # The identifier 'empty' can only be used in conditions such as .if, .ifdef or diff --git a/unit-tests/directive-for-errors.exp b/unit-tests/directive-for-errors.exp index e5d5cd158e8e..6064f35a1944 100644 --- a/unit-tests/directive-for-errors.exp +++ b/unit-tests/directive-for-errors.exp @@ -1,18 +1,15 @@ -make: "directive-for-errors.mk" line 9: Unknown directive "fori" -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 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.mk" line 64: Wrong number of words (5) in .for substitution list with 3 variables -make: "directive-for-errors.mk" line 78: missing `in' in for -make: "directive-for-errors.mk" line 89: Unknown modifier "Z" +make: directive-for-errors.mk:9: Unknown directive "fori" +make: directive-for-errors.mk:11: warning: <> +make: directive-for-errors.mk:13: for-less endfor +make: directive-for-errors.mk:25: Unknown directive "for" +make: directive-for-errors.mk:27: warning: <> +make: directive-for-errors.mk:29: for-less endfor +make: directive-for-errors.mk:44: invalid character '$' in .for loop variable name +make: directive-for-errors.mk:52: no iteration variables in for +make: directive-for-errors.mk:64: Wrong number of words (5) in .for substitution list with 3 variables +make: directive-for-errors.mk:78: missing `in' in for +make: directive-for-errors.mk:86: Unknown modifier ":Z" while evaluating "${:U3:Z} 4" with value "3" -make: "directive-for-errors.mk" line 93: warning: Should not be reached. -make: "directive-for-errors.mk" line 93: warning: Should not be reached. -make: "directive-for-errors.mk" line 93: warning: Should not be reached. make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 diff --git a/unit-tests/directive-for-errors.mk b/unit-tests/directive-for-errors.mk index 0fb556ec8ec3..42f93b0212f2 100644 --- a/unit-tests/directive-for-errors.mk +++ b/unit-tests/directive-for-errors.mk @@ -1,4 +1,4 @@ -# $NetBSD: directive-for-errors.mk,v 1.14 2024/08/29 20:20:36 rillig Exp $ +# $NetBSD: directive-for-errors.mk,v 1.16 2025/03/30 16:43:10 rillig Exp $ # # Tests for error handling in .for loops. @@ -81,14 +81,8 @@ ${:U\\}= backslash # see whether the "variable" '\' is local .endfor -# A malformed modifier should be detected and skip the body of the loop. -# -# XXX: As of 2020-12-31, Var_Subst doesn't report any errors, therefore -# the loop body is expanded as if no error had happened. -# expect+1: Unknown modifier "Z" +# An error in the items skips the body of the loop. +# expect+1: Unknown modifier ":Z" .for i in 1 2 ${:U3:Z} 4 -# expect+3: warning: Should not be reached. -# expect+2: warning: Should not be reached. -# expect+1: warning: Should not be reached. -. warning Should not be reached. +. error .endfor diff --git a/unit-tests/directive-for-escape.exp b/unit-tests/directive-for-escape.exp index be6c2b2a41bf..6ab8a333a10f 100644 --- a/unit-tests/directive-for-escape.exp +++ b/unit-tests/directive-for-escape.exp @@ -1,49 +1,49 @@ For: end for 1 For: loop body with chars = !"#$%&'()*+,-./0-9:;<=>?@A-Z[\]_^a-z{|}~: . info ${:U!"#$%&'()*+,-./0-9\:;<=>?@A-Z[\\]_^a-z{|\}~} -make: "directive-for-escape.mk" line 21: Unclosed expression, expecting '}' for modifier "U!"" +make: directive-for-escape.mk:21: Unclosed expression, expecting '}' for modifier "U!"" while evaluating "${:U!"" with value "!"" in .for loop from directive-for-escape.mk:20 with chars = !"#$%&'()*+,-./0-9:;<=>?@A-Z[\]_^a-z{|}~ -make: "directive-for-escape.mk" line 21: !" +make: directive-for-escape.mk:21: !" For: end for 1 For: loop body with chars = !"\\#$%&'()*+,-./0-9:;<=>?@A-Z[\]_^a-z{|}~: . info ${:U!"\\\\#$%&'()*+,-./0-9\:;<=>?@A-Z[\\]_^a-z{|\}~} -make: "directive-for-escape.mk" line 33: Unclosed expression, expecting '}' for modifier "U!"\\\\" +make: directive-for-escape.mk:33: Unclosed expression, expecting '}' for modifier "U!"\\\\" while evaluating "${:U!"\\\\" with value "!"\\" in .for loop from directive-for-escape.mk:32 with chars = !"\\#$%&'()*+,-./0-9:;<=>?@A-Z[\]_^a-z{|}~ -make: "directive-for-escape.mk" line 33: !"\\ +make: directive-for-escape.mk:33: !"\\ For: end for 1 For: loop body with i = $: . info ${:U\$} -make: "directive-for-escape.mk" line 57: $ +make: directive-for-escape.mk:57: $ For: loop body with i = ${V}: . info ${:U${V}} -make: "directive-for-escape.mk" line 57: value +make: directive-for-escape.mk:57: value For: loop body with i = ${V:=-with-modifier}: . info ${:U${V:=-with-modifier}} -make: "directive-for-escape.mk" line 57: value-with-modifier +make: directive-for-escape.mk:57: value-with-modifier For: loop body with i = $(V): . info ${:U$(V)} -make: "directive-for-escape.mk" line 57: value +make: directive-for-escape.mk:57: value For: loop body with i = $(V:=-with-modifier): . info ${:U$(V:=-with-modifier)} -make: "directive-for-escape.mk" line 57: value-with-modifier +make: directive-for-escape.mk:57: value-with-modifier For: end for 1 For: loop body with i = $: . info ${:U\$} -make: "directive-for-escape.mk" line 69: $ +make: directive-for-escape.mk:69: $ For: loop body with i = ${V}: . info ${:U${V}} -make: "directive-for-escape.mk" line 69: value +make: directive-for-escape.mk:69: value For: loop body with i = ${V:=-with-modifier}: . info ${:U${V:=-with-modifier}} -make: "directive-for-escape.mk" line 69: value-with-modifier +make: directive-for-escape.mk:69: value-with-modifier For: loop body with i = $(V): . info ${:U$(V)} -make: "directive-for-escape.mk" line 69: value +make: directive-for-escape.mk:69: value For: loop body with i = $(V:=-with-modifier): . info ${:U$(V:=-with-modifier)} -make: "directive-for-escape.mk" line 69: value-with-modifier +make: directive-for-escape.mk:69: value-with-modifier For: end for 1 For: loop body with i = ${UNDEF:U\$\$: # ${:U\${UNDEF\:U\\$\\$} @@ -54,62 +54,62 @@ For: loop body with i = end}: For: end for 1 For: loop body with i = ${UNDEF:U\$\$: . info ${:U\${UNDEF\:U\\$\\$} -make: "directive-for-escape.mk" line 120: ${UNDEF:U\backslash$ +make: directive-for-escape.mk:120: ${UNDEF:U\backslash$ For: loop body with i = {{}}: . info ${:U{{\}\}} -make: "directive-for-escape.mk" line 120: {{}} +make: directive-for-escape.mk:120: {{}} For: loop body with i = end}: . info ${:Uend\}} -make: "directive-for-escape.mk" line 120: end} +make: directive-for-escape.mk:120: end} For: end for 1 For: loop body with i = begin<${UNDEF:Ufallback:N{{{}}}}>end: . info ${:Ubegin<${UNDEF:Ufallback:N{{{}}}}>end} -make: "directive-for-escape.mk" line 138: begin<fallback>end +make: directive-for-escape.mk:138: begin<fallback>end For: end for 1 For: loop body with i = $: . info ${:U\$} -make: "directive-for-escape.mk" line 147: $ -make: "directive-for-escape.mk" line 155: invalid character ':' in .for loop variable name +make: directive-for-escape.mk:147: $ +make: directive-for-escape.mk:155: invalid character ':' in .for loop variable name For: end for 1 -make: "directive-for-escape.mk" line 165: invalid character '}' in .for loop variable name +make: directive-for-escape.mk:165: invalid character '}' in .for loop variable name For: end for 1 For: end for 1 For: loop body with i = inner: . info ${:Uinner} ${:Uinner} ${:Uinner:M*} $(:Uinner) $(:Uinner:M*) -make: "directive-for-escape.mk" line 175: inner inner inner inner inner +make: directive-for-escape.mk:175: inner inner inner inner inner For: end for 1 For: loop body with i = inner: . info ${i${:U}} -make: "directive-for-escape.mk" line 179: outer +make: directive-for-escape.mk:179: outer For: end for 1 For: loop body with i = inner: . info ${:Uinner\}} # XXX: unclear why ForLoop_SubstVarLong needs this -make: "directive-for-escape.mk" line 183: inner} +make: directive-for-escape.mk:183: inner} For: end for 1 For: loop body with i = inner: . info ${i2} ${i,} ${:Uinner}${:Uinner}${:Uinner:M*}${:Uinner} -make: "directive-for-escape.mk" line 187: two comma innerinnerinnerinner -make: "directive-for-escape.mk" line 196: invalid character '$' in .for loop variable name +make: directive-for-escape.mk:187: two comma innerinnerinnerinner +make: directive-for-escape.mk:196: invalid character '$' in .for loop variable name For: end for 1 -make: "directive-for-escape.mk" line 208: eight and no cents. +make: directive-for-escape.mk:208: eight and no cents. For: end for 1 -make: "directive-for-escape.mk" line 222: newline in .for value +make: directive-for-escape.mk:222: newline in .for value in .for loop from directive-for-escape.mk:222 with i = " " -make: "directive-for-escape.mk" line 222: newline in .for value +make: directive-for-escape.mk:222: newline in .for value in .for loop from directive-for-escape.mk:222 with i = " " For: loop body with i = " ": . info short: ${:U" "}, long: ${:U" "} -make: "directive-for-escape.mk" line 223: short: " ", long: " " +make: directive-for-escape.mk:223: short: " ", long: " " For: end for 1 For: loop body with i = " ": Parsing directive-for-escape.mk:236: .for i in "${.newline}" For: end for 1 -Parse_PushInput: .for loop in directive-for-escape.mk, line 236 -make: "directive-for-escape.mk" line 236: newline in .for value +Parse_PushInput: .for loop in directive-for-escape.mk:236 +make: directive-for-escape.mk:236: newline in .for value in .for loop from directive-for-escape.mk:236 with i = " " For: loop body with i = " @@ -118,7 +118,7 @@ For: loop body with i = " SetFilenameVars: ${.PARSEDIR} = <some-dir> ${.PARSEFILE} = `directive-for-escape.mk' Parsing directive-for-escape.mk:237: : ${:U" "} ParseDependency(: " ") -ParseEOF: returning to file directive-for-escape.mk, line 239 +ParseEOF: returning to directive-for-escape.mk:239 SetFilenameVars: ${.PARSEDIR} = <some-dir> ${.PARSEFILE} = `directive-for-escape.mk' Parsing directive-for-escape.mk:239: .MAKEFLAGS: -d0 ParseDependency(.MAKEFLAGS: -d0) diff --git a/unit-tests/directive-for-generating-endif.exp b/unit-tests/directive-for-generating-endif.exp index 142189f70579..983ea5d6a4cd 100755 --- a/unit-tests/directive-for-generating-endif.exp +++ b/unit-tests/directive-for-generating-endif.exp @@ -1,10 +1,10 @@ -make: "directive-for-generating-endif.mk" line 24: if-less endif +make: directive-for-generating-endif.mk:24: if-less endif in .for loop from directive-for-generating-endif.mk:20 with i = 3 -make: "directive-for-generating-endif.mk" line 24: if-less endif +make: directive-for-generating-endif.mk:24: if-less endif in .for loop from directive-for-generating-endif.mk:20 with i = 2 -make: "directive-for-generating-endif.mk" line 24: if-less endif +make: directive-for-generating-endif.mk:24: if-less endif in .for loop from directive-for-generating-endif.mk:20 with i = 1 -make: "directive-for-generating-endif.mk" line 30: 3 open conditionals +make: directive-for-generating-endif.mk:30: 3 open conditionals make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests exit status 1 diff --git a/unit-tests/directive-for-if.exp b/unit-tests/directive-for-if.exp index 71ea8ae63569..0b7ed45eb2a5 100644 --- a/unit-tests/directive-for-if.exp +++ b/unit-tests/directive-for-if.exp @@ -1,8 +1,8 @@ -make: "directive-for-if.mk" line 51: if-less endif +make: directive-for-if.mk:51: if-less endif in .for loop from directive-for-if.mk:46 with directive = if -make: "directive-for-if.mk" line 51: if-less endif +make: directive-for-if.mk:51: if-less endif in .for loop from directive-for-if.mk:46 with directive = ifdef -make: "directive-for-if.mk" line 51: if-less endif +make: directive-for-if.mk:51: if-less endif in .for loop from directive-for-if.mk:46 with directive = ifndef VAR1 VAR3 diff --git a/unit-tests/directive-for-lines.exp b/unit-tests/directive-for-lines.exp index 857b4829083b..bf5b2b8b1209 100644 --- a/unit-tests/directive-for-lines.exp +++ b/unit-tests/directive-for-lines.exp @@ -1,9 +1,9 @@ -make: "directive-for-lines.mk" line 27: expect 23 -make: "directive-for-lines.mk" line 27: expect 23 -make: "directive-for-lines.mk" line 36: expect 30 -make: "directive-for-lines.mk" line 27: expect 23 -make: "directive-for-lines.mk" line 27: expect 23 -make: "directive-for-lines.mk" line 36: expect 30 +make: directive-for-lines.mk:27: expect 23 +make: directive-for-lines.mk:27: expect 23 +make: directive-for-lines.mk:36: expect 30 +make: directive-for-lines.mk:27: expect 23 +make: directive-for-lines.mk:27: expect 23 +make: directive-for-lines.mk:36: expect 30 make: no target to make. make: stopped in unit-tests diff --git a/unit-tests/directive-for-null.exp b/unit-tests/directive-for-null.exp index 8aa36598550d..0a94c7d9e451 100644 --- a/unit-tests/directive-for-null.exp +++ b/unit-tests/directive-for-null.exp @@ -1,4 +1,4 @@ -make: "(stdin)" line 2: Zero byte read from file +make: (stdin):2: Zero byte read from file in directory <curdir> *** Error code 2 (continuing) diff --git a/unit-tests/directive-for-null.mk b/unit-tests/directive-for-null.mk index d3de8b598bc2..a833cd1a32e4 100644 --- a/unit-tests/directive-for-null.mk +++ b/unit-tests/directive-for-null.mk @@ -1,8 +1,8 @@ -# $NetBSD: directive-for-null.mk,v 1.4 2024/04/01 12:26:02 rillig Exp $ +# $NetBSD: directive-for-null.mk,v 1.5 2025/03/30 09:51:50 rillig Exp $ # # Test for parsing a .for loop that accidentally contains a null byte. # -# expect: make: "(stdin)" line 2: Zero byte read from file +# expect: make: (stdin):2: Zero byte read from file all: .PHONY @printf '%s\n' \ diff --git a/unit-tests/directive-for.exp b/unit-tests/directive-for.exp index b76a62bc81a2..cf87e6ea8569 100755 --- a/unit-tests/directive-for.exp +++ b/unit-tests/directive-for.exp @@ -1,34 +1,29 @@ -make: "directive-for.mk" line 117: outer -make: "directive-for.mk" line 138: a:\ a:\file.txt -make: "directive-for.mk" line 138: d:\\ -make: "directive-for.mk" line 138: d:\\file.txt -make: "directive-for.mk" line 158: ( ( ( -make: "directive-for.mk" line 158: [ [ [ -make: "directive-for.mk" line 158: { { { -make: "directive-for.mk" line 158: ) ) ) -make: "directive-for.mk" line 158: ] ] ] -make: "directive-for.mk" line 158: } } } -make: "directive-for.mk" line 158: (()) (()) (()) -make: "directive-for.mk" line 158: [[]] [[]] [[]] -make: "directive-for.mk" line 158: {{}} {{}} {{}} -make: "directive-for.mk" line 158: )( )( )( -make: "directive-for.mk" line 158: ][ ][ ][ -make: "directive-for.mk" line 158: }{ }{ }{ -make: "directive-for.mk" line 166: invalid character ':' in .for loop variable name -make: "directive-for.mk" line 173: invalid character '$' in .for loop variable name -make: "directive-for.mk" line 185: invalid character '$' in .for loop variable name -make: "directive-for.mk" line 210: Unknown modifier "Z" - while evaluating "${:Uword2:Z}-after word3" with value "word2" -make: "directive-for.mk" line 214: XXX: Should not reach word1 -make: "directive-for.mk" line 214: XXX: Should not reach before--after -make: "directive-for.mk" line 214: XXX: Should not reach word3 -make: "directive-for.mk" line 219: no iteration variables in for -make: "directive-for.mk" line 245: 1 open conditional - in .for loop from directive-for.mk:243 with var = value -make: "directive-for.mk" line 261: for-less endfor -make: "directive-for.mk" line 262: if-less endif -make: "directive-for.mk" line 270: if-less endif - in .for loop from directive-for.mk:269 with var = value +make: directive-for.mk:117: outer +make: directive-for.mk:138: a:\ a:\file.txt +make: directive-for.mk:138: d:\\ +make: directive-for.mk:138: d:\\file.txt +make: directive-for.mk:158: ( ( ( +make: directive-for.mk:158: [ [ [ +make: directive-for.mk:158: { { { +make: directive-for.mk:158: ) ) ) +make: directive-for.mk:158: ] ] ] +make: directive-for.mk:158: } } } +make: directive-for.mk:158: (()) (()) (()) +make: directive-for.mk:158: [[]] [[]] [[]] +make: directive-for.mk:158: {{}} {{}} {{}} +make: directive-for.mk:158: )( )( )( +make: directive-for.mk:158: ][ ][ ][ +make: directive-for.mk:158: }{ }{ }{ +make: directive-for.mk:166: invalid character ':' in .for loop variable name +make: directive-for.mk:173: invalid character '$' in .for loop variable name +make: directive-for.mk:185: invalid character '$' in .for loop variable name +make: directive-for.mk:207: no iteration variables in for +make: directive-for.mk:233: 1 open conditional + in .for loop from directive-for.mk:231 with var = value +make: directive-for.mk:249: for-less endfor +make: directive-for.mk:250: if-less endif +make: directive-for.mk:258: if-less endif + in .for loop from directive-for.mk:257 with var = value For: new loop 2 For: end for 2 For: end for 1 @@ -39,7 +34,7 @@ For: loop body with outer = o: endfor For: end for 1 For: loop body with inner = i: -make: "directive-for.mk" line 319: newline-item=(a) +make: directive-for.mk:307: newline-item=(a) make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 diff --git a/unit-tests/directive-for.mk b/unit-tests/directive-for.mk index cf24e282f730..2f989f54f228 100755 --- a/unit-tests/directive-for.mk +++ b/unit-tests/directive-for.mk @@ -1,4 +1,4 @@ -# $NetBSD: directive-for.mk,v 1.28 2024/08/29 20:20:36 rillig Exp $ +# $NetBSD: directive-for.mk,v 1.30 2025/03/30 16:43:10 rillig Exp $ # # Tests for the .for directive. # @@ -203,18 +203,6 @@ INDIRECT= ${DIRECT} .endfor -# XXX: A parse error or evaluation error in the items of the .for loop -# should skip the whole loop. As of 2023-05-09, the loop is expanded as -# usual. -# expect+1: Unknown modifier "Z" -.for var in word1 before-${:Uword2:Z}-after word3 -# expect+3: XXX: Should not reach word1 -# expect+2: XXX: Should not reach before--after -# expect+1: XXX: Should not reach word3 -. info XXX: Should not reach ${var} -.endfor - - # An empty list of variables to the left of the 'in' is a parse error. .for in value # expect+0: no iteration variables in for . error diff --git a/unit-tests/directive-hyphen-include.exp b/unit-tests/directive-hyphen-include.exp index d840a247102d..3f17f0c41f0b 100755 --- a/unit-tests/directive-hyphen-include.exp +++ b/unit-tests/directive-hyphen-include.exp @@ -1,4 +1,4 @@ -make: "directive-hyphen-include-error.inc" line 1: Invalid line 'syntax error' +make: directive-hyphen-include-error.inc:1: Invalid line 'syntax error' in directive-hyphen-include.mk:20 make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests diff --git a/unit-tests/directive-hyphen-include.mk b/unit-tests/directive-hyphen-include.mk index de3b68ae52b3..ad596f4c47db 100755 --- a/unit-tests/directive-hyphen-include.mk +++ b/unit-tests/directive-hyphen-include.mk @@ -1,4 +1,4 @@ -# $NetBSD: directive-hyphen-include.mk,v 1.3 2023/08/19 10:52:13 rillig Exp $ +# $NetBSD: directive-hyphen-include.mk,v 1.4 2025/03/30 09:51:50 rillig Exp $ # # Tests for the .-include directive, which includes another file, # silently skipping it if it cannot be opened. @@ -15,7 +15,7 @@ .-include "${MAKEFILE}/subdir" # Errors that are not related to opening the file are still reported. -# expect: make: "directive-hyphen-include-error.inc" line 1: Invalid line 'syntax error' +# expect: make: directive-hyphen-include-error.inc:1: Invalid line 'syntax error' _!= echo 'syntax error' > directive-hyphen-include-error.inc .-include "${.CURDIR}/directive-hyphen-include-error.inc" _!= rm directive-hyphen-include-error.inc diff --git a/unit-tests/directive-if-nested.exp b/unit-tests/directive-if-nested.exp index 1a9ae02f07b2..06dc1a0300a5 100644 --- a/unit-tests/directive-if-nested.exp +++ b/unit-tests/directive-if-nested.exp @@ -1,2 +1,2 @@ -make: "directive-if-nested.inc" line 1001: deeply nested .if directives +make: directive-if-nested.inc:1001: deeply nested .if directives exit status 0 diff --git a/unit-tests/directive-if.exp b/unit-tests/directive-if.exp index 56c8dfda5e30..0d4a7ea16d34 100644 --- a/unit-tests/directive-if.exp +++ b/unit-tests/directive-if.exp @@ -1,18 +1,18 @@ -make: "directive-if.mk" line 14: 0 evaluates to false. -make: "directive-if.mk" line 19: 1 evaluates to true. -make: "directive-if.mk" line 43: Unknown directive "ifx" -make: "directive-if.mk" line 45: This is not conditional. -make: "directive-if.mk" line 47: if-less else -make: "directive-if.mk" line 49: This is not conditional. -make: "directive-if.mk" line 51: if-less endif -make: "directive-if.mk" line 55: Malformed conditional '' -make: "directive-if.mk" line 66: Quotes in plain words are probably a mistake. -make: "directive-if.mk" line 76: Don't do this, always put a space after a directive. -make: "directive-if.mk" line 81: Don't do this, always put a space after a directive. -make: "directive-if.mk" line 88: Don't do this, always put a space around comparison operators. -make: "directive-if.mk" line 95: Don't do this, always put a space after a directive. -make: "directive-if.mk" line 100: Don't do this, always put a space after a directive. -make: "directive-if.mk" line 108: Unknown directive "ifn" +make: directive-if.mk:14: 0 evaluates to false. +make: directive-if.mk:19: 1 evaluates to true. +make: directive-if.mk:43: Unknown directive "ifx" +make: directive-if.mk:45: This is not conditional. +make: directive-if.mk:47: if-less else +make: directive-if.mk:49: This is not conditional. +make: directive-if.mk:51: if-less endif +make: directive-if.mk:55: Malformed conditional '' +make: directive-if.mk:66: Quotes in plain words are probably a mistake. +make: directive-if.mk:76: Don't do this, always put a space after a directive. +make: directive-if.mk:81: Don't do this, always put a space after a directive. +make: directive-if.mk:88: Don't do this, always put a space around comparison operators. +make: directive-if.mk:95: Don't do this, always put a space after a directive. +make: directive-if.mk:100: Don't do this, always put a space after a directive. +make: directive-if.mk:108: Unknown directive "ifn" make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 diff --git a/unit-tests/directive-ifmake.exp b/unit-tests/directive-ifmake.exp index 53727e4449e0..09e530d6f13a 100644 --- a/unit-tests/directive-ifmake.exp +++ b/unit-tests/directive-ifmake.exp @@ -1,10 +1,10 @@ -make: "directive-ifmake.mk" line 14: ok: positive condition works -make: "directive-ifmake.mk" line 26: ok: negation works -make: "directive-ifmake.mk" line 36: ok: double negation works -make: "directive-ifmake.mk" line 44: ok: both mentioned -make: "directive-ifmake.mk" line 52: ok: only those mentioned -make: "directive-ifmake.mk" line 63: Targets can even be added at parse time. -make: "directive-ifmake.mk" line 82: ok +make: directive-ifmake.mk:14: ok: positive condition works +make: directive-ifmake.mk:26: ok: negation works +make: directive-ifmake.mk:36: ok: double negation works +make: directive-ifmake.mk:44: ok: both mentioned +make: directive-ifmake.mk:52: ok: only those mentioned +make: directive-ifmake.mk:63: Targets can even be added at parse time. +make: directive-ifmake.mk:82: ok : first : second : late-target diff --git a/unit-tests/directive-ifndef.exp b/unit-tests/directive-ifndef.exp index d018e78616bc..339737268499 100644 --- a/unit-tests/directive-ifndef.exp +++ b/unit-tests/directive-ifndef.exp @@ -1,2 +1,2 @@ -make: "directive-ifndef.mk" line 14: guarded section +make: directive-ifndef.mk:14: guarded section exit status 0 diff --git a/unit-tests/directive-include-fatal.exp b/unit-tests/directive-include-fatal.exp index 35706336c1dd..abe28141ff29 100755 --- a/unit-tests/directive-include-fatal.exp +++ b/unit-tests/directive-include-fatal.exp @@ -1,4 +1,4 @@ -make: "directive-include-fatal.mk" line 14: Variable "UNDEF" is undefined +make: directive-include-fatal.mk:14: Variable "UNDEF" is undefined make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests exit status 1 diff --git a/unit-tests/directive-include-guard.exp b/unit-tests/directive-include-guard.exp index d7d2789681af..264ae11cde8b 100644 --- a/unit-tests/directive-include-guard.exp +++ b/unit-tests/directive-include-guard.exp @@ -1,106 +1,106 @@ -Parse_PushInput: file variable-ifndef.tmp, line 1 +Parse_PushInput: variable-ifndef.tmp:1 Skipping 'variable-ifndef.tmp' because 'VARIABLE_IFNDEF' is defined -Parse_PushInput: file variable-ifndef-reuse.tmp, line 1 +Parse_PushInput: variable-ifndef-reuse.tmp:1 Skipping 'variable-ifndef-reuse.tmp' because 'VARIABLE_IFNDEF' is defined -Parse_PushInput: file variable-ifndef-zero.tmp, line 1 -Parse_PushInput: file variable-ifndef-zero.tmp, line 1 -Parse_PushInput: file variable-ifndef-one.tmp, line 1 -Parse_PushInput: file variable-ifndef-one.tmp, line 1 -Parse_PushInput: file comments.tmp, line 1 +Parse_PushInput: variable-ifndef-zero.tmp:1 +Parse_PushInput: variable-ifndef-zero.tmp:1 +Parse_PushInput: variable-ifndef-one.tmp:1 +Parse_PushInput: variable-ifndef-one.tmp:1 +Parse_PushInput: comments.tmp:1 Skipping 'comments.tmp' because 'COMMENTS' is defined -Parse_PushInput: file variable-if.tmp, line 1 +Parse_PushInput: variable-if.tmp:1 Skipping 'variable-if.tmp' because 'VARIABLE_IF' is defined -Parse_PushInput: file variable-if-reuse.tmp, line 1 +Parse_PushInput: variable-if-reuse.tmp:1 Skipping 'variable-if-reuse.tmp' because 'VARIABLE_IF' is defined -Parse_PushInput: file variable-if-triple-negation.tmp, line 1 -Parse_PushInput: file variable-if-triple-negation.tmp, line 1 -Parse_PushInput: file variable-if-spaced.tmp, line 1 -Parse_PushInput: file variable-if-spaced.tmp, line 1 -Parse_PushInput: file variable-if-parenthesized.tmp, line 1 -Parse_PushInput: file variable-if-parenthesized.tmp, line 1 -Parse_PushInput: file variable-ifdef-negated.tmp, line 1 -Parse_PushInput: file variable-ifdef-negated.tmp, line 1 -Parse_PushInput: file variable-name-mismatch.tmp, line 1 -Parse_PushInput: file variable-name-mismatch.tmp, line 1 -Parse_PushInput: file variable-ifndef-parenthesized.tmp, line 1 -Parse_PushInput: file variable-ifndef-parenthesized.tmp, line 1 -Parse_PushInput: file variable-name-exclamation.tmp, line 1 -Parse_PushInput: file variable-name-exclamation.tmp, line 1 -Parse_PushInput: file variable-name-exclamation-middle.tmp, line 1 -Parse_PushInput: file variable-name-exclamation-middle.tmp, line 1 -Parse_PushInput: file variable-name-parentheses.tmp, line 1 -Parse_PushInput: file variable-name-parentheses.tmp, line 1 -Parse_PushInput: file variable-ifndef-plus.tmp, line 1 -Parse_PushInput: file variable-ifndef-plus.tmp, line 1 -Parse_PushInput: file variable-if-plus.tmp, line 1 -Parse_PushInput: file variable-if-plus.tmp, line 1 -Parse_PushInput: file variable-ifndef-indirect.tmp, line 1 -Parse_PushInput: file variable-ifndef-indirect.tmp, line 1 -Parse_PushInput: file variable-if-indirect.tmp, line 1 -Parse_PushInput: file variable-if-indirect.tmp, line 1 -Parse_PushInput: file variable-assign-indirect.tmp, line 1 +Parse_PushInput: variable-if-triple-negation.tmp:1 +Parse_PushInput: variable-if-triple-negation.tmp:1 +Parse_PushInput: variable-if-spaced.tmp:1 +Parse_PushInput: variable-if-spaced.tmp:1 +Parse_PushInput: variable-if-parenthesized.tmp:1 +Parse_PushInput: variable-if-parenthesized.tmp:1 +Parse_PushInput: variable-ifdef-negated.tmp:1 +Parse_PushInput: variable-ifdef-negated.tmp:1 +Parse_PushInput: variable-name-mismatch.tmp:1 +Parse_PushInput: variable-name-mismatch.tmp:1 +Parse_PushInput: variable-ifndef-parenthesized.tmp:1 +Parse_PushInput: variable-ifndef-parenthesized.tmp:1 +Parse_PushInput: variable-name-exclamation.tmp:1 +Parse_PushInput: variable-name-exclamation.tmp:1 +Parse_PushInput: variable-name-exclamation-middle.tmp:1 +Parse_PushInput: variable-name-exclamation-middle.tmp:1 +Parse_PushInput: variable-name-parentheses.tmp:1 +Parse_PushInput: variable-name-parentheses.tmp:1 +Parse_PushInput: variable-ifndef-plus.tmp:1 +Parse_PushInput: variable-ifndef-plus.tmp:1 +Parse_PushInput: variable-if-plus.tmp:1 +Parse_PushInput: variable-if-plus.tmp:1 +Parse_PushInput: variable-ifndef-indirect.tmp:1 +Parse_PushInput: variable-ifndef-indirect.tmp:1 +Parse_PushInput: variable-if-indirect.tmp:1 +Parse_PushInput: variable-if-indirect.tmp:1 +Parse_PushInput: variable-assign-indirect.tmp:1 Skipping 'variable-assign-indirect.tmp' because 'VARIABLE_ASSIGN_INDIRECT' is defined -Parse_PushInput: file variable-assign-late.tmp, line 1 +Parse_PushInput: variable-assign-late.tmp:1 Skipping 'variable-assign-late.tmp' because 'VARIABLE_ASSIGN_LATE' is defined -Parse_PushInput: file variable-assign-nested.tmp, line 1 -Parse_PushInput: .for loop in variable-assign-nested.tmp, line 3 +Parse_PushInput: variable-assign-nested.tmp:1 +Parse_PushInput: .for loop in variable-assign-nested.tmp:3 Skipping 'variable-assign-nested.tmp' because 'VARIABLE_ASSIGN_NESTED' is defined -Parse_PushInput: file variable-already-defined.tmp, line 1 +Parse_PushInput: variable-already-defined.tmp:1 Skipping 'variable-already-defined.tmp' because 'VARIABLE_ALREADY_DEFINED' is defined -Parse_PushInput: file variable-defined-then-undefined.tmp, line 1 -Parse_PushInput: file variable-defined-then-undefined.tmp, line 1 -Parse_PushInput: file variable-two-times.tmp, line 1 -Parse_PushInput: file variable-two-times.tmp, line 1 -Parse_PushInput: file variable-clash.tmp, line 1 +Parse_PushInput: variable-defined-then-undefined.tmp:1 +Parse_PushInput: variable-defined-then-undefined.tmp:1 +Parse_PushInput: variable-two-times.tmp:1 +Parse_PushInput: variable-two-times.tmp:1 +Parse_PushInput: variable-clash.tmp:1 Skipping 'variable-clash.tmp' because 'VARIABLE_IF' is defined -Parse_PushInput: file variable-swapped.tmp, line 1 -Parse_PushInput: file variable-swapped.tmp, line 1 -Parse_PushInput: file variable-undef-between.tmp, line 1 -Parse_PushInput: file variable-undef-between.tmp, line 1 -Parse_PushInput: file variable-undef-inside.tmp, line 1 -Parse_PushInput: file variable-undef-inside.tmp, line 1 -Parse_PushInput: file variable-not-defined.tmp, line 1 -Parse_PushInput: file variable-not-defined.tmp, line 1 -Parse_PushInput: file elif.tmp, line 1 -Parse_PushInput: file elif.tmp, line 1 -Parse_PushInput: file elif-reuse.tmp, line 1 -Parse_PushInput: file elif-reuse.tmp, line 1 -Parse_PushInput: file else.tmp, line 1 -Parse_PushInput: file else.tmp, line 1 -Parse_PushInput: file else-reuse.tmp, line 1 -Parse_PushInput: file else-reuse.tmp, line 1 -Parse_PushInput: file inner-if-elif-else.tmp, line 1 +Parse_PushInput: variable-swapped.tmp:1 +Parse_PushInput: variable-swapped.tmp:1 +Parse_PushInput: variable-undef-between.tmp:1 +Parse_PushInput: variable-undef-between.tmp:1 +Parse_PushInput: variable-undef-inside.tmp:1 +Parse_PushInput: variable-undef-inside.tmp:1 +Parse_PushInput: variable-not-defined.tmp:1 +Parse_PushInput: variable-not-defined.tmp:1 +Parse_PushInput: elif.tmp:1 +Parse_PushInput: elif.tmp:1 +Parse_PushInput: elif-reuse.tmp:1 +Parse_PushInput: elif-reuse.tmp:1 +Parse_PushInput: else.tmp:1 +Parse_PushInput: else.tmp:1 +Parse_PushInput: else-reuse.tmp:1 +Parse_PushInput: else-reuse.tmp:1 +Parse_PushInput: inner-if-elif-else.tmp:1 Skipping 'inner-if-elif-else.tmp' because 'INNER_IF_ELIF_ELSE' is defined -Parse_PushInput: file target.tmp, line 1 +Parse_PushInput: target.tmp:1 Skipping 'target.tmp' because '__target.tmp__' is defined -Parse_PushInput: file target-sys.tmp, line 1 +Parse_PushInput: target-sys.tmp:1 Skipping 'target-sys.tmp' because '__<target-sys.tmp>__' is defined -Parse_PushInput: file target-indirect.tmp, line 1 +Parse_PushInput: target-indirect.tmp:1 Skipping 'target-indirect.tmp' because 'target-indirect.tmp' is defined -Parse_PushInput: file target-indirect-PARSEFILE.tmp, line 1 +Parse_PushInput: target-indirect-PARSEFILE.tmp:1 Skipping 'target-indirect-PARSEFILE.tmp' because '__target-indirect-PARSEFILE.tmp__' is defined -Parse_PushInput: file target-indirect-PARSEFILE2.tmp, line 1 +Parse_PushInput: target-indirect-PARSEFILE2.tmp:1 Skipping 'target-indirect-PARSEFILE2.tmp' because '__target-indirect-PARSEFILE2.tmp__' is defined -Parse_PushInput: file subdir/target-indirect-PARSEFILE.tmp, line 1 +Parse_PushInput: subdir/target-indirect-PARSEFILE.tmp:1 Skipping 'subdir/target-indirect-PARSEFILE.tmp' because '__target-indirect-PARSEFILE.tmp__' is defined -Parse_PushInput: file target-indirect-PARSEDIR-PARSEFILE.tmp, line 1 +Parse_PushInput: target-indirect-PARSEDIR-PARSEFILE.tmp:1 Skipping 'target-indirect-PARSEDIR-PARSEFILE.tmp' because '__target-indirect-PARSEDIR-PARSEFILE.tmp__' is defined -Parse_PushInput: file subdir/target-indirect-PARSEDIR-PARSEFILE.tmp, line 1 +Parse_PushInput: subdir/target-indirect-PARSEDIR-PARSEFILE.tmp:1 Skipping 'subdir/target-indirect-PARSEDIR-PARSEFILE.tmp' because '__subdir/target-indirect-PARSEDIR-PARSEFILE.tmp__' is defined -Parse_PushInput: file target-unguarded.tmp, line 1 -Parse_PushInput: file target-unguarded.tmp, line 1 -Parse_PushInput: file target-plus.tmp, line 1 -Parse_PushInput: file target-plus.tmp, line 1 -Parse_PushInput: file target-already-defined.tmp, line 1 +Parse_PushInput: target-unguarded.tmp:1 +Parse_PushInput: target-unguarded.tmp:1 +Parse_PushInput: target-plus.tmp:1 +Parse_PushInput: target-plus.tmp:1 +Parse_PushInput: target-already-defined.tmp:1 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-leading-space.tmp, line 1 -Parse_PushInput: file target-name-leading-space.tmp, line 1 -Parse_PushInput: file target-name-trailing-space.tmp, line 1 -Parse_PushInput: file target-name-trailing-space.tmp, line 1 -Parse_PushInput: file target-call-parenthesized.tmp, line 1 -Parse_PushInput: file target-call-parenthesized.tmp, line 1 -Parse_PushInput: file multiline.tmp, line 1 +Parse_PushInput: target-name-exclamation.tmp:1 +Parse_PushInput: target-name-exclamation.tmp:1 +Parse_PushInput: target-name-leading-space.tmp:1 +Parse_PushInput: target-name-leading-space.tmp:1 +Parse_PushInput: target-name-trailing-space.tmp:1 +Parse_PushInput: target-name-trailing-space.tmp:1 +Parse_PushInput: target-call-parenthesized.tmp:1 +Parse_PushInput: target-call-parenthesized.tmp:1 +Parse_PushInput: multiline.tmp:1 Skipping 'multiline.tmp' because 'MULTILINE' is defined exit status 0 diff --git a/unit-tests/directive-include-guard.mk b/unit-tests/directive-include-guard.mk index 4c4194be4c36..702d0f4ab9dc 100644 --- a/unit-tests/directive-include-guard.mk +++ b/unit-tests/directive-include-guard.mk @@ -1,4 +1,4 @@ -# $NetBSD: directive-include-guard.mk,v 1.18 2024/08/07 05:48:45 rillig Exp $ +# $NetBSD: directive-include-guard.mk,v 1.19 2025/04/11 17:21:31 rillig Exp $ # # Tests for multiple-inclusion guards in makefiles. # @@ -33,7 +33,7 @@ LINES.variable-ifndef= \ '.ifndef VARIABLE_IFNDEF' \ 'VARIABLE_IFNDEF=' \ '.endif' -# expect: Parse_PushInput: file variable-ifndef.tmp, line 1 +# expect: Parse_PushInput: variable-ifndef.tmp:1 # expect: Skipping 'variable-ifndef.tmp' because 'VARIABLE_IFNDEF' is defined # A file that reuses a guard from a previous file (or whose guard is defined @@ -44,7 +44,7 @@ LINES.variable-ifndef-reuse= \ '.ifndef VARIABLE_IFNDEF' \ 'syntax error' \ '.endif' -# expect: Parse_PushInput: file variable-ifndef-reuse.tmp, line 1 +# expect: Parse_PushInput: variable-ifndef-reuse.tmp:1 # expect: Skipping 'variable-ifndef-reuse.tmp' because 'VARIABLE_IFNDEF' is defined # The guard variable cannot be a number, as numbers are interpreted @@ -54,8 +54,8 @@ LINES.variable-ifndef-zero= \ '.ifndef 0e0' \ 'syntax error' \ '.endif' -# expect: Parse_PushInput: file variable-ifndef-zero.tmp, line 1 -# expect: Parse_PushInput: file variable-ifndef-zero.tmp, line 1 +# expect: Parse_PushInput: variable-ifndef-zero.tmp:1 +# expect: Parse_PushInput: variable-ifndef-zero.tmp:1 # The guard variable cannot be a number, as numbers are interpreted # differently from bare words. @@ -63,8 +63,8 @@ CASES+= variable-ifndef-one LINES.variable-ifndef-one= \ '.ifndef 1' \ '.endif' -# expect: Parse_PushInput: file variable-ifndef-one.tmp, line 1 -# expect: Parse_PushInput: file variable-ifndef-one.tmp, line 1 +# expect: Parse_PushInput: variable-ifndef-one.tmp:1 +# expect: Parse_PushInput: variable-ifndef-one.tmp:1 # Comments and empty lines do not affect the multiple-inclusion guard. CASES+= comments @@ -76,7 +76,7 @@ LINES.comments= \ 'COMMENTS=\#comment' \ '.endif' \ '\# comment' -# expect: Parse_PushInput: file comments.tmp, line 1 +# expect: Parse_PushInput: comments.tmp:1 # expect: Skipping 'comments.tmp' because 'COMMENTS' is defined # An alternative form uses the 'defined' function. It is more verbose than @@ -87,7 +87,7 @@ LINES.variable-if= \ '.if !defined(VARIABLE_IF)' \ 'VARIABLE_IF=' \ '.endif' -# expect: Parse_PushInput: file variable-if.tmp, line 1 +# expect: Parse_PushInput: variable-if.tmp:1 # expect: Skipping 'variable-if.tmp' because 'VARIABLE_IF' is defined # A file that reuses a guard from a previous file (or whose guard is defined @@ -98,7 +98,7 @@ LINES.variable-if-reuse= \ '.if !defined(VARIABLE_IF)' \ 'syntax error' \ '.endif' -# expect: Parse_PushInput: file variable-if-reuse.tmp, line 1 +# expect: Parse_PushInput: variable-if-reuse.tmp:1 # expect: Skipping 'variable-if-reuse.tmp' because 'VARIABLE_IF' is defined # Triple negation is so uncommon that it's not recognized, even though it has @@ -108,8 +108,8 @@ LINES.variable-if-triple-negation= \ '.if !!!defined(VARIABLE_IF_TRIPLE_NEGATION)' \ 'VARIABLE_IF_TRIPLE_NEGATION=' \ '.endif' -# expect: Parse_PushInput: file variable-if-triple-negation.tmp, line 1 -# expect: Parse_PushInput: file variable-if-triple-negation.tmp, line 1 +# expect: Parse_PushInput: variable-if-triple-negation.tmp:1 +# expect: Parse_PushInput: variable-if-triple-negation.tmp:1 # If the guard variable is enclosed in spaces, it does not have an effect, as # that form is not common in practice. @@ -118,8 +118,8 @@ LINES.variable-if-spaced= \ '.if !defined( VARIABLE_IF_SPACED )' \ 'VARIABLE_IF_SPACED=' \ '.endif' -# expect: Parse_PushInput: file variable-if-spaced.tmp, line 1 -# expect: Parse_PushInput: file variable-if-spaced.tmp, line 1 +# expect: Parse_PushInput: variable-if-spaced.tmp:1 +# expect: Parse_PushInput: variable-if-spaced.tmp:1 # If the guard variable condition is enclosed in parentheses, it does not have # an effect, as that form is not common in practice. @@ -128,8 +128,8 @@ LINES.variable-if-parenthesized= \ '.if (!defined(VARIABLE_IF_PARENTHESIZED))' \ 'VARIABLE_IF_PARENTHESIZED=' \ '.endif' -# expect: Parse_PushInput: file variable-if-parenthesized.tmp, line 1 -# expect: Parse_PushInput: file variable-if-parenthesized.tmp, line 1 +# expect: Parse_PushInput: variable-if-parenthesized.tmp:1 +# expect: Parse_PushInput: variable-if-parenthesized.tmp:1 # A conditional other than '.if' or '.ifndef' does not guard the file, even if # it is otherwise equivalent to the above accepted forms. @@ -138,8 +138,8 @@ LINES.variable-ifdef-negated= \ '.ifdef !VARIABLE_IFDEF_NEGATED' \ 'VARIABLE_IFDEF_NEGATED=' \ '.endif' -# expect: Parse_PushInput: file variable-ifdef-negated.tmp, line 1 -# expect: Parse_PushInput: file variable-ifdef-negated.tmp, line 1 +# expect: Parse_PushInput: variable-ifdef-negated.tmp:1 +# expect: Parse_PushInput: variable-ifdef-negated.tmp:1 # The variable names in the '.if' and the assignment must be the same. CASES+= variable-name-mismatch @@ -147,8 +147,8 @@ LINES.variable-name-mismatch= \ '.ifndef VARIABLE_NAME_MISMATCH' \ 'VARIABLE_NAME_DIFFERENT=' \ '.endif' -# expect: Parse_PushInput: file variable-name-mismatch.tmp, line 1 -# expect: Parse_PushInput: file variable-name-mismatch.tmp, line 1 +# expect: Parse_PushInput: variable-name-mismatch.tmp:1 +# expect: Parse_PushInput: variable-name-mismatch.tmp:1 # If the guard variable condition is enclosed in parentheses, it does not have # an effect, as that form is not common in practice. @@ -157,8 +157,8 @@ LINES.variable-ifndef-parenthesized= \ '.ifndef (VARIABLE_IFNDEF_PARENTHESIZED)' \ 'VARIABLE_IFNDEF_PARENTHESIZED=' \ '.endif' -# expect: Parse_PushInput: file variable-ifndef-parenthesized.tmp, line 1 -# expect: Parse_PushInput: file variable-ifndef-parenthesized.tmp, line 1 +# expect: Parse_PushInput: variable-ifndef-parenthesized.tmp:1 +# expect: Parse_PushInput: variable-ifndef-parenthesized.tmp:1 # The variable name '!VARNAME' cannot be used in an '.ifndef' directive, as # the '!' would be a negation. It is syntactically valid in a '.if !defined' @@ -171,8 +171,8 @@ LINES.variable-name-exclamation= \ '.if !defined(!VARIABLE_NAME_EXCLAMATION)' \ '${:U!}VARIABLE_NAME_EXCLAMATION=' \ '.endif' -# expect: Parse_PushInput: file variable-name-exclamation.tmp, line 1 -# expect: Parse_PushInput: file variable-name-exclamation.tmp, line 1 +# expect: Parse_PushInput: variable-name-exclamation.tmp:1 +# expect: Parse_PushInput: variable-name-exclamation.tmp:1 # In general, a variable name can contain a '!' in the middle, as that # character is interpreted as an ordinary character in conditions as well as @@ -183,8 +183,8 @@ LINES.variable-name-exclamation-middle= \ '.ifndef VARIABLE_NAME!MIDDLE' \ 'VARIABLE_NAME!MIDDLE=' \ '.endif' -# expect: Parse_PushInput: file variable-name-exclamation-middle.tmp, line 1 -# expect: Parse_PushInput: file variable-name-exclamation-middle.tmp, line 1 +# expect: Parse_PushInput: variable-name-exclamation-middle.tmp:1 +# expect: Parse_PushInput: variable-name-exclamation-middle.tmp:1 # A variable name can contain balanced parentheses, at least in conditions and # on the left side of a variable assignment. There are enough places in make @@ -196,8 +196,8 @@ LINES.variable-name-parentheses= \ '.ifndef VARIABLE_NAME(&)PARENTHESES' \ 'VARIABLE_NAME(&)PARENTHESES=' \ '.endif' -# expect: Parse_PushInput: file variable-name-parentheses.tmp, line 1 -# expect: Parse_PushInput: file variable-name-parentheses.tmp, line 1 +# expect: Parse_PushInput: variable-name-parentheses.tmp:1 +# expect: Parse_PushInput: variable-name-parentheses.tmp:1 # The guard condition must consist of only the guard variable, nothing else. CASES+= variable-ifndef-plus @@ -206,8 +206,8 @@ LINES.variable-ifndef-plus= \ 'VARIABLE_IFNDEF_PLUS=' \ 'VARIABLE_IFNDEF_SECOND=' \ '.endif' -# expect: Parse_PushInput: file variable-ifndef-plus.tmp, line 1 -# expect: Parse_PushInput: file variable-ifndef-plus.tmp, line 1 +# expect: Parse_PushInput: variable-ifndef-plus.tmp:1 +# expect: Parse_PushInput: variable-ifndef-plus.tmp:1 # The guard condition must consist of only the guard variable, nothing else. CASES+= variable-if-plus @@ -216,8 +216,8 @@ LINES.variable-if-plus= \ 'VARIABLE_IF_PLUS=' \ 'VARIABLE_IF_SECOND=' \ '.endif' -# expect: Parse_PushInput: file variable-if-plus.tmp, line 1 -# expect: Parse_PushInput: file variable-if-plus.tmp, line 1 +# expect: Parse_PushInput: variable-if-plus.tmp:1 +# expect: Parse_PushInput: variable-if-plus.tmp:1 # The variable name in an '.ifndef' guard must be given directly, it must not # contain any '$' expression. @@ -226,8 +226,8 @@ LINES.variable-ifndef-indirect= \ '.ifndef $${VARIABLE_IFNDEF_INDIRECT:L}' \ 'VARIABLE_IFNDEF_INDIRECT=' \ '.endif' -# expect: Parse_PushInput: file variable-ifndef-indirect.tmp, line 1 -# expect: Parse_PushInput: file variable-ifndef-indirect.tmp, line 1 +# expect: Parse_PushInput: variable-ifndef-indirect.tmp:1 +# expect: Parse_PushInput: variable-ifndef-indirect.tmp:1 # The variable name in an '.if' guard must be given directly, it must not # contain any '$' expression. @@ -236,8 +236,8 @@ LINES.variable-if-indirect= \ '.if !defined($${VARIABLE_IF_INDIRECT:L})' \ 'VARIABLE_IF_INDIRECT=' \ '.endif' -# expect: Parse_PushInput: file variable-if-indirect.tmp, line 1 -# expect: Parse_PushInput: file variable-if-indirect.tmp, line 1 +# expect: Parse_PushInput: variable-if-indirect.tmp:1 +# expect: Parse_PushInput: variable-if-indirect.tmp:1 # The variable name in the guard condition must only contain alphanumeric # characters and underscores. The place where the guard variable is defined @@ -248,7 +248,7 @@ LINES.variable-assign-indirect= \ '.ifndef VARIABLE_ASSIGN_INDIRECT' \ '$${VARIABLE_ASSIGN_INDIRECT:L}=' \ '.endif' -# expect: Parse_PushInput: file variable-assign-indirect.tmp, line 1 +# expect: Parse_PushInput: variable-assign-indirect.tmp:1 # expect: Skipping 'variable-assign-indirect.tmp' because 'VARIABLE_ASSIGN_INDIRECT' is defined # The time at which the guard variable is defined doesn't matter, as long as @@ -259,7 +259,7 @@ LINES.variable-assign-late= \ 'VARIABLE_ASSIGN_LATE_OTHER=' \ 'VARIABLE_ASSIGN_LATE=' \ '.endif' -# expect: Parse_PushInput: file variable-assign-late.tmp, line 1 +# expect: Parse_PushInput: variable-assign-late.tmp:1 # expect: Skipping 'variable-assign-late.tmp' because 'VARIABLE_ASSIGN_LATE' is defined # The time at which the guard variable is defined doesn't matter, as long as @@ -273,7 +273,7 @@ LINES.variable-assign-nested= \ '. endfor' \ '. endif' \ '.endif' -# expect: Parse_PushInput: file variable-assign-nested.tmp, line 1 +# expect: Parse_PushInput: variable-assign-nested.tmp:1 # expect: Skipping 'variable-assign-nested.tmp' because 'VARIABLE_ASSIGN_NESTED' is defined # If the guard variable is defined before the file is included for the first @@ -287,7 +287,7 @@ LINES.variable-already-defined= \ 'VARIABLE_ALREADY_DEFINED=' \ '.endif' VARIABLE_ALREADY_DEFINED= -# expect: Parse_PushInput: file variable-already-defined.tmp, line 1 +# expect: Parse_PushInput: variable-already-defined.tmp:1 # expect: Skipping 'variable-already-defined.tmp' because 'VARIABLE_ALREADY_DEFINED' is defined # If the guard variable is defined before the file is included the first time, @@ -301,8 +301,8 @@ LINES.variable-defined-then-undefined= \ VARIABLE_DEFINED_THEN_UNDEFINED= UNDEF_BETWEEN.variable-defined-then-undefined= \ VARIABLE_DEFINED_THEN_UNDEFINED -# expect: Parse_PushInput: file variable-defined-then-undefined.tmp, line 1 -# expect: Parse_PushInput: file variable-defined-then-undefined.tmp, line 1 +# expect: Parse_PushInput: variable-defined-then-undefined.tmp:1 +# expect: Parse_PushInput: variable-defined-then-undefined.tmp:1 # The whole file content must be guarded by a single '.if' conditional, not by # several, as each of these conditionals would require its separate guard. @@ -316,8 +316,8 @@ LINES.variable-two-times= \ '.ifndef VARIABLE_TWO_TIMES_2' \ 'VARIABLE_TWO_TIMES_2=' \ '.endif' -# expect: Parse_PushInput: file variable-two-times.tmp, line 1 -# expect: Parse_PushInput: file variable-two-times.tmp, line 1 +# expect: Parse_PushInput: variable-two-times.tmp:1 +# expect: Parse_PushInput: variable-two-times.tmp:1 # When multiple files use the same guard variable name, the optimization of # skipping the file affects each of these files. @@ -328,7 +328,7 @@ LINES.variable-two-times= \ CASES+= variable-clash LINES.variable-clash= \ ${LINES.variable-if} -# expect: Parse_PushInput: file variable-clash.tmp, line 1 +# expect: Parse_PushInput: variable-clash.tmp:1 # expect: Skipping 'variable-clash.tmp' because 'VARIABLE_IF' is defined # The conditional must come before the assignment, otherwise the conditional @@ -339,8 +339,8 @@ LINES.variable-swapped= \ '.ifndef SWAPPED' \ '. error' \ '.endif' -# expect: Parse_PushInput: file variable-swapped.tmp, line 1 -# expect: Parse_PushInput: file variable-swapped.tmp, line 1 +# expect: Parse_PushInput: variable-swapped.tmp:1 +# expect: Parse_PushInput: variable-swapped.tmp:1 # If the guard variable is undefined between the first and the second time the # file is included, the guarded file is included again. @@ -351,8 +351,8 @@ LINES.variable-undef-between= \ '.endif' UNDEF_BETWEEN.variable-undef-between= \ VARIABLE_UNDEF_BETWEEN -# expect: Parse_PushInput: file variable-undef-between.tmp, line 1 -# expect: Parse_PushInput: file variable-undef-between.tmp, line 1 +# expect: Parse_PushInput: variable-undef-between.tmp:1 +# expect: Parse_PushInput: variable-undef-between.tmp:1 # If the guard variable is undefined while the file is included the first # time, the guard does not have an effect, and the file is included again. @@ -362,8 +362,8 @@ LINES.variable-undef-inside= \ 'VARIABLE_UNDEF_INSIDE=' \ '.undef VARIABLE_UNDEF_INSIDE' \ '.endif' -# expect: Parse_PushInput: file variable-undef-inside.tmp, line 1 -# expect: Parse_PushInput: file variable-undef-inside.tmp, line 1 +# expect: Parse_PushInput: variable-undef-inside.tmp:1 +# expect: Parse_PushInput: variable-undef-inside.tmp:1 # If the file does not define the guard variable, the guard does not have an # effect, and the file is included again. @@ -371,8 +371,8 @@ CASES+= variable-not-defined LINES.variable-not-defined= \ '.ifndef VARIABLE_NOT_DEFINED' \ '.endif' -# expect: Parse_PushInput: file variable-not-defined.tmp, line 1 -# expect: Parse_PushInput: file variable-not-defined.tmp, line 1 +# expect: Parse_PushInput: variable-not-defined.tmp:1 +# expect: Parse_PushInput: variable-not-defined.tmp:1 # The outermost '.if' must not have an '.elif' branch. CASES+= elif @@ -381,8 +381,8 @@ LINES.elif= \ 'ELIF=' \ '.elif 1' \ '.endif' -# expect: Parse_PushInput: file elif.tmp, line 1 -# expect: Parse_PushInput: file elif.tmp, line 1 +# expect: Parse_PushInput: elif.tmp:1 +# expect: Parse_PushInput: elif.tmp:1 # When a file with an '.if/.elif/.endif' conditional at the top level is # included, it is never optimized, as one of its branches is taken. @@ -392,8 +392,8 @@ LINES.elif-reuse= \ 'syntax error' \ '.elif 1' \ '.endif' -# expect: Parse_PushInput: file elif-reuse.tmp, line 1 -# expect: Parse_PushInput: file elif-reuse.tmp, line 1 +# expect: Parse_PushInput: elif-reuse.tmp:1 +# expect: Parse_PushInput: elif-reuse.tmp:1 # The outermost '.if' must not have an '.else' branch. CASES+= else @@ -402,8 +402,8 @@ LINES.else= \ 'ELSE=' \ '.else' \ '.endif' -# expect: Parse_PushInput: file else.tmp, line 1 -# expect: Parse_PushInput: file else.tmp, line 1 +# expect: Parse_PushInput: else.tmp:1 +# expect: Parse_PushInput: else.tmp:1 # When a file with an '.if/.else/.endif' conditional at the top level is # included, it is never optimized, as one of its branches is taken. @@ -413,8 +413,8 @@ LINES.else-reuse= \ 'syntax error' \ '.else' \ '.endif' -# expect: Parse_PushInput: file else-reuse.tmp, line 1 -# expect: Parse_PushInput: file else-reuse.tmp, line 1 +# expect: Parse_PushInput: else-reuse.tmp:1 +# expect: Parse_PushInput: else-reuse.tmp:1 # The inner '.if' directives may have an '.elif' or '.else', and it doesn't # matter which of their branches are taken. @@ -435,7 +435,7 @@ LINES.inner-if-elif-else= \ '. else' \ '. endif' \ '.endif' -# expect: Parse_PushInput: file inner-if-elif-else.tmp, line 1 +# expect: Parse_PushInput: inner-if-elif-else.tmp:1 # expect: Skipping 'inner-if-elif-else.tmp' because 'INNER_IF_ELIF_ELSE' is defined # The guard can also be a target instead of a variable. Using a target as a @@ -449,7 +449,7 @@ LINES.target= \ '.if !target(__target.tmp__)' \ '__target.tmp__: .NOTMAIN' \ '.endif' -# expect: Parse_PushInput: file target.tmp, line 1 +# expect: Parse_PushInput: target.tmp:1 # expect: Skipping 'target.tmp' because '__target.tmp__' is defined # When used for system files, the target name may include '<' and '>', for @@ -460,7 +460,7 @@ LINES.target-sys= \ '.if !target(__<target-sys.tmp>__)' \ '__<target-sys.tmp>__: .NOTMAIN' \ '.endif' -# expect: Parse_PushInput: file target-sys.tmp, line 1 +# expect: Parse_PushInput: target-sys.tmp:1 # expect: Skipping 'target-sys.tmp' because '__<target-sys.tmp>__' is defined # The target name may include variable references. These references are @@ -474,7 +474,7 @@ LINES.target-indirect= \ '.if !target($${target-indirect.tmp:L})' \ 'target-indirect.tmp: .NOTMAIN' \ '.endif' -# expect: Parse_PushInput: file target-indirect.tmp, line 1 +# expect: Parse_PushInput: target-indirect.tmp:1 # expect: Skipping 'target-indirect.tmp' because 'target-indirect.tmp' is defined # A common form of guard target is __${.PARSEFILE}__. This form can only be @@ -487,7 +487,7 @@ LINES.target-indirect-PARSEFILE= \ '.if !target(__$${.PARSEFILE}__)' \ '__$${.PARSEFILE}__: .NOTMAIN' \ '.endif' -# expect: Parse_PushInput: file target-indirect-PARSEFILE.tmp, line 1 +# expect: Parse_PushInput: target-indirect-PARSEFILE.tmp:1 # expect: Skipping 'target-indirect-PARSEFILE.tmp' because '__target-indirect-PARSEFILE.tmp__' is defined # Two files with different basenames can both use the same syntactic pattern @@ -497,7 +497,7 @@ LINES.target-indirect-PARSEFILE2= \ '.if !target(__$${.PARSEFILE}__)' \ '__$${.PARSEFILE}__: .NOTMAIN' \ '.endif' -# expect: Parse_PushInput: file target-indirect-PARSEFILE2.tmp, line 1 +# expect: Parse_PushInput: target-indirect-PARSEFILE2.tmp:1 # expect: Skipping 'target-indirect-PARSEFILE2.tmp' because '__target-indirect-PARSEFILE2.tmp__' is defined # Using plain .PARSEFILE without .PARSEDIR leads to name clashes. The include @@ -508,7 +508,7 @@ CASES+= subdir/target-indirect-PARSEFILE LINES.subdir/target-indirect-PARSEFILE= \ '.if !target(__$${.PARSEFILE}__)' \ '.endif' -# expect: Parse_PushInput: file subdir/target-indirect-PARSEFILE.tmp, line 1 +# expect: Parse_PushInput: subdir/target-indirect-PARSEFILE.tmp:1 # expect: Skipping 'subdir/target-indirect-PARSEFILE.tmp' because '__target-indirect-PARSEFILE.tmp__' is defined # Another common form of guard target is __${.PARSEDIR}/${.PARSEFILE}__ @@ -518,7 +518,7 @@ LINES.target-indirect-PARSEDIR-PARSEFILE= \ '.if !target(__$${.PARSEDIR}/$${.PARSEFILE}__)' \ '__$${.PARSEDIR}/$${.PARSEFILE}__: .NOTMAIN' \ '.endif' -# expect: Parse_PushInput: file target-indirect-PARSEDIR-PARSEFILE.tmp, line 1 +# expect: Parse_PushInput: target-indirect-PARSEDIR-PARSEFILE.tmp:1 # expect: Skipping 'target-indirect-PARSEDIR-PARSEFILE.tmp' because '__target-indirect-PARSEDIR-PARSEFILE.tmp__' is defined # The actual target starts with '__${.OBJDIR}/', see the .rawout file, but the # string '${.OBJDIR}/' gets stripped in post processing. @@ -530,7 +530,7 @@ LINES.subdir/target-indirect-PARSEDIR-PARSEFILE= \ '.if !target(__$${.PARSEDIR}/$${.PARSEFILE}__)' \ '__$${.PARSEDIR}/$${.PARSEFILE}__: .NOTMAIN' \ '.endif' -# expect: Parse_PushInput: file subdir/target-indirect-PARSEDIR-PARSEFILE.tmp, line 1 +# expect: Parse_PushInput: subdir/target-indirect-PARSEDIR-PARSEFILE.tmp:1 # expect: Skipping 'subdir/target-indirect-PARSEDIR-PARSEFILE.tmp' because '__subdir/target-indirect-PARSEDIR-PARSEFILE.tmp__' is defined # The actual target starts with '__${.OBJDIR}/', see the .rawout file, but the # string '${.OBJDIR}/' gets stripped in post processing. @@ -541,8 +541,8 @@ CASES+= target-unguarded LINES.target-unguarded= \ '.if !target(target-unguarded)' \ '.endif' -# expect: Parse_PushInput: file target-unguarded.tmp, line 1 -# expect: Parse_PushInput: file target-unguarded.tmp, line 1 +# expect: Parse_PushInput: target-unguarded.tmp:1 +# expect: Parse_PushInput: target-unguarded.tmp:1 # The guard condition must consist of only the guard target, nothing else. CASES+= target-plus @@ -550,8 +550,8 @@ LINES.target-plus= \ '.if !target(target-plus) && 1' \ 'target-plus: .NOTMAIN' \ '.endif' -# expect: Parse_PushInput: file target-plus.tmp, line 1 -# expect: Parse_PushInput: file target-plus.tmp, line 1 +# expect: Parse_PushInput: target-plus.tmp:1 +# expect: Parse_PushInput: target-plus.tmp:1 # If the guard target is defined before the file is included the first time, # the file is read once and then considered guarded. @@ -561,7 +561,7 @@ LINES.target-already-defined= \ 'target-already-defined: .NOTMAIN' \ '.endif' target-already-defined: .NOTMAIN -# expect: Parse_PushInput: file target-already-defined.tmp, line 1 +# expect: Parse_PushInput: target-already-defined.tmp:1 # expect: Skipping 'target-already-defined.tmp' because 'target-already-defined' is defined # A target name cannot contain the character '!'. In the condition, the '!' @@ -578,8 +578,8 @@ LINES.target-name-exclamation= \ '.if !target(!target-name-exclamation)' \ '\!target-name-exclamation: .NOTMAIN' \ '.endif' -# expect: Parse_PushInput: file target-name-exclamation.tmp, line 1 -# expect: Parse_PushInput: file target-name-exclamation.tmp, line 1 +# expect: Parse_PushInput: target-name-exclamation.tmp:1 +# expect: Parse_PushInput: target-name-exclamation.tmp:1 # If the guard target name has leading spaces, it does not have an effect, # as that form is not common in practice. @@ -588,8 +588,8 @@ 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 +# expect: Parse_PushInput: target-name-leading-space.tmp:1 +# expect: Parse_PushInput: target-name-leading-space.tmp:1 # If the guard target name has trailing spaces, it does not have an effect, # as that form is not common in practice. @@ -598,8 +598,8 @@ LINES.target-name-trailing-space= \ '.if !target(target-name-trailing-space )' \ 'target-name-trailing-space: .NOTMAIN' \ '.endif' -# expect: Parse_PushInput: file target-name-trailing-space.tmp, line 1 -# expect: Parse_PushInput: file target-name-trailing-space.tmp, line 1 +# expect: Parse_PushInput: target-name-trailing-space.tmp:1 +# expect: Parse_PushInput: target-name-trailing-space.tmp:1 # If the guard target condition is enclosed in parentheses, it does not have # an effect, as that form is not common in practice. @@ -608,8 +608,8 @@ LINES.target-call-parenthesized= \ '.if (!target(target-call-parenthesized))' \ 'target-call-parenthesized: .NOTMAIN' \ '.endif' -# expect: Parse_PushInput: file target-call-parenthesized.tmp, line 1 -# expect: Parse_PushInput: file target-call-parenthesized.tmp, line 1 +# expect: Parse_PushInput: target-call-parenthesized.tmp:1 +# expect: Parse_PushInput: target-call-parenthesized.tmp:1 # If the '.if' or '.ifndef' directive spans more than a single line, it is # still recognized as a guard condition. This case is entirely uncommon, but @@ -622,7 +622,7 @@ LINES.multiline= \ ' MULTILINE' \ 'MULTILINE=' \ '.endif' -# expect: Parse_PushInput: file multiline.tmp, line 1 +# expect: Parse_PushInput: multiline.tmp:1 # expect: Skipping 'multiline.tmp' because 'MULTILINE' is defined diff --git a/unit-tests/directive-include.exp b/unit-tests/directive-include.exp index 11a6ab8bc88a..71f39c57e807 100755 --- a/unit-tests/directive-include.exp +++ b/unit-tests/directive-include.exp @@ -2,13 +2,13 @@ CondParser_Eval: ${.MAKE.MAKEFILES:T} != "${.PARSEFILE} null" Comparing "directive-include.mk null" != "directive-include.mk null" CondParser_Eval: ${.MAKE.MAKEFILES:T} != "${.PARSEFILE} null" Comparing "directive-include.mk null" != "directive-include.mk null" -make: "directive-include.mk" line 26: Could not find nonexistent.mk -make: "directive-include.mk" line 49: Could not find " -make: "directive-include.mk" line 56: Unknown modifier "Z" +make: directive-include.mk:26: Could not find nonexistent.mk +make: directive-include.mk:49: Could not find " +make: directive-include.mk:56: Unknown modifier ":Z" while evaluating "${:U123:Z}.mk" with value "123" -make: "directive-include.mk" line 56: Could not find nonexistent.mk -make: "directive-include.mk" line 61: Cannot open /nonexistent -make: "directive-include.mk" line 66: Invalid line 'include' +make: directive-include.mk:56: Could not find nonexistent.mk +make: directive-include.mk:61: Cannot open /nonexistent +make: directive-include.mk:66: Invalid line 'include' make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests exit status 1 diff --git a/unit-tests/directive-include.mk b/unit-tests/directive-include.mk index bf3dd158b2ad..42cdd97c43c7 100755 --- a/unit-tests/directive-include.mk +++ b/unit-tests/directive-include.mk @@ -1,4 +1,4 @@ -# $NetBSD: directive-include.mk,v 1.17 2025/01/11 20:16:40 rillig Exp $ +# $NetBSD: directive-include.mk,v 1.19 2025/03/30 09:51:50 rillig Exp $ # # Tests for the .include directive, which includes another file. @@ -51,7 +51,7 @@ DQUOT= " # When the expression in a filename cannot be evaluated, the failing # expression is skipped and the file is included nevertheless. # FIXME: Add proper error handling, no file must be included here. -# expect+2: Unknown modifier "Z" +# expect+2: Unknown modifier ":Z" # expect+1: Could not find nonexistent.mk .include "nonexistent${:U123:Z}.mk" @@ -70,7 +70,7 @@ include # The following include directive behaves differently, depending on whether # the current file has a slash or is a relative filename. In the first case, # make opens the directory of the current file and tries to read from it, -# resulting in the error message """ line 1: Zero byte read from file". +# resulting in the error message ":1: Zero byte read from file". # In the second case, the error message is "Could not find ", without quotes # or any other indicator for the empty filename at the end of the line. #include ${:U} diff --git a/unit-tests/directive-info.exp b/unit-tests/directive-info.exp index 17c72caf1b23..730174d6ab4a 100644 --- a/unit-tests/directive-info.exp +++ b/unit-tests/directive-info.exp @@ -1,15 +1,15 @@ -make: "directive-info.mk" line 12: begin .info tests -make: "directive-info.mk" line 14: Unknown directive "inf" -make: "directive-info.mk" line 16: Missing argument for ".info" -make: "directive-info.mk" line 18: message -make: "directive-info.mk" line 20: indented message -make: "directive-info.mk" line 22: Unknown directive "information" -make: "directive-info.mk" line 24: Unknown directive "information" -make: "directive-info.mk" line 30: Missing argument for ".info" -make: "directive-info.mk" line 32: Missing argument for ".info" -make: "directive-info.mk" line 36: Unknown directive "info-message" -make: "directive-info.mk" line 38: no-target: no-source -make: "directive-info.mk" line 47: expect line 35 for multi-line message +make: directive-info.mk:12: begin .info tests +make: directive-info.mk:14: Unknown directive "inf" +make: directive-info.mk:16: Missing argument for ".info" +make: directive-info.mk:18: message +make: directive-info.mk:20: indented message +make: directive-info.mk:22: Unknown directive "information" +make: directive-info.mk:24: Unknown directive "information" +make: directive-info.mk:30: Missing argument for ".info" +make: directive-info.mk:32: Missing argument for ".info" +make: directive-info.mk:36: Unknown directive "info-message" +make: directive-info.mk:38: no-target: no-source +make: directive-info.mk:47: expect line 35 for multi-line message make: Fatal errors encountered -- cannot continue make: stopped making ".info.man" in unit-tests exit status 1 diff --git a/unit-tests/directive-misspellings.exp b/unit-tests/directive-misspellings.exp index a00615926740..b918d05a2683 100644 --- a/unit-tests/directive-misspellings.exp +++ b/unit-tests/directive-misspellings.exp @@ -1,45 +1,45 @@ -make: "directive-misspellings.mk" line 13: Unknown directive "dinclud" -make: "directive-misspellings.mk" line 16: Unknown directive "dincludx" -make: "directive-misspellings.mk" line 18: .include filename must be delimited by '"' or '<' -make: "directive-misspellings.mk" line 21: Unknown directive "erro" -make: "directive-misspellings.mk" line 23: Unknown directive "errox" -make: "directive-misspellings.mk" line 28: Unknown directive "expor" -make: "directive-misspellings.mk" line 31: Unknown directive "exporx" -make: "directive-misspellings.mk" line 33: Unknown directive "exports" -make: "directive-misspellings.mk" line 36: Unknown directive "export-en" -make: "directive-misspellings.mk" line 40: Unknown directive "export-environment" -make: "directive-misspellings.mk" line 43: Unknown directive "export-litera" -make: "directive-misspellings.mk" line 46: Unknown directive "export-literax" -make: "directive-misspellings.mk" line 48: Unknown directive "export-literally" -make: "directive-misspellings.mk" line 51: Unknown directive "-includ" -make: "directive-misspellings.mk" line 54: Unknown directive "-includx" -make: "directive-misspellings.mk" line 56: .include filename must be delimited by '"' or '<' -make: "directive-misspellings.mk" line 59: Unknown directive "includ" -make: "directive-misspellings.mk" line 61: Could not find file -make: "directive-misspellings.mk" line 63: Unknown directive "includx" -make: "directive-misspellings.mk" line 65: .include filename must be delimited by '"' or '<' -make: "directive-misspellings.mk" line 68: Unknown directive "inf" -make: "directive-misspellings.mk" line 70: msg -make: "directive-misspellings.mk" line 72: Unknown directive "infx" -make: "directive-misspellings.mk" line 74: Unknown directive "infos" -make: "directive-misspellings.mk" line 77: Unknown directive "sinclud" -make: "directive-misspellings.mk" line 80: Unknown directive "sincludx" -make: "directive-misspellings.mk" line 82: .include filename must be delimited by '"' or '<' -make: "directive-misspellings.mk" line 85: Unknown directive "unde" -make: "directive-misspellings.mk" line 88: Unknown directive "undex" -make: "directive-misspellings.mk" line 90: Unknown directive "undefs" -make: "directive-misspellings.mk" line 93: Unknown directive "unexpor" -make: "directive-misspellings.mk" line 96: Unknown directive "unexporx" -make: "directive-misspellings.mk" line 98: Unknown directive "unexports" -make: "directive-misspellings.mk" line 101: Unknown directive "unexport-en" -make: "directive-misspellings.mk" line 104: The directive .unexport-env does not take arguments -make: "directive-misspellings.mk" line 106: Unknown directive "unexport-enx" -make: "directive-misspellings.mk" line 108: Unknown directive "unexport-envs" -make: "directive-misspellings.mk" line 111: Unknown directive "warn" -make: "directive-misspellings.mk" line 113: Unknown directive "warnin" -make: "directive-misspellings.mk" line 115: warning: msg -make: "directive-misspellings.mk" line 117: Unknown directive "warninx" -make: "directive-misspellings.mk" line 119: Unknown directive "warnings" +make: directive-misspellings.mk:13: Unknown directive "dinclud" +make: directive-misspellings.mk:16: Unknown directive "dincludx" +make: directive-misspellings.mk:18: .include filename must be delimited by '"' or '<' +make: directive-misspellings.mk:21: Unknown directive "erro" +make: directive-misspellings.mk:23: Unknown directive "errox" +make: directive-misspellings.mk:28: Unknown directive "expor" +make: directive-misspellings.mk:31: Unknown directive "exporx" +make: directive-misspellings.mk:33: Unknown directive "exports" +make: directive-misspellings.mk:36: Unknown directive "export-en" +make: directive-misspellings.mk:40: Unknown directive "export-environment" +make: directive-misspellings.mk:43: Unknown directive "export-litera" +make: directive-misspellings.mk:46: Unknown directive "export-literax" +make: directive-misspellings.mk:48: Unknown directive "export-literally" +make: directive-misspellings.mk:51: Unknown directive "-includ" +make: directive-misspellings.mk:54: Unknown directive "-includx" +make: directive-misspellings.mk:56: .include filename must be delimited by '"' or '<' +make: directive-misspellings.mk:59: Unknown directive "includ" +make: directive-misspellings.mk:61: Could not find file +make: directive-misspellings.mk:63: Unknown directive "includx" +make: directive-misspellings.mk:65: .include filename must be delimited by '"' or '<' +make: directive-misspellings.mk:68: Unknown directive "inf" +make: directive-misspellings.mk:70: msg +make: directive-misspellings.mk:72: Unknown directive "infx" +make: directive-misspellings.mk:74: Unknown directive "infos" +make: directive-misspellings.mk:77: Unknown directive "sinclud" +make: directive-misspellings.mk:80: Unknown directive "sincludx" +make: directive-misspellings.mk:82: .include filename must be delimited by '"' or '<' +make: directive-misspellings.mk:85: Unknown directive "unde" +make: directive-misspellings.mk:88: Unknown directive "undex" +make: directive-misspellings.mk:90: Unknown directive "undefs" +make: directive-misspellings.mk:93: Unknown directive "unexpor" +make: directive-misspellings.mk:96: Unknown directive "unexporx" +make: directive-misspellings.mk:98: Unknown directive "unexports" +make: directive-misspellings.mk:101: Unknown directive "unexport-en" +make: directive-misspellings.mk:104: The directive .unexport-env does not take arguments +make: directive-misspellings.mk:106: Unknown directive "unexport-enx" +make: directive-misspellings.mk:108: Unknown directive "unexport-envs" +make: directive-misspellings.mk:111: Unknown directive "warn" +make: directive-misspellings.mk:113: Unknown directive "warnin" +make: directive-misspellings.mk:115: warning: msg +make: directive-misspellings.mk:117: Unknown directive "warninx" +make: directive-misspellings.mk:119: Unknown directive "warnings" make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 diff --git a/unit-tests/directive-sinclude.exp b/unit-tests/directive-sinclude.exp index 5b5560542c5a..b7503e18c9b5 100755 --- a/unit-tests/directive-sinclude.exp +++ b/unit-tests/directive-sinclude.exp @@ -1,4 +1,4 @@ -make: "directive-include-error.inc" line 1: Invalid line 'syntax error' +make: directive-include-error.inc:1: Invalid line 'syntax error' in directive-sinclude.mk:20 make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests diff --git a/unit-tests/directive-sinclude.mk b/unit-tests/directive-sinclude.mk index 58912c644a7e..d40915fa86d5 100755 --- a/unit-tests/directive-sinclude.mk +++ b/unit-tests/directive-sinclude.mk @@ -1,4 +1,4 @@ -# $NetBSD: directive-sinclude.mk,v 1.5 2023/08/19 10:52:14 rillig Exp $ +# $NetBSD: directive-sinclude.mk,v 1.6 2025/03/30 09:51:50 rillig Exp $ # # Tests for the .sinclude directive, which includes another file, # silently skipping it if it cannot be opened. @@ -15,7 +15,7 @@ .sinclude "${MAKEFILE}/subdir" # Errors that are not related to opening the file are still reported. -# expect: make: "directive-include-error.inc" line 1: Invalid line 'syntax error' +# expect: make: directive-include-error.inc:1: Invalid line 'syntax error' _!= echo 'syntax error' > directive-include-error.inc .sinclude "${.CURDIR}/directive-include-error.inc" _!= rm directive-include-error.inc diff --git a/unit-tests/directive-undef.exp b/unit-tests/directive-undef.exp index c62452abe2ba..f67be532c74f 100644 --- a/unit-tests/directive-undef.exp +++ b/unit-tests/directive-undef.exp @@ -1,7 +1,7 @@ -make: "directive-undef.mk" line 30: The .undef directive requires an argument -make: "directive-undef.mk" line 88: Unknown modifier "Z" +make: directive-undef.mk:30: The .undef directive requires an argument +make: directive-undef.mk:88: Unknown modifier ":Z" while evaluating variable "VARNAMES" with value "VARNAMES" -make: "directive-undef.mk" line 105: warning: UT_EXPORTED is still listed in .MAKE.EXPORTED even though spaceit is not exported anymore. +make: directive-undef.mk:105: warning: UT_EXPORTED is still listed in .MAKE.EXPORTED even though spaceit is not exported anymore. make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests exit status 1 diff --git a/unit-tests/directive-undef.mk b/unit-tests/directive-undef.mk index 167bb79ad07f..51867ac6f754 100644 --- a/unit-tests/directive-undef.mk +++ b/unit-tests/directive-undef.mk @@ -1,4 +1,4 @@ -# $NetBSD: directive-undef.mk,v 1.16 2024/08/29 20:20:36 rillig Exp $ +# $NetBSD: directive-undef.mk,v 1.17 2025/03/29 19:08:52 rillig Exp $ # # Tests for the .undef directive. # @@ -84,7 +84,7 @@ ${DOLLAR}= dollar # # As of var.c 1.762, this doesn't happen though because the error handling # in Var_Parse and Var_Subst is not done properly. -# expect+1: Unknown modifier "Z" +# expect+1: Unknown modifier ":Z" .undef ${VARNAMES:L:Z} diff --git a/unit-tests/directive-unexport-env.exp b/unit-tests/directive-unexport-env.exp index 57cf2d4b1dd9..cecebf3ef035 100644 --- a/unit-tests/directive-unexport-env.exp +++ b/unit-tests/directive-unexport-env.exp @@ -1,9 +1,9 @@ -make: "directive-unexport-env.mk" line 14: Unknown directive "unexport-en" -make: "directive-unexport-env.mk" line 17: Unknown directive "unexport-environment" +make: directive-unexport-env.mk:14: Unknown directive "unexport-en" +make: directive-unexport-env.mk:17: Unknown directive "unexport-environment" Global: UT_EXPORTED = value Global: UT_UNEXPORTED = value Global: .MAKE.EXPORTED = UT_EXPORTED -make: "directive-unexport-env.mk" line 24: The directive .unexport-env does not take arguments +make: directive-unexport-env.mk:24: The directive .unexport-env does not take arguments Var_Parse: ${.MAKE.EXPORTED:O:u} (eval) Evaluating modifier ${.MAKE.EXPORTED:O} on value "UT_EXPORTED" Result of ${.MAKE.EXPORTED:O} is "UT_EXPORTED" diff --git a/unit-tests/directive-unexport.exp b/unit-tests/directive-unexport.exp index b084daf5d147..1be4b03e3874 100644 --- a/unit-tests/directive-unexport.exp +++ b/unit-tests/directive-unexport.exp @@ -1,5 +1,5 @@ -make: "directive-unexport.mk" line 19: UT_A=a UT_B=b UT_C=c -make: "directive-unexport.mk" line 21: UT_A UT_B UT_C -make: "directive-unexport.mk" line 30: UT_A=a UT_B=b UT_C=c -make: "directive-unexport.mk" line 31: +make: directive-unexport.mk:19: UT_A=a UT_B=b UT_C=c +make: directive-unexport.mk:21: UT_A UT_B UT_C +make: directive-unexport.mk:30: UT_A=a UT_B=b UT_C=c +make: directive-unexport.mk:31: exit status 0 diff --git a/unit-tests/directive-warning.exp b/unit-tests/directive-warning.exp index 82bc06c55072..2dd4e8ceb7f9 100644 --- a/unit-tests/directive-warning.exp +++ b/unit-tests/directive-warning.exp @@ -1,11 +1,11 @@ -make: "directive-warning.mk" line 10: Unknown directive "warn" -make: "directive-warning.mk" line 12: Unknown directive "warn" -make: "directive-warning.mk" line 14: Unknown directive "warnin" -make: "directive-warning.mk" line 16: Unknown directive "warnin" -make: "directive-warning.mk" line 18: Missing argument for ".warning" -make: "directive-warning.mk" line 19: warning: message -make: "directive-warning.mk" line 21: Unknown directive "warnings" -make: "directive-warning.mk" line 23: Unknown directive "warnings" +make: directive-warning.mk:10: Unknown directive "warn" +make: directive-warning.mk:12: Unknown directive "warn" +make: directive-warning.mk:14: Unknown directive "warnin" +make: directive-warning.mk:16: Unknown directive "warnin" +make: directive-warning.mk:18: Missing argument for ".warning" +make: directive-warning.mk:19: warning: message +make: directive-warning.mk:21: Unknown directive "warnings" +make: directive-warning.mk:23: Unknown directive "warnings" make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests exit status 1 diff --git a/unit-tests/directive.exp b/unit-tests/directive.exp index a1532ee564dc..2f1da18cdbb5 100644 --- a/unit-tests/directive.exp +++ b/unit-tests/directive.exp @@ -1,14 +1,14 @@ -make: "directive.mk" line 10: Unknown directive "indented" -make: "directive.mk" line 12: Unknown directive "indented" -make: "directive.mk" line 14: Unknown directive "indented" -make: "directive.mk" line 19: Unknown directive "" +make: directive.mk:10: Unknown directive "indented" +make: directive.mk:12: Unknown directive "indented" +make: directive.mk:14: Unknown directive "indented" +make: directive.mk:19: Unknown directive "" Global: .info = # (empty) Global: .info = value -make: "directive.mk" line 31: := value +make: directive.mk:31: := value Global: .MAKEFLAGS = -r -k -d v -d Global: .MAKEFLAGS = -r -k -d v -d 0 -make: "directive.mk" line 40: Invalid line 'target-without-colon' -make: "directive.mk" line 43: Invalid line 'target-without-colon another-target' +make: directive.mk:40: Invalid line 'target-without-colon' +make: directive.mk:43: Invalid line 'target-without-colon another-target' make: Fatal errors encountered -- cannot continue make: stopped making ".target" in unit-tests exit status 1 diff --git a/unit-tests/error.exp b/unit-tests/error.exp index e782664498bf..3742be10b1a8 100644 --- a/unit-tests/error.exp +++ b/unit-tests/error.exp @@ -1,6 +1,6 @@ -make: "error.mk" line 7: just FYI -make: "error.mk" line 9: warning: this could be serious -make: "error.mk" line 11: this is fatal +make: error.mk:7: just FYI +make: error.mk:9: warning: this could be serious +make: error.mk:11: this is fatal make: stopped in unit-tests exit status 1 diff --git a/unit-tests/include-main.exp b/unit-tests/include-main.exp index f2b4263fccc4..f7587982d9b5 100644 --- a/unit-tests/include-main.exp +++ b/unit-tests/include-main.exp @@ -1,17 +1,17 @@ -make: "include-main.mk" line 15: main-before-ok -make: "include-main.mk" line 23: main-before-for-ok -make: "include-sub.inc" line 4: sub-before-ok -make: "include-sub.inc" line 14: sub-before-for-ok +make: include-main.mk:15: main-before-ok +make: include-main.mk:23: main-before-for-ok +make: include-sub.inc:4: sub-before-ok +make: include-sub.inc:14: sub-before-for-ok Parsing include-subsub.inc:5: . info subsub-ok -make: "include-subsub.inc" line 5: subsub-ok +make: include-subsub.inc:5: subsub-ok in .for loop from include-sub.inc:31 with i = include in .for loop from include-sub.inc:30 with i = nested in .for loop from include-sub.inc:29 with i = deeply in include-main.mk:29 Parsing include-subsub.inc:6: .MAKEFLAGS: -d0 ParseDependency(.MAKEFLAGS: -d0) -make: "include-sub.inc" line 38: sub-after-ok -make: "include-sub.inc" line 45: sub-after-for-ok -make: "include-main.mk" line 33: main-after-ok -make: "include-main.mk" line 41: main-after-for-ok +make: include-sub.inc:38: sub-after-ok +make: include-sub.inc:45: sub-after-for-ok +make: include-main.mk:33: main-after-ok +make: include-main.mk:41: main-after-for-ok exit status 0 diff --git a/unit-tests/lint.exp b/unit-tests/lint.exp index ded93d192b14..61188d6d5c29 100755 --- a/unit-tests/lint.exp +++ b/unit-tests/lint.exp @@ -1,4 +1,5 @@ make: In the :@ modifier, the variable name "${:Ubar:S,b,v,}" must not contain a dollar while evaluating variable "VAR" with value "value" + in command "@echo ${VAR:Uvalue:@${:Ubar:S,b,v,}@x${var}y@:Q}" in target "mod-loop-varname" exit status 2 diff --git a/unit-tests/meta-cmd-cmp.exp b/unit-tests/meta-cmd-cmp.exp index dc63da3b346b..c925e31d0489 100644 --- a/unit-tests/meta-cmd-cmp.exp +++ b/unit-tests/meta-cmd-cmp.exp @@ -7,27 +7,27 @@ Skipping meta for .END: .SPECIAL two: `.meta-cmd-cmp.cmp' is up to date. `.meta-cmd-cmp.nocmp' is up to date. -.meta-cmd-cmp.cmp2.meta: 3: cannot compare command using .OODATE +.meta-cmd-cmp.cmp2.meta:3: cannot compare command using .OODATE `.meta-cmd-cmp.cmp2' is up to date. Skipping meta for .END: .SPECIAL change1: -.meta-cmd-cmp.cmp.meta: 2: a build command has changed +.meta-cmd-cmp.cmp.meta:2: a build command has changed @echo FLAGS= > .meta-cmd-cmp.cmp vs @echo FLAGS=changed > .meta-cmd-cmp.cmp Building .meta-cmd-cmp.cmp `.meta-cmd-cmp.nocmp' is up to date. -.meta-cmd-cmp.cmp2.meta: 3: cannot compare command using .OODATE +.meta-cmd-cmp.cmp2.meta:3: cannot compare command using .OODATE `.meta-cmd-cmp.cmp2' is up to date. Skipping meta for .END: .SPECIAL change2: -.meta-cmd-cmp.cmp.meta: 2: a build command has changed +.meta-cmd-cmp.cmp.meta:2: a build command has changed @echo FLAGS=changed > .meta-cmd-cmp.cmp vs @echo FLAGS= > .meta-cmd-cmp.cmp Building .meta-cmd-cmp.cmp `.meta-cmd-cmp.nocmp' is up to date. -.meta-cmd-cmp.cmp2.meta: 2: a build command has changed +.meta-cmd-cmp.cmp2.meta:2: a build command has changed @echo FLAGS2= > .meta-cmd-cmp.cmp2 vs @echo FLAGS2=changed > .meta-cmd-cmp.cmp2 @@ -38,7 +38,7 @@ filter0: Building .meta-cmd-cmp.filter Skipping meta for .END: .SPECIAL filter1: -.meta-cmd-cmp.filter.meta: 2: a build command has changed +.meta-cmd-cmp.filter.meta:2: a build command has changed @echo ccache cc -c foo.c > .meta-cmd-cmp.filter vs @echo cc -c foo.c > .meta-cmd-cmp.filter diff --git a/unit-tests/moderrs.exp b/unit-tests/moderrs.exp index 06c305c83e4f..08aa2582f6be 100644 --- a/unit-tests/moderrs.exp +++ b/unit-tests/moderrs.exp @@ -1,140 +1,173 @@ -make: Unknown modifier "Z" +make: Unknown modifier ":Z" while evaluating variable "VAR" with value "TheVariable" + in command "@echo 'VAR:Z=before-${VAR:Z}-after'" in target "mod-unknown-direct" -make: Unknown modifier "Z" +make: Unknown modifier ":Z" + while evaluating indirect modifiers "Z" while evaluating variable "VAR" with value "TheVariable" + in command "@echo 'VAR:${MOD_UNKN}=before-${VAR:${MOD_UNKN}:inner}-after'" in target "mod-unknown-indirect" make: Unclosed expression, expecting '}' for modifier "S,V,v," while evaluating variable "VAR" with value "Thevariable" + in command "@echo VAR:S,V,v,=${VAR:S,V,v," in target "unclosed-direct" make: Unclosed expression after indirect modifier, expecting '}' while evaluating variable "VAR" with value "Thevariable" + in command "@echo VAR:${MOD_TERM},=${VAR:${MOD_S}" in target "unclosed-indirect" -make: Unfinished modifier (',' missing) +make: Unfinished modifier after "v", expecting "," + while evaluating indirect modifiers "S,V,v" while evaluating variable "VAR" with value "TheVariable" + in command "-@echo "VAR:${MOD_TERM}=${VAR:${MOD_TERM}}"" in target "unfinished-indirect" -make: Unfinished modifier ('@' missing) +make: Unfinished modifier after "var}", expecting "@" while evaluating variable "UNDEF" with value "1 2 3" + in command "@echo ${UNDEF:U1 2 3:@var}" in target "unfinished-loop-1" -make: Unfinished modifier ('@' missing) +make: Unfinished modifier after "...}", expecting "@" while evaluating variable "UNDEF" with value "1 2 3" + in command "@echo ${UNDEF:U1 2 3:@var@...}" in target "unfinished-loop-2" 1 2 3 make: Unclosed expression, expecting '}' for modifier "@var@${var}}...@" while evaluating variable "UNDEF" with value "1}... 2}... 3}..." + in command "@echo ${UNDEF:U1 2 3:@var@${var}}...@" in target "loop-close-1" 1}... 2}... 3}... -make: Unfinished modifier (']' missing) +make: Unfinished modifier after "}", expecting "]" while evaluating variable "UNDEF" with value "1 2 3" + in command "@echo ${UNDEF:U1 2 3:[}" in target "words-1" -make: Unfinished modifier (']' missing) +make: Unfinished modifier after "#}", expecting "]" while evaluating variable "UNDEF" with value "1 2 3" + in command "@echo ${UNDEF:U1 2 3:[#}" in target "words-2" 13= -make: Bad modifier ":[123451234512345123451234512345]" +make: Invalid modifier ":[123451234512345123451234512345]" while evaluating variable "UNDEF" with value "1 2 3" + in command "@echo 12345=${UNDEF:U1 2 3:[123451234512345123451234512345]:S,^$,ok,:S,^3$,ok,}" in target "words-3" -make: Unfinished modifier ('!' missing) +make: Unfinished modifier after "echo}", expecting "!" while evaluating variable "VARNAME" with value "" + in command "@echo ${VARNAME:!echo}" in target "exclam-1" -make: Unfinished modifier ('!' missing) +make: Unfinished modifier after "=exclam}", expecting "!" while evaluating variable "!" with value "!" + in command "@echo ${!:L:!=exclam}" in target "exclam-2" make: Missing delimiter for modifier ':S' while evaluating variable "VAR" with value "TheVariable" + in command "@echo 1: ${VAR:S" in target "mod-subst-delimiter-1" -make: Unfinished modifier (',' missing) +make: Unfinished modifier after "", expecting "," while evaluating variable "VAR" with value "TheVariable" + in command "@echo 2: ${VAR:S," in target "mod-subst-delimiter-2" -make: Unfinished modifier (',' missing) +make: Unfinished modifier after "from", expecting "," while evaluating variable "VAR" with value "TheVariable" + in command "@echo 3: ${VAR:S,from" in target "mod-subst-delimiter-3" -make: Unfinished modifier (',' missing) +make: Unfinished modifier after "", expecting "," while evaluating variable "VAR" with value "TheVariable" + in command "@echo 4: ${VAR:S,from," in target "mod-subst-delimiter-4" -make: Unfinished modifier (',' missing) +make: Unfinished modifier after "to", expecting "," while evaluating variable "VAR" with value "TheVariable" + in command "@echo 5: ${VAR:S,from,to" in target "mod-subst-delimiter-5" make: Unclosed expression, expecting '}' for modifier "S,from,to," while evaluating variable "VAR" with value "TheVariable" + in command "@echo 6: ${VAR:S,from,to," in target "mod-subst-delimiter-6" 7: TheVariable make: Missing delimiter for modifier ':C' while evaluating variable "VAR" with value "TheVariable" + in command "@echo 1: ${VAR:C" in target "mod-regex-delimiter-1" -make: Unfinished modifier (',' missing) +make: Unfinished modifier after "", expecting "," while evaluating variable "VAR" with value "TheVariable" + in command "@echo 2: ${VAR:C," in target "mod-regex-delimiter-2" -make: Unfinished modifier (',' missing) +make: Unfinished modifier after "from", expecting "," while evaluating variable "VAR" with value "TheVariable" + in command "@echo 3: ${VAR:C,from" in target "mod-regex-delimiter-3" -make: Unfinished modifier (',' missing) +make: Unfinished modifier after "", expecting "," while evaluating variable "VAR" with value "TheVariable" + in command "@echo 4: ${VAR:C,from," in target "mod-regex-delimiter-4" -make: Unfinished modifier (',' missing) +make: Unfinished modifier after "to", expecting "," while evaluating variable "VAR" with value "TheVariable" + in command "@echo 5: ${VAR:C,from,to" in target "mod-regex-delimiter-5" make: Unclosed expression, expecting '}' for modifier "C,from,to," while evaluating variable "VAR" with value "TheVariable" + in command "@echo 6: ${VAR:C,from,to," in target "mod-regex-delimiter-6" 7: TheVariable 112358132134 15152535558513521534 -make: Bad modifier ":ts\65oct" +make: Unknown modifier ":ts\65oct" while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34" + in command "@echo ${FIB:ts\65oct} # bad modifier" in target "mod-ts-parse-3" -make: Bad modifier ":ts\65oct" +make: Unknown modifier ":ts\65oct" while evaluating "${:U${FIB}:ts\65oct} # bad modifier, variable name is """ with value "1 1 2 3 5 8 13 21 34" + in command "@echo ${:U${FIB}:ts\65oct} # bad modifier, variable name is """ in target "mod-ts-parse-4" -make: Bad modifier ":tsxy" +make: Unknown modifier ":tsxy" while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34" + in command "@echo ${FIB:tsxy} # modifier too long" in target "mod-ts-parse-5" -make: Bad modifier ":t" +make: Unknown modifier ":t" while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34" + in command "@echo ${FIB:t" in target "mod-t-parse-1" -make: Bad modifier ":txy" +make: Unknown modifier ":txy" while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34" + in command "@echo ${FIB:txy}" in target "mod-t-parse-2" -make: Bad modifier ":t" +make: Unknown modifier ":t" while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34" + in command "@echo ${FIB:t}" in target "mod-t-parse-3" -make: Bad modifier ":t" +make: Unknown modifier ":t" while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34" + in command "@echo ${FIB:t:M*}" in target "mod-t-parse-4" -make: Unfinished modifier (':' missing) +make: Unfinished modifier after "", expecting ":" while evaluating then-branch of condition "FIB" + in command "@echo ${FIB:?" in target "mod-ifelse-parse-1" -make: Unfinished modifier (':' missing) +make: Unfinished modifier after "then", expecting ":" while evaluating then-branch of condition "FIB" + in command "@echo ${FIB:?then" in target "mod-ifelse-parse-2" -make: Unfinished modifier ('}' missing) +make: Unfinished modifier after "", expecting "}" while evaluating else-branch of condition "FIB" + in command "@echo ${FIB:?then:" in target "mod-ifelse-parse-3" -make: Unfinished modifier ('}' missing) +make: Unfinished modifier after "else", expecting "}" while evaluating else-branch of condition "FIB" + in command "@echo ${FIB:?then:else" in target "mod-ifelse-parse-4" then 1 1 2 3 5 8 13 21 34 -make: Unknown modifier "__" +make: Unknown modifier ":__" while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34" + in command "@echo ${FIB:__} # modifier name too long" in target "mod-remember-parse" -make: Unknown modifier "3" +make: Unknown modifier ":3" while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34" + in command "@echo ${FIB:3" in target "mod-sysv-parse-1" -make: Unclosed expression, expecting '}' for modifier "3" - while evaluating variable "FIB" with value "" - in target "mod-sysv-parse-1" -make: Unknown modifier "3=" +make: Unfinished modifier after "", expecting "}" while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34" + in command "@echo ${FIB:3=" in target "mod-sysv-parse-2" -make: Unclosed expression, expecting '}' for modifier "3=" - while evaluating variable "FIB" with value "" - in target "mod-sysv-parse-2" -make: Unknown modifier "3=x3" +make: Unfinished modifier after "x3", expecting "}" while evaluating variable "FIB" with value "1 1 2 3 5 8 13 21 34" - in target "mod-sysv-parse-3" -make: Unclosed expression, expecting '}' for modifier "3=x3" - while evaluating variable "FIB" with value "" + in command "@echo ${FIB:3=x3" in target "mod-sysv-parse-3" 1 1 2 x3 5 8 1x3 21 34 exit status 2 diff --git a/unit-tests/moderrs.mk b/unit-tests/moderrs.mk index ad9333dcfb1d..ca5cc082e6b8 100644 --- a/unit-tests/moderrs.mk +++ b/unit-tests/moderrs.mk @@ -1,4 +1,4 @@ -# $NetBSD: moderrs.mk,v 1.41 2024/08/29 20:20:36 rillig Exp $ +# $NetBSD: moderrs.mk,v 1.46 2025/03/30 00:35:52 rillig Exp $ # # various modifier error tests @@ -25,11 +25,11 @@ all: mod-remember-parse all: mod-sysv-parse-{1,2,3,4} mod-unknown-direct: -# expect: make: Unknown modifier "Z" +# expect: make: Unknown modifier ":Z" @echo 'VAR:Z=before-${VAR:Z}-after' mod-unknown-indirect: -# expect: make: Unknown modifier "Z" +# expect: make: Unknown modifier ":Z" @echo 'VAR:${MOD_UNKN}=before-${VAR:${MOD_UNKN}:inner}-after' unclosed-direct: @@ -41,14 +41,14 @@ unclosed-indirect: @echo VAR:${MOD_TERM},=${VAR:${MOD_S} unfinished-indirect: -# expect: make: Unfinished modifier (',' missing) +# expect: make: Unfinished modifier after "v", expecting "," -@echo "VAR:${MOD_TERM}=${VAR:${MOD_TERM}}" unfinished-loop-1: -# expect: make: Unfinished modifier ('@' missing) +# expect: make: Unfinished modifier after "var}", expecting "@" @echo ${UNDEF:U1 2 3:@var} unfinished-loop-2: -# expect: make: Unfinished modifier ('@' missing) +# expect: make: Unfinished modifier after "...}", expecting "@" @echo ${UNDEF:U1 2 3:@var@...} unfinished-loop-3: @echo ${UNDEF:U1 2 3:@var@${var}@} @@ -66,10 +66,10 @@ loop-close-2: @echo ${UNDEF:U1 2 3:@var@${var}}...@} words-1: -# expect: make: Unfinished modifier (']' missing) +# expect: make: Unfinished modifier after "}", expecting "]" @echo ${UNDEF:U1 2 3:[} words-2: -# expect: make: Unfinished modifier (']' missing) +# expect: make: Unfinished modifier after "#}", expecting "]" @echo ${UNDEF:U1 2 3:[#} words-3: @@ -96,30 +96,30 @@ words-3: @echo 12345=${UNDEF:U1 2 3:[123451234512345123451234512345]:S,^$,ok,:S,^3$,ok,} exclam-1: -# expect: make: Unfinished modifier ('!' missing) +# expect: make: Unfinished modifier after "echo}", expecting "!" @echo ${VARNAME:!echo} # When the final exclamation mark is missing, there is no # fallback to the SysV substitution modifier. # If there were a fallback, the output would be "exclam", # and the above would have produced an "Unknown modifier '!'". exclam-2: -# expect: make: Unfinished modifier ('!' missing) +# expect: make: Unfinished modifier after "=exclam}", expecting "!" @echo ${!:L:!=exclam} mod-subst-delimiter-1: # expect: make: Missing delimiter for modifier ':S' @echo 1: ${VAR:S mod-subst-delimiter-2: -# expect: make: Unfinished modifier (',' missing) +# expect: make: Unfinished modifier after "", expecting "," @echo 2: ${VAR:S, mod-subst-delimiter-3: -# expect: make: Unfinished modifier (',' missing) +# expect: make: Unfinished modifier after "from", expecting "," @echo 3: ${VAR:S,from mod-subst-delimiter-4: -# expect: make: Unfinished modifier (',' missing) +# expect: make: Unfinished modifier after "", expecting "," @echo 4: ${VAR:S,from, mod-subst-delimiter-5: -# expect: make: Unfinished modifier (',' missing) +# expect: make: Unfinished modifier after "to", expecting "," @echo 5: ${VAR:S,from,to mod-subst-delimiter-6: # expect: make: Unclosed expression, expecting '}' for modifier "S,from,to," @@ -131,16 +131,16 @@ mod-regex-delimiter-1: # expect: make: Missing delimiter for modifier ':C' @echo 1: ${VAR:C mod-regex-delimiter-2: -# expect: make: Unfinished modifier (',' missing) +# expect: make: Unfinished modifier after "", expecting "," @echo 2: ${VAR:C, mod-regex-delimiter-3: -# expect: make: Unfinished modifier (',' missing) +# expect: make: Unfinished modifier after "from", expecting "," @echo 3: ${VAR:C,from mod-regex-delimiter-4: -# expect: make: Unfinished modifier (',' missing) +# expect: make: Unfinished modifier after "", expecting "," @echo 4: ${VAR:C,from, mod-regex-delimiter-5: -# expect: make: Unfinished modifier (',' missing) +# expect: make: Unfinished modifier after "to", expecting "," @echo 5: ${VAR:C,from,to mod-regex-delimiter-6: # expect: make: Unclosed expression, expecting '}' for modifier "C,from,to," @@ -153,59 +153,56 @@ mod-ts-parse-1: mod-ts-parse-2: @echo ${FIB:ts\65} # octal 065 == U+0035 == '5' mod-ts-parse-3: -# expect: make: Bad modifier ":ts\65oct" +# expect: make: Unknown modifier ":ts\65oct" @echo ${FIB:ts\65oct} # bad modifier mod-ts-parse-4: -# expect: make: Bad modifier ":ts\65oct" +# expect: make: Unknown modifier ":ts\65oct" @echo ${:U${FIB}:ts\65oct} # bad modifier, variable name is "" mod-ts-parse-5: -# expect: make: Bad modifier ":tsxy" +# expect: make: Unknown modifier ":tsxy" @echo ${FIB:tsxy} # modifier too long mod-t-parse-1: -# expect: make: Bad modifier ":t" +# expect: make: Unknown modifier ":t" @echo ${FIB:t mod-t-parse-2: -# expect: make: Bad modifier ":txy" +# expect: make: Unknown modifier ":txy" @echo ${FIB:txy} mod-t-parse-3: -# expect: make: Bad modifier ":t" +# expect: make: Unknown modifier ":t" @echo ${FIB:t} mod-t-parse-4: -# expect: make: Bad modifier ":t" +# expect: make: Unknown modifier ":t" @echo ${FIB:t:M*} mod-ifelse-parse-1: -# expect: make: Unfinished modifier (':' missing) +# expect: make: Unfinished modifier after "", expecting ":" @echo ${FIB:? mod-ifelse-parse-2: -# expect: make: Unfinished modifier (':' missing) +# expect: make: Unfinished modifier after "then", expecting ":" @echo ${FIB:?then mod-ifelse-parse-3: -# expect: make: Unfinished modifier ('}' missing) +# expect: make: Unfinished modifier after "", expecting "}" @echo ${FIB:?then: mod-ifelse-parse-4: -# expect: make: Unfinished modifier ('}' missing) +# expect: make: Unfinished modifier after "else", expecting "}" @echo ${FIB:?then:else mod-ifelse-parse-5: @echo ${FIB:?then:else} mod-remember-parse: @echo ${FIB:_} # ok -# expect: make: Unknown modifier "__" +# expect: make: Unknown modifier ":__" @echo ${FIB:__} # modifier name too long mod-sysv-parse-1: -# expect: make: Unknown modifier "3" -# expect: make: Unclosed expression, expecting '}' for modifier "3" +# expect: make: Unknown modifier ":3" @echo ${FIB:3 mod-sysv-parse-2: -# expect: make: Unknown modifier "3=" -# expect: make: Unclosed expression, expecting '}' for modifier "3=" +# expect: make: Unfinished modifier after "", expecting "}" @echo ${FIB:3= mod-sysv-parse-3: -# expect: make: Unknown modifier "3=x3" -# expect: make: Unclosed expression, expecting '}' for modifier "3=x3" +# expect: make: Unfinished modifier after "x3", expecting "}" @echo ${FIB:3=x3 mod-sysv-parse-4: @echo ${FIB:3=x3} # ok diff --git a/unit-tests/opt-debug-file.exp b/unit-tests/opt-debug-file.exp index aa647456baf7..1059351188e4 100644 --- a/unit-tests/opt-debug-file.exp +++ b/unit-tests/opt-debug-file.exp @@ -1,6 +1,6 @@ -make: "opt-debug-file.mk" line 44: This goes to stderr only, once. -make: "opt-debug-file.mk" line 47: This goes to stderr only, once. -make: "opt-debug-file.mk" line 50: This goes to stderr, and in addition to the debug log. +make: opt-debug-file.mk:44: This goes to stderr only, once. +make: opt-debug-file.mk:47: This goes to stderr only, once. +make: opt-debug-file.mk:50: This goes to stderr, and in addition to the debug log. CondParser_Eval: ${:!cat opt-debug-file.debuglog!:Maddition:[#]} != 1 Comparing 1.000000 != 1.000000 make: Unterminated quoted string [make 'This goes to stdout only, once.] diff --git a/unit-tests/opt-debug-hash.exp b/unit-tests/opt-debug-hash.exp index 605161fa797e..1976b142b06f 100644 --- a/unit-tests/opt-debug-hash.exp +++ b/unit-tests/opt-debug-hash.exp @@ -1,4 +1,4 @@ -make: "opt-debug-hash.mk" line 13: Missing argument for ".error" +make: opt-debug-hash.mk:13: Missing argument for ".error" make: Fatal errors encountered -- cannot continue HashTable "targets": size=16 entries=0 maxchain=0 HashTable "Global variables": size=16 entries=<entries> maxchain=4 diff --git a/unit-tests/opt-debug-lint.exp b/unit-tests/opt-debug-lint.exp index 7274a06333ee..8e7339fcd2e9 100644 --- a/unit-tests/opt-debug-lint.exp +++ b/unit-tests/opt-debug-lint.exp @@ -1,10 +1,10 @@ -make: "opt-debug-lint.mk" line 20: Variable "X" is undefined -make: "opt-debug-lint.mk" line 43: Variable "UNDEF" is undefined -make: "opt-debug-lint.mk" line 65: Missing delimiter ':' after modifier "L" +make: opt-debug-lint.mk:20: Variable "X" is undefined +make: opt-debug-lint.mk:43: Variable "UNDEF" is undefined +make: opt-debug-lint.mk:65: Missing delimiter ':' after modifier "L" while evaluating variable "value" with value "value" -make: "opt-debug-lint.mk" line 65: Missing delimiter ':' after modifier "P" +make: opt-debug-lint.mk:65: Missing delimiter ':' after modifier "P" while evaluating variable "value" with value "value" -make: "opt-debug-lint.mk" line 74: Unknown modifier "${" +make: opt-debug-lint.mk:74: Unknown modifier ":${" while evaluating variable "value" with value "" make: Fatal errors encountered -- cannot continue make: stopped in unit-tests diff --git a/unit-tests/opt-debug-lint.mk b/unit-tests/opt-debug-lint.mk index 7918490b3f1a..59cd36fb05e9 100644 --- a/unit-tests/opt-debug-lint.mk +++ b/unit-tests/opt-debug-lint.mk @@ -1,4 +1,4 @@ -# $NetBSD: opt-debug-lint.mk,v 1.22 2025/01/11 20:54:45 rillig Exp $ +# $NetBSD: opt-debug-lint.mk,v 1.24 2025/04/04 18:57:01 rillig Exp $ # # Tests for the -dL command line option, which runs additional checks # to catch common mistakes, such as unclosed expressions. @@ -70,9 +70,11 @@ ${UNDEF}: ${UNDEF} # variable modifier had to be separated by colons. This was wrong though # since make always fell back trying to parse the indirect modifier as a # SysV modifier. -# expect+1: Unknown modifier "${" -.if ${value:${:UL}PL} != "LPL}" # FIXME: "LPL}" is unexpected here. +# expect+1: Unknown modifier ":${" +.if ${value:${:UL}PL} != "" . error ${value:${:UL}PL} +.else +. error .endif # Typically, an indirect modifier is followed by a colon or the closing diff --git a/unit-tests/opt-debug-parse.exp b/unit-tests/opt-debug-parse.exp index f0b57f2a703b..05659e28ee11 100644 --- a/unit-tests/opt-debug-parse.exp +++ b/unit-tests/opt-debug-parse.exp @@ -1,27 +1,27 @@ Parsing opt-debug-parse.mk:16: .for var in value -Parse_PushInput: .for loop in opt-debug-parse.mk, line 16 +Parse_PushInput: .for loop in opt-debug-parse.mk:16 SetFilenameVars: ${.PARSEDIR} = <some-dir> ${.PARSEFILE} = `opt-debug-parse.mk' Parsing opt-debug-parse.mk:21: .info trace with multi-line .for loop head -make: "opt-debug-parse.mk" line 21: trace with multi-line .for loop head +make: opt-debug-parse.mk:21: trace with multi-line .for loop head in .for loop from opt-debug-parse.mk:16 with var = value -ParseEOF: returning to file opt-debug-parse.mk, line 23 +ParseEOF: returning to opt-debug-parse.mk:23 SetFilenameVars: ${.PARSEDIR} = <some-dir> ${.PARSEFILE} = `opt-debug-parse.mk' Parsing opt-debug-parse.mk:26: .include "/dev/null" -Parse_PushInput: file /dev/null, line 1 +Parse_PushInput: /dev/null:1 SetFilenameVars: ${.PARSEDIR} = <some-dir> ${.PARSEFILE} = `null' SetFilenameVars: ${.INCLUDEDFROMDIR} = <some-dir> ${.INCLUDEDFROMFILE} = `opt-debug-parse.mk' -ParseEOF: returning to file opt-debug-parse.mk, line 27 +ParseEOF: returning to opt-debug-parse.mk:27 SetFilenameVars: ${.PARSEDIR} = <some-dir> ${.PARSEFILE} = `opt-debug-parse.mk' Parsing opt-debug-parse.mk:31: .for a b c in 1 2 3 ${:U4 5 6} -Parse_PushInput: .for loop in opt-debug-parse.mk, line 31 +Parse_PushInput: .for loop in opt-debug-parse.mk:31 SetFilenameVars: ${.PARSEDIR} = <some-dir> ${.PARSEFILE} = `opt-debug-parse.mk' Parsing opt-debug-parse.mk:34: .info trace -make: "opt-debug-parse.mk" line 34: trace +make: opt-debug-parse.mk:34: trace in .for loop from opt-debug-parse.mk:31 with a = 1, b = 2, c = 3 Parsing opt-debug-parse.mk:34: .info trace -make: "opt-debug-parse.mk" line 34: trace +make: opt-debug-parse.mk:34: trace in .for loop from opt-debug-parse.mk:31 with a = 4, b = 5, c = 6 -ParseEOF: returning to file opt-debug-parse.mk, line 36 +ParseEOF: returning to opt-debug-parse.mk:36 SetFilenameVars: ${.PARSEDIR} = <some-dir> ${.PARSEFILE} = `opt-debug-parse.mk' Parsing opt-debug-parse.mk:38: .MAKEFLAGS: -d0 ParseDependency(.MAKEFLAGS: -d0) diff --git a/unit-tests/opt-debug-var.exp b/unit-tests/opt-debug-var.exp index e113e66f26fe..5ee77d2f249d 100644 --- a/unit-tests/opt-debug-var.exp +++ b/unit-tests/opt-debug-var.exp @@ -3,9 +3,9 @@ Global: SUBST = # (empty) Global: SUBST = value Var_Parse: y(ASSIGNED) (eval) Var_Parse: $U (eval-defined-loud) -make: "opt-debug-var.mk" line 34: Variable "U" is undefined +make: opt-debug-var.mk:34: Variable "U" is undefined Var_Parse: $< (eval-defined-loud) -make: "opt-debug-var.mk" line 40: Variable "<" is undefined +make: opt-debug-var.mk:40: Variable "<" is undefined Global: .MAKEFLAGS = -r -k -d v -d Global: .MAKEFLAGS = -r -k -d v -d 0 make: Fatal errors encountered -- cannot continue diff --git a/unit-tests/opt-file.exp b/unit-tests/opt-file.exp index 78d1bfd0df4f..3087ab790d2e 100644 --- a/unit-tests/opt-file.exp +++ b/unit-tests/opt-file.exp @@ -1,7 +1,7 @@ value value line-with-trailing-whitespace -make: "(stdin)" line 1: Zero byte read from file +make: (stdin):1: Zero byte read from file in directory <curdir> *** Error code 2 (continuing) `all' not remade because of errors. diff --git a/unit-tests/opt-warnings-as-errors.exp b/unit-tests/opt-warnings-as-errors.exp index 8e392f9f9c6d..4e95da911102 100644 --- a/unit-tests/opt-warnings-as-errors.exp +++ b/unit-tests/opt-warnings-as-errors.exp @@ -1,6 +1,6 @@ -make: "opt-warnings-as-errors.mk" line 13: warning: message 1 +make: opt-warnings-as-errors.mk:13: warning: message 1 make: parsing warnings being treated as errors -make: "opt-warnings-as-errors.mk" line 15: warning: message 2 +make: opt-warnings-as-errors.mk:15: warning: message 2 parsing continues make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests diff --git a/unit-tests/parse.exp b/unit-tests/parse.exp index b55904c4df56..86d12effb5c7 100644 --- a/unit-tests/parse.exp +++ b/unit-tests/parse.exp @@ -1,6 +1,6 @@ -make: "parse.mk" line 7: Invalid line '<<<<<< old' -make: "parse.mk" line 14: Invalid line '>>>>>> new' -make: "parse.mk" line 25: Invalid line 'one-target ${:U }', expanded to 'one-target ' +make: parse.mk:7: Invalid line '<<<<<< old' +make: parse.mk:14: Invalid line '>>>>>> new' +make: parse.mk:25: Invalid line 'one-target ${:U }', expanded to 'one-target ' make: Fatal errors encountered -- cannot continue make: stopped making "Try_to_crash_FreeBSD.xxxxxxxxxxxxxxxxxx" in unit-tests exit status 1 diff --git a/unit-tests/posix-execution.exp b/unit-tests/posix-execution.exp new file mode 100644 index 000000000000..e455adaf98d7 --- /dev/null +++ b/unit-tests/posix-execution.exp @@ -0,0 +1,24 @@ +one-at-a-time: shell_variable is 'second' +echo "prefixes: ignore errors"; exit 13 +prefixes: ignore errors +*** Error code 13 (ignored) +prefixes: no echo +prefixes: always, no echo +shell-e-option: before +shell-e-option: after +echo 'do-prefix-plus: a regular command' +echo 'do-prefix-plus: prefixed by plus' +do-prefix-plus: prefixed by plus +echo 'do-prefix-plus: a regular command' +{ echo 'do-prefix-plus: a regular command' +} || exit $? +echo 'do-prefix-plus: prefixed by plus' +do-prefix-plus: prefixed by plus +{ echo 'do-prefix-plus: a regular command' +} || exit $? +do-error-not-ignored: successful +*** Error code 13 (continuing) + +Stop. +make: stopped making "do-error-not-ignored" in unit-tests +exit status 0 diff --git a/unit-tests/posix-execution.mk b/unit-tests/posix-execution.mk new file mode 100644 index 000000000000..ef4a66d84102 --- /dev/null +++ b/unit-tests/posix-execution.mk @@ -0,0 +1,59 @@ +# $NetBSD: posix-execution.mk,v 1.1 2025/04/13 09:29:32 rillig Exp $ +# +# https://pubs.opengroup.org/onlinepubs/9799919799/utilities/make.html#tag_20_76_13_03 +# + +.POSIX: + + +# The target consists of two commands, which are executed separately. +# The second command thus does not see the shell variable from the first +# command. +# expect: one-at-a-time: shell_variable is 'second' +all: one-at-a-time +one-at-a-time: + @shell_variable=first + @echo "$@: shell_variable is '$${shell_variable:-second}'" + + +# expect: echo "prefixes: ignore errors"; exit 13 +# expect: prefixes: ignore errors +# expect-not: echo "prefixes: no echo" +# expect: prefixes: no echo +# expect: prefixes: always, no echo +all: prefixes +prefixes: + -echo "$@: ignore errors"; exit 13 + @echo "$@: no echo" + +@echo "$@: always, no echo" + + +# Deviation from POSIX: The shell "-e" option is not in effect. +# expect: shell-e-option: before +# expect: shell-e-option: after +all: shell-e-option +shell-e-option: + @echo '$@: before'; false; echo '$@: after' + + +# expect-not-matches: ^do%-prefix%-plus: a regular command +# expect: do-prefix-plus: prefixed by plus +# expect: do-prefix-plus: prefixed by plus +all: prefix-plus +prefix-plus: + @${MAKE} -f ${MAKEFILE} -n do-prefix-plus + @${MAKE} -f ${MAKEFILE} -n -j1 do-prefix-plus +do-prefix-plus: + @echo '$@: a regular command' + @+echo '$@: prefixed by plus' + @echo '$@: a regular command' + + +# expect: do-error-not-ignored: successful +# expect-not: do-error-not-ignored: after an error +all: error-not-ignored +error-not-ignored: + @${MAKE} -f ${MAKEFILE} do-error-not-ignored || : +do-error-not-ignored: + @echo '$@: successful'; exit 13 + @echo '$@: after an error' diff --git a/unit-tests/posix-expansion.exp b/unit-tests/posix-expansion.exp new file mode 100644 index 000000000000..39a9383953dd --- /dev/null +++ b/unit-tests/posix-expansion.exp @@ -0,0 +1 @@ +exit status 0 diff --git a/unit-tests/posix-expansion.mk b/unit-tests/posix-expansion.mk new file mode 100644 index 000000000000..59082d567b37 --- /dev/null +++ b/unit-tests/posix-expansion.mk @@ -0,0 +1,22 @@ +# $NetBSD: posix-expansion.mk,v 1.2 2025/04/13 09:34:43 rillig Exp $ +# +# https://pubs.opengroup.org/onlinepubs/9799919799/utilities/make.html#tag_20_76_13_05 +# +# In POSIX mode, when expanding an expression containing modifiers, the +# modifiers specified in POSIX take precedence over the BSD-style modifiers. + +.POSIX: + + +MOD_SUBST= S s from to +# The modifier contains a "=" and is thus the POSIX modifier. +.if ${MOD_SUBST:S=from=to=} != "from=to= s from to" +. error +.endif +# The modifier does not contain a "=" and thus falls back to the BSD modifier. +.if ${MOD_SUBST:S,from,to,} != "S s to to" +. error +.endif + + +all: diff --git a/unit-tests/posix-varassign.exp b/unit-tests/posix-varassign.exp new file mode 100644 index 000000000000..39a9383953dd --- /dev/null +++ b/unit-tests/posix-varassign.exp @@ -0,0 +1 @@ +exit status 0 diff --git a/unit-tests/posix-varassign.mk b/unit-tests/posix-varassign.mk new file mode 100644 index 000000000000..6b9b2f083e3e --- /dev/null +++ b/unit-tests/posix-varassign.mk @@ -0,0 +1,79 @@ +# $NetBSD: posix-varassign.mk,v 1.1 2025/04/13 09:29:33 rillig Exp $ +# +# https://pubs.opengroup.org/onlinepubs/9799919799/utilities/make.html#tag_20_76_13_05 +# +# Test that variable assignments work in the same way as in default mode. +# +# The assignment operators "::=" and ":::=" are intentionally not supported, +# as they would introduce the distinction between eagerly and lazily evaluated +# macros, in addition to the eagerly and lazily evaluated assignments, and +# this would add too much complexity to the user's mental model, for too +# little benefit. + +.POSIX: + + +VAR= value +.if ${VAR} != "value" +. error +.endif + + +# Deviation from POSIX: The "::=" assignment operator is not supported, +# instead, the variable named "VAR:" is defined. +VAR= before +VAR::= posix-immediate-expansion +.if ${VAR} != "before" +. error +.elif ${${:UVAR\:}} != "posix-immediate-expansion" +. error +.endif + + +# Deviation from POSIX: The ":::=" assignment operator is not supported, +# instead, the variable named "VAR::" is defined. +VAR:::= posix-delayed-expansion +.if ${VAR} != "before" +. error +.elif ${${:UVAR\:\:}} != "posix-delayed-expansion" +. error +.endif + + +VAR!= echo from shell command +.if ${VAR} != "from shell command" +. error +.endif + + +VAR= value +VAR?= fallback +.if ${VAR} != "value" +. error +.endif +.undef VAR +VAR?= fallback +.if ${VAR} != "fallback" +. error +.endif + + +VAR= value +VAR+= appended +.if ${VAR} != "value appended" +. error +.endif + + +# In POSIX mode, the ":=" assignment operator is available as well, even +# though it is not specified by POSIX, due to the differences in existing +# make implementations. +REF= before +VAR:= immediate ${REF} +REF= after +.if ${VAR} != "immediate before" +. error +.endif + + +all: diff --git a/unit-tests/posix.exp b/unit-tests/posix.exp index 3af8361b1193..0d299fcca8d3 100644 --- a/unit-tests/posix.exp +++ b/unit-tests/posix.exp @@ -1,26 +1,4 @@ -Posix says we should execute the command as if run by system(3) -Expect 'Hello,' and 'World!' -Hello, -World! -a command -a command prefixed by '+' executes even with -n -another command -make -n -echo a command -echo "a command prefixed by '+' executes even with -n" -a command prefixed by '+' executes even with -n -echo another command -make -n -j1 -{ echo a command -} || exit $? -echo "a command prefixed by '+' executes even with -n" -a command prefixed by '+' executes even with -n -{ echo another command -} || exit $? -Now we expect an error... -*** Error code 1 (continuing) -`all' not remade because of errors. +make: no target to make. -Stop. -make: stopped making "all" in unit-tests -exit status 1 +make: stopped in unit-tests +exit status 2 diff --git a/unit-tests/posix.mk b/unit-tests/posix.mk index 43219258306e..5fe2ba9e1e07 100644 --- a/unit-tests/posix.mk +++ b/unit-tests/posix.mk @@ -1,23 +1,13 @@ -# $NetBSD: posix.mk,v 1.3 2022/01/23 18:15:29 rillig Exp $ - -all: x plus subs err - -x: - @echo "Posix says we should execute the command as if run by system(3)" - @echo "Expect 'Hello,' and 'World!'" - @echo Hello,; false; echo "World!" - -plus: - @echo a command - +@echo "a command prefixed by '+' executes even with -n" - @echo another command - -subs: - @echo make -n - @${.MAKE} -r -f ${MAKEFILE} -n plus - @echo make -n -j1 - @${.MAKE} -r -f ${MAKEFILE} -n -j1 plus - -err: - @(echo Now we expect an error...; exit 1) - @echo "Oops! you shouldn't see this!" +# $NetBSD: posix.mk,v 1.5 2025/04/13 09:44:58 rillig Exp $ +# +# This file is included in all tests that start with a ".POSIX:" line, +# even when the "-r" option is given. + +# The makefile containing the POSIX definitions is not supposed to contain a +# ".POSIX:" line, but even if it does, this must not lead to an endless loop +# by including it over and over again. +.POSIX: + +# The file <posix.mk> is not intended to be used as a top-level makefile, and +# it is not supposed to define any targets, only rules. +# expect: make: no target to make. diff --git a/unit-tests/recursive.exp b/unit-tests/recursive.exp index f63b7a54049e..e128d80beea6 100644 --- a/unit-tests/recursive.exp +++ b/unit-tests/recursive.exp @@ -1,5 +1,5 @@ -make: "recursive.mk" line 38: Unclosed variable "MISSING_PAREN" -make: "recursive.mk" line 40: Unclosed variable "MISSING_BRACE" +make: recursive.mk:38: Unclosed variable "MISSING_PAREN" +make: recursive.mk:40: Unclosed variable "MISSING_BRACE" make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 diff --git a/unit-tests/var-eval-short.exp b/unit-tests/var-eval-short.exp index 2b2e95750a1c..5f914e9e6c26 100644 --- a/unit-tests/var-eval-short.exp +++ b/unit-tests/var-eval-short.exp @@ -1,4 +1,4 @@ -make: "var-eval-short.mk" line 45: In the :@ modifier, the variable name "${FAIL}" must not contain a dollar +make: var-eval-short.mk:45: In the :@ modifier, the variable name "${FAIL}" must not contain a dollar while parsing "${:Uword:@${FAIL}@expr@}" Parsing var-eval-short.mk:158: .if 0 && ${0:?${FAIL}then:${FAIL}else} CondParser_Eval: 0 && ${0:?${FAIL}then:${FAIL}else} diff --git a/unit-tests/var-op-assign.exp b/unit-tests/var-op-assign.exp index de88eac21d0c..4e287e518eb7 100644 --- a/unit-tests/var-op-assign.exp +++ b/unit-tests/var-op-assign.exp @@ -1,6 +1,6 @@ this will be evaluated later -make: "var-op-assign.mk" line 60: Invalid line 'VARIABLE NAME= variable value' -make: "var-op-assign.mk" line 95: Parsing still continues until here. +make: var-op-assign.mk:60: Invalid line 'VARIABLE NAME= variable value' +make: var-op-assign.mk:95: Parsing still continues until here. make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests exit status 1 diff --git a/unit-tests/var-op-expand.exp b/unit-tests/var-op-expand.exp index 655a46023a11..88d2333a3f6f 100644 --- a/unit-tests/var-op-expand.exp +++ b/unit-tests/var-op-expand.exp @@ -1,11 +1,11 @@ -make: "var-op-expand.mk" line 274: Unknown modifier "s,value,replaced," +make: var-op-expand.mk:274: Unknown modifier ":s,value,replaced," while evaluating variable "later" with value "" while evaluating variable "indirect" with value "${later:s,value,replaced,} ok ${later:value=sysv}" -make: "var-op-expand.mk" line 278: warning: XXX Neither branch should be taken. -make: "var-op-expand.mk" line 283: Unknown modifier "s,value,replaced," +make: var-op-expand.mk:278: warning: XXX Neither branch should be taken. +make: var-op-expand.mk:283: Unknown modifier ":s,value,replaced," while evaluating variable "later" with value "lowercase-value" while evaluating variable "indirect" with value "${later:s,value,replaced,} ok ${later:value=sysv}" -make: "var-op-expand.mk" line 285: warning: XXX Neither branch should be taken. +make: var-op-expand.mk:285: warning: XXX Neither branch should be taken. make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests exit status 1 diff --git a/unit-tests/var-op-expand.mk b/unit-tests/var-op-expand.mk index a8e64bf45424..863ed19d4348 100644 --- a/unit-tests/var-op-expand.mk +++ b/unit-tests/var-op-expand.mk @@ -1,4 +1,4 @@ -# $NetBSD: var-op-expand.mk,v 1.22 2024/08/29 20:20:36 rillig Exp $ +# $NetBSD: var-op-expand.mk,v 1.23 2025/03/29 19:08:52 rillig Exp $ # # Tests for the := variable assignment operator, which expands its # right-hand side. @@ -270,7 +270,7 @@ later= lowercase-value .undef later INDIRECT:= ${LATER:S,value,replaced,} OK ${LATER:value=sysv} indirect:= ${INDIRECT:tl} -# expect+1: Unknown modifier "s,value,replaced," +# expect+1: Unknown modifier ":s,value,replaced," .if ${indirect} != " ok " . error .else @@ -279,7 +279,7 @@ indirect:= ${INDIRECT:tl} .endif LATER= uppercase-value later= lowercase-value -# expect+1: Unknown modifier "s,value,replaced," +# expect+1: Unknown modifier ":s,value,replaced," .if ${indirect} != "uppercase-replaced ok uppercase-sysv" # expect+1: warning: XXX Neither branch should be taken. . warning XXX Neither branch should be taken. diff --git a/unit-tests/var-op-shell.exp b/unit-tests/var-op-shell.exp index 9117001d40a7..0a44ac3fb938 100644 --- a/unit-tests/var-op-shell.exp +++ b/unit-tests/var-op-shell.exp @@ -1,8 +1,8 @@ -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 +make: var-op-shell.mk:32: warning: Command "echo "failed"; (exit 13)" exited with status 13 +make: var-op-shell.mk:39: warning: Command "exit 13" exited with status 13 +make: var-op-shell.mk:62: warning: "kill $$" exited on a signal /bin/no/such/command: not found -make: "var-op-shell.mk" line 69: warning: Command "/bin/no/such/command" exited with status 127 +make: var-op-shell.mk:69: warning: Command "/bin/no/such/command" exited with status 127 stderr Capturing the output of command "echo '$$$$'" Global: OUTPUT = $$$$ diff --git a/unit-tests/var-recursive.exp b/unit-tests/var-recursive.exp index 59812e0e71ff..75701e4c8c4f 100644 --- a/unit-tests/var-recursive.exp +++ b/unit-tests/var-recursive.exp @@ -1,27 +1,28 @@ -make: "var-recursive.mk" line 11: Variable DIRECT is recursive. +make: var-recursive.mk:11: Variable DIRECT is recursive. while evaluating variable "DIRECT" with value "${DIRECT}" in directory <curdir> -make: "var-recursive.mk" line 11: <> -make: "var-recursive.mk" line 19: Variable INDIRECT1 is recursive. +make: var-recursive.mk:11: <> +make: var-recursive.mk:19: Variable INDIRECT1 is recursive. while evaluating variable "INDIRECT2" with value "${INDIRECT1}" while evaluating variable "INDIRECT1" with value "${INDIRECT2}" in directory <curdir> -make: "var-recursive.mk" line 19: <> -make: "var-recursive.mk" line 26: <ok> -make: "var-recursive.mk" line 34: Variable MODIFIERS is recursive. +make: var-recursive.mk:19: <> +make: var-recursive.mk:26: <ok> +make: var-recursive.mk:34: Variable MODIFIERS is recursive. while evaluating variable "MODIFIERS" with value "${MODIFIERS:Mpattern}" in directory <curdir> -make: "var-recursive.mk" line 34: <Mpattern}> -make: "var-recursive.mk" line 43: Variable V is recursive. +make: var-recursive.mk:34: <Mpattern}> +make: var-recursive.mk:43: Variable V is recursive. while evaluating variable "V" with value "$V" in directory <curdir> -make: "var-recursive.mk" line 43: <> +make: var-recursive.mk:43: <> make: Fatal errors encountered -- cannot continue make: stopped making "loadtime" in unit-tests sub-exit status 1 : before-recursive make: Variable VAR is recursive. while evaluating variable "VAR" with value "${VAR}" + in command ": recursive-line-before <${VAR}> recursive-line-after" in target "runtime" sub-exit status 2 exit status 0 diff --git a/unit-tests/var-recursive.mk b/unit-tests/var-recursive.mk index e2951c900b11..b1c183e6f1b1 100644 --- a/unit-tests/var-recursive.mk +++ b/unit-tests/var-recursive.mk @@ -1,4 +1,4 @@ -# $NetBSD: var-recursive.mk,v 1.10 2024/08/29 20:20:36 rillig Exp $ +# $NetBSD: var-recursive.mk,v 1.12 2025/04/13 09:29:33 rillig Exp $ # # Tests for expressions that refer to themselves and thus cannot be # evaluated, as that would lead to an endless loop. @@ -49,10 +49,10 @@ runtime: # expect: : before-recursive : before-recursive # expect: make: Variable VAR is recursive. -# expect-not: recursive-line-before -# expect-not: recursive-line-after +# expect-not-matches: ^: recursive%-line%-before +# expect-not-matches: ^: recursive%-line%-after : recursive-line-before <${VAR}> recursive-line-after -# expect-not: after-recursive +# expect-not-matches: ^: after%-recursive : after-recursive .else diff --git a/unit-tests/var-scope-cmdline.exp b/unit-tests/var-scope-cmdline.exp index c663a9069a9f..41291d79a2fb 100644 --- a/unit-tests/var-scope-cmdline.exp +++ b/unit-tests/var-scope-cmdline.exp @@ -1,4 +1,4 @@ -make: "var-scope-cmdline.mk" line 72: global -make: "var-scope-cmdline.mk" line 82: makeflags +make: var-scope-cmdline.mk:72: global +make: var-scope-cmdline.mk:82: makeflags makeflags exit status 0 diff --git a/unit-tests/vardebug.exp b/unit-tests/vardebug.exp index 5e220f24df74..1a274de09f4d 100644 --- a/unit-tests/vardebug.exp +++ b/unit-tests/vardebug.exp @@ -54,11 +54,10 @@ Var_Parse: ${:Uvariable:unknown} (eval-defined-loud) Evaluating modifier ${:U...} on value "" (eval, undefined) Result of ${:Uvariable} is "variable" (eval, defined) Evaluating modifier ${:u...} on value "variable" (eval, defined) -make: "vardebug.mk" line 62: Unknown modifier "unknown" +make: vardebug.mk:59: Unknown modifier ":unknown" while evaluating "${:Uvariable:unknown}" with value "variable" -Result of ${:unknown} is error (eval, defined) Var_Parse: ${UNDEFINED} (eval-defined-loud) -make: "vardebug.mk" line 66: Variable "UNDEFINED" is undefined +make: vardebug.mk:63: Variable "UNDEFINED" is undefined Global: ignoring delete '.SHELL' as it is not found Command: .SHELL = </path/to/shell> Command: ignoring '.SHELL = overwritten' as it is read-only diff --git a/unit-tests/vardebug.mk b/unit-tests/vardebug.mk index 975f32b62286..3e242c378be5 100644 --- a/unit-tests/vardebug.mk +++ b/unit-tests/vardebug.mk @@ -1,4 +1,4 @@ -# $NetBSD: vardebug.mk,v 1.16 2025/01/11 21:21:33 rillig Exp $ +# $NetBSD: vardebug.mk,v 1.18 2025/03/29 19:08:52 rillig Exp $ # # Demonstrates the debugging output for var.c. @@ -55,10 +55,7 @@ VAR+= 3 # expect: Global: delete VAR .undef ${:UVAR} # Var_Delete -# When ApplyModifiers results in an error, this appears in the debug log -# as "is error", without surrounding quotes. -# expect: Result of ${:unknown} is error (eval, defined) -# expect+1: Unknown modifier "unknown" +# expect+1: Unknown modifier ":unknown" .if ${:Uvariable:unknown} .endif diff --git a/unit-tests/varmisc.exp b/unit-tests/varmisc.exp index 79d2c19e4d1b..509dbcc5e689 100644 --- a/unit-tests/varmisc.exp +++ b/unit-tests/varmisc.exp @@ -45,27 +45,36 @@ parse-dynamic: parse-dynamic parse-dynamic after parse-dynamic: parse-dynamic parse-dynamic after varerror-unclosed-1:begin make: Unclosed variable "" + in command "@echo $(" in target "varerror-unclosed-2" make: Unclosed variable "UNCLOSED" + in command "@echo $(UNCLOSED" in target "varerror-unclosed-3" make: Unclosed variable "UNCLOSED" + in command "@echo ${UNCLOSED" in target "varerror-unclosed-4" make: Unclosed variable "PATTERN" while evaluating variable "UNCLOSED" with value "" + in command "@echo ${UNCLOSED:M${PATTERN" in target "varerror-unclosed-5" make: Unclosed expression, expecting '}' for modifier "M${PATTERN" while evaluating variable "UNCLOSED" with value "" + in command "@echo ${UNCLOSED:M${PATTERN" in target "varerror-unclosed-5" make: Unclosed variable "param" + in command "@echo ${UNCLOSED.${param" in target "varerror-unclosed-6" make: Unclosed variable "UNCLOSED." + in command "@echo ${UNCLOSED.${param" in target "varerror-unclosed-6" make: Unclosed variable "UNCLOSED.1" + in command "@echo ${UNCLOSED.${:U1}" in target "varerror-unclosed-7" make: Unclosed variable "UNCLOSED_ORIG" while evaluating variable "UNCLOSED_INDIR_1" with value "${UNCLOSED_ORIG" while evaluating variable "UNCLOSED_INDIR_2" with value "${UNCLOSED_INDIR_1}" + in command "@echo ${UNCLOSED_INDIR_2}" in target "varerror-unclosed-8" target1-flags: we have: one two target2-flags: we have: one two three four diff --git a/unit-tests/varmod-assign-shell.exp b/unit-tests/varmod-assign-shell.exp index 712636491fc1..6e9fdc4dbb1d 100644 --- a/unit-tests/varmod-assign-shell.exp +++ b/unit-tests/varmod-assign-shell.exp @@ -1,10 +1,10 @@ -make: "varmod-assign-shell.mk" line 21: warning: Command "echo output; (exit 13)" exited with status 13 +make: varmod-assign-shell.mk: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: "varmod-assign-shell.mk" line 26: warning: Command "echo output; (exit 13)" exited with status 13 +make: varmod-assign-shell.mk:26: warning: 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 diff --git a/unit-tests/varmod-assign.exp b/unit-tests/varmod-assign.exp index 4a7dc509642a..a4b689ab9fd4 100644 --- a/unit-tests/varmod-assign.exp +++ b/unit-tests/varmod-assign.exp @@ -37,19 +37,27 @@ Global: .MAKEOVERRIDES = FIRST LAST LAST LAST APPENDED RAN RAN RAN IT1 THEN1 IE Result of ${CMD_NEW_VAR::=new-value} is "" (eval, undefined) Global: .MAKEFLAGS = -r -k -d v -d 0 -d v -d Global: .MAKEFLAGS = -r -k -d v -d 0 -d v -d 0 -make: Bad modifier ":" +make: Invalid attempt to assign "value" to variable "" via modifier "::=" while evaluating "${::=value}" with value "" + in command "@echo $@: ${::=value}" in target "mod-assign-empty-1" -make: Bad modifier ":" +make: Invalid attempt to assign "overwritten" to variable "" via modifier "::=" while evaluating "${:Uvalue::=overwritten}" with value "value" + in command "@echo $@: ${:Uvalue::=overwritten}" in target "mod-assign-empty-2" -mod-assign-empty-3: VAR=overwritten -make: Unknown modifier ":x" +make: Invalid attempt to assign "appended" to variable "" via modifier "::+=" + while evaluating "${:Uvalue::+=appended}" with value "value" + in command "@echo $@: ${:Uvalue::+=appended}" + in target "mod-assign-empty-3" +mod-assign-empty-4: VAR=overwritten +make: Unknown modifier "::x" while evaluating variable "ASSIGN" with value "" + in command "@echo ${ASSIGN::x}" in target "mod-assign-parse-1" sysv:y -make: Unfinished modifier ('}' missing) +make: Unfinished modifier after "value # missing closing brace", expecting "}" while evaluating variable "ASSIGN" with value "" + in command "@echo ${ASSIGN::=value # missing closing brace" in target "mod-assign-parse-3" ok=word make: warning: Command " echo word; (exit 13) " exited with status 13 diff --git a/unit-tests/varmod-assign.mk b/unit-tests/varmod-assign.mk index 237198faf254..af2c90385315 100644 --- a/unit-tests/varmod-assign.mk +++ b/unit-tests/varmod-assign.mk @@ -1,11 +1,11 @@ -# $NetBSD: varmod-assign.mk,v 1.25 2024/08/29 20:20:36 rillig Exp $ +# $NetBSD: varmod-assign.mk,v 1.28 2025/03/30 01:09:41 rillig Exp $ # # Tests for the obscure ::= variable modifiers, which perform variable # assignments during evaluation, just like the = operator in C. .if !make(target) -all: mod-assign-empty-{1,2,3} +all: mod-assign-empty-{1,2,3,4} all: mod-assign-parse-{1,2,3} all: mod-assign-shell-error @@ -74,26 +74,32 @@ SINK4:= ${0:?${THEN4::=then4${IT4::=t4}}:${ELSE4::=else4${IE4::=e4}}} ${THEN4}${ mod-assign-empty-1: # Assigning to the empty variable would obviously not work since that # variable is write-protected. -# expect: make: Bad modifier ":" +# expect: make: Invalid attempt to assign "value" to variable "" via modifier "::=" @echo $@: ${::=value} mod-assign-empty-2: # In this variant, it is not as obvious that the name of the # expression is empty. -# expect: make: Bad modifier ":" +# expect: make: Invalid attempt to assign "overwritten" to variable "" via modifier "::=" @echo $@: ${:Uvalue::=overwritten} mod-assign-empty-3: + # In this variant, it is not as obvious that the name of the + # expression is empty. +# expect: make: Invalid attempt to assign "appended" to variable "" via modifier "::+=" + @echo $@: ${:Uvalue::+=appended} + +mod-assign-empty-4: # The :L modifier sets the value of the expression to its variable # name. The name of the expression is "VAR", therefore assigning to # that variable works. -# expect: mod-assign-empty-3: VAR=overwritten +# expect: mod-assign-empty-4: VAR=overwritten @echo $@: ${VAR:L::=overwritten} VAR=${VAR} mod-assign-parse-1: # The modifier for assignment operators starts with a ':'. # An 'x' after that is an invalid modifier. -# expect: make: Unknown modifier ":x" +# expect: make: Unknown modifier "::x" @echo ${ASSIGN::x} mod-assign-parse-2: @@ -102,7 +108,7 @@ mod-assign-parse-2: @echo ${SYSV::=sysv\:x}${SYSV::x=:y} mod-assign-parse-3: -# expect: make: Unfinished modifier ('}' missing) +# expect: make: Unfinished modifier after "value # missing closing brace", expecting "}" @echo ${ASSIGN::=value # missing closing brace mod-assign-shell-error: diff --git a/unit-tests/varmod-edge.exp b/unit-tests/varmod-edge.exp index 2b3b038373b3..2b41623bb66c 100644 --- a/unit-tests/varmod-edge.exp +++ b/unit-tests/varmod-edge.exp @@ -1,22 +1,19 @@ -make: "varmod-edge.mk" line 60: Unclosed expression, expecting '}' for modifier "U*)" +make: varmod-edge.mk:60: Unclosed expression, expecting '}' for modifier "U*)" while evaluating "${:U*)" with value "*)" while evaluating variable "INP" with value "(parentheses)" while evaluating variable "MOD" with value "${INP:M${:U*)}}" -make: "varmod-edge.mk" line 88: Unfinished character list in pattern '[[' of modifier ':M' +make: varmod-edge.mk:88: Unfinished character list in pattern '[[' of modifier ':M' while evaluating variable "INP" with value "[ [[ [[[" while evaluating variable "MOD" with value "${INP:M${:U[[}}" -make: "varmod-edge.mk" line 178: Unfinished modifier ('=' missing) +make: varmod-edge.mk:178: Unfinished modifier after "a\=b}", expecting "=" while evaluating variable "INP" with value "file.c file..." while evaluating variable "MOD" with value "${INP:a\=b}" -make: "varmod-edge.mk" line 194: Unknown modifier ":" +make: varmod-edge.mk:193: Unknown modifier "::" while evaluating variable "INP" with value "value" while evaluating variable "MOD" with value "${INP::::}" -make: "varmod-edge.mk" line 194: Unknown modifier ":" - while evaluating variable "INP" with value "" - while evaluating variable "MOD" with value "${INP::::}" -make: "varmod-edge.mk" line 200: Unknown modifier "Z" +make: varmod-edge.mk:199: Unknown modifier ":Z" while evaluating "${:Z}" with value "" -make: "varmod-edge.mk" line 213: Unfinished modifier (',' missing) +make: varmod-edge.mk:212: Unfinished modifier after "}", expecting "," while evaluating "${:S,}" with value "" make: Fatal errors encountered -- cannot continue make: stopped in unit-tests diff --git a/unit-tests/varmod-edge.mk b/unit-tests/varmod-edge.mk index ee21b44e00f2..473c7ad171e5 100644 --- a/unit-tests/varmod-edge.mk +++ b/unit-tests/varmod-edge.mk @@ -1,4 +1,4 @@ -# $NetBSD: varmod-edge.mk,v 1.33 2025/01/11 20:54:45 rillig Exp $ +# $NetBSD: varmod-edge.mk,v 1.36 2025/03/29 19:08:52 rillig Exp $ # # Tests for edge cases in variable modifiers. # @@ -174,7 +174,7 @@ EXP= file.c file.ext INP= file.c file... MOD= ${INP:a\=b} EXP= # empty -# expect+1: Unfinished modifier ('=' missing) +# expect+1: Unfinished modifier after "a\=b}", expecting "=" .if ${MOD} != ${EXP} . warning expected "${EXP}", got "${MOD}" .endif @@ -188,15 +188,14 @@ EXP= value INP= value MOD= ${INP::::} -EXP= # empty -# expect+2: Unknown modifier ":" -# expect+1: Unknown modifier ":" +EXP= :} +# expect+1: Unknown modifier "::" .if ${MOD} != ${EXP} . warning expected "${EXP}", got "${MOD}" .endif # Even in expressions based on an unnamed variable, there may be errors. -# expect+1: Unknown modifier "Z" +# expect+1: Unknown modifier ":Z" .if ${:Z} . error .else @@ -209,7 +208,7 @@ EXP= # empty # variable name with quotes, leading to the rather confusing "Unfinished # modifier for (',' missing)", having two spaces in a row. # -# expect+1: Unfinished modifier (',' missing) +# expect+1: Unfinished modifier after "}", expecting "," .if ${:S,} . error .else diff --git a/unit-tests/varmod-gmtime.exp b/unit-tests/varmod-gmtime.exp index d34cb5c6a93f..466895d48e6b 100644 --- a/unit-tests/varmod-gmtime.exp +++ b/unit-tests/varmod-gmtime.exp @@ -1,12 +1,12 @@ -make: "varmod-gmtime.mk" line 60: Invalid time value "-1" +make: varmod-gmtime.mk:60: Invalid time value "-1" while evaluating "${:L:gmtime=-1} != """ with value "" -make: "varmod-gmtime.mk" line 70: Invalid time value " 1" +make: varmod-gmtime.mk:70: Invalid time value " 1" while evaluating "${:L:gmtime= 1} != """ with value "" -make: "varmod-gmtime.mk" line 117: Invalid time value "10000000000000000000000000000000" +make: varmod-gmtime.mk:117: Invalid time value "10000000000000000000000000000000" while evaluating "${:L:gmtime=10000000000000000000000000000000} != """ with value "" -make: "varmod-gmtime.mk" line 129: Invalid time value "error" +make: varmod-gmtime.mk:129: Invalid time value "error" while evaluating "${:L:gmtime=error} != """ with value "" -make: "varmod-gmtime.mk" line 139: Invalid time value "100000S,1970,bad," +make: varmod-gmtime.mk:139: Invalid time value "100000S,1970,bad," while evaluating variable "%Y" with value "%Y" make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests diff --git a/unit-tests/varmod-hash.exp b/unit-tests/varmod-hash.exp index 030923cf09d6..1abc6bc92a9f 100644 --- a/unit-tests/varmod-hash.exp +++ b/unit-tests/varmod-hash.exp @@ -1,12 +1,15 @@ -make: Unknown modifier "has" +make: Unknown modifier ":has" while evaluating variable "12345" with value "12345" + in command "@echo ${12345:L:has} # modifier name too short" in target "step-1" 26bb0f5f 12345 -make: Unknown modifier "hasX" +make: Unknown modifier ":hasX" while evaluating variable "12345" with value "12345" + in command "@echo ${12345:L:hasX} # misspelled" in target "step-4" -make: Unknown modifier "hashed" +make: Unknown modifier ":hashed" while evaluating variable "12345" with value "12345" + in command "@echo ${12345:L:hashed} # modifier name too long" in target "step-5" exit status 2 diff --git a/unit-tests/varmod-ifelse.exp b/unit-tests/varmod-ifelse.exp index 02f434f1d411..d92134a83c84 100644 --- a/unit-tests/varmod-ifelse.exp +++ b/unit-tests/varmod-ifelse.exp @@ -1,37 +1,37 @@ -make: "varmod-ifelse.mk" line 28: Bad condition +make: varmod-ifelse.mk:28: Bad condition while evaluating condition "bare words == "literal"" -make: "varmod-ifelse.mk" line 39: Bad condition +make: varmod-ifelse.mk:39: Bad condition while evaluating condition " == """ -make: "varmod-ifelse.mk" line 47: Bad condition +make: varmod-ifelse.mk:47: Bad condition while evaluating condition " == """ -make: "varmod-ifelse.mk" line 70: Bad condition +make: varmod-ifelse.mk:70: Bad condition while evaluating condition "1 == == 2" CondParser_Eval: "${1 == == 2:?yes:no}" != "" CondParser_Eval: 1 == == 2 Comparing 1.000000 == 0.000000 -make: "varmod-ifelse.mk" line 94: Bad condition +make: varmod-ifelse.mk:94: Bad condition while evaluating condition "1 == == 2" Comparing "" != "" -make: "varmod-ifelse.mk" line 98: warning: Oops, the parse error should have been propagated. +make: varmod-ifelse.mk:98: warning: Oops, the parse error should have been propagated. CondParser_Eval: ${ ${:U\$}{VAR} == value:?ok:bad} != "ok" CondParser_Eval: ${VAR} == value Comparing "value" == "value" Comparing "ok" != "ok" -make: "varmod-ifelse.mk" line 160: no. -make: "varmod-ifelse.mk" line 163: Comparison with '>=' requires both operands 'no' and '10' to be numeric +make: varmod-ifelse.mk:160: no. +make: varmod-ifelse.mk:163: Comparison with '>=' requires both operands 'no' and '10' to be numeric while evaluating condition "string == "literal" || no >= 10" -make: "varmod-ifelse.mk" line 163: . -make: "varmod-ifelse.mk" line 170: Bad condition +make: varmod-ifelse.mk:163: . +make: varmod-ifelse.mk:170: Bad condition while evaluating condition "string == "literal" && >= 10" -make: "varmod-ifelse.mk" line 170: . -make: "varmod-ifelse.mk" line 173: Bad condition +make: varmod-ifelse.mk:170: . +make: varmod-ifelse.mk:173: Bad condition while evaluating condition "string == "literal" || >= 10" -make: "varmod-ifelse.mk" line 173: . -make: "varmod-ifelse.mk" line 181: <true> -make: "varmod-ifelse.mk" line 184: <false> -make: "varmod-ifelse.mk" line 188: Bad condition +make: varmod-ifelse.mk:173: . +make: varmod-ifelse.mk:181: <true> +make: varmod-ifelse.mk:184: <false> +make: varmod-ifelse.mk:188: Bad condition while evaluating condition " " -make: "varmod-ifelse.mk" line 188: <> +make: varmod-ifelse.mk:188: <> CondParser_Eval: 0 && ${1:?${:Uthen0:S,}},,}:${:Uelse0:S,}},,}} != "not evaluated" CondParser_Eval: 1 && ${0:?${:Uthen1:S,}},,}:${:Uelse1:S,}},,}} != "else1" CondParser_Eval: 0 @@ -41,20 +41,20 @@ CondParser_Eval: 1 Comparing "then2" != "then2" CondParser_Eval: ${DELAYED} == "one" Comparing "two" == "one" -make: "varmod-ifelse.mk" line 284: no +make: varmod-ifelse.mk:284: no CondParser_Eval: ${DELAYED} == "two" Comparing "two" == "two" -make: "varmod-ifelse.mk" line 286: yes +make: varmod-ifelse.mk:286: yes CondParser_Eval: ${DELAYED} == "one" Comparing "two" == "one" -make: "varmod-ifelse.mk" line 289: no +make: varmod-ifelse.mk:289: no CondParser_Eval: ${DELAYED} == "two" Comparing "two" == "two" -make: "varmod-ifelse.mk" line 292: yes -make: "varmod-ifelse.mk" line 314: Unknown modifier "X-then" +make: varmod-ifelse.mk:292: yes +make: varmod-ifelse.mk:314: Unknown modifier ":X-then" while evaluating "${:X-then}:${:X-else}}" with value "" while evaluating then-branch of condition "1" -make: "varmod-ifelse.mk" line 314: Unknown modifier "X-else" +make: varmod-ifelse.mk:314: Unknown modifier ":X-else" while parsing "${:X-else}}" while evaluating else-branch of condition "1" make: Fatal errors encountered -- cannot continue diff --git a/unit-tests/varmod-ifelse.mk b/unit-tests/varmod-ifelse.mk index b2f5419e65ad..c316da51c3a9 100644 --- a/unit-tests/varmod-ifelse.mk +++ b/unit-tests/varmod-ifelse.mk @@ -1,4 +1,4 @@ -# $NetBSD: varmod-ifelse.mk,v 1.35 2025/01/11 20:54:45 rillig Exp $ +# $NetBSD: varmod-ifelse.mk,v 1.37 2025/04/04 18:57:01 rillig Exp $ # # Tests for the ${cond:?then:else} variable modifier, which evaluates either # the then-expression or the else-expression, depending on the condition. @@ -38,11 +38,11 @@ # expect+1: Bad condition COND:= ${${UNDEF} == "":?bad-assign:bad-assign} -# In a condition, undefined variables generate a "Malformed conditional" -# error. That error message is wrong though. In lint mode, the correct -# "Undefined variable" error message is generated. -# The difference to the ':=' variable assignment is the additional -# "Malformed conditional" error message. +# In a conditional directive, undefined variables are reported as such. In a +# ':?' modifier, though, the "variable name" is expanded first, and in that +# context, an undefined expression is not an error. The "variable name" then +# becomes the condition, in this case ' == ""', which is malformed because the +# left-hand side looks empty. # expect+1: Bad condition .if ${${UNDEF} == "":?bad-cond:bad-cond} . error @@ -309,7 +309,7 @@ BOTH= <${YES}> <${NO}> .endif -# expect+2: Unknown modifier "X-then" -# expect+1: Unknown modifier "X-else" +# expect+2: Unknown modifier ":X-then" +# expect+1: Unknown modifier ":X-else" .if ${1:?${:X-then}:${:X-else}} .endif diff --git a/unit-tests/varmod-indirect.exp b/unit-tests/varmod-indirect.exp index b572e34fcf8d..33a800c1ef64 100644 --- a/unit-tests/varmod-indirect.exp +++ b/unit-tests/varmod-indirect.exp @@ -1,23 +1,21 @@ -make: "varmod-indirect.mk" line 19: Unknown modifier "${" +make: varmod-indirect.mk:19: Unknown modifier ":${" while evaluating variable "value" with value "value" -make: "varmod-indirect.mk" line 52: Unknown modifier "${" +make: varmod-indirect.mk:52: Unknown modifier ":${" while evaluating variable "value" with value "value" -make: "varmod-indirect.mk" line 54: warning: FIXME: this expression should have resulted in a parse error rather than returning the unparsed portion of the expression. -make: "varmod-indirect.mk" line 143: before -make: "varmod-indirect.mk" line 143: after -make: "varmod-indirect.mk" line 151: before -make: "varmod-indirect.mk" line 151: after -make: "varmod-indirect.mk" line 159: before -make: "varmod-indirect.mk" line 159: after -make: "varmod-indirect.mk" line 164: Unknown modifier "Z" +make: varmod-indirect.mk:140: before +make: varmod-indirect.mk:140: after +make: varmod-indirect.mk:148: before +make: varmod-indirect.mk:148: after +make: varmod-indirect.mk:156: before +make: varmod-indirect.mk:156: after +make: varmod-indirect.mk:161: Unknown modifier ":Z" + while evaluating indirect modifiers "Z" while evaluating variable "UNDEF" with value "" -make: "varmod-indirect.mk" line 167: before -make: "varmod-indirect.mk" line 167: after -Parsing varmod-indirect.mk:176: _:= before ${UNDEF} after +Parsing varmod-indirect.mk:171: _:= before ${UNDEF} after Global: _ = # (empty) Var_Parse: ${UNDEF} after (eval-keep-dollar-and-undefined) Global: _ = before ${UNDEF} after -Parsing varmod-indirect.mk:179: _:= before ${UNDEF:${:US,a,a,}} after +Parsing varmod-indirect.mk:174: _:= before ${UNDEF:${:US,a,a,}} after Var_Parse: ${UNDEF:${:US,a,a,}} after (eval-keep-dollar-and-undefined) Indirect modifier "S,a,a," from "${:US,a,a,}" Evaluating modifier ${UNDEF:S...} on value "" (eval-keep-dollar-and-undefined, undefined) @@ -26,19 +24,19 @@ Modifier part: "a" ModifyWords: split "" into 1 word Result of ${UNDEF:S,a,a,} is "" (eval-keep-dollar-and-undefined, undefined) Global: _ = before ${UNDEF:S,a,a,} after -Parsing varmod-indirect.mk:189: _:= before ${UNDEF:${:U}} after +Parsing varmod-indirect.mk:184: _:= before ${UNDEF:${:U}} after Var_Parse: ${UNDEF:${:U}} after (eval-keep-dollar-and-undefined) Indirect modifier "" from "${:U}" Global: _ = before ${UNDEF:} after -Parsing varmod-indirect.mk:195: _:= before ${UNDEF:${:UZ}} after +Parsing varmod-indirect.mk:190: _:= before ${UNDEF:${:UZ}} after Var_Parse: ${UNDEF:${:UZ}} after (eval-keep-dollar-and-undefined) Indirect modifier "Z" from "${:UZ}" Evaluating modifier ${UNDEF:Z} on value "" (eval-keep-dollar-and-undefined, undefined) -make: "varmod-indirect.mk" line 195: Unknown modifier "Z" +make: varmod-indirect.mk:190: Unknown modifier ":Z" + while evaluating indirect modifiers "Z" while evaluating variable "UNDEF" with value "" -Result of ${UNDEF:Z} is error (eval-keep-dollar-and-undefined, undefined) Global: _ = before ${UNDEF:Z} after -Parsing varmod-indirect.mk:197: .MAKEFLAGS: -d0 +Parsing varmod-indirect.mk:192: .MAKEFLAGS: -d0 ParseDependency(.MAKEFLAGS: -d0) Global: .MAKEFLAGS = -r -k -d 0 -d pv -d Global: .MAKEFLAGS = -r -k -d 0 -d pv -d 0 diff --git a/unit-tests/varmod-indirect.mk b/unit-tests/varmod-indirect.mk index f54c0e232d2a..88d7db300704 100644 --- a/unit-tests/varmod-indirect.mk +++ b/unit-tests/varmod-indirect.mk @@ -1,4 +1,4 @@ -# $NetBSD: varmod-indirect.mk,v 1.21 2024/08/29 20:20:36 rillig Exp $ +# $NetBSD: varmod-indirect.mk,v 1.24 2025/03/30 16:43:10 rillig Exp $ # # Tests for indirect variable modifiers, such as in ${VAR:${M_modifiers}}. # These can be used for very basic purposes like converting a string to either @@ -15,7 +15,7 @@ # The following expression generates a parse error since its indirect # modifier contains more than a sole expression. # -# expect+1: Unknown modifier "${" +# expect+1: Unknown modifier ":${" .if ${value:L:${:US}${:U,value,replacement,}} != "S,value,replacement,}" . warning unexpected .endif @@ -44,16 +44,13 @@ # If an expression for an indirect modifier evaluates to anything else than an # empty string and is neither followed by a ':' nor '}', this produces a parse -# error. Because of this parse error, this feature cannot be used reasonably +# error. Due to this parse error, this construct cannot be used reasonably # in practice. # -# expect+2: Unknown modifier "${" +# expect+2: Unknown modifier ":${" #.MAKEFLAGS: -dvc -.if ${value:L:${:UM*}S,value,replaced,} == "M*S,value,replaced,}" -# expect+1: warning: FIXME: this expression should have resulted in a parse error rather than returning the unparsed portion of the expression. -. warning FIXME: this expression should have resulted in a parse $\ - error rather than returning the unparsed portion of the $\ - expression. +.if ${value:L:${:UM*}S,value,replaced,} == "anything" +. error .else . error .endif @@ -160,11 +157,9 @@ M_NoPrimes= ${PRIMES:${M_ListToSkip}} .endfor # An error in an indirect modifier. -# expect+1: Unknown modifier "Z" +# expect+1: Unknown modifier ":Z" .for var in before ${UNDEF:${:UZ}} after -# expect+2: before -# expect+1: after -. info ${var} +. error .endfor @@ -191,7 +186,7 @@ _:= before ${UNDEF:${:U}} after # XXX: This expands to ${UNDEF:Z}, which will behave differently if the # variable '_' is used in a context where the expression ${_} is # parsed but not evaluated. -# expect+1: Unknown modifier "Z" +# expect+1: Unknown modifier ":Z" _:= before ${UNDEF:${:UZ}} after .MAKEFLAGS: -d0 diff --git a/unit-tests/varmod-localtime.exp b/unit-tests/varmod-localtime.exp index b22bfe479227..a92b1d0f29a3 100644 --- a/unit-tests/varmod-localtime.exp +++ b/unit-tests/varmod-localtime.exp @@ -1,12 +1,12 @@ -make: "varmod-localtime.mk" line 60: Invalid time value "-1" +make: varmod-localtime.mk:60: Invalid time value "-1" while evaluating "${:L:localtime=-1} != """ with value "" -make: "varmod-localtime.mk" line 70: Invalid time value " 1" +make: varmod-localtime.mk:70: Invalid time value " 1" while evaluating "${:L:localtime= 1} != """ with value "" -make: "varmod-localtime.mk" line 117: Invalid time value "10000000000000000000000000000000" +make: varmod-localtime.mk:117: Invalid time value "10000000000000000000000000000000" while evaluating "${:L:localtime=10000000000000000000000000000000} != """ with value "" -make: "varmod-localtime.mk" line 129: Invalid time value "error" +make: varmod-localtime.mk:129: Invalid time value "error" while evaluating "${:L:localtime=error} != """ with value "" -make: "varmod-localtime.mk" line 139: Invalid time value "100000S,1970,bad," +make: varmod-localtime.mk:139: Invalid time value "100000S,1970,bad," while evaluating variable "%Y" with value "%Y" make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests diff --git a/unit-tests/varmod-loop-delete.exp b/unit-tests/varmod-loop-delete.exp index 874dce4495c1..daacafc35561 100644 --- a/unit-tests/varmod-loop-delete.exp +++ b/unit-tests/varmod-loop-delete.exp @@ -1,4 +1,4 @@ -make: "varmod-loop-delete.mk" line 20: Cannot delete variable "VAR" while it is used +make: varmod-loop-delete.mk:20: Cannot delete variable "VAR" while it is used while evaluating "${:U:@VAR@@} rest of the value" with value "" while evaluating variable "VAR" with value "${:U:@VAR@@} rest of the value" make: Fatal errors encountered -- cannot continue diff --git a/unit-tests/varmod-loop-varname.exp b/unit-tests/varmod-loop-varname.exp index 442f9bb6d684..9320af6c65ab 100644 --- a/unit-tests/varmod-loop-varname.exp +++ b/unit-tests/varmod-loop-varname.exp @@ -1,10 +1,10 @@ -make: "varmod-loop-varname.mk" line 17: In the :@ modifier, the variable name "${:Ubar:S,b,v,}" must not contain a dollar +make: varmod-loop-varname.mk:17: In the :@ modifier, the variable name "${:Ubar:S,b,v,}" must not contain a dollar while evaluating "${:Uone two three:@${:Ubar:S,b,v,}@+${var}+@} != "+one+ +two+ +three+"" with value "one two three" -make: "varmod-loop-varname.mk" line 87: In the :@ modifier, the variable name "v$" must not contain a dollar +make: varmod-loop-varname.mk:87: In the :@ modifier, the variable name "v$" must not contain a dollar while evaluating variable "1 2 3" with value "1 2 3" -make: "varmod-loop-varname.mk" line 93: In the :@ modifier, the variable name "v$$" must not contain a dollar +make: varmod-loop-varname.mk:93: In the :@ modifier, the variable name "v$$" must not contain a dollar while evaluating variable "1 2 3" with value "1 2 3" -make: "varmod-loop-varname.mk" line 99: In the :@ modifier, the variable name "v$$$" must not contain a dollar +make: varmod-loop-varname.mk:99: In the :@ modifier, the variable name "v$$$" must not contain a dollar while evaluating variable "1 2 3" with value "1 2 3" make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests diff --git a/unit-tests/varmod-match-escape.exp b/unit-tests/varmod-match-escape.exp index a972b14816bd..25d78226345c 100755 --- a/unit-tests/varmod-match-escape.exp +++ b/unit-tests/varmod-match-escape.exp @@ -30,15 +30,15 @@ Pattern for ':M' is ":\:" ModifyWords: split ": :: :\:" into 3 words Result of ${VALUES:M${:U\:}\:} is "::" Comparing ":" != "::" -make: "varmod-match-escape.mk" line 43: warning: XXX: Oops +make: varmod-match-escape.mk:43: warning: XXX: Oops Global: .MAKEFLAGS = -r -k -d cv -d Global: .MAKEFLAGS = -r -k -d cv -d 0 -make: "varmod-match-escape.mk" line 69: Dollar followed by nothing +make: varmod-match-escape.mk:69: Dollar followed by nothing while evaluating "${:U\$:M\$} != """ with value "$" -make: "varmod-match-escape.mk" line 110: Unfinished character list in pattern '[A-]' of modifier ':M' +make: varmod-match-escape.mk:110: Unfinished character list in pattern '[A-]' of modifier ':M' while evaluating variable "WORDS" with value "A A] A]] B B] B]] ] ]] ]]] a a] a]]" in .for loop from varmod-match-escape.mk:107 with pattern = [A-] -make: "varmod-match-escape.mk" line 110: Unfinished character list in pattern '[^A-]' of modifier ':M' +make: varmod-match-escape.mk:110: Unfinished character list in pattern '[^A-]' of modifier ':M' while evaluating variable "WORDS" with value "A A] A]] B B] B]] ] ]] ]]] a a] a]]" in .for loop from varmod-match-escape.mk:107 with pattern = [^A-] make: Fatal errors encountered -- cannot continue diff --git a/unit-tests/varmod-match.exp b/unit-tests/varmod-match.exp index fdc76c3ae83a..14eb7862d815 100644 --- a/unit-tests/varmod-match.exp +++ b/unit-tests/varmod-match.exp @@ -1,22 +1,22 @@ -make: "varmod-match.mk" line 289: Unfinished character list in pattern 'a[' of modifier ':M' +make: varmod-match.mk:289: Unfinished character list in pattern 'a[' of modifier ':M' while evaluating variable "WORDS" with value "a a[" -make: "varmod-match.mk" line 297: Unfinished character list in pattern 'a[^' of modifier ':M' +make: varmod-match.mk:297: Unfinished character list in pattern 'a[^' of modifier ':M' while evaluating variable "WORDS" with value "a a[ aX" -make: "varmod-match.mk" line 305: Unfinished character list in pattern '[-x1-3' of modifier ':M' +make: varmod-match.mk:305: Unfinished character list in pattern '[-x1-3' of modifier ':M' while evaluating variable "WORDS" with value "- + x xx 0 1 2 3 4 [x1-3" -make: "varmod-match.mk" line 313: Unfinished character list in pattern '*[-x1-3' of modifier ':M' +make: varmod-match.mk:313: Unfinished character list in pattern '*[-x1-3' of modifier ':M' while evaluating variable "WORDS" with value "- + x xx 0 1 2 3 4 00 01 10 11 000 001 010 011 100 101 110 111 [x1-3" -make: "varmod-match.mk" line 322: Unfinished character list in pattern '[^-x1-3' of modifier ':M' +make: varmod-match.mk:322: Unfinished character list in pattern '[^-x1-3' of modifier ':M' while evaluating variable "WORDS" with value "- + x xx 0 1 2 3 4 [x1-3" -make: "varmod-match.mk" line 336: Unfinished character list in pattern '?[\' of modifier ':M' +make: varmod-match.mk:336: Unfinished character list in pattern '?[\' of modifier ':M' while evaluating variable "WORDS" with value "\\ \a x\" -make: "varmod-match.mk" line 344: Unfinished character range in pattern '[x-' of modifier ':M' +make: varmod-match.mk:344: Unfinished character range in pattern '[x-' of modifier ':M' while evaluating variable "WORDS" with value "[x- x x- y" -make: "varmod-match.mk" line 356: Unfinished character range in pattern '[^x-' of modifier ':M' +make: varmod-match.mk:356: Unfinished character range in pattern '[^x-' of modifier ':M' while evaluating variable "WORDS" with value "[x- x x- y yyyyy" -make: "varmod-match.mk" line 363: Unfinished character list in pattern '[' of modifier ':M' +make: varmod-match.mk:363: Unfinished character list in pattern '[' of modifier ':M' while evaluating variable " : :: " with value " : :: " -make: "varmod-match.mk" line 363: Unknown modifier "]" +make: varmod-match.mk:363: Unknown modifier ":]" while evaluating variable " : :: " with value "" make: Fatal errors encountered -- cannot continue make: stopped in unit-tests diff --git a/unit-tests/varmod-match.mk b/unit-tests/varmod-match.mk index 3e9ada78231e..99184989fb83 100644 --- a/unit-tests/varmod-match.mk +++ b/unit-tests/varmod-match.mk @@ -1,4 +1,4 @@ -# $NetBSD: varmod-match.mk,v 1.29 2025/01/11 20:54:46 rillig Exp $ +# $NetBSD: varmod-match.mk,v 1.30 2025/03/29 19:08:52 rillig Exp $ # # Tests for the ':M' modifier, which keeps only those words that match the # given pattern. @@ -359,7 +359,7 @@ WORDS= [x- x x- y yyyyy # [:] matches never since the ':' starts the next modifier # expect+2: Unfinished character list in pattern '[' of modifier ':M' -# expect+1: Unknown modifier "]" +# expect+1: Unknown modifier ":]" .if ${ ${:U\:} ${:U\:\:} :L:M[:]} != ":" . error .else diff --git a/unit-tests/varmod-mtime.exp b/unit-tests/varmod-mtime.exp index 160bfcdd6cf8..538294b2cc7f 100644 --- a/unit-tests/varmod-mtime.exp +++ b/unit-tests/varmod-mtime.exp @@ -1,14 +1,14 @@ -make: "varmod-mtime.mk" line 46: Invalid argument '123x' for modifier ':mtime' +make: varmod-mtime.mk:46: Invalid argument '123x' for modifier ':mtime' while evaluating variable "no/such/file" with value "no/such/file" -make: "varmod-mtime.mk" line 68: Cannot determine mtime for 'no/such/file1': <ENOENT> +make: varmod-mtime.mk:68: Cannot determine mtime for 'no/such/file1': <ENOENT> while evaluating variable "no/such/file1 no/such/file2" with value "no/such/file1 no/such/file2" -make: "varmod-mtime.mk" line 68: Cannot determine mtime for 'no/such/file2': <ENOENT> +make: varmod-mtime.mk:68: Cannot determine mtime for 'no/such/file2': <ENOENT> while evaluating variable "no/such/file1 no/such/file2" with value "no/such/file1 no/such/file2" -make: "varmod-mtime.mk" line 78: Invalid argument 'errorhandler-no' for modifier ':mtime' +make: varmod-mtime.mk:78: Invalid argument 'errorhandler-no' for modifier ':mtime' while evaluating variable "MAKEFILE" with value "varmod-mtime.mk" -make: "varmod-mtime.mk" line 86: Invalid argument 'warn' for modifier ':mtime' +make: varmod-mtime.mk:86: Invalid argument 'warn' for modifier ':mtime' while evaluating variable "MAKEFILE" with value "varmod-mtime.mk" -make: "varmod-mtime.mk" line 110: Unknown modifier "mtim" +make: varmod-mtime.mk:110: Unknown modifier ":mtim" while evaluating variable "anything" with value "anything" make: Fatal errors encountered -- cannot continue make: stopped in unit-tests diff --git a/unit-tests/varmod-mtime.mk b/unit-tests/varmod-mtime.mk index 0d0ddfc26b52..67bca7c9d557 100644 --- a/unit-tests/varmod-mtime.mk +++ b/unit-tests/varmod-mtime.mk @@ -1,4 +1,4 @@ -# $NetBSD: varmod-mtime.mk,v 1.14 2025/01/11 20:54:46 rillig Exp $ +# $NetBSD: varmod-mtime.mk,v 1.15 2025/03/29 19:08:52 rillig Exp $ # # Tests for the ':mtime' variable modifier, which maps each word of the # expression to that file's modification time. @@ -106,7 +106,7 @@ end:= ${%s:L:gmtime} # If there is a typo in the modifier name, it does not match. -# expect+1: Unknown modifier "mtim" +# expect+1: Unknown modifier ":mtim" .if ${anything:L:mtim} . error .else diff --git a/unit-tests/varmod-order.exp b/unit-tests/varmod-order.exp index 2b955c123412..f48256c6ae0e 100644 --- a/unit-tests/varmod-order.exp +++ b/unit-tests/varmod-order.exp @@ -1,29 +1,27 @@ -make: "varmod-order.mk" line 14: Bad modifier ":OX" +make: varmod-order.mk:14: Unknown modifier ":OX" while evaluating variable "WORDS" with value "one two three four five six seven eight nine ten" -make: "varmod-order.mk" line 17: Bad modifier ":OxXX" +make: varmod-order.mk:17: Unknown modifier ":OxXX" while evaluating variable "WORDS" with value "one two three four five six seven eight nine ten" -make: "varmod-order.mk" line 20: Unclosed expression, expecting '}' for modifier "O" +make: varmod-order.mk:20: Unclosed expression, expecting '}' for modifier "O" while evaluating variable "WORDS" with value "eight five four nine one seven six ten three two" -make: "varmod-order.mk" line 22: Unclosed expression, expecting '}' for modifier "On" +make: varmod-order.mk:22: Unclosed expression, expecting '}' for modifier "On" while evaluating variable "NUMBERS" with value "1 2 3 4 5 6 7 8 9 10" -make: "varmod-order.mk" line 24: Unclosed expression, expecting '}' for modifier "Onr" +make: varmod-order.mk:24: Unclosed expression, expecting '}' for modifier "Onr" while evaluating variable "NUMBERS" with value "10 9 8 7 6 5 4 3 2 1" -make: "varmod-order.mk" line 30: Bad modifier ":Oxn" +make: varmod-order.mk:30: Unknown modifier ":Oxn" while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2" -make: "varmod-order.mk" line 39: Bad modifier ":On_typo" +make: varmod-order.mk:39: Unknown modifier ":On_typo" while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2" -make: "varmod-order.mk" line 48: Bad modifier ":Onr_typo" +make: varmod-order.mk:48: Unknown modifier ":Onr_typo" while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2" -make: "varmod-order.mk" line 57: Bad modifier ":Orn_typo" +make: varmod-order.mk:57: Unknown modifier ":Orn_typo" while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2" -make: "varmod-order.mk" line 68: Bad modifier ":Onn" +make: varmod-order.mk:68: Unknown modifier ":Onn" while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2" -make: "varmod-order.mk" line 77: Bad modifier ":Onrr" +make: varmod-order.mk:77: Unknown modifier ":Onrr" while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2" -make: "varmod-order.mk" line 86: Bad modifier ":Orrn" +make: varmod-order.mk:86: Unknown modifier ":Orrn" while evaluating variable "NUMBERS" with value "8 5 4 9 1 7 6 10 3 2" -make: "varmod-order.mk" line 100: Bad modifier ":On=Off" - while evaluating variable "SWITCH" with value "On" make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests exit status 1 diff --git a/unit-tests/varmod-order.mk b/unit-tests/varmod-order.mk index 0389b3f023af..c8386ef951dc 100644 --- a/unit-tests/varmod-order.mk +++ b/unit-tests/varmod-order.mk @@ -1,4 +1,4 @@ -# $NetBSD: varmod-order.mk,v 1.18 2025/01/11 20:54:46 rillig Exp $ +# $NetBSD: varmod-order.mk,v 1.19 2025/03/29 23:50:07 rillig Exp $ # # Tests for the :O variable modifier and its variants, which either sort the # words of the value or shuffle them. @@ -10,10 +10,10 @@ NUMBERS= 8 5 4 9 1 7 6 10 3 2 # in English alphabetical order . error ${WORDS:O} .endif -# expect+1: Bad modifier ":OX" +# expect+1: Unknown modifier ":OX" _:= ${WORDS:OX} -# expect+1: Bad modifier ":OxXX" +# expect+1: Unknown modifier ":OxXX" _:= ${WORDS:OxXX} # expect+1: Unclosed expression, expecting '}' for modifier "O" @@ -26,7 +26,7 @@ _:= ${NUMBERS:Onr # Shuffling numerically doesn't make sense, so don't allow 'x' and 'n' to be # combined. # -# expect+1: Bad modifier ":Oxn" +# expect+1: Unknown modifier ":Oxn" .if ${NUMBERS:Oxn} . error .else @@ -35,7 +35,7 @@ _:= ${NUMBERS:Onr # Extra characters after ':On' are detected and diagnosed. # -# expect+1: Bad modifier ":On_typo" +# expect+1: Unknown modifier ":On_typo" .if ${NUMBERS:On_typo} . error .else @@ -44,7 +44,7 @@ _:= ${NUMBERS:Onr # Extra characters after ':Onr' are detected and diagnosed. # -# expect+1: Bad modifier ":Onr_typo" +# expect+1: Unknown modifier ":Onr_typo" .if ${NUMBERS:Onr_typo} . error .else @@ -53,7 +53,7 @@ _:= ${NUMBERS:Onr # Extra characters after ':Orn' are detected and diagnosed. # -# expect+1: Bad modifier ":Orn_typo" +# expect+1: Unknown modifier ":Orn_typo" .if ${NUMBERS:Orn_typo} . error .else @@ -64,7 +64,7 @@ _:= ${NUMBERS:Onr # criteria are fixed, not computed, therefore allowing this redundancy does # not make sense. # -# expect+1: Bad modifier ":Onn" +# expect+1: Unknown modifier ":Onn" .if ${NUMBERS:Onn} . error .else @@ -73,7 +73,7 @@ _:= ${NUMBERS:Onr # Repeating the 'r' is not supported as well, for the same reasons as above. # -# expect+1: Bad modifier ":Onrr" +# expect+1: Unknown modifier ":Onrr" .if ${NUMBERS:Onrr} . error .else @@ -82,7 +82,7 @@ _:= ${NUMBERS:Onr # Repeating the 'r' is not supported as well, for the same reasons as above. # -# expect+1: Bad modifier ":Orrn" +# expect+1: Unknown modifier ":Orrn" .if ${NUMBERS:Orrn} . error .else @@ -91,16 +91,10 @@ _:= ${NUMBERS:Onr # If a modifier that starts with ':O' is not one of the known sort or shuffle -# forms, it is a parse error. Several other modifiers such as ':H' or ':u' -# fall back to the SysV modifier, for example, ':H=new' is not the standard -# ':H' modifier but instead replaces a trailing 'H' with 'new' in each word. -# There is no such fallback for the ':O' modifiers. +# forms, fall back to the SysV modifier. SWITCH= On -# expect+1: Bad modifier ":On=Off" .if ${SWITCH:On=Off} != "Off" . error -.else -. error .endif all: diff --git a/unit-tests/varmod-range.exp b/unit-tests/varmod-range.exp index dbd50c6def80..768ba9ac2f2d 100644 --- a/unit-tests/varmod-range.exp +++ b/unit-tests/varmod-range.exp @@ -1,13 +1,14 @@ -make: "varmod-range.mk" line 43: Malformed conditional '${:range=5} != ""' -make: "varmod-range.mk" line 66: Invalid number "x}Rest" != "Rest"" for ':range' modifier +make: varmod-range.mk:43: Variable "" is undefined + while evaluating "${:range=5} != """ with value "1 2 3 4 5" +make: varmod-range.mk:66: Invalid number "x}Rest" != "Rest"" for ':range' modifier while evaluating "${:U:range=x}Rest" != "Rest"" with value "" -make: "varmod-range.mk" line 76: Unknown modifier "x0" +make: varmod-range.mk:76: Unknown modifier ":x0" while evaluating "${:U:range=0x0}Rest" != "Rest"" with value "1" -make: "varmod-range.mk" line 93: Unknown modifier "rang" +make: varmod-range.mk:93: Unknown modifier ":rang" while evaluating variable "a b c" with value "a b c" -make: "varmod-range.mk" line 101: Unknown modifier "rango" +make: varmod-range.mk:101: Unknown modifier ":rango" while evaluating variable "a b c" with value "a b c" -make: "varmod-range.mk" line 109: Unknown modifier "ranger" +make: varmod-range.mk:109: Unknown modifier ":ranger" while evaluating variable "a b c" with value "a b c" make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests diff --git a/unit-tests/varmod-range.mk b/unit-tests/varmod-range.mk index 277935dc8bc7..7a60bcc23d86 100644 --- a/unit-tests/varmod-range.mk +++ b/unit-tests/varmod-range.mk @@ -1,4 +1,4 @@ -# $NetBSD: varmod-range.mk,v 1.16 2025/01/11 20:54:46 rillig Exp $ +# $NetBSD: varmod-range.mk,v 1.18 2025/04/04 18:57:01 rillig Exp $ # # Tests for the :range variable modifier, which generates sequences # of integers from the given range. @@ -39,7 +39,7 @@ # XXX: As of 2023-12-17, the ':range=n' modifier does not turn the undefined # expression into a defined one, even though it does not depend on the value # of the expression. This looks like an oversight. -# expect+1: Malformed conditional '${:range=5} != ""' +# expect+1: Variable "" is undefined .if ${:range=5} != "" . error .else @@ -72,7 +72,7 @@ # The upper limit of the range must always be given in decimal. # This parse error stops at the 'x', trying to parse it as a variable # modifier. -# expect+1: Unknown modifier "x0" +# expect+1: Unknown modifier ":x0" .if "${:U:range=0x0}Rest" != "Rest" . error .else @@ -89,7 +89,7 @@ #.endif # modifier name too short -# expect+1: Unknown modifier "rang" +# expect+1: Unknown modifier ":rang" .if "${a b c:L:rang}Rest" != "Rest" . error .else @@ -97,7 +97,7 @@ .endif # misspelled modifier name -# expect+1: Unknown modifier "rango" +# expect+1: Unknown modifier ":rango" .if "${a b c:L:rango}Rest" != "Rest" . error .else @@ -105,7 +105,7 @@ .endif # modifier name too long -# expect+1: Unknown modifier "ranger" +# expect+1: Unknown modifier ":ranger" .if "${a b c:L:ranger}Rest" != "Rest" . error .else diff --git a/unit-tests/varmod-select-words.exp b/unit-tests/varmod-select-words.exp index 7877837744ea..4ac95ead0852 100644 --- a/unit-tests/varmod-select-words.exp +++ b/unit-tests/varmod-select-words.exp @@ -1,5 +1,6 @@ -make: Bad modifier ":[]" +make: Invalid modifier ":[]" while evaluating variable "LIST" with value "one two three four five six" + in command "@echo 'LIST:[]="${LIST:[]}" is an error'" in target "mod-squarebrackets-empty" LIST:[0]="one two three four five six" LIST:[0x0]="one two three four five six" @@ -38,21 +39,25 @@ REALLYSPACE=" " REALLYSPACE:[1]="" == "" ? REALLYSPACE:[*]:[1]=" " == " " ? LIST:[1]="one" -make: Bad modifier ":[1.]" +make: Invalid modifier ":[1.]" while evaluating variable "LIST" with value "one two three four five six" + in command "@echo 'LIST:[1.]="${LIST:[1.]}" is an error'" in target "mod-squarebrackets-n-error-1" -make: Bad modifier ":[1]." +make: Extra text after "[1]" while evaluating variable "LIST" with value "one two three four five six" + in command "@echo 'LIST:[1].="${LIST:[1].}" is an error'" in target "mod-squarebrackets-n-error-2" LIST:[2]="two" LIST:[6]="six" LIST:[7]="" LIST:[999]="" -make: Bad modifier ":[-]" +make: Invalid modifier ":[-]" while evaluating variable "LIST" with value "one two three four five six" + in command "@echo 'LIST:[-]="${LIST:[-]}" is an error'" in target "mod-squarebrackets-n-error-3" -make: Bad modifier ":[--]" +make: Invalid modifier ":[--]" while evaluating variable "LIST" with value "one two three four five six" + in command "@echo 'LIST:[--]="${LIST:[--]}" is an error'" in target "mod-squarebrackets-n-error-4" LIST:[-1]="six" LIST:[-2]="five" @@ -72,28 +77,34 @@ LIST:[*]:C/ /,/:[2]="" LIST:[*]:C/ /,/:[*]:[2]="" LIST:[*]:C/ /,/:[@]:[2]="three" LONGLIST:[012..0x12]="10 11 12 13 14 15 16 17 18" -make: Bad modifier ":[1.]" +make: Invalid modifier ":[1.]" while evaluating variable "LIST" with value "one two three four five six" + in command "@echo 'LIST:[1.]="${LIST:[1.]}" is an error'" in target "mod-squarebrackets-start-end-error-1" -make: Bad modifier ":[1..]" +make: Invalid modifier ":[1..]" while evaluating variable "LIST" with value "one two three four five six" + in command "@echo 'LIST:[1..]="${LIST:[1..]}" is an error'" in target "mod-squarebrackets-start-end-error-2" -make: Bad modifier ":[1.. ]" +make: Invalid modifier ":[1.. ]" while evaluating variable "LIST" with value "one two three four five six" + in command "@echo 'LIST:[1.. ]="${LIST:[1.. ]}" is an error'" in target "mod-squarebrackets-start-end-error-3" LIST:[1..1]="one" -make: Bad modifier ":[1..1.]" +make: Invalid modifier ":[1..1.]" while evaluating variable "LIST" with value "one two three four five six" + in command "@echo 'LIST:[1..1.]="${LIST:[1..1.]}" is an error'" in target "mod-squarebrackets-start-end-error-4" LIST:[1..2]="one two" LIST:[2..1]="two one" LIST:[3..-2]="three four five" LIST:[-4..4]="three four" -make: Bad modifier ":[0..1]" +make: Invalid modifier ":[0..1]" while evaluating variable "LIST" with value "one two three four five six" + in command "@echo 'LIST:[0..1]="${LIST:[0..1]}" is an error'" in target "mod-squarebrackets-start-end-error-5" -make: Bad modifier ":[-1..0]" +make: Invalid modifier ":[-1..0]" while evaluating variable "LIST" with value "one two three four five six" + in command "@echo 'LIST:[-1..0]="${LIST:[-1..0]}" is an error'" in target "mod-squarebrackets-start-end-error-6" LIST:[-1..1]="six five four three two one" LIST:[0..0]="one two three four five six" @@ -108,8 +119,9 @@ LIST:[${ONE}]="one" LIST:[${MINUSONE}]="six" LIST:[${STAR}]="one two three four five six" LIST:[${AT}]="one two three four five six" -make: Bad modifier ":[${EMPTY" +make: Invalid modifier ":[]" while evaluating variable "LIST" with value "one two three four five six" + in command "@echo 'LIST:[$${EMPTY}]="${LIST:[${EMPTY}]}" is an error'" in target "mod-squarebrackets-nested-error-1" LIST:[${LONGLIST:[21]:S/2//}]="one" LIST:[${LIST:[#]}]="six" diff --git a/unit-tests/varmod-select-words.mk b/unit-tests/varmod-select-words.mk index 25a085891c0a..1217bb3c94b5 100644 --- a/unit-tests/varmod-select-words.mk +++ b/unit-tests/varmod-select-words.mk @@ -1,4 +1,4 @@ -# $NetBSD: varmod-select-words.mk,v 1.6 2024/08/29 20:20:36 rillig Exp $ +# $NetBSD: varmod-select-words.mk,v 1.7 2025/03/30 01:27:13 rillig Exp $ # # Tests for the :[...] variable modifier, which selects a single word # or a range of words from a variable. @@ -50,7 +50,7 @@ mod-squarebrackets: \ mod-squarebrackets-space mod-squarebrackets-empty: -# expect: make: Bad modifier ":[]" +# expect: make: Invalid modifier ":[]" @echo 'LIST:[]="${LIST:[]}" is an error' mod-squarebrackets-0-star-at: @@ -96,10 +96,10 @@ mod-squarebrackets-n-ok-1: @echo 'REALLYSPACE:[*]:[1]="${REALLYSPACE:[*]:[1]}" == " " ?' @echo 'LIST:[1]="${LIST:[1]}"' mod-squarebrackets-n-error-1: -# expect: make: Bad modifier ":[1.]" +# expect: make: Invalid modifier ":[1.]" @echo 'LIST:[1.]="${LIST:[1.]}" is an error' mod-squarebrackets-n-error-2: -# expect: make: Bad modifier ":[1]." +# expect: make: Extra text after "[1]" @echo 'LIST:[1].="${LIST:[1].}" is an error' mod-squarebrackets-n-ok-2: @echo 'LIST:[2]="${LIST:[2]}"' @@ -107,10 +107,10 @@ mod-squarebrackets-n-ok-2: @echo 'LIST:[7]="${LIST:[7]}"' @echo 'LIST:[999]="${LIST:[999]}"' mod-squarebrackets-n-error-3: -# expect: make: Bad modifier ":[-]" +# expect: make: Invalid modifier ":[-]" @echo 'LIST:[-]="${LIST:[-]}" is an error' mod-squarebrackets-n-error-4: -# expect: make: Bad modifier ":[--]" +# expect: make: Invalid modifier ":[--]" @echo 'LIST:[--]="${LIST:[--]}" is an error' mod-squarebrackets-n-ok-3: @echo 'LIST:[-1]="${LIST:[-1]}"' @@ -133,18 +133,18 @@ mod-squarebrackets-n-ok-3: @echo 'LONGLIST:[012..0x12]="${LONGLIST:[012..0x12]}"' mod-squarebrackets-start-end-error-1: -# expect: make: Bad modifier ":[1.]" +# expect: make: Invalid modifier ":[1.]" @echo 'LIST:[1.]="${LIST:[1.]}" is an error' mod-squarebrackets-start-end-error-2: -# expect: make: Bad modifier ":[1..]" +# expect: make: Invalid modifier ":[1..]" @echo 'LIST:[1..]="${LIST:[1..]}" is an error' mod-squarebrackets-start-end-error-3: -# expect: make: Bad modifier ":[1.. ]" +# expect: make: Invalid modifier ":[1.. ]" @echo 'LIST:[1.. ]="${LIST:[1.. ]}" is an error' mod-squarebrackets-start-end-ok-1: @echo 'LIST:[1..1]="${LIST:[1..1]}"' mod-squarebrackets-start-end-error-4: -# expect: make: Bad modifier ":[1..1.]" +# expect: make: Invalid modifier ":[1..1.]" @echo 'LIST:[1..1.]="${LIST:[1..1.]}" is an error' mod-squarebrackets-start-end-ok-2: @echo 'LIST:[1..2]="${LIST:[1..2]}"' @@ -152,10 +152,10 @@ mod-squarebrackets-start-end-ok-2: @echo 'LIST:[3..-2]="${LIST:[3..-2]}"' @echo 'LIST:[-4..4]="${LIST:[-4..4]}"' mod-squarebrackets-start-end-error-5: -# expect: make: Bad modifier ":[0..1]" +# expect: make: Invalid modifier ":[0..1]" @echo 'LIST:[0..1]="${LIST:[0..1]}" is an error' mod-squarebrackets-start-end-error-6: -# expect: make: Bad modifier ":[-1..0]" +# expect: make: Invalid modifier ":[-1..0]" @echo 'LIST:[-1..0]="${LIST:[-1..0]}" is an error' mod-squarebrackets-start-end-ok-3: @echo 'LIST:[-1..1]="${LIST:[-1..1]}"' @@ -174,7 +174,7 @@ mod-squarebrackets-nested-ok-1: @echo 'LIST:[$${STAR}]="${LIST:[${STAR}]}"' @echo 'LIST:[$${AT}]="${LIST:[${AT}]}"' mod-squarebrackets-nested-error-1: -# expect: make: Bad modifier ":[${EMPTY" +# expect: make: Invalid modifier ":[]" @echo 'LIST:[$${EMPTY}]="${LIST:[${EMPTY}]}" is an error' mod-squarebrackets-nested-ok-2: @echo 'LIST:[$${LONGLIST:[21]:S/2//}]="${LIST:[${LONGLIST:[21]:S/2//}]}"' diff --git a/unit-tests/varmod-shell.exp b/unit-tests/varmod-shell.exp index b2c6c59eea40..7f93e8354a1e 100644 --- a/unit-tests/varmod-shell.exp +++ b/unit-tests/varmod-shell.exp @@ -1,11 +1,11 @@ -make: "varmod-shell.mk" line 25: warning: Command "echo word; (exit 13)" exited with status 13 -make: "varmod-shell.mk" line 29: warning: Command "echo word; (exit 13)" exited with status 13 +make: varmod-shell.mk:25: warning: Command "echo word; (exit 13)" exited with status 13 +make: varmod-shell.mk:29: warning: Command "echo word; (exit 13)" exited with status 13 Global: _ = # (empty) Var_Parse: ${:!echo word; ${:U(exit 13)}!} (eval-keep-dollar-and-undefined) Evaluating modifier ${:!...} on value "" (eval-keep-dollar-and-undefined, undefined) Modifier part: "echo word; (exit 13)" Capturing the output of command "echo word; (exit 13)" -make: "varmod-shell.mk" line 36: warning: Command "echo word; (exit 13)" exited with status 13 +make: varmod-shell.mk:36: warning: Command "echo word; (exit 13)" exited with status 13 Result of ${:!echo word; ${:U(exit 13)}!} is "word" (eval-keep-dollar-and-undefined, defined) Global: _ = word Global: .MAKEFLAGS = -r -k -d v -d diff --git a/unit-tests/varmod-subst-regex.exp b/unit-tests/varmod-subst-regex.exp index 98c37f6fd8e7..816b02248591 100644 --- a/unit-tests/varmod-subst-regex.exp +++ b/unit-tests/varmod-subst-regex.exp @@ -1,51 +1,66 @@ make: Regex compilation error: (details omitted) while evaluating "${:Uword1 word2:C,****,____,g:C,word,____,:Q}." with value "word1 word2" + in command "@echo $@: ${:Uword1 word2:C,****,____,g:C,word,____,:Q}." in target "mod-regex-compile-error" make: No subexpression \1 while evaluating "${:U1 23 456:C,..,\1\1,:Q}" with value "1 23 456" + in command "@echo $@:11-missing:${:U1 23 456:C,..,\1\1,:Q}" in target "mod-regex-limits-1" make: No subexpression \1 while evaluating "${:U1 23 456:C,..,\1\1,:Q}" with value "1 23 456" + in command "@echo $@:11-missing:${:U1 23 456:C,..,\1\1,:Q}" in target "mod-regex-limits-1" make: No subexpression \1 while evaluating "${:U1 23 456:C,..,\1\1,:Q}" with value "1 23 456" + in command "@echo $@:11-missing:${:U1 23 456:C,..,\1\1,:Q}" in target "mod-regex-limits-1" make: No subexpression \1 while evaluating "${:U1 23 456:C,..,\1\1,:Q}" with value "1 23 456" + in command "@echo $@:11-missing:${:U1 23 456:C,..,\1\1,:Q}" in target "mod-regex-limits-1" mod-regex-limits-2:11-ok:1 22 446 make: No subexpression \2 while evaluating "${:U1 23 456:C,..,\2\2,:Q}" with value "1 23 456" + in command "@echo $@:22-missing:${:U1 23 456:C,..,\2\2,:Q}" in target "mod-regex-limits-3" make: No subexpression \2 while evaluating "${:U1 23 456:C,..,\2\2,:Q}" with value "1 23 456" + in command "@echo $@:22-missing:${:U1 23 456:C,..,\2\2,:Q}" in target "mod-regex-limits-3" make: No subexpression \2 while evaluating "${:U1 23 456:C,..,\2\2,:Q}" with value "1 23 456" + in command "@echo $@:22-missing:${:U1 23 456:C,..,\2\2,:Q}" in target "mod-regex-limits-3" make: No subexpression \2 while evaluating "${:U1 23 456:C,..,\2\2,:Q}" with value "1 23 456" + in command "@echo $@:22-missing:${:U1 23 456:C,..,\2\2,:Q}" in target "mod-regex-limits-3" make: No subexpression \2 while evaluating "${:U1 23 456:C,(.).,\2\2,:Q}" with value "1 23 456" + in command "@echo $@:22-missing:${:U1 23 456:C,(.).,\2\2,:Q}" in target "mod-regex-limits-4" make: No subexpression \2 while evaluating "${:U1 23 456:C,(.).,\2\2,:Q}" with value "1 23 456" + in command "@echo $@:22-missing:${:U1 23 456:C,(.).,\2\2,:Q}" in target "mod-regex-limits-4" make: No subexpression \2 while evaluating "${:U1 23 456:C,(.).,\2\2,:Q}" with value "1 23 456" + in command "@echo $@:22-missing:${:U1 23 456:C,(.).,\2\2,:Q}" in target "mod-regex-limits-4" make: No subexpression \2 while evaluating "${:U1 23 456:C,(.).,\2\2,:Q}" with value "1 23 456" + in command "@echo $@:22-missing:${:U1 23 456:C,(.).,\2\2,:Q}" in target "mod-regex-limits-4" mod-regex-limits-5:22-ok:1 33 556 mod-regex-limits-6:capture:ihgfedcbaabcdefghijABCDEFGHIJa0a1a2rest make: Regex compilation error: (details omitted) while evaluating variable "UNDEF" with value "value" + in command "@echo $@: ${UNDEF:Uvalue:C,[,,}" in target "mod-regex-errors-1" -make: Unknown modifier "Z" +make: Unknown modifier ":Z" while evaluating "${:U:Z}y,W}" with value "" while evaluating variable "word" with value "word" + in command "@echo $@: ${word:L:C,.*,x${:U:Z}y,W}" in target "mod-regex-errors-2" unmatched-subexpression.ok: one one 2 3 5 8 one3 2one 34 make: No match for subexpression \2 diff --git a/unit-tests/varmod-subst.exp b/unit-tests/varmod-subst.exp index 1547201bb404..8eec26e33ef5 100644 --- a/unit-tests/varmod-subst.exp +++ b/unit-tests/varmod-subst.exp @@ -45,8 +45,9 @@ mod-subst-delimiter: 1 two 3 tilde mod-subst-chain: A B c. -make: Unknown modifier "i" +make: Unknown modifier ":i" while evaluating "${:Uvalue:S,a,x,i}." with value "vxlue" + in command "@echo ${:Uvalue:S,a,x,i}." in target "mod-subst-chain" mod-subst-dollar:$1: mod-subst-dollar:$2: diff --git a/unit-tests/varmod-subst.mk b/unit-tests/varmod-subst.mk index 34f20a5f96f2..e9da303515b2 100644 --- a/unit-tests/varmod-subst.mk +++ b/unit-tests/varmod-subst.mk @@ -1,4 +1,4 @@ -# $NetBSD: varmod-subst.mk,v 1.16 2024/08/29 20:20:37 rillig Exp $ +# $NetBSD: varmod-subst.mk,v 1.17 2025/03/29 19:08:53 rillig Exp $ # # Tests for the :S,from,to, variable modifier. @@ -252,7 +252,7 @@ mod-subst-chain: # The error message is "make: Unknown modifier 'i'", which is # kind of correct, although it is mixing the terms for variable # modifiers with the matching modifiers. -# expect: make: Unknown modifier "i" +# expect: make: Unknown modifier ":i" @echo ${:Uvalue:S,a,x,i}. # No matter how many dollar signs there are, they all get merged diff --git a/unit-tests/varmod-sun-shell.exp b/unit-tests/varmod-sun-shell.exp index 5a557b97cec8..e3dcdfa840ff 100644 --- a/unit-tests/varmod-sun-shell.exp +++ b/unit-tests/varmod-sun-shell.exp @@ -1,11 +1,11 @@ -make: "varmod-sun-shell.mk" line 17: warning: Command "echo word; (exit 13)" exited with status 13 +make: varmod-sun-shell.mk:17: warning: Command "echo word; (exit 13)" exited with status 13 Global: _ = # (empty) Var_Parse: ${echo word; ${:U(exit 13)}:L:sh} (eval-keep-dollar-and-undefined) Evaluating modifier ${echo word; (exit 13):L} on value "" (eval-keep-dollar-and-undefined, undefined) Result of ${echo word; (exit 13):L} is "echo word; (exit 13)" (eval-keep-dollar-and-undefined, defined) Evaluating modifier ${echo word; (exit 13):s...} on value "echo word; (exit 13)" (eval-keep-dollar-and-undefined, defined) Capturing the output of command "echo word; (exit 13)" -make: "varmod-sun-shell.mk" line 24: warning: Command "echo word; (exit 13)" exited with status 13 +make: varmod-sun-shell.mk:24: warning: Command "echo word; (exit 13)" exited with status 13 Result of ${echo word; (exit 13):sh} is "word" (eval-keep-dollar-and-undefined, defined) Global: _ = word Global: .MAKEFLAGS = -r -k -d v -d diff --git a/unit-tests/varmod-sysv.exp b/unit-tests/varmod-sysv.exp index ecda358758e1..d2396fc7d576 100644 --- a/unit-tests/varmod-sysv.exp +++ b/unit-tests/varmod-sysv.exp @@ -1,4 +1,4 @@ -make: "varmod-sysv.mk" line 215: Unfinished modifier ('=' missing) +make: varmod-sysv.mk:215: Unfinished modifier after "from${:D=}to}", expecting "=" while evaluating variable "word216" with value "word216" word modifier result '' = "" @@ -145,7 +145,7 @@ pre-middle-suffix pre%ffix=NPre% "NPre-middle-su" suffix pre%ffix=NPre%NS "suffix" prefix pre%ffix=NPre%NS "prefix" pre-middle-suffix pre%ffix=NPre%NS "NPre-middle-suNS" -make: "varmod-sysv.mk" line 259: Unfinished modifier ('}' missing) +make: varmod-sysv.mk:259: Unfinished modifier after "$(})", expecting "}" while evaluating variable "error" with value "error" make: Fatal errors encountered -- cannot continue make: stopped making "all" in unit-tests diff --git a/unit-tests/varmod-sysv.mk b/unit-tests/varmod-sysv.mk index f7d7a1ffe81a..9209626cc214 100644 --- a/unit-tests/varmod-sysv.mk +++ b/unit-tests/varmod-sysv.mk @@ -1,4 +1,4 @@ -# $NetBSD: varmod-sysv.mk,v 1.22 2025/01/11 20:54:46 rillig Exp $ +# $NetBSD: varmod-sysv.mk,v 1.24 2025/03/30 00:35:52 rillig Exp $ # # Tests for the variable modifier ':from=to', which replaces the suffix # "from" with "to". It can also use '%' as a wildcard. @@ -211,7 +211,7 @@ # XXX: As of 2024-06-30, this expression generates an "Unfinished modifier" # error, while the correct error message would be "Unknown modifier" since # there is no modifier named "fromto". -# expect+1: Unfinished modifier ('=' missing) +# expect+1: Unfinished modifier after "from${:D=}to}", expecting "=" .if ${word216:L:from${:D=}to} . error .endif @@ -255,9 +255,32 @@ INDIRECT= 1:${VALUE} 2:$${VALUE} 4:$$$${VALUE} # The error case of an unfinished ':from=to' modifier after the '=' requires # an expression that is missing the closing '}'. -# expect+1: Unfinished modifier ('}' missing) +# expect+1: Unfinished modifier after "$(})", expecting "}" .if ${error:L:from=$(}) .endif +# The various ":t..." modifiers fall back to the ":from=to" modifier. +.if ${:Utarget:target=source} != "source" +. error +.endif +.if ${:Ufile.ts:ts=js} != "file.js" +. error +.endif +.if ${:Ufile.tsx:tsx=jsx} != "file.jsx" +. error +.endif +.if ${:Ufile.ts\\part:ts\part=replaced} != "file.replaced" +. error +.endif +.if ${:Ufile.ts\\123xyz:ts\123xyz=gone} != "file.gone" +. error +.endif +# Since the ":ts=" modifier is a valid form of the ":ts" modifier, don't fall +# back to the ":from=to" modifier. +.if ${:U1 2 3 file.ts:ts=} != "1=2=3=file.ts" +. error +.endif + + all: diff --git a/unit-tests/varmod-to-abs.exp b/unit-tests/varmod-to-abs.exp index 4506d5ea8175..2865149a06ca 100644 --- a/unit-tests/varmod-to-abs.exp +++ b/unit-tests/varmod-to-abs.exp @@ -1,5 +1,5 @@ -make: "varmod-to-abs.mk" line 19: does-not-exist.c -make: "varmod-to-abs.mk" line 21: does-not-exist.c +make: varmod-to-abs.mk:19: does-not-exist.c +make: varmod-to-abs.mk:21: does-not-exist.c cached_realpath: varmod-to-abs.mk -> varmod-to-abs.mk -make: "varmod-to-abs.mk" line 26: varmod-to-abs.mk +make: varmod-to-abs.mk:26: varmod-to-abs.mk exit status 0 diff --git a/unit-tests/varmod-to-separator.exp b/unit-tests/varmod-to-separator.exp index 368def5f7ffe..e8d5686c93c8 100644 --- a/unit-tests/varmod-to-separator.exp +++ b/unit-tests/varmod-to-separator.exp @@ -1,28 +1,28 @@ -make: "varmod-to-separator.mk" line 154: Invalid character number at "400:tu}" +make: varmod-to-separator.mk:154: Invalid character number at "400:tu}" while evaluating variable "WORDS" with value "one two three" -make: "varmod-to-separator.mk" line 169: Invalid character number at "100:tu}" +make: varmod-to-separator.mk:169: Invalid character number at "100:tu}" while evaluating variable "WORDS" with value "one two three" -make: "varmod-to-separator.mk" line 177: Invalid character number at ",}" +make: varmod-to-separator.mk:177: Invalid character number at ",}" while evaluating variable "word" with value "word" -make: "varmod-to-separator.mk" line 183: Invalid character number at "112233445566778899}" +make: varmod-to-separator.mk:183: Invalid character number at "112233445566778899}" while evaluating variable "word" with value "word" -make: "varmod-to-separator.mk" line 188: Bad modifier ":ts\-300" +make: varmod-to-separator.mk:188: Unknown modifier ":ts\-300" while evaluating variable "WORDS" with value "one two three" -make: "varmod-to-separator.mk" line 197: Bad modifier ":ts\8" +make: varmod-to-separator.mk:197: Unknown modifier ":ts\8" while evaluating variable "1 2 3" with value "1 2 3" -make: "varmod-to-separator.mk" line 205: Bad modifier ":ts\100L" +make: varmod-to-separator.mk:205: Unknown modifier ":ts\100L" while evaluating variable "1 2 3" with value "1 2 3" -make: "varmod-to-separator.mk" line 213: Bad modifier ":ts\x40g" +make: varmod-to-separator.mk:213: Unknown modifier ":ts\x40g" while evaluating variable "1 2 3" with value "1 2 3" -make: "varmod-to-separator.mk" line 222: Bad modifier ":tx" +make: varmod-to-separator.mk:222: Unknown modifier ":tx" while evaluating variable "WORDS" with value "one two three four five six" -make: "varmod-to-separator.mk" line 230: Bad modifier ":ts\X" +make: varmod-to-separator.mk:230: Unknown modifier ":ts\X" while evaluating variable "WORDS" with value "one two three four five six" -make: "varmod-to-separator.mk" line 239: Bad modifier ":t\X" +make: varmod-to-separator.mk:239: Unknown modifier ":ts\X" while evaluating variable "WORDS" with value "one two three four five six" -make: "varmod-to-separator.mk" line 255: Bad modifier ":ts\69" +make: varmod-to-separator.mk:255: Unknown modifier ":ts\69" while evaluating "${:Ua b:ts\69}" with value "a b" -make: "varmod-to-separator.mk" line 263: Invalid character number at "1F60E}" +make: varmod-to-separator.mk:263: Invalid character number at "1F60E}" while evaluating "${:Ua b:ts\x1F60E}" with value "a b" make: Fatal errors encountered -- cannot continue make: stopped in unit-tests diff --git a/unit-tests/varmod-to-separator.mk b/unit-tests/varmod-to-separator.mk index 5cb838bf5bb7..18986e7f4bea 100644 --- a/unit-tests/varmod-to-separator.mk +++ b/unit-tests/varmod-to-separator.mk @@ -1,4 +1,4 @@ -# $NetBSD: varmod-to-separator.mk,v 1.21 2025/01/11 20:54:46 rillig Exp $ +# $NetBSD: varmod-to-separator.mk,v 1.23 2025/03/30 00:35:52 rillig Exp $ # # Tests for the :ts variable modifier, which joins the words of the variable # using an arbitrary character as word separator. @@ -7,30 +7,30 @@ WORDS= one two three four five six # The words are separated by a single space, just as usual. .if ${WORDS:ts } != "one two three four five six" -. warning Space as separator does not work. +. error .endif # The separator can be an arbitrary character, for example a comma. .if ${WORDS:ts,} != "one,two,three,four,five,six" -. warning Comma as separator does not work. +. error .endif # After the :ts modifier, other modifiers can follow. .if ${WORDS:ts/:tu} != "ONE/TWO/THREE/FOUR/FIVE/SIX" -. warning Chaining modifiers does not work. +. error .endif # To use the ':' as the separator, just write it normally. # The first colon is the separator, the second ends the modifier. .if ${WORDS:ts::tu} != "ONE:TWO:THREE:FOUR:FIVE:SIX" -. warning Colon as separator does not work. +. error .endif # When there is just a colon but no other character, the words are # "separated" by an empty string, that is, they are all squashed # together. .if ${WORDS:ts:tu} != "ONETWOTHREEFOURFIVESIX" -. warning Colon as separator does not work. +. error .endif # Applying the :tu modifier first and then the :ts modifier does not change @@ -42,42 +42,42 @@ WORDS= one two three four five six # as a separator, but as the closing delimiter of the whole # expression. .if ${WORDS:tu:ts} != "ONETWOTHREEFOURFIVESIX" -. warning Colon as separator does not work. +. error .endif # The '}' plays the same role as the ':' in the preceding examples. # Since there is a single character before it, that character is taken as # the separator. .if ${WORDS:tu:ts/} != "ONE/TWO/THREE/FOUR/FIVE/SIX" -. warning Colon as separator does not work. +. error .endif # Now it gets interesting and ambiguous: The separator could either be empty # since it is followed by a colon. Or it could be the colon since that # colon is followed by the closing brace. It's the latter case. .if ${WORDS:ts:} != "one:two:three:four:five:six" -. warning Colon followed by closing brace does not work. +. error .endif # As in the ${WORDS:tu:ts} example above, the separator is empty. .if ${WORDS:ts} != "onetwothreefourfivesix" -. warning Empty separator before closing brace does not work. +. error .endif # The :ts modifier can be followed by other modifiers. .if ${WORDS:ts:S/two/2/} != "one2threefourfivesix" -. warning Separator followed by :S modifier does not work. +. error .endif # The :ts modifier can follow other modifiers. .if ${WORDS:S/two/2/:ts} != "one2threefourfivesix" -. warning :S modifier followed by :ts modifier does not work. +. error .endif # The :ts modifier with an actual separator can be followed by other # modifiers. .if ${WORDS:ts/:S/two/2/} != "one/2/three/four/five/six" -. warning The :ts modifier followed by an :S modifier does not work. +. error .endif # After the modifier ':ts/', the expression value is a single word since all @@ -128,22 +128,22 @@ WORDS= one two three four five six # The separator can be \n, which is a newline. .if ${WORDS:[1..3]:ts\n} != "one${.newline}two${.newline}three" -. warning The separator \n does not produce a newline. +. error .endif # The separator can be \t, which is a tab. .if ${WORDS:[1..3]:ts\t} != "one two three" -. warning The separator \t does not produce a tab. +. error .endif # The separator can be given as octal number. .if ${WORDS:[1..3]:ts\012:tu} != "ONE${.newline}TWO${.newline}THREE" -. warning The separator \012 is not interpreted in octal ASCII. +. error .endif # The octal number can have as many digits as it wants. .if ${WORDS:[1..2]:ts\000000000000000000000000012:tu} != "ONE${.newline}TWO" -. warning The separator \012 cannot have many leading zeroes. +. error .endif # The value of the separator character must not be outside the value space @@ -152,14 +152,14 @@ WORDS= one two three four five six # Since 2020-11-01, these out-of-bounds values are rejected. # expect+1: Invalid character number at "400:tu}" .if ${WORDS:[1..3]:ts\400:tu} -. warning The separator \400 is accepted even though it is out of bounds. +. error .else -. warning The separator \400 is accepted even though it is out of bounds. +. error .endif # The separator can be given as hexadecimal number. .if ${WORDS:[1..3]:ts\xa:tu} != "ONE${.newline}TWO${.newline}THREE" -. warning The separator \xa is not interpreted in hexadecimal ASCII. +. error .endif # The hexadecimal number must be in the range of an unsigned char. @@ -167,9 +167,9 @@ WORDS= one two three four five six # Since 2020-11-01, these out-of-bounds values are rejected. # expect+1: Invalid character number at "100:tu}" .if ${WORDS:[1..3]:ts\x100:tu} -. warning The separator \x100 is accepted even though it is out of bounds. +. error .else -. warning The separator \x100 is accepted even though it is out of bounds. +. error .endif # The number after ':ts\x' must be hexadecimal. @@ -184,41 +184,41 @@ WORDS= one two three four five six .endif # Negative numbers are not allowed for the separator character. -# expect+1: Bad modifier ":ts\-300" +# expect+1: Unknown modifier ":ts\-300" .if ${WORDS:[1..3]:ts\-300:tu} -. warning The separator \-300 is accepted even though it is negative. +. error .else -. warning The separator \-300 is accepted even though it is negative. +. error .endif # The character number is interpreted as octal number by default. # The digit '8' is not an octal digit though. -# expect+1: Bad modifier ":ts\8" +# expect+1: Unknown modifier ":ts\8" .if ${1 2 3:L:ts\8:tu} -. warning The separator \8 is accepted even though it is not octal. +. error .else -. warning The separator \8 is accepted even though it is not octal. +. error .endif # Trailing characters after the octal character number are rejected. -# expect+1: Bad modifier ":ts\100L" +# expect+1: Unknown modifier ":ts\100L" .if ${1 2 3:L:ts\100L} -. warning The separator \100L is accepted even though it contains an 'L'. +. error .else -. warning The separator \100L is accepted even though it contains an 'L'. +. error .endif # Trailing characters after the hexadecimal character number are rejected. -# expect+1: Bad modifier ":ts\x40g" +# expect+1: Unknown modifier ":ts\x40g" .if ${1 2 3:L:ts\x40g} -. warning The separator \x40g is accepted even though it contains a 'g'. +. error .else -. warning The separator \x40g is accepted even though it contains a 'g'. +. error .endif # In the :t modifier, the :t must be followed by any of A, l, s, u. -# expect+1: Bad modifier ":tx" +# expect+1: Unknown modifier ":tx" .if ${WORDS:tx} . error .else @@ -226,7 +226,7 @@ WORDS= one two three four five six .endif # The word separator can only be a single character. -# expect+1: Bad modifier ":ts\X" +# expect+1: Unknown modifier ":ts\X" .if ${WORDS:ts\X} . error .else @@ -235,9 +235,9 @@ WORDS= one two three four five six # After the backslash, only n, t, an octal number, or x and a hexadecimal # number are allowed. -# expect+1: Bad modifier ":t\X" -.if ${WORDS:t\X} != "anything" -. info This line is not reached. +# expect+1: Unknown modifier ":ts\X" +.if ${WORDS:ts\X} != "anything" +. error .endif @@ -251,7 +251,7 @@ WORDS= one two three four five six # happens for non-octal digits. From 2003.07.23.18.06.46 to # 2016.02.27.16.20.06, the result was '1E2', since 2016.03.07.20.20.35 make no # longer accepts this escape and complains. -# expect+1: Bad modifier ":ts\69" +# expect+1: Unknown modifier ":ts\69" .if ${:Ua b:ts\69} . error .else diff --git a/unit-tests/varmod.exp b/unit-tests/varmod.exp index 91968a7f310f..09c922aa16bd 100644 --- a/unit-tests/varmod.exp +++ b/unit-tests/varmod.exp @@ -1,44 +1,47 @@ -make: "varmod.mk" line 101: To escape a dollar, use \$, not $$, at "$$:L} != """ -make: "varmod.mk" line 101: Invalid variable name ':', at "$:L} != """ -make: "varmod.mk" line 107: Dollar followed by nothing +make: varmod.mk:111: To escape a dollar, use \$, not $$, at "$$:L} != """ +make: varmod.mk:111: Invalid variable name ':', at "$:L} != """ +make: varmod.mk:117: Dollar followed by nothing while evaluating "${:Uword:@word@${word}$@} != "word"" with value "word" -make: "varmod.mk" line 117: Missing delimiter ':' after modifier "P" +make: varmod.mk:127: Missing delimiter ':' after modifier "P" while evaluating variable "VAR" with value "VAR" -make: "varmod.mk" line 119: Missing argument for ".error" -make: "varmod.mk" line 125: Bad modifier ":[99333000222000111000]" +make: varmod.mk:129: Missing argument for ".error" +make: varmod.mk:135: Invalid modifier ":[99333000222000111000]" while evaluating variable "word" with value "word" -make: "varmod.mk" line 128: Bad modifier ":[2147483648]" +make: varmod.mk:138: Invalid modifier ":[2147483648]" while evaluating variable "word" with value "word" -make: "varmod.mk" line 134: Invalid number "99333000222000111000}" for ':range' modifier +make: varmod.mk:144: Invalid number "99333000222000111000}" for ':range' modifier while evaluating variable "word" with value "word" -make: "varmod.mk" line 141: Invalid time value "\" +make: varmod.mk:151: Invalid time value "\" + while evaluating indirect modifiers "gmtime=\" while evaluating "${:${:Ugmtime=\\}}" with value "" -make: "varmod.mk" line 156: Dollar followed by nothing +make: varmod.mk:166: Dollar followed by nothing while evaluating variable "VAR" with value "value$" -make: "varmod.mk" line 162: Dollar followed by nothing +make: varmod.mk:172: Dollar followed by nothing while evaluating variable "VAR" with value "value$" -make: "varmod.mk" line 162: Dollar followed by nothing +make: varmod.mk:172: Dollar followed by nothing while evaluating variable "VAR" with value "value$ appended$" -make: "varmod.mk" line 172: Dollar followed by nothing +make: varmod.mk:182: Dollar followed by nothing while evaluating variable "word" with value "word" -make: "varmod.mk" line 176: Bad modifier ":[$]" +make: varmod.mk:186: Invalid modifier ":[$]" while evaluating variable "word" with value "" -make: "varmod.mk" line 193: Dollar followed by nothing +make: varmod.mk:203: Dollar followed by nothing while evaluating variable "VAR" with value "value$ appended$" -make: "varmod.mk" line 193: Invalid variable name '}', at "$} != "set"" +make: varmod.mk:203: Invalid variable name '}', at "$} != "set"" while evaluating variable "VAR" with value "value<space>appended" -make: "varmod.mk" line 197: Invalid variable name '}', at "$} != "fallback"" +make: varmod.mk:207: Invalid variable name '}', at "$} != "fallback"" while evaluating "${:Ufallback$} != "fallback"" with value "" -make: "varmod.mk" line 201: Invalid time value "1000$" +make: varmod.mk:211: Invalid time value "1000$" while evaluating variable "%y" with value "%y" -make: "varmod.mk" line 207: Invalid time value "1000$" +make: varmod.mk:217: Invalid time value "1000$" while evaluating variable "%y" with value "%y" -make: "varmod.mk" line 213: Dollar followed by nothing +make: varmod.mk:223: Dollar followed by nothing while evaluating variable "word" with value "word" -make: "varmod.mk" line 217: Dollar followed by nothing +make: varmod.mk:227: Dollar followed by nothing while evaluating variable "word" with value "word" -make: "varmod.mk" line 221: Invalid argument 'fallback$' for modifier ':mtime' +make: varmod.mk:231: Invalid argument 'fallback$' for modifier ':mtime' while evaluating variable "." with value "." +make: varmod.mk:245: Missing delimiter ':' after modifier "L" + while evaluating variable "VAR" with value "VAR" make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 diff --git a/unit-tests/varmod.mk b/unit-tests/varmod.mk index e0398965229b..cc7b08c447e9 100644 --- a/unit-tests/varmod.mk +++ b/unit-tests/varmod.mk @@ -1,4 +1,4 @@ -# $NetBSD: varmod.mk,v 1.22 2025/01/11 20:54:46 rillig Exp $ +# $NetBSD: varmod.mk,v 1.26 2025/03/30 01:27:13 rillig Exp $ # # Tests for variable modifiers, such as :Q, :S,from,to or :Ufallback. # @@ -21,40 +21,50 @@ # * `individual`: parsing this modifier does not follow the common # pattern of calling `ParseModifierPart`. # -# The SysV column says whether a parse error in the modifier falls back -# trying the `:from=to` System V modifier. +# The SysV column says whether a modifier falls back trying the `:from=to` +# System V modifier. Remarks: # -# | **Operator** | **Behavior** | **Remarks** | **SysV** | +# In the assignment modifiers `::=` and its variants, the `=` is part of +# the modifier name, so they never fall back to the `:from=to` modifier. +# +# All no-colon modifiers get a "no", as the modifier name would be +# trimmed off before the `:from=to` modifier could see them, for +# example, ${VAR:LAR=ALUE} and ${VAR:L:AR=ALUE} behave the same. +# +# | **Modifier** | **Behavior** | **Remarks** | **SysV** | # |--------------|--------------|--------------------|----------| -# | `!` | no-colon | | no | -# | `:=` | greedy | | yes | -# | `?:` | greedy | | no | -# | `@` | no-colon | | no | -# | `C` | no-colon | | no | -# | `D` | individual | custom parser | N/A | -# | `E` | strict | | yes | -# | `H` | strict | | yes | -# | `L` | no-colon | | N/A | -# | `M` | individual | custom parser | N/A | -# | `N` | individual | custom parser | N/A | -# | `O` | strict | only literal value | no | -# | `P` | no-colon | | N/A | -# | `Q` | strict | | yes | -# | `R` | strict | | yes | -# | `S` | no-colon | | N/A | -# | `T` | strict | | N/A | -# | `U` | individual | custom parser | N/A | -# | `[` | strict | | no | -# | `_` | individual | strcspn | yes | -# | `gmtime` | strict | | yes | -# | `hash` | strict | | N/A | -# | `localtime` | strict | | yes | -# | `q` | strict | | yes | -# | `range` | strict | | N/A | -# | `sh` | strict | | N/A | -# | `t` | strict | | no | -# | `u` | strict | | yes | -# | `from=to` | greedy | SysV, fallback | N/A | +# | ! | no-colon | | no | +# | := | greedy | | no | +# | :?= | greedy | | no | +# | :+= | greedy | | no | +# | :!= | greedy | | no | +# | ?: | greedy | | no | +# | @ | no-colon | | no | +# | C | no-colon | | no | +# | D | individual | custom parser | no | +# | E | strict | | yes | +# | H | strict | | yes | +# | L | no-colon | | no | +# | M | individual | custom parser | no | +# | N | individual | custom parser | no | +# | O | strict | only literal value | yes | +# | P | no-colon | | no | +# | Q | strict | | yes | +# | R | strict | | yes | +# | S | no-colon | | no | +# | T | strict | | yes | +# | U | individual | custom parser | no | +# | [ | strict | | no | +# | _ | individual | strcspn | no | +# | gmtime | strict | | no | +# | hash | strict | | yes | +# | localtime | strict | | no | +# | q | strict | | yes | +# | range | strict | | no | +# | sh | strict | | yes | +# | t | strict | | yes | +# | u | strict | | yes | +# | from=to | greedy | SysV, fallback | --- | # These tests assume .MAKE.SAVE_DOLLARS = yes @@ -121,10 +131,10 @@ VAR= STOP # Test the word selection modifier ':[n]' with a very large number that is # larger than ULONG_MAX for any supported platform. -# expect+1: Bad modifier ":[99333000222000111000]" +# expect+1: Invalid modifier ":[99333000222000111000]" .if ${word:L:[99333000222000111000]} .endif -# expect+1: Bad modifier ":[2147483648]" +# expect+1: Invalid modifier ":[2147483648]" .if ${word:L:[2147483648]} .endif @@ -172,7 +182,7 @@ ${:U }= <space> .if ${word:L:@w@$w$@} != "word" . error .endif -# expect+1: Bad modifier ":[$]" +# expect+1: Invalid modifier ":[$]" .if ${word:[$]} . error .else @@ -229,3 +239,12 @@ VAR_DOLLAR= VAR$$ .if ${word:L:S,d,m$,} != "worm\$" . error .endif + +.undef VAR +# expect+1: Missing delimiter ':' after modifier "L" +.if ${VAR:LAR=ALUE} != "VALUE" +. error +.endif +.if ${VAR:L:AR=ALUE} != "VALUE" +. error +.endif diff --git a/unit-tests/varname-dollar.exp b/unit-tests/varname-dollar.exp index 4f7c2ebbdf12..08832792e35c 100644 --- a/unit-tests/varname-dollar.exp +++ b/unit-tests/varname-dollar.exp @@ -1,5 +1,5 @@ -make: "varname-dollar.mk" line 17: dollar is $. -make: "varname-dollar.mk" line 19: dollar in braces is . -make: "varname-dollar.mk" line 28: dollar is $. -make: "varname-dollar.mk" line 30: dollar in braces is dollar. +make: varname-dollar.mk:17: dollar is $. +make: varname-dollar.mk:19: dollar in braces is . +make: varname-dollar.mk:28: dollar is $. +make: varname-dollar.mk:30: dollar in braces is dollar. exit status 0 diff --git a/unit-tests/varname-dot-make-level.exp b/unit-tests/varname-dot-make-level.exp index 005bc85bed0f..63dcf58c6569 100644 --- a/unit-tests/varname-dot-make-level.exp +++ b/unit-tests/varname-dot-make-level.exp @@ -1,12 +1,11 @@ level 1: variable 0, env 1 level 2: variable 1, env 2 level 3: variable 2, env 3 +: set-env-same +ok +: set-env-different make: Cannot override read-only global variable ".MAKE.LEVEL.ENV" with a command line variable make: Fatal errors encountered -- cannot continue -make: stopped in unit-tests -*** Error code 1 (continuing) -`all' not remade because of errors. - -Stop. -make: stopped making "all" in unit-tests -exit status 1 +make: stopped making "ok" in unit-tests +set-env-different: exit 1 +exit status 0 diff --git a/unit-tests/varname-dot-make-level.mk b/unit-tests/varname-dot-make-level.mk index c4b6dc90028e..a85fbeb53b4c 100644 --- a/unit-tests/varname-dot-make-level.mk +++ b/unit-tests/varname-dot-make-level.mk @@ -1,29 +1,55 @@ -# $NetBSD: varname-dot-make-level.mk,v 1.5 2024/11/23 22:59:51 rillig Exp $ +# $NetBSD: varname-dot-make-level.mk,v 1.6 2025/03/22 12:23:00 rillig Exp $ # # Tests for the special .MAKE.LEVEL variable, which informs about the # recursion level. It is related to the environment variable MAKELEVEL, # even though they don't have the same value. -all: level_1 set-env +all: .PHONY level_1 set-env-same set-env-different +# expect: level 1: variable 0, env 1 level_1: .PHONY @printf 'level 1: variable %s, env %s\n' ${.MAKE.LEVEL} "$$${.MAKE.LEVEL.ENV}" @${MAKE} -f ${MAKEFILE} level_2 +# expect: level 2: variable 1, env 2 level_2: .PHONY @printf 'level 2: variable %s, env %s\n' ${.MAKE.LEVEL} "$$${.MAKE.LEVEL.ENV}" @${MAKE} -f ${MAKEFILE} level_3 -level_3: .PHONY - @printf 'level 3: variable %s, env %s\n' ${.MAKE.LEVEL} "$$${.MAKE.LEVEL.ENV}" - # The .unexport-env directive clears the environment, except for the -# MAKE_LEVEL variable. +# .MAKE.LEVEL.ENV make variable, which by default refers to the MAKELEVEL +# environment variable. .if make(level_2) .unexport-env .endif +# expect: level 3: variable 2, env 3 +level_3: .PHONY + @printf 'level 3: variable %s, env %s\n' ${.MAKE.LEVEL} "$$${.MAKE.LEVEL.ENV}" + + +# When a variable assignment from the command line tries to override a +# read-only global variable with the same value as before, ignore the +# assignment, as the variable value would not change. +# +# This special case allows older versions of make to coexist with newer +# versions of make. Older version of make (up to NetBSD 9) stored the internal +# .MAKE.LEVEL.ENV variable in the scope for command line variables, and these +# variables were passed to sub-makes via .MAKEOVERRIDES and the MAKEFLAGS +# environment variable. Newer versions of make (since NetBSD 11) store the +# internal .MAKE.LEVEL.ENV variable in the global scope but make it read-only +# and prevent any attempts to override it. +# +# https://gnats.netbsd.org/59184 +set-env-same: .PHONY + : ${.TARGET} + @${MAKE} -f ${MAKEFILE} ok .MAKE.LEVEL.ENV=${.MAKE.LEVEL.ENV} || echo "${.TARGET}: exit $$?" + # expect: make: Cannot override read-only global variable ".MAKE.LEVEL.ENV" with a command line variable -set-env: - @${MAKE} -f /dev/null .MAKE.LEVEL.ENV=MAKELEVEL +set-env-different: .PHONY + : ${.TARGET} + @${MAKE} -f ${MAKEFILE} ok .MAKE.LEVEL.ENV=CUSTOM || echo "${.TARGET}: exit $$?" + +ok: .PHONY + @echo ok diff --git a/unit-tests/varname-dot-make-meta-ignore_filter.exp b/unit-tests/varname-dot-make-meta-ignore_filter.exp index 045d26dc080e..0422b06d5d63 100644 --- a/unit-tests/varname-dot-make-meta-ignore_filter.exp +++ b/unit-tests/varname-dot-make-meta-ignore_filter.exp @@ -5,7 +5,7 @@ Use .MAKE.META.IGNORE_FILTER - check-ignore is up to date `check-ignore' is up to date. Skipping meta for .END: .SPECIAL Skip .MAKE.META.IGNORE_FILTER - check-ignore is out of date -<tmpdir>/obj/check-ignore.meta: <line>: file '<tmpdir>/ignore/check' is newer than the target... +<tmpdir>/obj/check-ignore.meta:<line>: file '<tmpdir>/ignore/check' is newer than the target... Building <tmpdir>/obj/check-ignore Skipping meta for .END: .SPECIAL exit status 0 diff --git a/unit-tests/varname-dot-make-meta-ignore_paths.exp b/unit-tests/varname-dot-make-meta-ignore_paths.exp index 161d09c2eff4..7f2d61e4feb1 100644 --- a/unit-tests/varname-dot-make-meta-ignore_paths.exp +++ b/unit-tests/varname-dot-make-meta-ignore_paths.exp @@ -5,7 +5,7 @@ Use .MAKE.META.IGNORE_PATHS - check-ignore is up to date `check-ignore' is up to date. Skipping meta for .END: .SPECIAL Skip .MAKE.META.IGNORE_PATHS - check-ignore is out of date -<tmpdir>/obj/check-ignore.meta: <line>: file '<tmpdir>/ignore/check' is newer than the target... +<tmpdir>/obj/check-ignore.meta:<line>: file '<tmpdir>/ignore/check' is newer than the target... Building <tmpdir>/obj/check-ignore Skipping meta for .END: .SPECIAL exit status 0 diff --git a/unit-tests/varname-dot-make-meta-ignore_patterns.exp b/unit-tests/varname-dot-make-meta-ignore_patterns.exp index ebc1c0c6261c..2b417e5b9e5a 100644 --- a/unit-tests/varname-dot-make-meta-ignore_patterns.exp +++ b/unit-tests/varname-dot-make-meta-ignore_patterns.exp @@ -5,7 +5,7 @@ Use .MAKE.META.IGNORE_PATTERNS - check-ignore is up to date `check-ignore' is up to date. Skipping meta for .END: .SPECIAL Skip .MAKE.META.IGNORE_PATTERNS - check-ignore is out of date -<tmpdir>/obj/check-ignore.meta: <line>: file '<tmpdir>/ignore/check' is newer than the target... +<tmpdir>/obj/check-ignore.meta:<line>: file '<tmpdir>/ignore/check' is newer than the target... Building <tmpdir>/obj/check-ignore Skipping meta for .END: .SPECIAL exit status 0 diff --git a/unit-tests/varname-dot-makeflags.exp b/unit-tests/varname-dot-makeflags.exp index 8004ab40a363..c5d5b120324c 100644 --- a/unit-tests/varname-dot-makeflags.exp +++ b/unit-tests/varname-dot-makeflags.exp @@ -1,9 +1,9 @@ -make: "varname-dot-makeflags.mk" line 11: MAKEFLAGS=<undefined> -make: "varname-dot-makeflags.mk" line 13: .MAKEFLAGS=< -r -k> -make: "varname-dot-makeflags.mk" line 15: .MAKEOVERRIDES=<> -make: "varname-dot-makeflags.mk" line 21: MAKEFLAGS=<undefined> -make: "varname-dot-makeflags.mk" line 23: .MAKEFLAGS=< -r -k -D VARNAME -r> -make: "varname-dot-makeflags.mk" line 25: .MAKEOVERRIDES=< VAR> +make: varname-dot-makeflags.mk:11: MAKEFLAGS=<undefined> +make: varname-dot-makeflags.mk:13: .MAKEFLAGS=< -r -k> +make: varname-dot-makeflags.mk:15: .MAKEOVERRIDES=<> +make: varname-dot-makeflags.mk:21: MAKEFLAGS=<undefined> +make: varname-dot-makeflags.mk:23: .MAKEFLAGS=< -r -k -D VARNAME -r> +make: varname-dot-makeflags.mk:25: .MAKEOVERRIDES=< VAR> runtime: MAKEFLAGS=< -r -k -D VARNAME -r VAR=value> runtime: .MAKEFLAGS=< -r -k -D VARNAME -r> runtime: .MAKEOVERRIDES=< VAR> diff --git a/unit-tests/varname-dot-newline.exp b/unit-tests/varname-dot-newline.exp index 6817b2a26339..6358d076ed5f 100644 --- a/unit-tests/varname-dot-newline.exp +++ b/unit-tests/varname-dot-newline.exp @@ -1,8 +1,8 @@ -make: "varname-dot-newline.mk" line 28: Cannot overwrite ".newline" as it is read-only +make: varname-dot-newline.mk:28: Cannot overwrite ".newline" as it is read-only in directory <curdir> -make: "varname-dot-newline.mk" line 30: Cannot append to ".newline" as it is read-only +make: varname-dot-newline.mk:30: Cannot append to ".newline" as it is read-only in directory <curdir> -make: "varname-dot-newline.mk" line 32: Cannot delete ".newline" as it is read-only +make: varname-dot-newline.mk:32: Cannot delete ".newline" as it is read-only in directory <curdir> make: Fatal errors encountered -- cannot continue make: stopped making "try-to-modify" in unit-tests diff --git a/unit-tests/varname-dot-parsedir.exp b/unit-tests/varname-dot-parsedir.exp index 4ac953c813cd..27fcf0627a81 100644 --- a/unit-tests/varname-dot-parsedir.exp +++ b/unit-tests/varname-dot-parsedir.exp @@ -1,5 +1,5 @@ -make: "varname-dot-parsedir.mk" line 37: At this point, .PARSEDIR is undefined. -make: "<normalized>" line 43: The location can be faked in some cases. -make: "varname-dot-parsedir.mk" line 48: The location is no longer fake. +make: varname-dot-parsedir.mk:37: At this point, .PARSEDIR is undefined. +make: <normalized>:43: The location can be faked in some cases. +make: varname-dot-parsedir.mk:48: The location is no longer fake. At run time, .PARSEDIR is undefined. exit status 0 diff --git a/unit-tests/varname-dot-parsefile.exp b/unit-tests/varname-dot-parsefile.exp index 651666ebcf24..c0262798c3b3 100644 --- a/unit-tests/varname-dot-parsefile.exp +++ b/unit-tests/varname-dot-parsefile.exp @@ -1,5 +1,5 @@ -make: "varname-dot-parsefile.mk" line 32: At this point, .PARSEFILE is undefined. -make: "<normalized>" line 38: The location can be faked in some cases. -make: "varname-dot-parsefile.mk" line 43: The location is no longer fake. +make: varname-dot-parsefile.mk:32: At this point, .PARSEFILE is undefined. +make: <normalized>:38: The location can be faked in some cases. +make: varname-dot-parsefile.mk:43: The location is no longer fake. At run time, .PARSEFILE is undefined. exit status 0 diff --git a/unit-tests/varname.exp b/unit-tests/varname.exp index 46e6d13d41bd..4886477c6125 100644 --- a/unit-tests/varname.exp +++ b/unit-tests/varname.exp @@ -5,13 +5,13 @@ Var_Parse: ${VARNAME} (eval) Global: VAR((( = 3 open parentheses Var_Parse: ${VAR(((}}}}" != "3 open parentheses}}}" (eval) Global: .ALLTARGETS = VAR(((=) -make: "varname.mk" line 32: Missing ')' in archive specification -make: "varname.mk" line 32: Error in archive specification: "VAR" +make: varname.mk:32: Missing ')' in archive specification +make: varname.mk:32: Error in archive specification: "VAR" Var_Parse: ${:UVAR\(\(\(}= try2 (eval) Evaluating modifier ${:U...} on value "" (eval, undefined) Result of ${:UVAR\(\(\(} is "VAR\(\(\(" (eval, defined) Global: .ALLTARGETS = VAR(((=) VAR\(\(\(= -make: "varname.mk" line 38: Invalid line '${:UVAR\(\(\(}= try2', expanded to 'VAR\(\(\(= try2' +make: varname.mk:38: Invalid line '${:UVAR\(\(\(}= try2', expanded to 'VAR\(\(\(= try2' Var_Parse: ${VARNAME} (eval) Global: VAR((( = try3 Global: .MAKEFLAGS = -r -k -d v -d diff --git a/unit-tests/varparse-dynamic.exp b/unit-tests/varparse-dynamic.exp index 940c61163b9c..22cc15b41307 100644 --- a/unit-tests/varparse-dynamic.exp +++ b/unit-tests/varparse-dynamic.exp @@ -1,5 +1,5 @@ -make: "varparse-dynamic.mk" line 9: Variable ".TARGEX" is undefined -make: "varparse-dynamic.mk" line 12: Variable ".TARGXX" is undefined +make: varparse-dynamic.mk:9: Variable ".TARGEX" is undefined +make: varparse-dynamic.mk:12: Variable ".TARGXX" is undefined make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 diff --git a/unit-tests/varparse-errors.exp b/unit-tests/varparse-errors.exp index b2212cb8baf0..d4d01c96627e 100644 --- a/unit-tests/varparse-errors.exp +++ b/unit-tests/varparse-errors.exp @@ -1,45 +1,52 @@ -make: "varparse-errors.mk" line 38: Unknown modifier "Z" +make: varparse-errors.mk:38: Unknown modifier ":Z" while evaluating "${:U:Z}" with value "" -make: "varparse-errors.mk" line 47: Unknown modifier "Z" +make: varparse-errors.mk:47: Unknown modifier ":Z" while evaluating "${:U:Z}post" with value "" -make: "varparse-errors.mk" line 73: Bad modifier ":OX" +make: varparse-errors.mk:73: Unknown modifier ":OX" while evaluating "${:U:OX:U${IND}} ${:U:OX:U${IND}}" with value "" -make: "varparse-errors.mk" line 73: Bad modifier ":OX" +make: varparse-errors.mk:73: Unknown modifier ":OX" while evaluating "${:OX}" with value "" while evaluating variable "IND" with value "${:OX}" -make: "varparse-errors.mk" line 73: Bad modifier ":OX" +make: varparse-errors.mk:73: Unknown modifier ":OX" while evaluating "${:U:OX:U${IND}}" with value "" -make: "varparse-errors.mk" line 73: Bad modifier ":OX" +make: varparse-errors.mk:73: Unknown modifier ":OX" while evaluating "${:OX}" with value "" while evaluating variable "IND" with value "${:OX}" -make: "varparse-errors.mk" line 81: Unclosed expression, expecting '}' for modifier "Q" +make: varparse-errors.mk:81: Unclosed expression, expecting '}' for modifier "Q" while evaluating "${:U:Q" with value "" -make: "varparse-errors.mk" line 83: Unclosed expression, expecting '}' for modifier "sh" +make: varparse-errors.mk:83: Unclosed expression, expecting '}' for modifier "sh" while evaluating "${:U:sh" with value "" -make: "varparse-errors.mk" line 85: Unclosed expression, expecting '}' for modifier "tA" +make: varparse-errors.mk:85: Unclosed expression, expecting '}' for modifier "tA" while evaluating "${:U:tA" with value "" -make: "varparse-errors.mk" line 87: Unclosed expression, expecting '}' for modifier "tsX" +make: varparse-errors.mk:87: Unclosed expression, expecting '}' for modifier "tsX" while evaluating "${:U:tsX" with value "" -make: "varparse-errors.mk" line 89: Unclosed expression, expecting '}' for modifier "ts" +make: varparse-errors.mk:89: Unclosed expression, expecting '}' for modifier "ts" while evaluating "${:U:ts" with value "" -make: "varparse-errors.mk" line 91: Unclosed expression, expecting '}' for modifier "ts\040" +make: varparse-errors.mk:91: Unclosed expression, expecting '}' for modifier "ts\040" while evaluating "${:U:ts\040" with value "" -make: "varparse-errors.mk" line 93: Unclosed expression, expecting '}' for modifier "u" +make: varparse-errors.mk:93: Unclosed expression, expecting '}' for modifier "u" while evaluating "${:U:u" with value "" -make: "varparse-errors.mk" line 95: Unclosed expression, expecting '}' for modifier "H" +make: varparse-errors.mk:95: Unclosed expression, expecting '}' for modifier "H" while evaluating "${:U:H" with value "." -make: "varparse-errors.mk" line 97: Unclosed expression, expecting '}' for modifier "[1]" +make: varparse-errors.mk:97: Unclosed expression, expecting '}' for modifier "[1]" while evaluating "${:U:[1]" with value "" -make: "varparse-errors.mk" line 99: Unclosed expression, expecting '}' for modifier "hash" +make: varparse-errors.mk:99: Unclosed expression, expecting '}' for modifier "hash" while evaluating "${:U:hash" with value "b2af338b" -make: "varparse-errors.mk" line 101: Unclosed expression, expecting '}' for modifier "range" +make: varparse-errors.mk:101: Unclosed expression, expecting '}' for modifier "range" while evaluating "${:U:range" with value "1" -make: "varparse-errors.mk" line 103: Unclosed expression, expecting '}' for modifier "_" +make: varparse-errors.mk:103: Unclosed expression, expecting '}' for modifier "_" while evaluating "${:U:_" with value "" -make: "varparse-errors.mk" line 105: Unclosed expression, expecting '}' for modifier "gmtime" +make: varparse-errors.mk:105: Unclosed expression, expecting '}' for modifier "gmtime" while evaluating "${:U:gmtime" with value "<timestamp>" -make: "varparse-errors.mk" line 107: Unclosed expression, expecting '}' for modifier "localtime" +make: varparse-errors.mk:107: Unclosed expression, expecting '}' for modifier "localtime" while evaluating "${:U:localtime" with value "<timestamp>" +make: varparse-errors.tmp:1: Unknown modifier ":Z" + while evaluating "${:Z}" with value "" + while evaluating variable "INDIRECT" with value "${:Z}" + while evaluating variable "VALUE" with value "${INDIRECT}" + in varparse-errors.tmp:1 + in varparse-errors.mk:126 +make: varparse-errors.tmp:1: make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 diff --git a/unit-tests/varparse-errors.mk b/unit-tests/varparse-errors.mk index b28ac1ec5dc1..921f2229f102 100644 --- a/unit-tests/varparse-errors.mk +++ b/unit-tests/varparse-errors.mk @@ -1,4 +1,4 @@ -# $NetBSD: varparse-errors.mk,v 1.19 2024/08/29 20:20:37 rillig Exp $ +# $NetBSD: varparse-errors.mk,v 1.24 2025/03/30 09:51:51 rillig Exp $ # Tests for parsing and evaluating all kinds of expressions. # @@ -34,7 +34,7 @@ ERR_EVAL= An evaluation error ${:Uvalue:C,.,\3,}. # As of 2020-12-01, errors in the variable name are silently ignored. # Since var.c 1.754 from 2020-12-20, unknown modifiers at parse time result # in an error message and a non-zero exit status. -# expect+1: Unknown modifier "Z" +# expect+1: Unknown modifier ":Z" VAR.${:U:Z}= unknown modifier in the variable name .if ${VAR.} != "unknown modifier in the variable name" . error @@ -43,7 +43,7 @@ VAR.${:U:Z}= unknown modifier in the variable name # As of 2020-12-01, errors in the variable name are silently ignored. # Since var.c 1.754 from 2020-12-20, unknown modifiers at parse time result # in an error message and a non-zero exit status. -# expect+1: Unknown modifier "Z" +# expect+1: Unknown modifier ":Z" VAR.${:U:Z}post= unknown modifier with text in the variable name .if ${VAR.post} != "unknown modifier with text in the variable name" . error @@ -66,10 +66,10 @@ VAR.${:U:Z}post= unknown modifier with text in the variable name # #.MAKEFLAGS: -dv IND= ${:OX} -# expect+4: Bad modifier ":OX" -# expect+3: Bad modifier ":OX" -# expect+2: Bad modifier ":OX" -# expect+1: Bad modifier ":OX" +# expect+4: Unknown modifier ":OX" +# expect+3: Unknown modifier ":OX" +# expect+2: Unknown modifier ":OX" +# expect+1: Unknown modifier ":OX" _:= ${:U:OX:U${IND}} ${:U:OX:U${IND}} #.MAKEFLAGS: -d0 @@ -105,3 +105,23 @@ UNCLOSED:= ${:U:_ UNCLOSED:= ${:U:gmtime # expect+1: Unclosed expression, expecting '}' for modifier "localtime" UNCLOSED:= ${:U:localtime + + +# In a stack trace that has both evaluation details and included files, list +# the current file twice: Once in the first line and once in the call +# hierarchy. While this is redundant, omitting the current file from the +# call hierarchy is more confusing, as the '.include' line does not contain +# the faulty expression. +# +# expect: make: varparse-errors.tmp:1: Unknown modifier ":Z" +# expect: while evaluating "${:Z}" with value "" +# expect: while evaluating variable "INDIRECT" with value "${:Z}" +# expect: while evaluating variable "VALUE" with value "${INDIRECT}" +# expect: in varparse-errors.tmp:1 +# expect: in varparse-errors.mk:126 +_!= echo '.info $${VALUE}' > varparse-errors.tmp +VALUE= ${INDIRECT} +INDIRECT= ${:Z} +# The "${.OBJDIR}/" is necessary to skip the directory cache. +.include "${.OBJDIR}/varparse-errors.tmp" +_!= rm -f varparse-errors.tmp @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1144 2025/01/11 21:21:33 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1159 2025/04/04 18:57:01 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -143,7 +143,7 @@ #endif /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1144 2025/01/11 21:21:33 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1159 2025/04/04 18:57:01 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -272,7 +272,9 @@ typedef struct SepBuf { typedef enum { VSK_TARGET, + VSK_COMMAND, VSK_VARNAME, + VSK_INDIRECT_MODIFIERS, VSK_COND, VSK_COND_THEN, VSK_COND_ELSE, @@ -383,7 +385,7 @@ EvalStack_Pop(void) evalStack.len--; } -void +bool EvalStack_PrintDetails(void) { size_t i; @@ -391,7 +393,9 @@ EvalStack_PrintDetails(void) for (i = evalStack.len; i > 0; i--) { static const char descr[][42] = { "in target", + "in command", "while evaluating variable", + "while evaluating indirect modifiers", "while evaluating condition", "while evaluating then-branch of condition", "while evaluating else-branch of condition", @@ -408,6 +412,7 @@ EvalStack_PrintDetails(void) value != NULL ? "\" with value \"" : "", value != NULL ? value : ""); } + return evalStack.len > 0; } static Var * @@ -1052,7 +1057,13 @@ Var_SetWithFlags(GNode *scope, const char *name, const char *val, * See ExistsInCmdline. */ Var *gl = VarFind(name, SCOPE_GLOBAL, false); - if (gl != NULL && gl->readOnlyLoud) + if (gl != NULL && strcmp(gl->val.data, val) == 0) { + DEBUG3(VAR, + "%s: ignoring to override the global " + "'%s = %s' from a command line variable " + "as the value wouldn't change\n", + scope->name, name, val); + } else if (gl != NULL && gl->readOnlyLoud) Parse_Error(PARSE_FATAL, "Cannot override " "read-only global variable \"%s\" " @@ -1971,10 +1982,6 @@ FormatTime(const char *fmt, time_t t, bool gmt) * 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. - * 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. */ @@ -2108,9 +2115,7 @@ typedef enum ApplyModifierResult { AMR_OK, /* Not a match, try the ':from=to' modifier as well. */ AMR_UNKNOWN, - /* Error out with "Bad modifier" message. */ - AMR_BAD, - /* Error out without the standard error message. */ + /* Error out without further error message. */ AMR_CLEANUP } ApplyModifierResult; @@ -2238,13 +2243,15 @@ ParseModifierPart( ParseModifierPartExpr(&p, part, ch, emode); } - *pp = p; if (*p != end1 && *p != end2) { Parse_Error(PARSE_FATAL, - "Unfinished modifier ('%c' missing)", end2); + "Unfinished modifier after \"%.*s\", expecting \"%c\"", + (int)(p - *pp), *pp, end2); LazyBuf_Done(part); + *pp = p; return false; } + *pp = p; if (end1 == end2) (*pp)++; @@ -3103,11 +3110,8 @@ ApplyModifier_ToSep(const char **pp, ModChain *ch) goto ok; } - /* ":ts<unrecognized><unrecognized>". */ - if (sep[0] != '\\') { - (*pp)++; /* just for backwards compatibility */ - return AMR_BAD; - } + if (sep[0] != '\\') + return AMR_UNKNOWN; /* ":ts\n" */ if (sep[1] == 'n') { @@ -3131,20 +3135,16 @@ ApplyModifier_ToSep(const char **pp, ModChain *ch) if (sep[1] == 'x') { base = 16; p++; - } else if (!ch_isdigit(sep[1])) { - (*pp)++; /* just for backwards compatibility */ - return AMR_BAD; /* ":ts<backslash><unrecognized>". */ - } + } else if (!ch_isdigit(sep[1])) + return AMR_UNKNOWN; /* ":ts\..." */ if (!TryParseChar(&p, base, &ch->sep)) { Parse_Error(PARSE_FATAL, "Invalid character number at \"%s\"", p); return AMR_CLEANUP; } - if (!IsDelimiter(*p, ch)) { - (*pp)++; /* just for backwards compatibility */ - return AMR_BAD; - } + if (!IsDelimiter(*p, ch)) + return AMR_UNKNOWN; *pp = p; } @@ -3197,18 +3197,14 @@ ApplyModifier_To(const char **pp, ModChain *ch) const char *mod = *pp; assert(mod[0] == 't'); - if (IsDelimiter(mod[1], ch)) { - *pp = mod + 1; - return AMR_BAD; /* Found ":t<endc>" or ":t:". */ - } + if (IsDelimiter(mod[1], ch)) + return AMR_UNKNOWN; /* ":t<endc>" or ":t:" */ if (mod[1] == 's') return ApplyModifier_ToSep(pp, ch); - if (!IsDelimiter(mod[2], ch)) { /* :t<any><any> */ - *pp = mod + 1; - return AMR_BAD; - } + if (!IsDelimiter(mod[2], ch)) + return AMR_UNKNOWN; if (mod[1] == 'A') { /* :tA */ *pp = mod + 2; @@ -3243,9 +3239,7 @@ ApplyModifier_To(const char **pp, ModChain *ch) return AMR_OK; } - /* Found ":t<unrecognized>:" or ":t<unrecognized><endc>". */ - *pp = mod + 1; /* XXX: unnecessary but observable */ - return AMR_BAD; + return AMR_UNKNOWN; /* ":t<any>:" or ":t<any><endc>" */ } /* :[#], :[1], :[-1..1], etc. */ @@ -3265,8 +3259,12 @@ ApplyModifier_Words(const char **pp, ModChain *ch) arg = LazyBuf_DoneGet(&argBuf); p = arg.str; - if (!IsDelimiter(**pp, ch)) - goto bad_modifier; /* Found junk after ']' */ + if (!IsDelimiter(**pp, ch)) { + Parse_Error(PARSE_FATAL, + "Extra text after \"[%s]\"", arg.str); + FStr_Done(&arg); + return AMR_CLEANUP; + } if (!ModChain_ShouldEval(ch)) goto ok; @@ -3331,8 +3329,9 @@ ok: return AMR_OK; bad_modifier: + Parse_Error(PARSE_FATAL, "Invalid modifier \":[%s]\"", arg.str); FStr_Done(&arg); - return AMR_BAD; + return AMR_CLEANUP; } #if __STDC_VERSION__ >= 199901L || defined(HAVE_LONG_LONG_INT) @@ -3445,17 +3444,17 @@ ApplyModifier_Order(const char **pp, ModChain *ch) else if (mod[1] == 'x') cmp = NULL; else - goto bad; + return AMR_UNKNOWN; *pp += 2; } else if (IsDelimiter(mod[3], ch)) { if ((mod[1] == 'n' && mod[2] == 'r') || (mod[1] == 'r' && mod[2] == 'n')) cmp = SubNumDesc; else - goto bad; + return AMR_UNKNOWN; *pp += 3; } else - goto bad; + return AMR_UNKNOWN; if (!ModChain_ShouldEval(ch)) return AMR_OK; @@ -3470,10 +3469,6 @@ ApplyModifier_Order(const char **pp, ModChain *ch) Expr_SetValueOwn(ch->expr, SubstringWords_JoinFree(words)); return AMR_OK; - -bad: - (*pp)++; - return AMR_BAD; } /* :? then : else */ @@ -3578,8 +3573,15 @@ ApplyModifier_Assign(const char **pp, ModChain *ch) found_op: if (expr->name[0] == '\0') { + const char *value = op[0] == '=' ? op + 1 : op + 2; *pp = mod + 1; - return AMR_BAD; + /* Take a guess at where the modifier ends. */ + Parse_Error(PARSE_FATAL, + "Invalid attempt to assign \"%.*s\" to variable \"\" " + "via modifier \"::%.*s\"", + (int)strcspn(value, ":)}"), value, + (int)(value - op), op); + return AMR_CLEANUP; } *pp = mod + (op[0] != '=' ? 3 : 2); @@ -3715,17 +3717,17 @@ IsSysVModifier(const char *p, char startc, char endc) bool eqFound = false; int depth = 1; - while (*p != '\0' && depth > 0) { + while (*p != '\0') { if (*p == '=') /* XXX: should also test depth == 1 */ eqFound = true; - else if (*p == endc) - depth--; - else if (*p == startc) + else if (*p == endc) { + if (--depth == 0) + break; + } else if (*p == startc) depth++; - if (depth > 0) - p++; + p++; } - return *p == endc && eqFound; + return eqFound; } /* :from=to */ @@ -3851,18 +3853,15 @@ LogAfterApply(const ModChain *ch, const char *p, const char *mod) { const Expr *expr = ch->expr; const char *value = Expr_Str(expr); - const char *quot = value == var_Error ? "" : "\""; if (ShouldLogInSimpleFormat(expr)) { - debug_printf("Result of ${%s:%.*s} is %s%s%s\n", - expr->name, (int)(p - mod), mod, - quot, value == var_Error ? "error" : value, quot); + debug_printf("Result of ${%s:%.*s} is \"%s\"\n", + expr->name, (int)(p - mod), mod, value); return; } - debug_printf("Result of ${%s:%.*s} is %s%s%s (%s, %s)\n", - expr->name, (int)(p - mod), mod, - quot, value == var_Error ? "error" : value, quot, + debug_printf("Result of ${%s:%.*s} is \"%s\" (%s, %s)\n", + expr->name, (int)(p - mod), mod, value, VarEvalMode_Name[expr->emode], ExprDefined_Name[expr->defined]); } @@ -3974,7 +3973,9 @@ ApplyModifiersIndirect(ModChain *ch, const char **pp) if (ModChain_ShouldEval(ch) && mods.str[0] != '\0') { const char *modsp = mods.str; + EvalStack_Push(VSK_INDIRECT_MODIFIERS, mods.str, NULL); ApplyModifiers(expr, &modsp, '\0', '\0'); + EvalStack_Pop(); if (Expr_Str(expr) == var_Error || *modsp != '\0') { FStr_Done(&mods); *pp = p; @@ -4008,9 +4009,14 @@ ApplySingleModifier(const char **pp, ModChain *ch) if (DEBUG(VAR)) LogBeforeApply(ch, mod); - res = ApplyModifier(&p, ch); + if (posix_state == PS_SET) + res = ApplyModifier_SysV(&p, ch); + else + res = AMR_UNKNOWN; + if (res == AMR_UNKNOWN) + res = ApplyModifier(&p, ch); - if (res == AMR_UNKNOWN) { + if (res == AMR_UNKNOWN && posix_state != PS_SET) { assert(p == mod); res = ApplyModifier_SysV(&p, ch); } @@ -4024,11 +4030,12 @@ ApplySingleModifier(const char **pp, ModChain *ch) */ for (p++; !IsDelimiter(*p, ch); p++) continue; - Parse_Error(PARSE_FATAL, "Unknown modifier \"%.*s\"", + Parse_Error(PARSE_FATAL, "Unknown modifier \":%.*s\"", (int)(p - mod), mod); Expr_SetValueRefer(ch->expr, var_Error); + res = AMR_CLEANUP; } - if (res == AMR_CLEANUP || res == AMR_BAD) { + if (res != AMR_OK) { *pp = p; return res; } @@ -4084,7 +4091,6 @@ ApplyModifiers( { ModChain ch = ModChain_Init(expr, startc, endc, ' ', false); const char *p; - const char *mod; assert(startc == '(' || startc == '{' || startc == '\0'); assert(endc == ')' || endc == '}' || endc == '\0'); @@ -4115,24 +4121,15 @@ ApplyModifiers( break; } - mod = p; - res = ApplySingleModifier(&p, &ch); if (res == AMR_CLEANUP) goto cleanup; - if (res == AMR_BAD) - goto bad_modifier; } *pp = p; assert(Expr_Str(expr) != NULL); /* Use var_Error or varUndefined. */ return; -bad_modifier: - /* Take a guess at where the modifier ends. */ - Parse_Error(PARSE_FATAL, "Bad modifier \":%.*s\"", - (int)strcspn(mod, ":)}"), mod); - cleanup: /* * TODO: Use p + strlen(p) instead, to stop parsing immediately. @@ -4341,16 +4338,18 @@ FindLocalLegacyVar(Substring varname, GNode *scope, static FStr EvalUndefined(bool dynamic, const char *start, const char *p, - Substring varname, VarEvalMode emode) + Substring varname, VarEvalMode emode, int parseErrorsBefore) { if (dynamic) return FStr_InitOwn(bmake_strsedup(start, p)); if (emode == VARE_EVAL_DEFINED_LOUD || (emode == VARE_EVAL_DEFINED && opts.strict)) { - Parse_Error(PARSE_FATAL, - "Variable \"%.*s\" is undefined", - (int)Substring_Length(varname), varname.start); + if (parseErrors == parseErrorsBefore) { + Parse_Error(PARSE_FATAL, + "Variable \"%.*s\" is undefined", + (int) Substring_Length(varname), varname.start); + } return FStr_InitRefer(var_Error); } @@ -4372,6 +4371,7 @@ ParseVarnameLong( GNode *scope, VarEvalMode emode, VarEvalMode nested_emode, + int parseErrorsBefore, const char **out_false_pp, FStr *out_false_val, @@ -4438,7 +4438,7 @@ ParseVarnameLong( p++; /* skip endc */ *out_false_pp = p; *out_false_val = EvalUndefined(dynamic, start, p, - name, emode); + name, emode, parseErrorsBefore); LazyBuf_Done(&varname); return false; } @@ -4570,6 +4570,7 @@ Var_Parse(const char **pp, GNode *scope, VarEvalMode emode) ? VARE_EVAL : emode, scope, DEF_REGULAR); FStr val; + int parseErrorsBefore = parseErrors; if (Var_Parse_U(pp, emode, &val)) return val; @@ -4592,6 +4593,7 @@ Var_Parse(const char **pp, GNode *scope, VarEvalMode emode) p++; } else { if (!ParseVarnameLong(&p, startc, scope, emode, expr.emode, + parseErrorsBefore, pp, &val, &endc, &v, &haveModifier, &extramodifiers, &dynamic, &expr.defined)) @@ -4666,14 +4668,10 @@ Var_Parse(const char **pp, GNode *scope, VarEvalMode emode) *pp = p; if (expr.defined == DEF_UNDEF) { - if (dynamic) - Expr_SetValueOwn(&expr, bmake_strsedup(start, p)); - else { - Expr_SetValueRefer(&expr, - emode == VARE_EVAL_DEFINED - || emode == VARE_EVAL_DEFINED_LOUD - ? var_Error : varUndefined); - } + Substring varname = Substring_InitStr(expr.name); + FStr value = EvalUndefined(dynamic, start, p, varname, emode, + parseErrorsBefore); + Expr_SetValue(&expr, value); } if (v->shortLived) { @@ -4782,8 +4780,10 @@ Var_SubstInTarget(const char *str, GNode *scope) { char *res; EvalStack_Push(VSK_TARGET, scope->name, NULL); + EvalStack_Push(VSK_COMMAND, str, NULL); res = Var_Subst(str, scope, VARE_EVAL); EvalStack_Pop(); + EvalStack_Pop(); return res; } |
