Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make Add a knob .MAKE.SAVE_DOLLARS to control the be...



details:   https://anonhg.NetBSD.org/src/rev/0f6cabe4d752
branches:  trunk
changeset: 813810:0f6cabe4d752
user:      sjg <sjg%NetBSD.org@localhost>
date:      Sat Feb 20 01:19:03 2016 +0000

description:
Add a knob .MAKE.SAVE_DOLLARS to control the behavior of $$ during :=

If TRUE '$$' are not consumed (saved).
If FALSE '$$' becomes '$' just like normal expansion rules.

default is TRUE.

Reviewed by: christos

diffstat:

 usr.bin/make/make.1 |  16 ++++++++++++++--
 usr.bin/make/var.c  |  24 +++++++++++++++++++-----
 2 files changed, 33 insertions(+), 7 deletions(-)

diffs (102 lines):

diff -r 027a06cc7268 -r 0f6cabe4d752 usr.bin/make/make.1
--- a/usr.bin/make/make.1       Fri Feb 19 22:09:09 2016 +0000
+++ b/usr.bin/make/make.1       Sat Feb 20 01:19:03 2016 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: make.1,v 1.252 2016/02/18 20:25:08 sjg Exp $
+.\"    $NetBSD: make.1,v 1.253 2016/02/20 01:19:03 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 February 18, 2016
+.Dd February 19, 2016
 .Dt MAKE 1
 .Os
 .Sh NAME
@@ -941,6 +941,18 @@
 .It Va .MAKE.PPID
 The parent process-id of
 .Nm .
+.It Va .MAKE.SAVE_DOLLARS
+value should be a boolen that controls wether
+.Ql $$
+are preserved when doing
+.Ql :=
+assignments.
+The default is true, for compatability with other makes.
+If set to false,
+.Ql $$
+becomes
+.Ql $
+per normal evaluation rules.
 .It Va MAKE_PRINT_VAR_ON_ERROR
 When
 .Nm
diff -r 027a06cc7268 -r 0f6cabe4d752 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Fri Feb 19 22:09:09 2016 +0000
+++ b/usr.bin/make/var.c        Sat Feb 20 01:19:03 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.204 2016/02/18 23:33:25 sjg Exp $    */
+/*     $NetBSD: var.c,v 1.205 2016/02/20 01:19:03 sjg Exp $    */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.204 2016/02/18 23:33:25 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.205 2016/02/20 01:19:03 sjg Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c      8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.204 2016/02/18 23:33:25 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.205 2016/02/20 01:19:03 sjg Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -162,6 +162,16 @@
 static char    varNoError[] = "";
 
 /*
+ * Traditionally we consume $$ during := like any other expansion.
+ * Other make's do not.
+ * This knob allows controlling the behavior.
+ * FALSE for old behavior.
+ * TRUE for new compatible.
+ */
+#define SAVE_DOLLARS ".MAKE.SAVE_DOLLARS"
+static Boolean save_dollars = TRUE;
+
+/*
  * Internally, variables are contained in four different contexts.
  *     1) the environment. They may not be changed. If an environment
  *         variable is appended-to, the result is placed in the global
@@ -992,7 +1002,11 @@
 
        Var_Append(MAKEOVERRIDES, name, VAR_GLOBAL);
     }
-       
+    if (*name == '.') {
+       if (strcmp(name, SAVE_DOLLARS) == 0)
+           save_dollars = s2Boolean(val, save_dollars);
+    }
+
  out:
     free(expanded_name);
     if (v != NULL)
@@ -3989,7 +4003,7 @@
             * In such a case, we skip over the escape character and store the
             * dollar sign into the buffer directly.
             */
-           if (flags & VARF_ASSIGN)
+           if (save_dollars && (flags & VARF_ASSIGN))
                Buf_AddByte(&buf, *str);
            str++;
            Buf_AddByte(&buf, *str);



Home | Main Index | Thread Index | Old Index