summaryrefslogtreecommitdiff
path: root/usr.bin/make/var.c
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 /usr.bin/make/var.c
parentefa7bae563df548bcabcf56a81cf3a6a1d7e0b89 (diff)
Add :L/:U modificators (lowercase/uppercase)
To use to get ports building more user-friendly.
Diffstat (limited to 'usr.bin/make/var.c')
-rw-r--r--usr.bin/make/var.c88
1 files changed, 86 insertions, 2 deletions
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] == ':')) {