Module Name: src Committed By: sjg Date: Wed Feb 1 18:39:27 UTC 2017
Modified Files: src/usr.bin/make: make.1 var.c Log Message: Since we are avoiding VAR_INTERNAL, allow the variable :_ stores to to be specified, also allows for multiple stages of modification to be stashed. To generate a diff of this commit: cvs rdiff -u -r1.265 -r1.266 src/usr.bin/make/make.1 cvs rdiff -u -r1.212 -r1.213 src/usr.bin/make/var.c 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/make.1 diff -u src/usr.bin/make/make.1:1.265 src/usr.bin/make/make.1:1.266 --- src/usr.bin/make/make.1:1.265 Mon Jan 30 02:46:20 2017 +++ src/usr.bin/make/make.1 Wed Feb 1 18:39:27 2017 @@ -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 @@ For example. .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 Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.212 src/usr.bin/make/var.c:1.213 --- src/usr.bin/make/var.c:1.212 Wed Feb 1 18:00:14 2017 +++ src/usr.bin/make/var.c Wed Feb 1 18:39:27 2017 @@ -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 @@ ApplyModifiers(char *nstr, const char *t 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;