diff options
author | harti <harti@FreeBSD.org> | 2005-03-22 08:16:09 +0000 |
---|---|---|
committer | harti <harti@FreeBSD.org> | 2005-03-22 08:16:09 +0000 |
commit | b2bb207f6bdb8a63b33a853d91b4cf7f34201950 (patch) | |
tree | cce88259ecd2a96c79c8fb88e094615fe62c38bc /usr.bin/make/var.c | |
parent | f4c9341562fb273bf2c05f5792e7e6cbb0171a4d (diff) | |
download | FreeBSD-src-b2bb207f6bdb8a63b33a853d91b4cf7f34201950.zip FreeBSD-src-b2bb207f6bdb8a63b33a853d91b4cf7f34201950.tar.gz |
Make some callers of VarFind using the same code structure.
Patch: 7.161
Submitted by: Max Okumoto <okumoto@ucsd.edu>
Diffstat (limited to 'usr.bin/make/var.c')
-rw-r--r-- | usr.bin/make/var.c | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index a5d7652..43a1c33 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -489,26 +489,27 @@ Var_Append(const char *name, const char *val, GNode *ctxt) n = VarPossiblyExpand(name, ctxt); v = VarFind(n, ctxt, (ctxt == VAR_GLOBAL) ? FIND_ENV : 0); - if (v == NULL) { VarAdd(n, val, ctxt); - } else { + + } else if (v->flags & VAR_FROM_ENV) { Buf_AddByte(v->val, (Byte)' '); Buf_Append(v->val, val); - DEBUGF(VAR, ("%s:%s = %s\n", ctxt->name, n, Buf_Data(v->val))); + /* + * If the original variable came from the + * environment, we have to install it in the global + * context (we could place it in the environment, but + * then we should provide a way to export other + * variables...) + */ + v->flags &= ~VAR_FROM_ENV; + Lst_AtFront(&ctxt->context, v); - if (v->flags & VAR_FROM_ENV) { - /* - * If the original variable came from the - * environment, we have to install it in the global - * context (we could place it in the environment, but - * then we should provide a way to export other - * variables...) - */ - v->flags &= ~VAR_FROM_ENV; - Lst_AtFront(&ctxt->context, v); - } + } else { + Buf_AddByte(v->val, (Byte)' '); + Buf_Append(v->val, val); + DEBUGF(VAR, ("%s:%s = %s\n", ctxt->name, n, Buf_Data(v->val))); } free(n); } @@ -534,14 +535,17 @@ Var_Exists(const char *name, GNode *ctxt) n = VarPossiblyExpand(name, ctxt); v = VarFind(n, ctxt, FIND_CMD | FIND_GLOBAL | FIND_ENV); - free(n); - if (v == NULL) { + free(n); return (FALSE); } else if (v->flags & VAR_FROM_ENV) { VarDestroy(v, TRUE); + free(n); + return (TRUE); + } else { + free(n); + return (TRUE); } - return (TRUE); } /*- @@ -561,22 +565,23 @@ Var_Value(const char *name, GNode *ctxt, char **frp) { Var *v; char *n; + char *p; n = VarPossiblyExpand(name, ctxt); v = VarFind(n, ctxt, FIND_ENV | FIND_GLOBAL | FIND_CMD); - free(n); - *frp = NULL; - if (v != NULL) { - char *p = Buf_Data(v->val); - - if (v->flags & VAR_FROM_ENV) { - VarDestroy(v, FALSE); - *frp = p; - } - return (p); + if (v == NULL) { + p = NULL; + *frp = NULL; + } else if (v->flags & VAR_FROM_ENV) { + p = Buf_Data(v->val); + *frp = p; + VarDestroy(v, FALSE); } else { - return (NULL); + p = Buf_Data(v->val); + *frp = NULL; } + free(n); + return (p); } /*- |