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/b6afe4f17302
branches: trunk
changeset: 955578:b6afe4f17302
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 da9d039834d8 -r b6afe4f17302 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 da9d039834d8 -r b6afe4f17302 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 da9d039834d8 -r b6afe4f17302 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