Skip to content

Commit f35f2d9

Browse files
committed
remove XLAT_VIRTUAL_UNRESOLVED
it hasn't been needed for a while. The only XLAT_VIRTUAL is Foreach-Variable-*, and that's going away soon.
1 parent 8b7cca1 commit f35f2d9

File tree

5 files changed

+23
-69
lines changed

5 files changed

+23
-69
lines changed

src/lib/unlang/xlat_alloc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ static int CC_HINT(nonnull) _xlat_copy_internal(NDEBUG_LOCATION_ARGS TALLOC_CTX
272272

273273
case XLAT_ONE_LETTER: /* Done with format */
274274
case XLAT_FUNC_UNRESOLVED:
275-
case XLAT_VIRTUAL_UNRESOLVED:
276275
break;
277276

278277
case XLAT_VIRTUAL:

src/lib/unlang/xlat_eval.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,11 @@ xlat_action_t xlat_frame_eval(TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_exp_head_
11741174
continue;
11751175

11761176
case XLAT_TMPL:
1177+
/*
1178+
* Everything should have been resolved.
1179+
*/
1180+
fr_assert(!tmpl_needs_resolving(node->vpt));
1181+
11771182
if (tmpl_is_data(node->vpt)) {
11781183
XLAT_DEBUG("** [%i] %s(value) - %s", unlang_interpret_stack_depth(request), __FUNCTION__,
11791184
node->vpt->name);
@@ -1317,7 +1322,6 @@ xlat_action_t xlat_frame_eval(TALLOC_CTX *ctx, fr_dcursor_t *out, xlat_exp_head_
13171322
*/
13181323
case XLAT_INVALID:
13191324
case XLAT_FUNC_UNRESOLVED:
1320-
case XLAT_VIRTUAL_UNRESOLVED:
13211325
fr_assert(0);
13221326
return XLAT_ACTION_FAIL;
13231327
}

src/lib/unlang/xlat_priv.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,11 @@ typedef enum {
109109
XLAT_FUNC = 0x0004, //!< xlat module
110110
XLAT_FUNC_UNRESOLVED = 0x0008, //!< func needs resolution during pass2.
111111
XLAT_VIRTUAL = 0x0010, //!< virtual attribute
112-
XLAT_VIRTUAL_UNRESOLVED = 0x0020, //!< virtual attribute needs resolution during pass2.
113-
XLAT_TMPL = 0x0040, //!< xlat attribute
112+
XLAT_TMPL = 0x0020, //!< xlat attribute
114113
#ifdef HAVE_REGEX
115-
XLAT_REGEX = 0x0080, //!< regex reference %{1}, etc.
114+
XLAT_REGEX = 0x0040, //!< regex reference %{1}, etc.
116115
#endif
117-
XLAT_GROUP = 0x0200 //!< encapsulated string of xlats
116+
XLAT_GROUP = 0x0100 //!< encapsulated string of xlats
118117
} xlat_type_t;
119118

120119
/** An xlat function call

src/lib/unlang/xlat_purify.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ static int xlat_purify_list_internal(xlat_exp_head_t *head, request_t *request,
163163
case XLAT_INVALID:
164164
case XLAT_FUNC_UNRESOLVED:
165165
case XLAT_VIRTUAL:
166-
case XLAT_VIRTUAL_UNRESOLVED:
167166
fr_assert(0);
168167
return -1;
169168

src/lib/unlang/xlat_tokenize.c

Lines changed: 15 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -567,21 +567,17 @@ static CC_HINT(nonnull(1,2,4)) ssize_t xlat_tokenize_attribute(xlat_exp_head_t *
567567
}
568568

569569
/*
570-
* We don't know it's virtual but
571-
* we don't know it's not either...
572-
*
573-
* Mark it up as virtual-unresolved
574-
* and let the resolution code figure
575-
* this out in a later pass.
570+
* Try to resolve it later
576571
*/
577-
xlat_exp_set_type(node, XLAT_VIRTUAL_UNRESOLVED);
572+
xlat_exp_set_type(node, XLAT_TMPL);
578573
xlat_exp_set_name_shallow(node, vpt->name);
579574
node->vpt = vpt;
580575
node->flags.needs_resolving = true;
581-
/*
582-
* Deal with normal attribute (or list)
583-
*/
576+
584577
} else {
578+
/*
579+
* Deal with normal attribute (or list)
580+
*/
585581
xlat_exp_set_type(node, XLAT_TMPL);
586582
xlat_exp_set_name_shallow(node, vpt->name);
587583
node->vpt = vpt;
@@ -1038,11 +1034,6 @@ static void _xlat_debug_node(xlat_exp_t const *node, int depth)
10381034
INFO_INDENT("virtual (%s)", node->fmt);
10391035
break;
10401036

1041-
case XLAT_VIRTUAL_UNRESOLVED:
1042-
fr_assert(node->fmt != NULL);
1043-
INFO_INDENT("virtual-unresolved (%s)", node->fmt);
1044-
break;
1045-
10461037
case XLAT_FUNC:
10471038
fr_assert(node->call.func != NULL);
10481039
INFO_INDENT("func (%s)", node->call.func->name);
@@ -1288,10 +1279,6 @@ ssize_t xlat_print_node(fr_sbuff_t *out, xlat_exp_head_t const *head, xlat_exp_t
12881279
FR_SBUFF_IN_BSTRCPY_BUFFER_RETURN(out, node->call.func->name);
12891280
break;
12901281

1291-
case XLAT_VIRTUAL_UNRESOLVED:
1292-
FR_SBUFF_IN_BSTRCPY_BUFFER_RETURN(out, node->fmt);
1293-
break;
1294-
12951282
case XLAT_FUNC:
12961283
FR_SBUFF_IN_BSTRCPY_BUFFER_RETURN(out, node->call.func->name);
12971284
FR_SBUFF_IN_CHAR_RETURN(out, '(');
@@ -1927,48 +1914,6 @@ int xlat_resolve(xlat_exp_head_t *head, xlat_res_rules_t const *xr_rules)
19271914
node->flags.impure_func = !node->call.func->flags.pure;
19281915
break;
19291916

1930-
/*
1931-
* This covers unresolved attributes as well as
1932-
* unresolved functions.
1933-
*/
1934-
case XLAT_VIRTUAL_UNRESOLVED:
1935-
{
1936-
if (xlat_resolve_virtual_attribute(node, node->vpt) == 0) break;
1937-
1938-
/*
1939-
* Try and resolve (in-place) as an attribute
1940-
*/
1941-
if ((tmpl_resolve(node->vpt, xr_rules->tr_rules) < 0) ||
1942-
(node->vpt->type != TMPL_TYPE_ATTR)) {
1943-
/*
1944-
* FIXME - Produce proper error with marker
1945-
*/
1946-
if (!xr_rules->allow_unresolved) {
1947-
error_unresolved:
1948-
if (node->quote == T_BARE_WORD) {
1949-
fr_strerror_printf_push("Failed resolving expansion: %s",
1950-
node->fmt);
1951-
} else {
1952-
fr_strerror_printf_push("Failed resolving expansion: %c%s%c",
1953-
fr_token_quote[node->quote], node->fmt, fr_token_quote[node->quote]);
1954-
}
1955-
return -1;
1956-
}
1957-
break;
1958-
}
1959-
1960-
/*
1961-
* Just need to flip the type as the tmpl should already have been fixed up
1962-
*/
1963-
xlat_exp_set_type(node, XLAT_TMPL);
1964-
1965-
/*
1966-
* Reset node flags. Attributes aren't pure, and don't need further resolving.
1967-
*/
1968-
node->flags = (xlat_flags_t){ };
1969-
}
1970-
break;
1971-
19721917
case XLAT_TMPL:
19731918
/*
19741919
* Double-quoted etc. strings may contain xlats, so we try to resolve them now.
@@ -1986,7 +1931,15 @@ int xlat_resolve(xlat_exp_head_t *head, xlat_res_rules_t const *xr_rules)
19861931
return -1;
19871932
}
19881933

1989-
if (node->flags.needs_resolving && !xr_rules->allow_unresolved) goto error_unresolved;
1934+
if (node->flags.needs_resolving && !xr_rules->allow_unresolved) {
1935+
if (node->quote == T_BARE_WORD) {
1936+
fr_strerror_printf_push("Failed resolving attribute: %s",
1937+
node->fmt);
1938+
} else {
1939+
fr_strerror_printf_push("Failed resolving attribute: %c%s%c",
1940+
fr_token_quote[node->quote], node->fmt, fr_token_quote[node->quote]);
1941+
}
1942+
}
19901943

19911944
xlat_flags_merge(&our_flags, &node->flags);
19921945
}

0 commit comments

Comments
 (0)