Lines Matching +defs:t +defs:expr
109 * Var_UnExport Don't export the variable anymore.
170 * The name of the variable, once set, doesn't change anymore.
704 char *expr;
719 expr = str_concat3("${", name, "}");
720 val = Var_Subst(expr, scope, VARE_EVAL);
730 free(expr);
976 char *expr = str_concat3(
978 char *filtered = Var_Subst(expr, SCOPE_GLOBAL, VARE_EVAL);
982 free(expr);
1103 * If requested, don't export these in the
1176 * If the variable doesn't exist, it is created. Otherwise a single space
1287 * The value if the variable exists, NULL if it doesn't.
1907 FormatTime(const char *fmt, time_t t, bool gmt)
1911 if (t == 0)
1912 time(&t);
1921 strftime(buf, sizeof buf, fmt, localtime(&t));
1928 strftime(buf, sizeof buf, fmt, (gmt ? gmtime : localtime)(&t));
1944 * ch->endc. The modifier doesn't have to check for this delimiter character,
1970 * during parsing though. For most modifiers this doesn't matter since their
1975 * expression from ch->expr->value, or the variable name from ch->var->name,
1976 * and stores the result back in ch->expr->value via Expr_SetValueOwn or
2045 Expr *expr;
2061 Expr_Define(Expr *expr)
2063 if (expr->defined == DEF_UNDEF)
2064 expr->defined = DEF_DEFINED;
2068 Expr_Str(const Expr *expr)
2070 return expr->value.str;
2074 Expr_Words(const Expr *expr)
2076 return Substring_Words(Expr_Str(expr), false);
2080 Expr_SetValue(Expr *expr, FStr value)
2082 FStr_Done(&expr->value);
2083 expr->value = value;
2087 Expr_SetValueOwn(Expr *expr, char *value)
2089 Expr_SetValue(expr, FStr_InitOwn(value));
2093 Expr_SetValueRefer(Expr *expr, const char *value)
2095 Expr_SetValue(expr, FStr_InitRefer(value));
2099 Expr_ShouldEval(const Expr *expr)
2101 return VarEvalMode_ShouldEval(expr->emode);
2107 return Expr_ShouldEval(ch->expr);
2123 * Allow backslashes to escape the delimiter, $, and \, but don't touch other
2145 FStr nested_val = Var_Parse(&p, ch->expr->scope,
2360 Expr *expr = ch->expr;
2361 const char *val = Expr_Str(expr);
2393 Expr_SetValueOwn(expr, SepBuf_DoneData(&result));
2400 Expr *expr = ch->expr;
2406 args.scope = expr->scope;
2428 if (!Expr_ShouldEval(expr))
2431 args.emode = VarEvalMode_WithoutKeepDollar(expr->emode);
2437 Var_Delete(expr->scope, args.var);
2478 FStr val = Var_Parse(&p, ch->expr->scope,
2479 shouldEval ? ch->expr->emode : VARE_PARSE);
2498 Expr *expr = ch->expr;
2501 Expr_ShouldEval(expr) &&
2502 (**pp == 'D') == (expr->defined == DEF_REGULAR);
2506 Expr_Define(expr);
2508 Expr_SetValue(expr, Substring_Str(LazyBuf_Get(&buf)));
2518 Expr *expr = ch->expr;
2522 if (Expr_ShouldEval(expr)) {
2523 Expr_Define(expr);
2524 Expr_SetValueOwn(expr, bmake_strdup(expr->name));
2553 Expr *expr;
2554 time_t t;
2567 if (!ParseModifierPart(&p, ':', ch->endc, ch->expr->emode,
2573 if (!TryParseTime(&arg_p, &t) || *arg_p != '\0') {
2580 t = 0;
2584 t = 0;
2588 expr = ch->expr;
2589 if (Expr_ShouldEval(expr))
2590 Expr_SetValueOwn(expr, FormatTime(Expr_Str(expr), t, gmt));
2604 Expr_SetValueOwn(ch->expr, Hash(Expr_Str(ch->expr)));
2613 Expr *expr = ch->expr;
2619 if (!Expr_ShouldEval(expr))
2622 Expr_Define(expr);
2624 gn = Targ_FindNode(expr->name);
2631 path = Dir_FindFile(expr->name, searchPath);
2634 path = bmake_strdup(expr->name);
2635 Expr_SetValueOwn(expr, path);
2644 Expr *expr = ch->expr;
2649 if (!ParseModifierPart(pp, '!', '!', expr->emode,
2654 if (Expr_ShouldEval(expr)) {
2657 Expr_SetValueOwn(expr, output);
2663 Expr_SetValueRefer(expr, "");
2666 Expr_Define(expr);
2704 SubstringWords words = Expr_Words(ch->expr);
2721 Expr_SetValueOwn(ch->expr, Buf_DoneData(&buf));
2730 Expr *expr = ch->expr;
2795 pattern = Var_Subst(pattern, expr->scope, expr->emode);
2967 if (!ParseModifierPart(pp, delim, delim, ch->expr->emode,
2972 if (!ParseModifierPart(pp, delim, delim, ch->expr->emode,
3011 if (!ParseModifierPart(pp, delim, delim, ch->expr->emode,
3016 if (!ParseModifierPart(pp, delim, delim, ch->expr->emode,
3069 QuoteShell(Expr_Str(ch->expr), quoteDollar, &buf);
3071 Expr_SetValue(ch->expr, LazyBuf_DoneGet(&buf));
3124 /* ":ts\t" */
3125 if (sep[1] == 't') {
3127 ch->sep = '\t';
3201 Expr *expr = ch->expr;
3203 assert(mod[0] == 't');
3207 return AMR_BAD; /* Found ":t<endc>" or ":t:". */
3213 if (!IsDelimiter(mod[2], ch)) { /* :t<any><any> */
3224 if (mod[1] == 't') { /* :tt */
3226 if (Expr_ShouldEval(expr))
3227 Expr_SetValueOwn(expr, str_totitle(Expr_Str(expr)));
3233 if (Expr_ShouldEval(expr))
3234 Expr_SetValueOwn(expr, str_toupper(Expr_Str(expr)));
3240 if (Expr_ShouldEval(expr))
3241 Expr_SetValueOwn(expr, str_tolower(Expr_Str(expr)));
3251 /* Found ":t<unrecognized>:" or ":t<unrecognized><endc>". */
3260 Expr *expr = ch->expr;
3267 if (!ParseModifierPart(pp, ']', ']', expr->emode,
3284 Expr_SetValueRefer(expr, "1");
3288 SubstringWords words = Expr_Words(expr);
3294 Expr_SetValueOwn(expr, Buf_DoneData(&buf));
3330 Expr_SetValueOwn(expr,
3331 VarSelectWords(Expr_Str(expr), first, last,
3422 Substring t = strs[i];
3424 strs[rndidx] = t;
3468 words = Expr_Words(ch->expr);
3475 Expr_SetValueOwn(ch->expr, SubstringWords_JoinFree(words));
3488 Expr *expr = ch->expr;
3496 if (Expr_ShouldEval(expr)) {
3498 cond_rc = Cond_EvalCondition(expr->name);
3500 then_emode = expr->emode;
3502 else_emode = expr->emode;
3528 if (!Expr_ShouldEval(expr)) {
3532 Expr_SetValue(expr, LazyBuf_DoneGet(&thenBuf));
3536 Expr_SetValue(expr, LazyBuf_DoneGet(&elseBuf));
3538 Expr_Define(expr);
3553 * @${t::=$i}
3554 * @echo 'The target is ${t:T}.'
3567 Expr *expr = ch->expr;
3582 if (expr->name[0] == '\0') {
3589 if (!ParseModifierPart(pp, ch->endc, ch->endc, expr->emode,
3596 if (!Expr_ShouldEval(expr))
3599 scope = expr->scope; /* scope where v belongs */
3600 if (expr->defined == DEF_REGULAR && expr->scope != SCOPE_GLOBAL
3601 && VarFind(expr->name, expr->scope, false) == NULL)
3605 Var_Append(scope, expr->name, val.str);
3613 Var_Set(scope, expr->name, output);
3615 } else if (op[0] == '?' && expr->defined == DEF_REGULAR) {
3618 Var_Set(scope, expr->name, val.str);
3620 Expr_SetValueRefer(expr, "");
3634 Expr *expr = ch->expr;
3655 if (Expr_ShouldEval(expr))
3656 Var_Set(SCOPE_GLOBAL, name.str, Expr_Str(expr));
3692 words = Expr_Words(ch->expr);
3708 Expr_SetValueOwn(ch->expr, SubstringWords_JoinFree(words));
3737 Expr *expr = ch->expr;
3749 if (!ParseModifierPart(pp, '=', '=', expr->emode,
3753 if (!ParseModifierPart(pp, ch->endc, ch->endc, expr->emode,
3763 if (lhsBuf.len == 0 && Expr_Str(expr)[0] == '\0')
3769 args.scope = expr->scope;
3788 Expr *expr = ch->expr;
3794 if (Expr_ShouldEval(expr)) {
3796 output = Cmd_Exec(Expr_Str(expr), &error);
3801 Expr_SetValueOwn(expr, output);
3809 * ones, don't log them, to keep the logs readable.
3812 ShouldLogInSimpleFormat(const Expr *expr)
3814 return (expr->emode == VARE_EVAL || expr->emode == VARE_EVAL_DEFINED)
3815 && expr->defined == DEF_REGULAR;
3821 const Expr *expr = ch->expr;
3829 if (!Expr_ShouldEval(expr)) {
3831 expr->name, mod[0], is_single_char ? "" : "...");
3835 if (ShouldLogInSimpleFormat(expr)) {
3838 expr->name, mod[0], is_single_char ? "" : "...",
3839 Expr_Str(expr));
3845 expr->name, mod[0], is_single_char ? "" : "...", Expr_Str(expr),
3846 VarEvalMode_Name[expr->emode], ExprDefined_Name[expr->defined]);
3852 const Expr *expr = ch->expr;
3853 const char *value = Expr_Str(expr);
3856 if (ShouldLogInSimpleFormat(expr)) {
3858 expr->name, (int)(p - mod), mod,
3864 expr->name, (int)(p - mod), mod,
3866 VarEvalMode_Name[expr->emode],
3867 ExprDefined_Name[expr->defined]);
3926 case 't':
3962 Expr *expr = ch->expr;
3964 FStr mods = Var_Parse(&p, expr->scope, expr->emode);
3977 ApplyModifiers(expr, &modsp, '\0', '\0');
3978 if (Expr_Str(expr) == var_Error || *modsp != '\0') {
4029 Expr_SetValueRefer(ch->expr, var_Error);
4060 #define ModChain_Init(expr, startc, endc, sep, oneBigWord) \
4061 (ModChain) { expr, startc, endc, sep, oneBigWord }
4064 ModChain_Init(Expr *expr, char startc, char endc, char sep, bool oneBigWord)
4067 ch.expr = expr;
4079 Expr *expr,
4085 ModChain ch = ModChain_Init(expr, startc, endc, ' ', false);
4091 assert(Expr_Str(expr) != NULL);
4128 assert(Expr_Str(expr) != NULL); /* Use var_Error or varUndefined. */
4148 Expr_SetValueRefer(expr, var_Error);
4476 Expr expr;
4478 expr.name = name;
4479 expr.value = value;
4480 expr.emode = emode;
4481 expr.scope = scope;
4482 expr.defined = defined;
4483 return expr;
4564 Expr expr = Expr_Init(NULL, FStr_InitRefer(NULL), emode,
4591 &dynamic, &expr.defined))
4595 expr.name = v->name.str;
4622 expr.value = FStr_InitRefer(v->val.data);
4626 else if (expr.name[0] != '\0')
4627 EvalStack_Push(VSK_VARNAME, expr.name, &expr.value);
4629 EvalStack_Push(VSK_EXPR, start, &expr.value);
4636 strchr(Expr_Str(&expr), '$') != NULL) {
4642 expanded = Var_Subst(Expr_Str(&expr), scope, nested_emode);
4645 Expr_SetValueOwn(&expr, expanded);
4650 ApplyModifiers(&expr, &em, '\0', '\0');
4655 ApplyModifiers(&expr, &p, startc, endc);
4663 if (expr.defined == DEF_UNDEF) {
4665 Expr_SetValueOwn(&expr, bmake_strsedup(start, p));
4672 Expr_SetValueRefer(&expr,
4679 if (expr.value.str == v->val.data) {
4681 expr.value.freeIt = v->val.data;
4688 return expr.value;
4716 * FIXME: The condition 'val.str == var_Error' doesn't