summaryrefslogtreecommitdiffstats
path: root/usr.bin/make
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>1999-04-19 07:30:04 +0000
committerimp <imp@FreeBSD.org>1999-04-19 07:30:04 +0000
commit40756d6d9b05c0e8aea95f208a024aa637563f22 (patch)
treec36f08dc546fa948a740ec720ecc47864ff93ea4 /usr.bin/make
parent26ffdfcbcfb691482c31ad3e886da869f343ce55 (diff)
downloadFreeBSD-src-40756d6d9b05c0e8aea95f208a024aa637563f22.zip
FreeBSD-src-40756d6d9b05c0e8aea95f208a024aa637563f22.tar.gz
Add :Q to quote variable expansion to all proper expansion of
variables for recursive makes. This makes it less painful to cross build recent NetBSD kernels on FreeBSD. Obtained from: NetBSD
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/make.16
-rw-r--r--usr.bin/make/var.c45
2 files changed, 49 insertions, 2 deletions
diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1
index e4f86fb..e4d9833 100644
--- a/usr.bin/make/make.1
+++ b/usr.bin/make/make.1
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
-.\" $Id: make.1,v 1.15 1998/11/15 05:51:55 bde Exp $
+.\" $Id: make.1,v 1.16 1998/11/29 13:46:39 pds Exp $
.\"
.Dd March 19, 1994
.Dt MAKE 1
@@ -488,6 +488,10 @@ This is identical to
.Ql Cm M ,
but selects all words which do not match
the rest of the modifier.
+.It Cm Q
+Quotes every shell meta-character in the variable, so that it can be passed
+safely through recursive invocations of
+.Nm make .
.It Cm R
Replaces each word in the variable with everything but its suffix.
.Sm off
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c
index 0ae601d..5ae9a1a 100644
--- a/usr.bin/make/var.c
+++ b/usr.bin/make/var.c
@@ -35,7 +35,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: var.c,v 1.10 1997/09/29 03:53:53 imp Exp $
+ * $Id: var.c,v 1.11 1998/06/02 13:11:04 thepish Exp $
*/
#ifndef lint
@@ -166,6 +166,7 @@ static Boolean VarSYSVMatch __P((char *, Boolean, Buffer, ClientData));
#endif
static Boolean VarNoMatch __P((char *, Boolean, Buffer, ClientData));
static Boolean VarSubstitute __P((char *, Boolean, Buffer, ClientData));
+static char *VarQuote __P((char *));
static char *VarModify __P((char *, Boolean (*)(char *, Boolean, Buffer,
ClientData),
ClientData));
@@ -1072,6 +1073,40 @@ VarModify (str, modProc, datum)
/*-
*-----------------------------------------------------------------------
+ * VarQuote --
+ * Quote shell meta-characters in the string
+ *
+ * Results:
+ * The quoted string
+ *
+ * Side Effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------
+ */
+static char *
+VarQuote(str)
+ char *str;
+{
+
+ Buffer buf;
+ /* This should cover most shells :-( */
+ static char meta[] = "\n \t'`\";&<>()|*?{}[]\\$!#^~";
+
+ buf = Buf_Init (MAKE_BSIZE);
+ for (; *str; str++) {
+ if (strchr(meta, *str) != NULL)
+ Buf_AddByte(buf, (Byte)'\\');
+ Buf_AddByte(buf, (Byte)*str);
+ }
+ Buf_AddByte(buf, (Byte) '\0');
+ str = (char *)Buf_GetAll (buf, (int *)NULL);
+ Buf_Destroy (buf, FALSE);
+ return str;
+}
+
+/*-
+ *-----------------------------------------------------------------------
* Var_Parse --
* Given the start of a variable invocation, extract the variable
* name and find its value, then modify it according to the
@@ -1613,6 +1648,14 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
free(pattern.rhs);
break;
}
+ case 'Q':
+ if (tstr[1] == endc || tstr[1] == ':') {
+ newStr = VarQuote (str);
+ cp = tstr + 1;
+ termc = *cp;
+ break;
+ }
+ /*FALLTHRU*/
case 'T':
if (tstr[1] == endc || tstr[1] == ':') {
newStr = VarModify (str, VarTail, (ClientData)0);
OpenPOWER on IntegriCloud