return node;
}
-static int xlat_tokenize_input(xlat_exp_head_t *head, fr_sbuff_t *in, bool brace,
+static int xlat_tokenize_input(xlat_exp_head_t *head, fr_sbuff_t *in,
fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules);
static inline int xlat_tokenize_alternation(xlat_exp_head_t *head, fr_sbuff_t *in,
* Parse the alternate expansion.
*/
if (xlat_tokenize_input(node->alternate[1], in,
- true, &xlat_expansion_rules, t_rules) < 0) goto error;
+ &xlat_expansion_rules, t_rules) < 0) goto error;
- if (!xlat_exp_head(node->alternate[1])) {
- fr_strerror_const("Empty expansion is invalid");
+ if (!fr_sbuff_next_if_char(in, '}')) {
+ fr_strerror_const("Missing closing brace");
goto error;
}
- if (!fr_sbuff_next_if_char(in, '}')) {
- fr_strerror_const("Missing closing brace");
+ if (!xlat_exp_head(node->alternate[1])) {
+ fr_strerror_const("Empty expansion is invalid");
goto error;
}
+
xlat_flags_merge(&node->flags, &node->alternate[1]->flags);
done:
bareword:
arg_group->quote = T_BARE_WORD;
- if (xlat_tokenize_input(arg_group->group, in, true, &xlat_expansion_rules, t_rules) < 0) {
+ if (xlat_tokenize_input(arg_group->group, in, &xlat_expansion_rules, t_rules) < 0) {
goto error;
}
+
xlat_flags_merge(&arg_group->flags, &arg_group->group->flags);
/*
* Support passing the monolithic argument
} else if (fr_sbuff_next_if_char(in, '"')) {
arg_group->quote = T_DOUBLE_QUOTED_STRING;
- if (xlat_tokenize_input(arg_group->group, in, false,
+ if (xlat_tokenize_input(arg_group->group, in,
&value_parse_rules_double_quoted, t_rules) < 0) {
goto error;
}
* @param[out] head to allocate nodes in, and where to write the first
* child, and where the flags are stored.
* @param[in] in sbuff to parse.
- * @param[in] brace true if we're inside a braced expansion, else false.
* @param[in] p_rules that control parsing.
* @param[in] t_rules that control attribute reference and xlat function parsing.
* @return
* - 0 on success.
* - -1 on failure.
*/
-static int xlat_tokenize_input(xlat_exp_head_t *head,
- fr_sbuff_t *in, bool brace,
- fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules)
+static int xlat_tokenize_input(xlat_exp_head_t *head, fr_sbuff_t *in,
+ fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules)
{
xlat_exp_t *node = NULL;
fr_slen_t slen;
}
/*
- * We were told to look for a brace, but we ran off of
- * the end of the string before we found one.
- */
- if (brace) {
- if (slen == 0) TALLOC_FREE(node); /* Free the empty node */
-
- if (!fr_sbuff_is_char(in, '}')) {
- fr_strerror_const("Missing closing brace");
- goto error;
- }
- /*
- * Empty input, emit no arguments
+ * Nothing we recognize. Just return nothing.
*/
- } else if (slen == 0) {
+ if (slen == 0) {
TALLOC_FREE(node);
XLAT_DEBUG("VALUE-BOX <-- (empty)");
}
our_t_rules.xlat.runtime_el = el;
fr_strerror_clear(); /* Clear error buffer */
- if (xlat_tokenize_input(head, &our_in, false, p_rules, &our_t_rules) < 0) {
+ if (xlat_tokenize_input(head, &our_in, p_rules, &our_t_rules) < 0) {
talloc_free(head);
FR_SBUFF_ERROR_RETURN(&our_in);
}
*/
case T_BARE_WORD:
if (xlat_tokenize_input(node->group, &our_in,
- false, our_p_rules, t_rules) < 0) {
+ our_p_rules, t_rules) < 0) {
error:
if (our_p_rules != &value_parse_rules_bareword_quoted) {
talloc_const_free(our_p_rules->terminals);
*/
case T_DOUBLE_QUOTED_STRING:
if (xlat_tokenize_input(node->group, &our_in,
- false, &value_parse_rules_double_quoted, t_rules) < 0) goto error;
+ &value_parse_rules_double_quoted, t_rules) < 0) goto error;
break;
/*
fr_strerror_clear(); /* Clear error buffer */
- if (xlat_tokenize_input(head, &our_in, false, p_rules, t_rules) < 0) {
+ if (xlat_tokenize_input(head, &our_in, p_rules, t_rules) < 0) {
talloc_free(head);
FR_SBUFF_ERROR_RETURN(&our_in);
}