From: Alan T. DeKok Date: Mon, 27 Jun 2022 18:21:51 +0000 (-0400) Subject: -4 is a number, not a function unary_minus(4) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64c67c870689d94573d3d3df5cf53b2135260004;p=thirdparty%2Ffreeradius-server.git -4 is a number, not a function unary_minus(4) Which helps a bit with optimization. --- diff --git a/src/lib/unlang/xlat_expr.c b/src/lib/unlang/xlat_expr.c index 34875849e25..83e5432fb1b 100644 --- a/src/lib/unlang/xlat_expr.c +++ b/src/lib/unlang/xlat_expr.c @@ -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); }