]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Allow unary negation before parantheses
authorAlan T. DeKok <aland@freeradius.org>
Sun, 4 Jan 2015 21:05:37 +0000 (16:05 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 4 Jan 2015 21:05:37 +0000 (16:05 -0500)
src/modules/rlm_expr/rlm_expr.c

index ee60e16ffc9080c65c0a293fdd9f8f0a1db842fc..5a15a6a8822fdd5fb20ef8fab9e3d294ef7693ba 100644 (file)
@@ -213,6 +213,11 @@ static bool get_number(REQUEST *request, char const **string, int64_t *answer)
                goto done;
        }
 
+       if (*p == '-') {
+               negative = true;
+               p++;
+       }
+
        /*
         *      Look for an attribute.
         */
@@ -285,11 +290,6 @@ static bool get_number(REQUEST *request, char const **string, int64_t *answer)
                goto done;
        }
 
-       if (*p == '-') {
-               negative = true;
-               p++;
-       }
-
        if ((*p < '0') || (*p > '9')) {
                RDEBUG2("Not a number at \"%s\"", p);
                return false;
@@ -306,11 +306,11 @@ static bool get_number(REQUEST *request, char const **string, int64_t *answer)
                p++;
        }
 
-       if (negative) x = -x;
-
+done:
        if (invert) x = ~x;
 
-done:
+       if (negative) x = -x;
+
        *string = p;
        *answer = x;
        return true;