Lines Matching refs:scope
470 GNode_FindVar(GNode *scope, Substring varname, unsigned int hash) in GNode_FindVar() argument
472 return HashTable_FindValueBySubstringHash(&scope->vars, varname, hash); in GNode_FindVar()
489 VarFindSubstring(Substring name, GNode *scope, bool elsewhere) in VarFindSubstring() argument
498 var = GNode_FindVar(scope, name, nameHash); in VarFindSubstring()
502 if (var == NULL && scope != SCOPE_CMDLINE) in VarFindSubstring()
505 if (!opts.checkEnvFirst && var == NULL && scope != SCOPE_GLOBAL) { in VarFindSubstring()
507 if (var == NULL && scope != SCOPE_INTERNAL) { in VarFindSubstring()
520 if (opts.checkEnvFirst && scope != SCOPE_GLOBAL) { in VarFindSubstring()
522 if (var == NULL && scope != SCOPE_INTERNAL) in VarFindSubstring()
535 VarFind(const char *name, GNode *scope, bool elsewhere) in VarFind() argument
537 return VarFindSubstring(Substring_InitStr(name), scope, elsewhere); in VarFind()
564 VarAdd(const char *name, const char *value, GNode *scope, VarSetFlags flags) in VarAdd() argument
566 HashEntry *he = HashTable_CreateEntry(&scope->vars, name, NULL); in VarAdd()
571 scope->name, name, value, ValueDescription(value)); in VarAdd()
580 Var_Delete(GNode *scope, const char *varname) in Var_Delete() argument
582 HashEntry *he = HashTable_FindEntry(&scope->vars, varname); in Var_Delete()
587 scope->name, varname); in Var_Delete()
600 scope->name, varname); in Var_Delete()
610 DEBUG2(VAR, "%s: delete %s\n", scope->name, varname); in Var_Delete()
617 HashTable_DeleteEntry(&scope->vars, he); in Var_Delete()
624 Var_DeleteAll(GNode *scope) in Var_DeleteAll() argument
627 HashIter_Init(&hi, &scope->vars); in Var_DeleteAll()
700 ExportVarEnv(Var *v, GNode *scope) in ExportVarEnv() argument
720 val = Var_Subst(expr, scope, VARE_EVAL); in ExportVarEnv()
721 if (scope != SCOPE_GLOBAL) { in ExportVarEnv()
773 ExportVar(const char *name, GNode *scope, VarExportMode mode) in ExportVar() argument
780 v = VarFind(name, scope, false); in ExportVar()
781 if (v == NULL && scope != SCOPE_GLOBAL) in ExportVar()
787 return ExportVarEnv(v, scope); in ExportVar()
799 Var_ReexportVars(GNode *scope) in Var_ReexportVars() argument
823 ExportVar(var->name.str, scope, VEM_ENV); in Var_ReexportVars()
836 ExportVar(varnames.words[i], scope, VEM_ENV); in Var_ReexportVars()
1018 Var_SetWithFlags(GNode *scope, const char *name, const char *val, in Var_SetWithFlags() argument
1027 scope->name, name, val); in Var_SetWithFlags()
1031 if (scope == SCOPE_GLOBAL in Var_SetWithFlags()
1040 scope->name, name, val); in Var_SetWithFlags()
1049 v = VarFind(name, scope, false); in Var_SetWithFlags()
1051 if (scope == SCOPE_CMDLINE && !(flags & VAR_SET_NO_EXPORT)) { in Var_SetWithFlags()
1066 scope->name, name, val); in Var_SetWithFlags()
1069 v = VarAdd(name, val, scope, flags); in Var_SetWithFlags()
1080 scope->name, name, val); in Var_SetWithFlags()
1087 scope->name, name, val, ValueDescription(val)); in Var_SetWithFlags()
1089 ExportVar(name, scope, VEM_PLAIN); in Var_SetWithFlags()
1092 if (scope == SCOPE_CMDLINE) { in Var_SetWithFlags()
1125 Var_Set(GNode *scope, const char *name, const char *val) in Var_Set() argument
1127 Var_SetWithFlags(scope, name, val, VAR_SET_NONE); in Var_Set()
1135 Var_SetExpand(GNode *scope, const char *name, const char *val) in Var_SetExpand() argument
1141 Var_Expand(&varname, scope, VARE_EVAL); in Var_SetExpand()
1147 scope->name, varname.str, val, name); in Var_SetExpand()
1149 Var_SetWithFlags(scope, varname.str, val, VAR_SET_NONE); in Var_SetExpand()
1180 Var_Append(GNode *scope, const char *name, const char *val) in Var_Append() argument
1184 v = VarFind(name, scope, scope == SCOPE_GLOBAL); in Var_Append()
1187 Var_SetWithFlags(scope, name, val, VAR_SET_NONE); in Var_Append()
1194 scope->name, name, val); in Var_Append()
1195 } else if (scope == SCOPE_CMDLINE || !v->fromCmd) { in Var_Append()
1199 DEBUG3(VAR, "%s: %s = %s\n", scope->name, name, v->val.data); in Var_Append()
1204 HashTable_CreateEntry(&scope->vars, name, NULL); in Var_Append()
1223 Var_AppendExpand(GNode *scope, const char *name, const char *val) in Var_AppendExpand() argument
1229 Var_Expand(&xname, scope, VARE_EVAL); in Var_AppendExpand()
1234 scope->name, xname.str, val, name); in Var_AppendExpand()
1236 Var_Append(scope, xname.str, val); in Var_AppendExpand()
1248 Var_Exists(GNode *scope, const char *name) in Var_Exists() argument
1250 Var *v = VarFind(name, scope, true); in Var_Exists()
1267 Var_ExistsExpand(GNode *scope, const char *name) in Var_ExistsExpand() argument
1272 Var_Expand(&varname, scope, VARE_EVAL); in Var_ExistsExpand()
1273 exists = Var_Exists(scope, varname.str); in Var_ExistsExpand()
1291 Var_Value(GNode *scope, const char *name) in Var_Value() argument
1293 Var *v = VarFind(name, scope, true); in Var_Value()
1465 GNode *scope; member
1489 Var_Expand(&rhs, args->scope, VARE_EVAL); in ModifyWord_SysVSubst()
1691 GNode *scope; member
1708 Var_SetWithFlags(args->scope, args->var, word.start, in ModifyWord_Loop()
1710 s = Var_Subst(args->body, args->scope, args->emode); in ModifyWord_Loop()
2017 GNode *const_member scope; member
2145 FStr nested_val = Var_Parse(&p, ch->expr->scope, in ParseModifierPartExpr()
2406 args.scope = expr->scope; in ApplyModifier_Loop()
2437 Var_Delete(expr->scope, args.var); in ApplyModifier_Loop()
2478 FStr val = Var_Parse(&p, ch->expr->scope, in ParseModifier_Defined()
2795 pattern = Var_Subst(pattern, expr->scope, expr->emode); in ParseModifier_Match()
3568 GNode *scope; in ApplyModifier_Assign() local
3599 scope = expr->scope; /* scope where v belongs */ in ApplyModifier_Assign()
3600 if (expr->defined == DEF_REGULAR && expr->scope != SCOPE_GLOBAL in ApplyModifier_Assign()
3601 && VarFind(expr->name, expr->scope, false) == NULL) in ApplyModifier_Assign()
3602 scope = SCOPE_GLOBAL; in ApplyModifier_Assign()
3605 Var_Append(scope, expr->name, val.str); in ApplyModifier_Assign()
3613 Var_Set(scope, expr->name, output); in ApplyModifier_Assign()
3618 Var_Set(scope, expr->name, val.str); in ApplyModifier_Assign()
3769 args.scope = expr->scope; in ApplyModifier_SysV()
3964 FStr mods = Var_Parse(&p, expr->scope, expr->emode); in ApplyModifiersIndirect()
4185 UndefinedShortVarValue(char varname, const GNode *scope) in UndefinedShortVarValue() argument
4187 if (scope == SCOPE_CMDLINE || scope == SCOPE_GLOBAL) { in UndefinedShortVarValue()
4217 GNode *scope, VarEvalMode emode, in ParseVarname() argument
4234 FStr nested_val = Var_Parse(&p, scope, emode); in ParseVarname()
4273 ParseVarnameShort(char varname, const char **pp, GNode *scope, in ParseVarnameShort() argument
4290 v = VarFind(name, scope, true); in ParseVarnameShort()
4299 val = UndefinedShortVarValue(varname, scope); in ParseVarnameShort()
4314 FindLocalLegacyVar(Substring varname, GNode *scope, in FindLocalLegacyVar() argument
4320 if (scope == SCOPE_CMDLINE || scope == SCOPE_GLOBAL) in FindLocalLegacyVar()
4331 scope, false); in FindLocalLegacyVar()
4367 GNode *scope, in ParseVarnameLong() argument
4392 ParseVarname(&p, startc, endc, scope, emode, &varname); in ParseVarnameLong()
4408 v = VarFindSubstring(name, scope, true); in ParseVarnameLong()
4421 v = FindLocalLegacyVar(name, scope, out_true_extraModifiers); in ParseVarnameLong()
4429 (scope == SCOPE_CMDLINE || scope == SCOPE_GLOBAL); in ParseVarnameLong()
4469 #define Expr_Init(name, value, emode, scope, defined) \ argument
4470 (Expr) { name, value, emode, scope, defined }
4474 VarEvalMode emode, GNode *scope, ExprDefined defined) in Expr_Init() argument
4481 expr.scope = scope; in Expr_Init()
4549 Var_Parse(const char **pp, GNode *scope, VarEvalMode emode) in Var_Parse() argument
4565 scope, DEF_REGULAR); in Var_Parse()
4583 if (!ParseVarnameShort(startc, pp, scope, emode, &val.str, &v)) in Var_Parse()
4588 if (!ParseVarnameLong(&p, startc, scope, emode, in Var_Parse()
4597 if (scope->fname != NULL) { in Var_Parse()
4599 PrintLocation(stderr, false, scope); in Var_Parse()
4642 expanded = Var_Subst(Expr_Str(&expr), scope, nested_emode); in Var_Parse()
4702 VarSubstExpr(const char **pp, Buffer *buf, GNode *scope, in VarSubstExpr() argument
4707 FStr val = Var_Parse(&nested_p, scope, emode); in VarSubstExpr()
4781 Var_Subst(const char *str, GNode *scope, VarEvalMode emode) in Var_Subst() argument
4799 VarSubstExpr(&p, &res, scope, emode, &errorReported); in Var_Subst()
4808 Var_SubstInTarget(const char *str, GNode *scope) in Var_SubstInTarget() argument
4811 EvalStack_Push(VSK_TARGET, scope->name, NULL); in Var_SubstInTarget()
4812 res = Var_Subst(str, scope, VARE_EVAL); in Var_SubstInTarget()
4818 Var_Expand(FStr *str, GNode *scope, VarEvalMode emode) in Var_Expand() argument
4824 expanded = Var_Subst(str->str, scope, emode); in Var_Expand()
4846 Var_Dump(GNode *scope) in Var_Dump() argument
4855 HashIter_Init(&hi, &scope->vars); in Var_Dump()
4864 const Var *var = HashTable_FindValue(&scope->vars, varname); in Var_Dump()