=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/make/var.c,v retrieving revision 1.47 retrieving revision 1.48 diff -c -r1.47 -r1.48 *** src/usr.bin/make/var.c 2000/08/21 10:44:21 1.47 --- src/usr.bin/make/var.c 2000/09/14 13:32:08 1.48 *************** *** 1,4 **** ! /* $OpenBSD: var.c,v 1.47 2000/08/21 10:44:21 espie Exp $ */ /* $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: var.c,v 1.48 2000/09/14 13:32:08 espie Exp $ */ /* $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $ */ /* *************** *** 66,79 **** * SUCH DAMAGE. */ - #ifndef lint - #if 0 - static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; - #else - static char rcsid[] = "$OpenBSD: var.c,v 1.47 2000/08/21 10:44:21 espie Exp $"; - #endif - #endif /* not lint */ - /*- * var.c -- * Variable-handling functions --- 66,71 ---- *************** *** 129,134 **** --- 121,135 ---- #include "hashconsts.h" #include "varmodifiers.h" + #ifndef lint + #if 0 + static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; + #else + UNUSED + static char rcsid[] = "$OpenBSD: var.c,v 1.48 2000/09/14 13:32:08 espie Exp $"; + #endif + #endif /* not lint */ + static SymTable *CTXT_GLOBAL, *CTXT_CMD, *CTXT_ENV; static char *varnames[] = { *************** *** 309,315 **** void Varq_Set(idx, val, gn) int idx; ! char *val; GNode *gn; { /* We only look for a variable in the given context since anything set --- 310,316 ---- void Varq_Set(idx, val, gn) int idx; ! const char *val; GNode *gn; { /* We only look for a variable in the given context since anything set *************** *** 324,330 **** } else { Buf_Reset(&(v->val)); Buf_AddString(&(v->val), val); - } if (DEBUG(VAR)) printf("%s:%s = %s\n", gn->name, varnames[idx], val); --- 325,330 ---- *************** *** 333,342 **** void Varq_Append(idx, val, gn) int idx; ! char *val; GNode *gn; { ! Var *v = gn->context.locals[idx]; if (v == NULL) { v = new_var(varnames[idx], val); --- 333,342 ---- void Varq_Append(idx, val, gn) int idx; ! const char *val; GNode *gn; { ! Var *v = gn->context.locals[idx]; if (v == NULL) { v = new_var(varnames[idx], val); *************** *** 516,522 **** * The added variable * * Side Effects: ! * The new variable is placed at the front of the given context * The name and val arguments are duplicated so they may * safely be freed. *----------------------------------------------------------------------- --- 516,522 ---- * The added variable * * Side Effects: ! * The new variable is placed in the given context. * The name and val arguments are duplicated so they may * safely be freed. *----------------------------------------------------------------------- *************** *** 538,547 **** idx = quick_lookup(name, &end, &k); ! if (idx != -1) { Parse_Error(PARSE_FATAL, "Trying to set dynamic variable %s", v->name); ! } else hash_insert(ctxt, hash_lookup_interval(ctxt, name, end, k), v); return v; } --- 538,547 ---- idx = quick_lookup(name, &end, &k); ! if (idx != -1) Parse_Error(PARSE_FATAL, "Trying to set dynamic variable %s", v->name); ! else hash_insert(ctxt, hash_lookup_interval(ctxt, name, end, k), v); return v; } *************** *** 551,569 **** *----------------------------------------------------------------------- * VarDelete -- * Delete a variable and all the space associated with it. - * - * Results: - * None - * - * Side Effects: - * None *----------------------------------------------------------------------- */ static void VarDelete(vp) ! void *vp; { ! Var *v = (Var *) vp; Buf_Destroy(&(v->val)); free(v); } --- 551,564 ---- *----------------------------------------------------------------------- * VarDelete -- * Delete a variable and all the space associated with it. *----------------------------------------------------------------------- */ static void VarDelete(vp) ! void *vp; { ! Var *v = (Var *) vp; ! Buf_Destroy(&(v->val)); free(v); } *************** *** 575,596 **** * Var_Delete -- * Remove a variable from a context. * - * Results: - * None. - * * Side Effects: * The Var structure is removed and freed. - * *----------------------------------------------------------------------- */ void Var_Delete(name, ctxt) ! char *name; ! GSymT *ctxt; { ! Var *v; ! u_int32_t k; ! const char *end = NULL; if (DEBUG(VAR)) printf("%s:delete %s\n", context_name(ctxt), name); --- 570,587 ---- * Var_Delete -- * Remove a variable from a context. * * Side Effects: * The Var structure is removed and freed. *----------------------------------------------------------------------- */ void Var_Delete(name, ctxt) ! const char *name; ! GSymT *ctxt; { ! Var *v; ! u_int32_t k; ! const char *end = NULL; if (DEBUG(VAR)) printf("%s:delete %s\n", context_name(ctxt), name); *************** *** 606,614 **** * Var_Set -- * Set the variable name to the value val in the given context. * - * Results: - * None. - * * Side Effects: * If the variable doesn't yet exist, a new record is created for it. * Else the old value is freed and the new one stuck in its place --- 597,602 ---- *************** *** 624,634 **** */ void Var_Set(name, val, ctxt) ! char *name; /* name of variable to set */ ! char *val; /* value to give to the variable */ GSymT *ctxt; /* context in which to set it */ { ! register Var *v; /* * We only look for a variable in the given context since anything set --- 612,622 ---- */ void Var_Set(name, val, ctxt) ! const char *name; /* name of variable to set */ ! const char *val; /* value to give to the variable */ GSymT *ctxt; /* context in which to set it */ { ! Var *v; /* * We only look for a variable in the given context since anything set *************** *** 641,647 **** else { Buf_Reset(&(v->val)); Buf_AddString(&(v->val), val); - } if (DEBUG(VAR)) printf("%s:%s = %s\n", context_name(ctxt), name, val); --- 629,634 ---- *************** *** 664,672 **** * The variable of the given name has the given value appended to it in * the given context. * - * Results: - * None - * * Side Effects: * If the variable doesn't exist, it is created. Else the strings * are concatenated (with a space in between). --- 651,656 ---- *************** *** 682,692 **** */ void Var_Append(name, val, ctxt) ! char *name; /* Name of variable to modify */ ! char *val; /* String to append to it */ GSymT *ctxt; /* Context in which this should occur */ { ! register Var *v; v = VarFind(name, (SymTable *)ctxt, (ctxt == VAR_GLOBAL) ? FIND_ENV : 0); --- 666,676 ---- */ void Var_Append(name, val, ctxt) ! const char *name; /* Name of variable to modify */ ! const char *val; /* String to append to it */ GSymT *ctxt; /* Context in which this should occur */ { ! Var *v; v = VarFind(name, (SymTable *)ctxt, (ctxt == VAR_GLOBAL) ? FIND_ENV : 0); *************** *** 695,702 **** } else { Buf_AddSpace(&(v->val)); Buf_AddString(&(v->val), val); - - } if (DEBUG(VAR)) printf("%s:%s = %s\n", context_name(ctxt), name, VarValue(v)); --- 679,684 ---- *************** *** 709,726 **** * * Results: * TRUE if it does, FALSE if it doesn't - * - * Side Effects: - * None. - * *----------------------------------------------------------------------- */ Boolean Var_Exists(name, ctxt) ! char *name; /* Variable to find */ GSymT *ctxt; /* Context in which to start search */ { ! Var *v; v = VarFind(name, (SymTable *)ctxt, FIND_MINE|FIND_ENV); --- 691,704 ---- * * Results: * TRUE if it does, FALSE if it doesn't *----------------------------------------------------------------------- */ Boolean Var_Exists(name, ctxt) ! const char *name; /* Variable to find */ GSymT *ctxt; /* Context in which to start search */ { ! Var *v; v = VarFind(name, (SymTable *)ctxt, FIND_MINE|FIND_ENV); *************** *** 737,753 **** * * Results: * The value if the variable exists, NULL if it doesn't - * - * Side Effects: - * None *----------------------------------------------------------------------- */ char * Var_Value(name, ctxt) ! char *name; /* name to find */ GSymT *ctxt; /* context in which to search for it */ { ! Var *v; v = VarFind(name, (SymTable *)ctxt, FIND_ENV | FIND_MINE); if (v != NULL) --- 715,728 ---- * * Results: * The value if the variable exists, NULL if it doesn't *----------------------------------------------------------------------- */ char * Var_Value(name, ctxt) ! const char *name; /* name to find */ GSymT *ctxt; /* context in which to search for it */ { ! Var *v; v = VarFind(name, (SymTable *)ctxt, FIND_ENV | FIND_MINE); if (v != NULL) *************** *** 768,788 **** */ static Var * var_name_with_dollar(str, pos, ctxt, err, endc) ! char *str; /* First dollar in variable name */ ! char **pos; /* Current position in variable spec */ SymTable *ctxt; /* The context for the variable */ Boolean err; /* TRUE if undefined variables are an error */ char endc; /* End character for spec */ { ! BUFFER buf; /* Store the variable name */ ! size_t sublen; /* Deal with recursive expansions */ ! Boolean subfree; ! char *n; /* Sub name */ ! Var *v; Buf_Init(&buf, MAKE_BSIZE); ! while (1) { Buf_AddInterval(&buf, str, *pos); n = Var_Parse(*pos, ctxt, err, &sublen, &subfree); if (n != NULL) --- 743,763 ---- */ static Var * var_name_with_dollar(str, pos, ctxt, err, endc) ! char *str; /* First dollar in variable name */ ! char **pos; /* Current position in variable spec */ SymTable *ctxt; /* The context for the variable */ Boolean err; /* TRUE if undefined variables are an error */ char endc; /* End character for spec */ { ! BUFFER buf; /* Store the variable name */ ! size_t sublen; /* Deal with recursive expansions */ ! Boolean subfree; ! char *n; /* Sub name */ ! Var *v; Buf_Init(&buf, MAKE_BSIZE); ! for (;;) { Buf_AddInterval(&buf, str, *pos); n = Var_Parse(*pos, ctxt, err, &sublen, &subfree); if (n != NULL)