diff options
author | Tilghman Lesher <tilghman@meg.abyt.es> | 2012-01-16 19:49:50 +0000 |
---|---|---|
committer | Tilghman Lesher <tilghman@meg.abyt.es> | 2012-01-16 19:49:50 +0000 |
commit | c60d15222c8c414b8f4a09a287d52916d70e27dd (patch) | |
tree | c3d83be65c1c40be5ac9e44d7622da81235469a7 /main/ast_expr2.y | |
parent | e09527b10db2826d8a695c214d335acb6cad14f8 (diff) |
Add ABS() absolute value function to the expression parser.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@351079 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/ast_expr2.y')
-rw-r--r-- | main/ast_expr2.y | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/main/ast_expr2.y b/main/ast_expr2.y index aabca8a46..bf1237a53 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) |