diff options
Diffstat (limited to 'usr.bin/make/var.c')
-rw-r--r-- | usr.bin/make/var.c | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index bcea186..1019ab5 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -271,15 +271,15 @@ VarFind (name, ctxt, flags) if ((env = getenv (name)) != NULL) { int len; - + v = (Var *) emalloc(sizeof(Var)); v->name = strdup(name); len = strlen(env); - + v->val = Buf_Init(len); Buf_AddBytes(v->val, len, (Byte *)env); - + v->flags = VAR_FROM_ENV; return (v); } else if (checkEnvFirst && (flags & FIND_GLOBAL) && @@ -746,7 +746,7 @@ VarRoot (word, addSpace, buf, dummy) * VarMatch -- * Place the word in the buffer if it matches the given pattern. * Callback function for VarModify to implement the :M modifier. - * + * * Results: * TRUE if a space should be placed in the buffer before the next * word. @@ -783,7 +783,7 @@ VarMatch (word, addSpace, buf, pattern) * Place the word in the buffer if it matches the given pattern. * Callback function for VarModify to implement the System V % * modifiers. - * + * * Results: * TRUE if a space should be placed in the buffer before the next * word. @@ -825,7 +825,7 @@ VarSYSVMatch (word, addSpace, buf, patp) * VarNoMatch -- * Place the word in the buffer if it doesn't match the given pattern. * Callback function for VarModify to implement the :N modifier. - * + * * Results: * TRUE if a space should be placed in the buffer before the next * word. @@ -1067,7 +1067,7 @@ VarModify (str, modProc, datum) for (i = 1; i < ac; i++) addSpace = (*modProc)(av[i], addSpace, buf, datum); - + Buf_AddByte (buf, '\0'); str = (char *)Buf_GetAll (buf, (int *)NULL); Buf_Destroy (buf, FALSE); @@ -1118,11 +1118,11 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) * expanding it in a non-local context. This * is done to support dynamic sources. The * result is just the invocation, unaltered */ - + *freePtr = FALSE; dynamic = FALSE; start = str; - + if (str[1] != '(' && str[1] != '{') { /* * If it's not bounded by braces of some sort, life is much simpler. @@ -1137,7 +1137,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) v = VarFind (name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD); if (v == (Var *)NIL) { *lengthPtr = 2; - + if ((ctxt == VAR_CMD) || (ctxt == VAR_GLOBAL)) { /* * If substituting a local variable in a non-local context, @@ -1195,7 +1195,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) return (var_Error); } *tstr = '\0'; - + v = VarFind (str + 2, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD); if ((v == (Var *)NIL) && (ctxt != VAR_CMD) && (ctxt != VAR_GLOBAL) && ((tstr-str) == 4) && (str[3] == 'F' || str[3] == 'D')) @@ -1221,7 +1221,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) vname[0] = str[2]; vname[1] = '\0'; v = VarFind(vname, ctxt, 0); - + if (v != (Var *)NIL) { /* * No need for nested expansion or anything, as we're @@ -1229,7 +1229,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) * but nested invocations in them... */ val = (char *)Buf_GetAll(v->val, (int *)NULL); - + if (str[3] == 'D') { val = VarModify(val, VarHead, (ClientData)0); } else { @@ -1248,7 +1248,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) } } } - + if (v == (Var *)NIL) { if ((((tstr-str) == 3) || ((((tstr-str) == 4) && (str[3] == 'F' || @@ -1277,7 +1277,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) ((ctxt == VAR_CMD) || (ctxt == VAR_GLOBAL))) { int len; - + len = (tstr-str) - 3; if ((strncmp(str+2, ".TARGET", len) == 0) || (strncmp(str+2, ".ARCHIVE", len) == 0) || @@ -1287,7 +1287,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) dynamic = TRUE; } } - + if (!haveModifier) { /* * No modifiers -- have specification length so we can return @@ -1337,9 +1337,9 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) str = Var_Subst(NULL, str, ctxt, err); *freePtr = TRUE; } - + v->flags &= ~VAR_IN_USE; - + /* * Now we need to apply any modifiers the user wants applied. * These are: @@ -1365,7 +1365,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) while (*tstr != endc) { char *newStr; /* New value to return */ char termc; /* Character which terminated scan */ - + if (DEBUG(VAR)) { printf("Applying :%c to \"%s\"\n", *tstr, str); } @@ -1442,7 +1442,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) } buf = Buf_Init(0); - + /* * Pass through the lhs looking for 1) escaped delimiters, * '$'s and backslashes (place the escaped character in @@ -1468,7 +1468,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) char *cp2; int len; Boolean freeIt; - + cp2 = Var_Parse(cp, ctxt, err, &len, &freeIt); Buf_AddBytes(buf, strlen(cp2), (Byte *)cp2); if (freeIt) { @@ -1488,7 +1488,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) } Buf_AddByte(buf, (Byte)'\0'); - + /* * If lhs didn't end with the delimiter, complain and * return NULL @@ -1523,7 +1523,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) * it right here) and 3) expand any variable substitutions. */ buf = Buf_Init(0); - + tstr = cp + 1; for (cp = tstr; *cp != '\0' && *cp != delim; cp++) { if ((*cp == '\\') && @@ -1554,7 +1554,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) } Buf_AddByte(buf, (Byte)'\0'); - + /* * If didn't end in delimiter character, complain */ @@ -1633,7 +1633,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) */ VarPattern pattern; Boolean eqFound; - + pattern.flags = 0; eqFound = FALSE; /* @@ -1656,7 +1656,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) cp++; } if (*cp == endc && eqFound) { - + /* * Now we break this sucker into the lhs and * rhs. We must null terminate them of course. @@ -1666,7 +1666,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) pattern.lhs = tstr; pattern.leftLen = cp - tstr; *cp++ = '\0'; - + pattern.rhs = cp; cnt = 1; while (cnt) { @@ -1679,7 +1679,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) } pattern.rightLen = cp - pattern.rhs; *cp = '\0'; - + /* * SYSV modifications happen through the whole * string. Note the pattern is anchored at the end. @@ -1697,7 +1697,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) Error ("Unknown modifier '%c'\n", *tstr); for (cp = tstr+1; *cp != ':' && *cp != endc && *cp != '\0'; - cp++) + cp++) continue; termc = *cp; newStr = var_Error; @@ -1707,7 +1707,7 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) if (DEBUG(VAR)) { printf("Result is \"%s\"\n", newStr); } - + if (*freePtr) { free (str); } @@ -1731,10 +1731,10 @@ Var_Parse (str, ctxt, err, lengthPtr, freePtr) *lengthPtr = tstr - start + 1; *tstr = endc; } - + if (v->flags & VAR_FROM_ENV) { Boolean destroy = FALSE; - + if (str != (char *)Buf_GetAll(v->val, (int *)NULL)) { destroy = TRUE; } else { @@ -1841,9 +1841,9 @@ Var_Subst (var, str, ctxt, undefErr) /* * Scan up to the end of the variable name. */ - for (p = &str[2]; *p && + for (p = &str[2]; *p && *p != ':' && *p != ')' && *p != '}'; p++) - if (*p == '$') + if (*p == '$') break; /* * A variable inside the variable. We cannot expand @@ -1855,14 +1855,14 @@ Var_Subst (var, str, ctxt, undefErr) str = p; continue; } - - if (strncmp(var, str + 2, p - str - 2) != 0 || + + if (strncmp(var, str + 2, p - str - 2) != 0 || var[p - str - 2] != '\0') { /* * Not the variable we want to expand, scan * until the next variable */ - for (;*p != '$' && *p != '\0'; p++) + for (;*p != '$' && *p != '\0'; p++) continue; Buf_AddBytes(buf, p - str, (Byte *) str); str = p; @@ -1876,7 +1876,7 @@ Var_Subst (var, str, ctxt, undefErr) if (!expand) continue; } - + val = Var_Parse (str, ctxt, undefErr, &length, &doFree); /* @@ -1916,7 +1916,7 @@ Var_Subst (var, str, ctxt, undefErr) * advance the string pointer. */ str += length; - + /* * Copy all the characters from the variable value straight * into the new string. @@ -1928,7 +1928,7 @@ Var_Subst (var, str, ctxt, undefErr) } } } - + Buf_AddByte (buf, '\0'); str = (char *)Buf_GetAll (buf, (int *)NULL); Buf_Destroy (buf, FALSE); @@ -1987,7 +1987,7 @@ Var_GetHead(file) * None * * Side Effects: - * The VAR_CMD and VAR_GLOBAL contexts are created + * The VAR_CMD and VAR_GLOBAL contexts are created *----------------------------------------------------------------------- */ void @@ -2005,7 +2005,7 @@ Var_End () { Lst_Destroy(allVars, VarDelete); } - + /****************** PRINT DEBUGGING INFO *****************/ static int |