Fixes for FreeBSD... testing for every conceivable math function now

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@83517 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Tilghman Lesher
2007-09-22 02:07:53 +00:00
parent 0b0c36ff6a
commit 48f56ba8b4
6 changed files with 14054 additions and 278 deletions

13268
configure vendored

File diff suppressed because it is too large Load Diff

View File

@@ -278,7 +278,7 @@ AC_FUNC_STRNLEN
AC_FUNC_STRTOD
AC_FUNC_UTIME_NULL
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([asprintf atexit bzero dup2 endpwent floor ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap pow putenv re_comp regcomp rint select setenv socket sqrt strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtol strtoq unsetenv utime vasprintf])
AC_CHECK_FUNCS([asprintf atexit bzero dup2 endpwent ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday inet_ntoa isascii localtime_r memchr memmove memset mkdir munmap putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtol strtoq unsetenv utime vasprintf])
# https support (in main/http.c) uses funopen on BSD systems,
# fopencookie on linux
@@ -447,14 +447,48 @@ AST_EXT_LIB_CHECK([EXP2L], [m], [exp2l])
AST_EXT_LIB_CHECK([LOG2L], [m], [log2l])
AST_EXT_LIB_CHECK([EXP10L], [m], [exp10l])
AST_EXT_LIB_CHECK([LOG10L], [m], [log10l])
AST_EXT_LIB_CHECK([SINL], [m], [sinl])
AST_EXT_LIB_CHECK([COSL], [m], [cosl])
AST_EXT_LIB_CHECK([TANL], [m], [tanl])
AST_EXT_LIB_CHECK([ASINL], [m], [asinl])
AST_EXT_LIB_CHECK([ACOSL], [m], [acosl])
AST_EXT_LIB_CHECK([ATANL], [m], [atanl])
AST_EXT_LIB_CHECK([ATAN2L], [m], [atan2l])
AST_EXT_LIB_CHECK([POWL], [m], [powl])
AST_EXT_LIB_CHECK([SQRTL], [m], [sqrtl])
AST_EXT_LIB_CHECK([RINTL], [m], [rintl])
AST_EXT_LIB_CHECK([EXPL], [m], [expl])
AST_EXT_LIB_CHECK([LOGL], [m], [logl])
AST_EXT_LIB_CHECK([REMAINDERL], [m], [remainderl])
AST_EXT_LIB_CHECK([FMODL], [m], [fmodl])
AST_EXT_LIB_CHECK([ROUNDL], [m], [roundl])
AST_EXT_LIB_CHECK([TRUNCL], [m], [truncl])
AST_EXT_LIB_CHECK([STRTOLD], [c], [strtold], [stdlib.h])
AST_EXT_LIB_CHECK([FLOORL], [m], [floorl])
AST_EXT_LIB_CHECK([CEILL], [m], [ceill])
AST_EXT_LIB_CHECK([EXP2], [m], [exp2])
AST_EXT_LIB_CHECK([LOG2], [m], [log2])
AST_EXT_LIB_CHECK([EXP10], [m], [exp10])
AST_EXT_LIB_CHECK([LOG10], [m], [log10])
AST_EXT_LIB_CHECK([SIN], [m], [sin])
AST_EXT_LIB_CHECK([COS], [m], [cos])
AST_EXT_LIB_CHECK([TAN], [m], [tan])
AST_EXT_LIB_CHECK([ASIN], [m], [asin])
AST_EXT_LIB_CHECK([ACOS], [m], [acos])
AST_EXT_LIB_CHECK([ATAN], [m], [atan])
AST_EXT_LIB_CHECK([ATAN2], [m], [atan2])
AST_EXT_LIB_CHECK([POW], [m], [pow])
AST_EXT_LIB_CHECK([SQRT], [m], [sqrt])
AST_EXT_LIB_CHECK([RINT], [m], [rint])
AST_EXT_LIB_CHECK([EXP], [m], [exp])
AST_EXT_LIB_CHECK([LOG], [m], [log])
AST_EXT_LIB_CHECK([REMAINDER], [m], [remainder])
AST_EXT_LIB_CHECK([FMOD], [m], [fmod])
AST_EXT_LIB_CHECK([ROUND], [m], [round])
AST_EXT_LIB_CHECK([TRUNC], [m], [trunc])
AST_EXT_LIB_CHECK([STRTOD], [c], [strtod], [stdlib.h])
AST_EXT_LIB_CHECK([FLOOR], [m], [floor])
AST_EXT_LIB_CHECK([CEIL], [m], [ceil])
GSM_INTERNAL="yes"
AC_SUBST(GSM_INTERNAL)

View File

