mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-26 06:26:41 +00:00
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
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user