Update man page and add test case for specifying modifiers via variable.
Also allow said variable to appear anywhere in the modifier list.
This commit is contained in:
parent
016de84c5b
commit
2bc18a45e6
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: make.1,v 1.119 2006/01/22 19:54:55 dsl Exp $
|
||||
.\" $NetBSD: make.1,v 1.120 2006/02/26 21:43:00 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 22, 2006
|
||||
.Dd Feburary 26, 2006
|
||||
.Dt MAKE 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -694,11 +694,24 @@ Variable expansion may be modified to select or modify each word of the
|
|||
variable (where a ``word'' is white-space delimited sequence of characters).
|
||||
The general format of a variable expansion is as follows:
|
||||
.Pp
|
||||
.Dl {variable[:modifier[:...]]}
|
||||
.Dl ${variable[:modifier[:...]]}
|
||||
.Pp
|
||||
Each modifier begins with a colon,
|
||||
which may be escaped with a backslash
|
||||
.Pq Ql \e .
|
||||
.Pp
|
||||
A set of modifiers can be specified via a variable, as follows:
|
||||
.Pp
|
||||
.Dl modifier_variable=modifier[:...]
|
||||
.Dl ${variable:${modifier_variable}[:...]}
|
||||
.Pp
|
||||
In this case the first modifier in the modifier_variable does not
|
||||
start with a colon, since that must appear in the referencing
|
||||
variable.
|
||||
If any of the modifiers in the modifier_variable contain a dollar sign
|
||||
.Pq Ql $ ,
|
||||
these must be doubled to avoid early expansion.
|
||||
.Pp
|
||||
The supported modifiers are:
|
||||
.Bl -tag -width EEE
|
||||
.It Cm \&:E
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.17 2006/02/13 18:17:36 apb Exp $
|
||||
# $NetBSD: Makefile,v 1.18 2006/02/26 21:43:01 sjg Exp $
|
||||
#
|
||||
# Unit tests for make(1)
|
||||
# The main targets are:
|
||||
|
@ -22,6 +22,7 @@ SUBFILES= \
|
|||
comment \
|
||||
cond1 \
|
||||
modmatch \
|
||||
modmisc \
|
||||
modorder \
|
||||
modts \
|
||||
modword \
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# $Id: modmisc,v 1.1 2006/02/26 21:43:01 sjg Exp $
|
||||
#
|
||||
# miscelaneous modifier tests
|
||||
|
||||
path=:/bin:/usr/bin::/sbin:/usr/sbin:.:/home/user/bin:./bin:.
|
||||
# strip cwd from path.
|
||||
MOD_NODOT=S/:/ /g:N.:ts:
|
||||
# and decorate, note that $'s need to be doubled. Also note that
|
||||
# the modifier_variable can be used with other modifiers.
|
||||
MOD_NODOTX=S/:/ /g:N.:@d@'$$d'@
|
||||
|
||||
all: modvar
|
||||
|
||||
modvar:
|
||||
@echo "path='${path}'"
|
||||
@echo "path='${path:${MOD_NODOT}}'"
|
||||
@echo "path='${path:S,home,homes,:${MOD_NODOT}}'"
|
||||
@echo "path=${path:${MOD_NODOTX}:ts:}"
|
|
@ -35,6 +35,10 @@ LIB=d X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBD.A"
|
|||
LIB=e X_LIBS:M${LIB${LIB:tu}} is "/tmp/libe.a"
|
||||
LIB=e X_LIBS:M*/lib${LIB}.a is "/tmp/libe.a"
|
||||
LIB=e X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBE.A"
|
||||
path=':/bin:/usr/bin::/sbin:/usr/sbin:.:/home/user/bin:./bin:.'
|
||||
path='/bin:/usr/bin:/sbin:/usr/sbin:/home/user/bin:./bin'
|
||||
path='/bin:/usr/bin:/sbin:/usr/sbin:/homes/user/bin:./bin'
|
||||
path='/bin':'/usr/bin':'/sbin':'/usr/sbin':'/home/user/bin':'./bin'
|
||||
LIST = one two three four five six seven eigth nine ten
|
||||
LIST:O = eigth five four nine one seven six ten three two
|
||||
# Note that 1 in every 10! trials two independently generated
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: var.c,v 1.101 2006/02/18 01:29:27 sjg Exp $ */
|
||||
/* $NetBSD: var.c,v 1.102 2006/02/26 21:43:00 sjg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
|
@ -69,14 +69,14 @@
|
|||
*/
|
||||
|
||||
#ifndef MAKE_NATIVE
|
||||
static char rcsid[] = "$NetBSD: var.c,v 1.101 2006/02/18 01:29:27 sjg Exp $";
|
||||
static char rcsid[] = "$NetBSD: var.c,v 1.102 2006/02/26 21:43:00 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.101 2006/02/18 01:29:27 sjg Exp $");
|
||||
__RCSID("$NetBSD: var.c,v 1.102 2006/02/26 21:43:00 sjg Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif
|
||||
|
@ -2260,13 +2260,16 @@ Var_Parse(const char *str, GNode *ctxt, Boolean err, int *lengthPtr,
|
|||
tstr++;
|
||||
delim = '\0';
|
||||
|
||||
if (*tstr == '$') {
|
||||
tstr = tstr2 = Var_Subst(NULL, tstr, ctxt, err);
|
||||
}
|
||||
while (*tstr && *tstr != endc) {
|
||||
char *newStr; /* New value to return */
|
||||
char termc; /* Character which terminated scan */
|
||||
|
||||
if (*tstr == '$') {
|
||||
newStr = Var_Subst(NULL, tstr, ctxt, err);
|
||||
if (tstr2)
|
||||
free(tstr2);
|
||||
tstr = tstr2 = newStr;
|
||||
}
|
||||
if (DEBUG(VAR)) {
|
||||
printf("Applying :%c to \"%s\"\n", *tstr, nstr);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue