]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
-4 is a number, not a function unary_minus(4)
authorAlan T. DeKok <aland@freeradius.org>
Mon, 27 Jun 2022 18:21:51 +0000 (14:21 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 28 Jun 2022 00:22:10 +0000 (20:22 -0400)
Which helps a bit with optimization.

src/lib/unlang/xlat_expr.c

index 34875849e25cc41046709c64bbaaf277e95bf734..83e5432fb1bb2d9a9b4a7db6d26e5b974df2cdf2 100644 (file)
@@ -1527,6 +1527,13 @@ static ssize_t tokenize_unary(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuff_
 
        }
        else if (fr_sbuff_next_if_char(&our_in, '-')) { /* unary minus */
+               fr_sbuff_skip_whitespace(&our_in);
+
+               /*
+                *      -4 is a number, not minus(4).
+                */
+               if (fr_sbuff_is_digit(&our_in)) goto field;
+
                func = xlat_func_find("unary_minus", 11);
                fr_assert(func != NULL);
                c = '-';
@@ -1544,6 +1551,7 @@ static ssize_t tokenize_unary(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuff_
                c = '+';
 
        check_for_double:
+               fr_sbuff_skip_whitespace(&our_in);
                fr_sbuff_skip_whitespace(&our_in);
                if (fr_sbuff_next_if_char(&our_in, c)) {
                        fr_strerror_const("Double operator is invalid");
@@ -1556,6 +1564,7 @@ static ssize_t tokenize_unary(xlat_exp_head_t *head, xlat_exp_t **out, fr_sbuff_
         *      that we return that, and not the child node
         */
        if (!func) {
+       field:
                return tokenize_field(head, out, in, p_rules, t_rules, bracket_rules, out_c);
        }