]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
just pass xlat_arg_parser_t*, not xlat_t*
authorAlan T. DeKok <aland@freeradius.org>
Mon, 30 Jun 2025 10:11:07 +0000 (06:11 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 30 Jun 2025 17:25:35 +0000 (13:25 -0400)
the argument parser only needs the arguments, and not the rest
of the function definition

src/lib/unlang/xlat.h
src/lib/unlang/xlat_tokenize.c

index 6eaa613fc9694ec5fda12dc74d47aea1571659a3..2c9c45e39255b97bb739cf69a6f35500098254d7 100644 (file)
@@ -407,7 +407,7 @@ fr_slen_t   xlat_tokenize_condition(TALLOC_CTX *ctx, xlat_exp_head_t **head, fr_sb
                                        fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules) CC_HINT(nonnull(1,2,3));
 
 fr_slen_t      xlat_tokenize_argv(TALLOC_CTX *ctx, xlat_exp_head_t **head, fr_sbuff_t *in,
-                                  xlat_t const *xlat, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules,
+                                  xlat_arg_parser_t const *xlat_args, fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules,
                                   bool spaces) CC_HINT(nonnull(1,2,3,6));
 
 fr_slen_t      xlat_tokenize(TALLOC_CTX *ctx, xlat_exp_head_t **head, fr_sbuff_t *in,
index 405c45ef1ab4506cf3663998e89626b3da5944bd..f8519c0747434cfdf2b8ef53832cf28fa4c059fc 100644 (file)
@@ -414,7 +414,7 @@ static CC_HINT(nonnull) int xlat_tokenize_function_args(xlat_exp_head_t *head, f
        XLAT_DEBUG("NEW <-- %pV", fr_box_strvalue_len(fr_sbuff_current(in), fr_sbuff_remaining(in)));
 
        /*
-        *      The caller ensures that the first character aftet the percent exists, and is alphanumeric.
+        *      The caller ensures that the first character after the percent exists, and is alphanumeric.
         */
        c = fr_sbuff_char(in, '\0');
 
@@ -519,7 +519,7 @@ static CC_HINT(nonnull) int xlat_tokenize_function_args(xlat_exp_head_t *head, f
         *      Now parse the child nodes that form the
         *      function's arguments.
         */
-       if (xlat_tokenize_argv(node, &node->call.args, in, func,
+       if (xlat_tokenize_argv(node, &node->call.args, in, func ? func->args : NULL,
                               &xlat_function_arg_rules, t_rules, false) < 0) {
        error:
                talloc_free(node);
@@ -1586,7 +1586,7 @@ done:
  *                             later.
  * @param[out] out             the head of the xlat list / tree structure.
  * @param[in] in               the format string to expand.
- * @param[in] xlat             we're tokenizing arguments for.
+ * @param[in] xlat_args                the arguments
  * @param[in] p_rules          controlling how to parse the string outside of
  *                             any expansions.
  * @param[in] t_rules          controlling how attribute references are parsed.
@@ -1596,7 +1596,7 @@ done:
  *     - >0  on success which is the number of characters parsed.
  */
 fr_slen_t xlat_tokenize_argv(TALLOC_CTX *ctx, xlat_exp_head_t **out, fr_sbuff_t *in,
-                            xlat_t const *xlat,
+                            xlat_arg_parser_t const *xlat_args,
                             fr_sbuff_parse_rules_t const *p_rules, tmpl_rules_t const *t_rules, bool spaces)
 {
        int                             argc;
@@ -1609,8 +1609,8 @@ fr_slen_t xlat_tokenize_argv(TALLOC_CTX *ctx, xlat_exp_head_t **out, fr_sbuff_t
        xlat_arg_parser_t const         *arg = NULL, *arg_start;
        tmpl_rules_t                    arg_t_rules;
 
-       if (xlat && xlat->args) {
-               arg_start = arg = xlat->args;   /* Track the arguments as we parse */
+       if (xlat_args) {
+               arg_start = arg = xlat_args;    /* Track the arguments as we parse */
        } else {
                static xlat_arg_parser_t const  default_arg[] = { { .variadic = XLAT_ARG_VARIADIC_EMPTY_SQUASH, .type = FR_TYPE_VOID  },
                                                                  XLAT_ARG_PARSER_TERMINATOR };
@@ -1634,7 +1634,11 @@ fr_slen_t xlat_tokenize_argv(TALLOC_CTX *ctx, xlat_exp_head_t **out, fr_sbuff_t
                }
 
        } else {
-               fr_assert(p_rules == &xlat_function_arg_rules);
+               if (!p_rules) {
+                       p_rules = &xlat_function_arg_rules;
+               } else {
+                       fr_assert(p_rules == &xlat_function_arg_rules);
+               }
                fr_assert(p_rules->terminals);
 
                our_p_rules = p_rules;