version 1.25, 1999/12/18 02:11:27 |
version 1.26, 1999/12/18 21:53:33 |
|
|
* |
* |
* Results: |
* Results: |
* A pointer to the structure describing the desired variable or |
* A pointer to the structure describing the desired variable or |
* NIL if the variable does not exist. |
* NULL if the variable does not exist. |
* |
* |
* Side Effects: |
* Side Effects: |
* Caches env variables in the VAR_ENV context. |
* Caches env variables in the VAR_ENV context. |
|
|
*/ |
*/ |
var = Lst_Find(ctxt->context, (ClientData)name, VarCmp); |
var = Lst_Find(ctxt->context, (ClientData)name, VarCmp); |
|
|
if ((var == NILLNODE) && (flags & FIND_CMD) && (ctxt != VAR_CMD)) |
if ((var == NULL) && (flags & FIND_CMD) && (ctxt != VAR_CMD)) |
var = Lst_Find (VAR_CMD->context, (ClientData)name, VarCmp); |
var = Lst_Find (VAR_CMD->context, (ClientData)name, VarCmp); |
if (!checkEnvFirst && (var == NILLNODE) && (flags & FIND_GLOBAL) && |
if (!checkEnvFirst && (var == NULL) && (flags & FIND_GLOBAL) && |
(ctxt != VAR_GLOBAL)) { |
(ctxt != VAR_GLOBAL)) { |
var = Lst_Find (VAR_GLOBAL->context, (ClientData)name, VarCmp); |
var = Lst_Find (VAR_GLOBAL->context, (ClientData)name, VarCmp); |
} |
} |
if ((var == NILLNODE) && (flags & FIND_ENV)) { |
if ((var == NULL) && (flags & FIND_ENV)) { |
var = Lst_Find(VAR_ENV->context, (ClientData)name, VarCmp); |
var = Lst_Find(VAR_ENV->context, (ClientData)name, VarCmp); |
if (var == NILLNODE) { |
if (var == NULL) { |
char *env; |
char *env; |
|
|
if ((env = getenv(name)) != NULL) |
if ((env = getenv(name)) != NULL) |
return VarAdd(name, env, VAR_ENV); |
return VarAdd(name, env, VAR_ENV); |
} |
} |
} |
} |
if (var == NILLNODE && checkEnvFirst && (flags & FIND_GLOBAL) && |
if (var == NULL && checkEnvFirst && (flags & FIND_GLOBAL) && |
(ctxt != VAR_GLOBAL)) |
(ctxt != VAR_GLOBAL)) |
var = Lst_Find(VAR_GLOBAL->context, (ClientData)name, VarCmp); |
var = Lst_Find(VAR_GLOBAL->context, (ClientData)name, VarCmp); |
if (var == NILLNODE) |
if (var == NULL) |
return ((Var *) NIL); |
return NULL; |
else |
else |
return ((Var *) Lst_Datum (var)); |
return (Var *)Lst_Datum(var); |
} |
} |
|
|
/*- |
/*- |
|
|
printf("%s:delete %s\n", ctxt->name, name); |
printf("%s:delete %s\n", ctxt->name, name); |
} |
} |
ln = Lst_Find(ctxt->context, (ClientData)name, VarCmp); |
ln = Lst_Find(ctxt->context, (ClientData)name, VarCmp); |
if (ln != NILLNODE) { |
if (ln != NULL) { |
register Var *v; |
register Var *v; |
|
|
v = (Var *)Lst_Datum(ln); |
v = (Var *)Lst_Datum(ln); |
|
|
* point in searching them all just to save a bit of memory... |
* point in searching them all just to save a bit of memory... |
*/ |
*/ |
v = VarFind (name, ctxt, 0); |
v = VarFind (name, ctxt, 0); |
if (v == (Var *) NIL) { |
if (v == NULL) { |
(void)VarAdd(name, val, ctxt); |
(void)VarAdd(name, val, ctxt); |
} else { |
} else { |
Buf_Reset(&(v->val)); |
Buf_Reset(&(v->val)); |
|
|
|
|
v = VarFind (name, ctxt, (ctxt == VAR_GLOBAL) ? FIND_ENV : 0); |
v = VarFind (name, ctxt, (ctxt == VAR_GLOBAL) ? FIND_ENV : 0); |
|
|
if (v == (Var *) NIL) { |
if (v == NULL) { |
(void)VarAdd(name, val, ctxt); |
(void)VarAdd(name, val, ctxt); |
} else { |
} else { |
Buf_AddSpace(&(v->val)); |
Buf_AddSpace(&(v->val)); |
|
|
|
|
v = VarFind(name, ctxt, FIND_CMD|FIND_GLOBAL|FIND_ENV); |
v = VarFind(name, ctxt, FIND_CMD|FIND_GLOBAL|FIND_ENV); |
|
|
if (v == (Var *)NIL) |
if (v == NULL) |
return FALSE; |
return FALSE; |
else |
else |
return TRUE; |
return TRUE; |
|
|
Var *v; |
Var *v; |
|
|
v = VarFind(name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD); |
v = VarFind(name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD); |
if (v != (Var *)NIL) |
if (v != NULL) |
return VarValue(v); |
return VarValue(v); |
else |
else |
return NULL; |
return NULL; |
|
|
name[1] = '\0'; |
name[1] = '\0'; |
|
|
v = VarFind (name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD); |
v = VarFind (name, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD); |
if (v == (Var *)NIL) { |
if (v == NULL) { |
*lengthPtr = 2; |
*lengthPtr = 2; |
|
|
if ((ctxt == VAR_CMD) || (ctxt == VAR_GLOBAL)) { |
if ((ctxt == VAR_CMD) || (ctxt == VAR_GLOBAL)) { |
|
|
*tstr = '\0'; |
*tstr = '\0'; |
|
|
v = VarFind (str + 2, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD); |
v = VarFind (str + 2, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD); |
if ((v == (Var *)NIL) && (ctxt != VAR_CMD) && (ctxt != VAR_GLOBAL) && |
if ((v == NULL) && (ctxt != VAR_CMD) && (ctxt != VAR_GLOBAL) && |
((tstr-str) == 4) && (str[3] == 'F' || str[3] == 'D')) |
((tstr-str) == 4) && (str[3] == 'F' || str[3] == 'D')) |
{ |
{ |
/* |
/* |
|
|
vname[1] = '\0'; |
vname[1] = '\0'; |
v = VarFind(vname, ctxt, 0); |
v = VarFind(vname, ctxt, 0); |
|
|
if (v != (Var *)NIL) { |
if (v != NULL) { |
/* |
/* |
* No need for nested expansion or anything, as we're |
* No need for nested expansion or anything, as we're |
* the only one who sets these things and we sure don't |
* the only one who sets these things and we sure don't |
|
|
} |
} |
} |
} |
|
|
if (v == (Var *)NIL) { |
if (v == NULL) { |
if ((((tstr-str) == 3) || |
if ((((tstr-str) == 3) || |
((((tstr-str) == 4) && (str[3] == 'F' || |
((((tstr-str) == 4) && (str[3] == 'F' || |
str[3] == 'D')))) && |
str[3] == 'D')))) && |