Lines Matching +defs:var +defs:cmd +defs:c
1 /* $NetBSD: var.c,v 1.1144 2025/01/11 21:21:33 rillig Exp $ */
4 * Copyright (c) 1988, 1989, 1990, 1993
36 * Copyright (c) 1989 by Berkeley Softworks
130 /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
131 MAKE_RCSID("$NetBSD: var.c,v 1.1144 2025/01/11 21:21:33 rillig Exp $");
176 * Appending to its value depends on the scope, see var-op-append.mk.
403 Var *var = bmake_malloc(sizeof *var);
404 var->name = name;
405 Buf_InitSize(&var->val, value_len + 1);
406 Buf_AddBytes(&var->val, value, value_len);
407 var->fromCmd = false;
408 var->shortLived = shortLived;
409 var->fromEnvironment = fromEnvironment;
410 var->readOnly = readOnly;
411 var->readOnlyLoud = false;
412 var->inUse = false;
413 var->exported = false;
414 var->reexport = false;
415 return var;
470 Var *var;
477 var = GNode_FindVar(scope, name, nameHash);
479 return var;
481 if (var == NULL && scope != SCOPE_CMDLINE)
482 var = GNode_FindVar(SCOPE_CMDLINE, name, nameHash);
484 if (!opts.checkEnvFirst && var == NULL && scope != SCOPE_GLOBAL) {
485 var = GNode_FindVar(SCOPE_GLOBAL, name, nameHash);
486 if (var == NULL && scope != SCOPE_INTERNAL) {
488 var = GNode_FindVar(SCOPE_INTERNAL, name, nameHash);
492 if (var == NULL) {
500 var = GNode_FindVar(SCOPE_GLOBAL, name, nameHash);
501 if (var == NULL && scope != SCOPE_INTERNAL)
502 var = GNode_FindVar(SCOPE_INTERNAL, name,
504 return var;
510 return var;
801 Var *var = hi.entry->value;
802 ExportVar(var->name.str, scope, VEM_ENV);
1404 * For example, when evaluating the modifier ':M*b' in ${:Ua b c:M*b}, the
1405 * callback is called 3 times, once for "a", "b" and "c".
1671 const char *var; /* name of the temporary variable */
1687 Var_SetWithFlags(args->scope, args->var, word.start,
1893 fmt = "%c";
1954 * expression from ch->expr->value, or the variable name from ch->var->name,
2170 * the "var" or "replacement ${var}" in :@var@replacement ${var}@, up to and
2228 "Unfinished modifier ('%c' missing)", end2);
2245 IsDelimiter(char c, const ModChain *ch)
2247 return c == ':' || c == ch->endc || c == '\0';
2375 /* :@var@...${var}...@ */
2392 args.var = tvar.str;
2393 if (strchr(args.var, '$') != NULL) {
2397 args.var);
2416 Var_Delete(expr->scope, args.var);
2444 /* See Buf_AddEscaped in for.c for the counterpart. */
2446 char c = p[1];
2447 if ((IsDelimiter(c, ch) && c != '\0') ||
2448 c == '$' || c == '\\') {
2450 LazyBuf_Add(buf, c);
2619 /* :!cmd! */
2625 FStr cmd;
2631 cmd = LazyBuf_DoneGet(&cmdBuf);
2635 output = Cmd_Exec(cmd.str, &error);
2644 FStr_Done(&cmd);
2779 DEBUG2(VAR, "Pattern for ':%c' is \"%s\"\n", mod[0], pattern);
3539 * ::!=<cmd> Assigns output of <cmd> as the new value of
3810 debug_printf("Parsing modifier ${%s:%c%s}\n",
3817 "Evaluating modifier ${%s:%c%s} on value \"%s\"\n",
3824 "Evaluating modifier ${%s:%c%s} on value \"%s\" (%s, %s)\n",
3969 "expecting '%c'",
4019 "Unclosed expression, expecting '%c' for "
4054 /* Apply any modifiers (such as :Mpattern or :@var@loop@ or :Q or ::=value). */
4075 "Unclosed expression, expecting '%c'", ch.endc);
4241 "Invalid variable name '%c', at \"%s\"", varname, start);
4595 * possible (since var.c 1.212 from 2017-02-01) to delete the variable
4815 const Var *var = HashTable_FindValue(&scope->vars, varname);
4817 var->val.data, ValueDescription(var->val.data));