summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>1999-09-25 14:44:01 +0000
committerMarc Espie <espie@cvs.openbsd.org>1999-09-25 14:44:01 +0000
commit642be3423458e4068a0fc30e177b3d76032854a1 (patch)
tree2d607b9bc4db294c95a571efdd06c7c0adbda65a
parentefa7bae563df548bcabcf56a81cf3a6a1d7e0b89 (diff)
Add :L/:U modificators (lowercase/uppercase)
To use to get ports building more user-friendly.
-rw-r--r--usr.bin/make/make.16
-rw-r--r--usr.bin/make/var.c88
2 files changed, 91 insertions, 3 deletions
diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1
index a3afcb8d1e1..6c9e7fd51d4 100644
--- a/usr.bin/make/make.1
+++ b/usr.bin/make/make.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: make.1,v 1.19 1999/06/05 01:21:33 aaron Exp $
+.\" $OpenBSD: make.1,v 1.20 1999/09/25 14:44:00 espie Exp $
.\" $NetBSD: make.1,v 1.18 1997/03/10 21:19:53 christos Exp $
.\"
.\" Copyright (c) 1990, 1993
@@ -575,6 +575,10 @@ The colon may be escaped with a backslash
Replaces each word in the variable with its suffix.
.It Cm H
Replaces each word in the variable with everything but the last component.
+.It Cm L
+Replaces each word in the variable with its lower case equivalent.
+.It Cm U
+Replaces each word in the variable with its upper case equivalent.
.It Cm M Ns Ar pattern
Select only those words that match the rest of the modifier.
The standard shell wildcard characters
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c
index c25c1ec2e07..442e14643e5 100644
--- a/usr.bin/make/var.c
+++ b/usr.bin/make/var.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: var.c,v 1.10 1998/12/05 00:06:29 espie Exp $ */
+/* $OpenBSD: var.c,v 1.11 1999/09/25 14:44:00 espie Exp $ */
/* $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $ */
/*
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
#else
-static char rcsid[] = "$OpenBSD: var.c,v 1.10 1998/12/05 00:06:29 espie Exp $";
+static char rcsid[] = "$OpenBSD: var.c,v 1.11 1999/09/25 14:44:00 espie Exp $";
#endif
#endif /* not lint */
@@ -614,6 +614,74 @@ Var_Value (name, ctxt, frp)
/*-
*-----------------------------------------------------------------------
+ * VarUppercase --
+ * Place the Upper cased word in the given buffer.
+ *
+ * Results:
+ * TRUE if characters were added to the buffer (a space needs to be
+ * added to the buffer before the next word).
+ *
+ * Side Effects:
+ * The word is added to the buffer.
+ *
+ *-----------------------------------------------------------------------
+ */
+static Boolean
+VarUppercase (word, addSpace, buf, dummy)
+ char *word; /* Word to Upper Case */
+ Boolean addSpace; /* True if need to add a space to the buffer
+ * before sticking in the head */
+ Buffer buf; /* Buffer in which to store it */
+ ClientData dummy;
+{
+ size_t len = strlen(word);
+
+ if (addSpace) {
+ Buf_AddByte (buf, (Byte)' ');
+ }
+
+ while (len--) {
+ Buf_AddByte (buf, toupper(*word++));
+ }
+ return (TRUE);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * VarLowercase --
+ * Place the Lower cased word in the given buffer.
+ *
+ * Results:
+ * TRUE if characters were added to the buffer (a space needs to be
+ * added to the buffer before the next word).
+ *
+ * Side Effects:
+ * The word is added to the buffer.
+ *
+ *-----------------------------------------------------------------------
+ */
+static Boolean
+VarLowercase (word, addSpace, buf, dummy)
+ char *word; /* Word to Lower Case */
+ Boolean addSpace; /* True if need to add a space to the buffer
+ * before sticking in the head */
+ Buffer buf; /* Buffer in which to store it */
+ ClientData dummy;
+{
+ size_t len = strlen(word);
+
+ if (addSpace) {
+ Buf_AddByte (buf, (Byte)' ');
+ }
+
+ while (len--) {
+ Buf_AddByte (buf, tolower(*word++));
+ }
+ return (TRUE);
+}
+
+/*-
+ *-----------------------------------------------------------------------
* VarHead --
* Remove the tail of the given word and place the result in the given
* buffer.
@@ -1898,6 +1966,22 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
break;
}
/*FALLTHRU*/
+ case 'U':
+ if (tstr[1] == endc || tstr[1] == ':') {
+ newStr = VarModify (str, VarUppercase, (ClientData)0);
+ cp = tstr + 1;
+ termc = *cp;
+ break;
+ }
+ /*FALLTHRU*/
+ case 'L':
+ if (tstr[1] == endc || tstr[1] == ':') {
+ newStr = VarModify (str, VarLowercase, (ClientData)0);
+ cp = tstr + 1;
+ termc = *cp;
+ break;
+ }
+ /*FALLTHRU*/
#ifdef SUNSHCMD
case 's':
if (tstr[1] == 'h' && (tstr[2] == endc || tstr[2] == ':')) {