Index: doc/channelvariables.tex =================================================================== --- doc/channelvariables.tex (revision 72704) +++ doc/channelvariables.tex (working copy) @@ -207,19 +207,19 @@ an empty string or zero; otherwise, returns zero. expr1 {=, >, >=, <, <=, !=} expr2 - Return the results of integer comparison if both arguments are - integers; otherwise, returns the results of string comparison + Return the results of floating point comparison if both arguments are + numbers; otherwise, returns the results of string comparison using the locale-specific collation sequence. The result of each comparison is 1 if the specified relation is true, or 0 if the relation is false. expr1 {+, -} expr2 - Return the results of addition or subtraction of integer-valued - arguments. + Return the results of addition or subtraction of float-valued + arguments (type 'long double', or 96-128 bit floating point numbers, if possible). expr1 {*, /, %} expr2 - Return the results of multiplication, integer division, or - remainder of integer-valued arguments. + Return the results of multiplication, division, or + remainder of floating point valued arguments (96-128 bit if possible). - expr1 Return the result of subtracting expr1 from 0. @@ -319,10 +319,15 @@ \subsection{Numbers Vs. Strings} -Tokens consisting only of numbers are converted to 64-bit numbers for -most of the operators. This means that overflows can occur when the -numbers get above 18 digits. Warnings will appear in the logs in this -case. +Tokens consisting only of numbers, and optionally containing a '.', are converted to 96-128-bit floating point (long double) numbers for +most of the operators. +Since the %.16Lg format of sprintf is used to turn these numbers into +strings, you can expect a maximum of 16 digits of precision. (which is +about all that 96-128 bit floating point can offer). If your system cannot +provide "long double" in the compiler, or "fmodl", or "strtold" in the +math libraries, or "%.16Lg" capability in sprintf, then you can back +it down to plain "double" in ast_expr2.y and ast_expr2.fl by defining +HAS_LONG_DOUBLE to 0. \subsection{Conditionals} Index: UPGRADE.txt =================================================================== --- UPGRADE.txt (revision 72704) +++ UPGRADE.txt (working copy) @@ -23,6 +23,15 @@ the default sound file layout for non-English sounds is the 'new style' layout introduced in Asterisk 1.4 (and used by the automatic sound file installer in the Makefile). +* Expressions (the stuff in $[ ... ]) are now floating point. They + accept simple floating point notation (with a '.' for a decimal point). + **No E notation** is accepted. (as in 3E9 for 3000000000, or 2e2 for 200). + It uses (long double) if __USE_ISOC99 is set in your system; otherwise + it uses plain doubles. (long double) will give you about 16 digits of + precision. keep that in mind as you manipulate numbers in the dialplan. + Also, keep in mind, that if you were depending on truncation because + arithmetic operators were integer, you now must rethink the expressions. + Voicemail: Index: main/ast_expr2f.c =================================================================== --- main/ast_expr2f.c (revision 72704) +++ main/ast_expr2f.c (working copy) @@ -229,8 +229,8 @@ */ int yy_at_bol; - int yy_bs_lineno; /*!< The line count. */ - int yy_bs_column; /*!< The column count. */ + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ /* Whether to try to fill the input buffer when we reach the * end of it. @@ -732,8 +732,8 @@ -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, -23, 39, 39, -23, -23, 39, - -23, -23, -23, -23, 39, -23, 39, -23, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, -23, 39, + -23, -23, -23, -23, 39, -23, 42, -23, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, -23, 39, -23, -23, -23, -23, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, @@ -750,7 +750,7 @@ -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, - -24, -24, -24, -24, -24, -24, -24, -24, 43, -24, + -24, -24, -24, -24, -24, -24, -24, -24, 44, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, -24, @@ -769,7 +769,7 @@ -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, 44, -25, -25, -25, -25, -25, -25, -25, -25, + -25, 45, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, @@ -786,14 +786,14 @@ -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, 45, -26, -26, -26, -26, -26, -26, -26, -26, + -26, 46, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, - -26, -26, -26, -26, -26, -26, 46, -26 + -26, -26, -26, -26, -26, -26, 47, -26 }, { @@ -803,7 +803,7 @@ -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, - -27, 47, -27, -27, -27, -27, -27, -27, -27, -27, + -27, 48, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, -27, @@ -844,25 +844,25 @@ -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, -29, - -29, -29, -29, -29, 48, -29, -29, -29 + -29, -29, -29, -29, 49, -29, -29, -29 }, { - 7, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 7, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 50, 49, 51, 49, 49 + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 51, 50, 52, 50, 50 }, { @@ -900,21 +900,21 @@ }, { - 7, 52, 52, 52, 52, 52, 52, 52, 52, -33, + 7, 53, 53, 53, 53, 53, 53, 53, 53, -33, - -33, 52, 52, -33, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, -33, -33, 52, 52, -33, -33, -33, 52, - -33, -33, -33, -33, 52, -33, 52, -33, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, -33, 52, - -33, -33, -33, -33, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, + -33, 53, 53, -33, 53, 53, 53, 53, 53, 53, + 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, + 53, 53, -33, -33, 53, 53, -33, -33, -33, 53, + -33, -33, -33, -33, 53, -33, 53, -33, 53, 53, + 53, 53, 53, 53, 53, 53, 53, 53, -33, 53, + -33, -33, -33, -33, 53, 53, 53, 53, 53, 53, + 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, + 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, + 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, + 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, -33, 52, 52, 52 + 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, + 53, 53, 53, 53, -33, 53, 53, 53 }, { @@ -948,7 +948,7 @@ -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, -35, - -35, -35, -35, 53, -35, -35, -35, -35 + -35, -35, -35, 54, -35, -35, -35, -35 }, { @@ -1061,8 +1061,8 @@ -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, -42, 39, 39, -42, -42, 39, - -42, -42, -42, -42, 39, -42, 39, -42, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, -42, 39, + -42, -42, -42, -42, 39, -42, 39, -42, 55, 55, + 55, 55, 55, 55, 55, 55, 55, 55, -42, 39, -42, -42, -42, -42, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, @@ -1077,17 +1077,17 @@ -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, + -43, -43, -43, -43, -43, 39, 39, -43, -43, 39, + -43, -43, -43, -43, 39, -43, 42, -43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, -43, 39, + -43, -43, -43, -43, 39, 39, 39, 39, 39, 39, + 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, + 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, + 39, -43, 39, -43, 39, 39, -43, 39, 39, 39, + 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, - -43, -43, -43, -43, -43, -43, -43, -43, -43, -43, - -43, -43, -43, -43, -43, -43, -43, -43 + 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, + 39, 39, 39, -43, -43, -43, -43, -43 }, { @@ -1177,38 +1177,38 @@ }, { - 7, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 7, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, - 49, 49, 49, 50, 49, 51, 49, 49 + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49, -49, -49, + -49, -49, -49, -49, -49, -49, -49, -49 }, { - 7, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, + 7, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50, -50, -50, - -50, -50, -50, -50, -50, -50, -50, -50 + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, + 50, 50, 50, 51, 50, 52, 50, 50 }, { @@ -1229,40 +1229,74 @@ }, { - 7, 52, 52, 52, 52, 52, 52, 52, 52, -52, - -52, 52, 52, -52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, -52, -52, 52, 52, -52, -52, -52, 52, + 7, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, - -52, -52, -52, -52, 52, -52, 52, -52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, -52, 52, - -52, -52, -52, -52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, - 52, 52, 52, 52, -52, 52, 52, 52 + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52, -52, -52, + -52, -52, -52, -52, -52, -52, -52, -52 }, { - 7, -53, -53, -53, -53, -53, -53, -53, -53, -53, + 7, 53, 53, 53, 53, 53, 53, 53, 53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, + -53, 53, 53, -53, 53, 53, 53, 53, 53, 53, + 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, + 53, 53, -53, -53, 53, 53, -53, -53, -53, 53, + -53, -53, -53, -53, 53, -53, 53, -53, 53, 53, + 53, 53, 53, 53, 53, 53, 53, 53, -53, 53, + -53, -53, -53, -53, 53, 53, 53, 53, 53, 53, + 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, + 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, + 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, + 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, - -53, -53, -53, -53, -53, -53, -53, -53, -53, -53, - -53, -53, -53, -53, -53, -53, -53, -53 + 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, + 53, 53, 53, 53, -53, 53, 53, 53 }, + { + 7, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54, -54, -54, + -54, -54, -54, -54, -54, -54, -54, -54 + }, + + { + 7, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, -55, -55, -55, -55, -55, + -55, -55, -55, -55, -55, 39, 39, -55, -55, 39, + -55, -55, -55, -55, 39, -55, 39, -55, 55, 55, + + 55, 55, 55, 55, 55, 55, 55, 55, -55, 39, + -55, -55, -55, -55, 39, 39, 39, 39, 39, 39, + 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, + 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, + 39, -55, 39, -55, 39, 39, -55, 39, 39, 39, + 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, + 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, + 39, 39, 39, -55, -55, -55, -55, -55 + }, + } ; static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); @@ -1290,24 +1324,24 @@ flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static yyconst flex_int16_t yy_accept[54] = +static yyconst flex_int16_t yy_accept[56] = { 0, 0, 0, 0, 0, 32, 32, 36, 35, 25, 27, 19, 35, 29, 29, 17, 2, 22, 23, 15, 13, 14, 16, 28, 20, 9, 3, 8, 18, 1, 35, 31, 30, 32, 33, 33, 12, 0, 26, 29, 24, - 5, 28, 21, 11, 6, 7, 10, 4, 0, 31, - 30, 32, 34 + 5, 29, 28, 21, 11, 6, 7, 10, 4, 0, + 31, 30, 32, 34, 28 } ; -static yyconst yy_state_type yy_NUL_trans[54] = +static yyconst yy_state_type yy_NUL_trans[56] = { 0, 8, 8, 30, 30, 33, 33, 0, 0, 0, 0, 0, 37, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 49, - 0, 0, 52, 0, 0, 0, 37, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 49, 0, - 0, 52, 0 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, + 0, 0, 53, 0, 0, 0, 37, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, + 0, 0, 53, 0, 0 } ; /* The intent behind this definition is that it'll catch @@ -1344,12 +1378,29 @@ #include "asterisk.h" +#include +#include + #ifndef STANDALONE ASTERISK_FILE_VERSION(__FILE__, "$Revision$") +#else +#ifndef __USE_ISOC99 +#define __USE_ISOC99 1 #endif +#endif -#include -#include +#ifdef __USE_ISOC99 +#define FP___PRINTF "%.16Lg" +#define FP___FMOD fmodl +#define FP___STRTOD strtold +#define FP___TYPE long double +#else +#define FP___PRINTF "%.8g" +#define FP___FMOD fmod +#define FP___STRTOD strtod +#define FP___TYPE double +#endif + #include #include #include @@ -1368,14 +1419,14 @@ #include "asterisk/strings.h" enum valtype { - AST_EXPR_integer, AST_EXPR_numeric_string, AST_EXPR_string + AST_EXPR_number, AST_EXPR_numeric_string, AST_EXPR_string } ; struct val { enum valtype type; union { char *s; - quad_t i; + FP___TYPE i; /* long double or just double if it's a bad day */ } u; } ; @@ -1411,17 +1462,19 @@ static int curlycount = 0; static char *expr2_token_subst(char *mess); -#line 1415 "ast_expr2f.c" +#line 1466 "ast_expr2f.c" #define INITIAL 0 #define var 1 #define trail 2 +#ifndef YY_NO_UNISTD_H /* Special case for "unistd.h", since it is non-ANSI. We include it way * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ #include +#endif #ifndef YY_EXTRA_TYPE #define YY_EXTRA_TYPE void * @@ -1436,9 +1489,9 @@ /* The rest are the same as the globals declared in the non-reentrant scanner. */ FILE *yyin_r, *yyout_r; - size_t yy_buffer_stack_top; /*!< index of top of stack. */ - size_t yy_buffer_stack_max; /*!< capacity of stack. */ - YY_BUFFER_STATE * yy_buffer_stack; /*!< Stack as an array. */ + size_t yy_buffer_stack_top; /**< index of top of stack. */ + size_t yy_buffer_stack_max; /**< capacity of stack. */ + YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */ char yy_hold_char; int yy_n_chars; int yyleng_r; @@ -1465,6 +1518,8 @@ }; /* end struct yyguts_t */ +static int yy_init_globals (yyscan_t yyscanner ); + /* This must go here because YYSTYPE and YYLTYPE are included * from bison output in section 1.*/ # define yylval yyg->yylval_r @@ -1599,9 +1654,11 @@ #ifndef YY_DECL #define YY_DECL_IS_OURS 1 -extern int ast_yylex (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner); +extern int ast_yylex \ + (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner); -#define YY_DECL int ast_yylex (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner) +#define YY_DECL int ast_yylex \ + (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner) #endif /* !YY_DECL */ /* Code executed at the beginning of each rule, after yytext and yyleng @@ -1619,8 +1676,7 @@ #define YY_RULE_SETUP \ YY_USER_ACTION -/*! - * \brief The main scanner function which does all the work. +/** The main scanner function which does all the work. */ YY_DECL { @@ -1629,10 +1685,10 @@ register int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; -#line 104 "ast_expr2.fl" +#line 121 "ast_expr2.fl" -#line 1635 "ast_expr2f.c" +#line 1692 "ast_expr2f.c" yylval = yylval_param; @@ -1715,122 +1771,122 @@ case 1: YY_RULE_SETUP -#line 106 "ast_expr2.fl" +#line 123 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_OR;} YY_BREAK case 2: YY_RULE_SETUP -#line 107 "ast_expr2.fl" +#line 124 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_AND;} YY_BREAK case 3: YY_RULE_SETUP -#line 108 "ast_expr2.fl" +#line 125 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_EQ;} YY_BREAK case 4: YY_RULE_SETUP -#line 109 "ast_expr2.fl" +#line 126 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_OR;} YY_BREAK case 5: YY_RULE_SETUP -#line 110 "ast_expr2.fl" +#line 127 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_AND;} YY_BREAK case 6: YY_RULE_SETUP -#line 111 "ast_expr2.fl" +#line 128 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_EQ;} YY_BREAK case 7: YY_RULE_SETUP -#line 112 "ast_expr2.fl" +#line 129 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_EQTILDE;} YY_BREAK case 8: YY_RULE_SETUP -#line 113 "ast_expr2.fl" +#line 130 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_GT;} YY_BREAK case 9: YY_RULE_SETUP -#line 114 "ast_expr2.fl" +#line 131 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_LT;} YY_BREAK case 10: YY_RULE_SETUP -#line 115 "ast_expr2.fl" +#line 132 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_GE;} YY_BREAK case 11: YY_RULE_SETUP -#line 116 "ast_expr2.fl" +#line 133 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_LE;} YY_BREAK case 12: YY_RULE_SETUP -#line 117 "ast_expr2.fl" +#line 134 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_NE;} YY_BREAK case 13: YY_RULE_SETUP -#line 118 "ast_expr2.fl" +#line 135 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_PLUS;} YY_BREAK case 14: YY_RULE_SETUP -#line 119 "ast_expr2.fl" +#line 136 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_MINUS;} YY_BREAK case 15: YY_RULE_SETUP -#line 120 "ast_expr2.fl" +#line 137 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_MULT;} YY_BREAK case 16: YY_RULE_SETUP -#line 121 "ast_expr2.fl" +#line 138 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_DIV;} YY_BREAK case 17: YY_RULE_SETUP -#line 122 "ast_expr2.fl" +#line 139 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_MOD;} YY_BREAK case 18: YY_RULE_SETUP -#line 123 "ast_expr2.fl" +#line 140 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_COND;} YY_BREAK case 19: YY_RULE_SETUP -#line 124 "ast_expr2.fl" +#line 141 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_COMPL;} YY_BREAK case 20: YY_RULE_SETUP -#line 125 "ast_expr2.fl" +#line 142 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_COLON;} YY_BREAK case 21: YY_RULE_SETUP -#line 126 "ast_expr2.fl" +#line 143 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_COLONCOLON;} YY_BREAK case 22: YY_RULE_SETUP -#line 127 "ast_expr2.fl" +#line 144 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_LP;} YY_BREAK case 23: YY_RULE_SETUP -#line 128 "ast_expr2.fl" +#line 145 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; return TOK_RP;} YY_BREAK case 24: YY_RULE_SETUP -#line 129 "ast_expr2.fl" +#line 146 "ast_expr2.fl" { /* gather the contents of ${} expressions, with trailing stuff, * into a single TOKEN. @@ -1843,24 +1899,24 @@ YY_BREAK case 25: YY_RULE_SETUP -#line 139 "ast_expr2.fl" +#line 156 "ast_expr2.fl" {} YY_BREAK case 26: /* rule 26 can match eol */ YY_RULE_SETUP -#line 140 "ast_expr2.fl" +#line 157 "ast_expr2.fl" {SET_COLUMNS; SET_STRING; return TOKEN;} YY_BREAK case 27: /* rule 27 can match eol */ YY_RULE_SETUP -#line 142 "ast_expr2.fl" +#line 159 "ast_expr2.fl" {/* what to do with eol */} YY_BREAK case 28: YY_RULE_SETUP -#line 143 "ast_expr2.fl" +#line 160 "ast_expr2.fl" { SET_COLUMNS; /* the original behavior of the expression parser was @@ -1872,7 +1928,7 @@ YY_BREAK case 29: YY_RULE_SETUP -#line 152 "ast_expr2.fl" +#line 169 "ast_expr2.fl" { SET_COLUMNS; SET_STRING; @@ -1882,7 +1938,7 @@ case 30: /* rule 30 can match eol */ YY_RULE_SETUP -#line 159 "ast_expr2.fl" +#line 176 "ast_expr2.fl" { curlycount--; if (curlycount < 0) { @@ -1896,7 +1952,7 @@ case 31: /* rule 31 can match eol */ YY_RULE_SETUP -#line 169 "ast_expr2.fl" +#line 186 "ast_expr2.fl" { curlycount++; yymore(); @@ -1904,7 +1960,7 @@ YY_BREAK case 32: YY_RULE_SETUP -#line 175 "ast_expr2.fl" +#line 192 "ast_expr2.fl" { BEGIN(0); SET_COLUMNS; @@ -1915,7 +1971,7 @@ case 33: /* rule 33 can match eol */ YY_RULE_SETUP -#line 182 "ast_expr2.fl" +#line 199 "ast_expr2.fl" { char c = yytext[yyleng-1]; BEGIN(0); @@ -1927,7 +1983,7 @@ YY_BREAK case 34: YY_RULE_SETUP -#line 191 "ast_expr2.fl" +#line 208 "ast_expr2.fl" { curlycount = 0; BEGIN(var); @@ -1935,7 +1991,7 @@ } YY_BREAK case YY_STATE_EOF(trail): -#line 197 "ast_expr2.fl" +#line 214 "ast_expr2.fl" { BEGIN(0); SET_COLUMNS; @@ -1946,10 +2002,10 @@ YY_BREAK case 35: YY_RULE_SETUP -#line 205 "ast_expr2.fl" +#line 222 "ast_expr2.fl" ECHO; YY_BREAK -#line 1952 "ast_expr2f.c" +#line 2009 "ast_expr2f.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(var): yyterminate(); @@ -2137,7 +2193,7 @@ else { - size_t num_to_read = + int num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) @@ -2382,11 +2438,10 @@ } #endif /* ifndef YY_NO_INPUT */ -/*! - * \brief Immediately switch to a different input stream. - * \param input_file A readable stream. - * \param yyscanner The scanner object. - * \note This function does not reset the start condition to @c INITIAL . +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . */ void ast_yyrestart (FILE * input_file , yyscan_t yyscanner) { @@ -2402,10 +2457,9 @@ ast_yy_load_buffer_state(yyscanner ); } -/*! - * \brief Switch to a different input buffer. - * \param new_buffer The new input buffer. - * \param yyscanner The scanner object. +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. */ void ast_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { @@ -2448,13 +2502,11 @@ yyg->yy_hold_char = *yyg->yy_c_buf_p; } -/*! - * \brief Allocate and initialize an input buffer state. - * \param file A readable stream. - * \param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * \param yyscanner The scanner object. - * - * \return the allocated buffer state. +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. */ YY_BUFFER_STATE ast_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) { @@ -2480,10 +2532,9 @@ return b; } -/*! - * \brief Destroy the buffer. - * \param b a buffer created with ast_yy_create_buffer() - * \param yyscanner The scanner object. +/** Destroy the buffer. + * @param b a buffer created with ast_yy_create_buffer() + * @param yyscanner The scanner object. */ void ast_yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { @@ -2534,10 +2585,9 @@ errno = oerrno; } -/*! - * \brief Discard all buffered characters. On the next scan, YY_INPUT will be called. - * \param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * \param yyscanner The scanner object. +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. */ void ast_yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) { @@ -2563,12 +2613,11 @@ ast_yy_load_buffer_state(yyscanner ); } -/*! - * \brief Pushes the new state onto the stack. The new state becomes +/** Pushes the new state onto the stack. The new state becomes * the current state. This function will allocate the stack * if necessary. - * \param new_buffer The new state. - * \param yyscanner The scanner object. + * @param new_buffer The new state. + * @param yyscanner The scanner object. */ void ast_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) { @@ -2597,10 +2646,9 @@ yyg->yy_did_buffer_switch_on_eof = 1; } -/*! - * \brief Removes and deletes the top of the stack, if present. +/** Removes and deletes the top of the stack, if present. * The next element becomes the new top. - * \param yyscanner The scanner object. + * @param yyscanner The scanner object. */ void ast_yypop_buffer_state (yyscan_t yyscanner) { @@ -2662,13 +2710,11 @@ } } -/*! - * \brief Setup the input buffer state to scan directly from a user-specified character buffer. - * \param base the character buffer - * \param size the size in bytes of the character buffer - * \param yyscanner The scanner object. - * - * \return the newly allocated buffer state object. +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. */ YY_BUFFER_STATE ast_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) { @@ -2699,30 +2745,26 @@ return b; } -/*! - * \brief Setup the input buffer state to scan a string. The next call to ast_yylex() will +/** Setup the input buffer state to scan a string. The next call to ast_yylex() will * scan from a @e copy of @a str. - * \param str a NUL-terminated string to scan - * \param yyscanner The scanner object. - * - * \return the newly allocated buffer state object. - * \note If you want to scan bytes that may contain NULL values, then use + * @param str a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use * ast_yy_scan_bytes() instead. */ -YY_BUFFER_STATE ast_yy_scan_string (yyconst char * str , yyscan_t yyscanner) +YY_BUFFER_STATE ast_yy_scan_string (yyconst char * yy_str , yyscan_t yyscanner) { - return ast_yy_scan_bytes(str,strlen(str) ,yyscanner); + return ast_yy_scan_bytes(yy_str,strlen(yy_str) ,yyscanner); } -/*! - * \brief Setup the input buffer state to scan the given bytes. The next call to ast_yylex() will +/** Setup the input buffer state to scan the given bytes. The next call to ast_yylex() will * scan from a @e copy of @a bytes. - * \param bytes the byte buffer to scan - * \param len the number of bytes in the buffer pointed to by @a bytes. - * \param yyscanner The scanner object. - * - * \return the newly allocated buffer state object. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. */ YY_BUFFER_STATE ast_yy_scan_bytes (yyconst char * bytes, int len , yyscan_t yyscanner) { @@ -2783,9 +2825,8 @@ /* Accessor methods (get/set functions) to struct members. */ -/*! - * \brief Get the user-defined data for this scanner. - * \param yyscanner The scanner object. +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. */ YY_EXTRA_TYPE ast_yyget_extra (yyscan_t yyscanner) { @@ -2793,9 +2834,8 @@ return yyextra; } -/*! - * \brief Get the current line number. - * \param yyscanner The scanner object. +/** Get the current line number. + * @param yyscanner The scanner object. */ int ast_yyget_lineno (yyscan_t yyscanner) { @@ -2807,9 +2847,8 @@ return yylineno; } -/*! - * \brief Get the current column number. - * \param yyscanner The scanner object. +/** Get the current column number. + * @param yyscanner The scanner object. */ int ast_yyget_column (yyscan_t yyscanner) { @@ -2821,9 +2860,8 @@ return yycolumn; } -/*! - * \brief Get the input stream. - * \param yyscanner The scanner object. +/** Get the input stream. + * @param yyscanner The scanner object. */ FILE *ast_yyget_in (yyscan_t yyscanner) { @@ -2831,9 +2869,8 @@ return yyin; } -/*! - * \brief Get the output stream. - * \param yyscanner The scanner object. +/** Get the output stream. + * @param yyscanner The scanner object. */ FILE *ast_yyget_out (yyscan_t yyscanner) { @@ -2841,9 +2878,8 @@ return yyout; } -/*! - * \brief Get the length of the current token. - * \param yyscanner The scanner object. +/** Get the length of the current token. + * @param yyscanner The scanner object. */ int ast_yyget_leng (yyscan_t yyscanner) { @@ -2851,9 +2887,8 @@ return yyleng; } -/*! - * \brief Get the current token. - * \param yyscanner The scanner object. +/** Get the current token. + * @param yyscanner The scanner object. */ char *ast_yyget_text (yyscan_t yyscanner) @@ -2862,10 +2897,9 @@ return yytext; } -/*! - * \brief Set the user-defined data. This data is never touched by the scanner. - * \param user_defined The data to be associated with this scanner. - * \param yyscanner The scanner object. +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. */ void ast_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) { @@ -2873,10 +2907,9 @@ yyextra = user_defined ; } -/*! - * \brief Set the current line number. - * \param line_number - * \param yyscanner The scanner object. +/** Set the current line number. + * @param line_number + * @param yyscanner The scanner object. */ void ast_yyset_lineno (int line_number , yyscan_t yyscanner) { @@ -2889,10 +2922,9 @@ yylineno = line_number; } -/*! - * \brief Set the current column. - * \param column_no - * \param yyscanner The scanner object. +/** Set the current column. + * @param line_number + * @param yyscanner The scanner object. */ void ast_yyset_column (int column_no , yyscan_t yyscanner) { @@ -2905,12 +2937,11 @@ yycolumn = column_no; } -/*! - * \brief Set the input stream. This does not discard the current +/** Set the input stream. This does not discard the current * input buffer. - * \param in_str A readable stream. - * \param yyscanner The scanner object. - * \see ast_yy_switch_to_buffer + * @param in_str A readable stream. + * @param yyscanner The scanner object. + * @see ast_yy_switch_to_buffer */ void ast_yyset_in (FILE * in_str , yyscan_t yyscanner) { @@ -2995,8 +3026,7 @@ /* User-visible API */ -/*! - * \brief ast_yylex_init is special because it creates the scanner itself, so it is +/* ast_yylex_init is special because it creates the scanner itself, so it is * the ONLY reentrant function that doesn't take the scanner as the last argument. * That's why we explicitly handle the declaration, instead of using our macros. */ @@ -3021,7 +3051,7 @@ return yy_init_globals ( *ptr_yy_globals ); } -/*! \brief ast_yylex_destroy is for both reentrant and non-reentrant scanners. */ +/* ast_yylex_destroy is for both reentrant and non-reentrant scanners. */ int ast_yylex_destroy (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; @@ -3108,7 +3138,7 @@ #undef YY_DECL_IS_OURS #undef YY_DECL #endif -#line 205 "ast_expr2.fl" +#line 222 "ast_expr2.fl" @@ -3143,10 +3173,10 @@ return_value = 1; } } else { - if (io.val->type == AST_EXPR_integer) { + if (io.val->type == AST_EXPR_number) { int res_length; - res_length = snprintf(buf, length, "%ld", (long int) io.val->u.i); + res_length = snprintf(buf, length, FP___PRINTF, io.val->u.i); return_value = (res_length <= length) ? res_length : length; } else { #if defined(STANDALONE) || defined(LOW_MEMORY) || defined(STANDALONE_AEL) Index: main/ast_expr2.fl =================================================================== --- main/ast_expr2.fl (revision 72704) +++ main/ast_expr2.fl (working copy) @@ -24,12 +24,29 @@ #include "asterisk.h" +#include +#include + #ifndef STANDALONE ASTERISK_FILE_VERSION(__FILE__, "$Revision$") +#else +#ifndef __USE_ISOC99 +#define __USE_ISOC99 1 #endif +#endif -#include -#include +#ifdef __USE_ISOC99 +#define FP___PRINTF "%.16Lg" +#define FP___FMOD fmodl +#define FP___STRTOD strtold +#define FP___TYPE long double +#else +#define FP___PRINTF "%.8g" +#define FP___FMOD fmod +#define FP___STRTOD strtod +#define FP___TYPE double +#endif + #include #include #include @@ -48,14 +65,14 @@ #include "asterisk/strings.h" enum valtype { - AST_EXPR_integer, AST_EXPR_numeric_string, AST_EXPR_string + AST_EXPR_number, AST_EXPR_numeric_string, AST_EXPR_string } ; struct val { enum valtype type; union { char *s; - quad_t i; + FP___TYPE i; /* long double or just double if it's a bad day */ } u; } ; @@ -140,7 +157,7 @@ \"[^"]*\" {SET_COLUMNS; SET_STRING; return TOKEN;} [\n] {/* what to do with eol */} -[0-9]+ { +[0-9]+(\.[0-9]+)? { SET_COLUMNS; /* the original behavior of the expression parser was * to bring in numbers as a numeric string @@ -235,10 +252,10 @@ return_value = 1; } } else { - if (io.val->type == AST_EXPR_integer) { + if (io.val->type == AST_EXPR_number) { int res_length; - res_length = snprintf(buf, length, "%ld", (long int) io.val->u.i); + res_length = snprintf(buf, length, FP___PRINTF, io.val->u.i); return_value = (res_length <= length) ? res_length : length; } else { #if defined(STANDALONE) || defined(LOW_MEMORY) || defined(STANDALONE_AEL) Index: main/Makefile =================================================================== --- main/Makefile (revision 72704) +++ main/Makefile (working copy) @@ -118,7 +118,7 @@ testexpr2: ast_expr2f.c ast_expr2.c ast_expr2.h $(CC) -g -c -Iinclude -DSTANDALONE ast_expr2f.c $(CC) -g -c -Iinclude -DSTANDALONE ast_expr2.c - $(CC) -g -o testexpr2 ast_expr2f.o ast_expr2.o + $(CC) -g -o testexpr2 ast_expr2f.o ast_expr2.o -lm rm ast_expr2.o ast_expr2f.o channel.o: ASTCFLAGS+=$(ZAPTEL_INCLUDE) Index: main/ast_expr2.c =================================================================== --- main/ast_expr2.c (revision 72704) +++ main/ast_expr2.c (working copy) @@ -1,10 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.3. */ +/* A Bison parser, made by GNU Bison 2.1a. */ -/* Skeleton implementation for Bison's Yacc-like parsers in C +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) @@ -20,19 +18,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ @@ -47,7 +37,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.3" +#define YYBISON_VERSION "2.1a" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -131,7 +121,7 @@ * * Largely rewritten by J.T. Conklin (jtc@wimsey.com) * - * And then overhauled twice by Steve Murphy (murf@e-tools.com) + * And then overhauled twice by Steve Murphy (murf@digium.com) * to add double-quoted strings, allow mult. spaces, improve * error messages, and then to fold in a flex scanner for the * yylex operation. @@ -139,16 +129,34 @@ * $FreeBSD: src/bin/expr/expr.y,v 1.16 2000/07/22 10:59:36 se Exp $ */ -#include "asterisk.h" -#ifndef STANDALONE -ASTERISK_FILE_VERSION(__FILE__, "$Revision$") +#include +#include + +#ifdef STANDALONE /* I guess somewhere, the feature is set in the asterisk includes */ +#ifndef __USE_ISOC99 +#define __USE_ISOC99 1 #endif +#endif -#include -#include +#ifdef __USE_ISOC99 +#define FP___PRINTF "%.16Lg" +#define FP___FMOD fmodl +#define FP___STRTOD strtold +#define FP___TYPE long double +#else +#define FP___PRINTF "%.8g" +#define FP___FMOD fmod +#define FP___STRTOD strtod +#define FP___TYPE double +#endif + #include +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif #include +#include #include #include #include @@ -161,6 +169,7 @@ #include #include +#include "asterisk.h" #include "asterisk/ast_expr.h" #include "asterisk/logger.h" @@ -177,7 +186,7 @@ # if ! defined(QUAD_MAX) # define QUAD_MAX (0x7fffffffffffffffLL) # endif - +#define YYENABLE_NLS 0 #define YYPARSE_PARAM parseio #define YYLEX_PARAM ((struct parse_io *)parseio)->scanner #define YYERROR_VERBOSE 1 @@ -185,7 +194,7 @@ extern int extra_error_message_supplied; enum valtype { - AST_EXPR_integer, AST_EXPR_numeric_string, AST_EXPR_string + AST_EXPR_number, AST_EXPR_numeric_string, AST_EXPR_string } ; #ifdef STANDALONE @@ -196,7 +205,7 @@ enum valtype type; union { char *s; - quad_t i; + FP___TYPE i; /* either long double, or just double, on a bad day */ } u; } ; @@ -209,14 +218,14 @@ yyscan_t scanner; }; -static int chk_div __P((quad_t, quad_t)); -static int chk_minus __P((quad_t, quad_t, quad_t)); -static int chk_plus __P((quad_t, quad_t, quad_t)); -static int chk_times __P((quad_t, quad_t, quad_t)); +static int chk_div __P((FP___TYPE, FP___TYPE)); +static int chk_minus __P((FP___TYPE, FP___TYPE, FP___TYPE)); +static int chk_plus __P((FP___TYPE, FP___TYPE, FP___TYPE)); +static int chk_times __P((FP___TYPE, FP___TYPE, FP___TYPE)); static void free_value __P((struct val *)); static int is_zero_or_null __P((struct val *)); static int isstring __P((struct val *)); -static struct val *make_integer __P((quad_t)); +static struct val *make_number __P((FP___TYPE)); static struct val *make_str __P((const char *)); static struct val *op_and __P((struct val *, struct val *)); static struct val *op_colon __P((struct val *, struct val *)); @@ -236,7 +245,7 @@ static struct val *op_plus __P((struct val *, struct val *)); static struct val *op_rem __P((struct val *, struct val *)); static struct val *op_times __P((struct val *, struct val *)); -static quad_t to_integer __P((struct val *)); +static int to_number __P((struct val *)); static void to_string __P((struct val *)); /* uh, if I want to predeclare yylex with a YYLTYPE, I have to predeclare the yyltype... sigh */ @@ -284,12 +293,12 @@ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 147 "ast_expr2.y" +#line 166 "ast_expr2.y" { struct val *val; } -/* Line 193 of yacc.c. */ -#line 293 "ast_expr2.c" +/* Line 198 of yacc.c. */ +#line 302 "ast_expr2.c" YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 @@ -311,13 +320,13 @@ /* Copy the second part of user declarations. */ -#line 151 "ast_expr2.y" +#line 170 "ast_expr2.y" extern int ast_yylex __P((YYSTYPE *, YYLTYPE *, yyscan_t)); -/* Line 216 of yacc.c. */ -#line 321 "ast_expr2.c" +/* Line 221 of yacc.c. */ +#line 330 "ast_expr2.c" #ifdef short # undef short @@ -367,7 +376,7 @@ #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# ifdef YYENABLE_NLS +# if YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) @@ -447,13 +456,8 @@ # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif -# if (defined __cplusplus && ! defined _STDLIB_H \ - && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) -# include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 -# endif +# ifdef __cplusplus +extern "C" { # endif # ifndef YYMALLOC # define YYMALLOC malloc @@ -469,6 +473,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif +# ifdef __cplusplus +} +# endif # endif #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ @@ -612,9 +619,9 @@ /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 175, 175, 183, 190, 191, 195, 199, 203, 207, - 211, 215, 219, 223, 227, 231, 235, 239, 243, 247, - 251, 255, 259, 263 + 0, 194, 194, 202, 209, 210, 214, 218, 222, 226, + 230, 234, 238, 242, 246, 250, 254, 258, 262, 266, + 270, 274, 278, 282 }; #endif @@ -872,14 +879,14 @@ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp) +yy_symbol_value_print (FILE *yyoutput, int yytype, const YYSTYPE * const yyvaluep, const YYLTYPE * const yylocationp) #else static void yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) FILE *yyoutput; int yytype; - YYSTYPE const * const yyvaluep; - YYLTYPE const * const yylocationp; + const YYSTYPE * const yyvaluep; + const YYLTYPE * const yylocationp; #endif { if (!yyvaluep) @@ -906,14 +913,14 @@ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp) +yy_symbol_print (FILE *yyoutput, int yytype, const YYSTYPE * const yyvaluep, const YYLTYPE * const yylocationp) #else static void yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp) FILE *yyoutput; int yytype; - YYSTYPE const * const yyvaluep; - YYLTYPE const * const yylocationp; + const YYSTYPE * const yyvaluep; + const YYLTYPE * const yylocationp; #endif { if (yytype < YYNTOKENS) @@ -966,7 +973,8 @@ yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule) #else static void -yy_reduce_print (yyvsp, yylsp, yyrule) +yy_reduce_print (yyvsp, yylsp, yyrule + ) YYSTYPE *yyvsp; YYLTYPE *yylsp; int yyrule; @@ -1089,7 +1097,7 @@ { if (*yystr == '"') { - YYSIZE_T yyn = 0; + size_t yyn = 0; char const *yyp = yystr; for (;;) @@ -1136,7 +1144,7 @@ { int yyn = yypact[yystate]; - if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + if (! (YYPACT_NINF < yyn && yyn < YYLAST)) return 0; else { @@ -1174,7 +1182,7 @@ int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; + int yychecklim = YYLAST - yyn; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yycount = 1; @@ -1262,114 +1270,114 @@ switch (yytype) { case 3: /* "TOK_COLONCOLON" */ -#line 169 "ast_expr2.y" +#line 188 "ast_expr2.y" { free_value((yyvaluep->val)); }; -#line 1268 "ast_expr2.c" +#line 1276 "ast_expr2.c" break; case 4: /* "TOK_COND" */ -#line 169 "ast_expr2.y" +#line 188 "ast_expr2.y" { free_value((yyvaluep->val)); }; -#line 1273 "ast_expr2.c" +#line 1281 "ast_expr2.c" break; case 5: /* "TOK_OR" */ -#line 169 "ast_expr2.y" +#line 188 "ast_expr2.y" { free_value((yyvaluep->val)); }; -#line 1278 "ast_expr2.c" +#line 1286 "ast_expr2.c" break; case 6: /* "TOK_AND" */ -#line 169 "ast_expr2.y" +#line 188 "ast_expr2.y" { free_value((yyvaluep->val)); }; -#line 1283 "ast_expr2.c" +#line 1291 "ast_expr2.c" break; case 7: /* "TOK_NE" */ -#line 169 "ast_expr2.y" +#line 188 "ast_expr2.y" { free_value((yyvaluep->val)); }; -#line 1288 "ast_expr2.c" +#line 1296 "ast_expr2.c" break; case 8: /* "TOK_LE" */ -#line 169 "ast_expr2.y" +#line 188 "ast_expr2.y" { free_value((yyvaluep->val)); }; -#line 1293 "ast_expr2.c" +#line 1301 "ast_expr2.c" break; case 9: /* "TOK_GE" */ -#line 169 "ast_expr2.y" +#line 188 "ast_expr2.y" { free_value((yyvaluep->val)); }; -#line 1298 "ast_expr2.c" +#line 1306 "ast_expr2.c" break; case 10: /* "TOK_LT" */ -#line 169 "ast_expr2.y" +#line 188 "ast_expr2.y" { free_value((yyvaluep->val)); }; -#line 1303 "ast_expr2.c" +#line 1311 "ast_expr2.c" break; case 11: /* "TOK_GT" */ -#line 169 "ast_expr2.y" +#line 188 "ast_expr2.y" { free_value((yyvaluep->val)); }; -#line 1308 "ast_expr2.c" +#line 1316 "ast_expr2.c" break; case 12: /* "TOK_EQ" */ -#line 169 "ast_expr2.y" +#line 188 "ast_expr2.y" { free_value((yyvaluep->val)); }; -#line 1313 "ast_expr2.c" +#line 1321 "ast_expr2.c" break; case 13: /* "TOK_MINUS" */ -#line 169 "ast_expr2.y" +#line 188 "ast_expr2.y" { free_value((yyvaluep->val)); }; -#line 1318 "ast_expr2.c" +#line 1326 "ast_expr2.c" break; case 14: /* "TOK_PLUS" */ -#line 169 "ast_expr2.y" +#line 188 "ast_expr2.y" { free_value((yyvaluep->val)); }; -#line 1323 "ast_expr2.c" +#line 1331 "ast_expr2.c" break; case 15: /* "TOK_MOD" */ -#line 169 "ast_expr2.y" +#line 188 "ast_expr2.y" { free_value((yyvaluep->val)); }; -#line 1328 "ast_expr2.c" +#line 1336 "ast_expr2.c" break; case 16: /* "TOK_DIV" */ -#line 169 "ast_expr2.y" +#line 188 "ast_expr2.y" { free_value((yyvaluep->val)); }; -#line 1333 "ast_expr2.c" +#line 1341 "ast_expr2.c" break; case 17: /* "TOK_MULT" */ -#line 169 "ast_expr2.y" +#line 188 "ast_expr2.y" { free_value((yyvaluep->val)); }; -#line 1338 "ast_expr2.c" +#line 1346 "ast_expr2.c" break; case 18: /* "TOK_COMPL" */ -#line 169 "ast_expr2.y" +#line 188 "ast_expr2.y" { free_value((yyvaluep->val)); }; -#line 1343 "ast_expr2.c" +#line 1351 "ast_expr2.c" break; case 19: /* "TOK_EQTILDE" */ -#line 169 "ast_expr2.y" +#line 188 "ast_expr2.y" { free_value((yyvaluep->val)); }; -#line 1348 "ast_expr2.c" +#line 1356 "ast_expr2.c" break; case 20: /* "TOK_COLON" */ -#line 169 "ast_expr2.y" +#line 188 "ast_expr2.y" { free_value((yyvaluep->val)); }; -#line 1353 "ast_expr2.c" +#line 1361 "ast_expr2.c" break; case 21: /* "TOK_LP" */ -#line 169 "ast_expr2.y" +#line 188 "ast_expr2.y" { free_value((yyvaluep->val)); }; -#line 1358 "ast_expr2.c" +#line 1366 "ast_expr2.c" break; case 22: /* "TOK_RP" */ -#line 169 "ast_expr2.y" +#line 188 "ast_expr2.y" { free_value((yyvaluep->val)); }; -#line 1363 "ast_expr2.c" +#line 1371 "ast_expr2.c" break; case 23: /* "TOKEN" */ -#line 169 "ast_expr2.y" +#line 188 "ast_expr2.y" { free_value((yyvaluep->val)); }; -#line 1368 "ast_expr2.c" +#line 1376 "ast_expr2.c" break; case 26: /* "expr" */ -#line 169 "ast_expr2.y" +#line 188 "ast_expr2.y" { free_value((yyvaluep->val)); }; -#line 1373 "ast_expr2.c" +#line 1381 "ast_expr2.c" break; default: @@ -1692,10 +1700,10 @@ switch (yyn) { case 2: -#line 175 "ast_expr2.y" +#line 194 "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_integer ) + if( (yyvsp[(1) - (1)].val)->type == AST_EXPR_number ) ((struct parse_io *)parseio)->val->u.i = (yyvsp[(1) - (1)].val)->u.i; else ((struct parse_io *)parseio)->val->u.s = (yyvsp[(1) - (1)].val)->u.s; @@ -1704,7 +1712,7 @@ break; case 3: -#line 183 "ast_expr2.y" +#line 202 "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(""); @@ -1712,12 +1720,12 @@ break; case 4: -#line 190 "ast_expr2.y" +#line 209 "ast_expr2.y" { (yyval.val)= (yyvsp[(1) - (1)].val);;} break; case 5: -#line 191 "ast_expr2.y" +#line 210 "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; @@ -1725,7 +1733,7 @@ break; case 6: -#line 195 "ast_expr2.y" +#line 214 "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; @@ -1733,7 +1741,7 @@ break; case 7: -#line 199 "ast_expr2.y" +#line 218 "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; @@ -1741,7 +1749,7 @@ break; case 8: -#line 203 "ast_expr2.y" +#line 222 "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; @@ -1749,7 +1757,7 @@ break; case 9: -#line 207 "ast_expr2.y" +#line 226 "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; @@ -1757,7 +1765,7 @@ break; case 10: -#line 211 "ast_expr2.y" +#line 230 "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; @@ -1765,7 +1773,7 @@ break; case 11: -#line 215 "ast_expr2.y" +#line 234 "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; @@ -1773,7 +1781,7 @@ break; case 12: -#line 219 "ast_expr2.y" +#line 238 "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; @@ -1781,7 +1789,7 @@ break; case 13: -#line 223 "ast_expr2.y" +#line 242 "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; @@ -1789,7 +1797,7 @@ break; case 14: -#line 227 "ast_expr2.y" +#line 246 "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; @@ -1797,7 +1805,7 @@ break; case 15: -#line 231 "ast_expr2.y" +#line 250 "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; @@ -1805,7 +1813,7 @@ break; case 16: -#line 235 "ast_expr2.y" +#line 254 "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; @@ -1813,7 +1821,7 @@ break; case 17: -#line 239 "ast_expr2.y" +#line 258 "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; @@ -1821,7 +1829,7 @@ break; case 18: -#line 243 "ast_expr2.y" +#line 262 "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; @@ -1829,7 +1837,7 @@ break; case 19: -#line 247 "ast_expr2.y" +#line 266 "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; @@ -1837,7 +1845,7 @@ break; case 20: -#line 251 "ast_expr2.y" +#line 270 "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; @@ -1845,7 +1853,7 @@ break; case 21: -#line 255 "ast_expr2.y" +#line 274 "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; @@ -1853,7 +1861,7 @@ break; case 22: -#line 259 "ast_expr2.y" +#line 278 "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; @@ -1861,7 +1869,7 @@ break; case 23: -#line 263 "ast_expr2.y" +#line 282 "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)); @@ -1870,8 +1878,8 @@ break; -/* Line 1267 of yacc.c. */ -#line 1875 "ast_expr2.c" +/* Line 1270 of yacc.c. */ +#line 1883 "ast_expr2.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -2086,16 +2094,15 @@ if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif - /* Make sure YYID is used. */ - return YYID (yyresult); + return yyresult; } -#line 270 "ast_expr2.y" +#line 289 "ast_expr2.y" static struct val * -make_integer (quad_t i) +make_number (FP___TYPE i) { struct val *vp; @@ -2105,7 +2112,7 @@ return(NULL); } - vp->type = AST_EXPR_integer; + vp->type = AST_EXPR_number; vp->u.i = i; return vp; } @@ -2115,7 +2122,7 @@ { struct val *vp; size_t i; - int isint; + int isint; /* this started out being a test for an integer, but then ended up being a test for a float */ vp = (struct val *) malloc (sizeof (*vp)); if (vp == NULL || ((vp->u.s = strdup (s)) == NULL)) { @@ -2123,14 +2130,13 @@ return(NULL); } - for(i = 1, isint = isdigit(s[0]) || s[0] == '-'; - isint && i < strlen(s); - i++) + for (i = 0, isint = (isdigit(s[0]) || s[0] == '-' || s[0]=='.'); isint && i < strlen(s); i++) { - if(!isdigit(s[i])) - isint = 0; + if (!isdigit(s[i]) && s[i] != '.') { + isint = 0; + break; + } } - if (isint) vp->type = AST_EXPR_numeric_string; else @@ -2152,17 +2158,17 @@ } -static quad_t -to_integer (struct val *vp) +static int +to_number (struct val *vp) { - quad_t i; + FP___TYPE i; if (vp == NULL) { - ast_log(LOG_WARNING,"vp==NULL in to_integer()\n"); + ast_log(LOG_WARNING,"vp==NULL in to_number()\n"); return(0); } - if (vp->type == AST_EXPR_integer) + if (vp->type == AST_EXPR_number) return 1; if (vp->type == AST_EXPR_string) @@ -2170,16 +2176,16 @@ /* vp->type == AST_EXPR_numeric_string, make it numeric */ errno = 0; - i = strtoll(vp->u.s, (char**)NULL, 10); + i = FP___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 integer under/overflowed!\n", vp->u.s); + ast_log(LOG_WARNING,"Conversion of %s to number under/overflowed!\n", vp->u.s); free(vp->u.s); vp->u.s = 0; return(0); } free (vp->u.s); vp->u.i = i; - vp->type = AST_EXPR_integer; + vp->type = AST_EXPR_number; return 1; } @@ -2220,7 +2226,7 @@ return; } - sprintf(tmp, "%ld", (long int) vp->u.i); + sprintf(tmp, FP___PRINTF, vp->u.i); vp->type = AST_EXPR_string; vp->u.s = tmp; } @@ -2229,7 +2235,7 @@ static int isstring (struct val *vp) { - /* only TRUE if this string is not a valid integer */ + /* only TRUE if this string is not a valid number */ return (vp->type == AST_EXPR_string); } @@ -2237,10 +2243,10 @@ static int is_zero_or_null (struct val *vp) { - if (vp->type == AST_EXPR_integer) { + if (vp->type == AST_EXPR_number) { return (vp->u.i == 0); } else { - return (*vp->u.s == 0 || (to_integer (vp) && vp->u.i == 0)); + return (*vp->u.s == 0 || (to_number(vp) && vp->u.i == 0)); } /* NOTREACHED */ } @@ -2327,7 +2333,7 @@ if (is_zero_or_null (a) || is_zero_or_null (b)) { free_value (a); free_value (b); - return (make_integer ((quad_t)0)); + return (make_number ((double)0.0)); } else { free_value (b); return (a); @@ -2342,18 +2348,18 @@ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); - r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) == 0)); + r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) == 0)); } else { #ifdef DEBUG_FOR_CONVERSIONS char buffer[2000]; sprintf(buffer,"Converting '%s' and '%s' ", a->u.s, b->u.s); #endif - (void)to_integer(a); - (void)to_integer(b); + (void)to_number(a); + (void)to_number(b); #ifdef DEBUG_FOR_CONVERSIONS ast_log(LOG_WARNING,"%s to '%lld' and '%lld'\n", buffer, a->u.i, b->u.i); #endif - r = make_integer ((quad_t)(a->u.i == b->u.i)); + r = make_number ((FP___TYPE)(a->u.i == b->u.i)); } free_value (a); @@ -2369,11 +2375,11 @@ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); - r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) > 0)); + r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) > 0)); } else { - (void)to_integer(a); - (void)to_integer(b); - r = make_integer ((quad_t)(a->u.i > b->u.i)); + (void)to_number(a); + (void)to_number(b); + r = make_number ((FP___TYPE)(a->u.i > b->u.i)); } free_value (a); @@ -2389,11 +2395,11 @@ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); - r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) < 0)); + r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) < 0)); } else { - (void)to_integer(a); - (void)to_integer(b); - r = make_integer ((quad_t)(a->u.i < b->u.i)); + (void)to_number(a); + (void)to_number(b); + r = make_number ((FP___TYPE)(a->u.i < b->u.i)); } free_value (a); @@ -2409,11 +2415,11 @@ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); - r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) >= 0)); + r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) >= 0)); } else { - (void)to_integer(a); - (void)to_integer(b); - r = make_integer ((quad_t)(a->u.i >= b->u.i)); + (void)to_number(a); + (void)to_number(b); + r = make_number ((FP___TYPE)(a->u.i >= b->u.i)); } free_value (a); @@ -2429,11 +2435,11 @@ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); - r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) <= 0)); + r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) <= 0)); } else { - (void)to_integer(a); - (void)to_integer(b); - r = make_integer ((quad_t)(a->u.i <= b->u.i)); + (void)to_number(a); + (void)to_number(b); + r = make_number ((FP___TYPE)(a->u.i <= b->u.i)); } free_value (a); @@ -2463,7 +2469,7 @@ } else { - (void)to_integer(a); + (void)to_number(a); if( a->u.i ) { free_value(a); @@ -2488,11 +2494,11 @@ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); - r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) != 0)); + r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) != 0)); } else { - (void)to_integer(a); - (void)to_integer(b); - r = make_integer ((quad_t)(a->u.i != b->u.i)); + (void)to_number(a); + (void)to_number(b); + r = make_number ((FP___TYPE)(a->u.i != b->u.i)); } free_value (a); @@ -2501,7 +2507,7 @@ } static int -chk_plus (quad_t a, quad_t b, quad_t r) +chk_plus (FP___TYPE a, FP___TYPE b, FP___TYPE r) { /* sum of two positive numbers must be positive */ if (a > 0 && b > 0 && r <= 0) @@ -2518,23 +2524,23 @@ { struct val *r; - if (!to_integer (a)) { + if (!to_number (a)) { if( !extra_error_message_supplied ) ast_log(LOG_WARNING,"non-numeric argument\n"); - if (!to_integer (b)) { + if (!to_number (b)) { free_value(a); free_value(b); - return make_integer(0); + return make_number(0); } else { free_value(a); return (b); } - } else if (!to_integer(b)) { + } else if (!to_number(b)) { free_value(b); return (a); } - r = make_integer (/*(quad_t)*/(a->u.i + b->u.i)); + r = make_number (a->u.i + b->u.i); if (chk_plus (a->u.i, b->u.i, r->u.i)) { ast_log(LOG_WARNING,"overflow\n"); } @@ -2544,7 +2550,7 @@ } static int -chk_minus (quad_t a, quad_t b, quad_t r) +chk_minus (FP___TYPE a, FP___TYPE b, FP___TYPE r) { /* special case subtraction of QUAD_MIN */ if (b == QUAD_MIN) { @@ -2562,27 +2568,27 @@ { struct val *r; - if (!to_integer (a)) { + if (!to_number (a)) { if( !extra_error_message_supplied ) ast_log(LOG_WARNING, "non-numeric argument\n"); - if (!to_integer (b)) { + if (!to_number (b)) { free_value(a); free_value(b); - return make_integer(0); + return make_number(0); } else { - r = make_integer(0 - b->u.i); + r = make_number(0 - b->u.i); free_value(a); free_value(b); return (r); } - } else if (!to_integer(b)) { + } else if (!to_number(b)) { if( !extra_error_message_supplied ) ast_log(LOG_WARNING, "non-numeric argument\n"); free_value(b); return (a); } - r = make_integer (/*(quad_t)*/(a->u.i - b->u.i)); + r = make_number (a->u.i - b->u.i); if (chk_minus (a->u.i, b->u.i, r->u.i)) { ast_log(LOG_WARNING, "overflow\n"); } @@ -2596,14 +2602,14 @@ { struct val *r; - if (!to_integer (a) ) { + if (!to_number (a) ) { free_value(a); if( !extra_error_message_supplied ) ast_log(LOG_WARNING, "non-numeric argument\n"); - return make_integer(0); + return make_number(0); } - r = make_integer (/*(quad_t)*/(- a->u.i)); + r = make_number (- a->u.i); if (chk_minus (0, a->u.i, r->u.i)) { ast_log(LOG_WARNING, "overflow\n"); } @@ -2625,7 +2631,7 @@ { switch( a->type ) { - case AST_EXPR_integer: + case AST_EXPR_number: if( a->u.i == 0 ) v1 = 0; break; @@ -2656,13 +2662,13 @@ } } - r = make_integer (!v1); + r = make_number (!v1); free_value (a); return r; } static int -chk_times (quad_t a, quad_t b, quad_t r) +chk_times (FP___TYPE a, FP___TYPE b, FP___TYPE r) { /* special case: first operand is 0, no overflow possible */ if (a == 0) @@ -2678,15 +2684,15 @@ { struct val *r; - if (!to_integer (a) || !to_integer (b)) { + if (!to_number (a) || !to_number (b)) { free_value(a); free_value(b); if( !extra_error_message_supplied ) ast_log(LOG_WARNING, "non-numeric argument\n"); - return(make_integer(0)); + return(make_number(0)); } - r = make_integer (/*(quad_t)*/(a->u.i * b->u.i)); + r = make_number (a->u.i * b->u.i); if (chk_times (a->u.i, b->u.i, r->u.i)) { ast_log(LOG_WARNING, "overflow\n"); } @@ -2696,7 +2702,7 @@ } static int -chk_div (quad_t a, quad_t b) +chk_div (FP___TYPE a, FP___TYPE b) { /* div by zero has been taken care of before */ /* only QUAD_MIN / -1 causes overflow */ @@ -2711,28 +2717,28 @@ { struct val *r; - if (!to_integer (a)) { + if (!to_number (a)) { free_value(a); free_value(b); if( !extra_error_message_supplied ) ast_log(LOG_WARNING, "non-numeric argument\n"); - return make_integer(0); - } else if (!to_integer (b)) { + return make_number(0); + } else if (!to_number (b)) { free_value(a); free_value(b); if( !extra_error_message_supplied ) ast_log(LOG_WARNING, "non-numeric argument\n"); - return make_integer(INT_MAX); + return make_number(INT_MAX); } if (b->u.i == 0) { ast_log(LOG_WARNING, "division by zero\n"); free_value(a); free_value(b); - return make_integer(INT_MAX); + return make_number(INT_MAX); } - r = make_integer (/*(quad_t)*/(a->u.i / b->u.i)); + r = make_number (a->u.i / b->u.i); if (chk_div (a->u.i, b->u.i)) { ast_log(LOG_WARNING, "overflow\n"); } @@ -2746,12 +2752,12 @@ { struct val *r; - if (!to_integer (a) || !to_integer (b)) { + if (!to_number (a) || !to_number (b)) { if( !extra_error_message_supplied ) ast_log(LOG_WARNING, "non-numeric argument\n"); free_value(a); free_value(b); - return make_integer(0); + return make_number(0); } if (b->u.i == 0) { @@ -2760,7 +2766,7 @@ return(b); } - r = make_integer (/*(quad_t)*/(a->u.i % b->u.i)); + r = make_number (FP___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); @@ -2800,11 +2806,11 @@ v = make_str (a->u.s + rm[1].rm_so); } else { - v = make_integer ((quad_t)(rm[0].rm_eo - rm[0].rm_so)); + v = make_number ((FP___TYPE)(rm[0].rm_eo - rm[0].rm_so)); } } else { if (rp.re_nsub == 0) { - v = make_integer ((quad_t)0); + v = make_number ((FP___TYPE)0); } else { v = make_str (""); } @@ -2851,11 +2857,11 @@ v = make_str (a->u.s + rm[1].rm_so); } else { - v = make_integer ((quad_t)(rm[0].rm_eo - rm[0].rm_so)); + v = make_number ((FP___TYPE)(rm[0].rm_eo - rm[0].rm_so)); } } else { if (rp.re_nsub == 0) { - v = make_integer ((quad_t)0); + v = make_number ((FP___TYPE)0.0); } else { v = make_str (""); } Index: main/ast_expr2.h =================================================================== --- main/ast_expr2.h (revision 72704) +++ main/ast_expr2.h (working copy) @@ -1,10 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.3. */ +/* A Bison parser, made by GNU Bison 2.1a. */ -/* Skeleton interface for Bison's Yacc-like parsers in C +/* Skeleton parser for Yacc-like parsing with Bison, + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) @@ -20,19 +18,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* As a special exception, you may create a larger work that contains - part or all of the Bison parser skeleton and distribute that work - under terms of your choice, so long as that work isn't itself a - parser generator using the skeleton or a modified version thereof - as a parser skeleton. Alternatively, if you modify or redistribute - the parser skeleton itself, you may (at your option) remove this - special exception, which will cause the skeleton and the resulting - Bison output files to be licensed under the GNU General Public - License without this special exception. +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ - This special exception was added by the Free Software Foundation in - version 2.2 of Bison. */ - /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE @@ -90,12 +80,12 @@ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -#line 147 "ast_expr2.y" +#line 166 "ast_expr2.y" { struct val *val; } -/* Line 1529 of yacc.c. */ -#line 99 "ast_expr2.h" +/* Line 1536 of yacc.c. */ +#line 89 "ast_expr2.h" YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 @@ -118,3 +108,5 @@ #endif + + Index: main/ast_expr2.y =================================================================== --- main/ast_expr2.y (revision 72704) +++ main/ast_expr2.y (working copy) @@ -4,7 +4,7 @@ * * Largely rewritten by J.T. Conklin (jtc@wimsey.com) * - * And then overhauled twice by Steve Murphy (murf@e-tools.com) + * And then overhauled twice by Steve Murphy (murf@digium.com) * to add double-quoted strings, allow mult. spaces, improve * error messages, and then to fold in a flex scanner for the * yylex operation. @@ -12,16 +12,34 @@ * $FreeBSD: src/bin/expr/expr.y,v 1.16 2000/07/22 10:59:36 se Exp $ */ -#include "asterisk.h" -#ifndef STANDALONE -ASTERISK_FILE_VERSION(__FILE__, "$Revision$") +#include +#include + +#ifdef STANDALONE /* I guess somewhere, the feature is set in the asterisk includes */ +#ifndef __USE_ISOC99 +#define __USE_ISOC99 1 #endif +#endif -#include -#include +#ifdef __USE_ISOC99 +#define FP___PRINTF "%.16Lg" +#define FP___FMOD fmodl +#define FP___STRTOD strtold +#define FP___TYPE long double +#else +#define FP___PRINTF "%.8g" +#define FP___FMOD fmod +#define FP___STRTOD strtod +#define FP___TYPE double +#endif + #include +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#endif #include +#include #include #include #include @@ -34,6 +52,7 @@ #include #include +#include "asterisk.h" #include "asterisk/ast_expr.h" #include "asterisk/logger.h" @@ -50,7 +69,7 @@ # if ! defined(QUAD_MAX) # define QUAD_MAX (0x7fffffffffffffffLL) # endif - +#define YYENABLE_NLS 0 #define YYPARSE_PARAM parseio #define YYLEX_PARAM ((struct parse_io *)parseio)->scanner #define YYERROR_VERBOSE 1 @@ -58,7 +77,7 @@ extern int extra_error_message_supplied; enum valtype { - AST_EXPR_integer, AST_EXPR_numeric_string, AST_EXPR_string + AST_EXPR_number, AST_EXPR_numeric_string, AST_EXPR_string } ; #ifdef STANDALONE @@ -69,7 +88,7 @@ enum valtype type; union { char *s; - quad_t i; + FP___TYPE i; /* either long double, or just double, on a bad day */ } u; } ; @@ -82,14 +101,14 @@ yyscan_t scanner; }; -static int chk_div __P((quad_t, quad_t)); -static int chk_minus __P((quad_t, quad_t, quad_t)); -static int chk_plus __P((quad_t, quad_t, quad_t)); -static int chk_times __P((quad_t, quad_t, quad_t)); +static int chk_div __P((FP___TYPE, FP___TYPE)); +static int chk_minus __P((FP___TYPE, FP___TYPE, FP___TYPE)); +static int chk_plus __P((FP___TYPE, FP___TYPE, FP___TYPE)); +static int chk_times __P((FP___TYPE, FP___TYPE, FP___TYPE)); static void free_value __P((struct val *)); static int is_zero_or_null __P((struct val *)); static int isstring __P((struct val *)); -static struct val *make_integer __P((quad_t)); +static struct val *make_number __P((FP___TYPE)); static struct val *make_str __P((const char *)); static struct val *op_and __P((struct val *, struct val *)); static struct val *op_colon __P((struct val *, struct val *)); @@ -109,7 +128,7 @@ static struct val *op_plus __P((struct val *, struct val *)); static struct val *op_rem __P((struct val *, struct val *)); static struct val *op_times __P((struct val *, struct val *)); -static quad_t to_integer __P((struct val *)); +static int to_number __P((struct val *)); static void to_string __P((struct val *)); /* uh, if I want to predeclare yylex with a YYLTYPE, I have to predeclare the yyltype... sigh */ @@ -174,7 +193,7 @@ start: expr { ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1); ((struct parse_io *)parseio)->val->type = $1->type; - if( $1->type == AST_EXPR_integer ) + if( $1->type == AST_EXPR_number ) ((struct parse_io *)parseio)->val->u.i = $1->u.i; else ((struct parse_io *)parseio)->val->u.s = $1->u.s; @@ -270,7 +289,7 @@ %% static struct val * -make_integer (quad_t i) +make_number (FP___TYPE i) { struct val *vp; @@ -280,7 +299,7 @@ return(NULL); } - vp->type = AST_EXPR_integer; + vp->type = AST_EXPR_number; vp->u.i = i; return vp; } @@ -290,7 +309,7 @@ { struct val *vp; size_t i; - int isint; + int isint; /* this started out being a test for an integer, but then ended up being a test for a float */ vp = (struct val *) malloc (sizeof (*vp)); if (vp == NULL || ((vp->u.s = strdup (s)) == NULL)) { @@ -298,14 +317,13 @@ return(NULL); } - for(i = 1, isint = isdigit(s[0]) || s[0] == '-'; - isint && i < strlen(s); - i++) + for (i = 0, isint = (isdigit(s[0]) || s[0] == '-' || s[0]=='.'); isint && i < strlen(s); i++) { - if(!isdigit(s[i])) - isint = 0; + if (!isdigit(s[i]) && s[i] != '.') { + isint = 0; + break; + } } - if (isint) vp->type = AST_EXPR_numeric_string; else @@ -327,17 +345,17 @@ } -static quad_t -to_integer (struct val *vp) +static int +to_number (struct val *vp) { - quad_t i; + FP___TYPE i; if (vp == NULL) { - ast_log(LOG_WARNING,"vp==NULL in to_integer()\n"); + ast_log(LOG_WARNING,"vp==NULL in to_number()\n"); return(0); } - if (vp->type == AST_EXPR_integer) + if (vp->type == AST_EXPR_number) return 1; if (vp->type == AST_EXPR_string) @@ -345,16 +363,16 @@ /* vp->type == AST_EXPR_numeric_string, make it numeric */ errno = 0; - i = strtoll(vp->u.s, (char**)NULL, 10); + i = FP___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 integer under/overflowed!\n", vp->u.s); + ast_log(LOG_WARNING,"Conversion of %s to number under/overflowed!\n", vp->u.s); free(vp->u.s); vp->u.s = 0; return(0); } free (vp->u.s); vp->u.i = i; - vp->type = AST_EXPR_integer; + vp->type = AST_EXPR_number; return 1; } @@ -395,7 +413,7 @@ return; } - sprintf(tmp, "%ld", (long int) vp->u.i); + sprintf(tmp, FP___PRINTF, vp->u.i); vp->type = AST_EXPR_string; vp->u.s = tmp; } @@ -404,7 +422,7 @@ static int isstring (struct val *vp) { - /* only TRUE if this string is not a valid integer */ + /* only TRUE if this string is not a valid number */ return (vp->type == AST_EXPR_string); } @@ -412,10 +430,10 @@ static int is_zero_or_null (struct val *vp) { - if (vp->type == AST_EXPR_integer) { + if (vp->type == AST_EXPR_number) { return (vp->u.i == 0); } else { - return (*vp->u.s == 0 || (to_integer (vp) && vp->u.i == 0)); + return (*vp->u.s == 0 || (to_number(vp) && vp->u.i == 0)); } /* NOTREACHED */ } @@ -502,7 +520,7 @@ if (is_zero_or_null (a) || is_zero_or_null (b)) { free_value (a); free_value (b); - return (make_integer ((quad_t)0)); + return (make_number ((double)0.0)); } else { free_value (b); return (a); @@ -517,18 +535,18 @@ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); - r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) == 0)); + r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) == 0)); } else { #ifdef DEBUG_FOR_CONVERSIONS char buffer[2000]; sprintf(buffer,"Converting '%s' and '%s' ", a->u.s, b->u.s); #endif - (void)to_integer(a); - (void)to_integer(b); + (void)to_number(a); + (void)to_number(b); #ifdef DEBUG_FOR_CONVERSIONS ast_log(LOG_WARNING,"%s to '%lld' and '%lld'\n", buffer, a->u.i, b->u.i); #endif - r = make_integer ((quad_t)(a->u.i == b->u.i)); + r = make_number ((FP___TYPE)(a->u.i == b->u.i)); } free_value (a); @@ -544,11 +562,11 @@ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); - r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) > 0)); + r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) > 0)); } else { - (void)to_integer(a); - (void)to_integer(b); - r = make_integer ((quad_t)(a->u.i > b->u.i)); + (void)to_number(a); + (void)to_number(b); + r = make_number ((FP___TYPE)(a->u.i > b->u.i)); } free_value (a); @@ -564,11 +582,11 @@ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); - r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) < 0)); + r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) < 0)); } else { - (void)to_integer(a); - (void)to_integer(b); - r = make_integer ((quad_t)(a->u.i < b->u.i)); + (void)to_number(a); + (void)to_number(b); + r = make_number ((FP___TYPE)(a->u.i < b->u.i)); } free_value (a); @@ -584,11 +602,11 @@ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); - r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) >= 0)); + r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) >= 0)); } else { - (void)to_integer(a); - (void)to_integer(b); - r = make_integer ((quad_t)(a->u.i >= b->u.i)); + (void)to_number(a); + (void)to_number(b); + r = make_number ((FP___TYPE)(a->u.i >= b->u.i)); } free_value (a); @@ -604,11 +622,11 @@ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); - r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) <= 0)); + r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) <= 0)); } else { - (void)to_integer(a); - (void)to_integer(b); - r = make_integer ((quad_t)(a->u.i <= b->u.i)); + (void)to_number(a); + (void)to_number(b); + r = make_number ((FP___TYPE)(a->u.i <= b->u.i)); } free_value (a); @@ -638,7 +656,7 @@ } else { - (void)to_integer(a); + (void)to_number(a); if( a->u.i ) { free_value(a); @@ -663,11 +681,11 @@ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); - r = make_integer ((quad_t)(strcoll (a->u.s, b->u.s) != 0)); + r = make_number ((FP___TYPE)(strcoll (a->u.s, b->u.s) != 0)); } else { - (void)to_integer(a); - (void)to_integer(b); - r = make_integer ((quad_t)(a->u.i != b->u.i)); + (void)to_number(a); + (void)to_number(b); + r = make_number ((FP___TYPE)(a->u.i != b->u.i)); } free_value (a); @@ -676,7 +694,7 @@ } static int -chk_plus (quad_t a, quad_t b, quad_t r) +chk_plus (FP___TYPE a, FP___TYPE b, FP___TYPE r) { /* sum of two positive numbers must be positive */ if (a > 0 && b > 0 && r <= 0) @@ -693,23 +711,23 @@ { struct val *r; - if (!to_integer (a)) { + if (!to_number (a)) { if( !extra_error_message_supplied ) ast_log(LOG_WARNING,"non-numeric argument\n"); - if (!to_integer (b)) { + if (!to_number (b)) { free_value(a); free_value(b); - return make_integer(0); + return make_number(0); } else { free_value(a); return (b); } - } else if (!to_integer(b)) { + } else if (!to_number(b)) { free_value(b); return (a); } - r = make_integer (/*(quad_t)*/(a->u.i + b->u.i)); + r = make_number (a->u.i + b->u.i); if (chk_plus (a->u.i, b->u.i, r->u.i)) { ast_log(LOG_WARNING,"overflow\n"); } @@ -719,7 +737,7 @@ } static int -chk_minus (quad_t a, quad_t b, quad_t r) +chk_minus (FP___TYPE a, FP___TYPE b, FP___TYPE r) { /* special case subtraction of QUAD_MIN */ if (b == QUAD_MIN) { @@ -737,27 +755,27 @@ { struct val *r; - if (!to_integer (a)) { + if (!to_number (a)) { if( !extra_error_message_supplied ) ast_log(LOG_WARNING, "non-numeric argument\n"); - if (!to_integer (b)) { + if (!to_number (b)) { free_value(a); free_value(b); - return make_integer(0); + return make_number(0); } else { - r = make_integer(0 - b->u.i); + r = make_number(0 - b->u.i); free_value(a); free_value(b); return (r); } - } else if (!to_integer(b)) { + } else if (!to_number(b)) { if( !extra_error_message_supplied ) ast_log(LOG_WARNING, "non-numeric argument\n"); free_value(b); return (a); } - r = make_integer (/*(quad_t)*/(a->u.i - b->u.i)); + r = make_number (a->u.i - b->u.i); if (chk_minus (a->u.i, b->u.i, r->u.i)) { ast_log(LOG_WARNING, "overflow\n"); } @@ -771,14 +789,14 @@ { struct val *r; - if (!to_integer (a) ) { + if (!to_number (a) ) { free_value(a); if( !extra_error_message_supplied ) ast_log(LOG_WARNING, "non-numeric argument\n"); - return make_integer(0); + return make_number(0); } - r = make_integer (/*(quad_t)*/(- a->u.i)); + r = make_number (- a->u.i); if (chk_minus (0, a->u.i, r->u.i)) { ast_log(LOG_WARNING, "overflow\n"); } @@ -800,7 +818,7 @@ { switch( a->type ) { - case AST_EXPR_integer: + case AST_EXPR_number: if( a->u.i == 0 ) v1 = 0; break; @@ -831,13 +849,13 @@ } } - r = make_integer (!v1); + r = make_number (!v1); free_value (a); return r; } static int -chk_times (quad_t a, quad_t b, quad_t r) +chk_times (FP___TYPE a, FP___TYPE b, FP___TYPE r) { /* special case: first operand is 0, no overflow possible */ if (a == 0) @@ -853,15 +871,15 @@ { struct val *r; - if (!to_integer (a) || !to_integer (b)) { + if (!to_number (a) || !to_number (b)) { free_value(a); free_value(b); if( !extra_error_message_supplied ) ast_log(LOG_WARNING, "non-numeric argument\n"); - return(make_integer(0)); + return(make_number(0)); } - r = make_integer (/*(quad_t)*/(a->u.i * b->u.i)); + r = make_number (a->u.i * b->u.i); if (chk_times (a->u.i, b->u.i, r->u.i)) { ast_log(LOG_WARNING, "overflow\n"); } @@ -871,7 +889,7 @@ } static int -chk_div (quad_t a, quad_t b) +chk_div (FP___TYPE a, FP___TYPE b) { /* div by zero has been taken care of before */ /* only QUAD_MIN / -1 causes overflow */ @@ -886,28 +904,28 @@ { struct val *r; - if (!to_integer (a)) { + if (!to_number (a)) { free_value(a); free_value(b); if( !extra_error_message_supplied ) ast_log(LOG_WARNING, "non-numeric argument\n"); - return make_integer(0); - } else if (!to_integer (b)) { + return make_number(0); + } else if (!to_number (b)) { free_value(a); free_value(b); if( !extra_error_message_supplied ) ast_log(LOG_WARNING, "non-numeric argument\n"); - return make_integer(INT_MAX); + return make_number(INT_MAX); } if (b->u.i == 0) { ast_log(LOG_WARNING, "division by zero\n"); free_value(a); free_value(b); - return make_integer(INT_MAX); + return make_number(INT_MAX); } - r = make_integer (/*(quad_t)*/(a->u.i / b->u.i)); + r = make_number (a->u.i / b->u.i); if (chk_div (a->u.i, b->u.i)) { ast_log(LOG_WARNING, "overflow\n"); } @@ -921,12 +939,12 @@ { struct val *r; - if (!to_integer (a) || !to_integer (b)) { + if (!to_number (a) || !to_number (b)) { if( !extra_error_message_supplied ) ast_log(LOG_WARNING, "non-numeric argument\n"); free_value(a); free_value(b); - return make_integer(0); + return make_number(0); } if (b->u.i == 0) { @@ -935,7 +953,7 @@ return(b); } - r = make_integer (/*(quad_t)*/(a->u.i % b->u.i)); + r = make_number (FP___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); @@ -975,11 +993,11 @@ v = make_str (a->u.s + rm[1].rm_so); } else { - v = make_integer ((quad_t)(rm[0].rm_eo - rm[0].rm_so)); + v = make_number ((FP___TYPE)(rm[0].rm_eo - rm[0].rm_so)); } } else { if (rp.re_nsub == 0) { - v = make_integer ((quad_t)0); + v = make_number ((FP___TYPE)0); } else { v = make_str (""); } @@ -1026,11 +1044,11 @@ v = make_str (a->u.s + rm[1].rm_so); } else { - v = make_integer ((quad_t)(rm[0].rm_eo - rm[0].rm_so)); + v = make_number ((FP___TYPE)(rm[0].rm_eo - rm[0].rm_so)); } } else { if (rp.re_nsub == 0) { - v = make_integer ((quad_t)0); + v = make_number ((FP___TYPE)0.0); } else { v = make_str (""); } Index: utils/expr2.testinput =================================================================== --- utils/expr2.testinput (revision 72704) +++ utils/expr2.testinput (working copy) @@ -90,3 +90,7 @@ 3 something 043 +2.1+4.2 +1.500003+1.4999999999999898989898989898989898989889898 +1/4 +