Add :L and :U variable modifiers. These convert the variable's value to

all-lower or all-upper case characters, respectively.  These were added
to further reduce differences between NetBSD/OpenBSD and FreeBSD make(1)
to propagate OpenPackages.

PR:		19959
Submitted by:	Gaspar Chilingarav <nm@web.am>
This commit is contained in:
Will Andrews 2000-10-09 04:53:36 +00:00
parent 2694d8d147
commit 28323ac07e
2 changed files with 38 additions and 0 deletions

View File

@ -628,6 +628,8 @@ potentially occur within each affected word.
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
Converts variable to lower-case letters.
.It Cm M Ns Ar pattern
Select only those words that match the rest of the modifier.
The standard shell wildcard characters
@ -717,6 +719,8 @@ is the substring of
.Ar old_string
to be replaced in
.Ar new_string
.It Cm U
Converts variable to upper-case letters.
.El
.Sh DIRECTIVES, CONDITIONALS, AND FOR LOOPS
Directives, conditionals, and for loops reminiscent

View File

@ -1739,6 +1739,8 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
* (pathname minus the suffix).
* :lhs=rhs Like :S, but the rhs goes to the end of
* the invocation.
* :U Converts variable to upper-case.
* :L Converts variable to lower-case.
*/
if ((str != (char *)NULL) && haveModifier) {
/*
@ -1753,6 +1755,38 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr)
printf("Applying :%c to \"%s\"\n", *tstr, str);
}
switch (*tstr) {
case 'U':
if (tstr[1] == endc || tstr[1] == ':') {
Buffer buf;
buf = Buf_Init(MAKE_BSIZE);
for (cp = str; *cp ; cp++)
Buf_AddByte(buf, (Byte) toupper(*cp));
Buf_AddByte(buf, (Byte) '\0');
newStr = (char *) Buf_GetAll(buf, (int *) NULL);
Buf_Destroy(buf, FALSE);
cp = tstr + 1;
termc = *cp;
break;
}
/* FALLTHROUGH */
case 'L':
if (tstr[1] == endc || tstr[1] == ':') {
Buffer buf;
buf = Buf_Init(MAKE_BSIZE);
for (cp = str; *cp ; cp++)
Buf_AddByte(buf, (Byte) tolower(*cp));
Buf_AddByte(buf, (Byte) '\0');
newStr = (char *) Buf_GetAll(buf, (int *) NULL);
Buf_Destroy(buf, FALSE);
cp = tstr + 1;
termc = *cp;
break;
}
/* FALLTHROUGH */
case 'N':
case 'M':
{