[Home]

Summary:ASTERISK-04358: [patch] add new feature to app_math
Reporter:Mike Anikienko (mike anikienko)Labels:
Date Opened:2005-06-06 05:30:48Date Closed:2008-01-15 15:37:58.000-0600
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Applications/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) app_math.patch
( 1) math.patch
Description:1) app_math dont detect operation modulus (%):
...
} else if ((op = strchr(mvalue1, '/'))) {
iaction = DIVIDEFUNCTION;
*op = '\0';
} else if ((op = strchr(mvalue1, '>'))) {
...
Symbol '%' is abnsent in this code.
But code for calcuation modulus present in this code:
...
case MODULUSFUNCTION : {
int inum1 = fnum1;
int inum2 = fnum2;
ftmp = (inum1 % inum2);
break;
}
...
I am patch this code.

2) I am add parameter <type_of_result>: float, int, hex, char. Before, result returned only in float - not all needed float. But, default I leave float.
Math(returnvar,<number1><op><number 2>,[<type_of_result>])
Example: Math(i,123%16,int)
Comments:By: Clod Patry (junky) 2005-06-06 07:08:45

related to code review: else if on the same line.

By: Michael Jerris (mikej) 2005-06-06 07:34:22

Would you be willing to convert app_math to dialplan functions instead of applications?

By: Mike Anikienko (mike anikienko) 2005-06-07 02:28:26

I am convert app_math to dialplan functions instead of applications.
To apply this patch go to root asterisk directory and execute:
patch -p1 <math.patch
After patch, please, remove file apps/app_math.c.
New function MATH dont have 1-st param (return val), as before. Now syntax like this:
MATH(<number1><op><number 2>,[<type_of_result>])
Example: Set(i=${MATH(123%16,int)}) - set var i=11

By: Kevin P. Fleming (kpfleming) 2005-06-09 18:58:39

Since this was your first patch, I've accepted and committed with a number of changes... in the future, please pay close attention to the CODING-GUIDELINES document in the areas of code formatting and function usage. Also we prefer to see the attached documentation be as clean and clear as possible.

Thanks for the contribution!

By: Michael Jerris (mikej) 2005-06-10 06:10:00

Thanks very much for the contribution, and for going above and beyond on your first time contributing.. Cheers.


By: Digium Subversion (svnbot) 2008-01-15 15:37:58.000-0600

Repository: asterisk
Revision: 5895

U   trunk/apps/app_math.c
U   trunk/doc/README.math
U   trunk/funcs/Makefile
A   trunk/funcs/func_math.c

------------------------------------------------------------------------
r5895 | kpfleming | 2008-01-15 15:37:58 -0600 (Tue, 15 Jan 2008) | 3 lines

add MATH() dialplan function (bug ASTERISK-4358, with mods)
deprecate the Math() application

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=5895