Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make Since we are avoiding VAR_INTERNAL, allow the v...
details: https://anonhg.NetBSD.org/src/rev/80790d60fe8d
branches: trunk
changeset: 351085:80790d60fe8d
user: sjg <sjg%NetBSD.org@localhost>
date: Wed Feb 01 18:39:27 2017 +0000
description:
Since we are avoiding VAR_INTERNAL, allow the variable :_ stores to
to be specified, also allows for multiple stages of modification to
be stashed.
diffstat:
usr.bin/make/make.1 | 16 +++++++---------
usr.bin/make/var.c | 27 ++++++++++++++++++++-------
2 files changed, 27 insertions(+), 16 deletions(-)
diffs (103 lines):
diff -r 00ff316d6b9b -r 80790d60fe8d usr.bin/make/make.1
--- a/usr.bin/make/make.1 Wed Feb 01 18:24:22 2017 +0000
+++ b/usr.bin/make/make.1 Wed Feb 01 18:39:27 2017 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: make.1,v 1.265 2017/01/30 02:46:20 sjg Exp $
+.\" $NetBSD: make.1,v 1.266 2017/02/01 18:39:27 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 January 29, 2017
+.Dd February 1, 2017
.Dt MAKE 1
.Os
.Sh NAME
@@ -1425,24 +1425,22 @@
.Pp
However a single character variable is often more readable:
.Dl ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}
-.It Cm \&:_
+.It Cm \&:_[=var]
Save the current variable value in
.Ql $_
+or the named
+.Va var
for later reference.
-This
-.Ql $_
-is internal to the variable modifier processing and
-will not conflict with any set in a makefile.
Example usage:
.Bd -literal -offset indent
-M_cmpv.units = 1 100 10000
+M_cmpv.units = 1 1000 1000000
M_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \&\\
\\* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh
.Dv .if ${VERSION:${M_cmpv}} < ${3.1.12:L:${M_cmpv}}
.Ed
-Here the
+Here
.Ql $_
is used to save the result of the
.Ql :S
diff -r 00ff316d6b9b -r 80790d60fe8d usr.bin/make/var.c
--- a/usr.bin/make/var.c Wed Feb 01 18:24:22 2017 +0000
+++ b/usr.bin/make/var.c Wed Feb 01 18:39:27 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.212 2017/02/01 18:00:14 sjg Exp $ */
+/* $NetBSD: var.c,v 1.213 2017/02/01 18:39:27 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.212 2017/02/01 18:00:14 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.213 2017/02/01 18:39:27 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.212 2017/02/01 18:00:14 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.213 2017/02/01 18:39:27 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -2742,11 +2742,24 @@
break;
}
case '_': /* remember current value */
- if CHARMOD_MATCH(tstr[1]) {
- Var_Set("_", nstr, ctxt, 0);
+ cp = tstr + 1; /* make sure it is set */
+ if (STRMOD_MATCHX(tstr, "_", 1)) {
+ if (tstr[1] == '=') {
+ char *np;
+ int n;
+
+ cp++;
+ n = strcspn(cp, ":)}");
+ np = bmake_strndup(cp, n+1);
+ np[n] = '\0';
+ cp = tstr + 2 + n;
+ Var_Set(np, nstr, ctxt, 0);
+ free(np);
+ } else {
+ Var_Set("_", nstr, ctxt, 0);
+ }
newStr = nstr;
- cp = ++tstr;
- termc = *tstr;
+ termc = *cp;
break;
}
goto default_case;
Home |
Main Index |
Thread Index |
Old Index