=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/make/var.c,v retrieving revision 1.25 retrieving revision 1.26 diff -c -r1.25 -r1.26 *** src/usr.bin/make/var.c 1999/12/18 02:11:27 1.25 --- src/usr.bin/make/var.c 1999/12/18 21:53:33 1.26 *************** *** 1,4 **** ! /* $OpenBSD: var.c,v 1.25 1999/12/18 02:11:27 espie Exp $ */ /* $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: var.c,v 1.26 1999/12/18 21:53:33 espie Exp $ */ /* $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $ */ /* *************** *** 70,76 **** #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; #else ! static char rcsid[] = "$OpenBSD: var.c,v 1.25 1999/12/18 02:11:27 espie Exp $"; #endif #endif /* not lint */ --- 70,76 ---- #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; #else ! static char rcsid[] = "$OpenBSD: var.c,v 1.26 1999/12/18 21:53:33 espie Exp $"; #endif #endif /* not lint */ *************** *** 260,266 **** * * Results: * A pointer to the structure describing the desired variable or ! * NIL if the variable does not exist. * * Side Effects: * Caches env variables in the VAR_ENV context. --- 260,266 ---- * * Results: * A pointer to the structure describing the desired variable or ! * NULL if the variable does not exist. * * Side Effects: * Caches env variables in the VAR_ENV context. *************** *** 322,349 **** */ var = Lst_Find(ctxt->context, (ClientData)name, VarCmp); ! if ((var == NILLNODE) && (flags & FIND_CMD) && (ctxt != VAR_CMD)) var = Lst_Find (VAR_CMD->context, (ClientData)name, VarCmp); ! if (!checkEnvFirst && (var == NILLNODE) && (flags & FIND_GLOBAL) && (ctxt != VAR_GLOBAL)) { var = Lst_Find (VAR_GLOBAL->context, (ClientData)name, VarCmp); } ! if ((var == NILLNODE) && (flags & FIND_ENV)) { var = Lst_Find(VAR_ENV->context, (ClientData)name, VarCmp); ! if (var == NILLNODE) { char *env; if ((env = getenv(name)) != NULL) return VarAdd(name, env, VAR_ENV); } } ! if (var == NILLNODE && checkEnvFirst && (flags & FIND_GLOBAL) && (ctxt != VAR_GLOBAL)) var = Lst_Find(VAR_GLOBAL->context, (ClientData)name, VarCmp); ! if (var == NILLNODE) ! return ((Var *) NIL); else ! return ((Var *) Lst_Datum (var)); } /*- --- 322,349 ---- */ var = Lst_Find(ctxt->context, (ClientData)name, VarCmp); ! if ((var == NULL) && (flags & FIND_CMD) && (ctxt != VAR_CMD)) var = Lst_Find (VAR_CMD->context, (ClientData)name, VarCmp); ! if (!checkEnvFirst && (var == NULL) && (flags & FIND_GLOBAL) && (ctxt != VAR_GLOBAL)) { var = Lst_Find (VAR_GLOBAL->context, (ClientData)name, VarCmp); } ! if ((var == NULL) && (flags & FIND_ENV)) { var = Lst_Find(VAR_ENV->context, (ClientData)name, VarCmp); ! if (var == NULL) { char *env; if ((env = getenv(name)) != NULL) return VarAdd(name, env, VAR_ENV); } } ! if (var == NULL && checkEnvFirst && (flags & FIND_GLOBAL) && (ctxt != VAR_GLOBAL)) var = Lst_Find(VAR_GLOBAL->context, (ClientData)name, VarCmp); ! if (var == NULL) ! return NULL; else ! return (Var *)Lst_Datum(var); } /*- *************** *** 436,442 **** printf("%s:delete %s\n", ctxt->name, name); } ln = Lst_Find(ctxt->context, (ClientData)name, VarCmp); ! if (ln != NILLNODE) { register Var *v; v = (Var *)Lst_Datum(ln); --- 436,442 ---- printf("%s:delete %s\n", ctxt->name, name); } ln = Lst_Find(ctxt->context, (ClientData)name, VarCmp); ! if (ln != NULL) { register Var *v; v = (Var *)Lst_Datum(ln); *************** *** 482,488 **** * point in searching them all just to save a bit of memory... */ v = VarFind (name, ctxt, 0); ! if (v == (Var *) NIL) { (void)VarAdd(name, val, ctxt); } else { Buf_Reset(&(v->val)); --- 482,488 ---- * point in searching them all just to save a bit of memory... */ v = VarFind (name, ctxt, 0); ! if (v == NULL) { (void)VarAdd(name, val, ctxt); } else { Buf_Reset(&(v->val)); *************** *** 537,543 **** v = VarFind (name, ctxt, (ctxt == VAR_GLOBAL) ? FIND_ENV : 0); ! if (v == (Var *) NIL) { (void)VarAdd(name, val, ctxt); } else { Buf_AddSpace(&(v->val)); --- 537,543 ---- v = VarFind (name, ctxt, (ctxt == VAR_GLOBAL) ? FIND_ENV : 0); ! if (v == NULL) { (void)VarAdd(name, val, ctxt); } else { Buf_AddSpace(&(v->val)); *************** *** 572,578 **** v = VarFind(name, ctxt, FIND_CMD|FIND_GLOBAL|FIND_ENV); ! if (v == (Var *)NIL) return FALSE; else return TRUE; --- 572,578 ---- v = VarFind(name, ctxt, FIND_CMD|FIND_GLOBAL|FIND_ENV); ! if (v == NULL) return FALSE; else return TRUE; *************** *** 598,604 **** Var *v; v = VarFind(name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD); ! if (v != (Var *)NIL) return VarValue(v); else return NULL; --- 598,604 ---- Var *v; v = VarFind(name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD); ! if (v != NULL) return VarValue(v); else return NULL; *************** *** 1473,1479 **** name[1] = '\0'; v = VarFind (name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD); ! if (v == (Var *)NIL) { *lengthPtr = 2; if ((ctxt == VAR_CMD) || (ctxt == VAR_GLOBAL)) { --- 1473,1479 ---- name[1] = '\0'; v = VarFind (name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD); ! if (v == NULL) { *lengthPtr = 2; if ((ctxt == VAR_CMD) || (ctxt == VAR_GLOBAL)) { *************** *** 1535,1541 **** *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')) { /* --- 1535,1541 ---- *tstr = '\0'; v = VarFind (str + 2, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD); ! if ((v == NULL) && (ctxt != VAR_CMD) && (ctxt != VAR_GLOBAL) && ((tstr-str) == 4) && (str[3] == 'F' || str[3] == 'D')) { /* *************** *** 1560,1566 **** vname[1] = '\0'; v = VarFind(vname, ctxt, 0); ! if (v != (Var *)NIL) { /* * No need for nested expansion or anything, as we're * the only one who sets these things and we sure don't --- 1560,1566 ---- vname[1] = '\0'; v = VarFind(vname, ctxt, 0); ! if (v != NULL) { /* * No need for nested expansion or anything, as we're * the only one who sets these things and we sure don't *************** *** 1587,1593 **** } } ! if (v == (Var *)NIL) { if ((((tstr-str) == 3) || ((((tstr-str) == 4) && (str[3] == 'F' || str[3] == 'D')))) && --- 1587,1593 ---- } } ! if (v == NULL) { if ((((tstr-str) == 3) || ((((tstr-str) == 4) && (str[3] == 'F' || str[3] == 'D')))) &&