@@ -18,6 +18,18 @@
/* Define to 1 if using `alloca.c'. */
#undef C_ALLOCA
/* Define this to indicate the ${ACOS_DESCRIP} library */
#undef HAVE_ACOS
/* Define this to indicate the ${ACOSL_DESCRIP} library */
#undef HAVE_ACOSL
/* Define to indicate the ${ACOSL_DESCRIP} library version */
#undef HAVE_ACOSL_VERSION
/* Define to indicate the ${ACOS_DESCRIP} library version */
#undef HAVE_ACOS_VERSION
/* Define to 1 if you have the `alarm' function. */
#undef HAVE_ALARM
@@ -37,9 +49,45 @@
/* Define to 1 if you have the <arpa/inet.h> header file. */
#undef HAVE_ARPA_INET_H
/* Define this to indicate the ${ASIN_DESCRIP} library */
#undef HAVE_ASIN
/* Define this to indicate the ${ASINL_DESCRIP} library */
#undef HAVE_ASINL
/* Define to indicate the ${ASINL_DESCRIP} library version */
#undef HAVE_ASINL_VERSION
/* Define to indicate the ${ASIN_DESCRIP} library version */
#undef HAVE_ASIN_VERSION
/* Define to 1 if you have the `asprintf' function. */
#undef HAVE_ASPRINTF
/* Define this to indicate the ${ATAN_DESCRIP} library */
#undef HAVE_ATAN
/* Define this to indicate the ${ATAN2_DESCRIP} library */
#undef HAVE_ATAN2
/* Define this to indicate the ${ATAN2L_DESCRIP} library */
#undef HAVE_ATAN2L
/* Define to indicate the ${ATAN2L_DESCRIP} library version */
#undef HAVE_ATAN2L_VERSION
/* Define to indicate the ${ATAN2_DESCRIP} library version */
#undef HAVE_ATAN2_VERSION
/* Define this to indicate the ${ATANL_DESCRIP} library */
#undef HAVE_ATANL
/* Define to indicate the ${ATANL_DESCRIP} library version */
#undef HAVE_ATANL_VERSION
/* Define to indicate the ${ATAN_DESCRIP} library version */
#undef HAVE_ATAN_VERSION
/* Define to 1 if you have the `atexit' function. */
#undef HAVE_ATEXIT
@@ -80,9 +128,33 @@
/* Define to indicate the ${CAP_DESCRIP} library version */
#undef HAVE_CAP_VERSION
/* Define this to indicate the ${CEIL_DESCRIP} library */
#undef HAVE_CEIL
/* Define this to indicate the ${CEILL_DESCRIP} library */
#undef HAVE_CEILL
/* Define to indicate the ${CEILL_DESCRIP} library version */
#undef HAVE_CEILL_VERSION
/* Define to indicate the ${CEIL_DESCRIP} library version */
#undef HAVE_CEIL_VERSION
/* Define to 1 if your system has a working `chown' function. */
#undef HAVE_CHOWN
/* Define this to indicate the ${COS_DESCRIP} library */
#undef HAVE_COS
/* Define this to indicate the ${COSL_DESCRIP} library */
#undef HAVE_COSL
/* Define to indicate the ${COSL_DESCRIP} library version */
#undef HAVE_COSL_VERSION
/* Define to indicate the ${COS_DESCRIP} library version */
#undef HAVE_COS_VERSION
/* Define this to indicate the ${CRYPTO_DESCRIP} library */
#undef HAVE_CRYPTO
@@ -117,6 +189,9 @@
/* Define to 1 if your system has working epoll support. */
#undef HAVE_EPOLL
/* Define this to indicate the ${EXP_DESCRIP} library */
#undef HAVE_EXP
/* Define this to indicate the ${EXP10_DESCRIP} library */
#undef HAVE_EXP10
@@ -141,12 +216,42 @@
/* Define to indicate the ${EXP2_DESCRIP} library version */
#undef HAVE_EXP2_VERSION
/* Define this to indicate the ${EXPL_DESCRIP} library */
#undef HAVE_EXPL
/* Define to indicate the ${EXPL_DESCRIP} library version */
#undef HAVE_EXPL_VERSION
/* Define to indicate the ${EXP_DESCRIP} library version */
#undef HAVE_EXP_VERSION
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define to 1 if you have the `floor' function. */
/* Define this to indicate the ${FLOOR_DESCRIP} library */
#undef HAVE_FLOOR
/* Define this to indicate the ${FLOORL_DESCRIP} library */
#undef HAVE_FLOORL
/* Define to indicate the ${FLOORL_DESCRIP} library version */
#undef HAVE_FLOORL_VERSION
/* Define to indicate the ${FLOOR_DESCRIP} library version */
#undef HAVE_FLOOR_VERSION
/* Define this to indicate the ${FMOD_DESCRIP} library */
#undef HAVE_FMOD
/* Define this to indicate the ${FMODL_DESCRIP} library */
#undef HAVE_FMODL
/* Define to indicate the ${FMODL_DESCRIP} library version */
#undef HAVE_FMODL_VERSION
/* Define to indicate the ${FMOD_DESCRIP} library version */
#undef HAVE_FMOD_VERSION
/* Define to 1 if you have the `fopencookie' function. */
#undef HAVE_FOPENCOOKIE
@@ -268,6 +373,9 @@
/* Define to 1 if you have the `localtime_r' function. */
#undef HAVE_LOCALTIME_R
/* Define this to indicate the ${LOG_DESCRIP} library */
#undef HAVE_LOG
/* Define this to indicate the ${LOG10_DESCRIP} library */
#undef HAVE_LOG10
@@ -292,6 +400,15 @@
/* Define to indicate the ${LOG2_DESCRIP} library version */
#undef HAVE_LOG2_VERSION
/* Define this to indicate the ${LOGL_DESCRIP} library */
#undef HAVE_LOGL
/* Define to indicate the ${LOGL_DESCRIP} library version */
#undef HAVE_LOGL_VERSION
/* Define to indicate the ${LOG_DESCRIP} library version */
#undef HAVE_LOG_VERSION
/* Define this to indicate the ${LTDL_DESCRIP} library */
#undef HAVE_LTDL
@@ -397,9 +514,18 @@
/* Define to indicate the ${POPT_DESCRIP} library version */
#undef HAVE_POPT_VERSION
/* Define to 1 if you have the `pow' function. */
/* Define this to indicate the ${POW_DESCRIP} library */
#undef HAVE_POW
/* Define this to indicate the ${POWL_DESCRIP} library */
#undef HAVE_POWL
/* Define to indicate the ${POWL_DESCRIP} library version */
#undef HAVE_POWL_VERSION
/* Define to indicate the ${POW_DESCRIP} library version */
#undef HAVE_POW_VERSION
/* Define this to indicate the ${PRI_DESCRIP} library */
#undef HAVE_PRI
@@ -442,6 +568,18 @@
/* Define to 1 if you have the `regcomp' function. */
#undef HAVE_REGCOMP
/* Define this to indicate the ${REMAINDER_DESCRIP} library */
#undef HAVE_REMAINDER
/* Define this to indicate the ${REMAINDERL_DESCRIP} library */
#undef HAVE_REMAINDERL
/* Define to indicate the ${REMAINDERL_DESCRIP} library version */
#undef HAVE_REMAINDERL_VERSION
/* Define to indicate the ${REMAINDER_DESCRIP} library version */
#undef HAVE_REMAINDER_VERSION
/* Define to 1 if your system has the ndestroy resolver function. */
#undef HAVE_RES_NDESTROY
@@ -451,9 +589,18 @@
/* Define to 1 if you have the `re_comp' function. */
#undef HAVE_RE_COMP
/* Define to 1 if you have the `rint' function. */
/* Define this to indicate the ${RINT_DESCRIP} library */
#undef HAVE_RINT
/* Define this to indicate the ${RINTL_DESCRIP} library */
#undef HAVE_RINTL
/* Define to indicate the ${RINTL_DESCRIP} library version */
#undef HAVE_RINTL_VERSION
/* Define to indicate the ${RINT_DESCRIP} library version */
#undef HAVE_RINT_VERSION
/* Define this to indicate the ${ROUND_DESCRIP} library */
#undef HAVE_ROUND
@@ -478,6 +625,18 @@
/* Define to 1 if you have the `setenv' function. */
#undef HAVE_SETENV
/* Define this to indicate the ${SIN_DESCRIP} library */
#undef HAVE_SIN
/* Define this to indicate the ${SINL_DESCRIP} library */
#undef HAVE_SINL
/* Define to indicate the ${SINL_DESCRIP} library version */
#undef HAVE_SINL_VERSION
/* Define to indicate the ${SIN_DESCRIP} library version */
#undef HAVE_SIN_VERSION
/* Define to 1 if you have the `socket' function. */
#undef HAVE_SOCKET
@@ -499,9 +658,18 @@
/* Define to indicate the ${SQLITE_DESCRIP} library version */
#undef HAVE_SQLITE_VERSION
/* Define to 1 if you have the `sqrt' function. */
/* Define this to indicate the ${SQRT_DESCRIP} library */
#undef HAVE_SQRT
/* Define this to indicate the ${SQRTL_DESCRIP} library */
#undef HAVE_SQRTL
/* Define to indicate the ${SQRTL_DESCRIP} library version */
#undef HAVE_SQRTL_VERSION
/* Define to indicate the ${SQRT_DESCRIP} library version */
#undef HAVE_SQRT_VERSION
/* Define this to indicate the ${SS7_DESCRIP} library */
#undef HAVE_SS7
@@ -582,9 +750,21 @@
/* Define to 1 if you have the `strstr' function. */
#undef HAVE_STRSTR
/* Define this to indicate the ${STRTOD_DESCRIP} library */
#undef HAVE_STRTOD
/* Define to indicate the ${STRTOD_DESCRIP} library version */
#undef HAVE_STRTOD_VERSION
/* Define to 1 if you have the `strtol' function. */
#undef HAVE_STRTOL
/* Define this to indicate the ${STRTOLD_DESCRIP} library */
#undef HAVE_STRTOLD
/* Define to indicate the ${STRTOLD_DESCRIP} library version */
#undef HAVE_STRTOLD_VERSION
/* Define to 1 if you have the `strtoq' function. */
#undef HAVE_STRTOQ
@@ -645,6 +825,18 @@
/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
#undef HAVE_SYS_WAIT_H
/* Define this to indicate the ${TAN_DESCRIP} library */
#undef HAVE_TAN
/* Define this to indicate the ${TANL_DESCRIP} library */
#undef HAVE_TANL
/* Define to indicate the ${TANL_DESCRIP} library version */
#undef HAVE_TANL_VERSION
/* Define to indicate the ${TAN_DESCRIP} library version */
#undef HAVE_TAN_VERSION
/* Define this to indicate the ${TERMCAP_DESCRIP} library */
#undef HAVE_TERMCAP

