Module Name: src Committed By: rillig Date: Sun Jan 7 11:39:04 UTC 2024
Modified Files: src/usr.bin/make: job.c parse.c var.c src/usr.bin/make/unit-tests: varparse-undef-partial.mk Log Message: make: clean up comments, constify shell name To generate a diff of this commit: cvs rdiff -u -r1.464 -r1.465 src/usr.bin/make/job.c cvs rdiff -u -r1.715 -r1.716 src/usr.bin/make/parse.c cvs rdiff -u -r1.1093 -r1.1094 src/usr.bin/make/var.c cvs rdiff -u -r1.4 -r1.5 \ src/usr.bin/make/unit-tests/varparse-undef-partial.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.464 src/usr.bin/make/job.c:1.465 --- src/usr.bin/make/job.c:1.464 Sun Jan 7 01:33:57 2024 +++ src/usr.bin/make/job.c Sun Jan 7 11:39:04 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.464 2024/01/07 01:33:57 sjg Exp $ */ +/* $NetBSD: job.c,v 1.465 2024/01/07 11:39:04 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -141,7 +141,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.464 2024/01/07 01:33:57 sjg Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.465 2024/01/07 11:39:04 rillig Exp $"); /* * A shell defines how the commands are run. All commands for a target are @@ -2474,16 +2474,9 @@ Job_ParseShell(char *line) } } } else { - /* - * The user provided a path. If s/he gave nothing else - * (fullSpec is false), try and find a matching shell in the - * ones we know of. Else we just take the specification at - * its word and copy it to a new location. In either case, - * we need to record the path the user gave for the shell. - */ - char *name = path + (str_basename(path) - path); shellPath = path; - shellName = newShell.name != NULL ? newShell.name : name; + shellName = newShell.name != NULL ? newShell.name + : str_basename(path); if (!fullSpec) { if ((sh = FindShellByName(shellName)) == NULL) { Parse_Error(PARSE_WARNING, Index: src/usr.bin/make/parse.c diff -u src/usr.bin/make/parse.c:1.715 src/usr.bin/make/parse.c:1.716 --- src/usr.bin/make/parse.c:1.715 Fri Jan 5 23:22:06 2024 +++ src/usr.bin/make/parse.c Sun Jan 7 11:39:04 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.715 2024/01/05 23:22:06 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.716 2024/01/07 11:39:04 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -105,7 +105,7 @@ #include "pathnames.h" /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: parse.c,v 1.715 2024/01/05 23:22:06 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.716 2024/01/07 11:39:04 rillig Exp $"); /* Detects a multiple-inclusion guard in a makefile. */ typedef enum { @@ -115,9 +115,7 @@ typedef enum { GS_NO /* the file is not guarded */ } GuardState; -/* - * A file being read. - */ +/* A file being parsed. */ typedef struct IncludedFile { FStr name; /* absolute or relative to the cwd */ unsigned lineno; /* 1-based */ @@ -2901,13 +2899,6 @@ ParseDependencyLine(char *line) static void ParseLine(char *line) { - /* - * Lines that begin with '.' can be pretty much anything: - * - directives like '.include' or '.if', - * - suffix rules like '.c.o:', - * - dependencies for filenames that start with '.', - * - variable assignments like '.tmp=value'. - */ if (line[0] == '.' && ParseDirective(line)) return; Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.1093 src/usr.bin/make/var.c:1.1094 --- src/usr.bin/make/var.c:1.1093 Fri Jan 5 23:22:06 2024 +++ src/usr.bin/make/var.c Sun Jan 7 11:39:04 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1093 2024/01/05 23:22:06 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1094 2024/01/07 11:39:04 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -139,7 +139,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1093 2024/01/05 23:22:06 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1094 2024/01/07 11:39:04 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -1859,15 +1859,15 @@ FormatTime(const char *fmt, time_t t, bo * Some modifiers such as ':sh' or '::=' have noticeable side effects though. * * Evaluating the modifier usually takes the current value of the - * expression from ch->expr->value, or the variable name from ch->var->name + * expression from ch->expr->value, or the variable name from ch->var->name, * and stores the result back in ch->expr->value via Expr_SetValueOwn or * Expr_SetValueRefer. * - * If evaluating fails (as of 2020-08-23), an error message is printed using - * Error. This function has no side effects, it really just prints the error - * message. Processing the expression continues as if everything were ok. - * TODO: This should be fixed by adding proper error handling to Var_Subst, - * Var_Parse, ApplyModifiers and ModifyWords. + * If evaluating fails, the fallback error message "Bad modifier" is printed + * using Error. This function has no side effects, it really just prints the + * error message, continuing as if nothing had happened. TODO: This should be + * fixed by adding proper error handling to Var_Subst, Var_Parse, + * ApplyModifiers and ModifyWords. * * Some modifiers such as :D and :U turn undefined expressions into defined * expressions using Expr_Define. @@ -1936,7 +1936,7 @@ typedef struct ModChain { char const_member startc; /* '\0' or '}' or ')' */ char const_member endc; - /* Word separator when joining words (see the :ts modifier). */ + /* Separator when joining words (see the :ts modifier). */ char sep; /* * Whether some modifiers that otherwise split the variable value @@ -4598,10 +4598,10 @@ VarSubstExpr(const char **pp, Buffer *bu } else if (val.str == var_Error) { /* - * XXX: This condition is wrong. If val == var_Error, - * this doesn't necessarily mean there was an undefined - * variable. It could equally well be a parse error; - * see unit-tests/varmod-order.exp. + * FIXME: The condition 'val.str == var_Error' doesn't + * mean there was an undefined variable. It could + * equally well be a parse error; see + * unit-tests/varmod-order.mk. */ /* @@ -4612,10 +4612,10 @@ VarSubstExpr(const char **pp, Buffer *bu if (!*inout_errorReported) { Parse_Error(PARSE_FATAL, "Undefined variable \"%.*s\"", - (int)(size_t)(nested_p - p), p); + (int)(nested_p - p), p); + *inout_errorReported = true; } p = nested_p; - *inout_errorReported = true; } else { /* * Copy the initial '$' of the undefined expression, Index: src/usr.bin/make/unit-tests/varparse-undef-partial.mk diff -u src/usr.bin/make/unit-tests/varparse-undef-partial.mk:1.4 src/usr.bin/make/unit-tests/varparse-undef-partial.mk:1.5 --- src/usr.bin/make/unit-tests/varparse-undef-partial.mk:1.4 Sun Nov 19 21:47:52 2023 +++ src/usr.bin/make/unit-tests/varparse-undef-partial.mk Sun Jan 7 11:39:04 2024 @@ -1,4 +1,4 @@ -# $NetBSD: varparse-undef-partial.mk,v 1.4 2023/11/19 21:47:52 rillig Exp $ +# $NetBSD: varparse-undef-partial.mk,v 1.5 2024/01/07 11:39:04 rillig Exp $ # When an undefined variable is expanded in a ':=' assignment, only the # initial '$' of the expression is skipped by the parser, while @@ -11,9 +11,8 @@ PARAM= :Q # The expression ${VAR.${PARAM}} refers to the variable named "VAR.:Q", # with the ":Q" being part of the name. This variable is not defined, -# therefore the initial '$' of that whole expression is skipped by the -# parser (see Var_Subst, the Buf_AddByte in the else branch) and the rest -# of the expression is expanded as usual. +# therefore the initial '$' of that whole expression is skipped by the parser +# (see VarSubstExpr) and the rest of the expression is expanded as usual. # # The resulting expression is ${VAR.:Q}, which means that the # interpretation of the ":Q" has changed from being part of the variable