diff --git a/CHANGES b/CHANGES index 034320ac9fc449bb92a9aeacee212f68c327549c..a03f5b7eae4bcbe05b113804b3654e0ba2d4d0f8 100644 --- a/CHANGES +++ b/CHANGES @@ -12,6 +12,11 @@ --- Functionality changes from Asterisk 10 to Asterisk 11 -------------------- ------------------------------------------------------------------------------ +Core +---- + * The expression parser now recognizes the ABS() absolute value function, + which will convert negative floating point values to positive values. + ConfBridge ------------------- * Added menu action admin_toggle_mute_participants. This will mute / unmute diff --git a/main/ast_expr2.c b/main/ast_expr2.c index fe93c35774b72fe6e62cfc3f1af7e1ddecf7951e..83caad4e819ee725e39b9c4db5e78b5f8ed3fb1b 100644 --- a/main/ast_expr2.c +++ b/main/ast_expr2.c @@ -3036,6 +3036,15 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru return make_number(0.0); } #endif + } else if (strcmp(funcname->u.s, "ABS") == 0) { + if (arglist && !arglist->right && arglist->val) { + to_number(arglist->val); + result = make_number(arglist->val->u.i < 0 ? arglist->val->u.i * -1 : arglist->val->u.i); + return result; + } else { + ast_log(LOG_WARNING, "Wrong args to %s() function\n", funcname->u.s); + return make_number(0.0); + } } else { /* is this a custom function we should execute and collect the results of? */ #if !defined(STANDALONE) && !defined(STANDALONE2) diff --git a/main/ast_expr2.y b/main/ast_expr2.y index aabca8a4634606fd58a3ea5ebb6032a2c2b8acbe..bf1237a5329081a66fb3d8ed990102c711410a0c 100644 --- a/main/ast_expr2.y +++ b/main/ast_expr2.y @@ -1029,6 +1029,15 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru return make_number(0.0); } #endif + } else if (strcmp(funcname->u.s, "ABS") == 0) { + if (arglist && !arglist->right && arglist->val) { + to_number(arglist->val); + result = make_number(arglist->val->u.i < 0 ? arglist->val->u.i * -1 : arglist->val->u.i); + return result; + } else { + ast_log(LOG_WARNING, "Wrong args to %s() function\n", funcname->u.s); + return make_number(0.0); + } } else { /* is this a custom function we should execute and collect the results of? */ #if !defined(STANDALONE) && !defined(STANDALONE2)