aboutsummaryrefslogtreecommitdiffstats
path: root/main/ast_expr2.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/ast_expr2.c')
-rw-r--r--main/ast_expr2.c433
1 files changed, 219 insertions, 214 deletions
diff --git a/main/ast_expr2.c b/main/ast_expr2.c
index b223c4f28..021feff74 100644
--- a/main/ast_expr2.c
+++ b/main/ast_expr2.c
@@ -1,9 +1,7 @@
-/* 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
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
- Free Software Foundation, Inc.
+/* Skeleton parser for Yacc-like parsing with Bison,
+ 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
@@ -20,18 +18,10 @@
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.
-
- This special exception was added by the Free Software Foundation in
- version 2.2 of Bison. */
+/* 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. */
/* 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,33 @@
* $FreeBSD: src/bin/expr/expr.y,v 1.16 2000/07/22 10:59:36 se Exp $
*/
-#include "asterisk.h"
+#include <sys/types.h>
+#include <stdio.h>
-#ifndef STANDALONE
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+#ifdef STANDALONE /* I guess somewhere, the feature is set in the asterisk includes */
+#ifndef __USE_ISOC99
+#define __USE_ISOC99 1
+#endif
+#endif
+
+#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 <sys/types.h>
-#include <stdio.h>
#include <stdlib.h>
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
#include <string.h>
+#include <math.h>
#include <locale.h>
#include <unistd.h>
#include <ctype.h>
@@ -161,6 +168,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <regex.h>
#include <limits.h>
+#include "asterisk.h"
#include "asterisk/ast_expr.h"
#include "asterisk/logger.h"
@@ -177,7 +185,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
# 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 +193,7 @@ extern char extra_error_message[4095];
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 +204,7 @@ struct val {
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 +217,14 @@ struct parse_io
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 +244,7 @@ static struct val *op_or __P((struct val *, struct val *));
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 +292,12 @@ int ast_yyerror(const char *,YYLTYPE *, struct parse_io *);
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
-#line 147 "ast_expr2.y"
+#line 165 "ast_expr2.y"
{
struct val *val;
}
-/* Line 193 of yacc.c. */
-#line 293 "ast_expr2.c"
+/* Line 198 of yacc.c. */
+#line 301 "ast_expr2.c"
YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
@@ -311,13 +319,13 @@ typedef struct YYLTYPE
/* Copy the second part of user declarations. */
-#line 151 "ast_expr2.y"
+#line 169 "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 329 "ast_expr2.c"
#ifdef short
# undef short
@@ -447,13 +455,8 @@ YYID (i)
# 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 <stdlib.h> /* 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 +472,9 @@ void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
void free (void *); /* INFRINGES ON USER NAME SPACE */
# endif
# endif
+# ifdef __cplusplus
+}
+# endif
# endif
#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
@@ -612,9 +618,9 @@ static const yytype_int8 yyrhs[] =
/* 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, 193, 193, 201, 208, 209, 213, 217, 221, 225,
+ 229, 233, 237, 241, 245, 249, 253, 257, 261, 265,
+ 269, 273, 277, 281
};
#endif
@@ -872,14 +878,14 @@ do { \
#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 +912,14 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp)
#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 +972,8 @@ static void
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 +1096,7 @@ yytnamerr (char *yyres, const char *yystr)
{
if (*yystr == '"')
{
- YYSIZE_T yyn = 0;
+ size_t yyn = 0;
char const *yyp = yystr;
for (;;)
@@ -1136,7 +1143,7 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
{
int yyn = yypact[yystate];
- if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
+ if (! (YYPACT_NINF < yyn && yyn < YYLAST))
return 0;
else
{
@@ -1174,7 +1181,7 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
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 +1269,114 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp)
switch (yytype)
{
case 3: /* "TOK_COLONCOLON" */
-#line 169 "ast_expr2.y"
+#line 187 "ast_expr2.y"
{ free_value((yyvaluep->val)); };
-#line 1268 "ast_expr2.c"
+#line 1275 "ast_expr2.c"
break;
case 4: /* "TOK_COND" */
-#line 169 "ast_expr2.y"
+#line 187 "ast_expr2.y"
{ free_value((yyvaluep->val)); };
-#line 1273 "ast_expr2.c"
+#line 1280 "ast_expr2.c"
break;
case 5: /* "TOK_OR" */
-#line 169 "ast_expr2.y"
+#line 187 "ast_expr2.y"
{ free_value((yyvaluep->val)); };
-#line 1278 "ast_expr2.c"
+#line 1285 "ast_expr2.c"
break;
case 6: /* "TOK_AND" */
-#line 169 "ast_expr2.y"
+#line 187 "ast_expr2.y"
{ free_value((yyvaluep->val)); };
-#line 1283 "ast_expr2.c"
+#line 1290 "ast_expr2.c"
break;
case 7: /* "TOK_NE" */
-#line 169 "ast_expr2.y"
+#line 187 "ast_expr2.y"
{ free_value((yyvaluep->val)); };
-#line 1288 "ast_expr2.c"
+#line 1295 "ast_expr2.c"
break;
case 8: /* "TOK_LE" */
-#line 169 "ast_expr2.y"
+#line 187 "ast_expr2.y"
{ free_value((yyvaluep->val)); };
-#line 1293 "ast_expr2.c"
+#line 1300 "ast_expr2.c"
break;
case 9: /* "TOK_GE" */
-#line 169 "ast_expr2.y"
+#line 187 "ast_expr2.y"
{ free_value((yyvaluep->val)); };
-#line 1298 "ast_expr2.c"
+#line 1305 "ast_expr2.c"
break;
case 10: /* "TOK_LT" */
-#line 169 "ast_expr2.y"
+#line 187 "ast_expr2.y"
{ free_value((yyvaluep->val)); };
-#line 1303 "ast_expr2.c"
+#line 1310 "ast_expr2.c"
break;
case 11: /* "TOK_GT" */
-#line 169 "ast_expr2.y"
+#line 187 "ast_expr2.y"
{ free_value((yyvaluep->val)); };
-#line 1308 "ast_expr2.c"
+#line 1315 "ast_expr2.c"
break;
case 12: /* "TOK_EQ" */
-#line 169 "ast_expr2.y"
+#line 187 "ast_expr2.y"
{ free_value((yyvaluep->val)); };
-#line 1313 "ast_expr2.c"
+#line 1320 "ast_expr2.c"
break;
case 13: /* "TOK_MINUS" */
-#line 169 "ast_expr2.y"
+#line 187 "ast_expr2.y"
{ free_value((yyvaluep->val)); };
-#line 1318 "ast_expr2.c"
+#line 1325 "ast_expr2.c"
break;
case 14: /* "TOK_PLUS" */
-#line 169 "ast_expr2.y"
+#line 187 "ast_expr2.y"
{ free_value((yyvaluep->val)); };
-#line 1323 "ast_expr2.c"
+#line 1330 "ast_expr2.c"
break;
case 15: /* "TOK_MOD" */
-#line 169 "ast_expr2.y"
+#line 187 "ast_expr2.y"
{ free_value((yyvaluep->val)); };
-#line 1328 "ast_expr2.c"
+#line 1335 "ast_expr2.c"
break;
case 16: /* "TOK_DIV" */
-#line 169 "ast_expr2.y"
+#line 187 "ast_expr2.y"
{ free_value((yyvaluep->val)); };
-#line 1333 "ast_expr2.c"
+#line 1340 "ast_expr2.c"
break;
case 17: /* "TOK_MULT" */
-#line 169 "ast_expr2.y"
+#line 187 "ast_expr2.y"
{ free_value((yyvaluep->val)); };
-#line 1338 "ast_expr2.c"
+#line 1345 "ast_expr2.c"
break;
case 18: /* "TOK_COMPL" */
-#line 169 "ast_expr2.y"
+#line 187 "ast_expr2.y"
{ free_value((yyvaluep->val)); };
-#line 1343 "ast_expr2.c"
+#line 1350 "ast_expr2.c"
break;
case 19: /* "TOK_EQTILDE" */
-#line 169 "ast_expr2.y"
+#line 187 "ast_expr2.y"
{ free_value((yyvaluep->val)); };
-#line 1348 "ast_expr2.c"
+#line 1355 "ast_expr2.c"
break;
case 20: /* "TOK_COLON" */
-#line 169 "ast_expr2.y"
+#line 187 "ast_expr2.y"
{ free_value((yyvaluep->val)); };
-#line 1353 "ast_expr2.c"
+#line 1360 "ast_expr2.c"
break;
case 21: /* "TOK_LP" */
-#line 169 "ast_expr2.y"
+#line 187 "ast_expr2.y"
{ free_value((yyvaluep->val)); };
-#line 1358 "ast_expr2.c"
+#line 1365 "ast_expr2.c"
break;
case 22: /* "TOK_RP" */
-#line 169 "ast_expr2.y"
+#line 187 "ast_expr2.y"
{ free_value((yyvaluep->val)); };
-#line 1363 "ast_expr2.c"
+#line 1370 "ast_expr2.c"
break;
case 23: /* "TOKEN" */
-#line 169 "ast_expr2.y"
+#line 187 "ast_expr2.y"
{ free_value((yyvaluep->val)); };
-#line 1368 "ast_expr2.c"
+#line 1375 "ast_expr2.c"
break;
case 26: /* "expr" */
-#line 169 "ast_expr2.y"
+#line 187 "ast_expr2.y"
{ free_value((yyvaluep->val)); };
-#line 1373 "ast_expr2.c"
+#line 1380 "ast_expr2.c"
break;
default:
@@ -1692,10 +1699,10 @@ yyreduce:
switch (yyn)
{
case 2:
-#line 175 "ast_expr2.y"
+#line 193 "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 +1711,7 @@ yyreduce:
break;
case 3:
-#line 183 "ast_expr2.y"
+#line 201 "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 +1719,12 @@ yyreduce:
break;
case 4:
-#line 190 "ast_expr2.y"
+#line 208 "ast_expr2.y"
{ (yyval.val)= (yyvsp[(1) - (1)].val);;}
break;
case 5:
-#line 191 "ast_expr2.y"
+#line 209 "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 +1732,7 @@ yyreduce:
break;
case 6:
-#line 195 "ast_expr2.y"
+#line 213 "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 +1740,7 @@ yyreduce:
break;
case 7:
-#line 199 "ast_expr2.y"
+#line 217 "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 +1748,7 @@ yyreduce:
break;
case 8:
-#line 203 "ast_expr2.y"
+#line 221 "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 +1756,7 @@ yyreduce:
break;
case 9:
-#line 207 "ast_expr2.y"
+#line 225 "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 +1764,7 @@ yyreduce:
break;
case 10:
-#line 211 "ast_expr2.y"
+#line 229 "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 +1772,7 @@ yyreduce:
break;
case 11:
-#line 215 "ast_expr2.y"
+#line 233 "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 +1780,7 @@ yyreduce:
break;
case 12:
-#line 219 "ast_expr2.y"
+#line 237 "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 +1788,7 @@ yyreduce:
break;
case 13:
-#line 223 "ast_expr2.y"
+#line 241 "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 +1796,7 @@ yyreduce:
break;
case 14:
-#line 227 "ast_expr2.y"
+#line 245 "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 +1804,7 @@ yyreduce:
break;
case 15:
-#line 231 "ast_expr2.y"
+#line 249 "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 +1812,7 @@ yyreduce:
break;
case 16:
-#line 235 "ast_expr2.y"
+#line 253 "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 +1820,7 @@ yyreduce:
break;
case 17:
-#line 239 "ast_expr2.y"
+#line 257 "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 +1828,7 @@ yyreduce:
break;
case 18:
-#line 243 "ast_expr2.y"
+#line 261 "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 +1836,7 @@ yyreduce:
break;
case 19:
-#line 247 "ast_expr2.y"
+#line 265 "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 +1844,7 @@ yyreduce:
break;
case 20:
-#line 251 "ast_expr2.y"
+#line 269 "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 +1852,7 @@ yyreduce:
break;
case 21:
-#line 255 "ast_expr2.y"
+#line 273 "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 +1860,7 @@ yyreduce:
break;
case 22:
-#line 259 "ast_expr2.y"
+#line 277 "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 +1868,7 @@ yyreduce:
break;
case 23:
-#line 263 "ast_expr2.y"
+#line 281 "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 +1877,8 @@ yyreduce:
break;
-/* Line 1267 of yacc.c. */
-#line 1875 "ast_expr2.c"
+/* Line 1270 of yacc.c. */
+#line 1882 "ast_expr2.c"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -2086,16 +2093,15 @@ yyreturn:
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
#endif
- /* Make sure YYID is used. */
- return YYID (yyresult);
+ return yyresult;
}
-#line 270 "ast_expr2.y"
+#line 288 "ast_expr2.y"
static struct val *
-make_integer (quad_t i)
+make_number (FP___TYPE i)
{
struct val *vp;
@@ -2105,7 +2111,7 @@ make_integer (quad_t i)
return(NULL);
}
- vp->type = AST_EXPR_integer;
+ vp->type = AST_EXPR_number;
vp->u.i = i;
return vp;
}
@@ -2115,7 +2121,7 @@ make_str (const char *s)
{
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 +2129,13 @@ make_str (const char *s)
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 +2157,17 @@ free_value (struct val *vp)
}
-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 +2175,16 @@ to_integer (struct val *vp)
/* 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 +2225,7 @@ to_string (struct val *vp)
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 +2234,7 @@ to_string (struct val *vp)
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 +2242,10 @@ isstring (struct val *vp)
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 +2332,7 @@ op_and (struct val *a, struct val *b)
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 +2347,18 @@ op_eq (struct val *a, struct val *b)
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 +2374,11 @@ op_gt (struct val *a, struct val *b)
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 +2394,11 @@ op_lt (struct val *a, struct val *b)
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 +2414,11 @@ op_ge (struct val *a, struct val *b)
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 +2434,11 @@ op_le (struct val *a, struct val *b)
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 +2468,7 @@ op_cond (struct val *a, struct val *b, struct val *c)
}
else
{
- (void)to_integer(a);
+ (void)to_number(a);
if( a->u.i )
{
free_value(a);
@@ -2488,11 +2493,11 @@ op_ne (struct val *a, struct val *b)
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 +2506,7 @@ op_ne (struct val *a, struct val *b)
}
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 +2523,23 @@ op_plus (struct val *a, struct val *b)
{
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 +2549,7 @@ op_plus (struct val *a, struct val *b)
}
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 +2567,27 @@ op_minus (struct val *a, struct val *b)
{
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 +2601,14 @@ op_negate (struct val *a)
{
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 +2630,7 @@ op_compl (struct val *a)
{
switch( a->type )
{
- case AST_EXPR_integer:
+ case AST_EXPR_number:
if( a->u.i == 0 )
v1 = 0;
break;
@@ -2656,13 +2661,13 @@ op_compl (struct val *a)
}
}
- 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 +2683,15 @@ op_times (struct val *a, struct val *b)
{
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 +2701,7 @@ op_times (struct val *a, struct val *b)
}
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 +2716,28 @@ op_div (struct val *a, struct val *b)
{
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 +2751,12 @@ op_rem (struct val *a, struct val *b)
{
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 +2765,7 @@ op_rem (struct val *a, struct val *b)
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 +2805,11 @@ op_colon (struct val *a, struct val *b)
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 +2856,11 @@ op_eqtilde (struct val *a, struct val *b)
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 ("");
}