]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
move tokenize regex
authorAlan T. DeKok <aland@freeradius.org>
Sat, 12 Apr 2025 12:09:57 +0000 (08:09 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 12 Apr 2025 12:09:57 +0000 (08:09 -0400)
from expr to tokenize_word, in preparation for moving more over

src/lib/unlang/xlat_expr.c
src/lib/unlang/xlat_tokenize.c

index 571e8d1d84e77ad2343c97a698b767e9af9547d6..a453d24aba63ae98d9afa04c4a89c7baf3b668f0 100644 (file)
@@ -2406,25 +2406,6 @@ static fr_slen_t tokenize_field(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuf
                        *out = node;
                        FR_SBUFF_SET_RETURN(in, &our_in);
                }
-
-#ifdef HAVE_REGEX
-               /*
-                *      Regular expression expansions are %{...}
-                */
-               if (fr_sbuff_adv_past_str_literal(&our_in, "%{")) {
-                       int ret;
-                       fr_sbuff_marker_t m_s;
-
-                       fr_sbuff_marker(&m_s, &our_in);
-
-                       ret = xlat_tokenize_regex(head, out, &our_in, &m_s);
-                       if (ret < 0) FR_SBUFF_ERROR_RETURN(&our_in);
-
-                       if (ret == 1) FR_SBUFF_SET_RETURN(in, &our_in);
-
-                       fr_sbuff_set(&our_in, &opand_m);
-               }
-#endif /* HAVE_REGEX */
                FALL_THROUGH;
 
        default:
index 0c10ff4ee378aa6ce938d90fb35f49bf13cf6e23..3fc80aa0c534e7ee06918cb6f6f8adf57345e0b2 100644 (file)
@@ -1338,6 +1338,9 @@ fr_slen_t xlat_tokenize_word(TALLOC_CTX *ctx, xlat_exp_t **out, fr_sbuff_t *in,
        ssize_t         slen;
        fr_sbuff_t      our_in = FR_SBUFF(in);
        xlat_exp_t      *node;
+#ifdef HAVE_REGEX
+       fr_sbuff_marker_t m_exp;
+#endif
 
        /*
         *      Triple-quoted strings have different terminal conditions.
@@ -1354,9 +1357,34 @@ fr_slen_t xlat_tokenize_word(TALLOC_CTX *ctx, xlat_exp_t **out, fr_sbuff_t *in,
                FR_SBUFF_ERROR_RETURN(&our_in);
 
        case T_BARE_WORD:
+#ifdef HAVE_REGEX
+               fr_sbuff_marker(&m_exp, &our_in);
+
+               /*
+                *      Regular expression expansions are %{...}
+                */
+               if (fr_sbuff_adv_past_str_literal(&our_in, "%{")) {
+                       int ret;
+                       fr_sbuff_marker_t m_s;
+
+                       fr_sbuff_marker(&m_s, &our_in);
+
+                       ret = xlat_tokenize_regex(ctx, &node, &our_in, &m_s);
+                       if (ret < 0) FR_SBUFF_ERROR_RETURN(&our_in);
+
+                       if (ret == 1) goto done;
+
+                       fr_sbuff_set(&our_in, &m_exp);
+               }
+#endif /* HAVE_REGEX */
+
 #if 0
                /*
                 *      Avoid a bounce through tmpls for %{...} and %func()
+                *
+                *      @todo   %{...}    --> tokenize expression
+                *              %foo(..)  --> tokenize_function_args (and have that function look for ()
+                *              %Y or %Y() --> one letter
                 */
                if (fr_sbuff_is_char(&our_in, '%')) {
                        xlat_exp_head_t *head = NULL;