Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): only use the VARE_ASSIGN flag if neces...
details: https://anonhg.NetBSD.org/src/rev/18c820819628
branches: trunk
changeset: 976802:18c820819628
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Oct 04 10:35:25 2020 +0000
description:
make(1): only use the VARE_ASSIGN flag if necessary
When checking the right-hand side of a variable assignment for syntax
errors, it does not matter whether a '$$' is expanded to '$' or kept as
'$$'.
diffstat:
usr.bin/make/nonints.h | 5 ++++-
usr.bin/make/parse.c | 9 +++++----
usr.bin/make/var.c | 10 +++-------
3 files changed, 12 insertions(+), 12 deletions(-)
diffs (86 lines):
diff -r 304be8f62172 -r 18c820819628 usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h Sun Oct 04 10:34:18 2020 +0000
+++ b/usr.bin/make/nonints.h Sun Oct 04 10:35:25 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nonints.h,v 1.134 2020/10/03 15:00:57 rillig Exp $ */
+/* $NetBSD: nonints.h,v 1.135 2020/10/04 10:35:25 rillig Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@@ -192,10 +192,13 @@
/* var.c */
typedef enum {
+ VARE_NONE = 0,
/* Treat undefined variables as errors. */
VARE_UNDEFERR = 0x01,
/* Expand and evaluate variables during parsing. */
VARE_WANTRES = 0x02,
+ /* In an assignment using the ':=' operator, keep '$$' as '$$' instead
+ * of reducing it to a single '$'. */
VARE_ASSIGN = 0x04
} VarEvalFlags;
diff -r 304be8f62172 -r 18c820819628 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Sun Oct 04 10:34:18 2020 +0000
+++ b/usr.bin/make/parse.c Sun Oct 04 10:35:25 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.349 2020/10/04 07:49:45 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.350 2020/10/04 10:35:25 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.349 2020/10/04 07:49:45 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.350 2020/10/04 10:35:25 rillig Exp $");
/* types and constants */
@@ -1845,10 +1845,11 @@
if (DEBUG(LINT)) {
if (type != VAR_SUBST && strchr(cp, '$') != NULL) {
- /* sanity check now */
+ /* Check for syntax errors such as unclosed expressions or
+ * unknown modifiers. */
char *expandedValue;
- (void)Var_Subst(cp, ctxt, VARE_ASSIGN, &expandedValue);
+ (void)Var_Subst(cp, ctxt, VARE_NONE, &expandedValue);
/* TODO: handle errors */
free(expandedValue);
}
diff -r 304be8f62172 -r 18c820819628 usr.bin/make/var.c
--- a/usr.bin/make/var.c Sun Oct 04 10:34:18 2020 +0000
+++ b/usr.bin/make/var.c Sun Oct 04 10:35:25 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.564 2020/10/03 21:19:54 rillig Exp $ */
+/* $NetBSD: var.c,v 1.565 2020/10/04 10:35:25 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.564 2020/10/03 21:19:54 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.565 2020/10/04 10:35:25 rillig Exp $");
#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -3768,11 +3768,7 @@
while (*p != '\0') {
if (p[0] == '$' && p[1] == '$') {
- /*
- * A dollar sign may be escaped with another dollar sign.
- * In such a case, we skip over the escape character and store the
- * dollar sign into the buffer directly.
- */
+ /* A dollar sign may be escaped with another dollar sign. */
if (save_dollars && (eflags & VARE_ASSIGN))
Buf_AddByte(&buf, '$');
Buf_AddByte(&buf, '$');
Home |
Main Index |
Thread Index |
Old Index