mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-20 11:43:52 +00:00
Merged revisions 65866 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r65866 | dhubbard | 2007-05-24 10:08:56 -0500 (Thu, 24 May 2007) | 1 line merged qwell's func_math patch for issue 9507 ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@65906 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -77,6 +77,7 @@ static int math(struct ast_channel *chan, const char *cmd, char *parse,
|
|||||||
int iaction = -1;
|
int iaction = -1;
|
||||||
int type_of_result = FLOAT_RESULT;
|
int type_of_result = FLOAT_RESULT;
|
||||||
char *mvalue1, *mvalue2 = NULL, *mtype_of_result;
|
char *mvalue1, *mvalue2 = NULL, *mtype_of_result;
|
||||||
|
int negvalue1 = 0;
|
||||||
AST_DECLARE_APP_ARGS(args,
|
AST_DECLARE_APP_ARGS(args,
|
||||||
AST_APP_ARG(argv0);
|
AST_APP_ARG(argv0);
|
||||||
AST_APP_ARG(argv1);
|
AST_APP_ARG(argv1);
|
||||||
@@ -96,13 +97,12 @@ static int math(struct ast_channel *chan, const char *cmd, char *parse,
|
|||||||
|
|
||||||
mvalue1 = args.argv0;
|
mvalue1 = args.argv0;
|
||||||
|
|
||||||
if ((op = strchr(mvalue1, '+'))) {
|
if (mvalue1[0] == '-') {
|
||||||
iaction = ADDFUNCTION;
|
negvalue1 = 1;
|
||||||
*op = '\0';
|
mvalue1++;
|
||||||
} else if ((op = strchr(mvalue1, '-'))) {
|
}
|
||||||
iaction = SUBTRACTFUNCTION;
|
|
||||||
*op = '\0';
|
if ((op = strchr(mvalue1, '*'))) {
|
||||||
} else if ((op = strchr(mvalue1, '*'))) {
|
|
||||||
iaction = MULTIPLYFUNCTION;
|
iaction = MULTIPLYFUNCTION;
|
||||||
*op = '\0';
|
*op = '\0';
|
||||||
} else if ((op = strchr(mvalue1, '/'))) {
|
} else if ((op = strchr(mvalue1, '/'))) {
|
||||||
@@ -141,6 +141,12 @@ static int math(struct ast_channel *chan, const char *cmd, char *parse,
|
|||||||
iaction = EQFUNCTION;
|
iaction = EQFUNCTION;
|
||||||
} else
|
} else
|
||||||
op = NULL;
|
op = NULL;
|
||||||
|
} else if ((op = strchr(mvalue1, '+'))) {
|
||||||
|
iaction = ADDFUNCTION;
|
||||||
|
*op = '\0';
|
||||||
|
} else if ((op = strchr(mvalue1, '-'))) { /* subtraction MUST always be last, in case we have a negative first number */
|
||||||
|
iaction = SUBTRACTFUNCTION;
|
||||||
|
*op = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (op)
|
if (op)
|
||||||
@@ -184,6 +190,9 @@ static int math(struct ast_channel *chan, const char *cmd, char *parse,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (negvalue1)
|
||||||
|
fnum1 = 0 - fnum1;
|
||||||
|
|
||||||
switch (iaction) {
|
switch (iaction) {
|
||||||
case ADDFUNCTION:
|
case ADDFUNCTION:
|
||||||
ftmp = fnum1 + fnum2;
|
ftmp = fnum1 + fnum2;
|
||||||
|
Reference in New Issue
Block a user