From 642be3423458e4068a0fc30e177b3d76032854a1 Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Sat, 25 Sep 1999 14:44:01 +0000 Subject: Add :L/:U modificators (lowercase/uppercase) To use to get ports building more user-friendly. --- usr.bin/make/var.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 86 insertions(+), 2 deletions(-) (limited to 'usr.bin/make/var.c') 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 */ @@ -612,6 +612,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 -- @@ -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] == ':')) { -- cgit v1.2.3