View File

@@ -143,40 +143,186 @@
#include <sys/types.h>
#include <stdio.h>
#include "asterisk.h"
/* Instead of looking for an arbitrary keyword, just test for various C99 function presence */
#if (defined(HAVE_ROUNDL) || defined(HAVE_TRUNCL) || defined(HAVE_LOG10L) || defined(HAVE_LOG2L))
#ifndef __USE_ISOC99
#define __USE_ISOC99
#endif
#endif
#ifdef __USE_ISOC99
#define FP___PRINTF "%.18Lg"
#define FP___FMOD fmodl
#define FP___STRTOD strtold
#define FP___TYPE long double
#define FUNC_COS cosl
#define FUNC_SIN sinl
#define FUNC_TAN tanl
#define FUNC_ACOS acosl
#define FUNC_ASIN asinl
#define FUNC_ATAN atanl
#define FUNC_ATAN2 atan2l
#define FUNC_POW powl
#define FUNC_SQRT sqrtl
#ifdef HAVE_COSL
#define FUNC_COS cosl
#else
#ifdef HAVE_COS
#define FUNC_COS (long double)cos
#else
#undef FUNC_COS
#endif
#endif
#ifdef HAVE_SINL
#define FUNC_SIN sinl
#else
#ifdef HAVE_SIN
#define FUNC_SIN (long double)sin
#else
#undef FUNC_SIN
#endif
#endif
#ifdef HAVE_TANL
#define FUNC_TAN tanl
#else
#ifdef HAVE_TAN
#define FUNC_TAN (long double)tan
#else
#undef FUNC_TAN
#endif
#endif
#ifdef HAVE_ACOSL
#define FUNC_ACOS acosl
#else
#ifdef HAVE_ACOS
#define FUNC_ACOS (long double)acos
#else
#undef FUNC_ACOS
#endif
#endif
#ifdef HAVE_ASINL
#define FUNC_ASIN asinl
#else
#ifdef HAVE_ASIN
#define FUNC_ASIN (long double)asin
#else
#undef FUNC_ASIN
#endif
#endif
#ifdef HAVE_ATANL
#define FUNC_ATAN atanl
#else
#ifdef HAVE_ATAN
#define FUNC_ATAN (long double)atan
#else
#undef FUNC_ATAN
#endif
#endif
#ifdef HAVE_ATAN2L
#define FUNC_ATAN2 atan2l
#else
#ifdef HAVE_ATAN2
#define FUNC_ATAN2 (long double)atan2
#else
#undef FUNC_ATAN2
#endif
#endif
#ifdef HAVE_POWL
#define FUNC_POW powl
#else
#ifdef HAVE_POW
#define FUNC_POW (long double)pow
#else
#undef FUNC_POW
#endif
#endif
#ifdef HAVE_SQRTL
#define FUNC_SQRT sqrtl
#else
#ifdef HAVE_SQRT
#define FUNC_SQRT (long double)sqrt
#else
#undef FUNC_SQRT
#endif
#endif
#ifdef HAVE_RINTL
#define FUNC_RINT rintl
#else
#ifdef HAVE_RINT
#define FUNC_RINT (long double)rint
#else
#undef FUNC_RINT
#endif
#endif
#ifdef HAVE_EXPL
#define FUNC_EXP expl
#else
#ifdef HAVE_EXP
#define FUNC_EXP (long double)exp
#else
#undef FUNC_EXP
#endif
#endif
#ifdef HAVE_LOGL
#define FUNC_LOG logl
#else
#ifdef HAVE_LOG
#define FUNC_LOG (long double)log
#else
#undef FUNC_LOG
#endif
#endif
#ifdef HAVE_REMINDERL
#define FUNC_REMINDER reminderl
#else
#ifdef HAVE_REMINDER
#define FUNC_REMINDER (long double)reminder
#else
#undef FUNC_REMINDER
#endif
#endif
#ifdef HAVE_FMODL
#define FUNC_FMOD fmodl
#else
#ifdef HAVE_FMOD
#define FUNC_FMOD (long double)fmod
#else
#undef FUNC_FMOD
#endif
#endif
#ifdef HAVE_STRTOLD
#define FUNC_STRTOD strtold
#else
#ifdef HAVE_STRTOD
#define FUNC_STRTOD (long double)strtod
#else
#undef FUNC_STRTOD
#endif
#endif
#ifdef HAVE_FLOORL
#define FUNC_FLOOR floorl
#else
#ifdef HAVE_FLOOR
#define FUNC_FLOOR (long double)floor
#else
#undef FUNC_FLOOR
#endif /* defined(HAVE_FLOOR) */
#endif /* defined(HAVE_FLOORL) */
#ifdef HAVE_CEILL
#define FUNC_CEIL ceill
#define FUNC_RINT rintl
#define FUNC_EXP expl
#define FUNC_LOG logl
#define FUNC_REMAINDER remainderl
#else
#ifdef HAVE_CEIL
#define FUNC_CEIL (long double)ceil
#else
#undef FUNC_CEIL
#endif /* defined(HAVE_CEIL) */
#endif /* defined(HAVE_CEILL) */
#ifdef HAVE_ROUNDL
#define FUNC_ROUND roundl
#else /* HAVE_ROUNDL */
#ifdef HAVE_ROUND
#define FUNC_ROUND round
#define FUNC_ROUND (long double)round
#else /* HAVE_ROUND */
#undef FUNC_ROUND
#endif /* HAVE_ROUND */
@@ -186,7 +332,7 @@
#define FUNC_TRUNC truncl
#else /* HAVE_TRUNCL */
#ifdef HAVE_TRUNC
#define FUNC_TRUNC trunc
#define FUNC_TRUNC (long double)trunc
#else /* HAVE_TRUNC */
#undef FUNC_TRUNC
#endif /* HAVE_TRUNC */
@@ -199,86 +345,50 @@
#ifdef HAVE_EXP2L
#define FUNC_EXP2 exp2l
#else
#if (defined(HAVE_EXPL) && defined(HAVE_LOGL))
#define FUNC_EXP2(x) expl((x) * logl(2.0))
#endif
#else
#if (defined(HAVE_EXP) && defined(HAVE_LOG))
#define FUNC_EXP2(x) (long double)exp((x) * log(2.0))
#endif /* defined(HAVE_EXP) && defined(HAVE_LOG) */
#endif /* defined(HAVE_EXPL) && defined(HAVE_LOGL) */
#endif /* defined(HAVE_EXP2L) */
#ifdef HAVE_EXP10L
#define FUNC_EXP10 exp10l
#else
#if (defined(HAVE_EXPL) && defined(HAVE_LOGL))
#define FUNC_EXP10(x) expl((x) * logl(10.0))
#endif
#else
#if (defined(HAVE_EXP) && defined(HAVE_LOG))
#define FUNC_EXP10(x) (long double)exp((x) * log(10.0))
#endif /* defined(HAVE_EXP) && defined(HAVE_LOG) */
#endif /* defined(HAVE_EXPL) && defined(HAVE_LOGL) */
#endif /* defined(HAVE_EXP10L) */
#ifdef HAVE_LOG2L
#define FUNC_LOG2 log2l
#else
#ifdef HAVE_LOGL
#define FUNC_LOG2(x) (logl(x) / logl(2.0))
#endif
#else
#ifdef HAVE_LOG
#define FUNC_LOG2(x) ((long double)log(x) / log(2.0))
#endif /* defined(HAVE_LOG) */
#endif /* defined(HAVE_LOGL) */
#endif /* defined(HAVE_LOG2L) */
#ifdef HAVE_LOG10L
#define FUNC_LOG10 log10l
#else
#ifdef HAVE_LOGL
#define FUNC_LOG10(x) (logl(x) / logl(10.0))
#endif
#else /* defined(__USE_ISOC99) */
#define FP___PRINTF "%.16g"
#define FP___FMOD fmod
#define FP___STRTOD strtod
#define FP___TYPE double
#define FUNC_COS cos
#define FUNC_SIN sin
#define FUNC_TAN tan
#define FUNC_ACOS acos
#define FUNC_ASIN asin
#define FUNC_ATAN atan
#define FUNC_ATAN2 atan2
#define FUNC_POW pow
#define FUNC_SQRT sqrt
#define FUNC_FLOOR floor
#define FUNC_CEIL ceil
#define FUNC_RINT rint
#define FUNC_EXP exp
#define FUNC_LOG log
#define FUNC_REMAINDER remainder
#ifdef HAVE_ROUND
#define FUNC_ROUND round
#else
#undef FUNC_ROUND
#endif
#ifdef HAVE_TRUNC
#define FUNC_TRUNC round
#else
#undef FUNC_TRUNC
#endif
#ifdef HAVE_EXP2
#define FUNC_EXP2 exp2
#else
#define FUNC_EXP2(x) exp((x) * log(2.0))
#endif
#ifdef HAVE_EXP10
#define FUNC_EXP10 exp10
#else
#define FUNC_EXP10(x) exp((x) * log(10.0))
#endif
#ifdef HAVE_LOG2
#define FUNC_LOG2 log2
#else
#define FUNC_LOG2(x) (log(x) / log(2.0))
#endif
#ifdef HAVE_LOG10
#define FUNC_LOG10 log10
#else
#define FUNC_LOG10(x) (log(x) / log(10.0))
#endif
#endif /* defined(__USE_ISOC99) */
#ifdef HAVE_LOG
#define FUNC_LOG10(x) ((long double)log(x) / log(10.0))
#endif /* defined(HAVE_LOG) */
#endif /* defined(HAVE_LOGL) */
#endif /* defined(HAVE_LOG10L) */
#include <stdlib.h>
@@ -299,7 +409,6 @@
#include <regex.h>
#include <limits.h>
#include "asterisk.h"
#include "asterisk/ast_expr.h"
#include "asterisk/logger.h"
#ifndef STANDALONE
@@ -444,13 +553,13 @@ int ast_yyerror(const char *,YYLTYPE *, struct parse_io *);
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
#line 305 "../main/ast_expr2.y"
#line 414 "../main/ast_expr2.y"
{
struct val *val;
struct expr_node *arglist;
}
/* Line 187 of yacc.c. */
#line 454 "../main/ast_expr2.c"
#line 563 "../main/ast_expr2.c"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
@@ -472,13 +581,13 @@ typedef struct YYLTYPE
/* Copy the second part of user declarations. */
#line 310 "../main/ast_expr2.y"
#line 419 "../main/ast_expr2.y"
extern int ast_yylex __P((YYSTYPE *, YYLTYPE *, yyscan_t));
/* Line 216 of yacc.c. */
#line 482 "../main/ast_expr2.c"
#line 591 "../main/ast_expr2.c"
#ifdef short
# undef short
@@ -774,9 +883,9 @@ static const yytype_int8 yyrhs[] =
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
0, 336, 336, 344, 351, 352, 361, 367, 368, 372,
376, 380, 384, 388, 392, 396, 400, 404, 408, 412,
416, 420, 424, 428, 432, 436, 440
0, 445, 445, 453, 460, 461, 470, 476, 477, 481,
485, 489, 493, 497, 501, 505, 509, 513, 517, 521,
525, 529, 533, 537, 541, 545, 549
};
#endif
@@ -1429,114 +1538,114 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp)
switch (yytype)
{
case 4: /* "TOK_COLONCOLON" */
#line 330 "../main/ast_expr2.y"
#line 439 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1435 "../main/ast_expr2.c"
#line 1544 "../main/ast_expr2.c"
break;
case 5: /* "TOK_COND" */
#line 330 "../main/ast_expr2.y"
#line 439 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1440 "../main/ast_expr2.c"
#line 1549 "../main/ast_expr2.c"
break;
case 6: /* "TOK_OR" */
#line 330 "../main/ast_expr2.y"
#line 439 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1445 "../main/ast_expr2.c"
#line 1554 "../main/ast_expr2.c"
break;
case 7: /* "TOK_AND" */
#line 330 "../main/ast_expr2.y"
#line 439 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1450 "../main/ast_expr2.c"
#line 1559 "../main/ast_expr2.c"
break;
case 8: /* "TOK_NE" */
#line 330 "../main/ast_expr2.y"
#line 439 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1455 "../main/ast_expr2.c"
#line 1564 "../main/ast_expr2.c"
break;
case 9: /* "TOK_LE" */
#line 330 "../main/ast_expr2.y"
#line 439 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1460 "../main/ast_expr2.c"
#line 1569 "../main/ast_expr2.c"
break;
case 10: /* "TOK_GE" */
#line 330 "../main/ast_expr2.y"
#line 439 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1465 "../main/ast_expr2.c"
#line 1574 "../main/ast_expr2.c"
break;
case 11: /* "TOK_LT" */
#line 330 "../main/ast_expr2.y"
#line 439 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1470 "../main/ast_expr2.c"
#line 1579 "../main/ast_expr2.c"
break;
case 12: /* "TOK_GT" */
#line 330 "../main/ast_expr2.y"
#line 439 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1475 "../main/ast_expr2.c"
#line 1584 "../main/ast_expr2.c"
break;
case 13: /* "TOK_EQ" */
#line 330 "../main/ast_expr2.y"
#line 439 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1480 "../main/ast_expr2.c"
#line 1589 "../main/ast_expr2.c"
break;
case 14: /* "TOK_MINUS" */
#line 330 "../main/ast_expr2.y"
#line 439 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1485 "../main/ast_expr2.c"
#line 1594 "../main/ast_expr2.c"
break;
case 15: /* "TOK_PLUS" */
#line 330 "../main/ast_expr2.y"
#line 439 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1490 "../main/ast_expr2.c"
#line 1599 "../main/ast_expr2.c"
break;
case 16: /* "TOK_MOD" */
#line 330 "../main/ast_expr2.y"
#line 439 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1495 "../main/ast_expr2.c"
#line 1604 "../main/ast_expr2.c"
break;
case 17: /* "TOK_DIV" */
#line 330 "../main/ast_expr2.y"
#line 439 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1500 "../main/ast_expr2.c"
#line 1609 "../main/ast_expr2.c"
break;
case 18: /* "TOK_MULT" */
#line 330 "../main/ast_expr2.y"
#line 439 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1505 "../main/ast_expr2.c"
#line 1614 "../main/ast_expr2.c"
break;
case 19: /* "TOK_COMPL" */
#line 330 "../main/ast_expr2.y"
#line 439 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1510 "../main/ast_expr2.c"
#line 1619 "../main/ast_expr2.c"
break;
case 20: /* "TOK_EQTILDE" */
#line 330 "../main/ast_expr2.y"
#line 439 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1515 "../main/ast_expr2.c"
#line 1624 "../main/ast_expr2.c"
break;
case 21: /* "TOK_COLON" */
#line 330 "../main/ast_expr2.y"
#line 439 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1520 "../main/ast_expr2.c"
#line 1629 "../main/ast_expr2.c"
break;
case 22: /* "TOK_LP" */
#line 330 "../main/ast_expr2.y"
#line 439 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1525 "../main/ast_expr2.c"
#line 1634 "../main/ast_expr2.c"
break;
case 23: /* "TOK_RP" */
#line 330 "../main/ast_expr2.y"
#line 439 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1530 "../main/ast_expr2.c"
#line 1639 "../main/ast_expr2.c"
break;
case 24: /* "TOKEN" */
#line 330 "../main/ast_expr2.y"
#line 439 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1535 "../main/ast_expr2.c"
#line 1644 "../main/ast_expr2.c"
break;
case 28: /* "expr" */
#line 330 "../main/ast_expr2.y"
#line 439 "../main/ast_expr2.y"
{ free_value((yyvaluep->val)); };
#line 1540 "../main/ast_expr2.c"
#line 1649 "../main/ast_expr2.c"
break;
default:
@@ -1859,7 +1968,7 @@ yyreduce:
switch (yyn)
{
case 2:
#line 336 "../main/ast_expr2.y"
#line 445 "../main/ast_expr2.y"
{ ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1);
((struct parse_io *)parseio)->val->type = (yyvsp[(1) - (1)].val)->type;
if( (yyvsp[(1) - (1)].val)->type == AST_EXPR_number )
@@ -1871,7 +1980,7 @@ yyreduce:
break;
case 3:
#line 344 "../main/ast_expr2.y"
#line 453 "../main/ast_expr2.y"
{/* nothing */ ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1);
((struct parse_io *)parseio)->val->type = AST_EXPR_string;
((struct parse_io *)parseio)->val->u.s = strdup("");
@@ -1879,12 +1988,12 @@ yyreduce:
break;
case 4:
#line 351 "../main/ast_expr2.y"
#line 460 "../main/ast_expr2.y"
{ (yyval.arglist) = alloc_expr_node(AST_EXPR_NODE_VAL); (yyval.arglist)->val = (yyvsp[(1) - (1)].val);;}
break;
case 5:
#line 352 "../main/ast_expr2.y"
#line 461 "../main/ast_expr2.y"
{struct expr_node *x = alloc_expr_node(AST_EXPR_NODE_VAL);
struct expr_node *t;
DESTROY((yyvsp[(2) - (3)].val));
@@ -1894,7 +2003,7 @@ yyreduce:
break;
case 6:
#line 361 "../main/ast_expr2.y"
#line 470 "../main/ast_expr2.y"
{ (yyval.val) = op_func((yyvsp[(1) - (4)].val),(yyvsp[(3) - (4)].arglist), ((struct parse_io *)parseio)->chan);
DESTROY((yyvsp[(2) - (4)].val));
DESTROY((yyvsp[(4) - (4)].val));
@@ -1904,12 +2013,12 @@ yyreduce:
break;
case 7:
#line 367 "../main/ast_expr2.y"
#line 476 "../main/ast_expr2.y"
{(yyval.val) = (yyvsp[(1) - (1)].val);;}
break;
case 8:
#line 368 "../main/ast_expr2.y"
#line 477 "../main/ast_expr2.y"
{ (yyval.val) = (yyvsp[(2) - (3)].val);
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
(yyloc).first_line=0; (yyloc).last_line=0;
@@ -1917,7 +2026,7 @@ yyreduce:
break;
case 9:
#line 372 "../main/ast_expr2.y"
#line 481 "../main/ast_expr2.y"
{ (yyval.val) = op_or ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1925,7 +2034,7 @@ yyreduce:
break;
case 10:
#line 376 "../main/ast_expr2.y"
#line 485 "../main/ast_expr2.y"
{ (yyval.val) = op_and ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1933,7 +2042,7 @@ yyreduce:
break;
case 11:
#line 380 "../main/ast_expr2.y"
#line 489 "../main/ast_expr2.y"
{ (yyval.val) = op_eq ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1941,7 +2050,7 @@ yyreduce:
break;
case 12:
#line 384 "../main/ast_expr2.y"
#line 493 "../main/ast_expr2.y"
{ (yyval.val) = op_gt ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1949,7 +2058,7 @@ yyreduce:
break;
case 13:
#line 388 "../main/ast_expr2.y"
#line 497 "../main/ast_expr2.y"
{ (yyval.val) = op_lt ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1957,7 +2066,7 @@ yyreduce:
break;
case 14:
#line 392 "../main/ast_expr2.y"
#line 501 "../main/ast_expr2.y"
{ (yyval.val) = op_ge ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1965,7 +2074,7 @@ yyreduce:
break;
case 15:
#line 396 "../main/ast_expr2.y"
#line 505 "../main/ast_expr2.y"
{ (yyval.val) = op_le ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1973,7 +2082,7 @@ yyreduce:
break;
case 16:
#line 400 "../main/ast_expr2.y"
#line 509 "../main/ast_expr2.y"
{ (yyval.val) = op_ne ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1981,7 +2090,7 @@ yyreduce:
break;
case 17:
#line 404 "../main/ast_expr2.y"
#line 513 "../main/ast_expr2.y"
{ (yyval.val) = op_plus ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1989,7 +2098,7 @@ yyreduce:
break;
case 18:
#line 408 "../main/ast_expr2.y"
#line 517 "../main/ast_expr2.y"
{ (yyval.val) = op_minus ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -1997,7 +2106,7 @@ yyreduce:
break;
case 19:
#line 412 "../main/ast_expr2.y"
#line 521 "../main/ast_expr2.y"
{ (yyval.val) = op_negate ((yyvsp[(2) - (2)].val));
DESTROY((yyvsp[(1) - (2)].val));
(yyloc).first_column = (yylsp[(1) - (2)]).first_column; (yyloc).last_column = (yylsp[(2) - (2)]).last_column;
@@ -2005,7 +2114,7 @@ yyreduce:
break;
case 20:
#line 416 "../main/ast_expr2.y"
#line 525 "../main/ast_expr2.y"
{ (yyval.val) = op_compl ((yyvsp[(2) - (2)].val));
DESTROY((yyvsp[(1) - (2)].val));
(yyloc).first_column = (yylsp[(1) - (2)]).first_column; (yyloc).last_column = (yylsp[(2) - (2)]).last_column;
@@ -2013,7 +2122,7 @@ yyreduce:
break;
case 21:
#line 420 "../main/ast_expr2.y"
#line 529 "../main/ast_expr2.y"
{ (yyval.val) = op_times ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -2021,7 +2130,7 @@ yyreduce:
break;
case 22:
#line 424 "../main/ast_expr2.y"
#line 533 "../main/ast_expr2.y"
{ (yyval.val) = op_div ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -2029,7 +2138,7 @@ yyreduce:
break;
case 23:
#line 428 "../main/ast_expr2.y"
#line 537 "../main/ast_expr2.y"
{ (yyval.val) = op_rem ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -2037,7 +2146,7 @@ yyreduce:
break;
case 24:
#line 432 "../main/ast_expr2.y"
#line 541 "../main/ast_expr2.y"
{ (yyval.val) = op_colon ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -2045,7 +2154,7 @@ yyreduce:
break;
case 25:
#line 436 "../main/ast_expr2.y"
#line 545 "../main/ast_expr2.y"
{ (yyval.val) = op_eqtilde ((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val));
DESTROY((yyvsp[(2) - (3)].val));
(yyloc).first_column = (yylsp[(1) - (3)]).first_column; (yyloc).last_column = (yylsp[(3) - (3)]).last_column;
@@ -2053,7 +2162,7 @@ yyreduce:
break;
case 26:
#line 440 "../main/ast_expr2.y"
#line 549 "../main/ast_expr2.y"
{ (yyval.val) = op_cond ((yyvsp[(1) - (5)].val), (yyvsp[(3) - (5)].val), (yyvsp[(5) - (5)].val));
DESTROY((yyvsp[(2) - (5)].val));
DESTROY((yyvsp[(4) - (5)].val));
@@ -2063,7 +2172,7 @@ yyreduce:
/* Line 1267 of yacc.c. */
#line 2067 "../main/ast_expr2.c"
#line 2176 "../main/ast_expr2.c"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -2283,7 +2392,7 @@ yyreturn:
}
#line 447 "../main/ast_expr2.y"
#line 556 "../main/ast_expr2.y"
static struct expr_node *alloc_expr_node(enum node_type nt)
@@ -2374,7 +2483,7 @@ to_number (struct val *vp)
/* vp->type == AST_EXPR_numeric_string, make it numeric */
errno = 0;
i = FP___STRTOD(vp->u.s, (char**)0); /* either strtod, or strtold on a good day */
i = FUNC_STRTOD(vp->u.s, (char**)0); /* either strtod, or strtold on a good day */
if (errno != 0) {
ast_log(LOG_WARNING,"Conversion of %s to number under/overflowed!\n", vp->u.s);
free(vp->u.s);
@@ -2584,8 +2693,9 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
if (strspn(funcname->u.s,"ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789") == strlen(funcname->u.s))
{
struct val *result;
if (strcmp(funcname->u.s,"COS") == 0) {
if (0) {
#ifdef FUNC_COS
} else if (strcmp(funcname->u.s,"COS") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
result = make_number(FUNC_COS(arglist->val->u.i));
@@ -2594,6 +2704,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_SIN
} else if (strcmp(funcname->u.s,"SIN") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -2603,6 +2715,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_TAN
} else if (strcmp(funcname->u.s,"TAN") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -2612,6 +2726,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_ACOS
} else if (strcmp(funcname->u.s,"ACOS") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -2621,6 +2737,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_ASIN
} else if (strcmp(funcname->u.s,"ASIN") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -2630,6 +2748,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_ATAN
} else if (strcmp(funcname->u.s,"ATAN") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -2639,6 +2759,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_ATAN2
} else if (strcmp(funcname->u.s,"ATAN2") == 0) {
if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){
to_number(arglist->val);
@@ -2649,6 +2771,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_POW
} else if (strcmp(funcname->u.s,"POW") == 0) {
if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){
to_number(arglist->val);
@@ -2659,6 +2783,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_SQRT
} else if (strcmp(funcname->u.s,"SQRT") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -2668,6 +2794,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_FLOOR
} else if (strcmp(funcname->u.s,"FLOOR") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -2677,6 +2805,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_CEIL
} else if (strcmp(funcname->u.s,"CEIL") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -2686,6 +2816,7 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_ROUND
} else if (strcmp(funcname->u.s,"ROUND") == 0) {
if (arglist && !arglist->right && arglist->val){
@@ -2697,6 +2828,7 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
return make_number(0.0);
}
#endif /* defined(FUNC_ROUND) */
#ifdef FUNC_RINT
} else if (strcmp(funcname->u.s,"RINT") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -2706,6 +2838,7 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_TRUNC
} else if (strcmp(funcname->u.s,"TRUNC") == 0) {
if (arglist && !arglist->right && arglist->val){
@@ -2717,6 +2850,7 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
return make_number(0.0);
}
#endif /* defined(FUNC_TRUNC) */
#ifdef FUNC_EXP
} else if (strcmp(funcname->u.s,"EXP") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -2726,6 +2860,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_EXP2
} else if (strcmp(funcname->u.s,"EXP2") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -2735,6 +2871,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_EXP10
} else if (strcmp(funcname->u.s,"EXP10") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -2744,6 +2882,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_LOG
} else if (strcmp(funcname->u.s,"LOG") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -2753,6 +2893,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_LOG2
} else if (strcmp(funcname->u.s,"LOG2") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -2762,6 +2904,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_LOG10
} else if (strcmp(funcname->u.s,"LOG10") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -2771,6 +2915,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_REMAINDER
} else if (strcmp(funcname->u.s,"REMAINDER") == 0) {
if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){
to_number(arglist->val);
@@ -2781,6 +2927,7 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
} else {
/* is this a custom function we should execute and collect the results of? */
#ifndef STANDALONE
@@ -2797,7 +2944,7 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
f->read(chan, funcname->u.s, argbuf, workspace, sizeof(workspace));
free(argbuf);
if (is_really_num(workspace))
return make_number(FP___STRTOD(workspace,(char **)NULL));
return make_number(FUNC_STRTOD(workspace,(char **)NULL));
else
return make_str(workspace);
} else {
@@ -3275,7 +3422,7 @@ op_rem (struct val *a, struct val *b)
return(b);
}
r = make_number (FP___FMOD(a->u.i, b->u.i)); /* either fmod or fmodl if FP___TYPE is available */
r = make_number (FUNC_FMOD(a->u.i, b->u.i)); /* either fmod or fmodl if FP___TYPE is available */
/* chk_rem necessary ??? */
free_value (a);
free_value (b);

View File

@@ -92,7 +92,7 @@
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
#line 305 "../main/ast_expr2.y"
#line 414 "../main/ast_expr2.y"
{
struct val *val;
struct expr_node *arglist;

View File

@@ -14,40 +14,186 @@
#include <sys/types.h>
#include <stdio.h>
#include "asterisk.h"
/* Instead of looking for an arbitrary keyword, just test for various C99 function presence */
#if (defined(HAVE_ROUNDL) || defined(HAVE_TRUNCL) || defined(HAVE_LOG10L) || defined(HAVE_LOG2L))
#ifndef __USE_ISOC99
#define __USE_ISOC99
#endif
#endif
#ifdef __USE_ISOC99
#define FP___PRINTF "%.18Lg"
#define FP___FMOD fmodl
#define FP___STRTOD strtold
#define FP___TYPE long double
#define FUNC_COS cosl
#define FUNC_SIN sinl
#define FUNC_TAN tanl
#define FUNC_ACOS acosl
#define FUNC_ASIN asinl
#define FUNC_ATAN atanl
#define FUNC_ATAN2 atan2l
#define FUNC_POW powl
#define FUNC_SQRT sqrtl
#ifdef HAVE_COSL
#define FUNC_COS cosl
#else
#ifdef HAVE_COS
#define FUNC_COS (long double)cos
#else
#undef FUNC_COS
#endif
#endif
#ifdef HAVE_SINL
#define FUNC_SIN sinl
#else
#ifdef HAVE_SIN
#define FUNC_SIN (long double)sin
#else
#undef FUNC_SIN
#endif
#endif
#ifdef HAVE_TANL
#define FUNC_TAN tanl
#else
#ifdef HAVE_TAN
#define FUNC_TAN (long double)tan
#else
#undef FUNC_TAN
#endif
#endif
#ifdef HAVE_ACOSL
#define FUNC_ACOS acosl
#else
#ifdef HAVE_ACOS
#define FUNC_ACOS (long double)acos
#else
#undef FUNC_ACOS
#endif
#endif
#ifdef HAVE_ASINL
#define FUNC_ASIN asinl
#else
#ifdef HAVE_ASIN
#define FUNC_ASIN (long double)asin
#else
#undef FUNC_ASIN
#endif
#endif
#ifdef HAVE_ATANL
#define FUNC_ATAN atanl
#else
#ifdef HAVE_ATAN
#define FUNC_ATAN (long double)atan
#else
#undef FUNC_ATAN
#endif
#endif
#ifdef HAVE_ATAN2L
#define FUNC_ATAN2 atan2l
#else
#ifdef HAVE_ATAN2
#define FUNC_ATAN2 (long double)atan2
#else
#undef FUNC_ATAN2
#endif
#endif
#ifdef HAVE_POWL
#define FUNC_POW powl
#else
#ifdef HAVE_POW
#define FUNC_POW (long double)pow
#else
#undef FUNC_POW
#endif
#endif
#ifdef HAVE_SQRTL
#define FUNC_SQRT sqrtl
#else
#ifdef HAVE_SQRT
#define FUNC_SQRT (long double)sqrt
#else
#undef FUNC_SQRT
#endif
#endif
#ifdef HAVE_RINTL
#define FUNC_RINT rintl
#else
#ifdef HAVE_RINT
#define FUNC_RINT (long double)rint
#else
#undef FUNC_RINT
#endif
#endif
#ifdef HAVE_EXPL
#define FUNC_EXP expl
#else
#ifdef HAVE_EXP
#define FUNC_EXP (long double)exp
#else
#undef FUNC_EXP
#endif
#endif
#ifdef HAVE_LOGL
#define FUNC_LOG logl
#else
#ifdef HAVE_LOG
#define FUNC_LOG (long double)log
#else
#undef FUNC_LOG
#endif
#endif
#ifdef HAVE_REMINDERL
#define FUNC_REMINDER reminderl
#else
#ifdef HAVE_REMINDER
#define FUNC_REMINDER (long double)reminder
#else
#undef FUNC_REMINDER
#endif
#endif
#ifdef HAVE_FMODL
#define FUNC_FMOD fmodl
#else
#ifdef HAVE_FMOD
#define FUNC_FMOD (long double)fmod
#else
#undef FUNC_FMOD
#endif
#endif
#ifdef HAVE_STRTOLD
#define FUNC_STRTOD strtold
#else
#ifdef HAVE_STRTOD
#define FUNC_STRTOD (long double)strtod
#else
#undef FUNC_STRTOD
#endif
#endif
#ifdef HAVE_FLOORL
#define FUNC_FLOOR floorl
#else
#ifdef HAVE_FLOOR
#define FUNC_FLOOR (long double)floor
#else
#undef FUNC_FLOOR
#endif /* defined(HAVE_FLOOR) */
#endif /* defined(HAVE_FLOORL) */
#ifdef HAVE_CEILL
#define FUNC_CEIL ceill
#define FUNC_RINT rintl
#define FUNC_EXP expl
#define FUNC_LOG logl
#define FUNC_REMAINDER remainderl
#else
#ifdef HAVE_CEIL
#define FUNC_CEIL (long double)ceil
#else
#undef FUNC_CEIL
#endif /* defined(HAVE_CEIL) */
#endif /* defined(HAVE_CEILL) */
#ifdef HAVE_ROUNDL
#define FUNC_ROUND roundl
#else /* HAVE_ROUNDL */
#ifdef HAVE_ROUND
#define FUNC_ROUND round
#define FUNC_ROUND (long double)round
#else /* HAVE_ROUND */
#undef FUNC_ROUND
#endif /* HAVE_ROUND */
@@ -57,7 +203,7 @@
#define FUNC_TRUNC truncl
#else /* HAVE_TRUNCL */
#ifdef HAVE_TRUNC
#define FUNC_TRUNC trunc
#define FUNC_TRUNC (long double)trunc
#else /* HAVE_TRUNC */
#undef FUNC_TRUNC
#endif /* HAVE_TRUNC */
@@ -70,86 +216,50 @@
#ifdef HAVE_EXP2L
#define FUNC_EXP2 exp2l
#else
#if (defined(HAVE_EXPL) && defined(HAVE_LOGL))
#define FUNC_EXP2(x) expl((x) * logl(2.0))
#endif
#else
#if (defined(HAVE_EXP) && defined(HAVE_LOG))
#define FUNC_EXP2(x) (long double)exp((x) * log(2.0))
#endif /* defined(HAVE_EXP) && defined(HAVE_LOG) */
#endif /* defined(HAVE_EXPL) && defined(HAVE_LOGL) */
#endif /* defined(HAVE_EXP2L) */
#ifdef HAVE_EXP10L
#define FUNC_EXP10 exp10l
#else
#if (defined(HAVE_EXPL) && defined(HAVE_LOGL))
#define FUNC_EXP10(x) expl((x) * logl(10.0))
#endif
#else
#if (defined(HAVE_EXP) && defined(HAVE_LOG))
#define FUNC_EXP10(x) (long double)exp((x) * log(10.0))
#endif /* defined(HAVE_EXP) && defined(HAVE_LOG) */
#endif /* defined(HAVE_EXPL) && defined(HAVE_LOGL) */
#endif /* defined(HAVE_EXP10L) */
#ifdef HAVE_LOG2L
#define FUNC_LOG2 log2l
#else
#ifdef HAVE_LOGL
#define FUNC_LOG2(x) (logl(x) / logl(2.0))
#endif
#else
#ifdef HAVE_LOG
#define FUNC_LOG2(x) ((long double)log(x) / log(2.0))
#endif /* defined(HAVE_LOG) */
#endif /* defined(HAVE_LOGL) */
#endif /* defined(HAVE_LOG2L) */
#ifdef HAVE_LOG10L
#define FUNC_LOG10 log10l
#else
#ifdef HAVE_LOGL
#define FUNC_LOG10(x) (logl(x) / logl(10.0))
#endif
#else /* defined(__USE_ISOC99) */
#define FP___PRINTF "%.16g"
#define FP___FMOD fmod
#define FP___STRTOD strtod
#define FP___TYPE double
#define FUNC_COS cos
#define FUNC_SIN sin
#define FUNC_TAN tan
#define FUNC_ACOS acos
#define FUNC_ASIN asin
#define FUNC_ATAN atan
#define FUNC_ATAN2 atan2
#define FUNC_POW pow
#define FUNC_SQRT sqrt
#define FUNC_FLOOR floor
#define FUNC_CEIL ceil
#define FUNC_RINT rint
#define FUNC_EXP exp
#define FUNC_LOG log
#define FUNC_REMAINDER remainder
#ifdef HAVE_ROUND
#define FUNC_ROUND round
#else
#undef FUNC_ROUND
#endif
#ifdef HAVE_TRUNC
#define FUNC_TRUNC round
#else
#undef FUNC_TRUNC
#endif
#ifdef HAVE_EXP2
#define FUNC_EXP2 exp2
#else
#define FUNC_EXP2(x) exp((x) * log(2.0))
#endif
#ifdef HAVE_EXP10
#define FUNC_EXP10 exp10
#else
#define FUNC_EXP10(x) exp((x) * log(10.0))
#endif
#ifdef HAVE_LOG2
#define FUNC_LOG2 log2
#else
#define FUNC_LOG2(x) (log(x) / log(2.0))
#endif
#ifdef HAVE_LOG10
#define FUNC_LOG10 log10
#else
#define FUNC_LOG10(x) (log(x) / log(10.0))
#endif
#endif /* defined(__USE_ISOC99) */
#ifdef HAVE_LOG
#define FUNC_LOG10(x) ((long double)log(x) / log(10.0))
#endif /* defined(HAVE_LOG) */
#endif /* defined(HAVE_LOGL) */
#endif /* defined(HAVE_LOG10L) */
#include <stdlib.h>
@@ -170,7 +280,6 @@
#include <regex.h>
#include <limits.h>
#include "asterisk.h"
#include "asterisk/ast_expr.h"
#include "asterisk/logger.h"
#ifndef STANDALONE
@@ -534,7 +643,7 @@ to_number (struct val *vp)
/* vp->type == AST_EXPR_numeric_string, make it numeric */
errno = 0;
i = FP___STRTOD(vp->u.s, (char**)0); /* either strtod, or strtold on a good day */
i = FUNC_STRTOD(vp->u.s, (char**)0); /* either strtod, or strtold on a good day */
if (errno != 0) {
ast_log(LOG_WARNING,"Conversion of %s to number under/overflowed!\n", vp->u.s);
free(vp->u.s);
@@ -744,8 +853,9 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
if (strspn(funcname->u.s,"ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789") == strlen(funcname->u.s))
{
struct val *result;
if (strcmp(funcname->u.s,"COS") == 0) {
if (0) {
#ifdef FUNC_COS
} else if (strcmp(funcname->u.s,"COS") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
result = make_number(FUNC_COS(arglist->val->u.i));
@@ -754,6 +864,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_SIN
} else if (strcmp(funcname->u.s,"SIN") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -763,6 +875,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_TAN
} else if (strcmp(funcname->u.s,"TAN") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -772,6 +886,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_ACOS
} else if (strcmp(funcname->u.s,"ACOS") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -781,6 +897,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_ASIN
} else if (strcmp(funcname->u.s,"ASIN") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -790,6 +908,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_ATAN
} else if (strcmp(funcname->u.s,"ATAN") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -799,6 +919,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_ATAN2
} else if (strcmp(funcname->u.s,"ATAN2") == 0) {
if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){
to_number(arglist->val);
@@ -809,6 +931,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_POW
} else if (strcmp(funcname->u.s,"POW") == 0) {
if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){
to_number(arglist->val);
@@ -819,6 +943,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_SQRT
} else if (strcmp(funcname->u.s,"SQRT") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -828,6 +954,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_FLOOR
} else if (strcmp(funcname->u.s,"FLOOR") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -837,6 +965,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_CEIL
} else if (strcmp(funcname->u.s,"CEIL") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -846,6 +976,7 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_ROUND
} else if (strcmp(funcname->u.s,"ROUND") == 0) {
if (arglist && !arglist->right && arglist->val){
@@ -857,6 +988,7 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
return make_number(0.0);
}
#endif /* defined(FUNC_ROUND) */
#ifdef FUNC_RINT
} else if (strcmp(funcname->u.s,"RINT") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -866,6 +998,7 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_TRUNC
} else if (strcmp(funcname->u.s,"TRUNC") == 0) {
if (arglist && !arglist->right && arglist->val){
@@ -877,6 +1010,7 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
return make_number(0.0);
}
#endif /* defined(FUNC_TRUNC) */
#ifdef FUNC_EXP
} else if (strcmp(funcname->u.s,"EXP") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -886,6 +1020,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_EXP2
} else if (strcmp(funcname->u.s,"EXP2") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -895,6 +1031,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_EXP10
} else if (strcmp(funcname->u.s,"EXP10") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -904,6 +1042,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_LOG
} else if (strcmp(funcname->u.s,"LOG") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -913,6 +1053,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_LOG2
} else if (strcmp(funcname->u.s,"LOG2") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -922,6 +1064,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_LOG10
} else if (strcmp(funcname->u.s,"LOG10") == 0) {
if (arglist && !arglist->right && arglist->val){
to_number(arglist->val);
@@ -931,6 +1075,8 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
#ifdef FUNC_REMAINDER
} else if (strcmp(funcname->u.s,"REMAINDER") == 0) {
if (arglist && arglist->right && !arglist->right->right && arglist->val && arglist->right->val){
to_number(arglist->val);
@@ -941,6 +1087,7 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
ast_log(LOG_WARNING,"Wrong args to %s() function\n",funcname->u.s);
return make_number(0.0);
}
#endif
} else {
/* is this a custom function we should execute and collect the results of? */
#ifndef STANDALONE
@@ -957,7 +1104,7 @@ static struct val *op_func(struct val *funcname, struct expr_node *arglist, stru
f->read(chan, funcname->u.s, argbuf, workspace, sizeof(workspace));
free(argbuf);
if (is_really_num(workspace))
return make_number(FP___STRTOD(workspace,(char **)NULL));
return make_number(FUNC_STRTOD(workspace,(char **)NULL));
else
return make_str(workspace);
} else {
@@ -1435,7 +1582,7 @@ op_rem (struct val *a, struct val *b)
return(b);
}
r = make_number (FP___FMOD(a->u.i, b->u.i)); /* either fmod or fmodl if FP___TYPE is available */
r = make_number (FUNC_FMOD(a->u.i, b->u.i)); /* either fmod or fmodl if FP___TYPE is available */
/* chk_rem necessary ??? */
free_value (a);
free_value (b);