[asterisk-commits] branch murf/bug_6072 - r8263 /team/murf/bug_6072/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu Jan 19 07:46:15 MST 2006
Author: murf
Date: Thu Jan 19 08:46:12 2006
New Revision: 8263
URL: http://svn.digium.com/view/asterisk?rev=8263&view=rev
Log:
committing the propdel of svnmerge-integrated
as well as the diffs from corydon for removing the leaks.
Modified:
team/murf/bug_6072/ast_expr2.c
team/murf/bug_6072/ast_expr2.fl
team/murf/bug_6072/ast_expr2.h
team/murf/bug_6072/ast_expr2.y
team/murf/bug_6072/ast_expr2f.c
Modified: team/murf/bug_6072/ast_expr2.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug_6072/ast_expr2.c?rev=8263&r1=8262&r2=8263&view=diff
==============================================================================
--- team/murf/bug_6072/ast_expr2.c (original)
+++ team/murf/bug_6072/ast_expr2.c Thu Jan 19 08:46:12 2006
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 1.875d. */
+/* A Bison parser, made by GNU Bison 2.0. */
/* Skeleton parser for Yacc-like parsing with Bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
@@ -45,8 +45,7 @@
/* Using locations. */
#define YYLSP_NEEDED 1
-/* If NAME_PREFIX is specified substitute the variables and functions
- names. */
+/* Substitute the variable and function names. */
#define yyparse ast_yyparse
#define yylex ast_yylex
#define yyerror ast_yyerror
@@ -238,7 +237,12 @@
some useful info about the error. Not as easy as it looks, but it
is possible. */
#define ast_yyerror(x) ast_yyerror(x,&yyloc,parseio)
-
+#define DESTROY(x) { \
+if ((x)->type == AST_EXPR_numeric_string || (x)->type == AST_EXPR_string) \
+ free((x)->u.s); \
+ (x)->u.s = 0; \
+ free(x); \
+}
/* Enabling traces. */
@@ -255,12 +259,12 @@
#endif
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
-#line 137 "ast_expr2.y"
+#line 142 "ast_expr2.y"
typedef union YYSTYPE {
struct val *val;
} YYSTYPE;
-/* Line 191 of yacc.c. */
-#line 264 "ast_expr2.c"
+/* Line 190 of yacc.c. */
+#line 268 "ast_expr2.c"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
@@ -281,13 +285,13 @@
/* Copy the second part of user declarations. */
-#line 141 "ast_expr2.y"
+#line 146 "ast_expr2.y"
extern int ast_yylex __P((YYSTYPE *, YYLTYPE *, yyscan_t));
-/* Line 214 of yacc.c. */
-#line 291 "ast_expr2.c"
+/* Line 213 of yacc.c. */
+#line 295 "ast_expr2.c"
#if ! defined (yyoverflow) || YYERROR_VERBOSE
@@ -302,14 +306,10 @@
# ifdef YYSTACK_USE_ALLOCA
# if YYSTACK_USE_ALLOCA
-# define YYSTACK_ALLOC alloca
-# endif
-# else
-# if defined (alloca) || defined (_ALLOCA_H)
-# define YYSTACK_ALLOC alloca
-# else
# ifdef __GNUC__
# define YYSTACK_ALLOC __builtin_alloca
+# else
+# define YYSTACK_ALLOC alloca
# endif
# endif
# endif
@@ -473,9 +473,9 @@
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const unsigned char yyrline[] =
{
- 0, 160, 160, 168, 169, 172, 175, 178, 181, 184,
- 187, 190, 193, 196, 199, 202, 205, 208, 211, 214,
- 217, 220, 223
+ 0, 165, 165, 175, 176, 180, 184, 188, 192, 196,
+ 200, 204, 208, 212, 216, 220, 224, 228, 232, 236,
+ 240, 244, 248
};
#endif
@@ -660,19 +660,52 @@
} \
while (0)
+
#define YYTERROR 1
#define YYERRCODE 256
-/* YYLLOC_DEFAULT -- Compute the default location (before the actions
- are run). */
-
+
+/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
+ If N is 0, then set CURRENT to the empty location which ends
+ the previous symbol: RHS[0] (always defined). */
+
+#define YYRHSLOC(Rhs, K) ((Rhs)[K])
#ifndef YYLLOC_DEFAULT
-# define YYLLOC_DEFAULT(Current, Rhs, N) \
- ((Current).first_line = (Rhs)[1].first_line, \
- (Current).first_column = (Rhs)[1].first_column, \
- (Current).last_line = (Rhs)[N].last_line, \
- (Current).last_column = (Rhs)[N].last_column)
-#endif
+# define YYLLOC_DEFAULT(Current, Rhs, N) \
+ do \
+ if (N) \
+ { \
+ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
+ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
+ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
+ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
+ } \
+ else \
+ { \
+ (Current).first_line = (Current).last_line = \
+ YYRHSLOC (Rhs, 0).last_line; \
+ (Current).first_column = (Current).last_column = \
+ YYRHSLOC (Rhs, 0).last_column; \
+ } \
+ while (0)
+#endif
+
+
+/* YY_LOCATION_PRINT -- Print the location on the stream.
+ This macro was not mandated originally: define only if we know
+ we won't break user code: when these are the locations we know. */
+
+#ifndef YY_LOCATION_PRINT
+# if YYLTYPE_IS_TRIVIAL
+# define YY_LOCATION_PRINT(File, Loc) \
+ fprintf (File, "%d.%d-%d.%d", \
+ (Loc).first_line, (Loc).first_column, \
+ (Loc).last_line, (Loc).last_column)
+# else
+# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+# endif
+#endif
+
/* YYLEX -- calling `yylex' with the right arguments. */
@@ -696,19 +729,13 @@
YYFPRINTF Args; \
} while (0)
-# define YYDSYMPRINT(Args) \
-do { \
- if (yydebug) \
- yysymprint Args; \
-} while (0)
-
-# define YYDSYMPRINTF(Title, Token, Value, Location) \
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
do { \
if (yydebug) \
{ \
YYFPRINTF (stderr, "%s ", Title); \
yysymprint (stderr, \
- Token, Value, Location); \
+ Type, Value, Location); \
YYFPRINTF (stderr, "\n"); \
} \
} while (0)
@@ -775,8 +802,7 @@
int yydebug;
#else /* !YYDEBUG */
# define YYDPRINTF(Args)
-# define YYDSYMPRINT(Args)
-# define YYDSYMPRINTF(Title, Token, Value, Location)
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
#endif /* !YYDEBUG */
@@ -793,10 +819,6 @@
Do not make this value too large; the results are undefined if
SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
evaluated with infinite-precision integer arithmetic. */
-
-#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0
-# undef YYMAXDEPTH
-#endif
#ifndef YYMAXDEPTH
# define YYMAXDEPTH 10000
@@ -881,15 +903,17 @@
(void) yylocationp;
if (yytype < YYNTOKENS)
- {
- YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
-# ifdef YYPRINT
- YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
-# endif
- }
+ YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
else
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
+ YY_LOCATION_PRINT (yyoutput, *yylocationp);
+ fprintf (yyoutput, ": ");
+
+# ifdef YYPRINT
+ if (yytype < YYNTOKENS)
+ YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+# endif
switch (yytype)
{
default:
@@ -905,10 +929,11 @@
#if defined (__STDC__) || defined (__cplusplus)
static void
-yydestruct (int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
+yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
#else
static void
-yydestruct (yytype, yyvaluep, yylocationp)
+yydestruct (yymsg, yytype, yyvaluep, yylocationp)
+ const char *yymsg;
int yytype;
YYSTYPE *yyvaluep;
YYLTYPE *yylocationp;
@@ -917,6 +942,10 @@
/* Pacify ``unused variable'' warnings. */
(void) yyvaluep;
(void) yylocationp;
+
+ if (!yymsg)
+ yymsg = "Deleting";
+ YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
switch (yytype)
{
@@ -970,15 +999,15 @@
#endif
#endif
{
- /* The lookahead symbol. */
+ /* The look-ahead symbol. */
int yychar;
-/* The semantic value of the lookahead symbol. */
+/* The semantic value of the look-ahead symbol. */
YYSTYPE yylval;
/* Number of syntax errors so far. */
int yynerrs;
-/* Location data for the lookahead symbol. */
+/* Location data for the look-ahead symbol. */
YYLTYPE yylloc;
register int yystate;
@@ -986,7 +1015,7 @@
int yyresult;
/* Number of tokens to shift before error messages enabled. */
int yyerrstatus;
- /* Lookahead token as an internal (translated) token number. */
+ /* Look-ahead token as an internal (translated) token number. */
int yytoken = 0;
/* Three stacks and their tools:
@@ -1011,7 +1040,8 @@
YYLTYPE yylsa[YYINITDEPTH];
YYLTYPE *yyls = yylsa;
YYLTYPE *yylsp;
- YYLTYPE *yylerrsp;
+ /* The locations where the error started and ended. */
+ YYLTYPE yyerror_range[2];
#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
@@ -1041,6 +1071,15 @@
yyssp = yyss;
yyvsp = yyvs;
yylsp = yyls;
+#if YYLTYPE_IS_TRIVIAL
+ /* Initialize the default location before parsing starts. */
+ yylloc.first_line = yylloc.last_line = 1;
+ yylloc.first_column = yylloc.last_column = 0;
+#endif
+
+
+ yyvsp[0] = yylval;
+ yylsp[0] = yylloc;
goto yysetstate;
@@ -1131,18 +1170,18 @@
yybackup:
/* Do appropriate processing given the current state. */
-/* Read a lookahead token if we need one and don't already have one. */
+/* Read a look-ahead token if we need one and don't already have one. */
/* yyresume: */
- /* First try to decide what to do without reference to lookahead token. */
+ /* First try to decide what to do without reference to look-ahead token. */
yyn = yypact[yystate];
if (yyn == YYPACT_NINF)
goto yydefault;
- /* Not known => get a lookahead token if don't already have one. */
-
- /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
+ /* Not known => get a look-ahead token if don't already have one. */
+
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
@@ -1157,7 +1196,7 @@
else
{
yytoken = YYTRANSLATE (yychar);
- YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
+ YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
}
/* If the proper action on seeing token YYTOKEN is to reduce or to
@@ -1177,8 +1216,8 @@
if (yyn == YYFINAL)
YYACCEPT;
- /* Shift the lookahead token. */
- YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
+ /* Shift the look-ahead token. */
+ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
/* Discard the token being shifted unless it is eof. */
if (yychar != YYEOF)
@@ -1229,158 +1268,180 @@
switch (yyn)
{
case 2:
-#line 160 "ast_expr2.y"
+#line 165 "ast_expr2.y"
{ ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1);
- ((struct parse_io *)parseio)->val->type = yyval.val->type;
- if( yyval.val->type == AST_EXPR_integer )
- ((struct parse_io *)parseio)->val->u.i = yyval.val->u.i;
+ ((struct parse_io *)parseio)->val->type = (yyvsp[0].val)->type;
+ if( (yyvsp[0].val)->type == AST_EXPR_integer )
+ ((struct parse_io *)parseio)->val->u.i = (yyvsp[0].val)->u.i;
else
- ((struct parse_io *)parseio)->val->u.s = yyval.val->u.s; ;}
+ ((struct parse_io *)parseio)->val->u.s = (yyvsp[0].val)->u.s;
+ free((yyvsp[0].val));
+ ;}
break;
case 3:
-#line 168 "ast_expr2.y"
- { yyval.val= yyvsp[0].val;;}
+#line 175 "ast_expr2.y"
+ { (yyval.val)= (yyvsp[0].val);;}
break;
case 4:
-#line 169 "ast_expr2.y"
- { yyval.val = yyvsp[-1].val;
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 176 "ast_expr2.y"
+ { (yyval.val) = (yyvsp[-1].val);
+ (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
+ (yyloc).first_line=0; (yyloc).last_line=0;
+ DESTROY((yyvsp[-2].val)); DESTROY((yyvsp[0].val)); ;}
break;
case 5:
-#line 172 "ast_expr2.y"
- { yyval.val = op_or (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 180 "ast_expr2.y"
+ { (yyval.val) = op_or ((yyvsp[-2].val), (yyvsp[0].val));
+ DESTROY((yyvsp[-1].val));
+ (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
+ (yyloc).first_line=0; (yyloc).last_line=0;;}
break;
case 6:
-#line 175 "ast_expr2.y"
- { yyval.val = op_and (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 184 "ast_expr2.y"
+ { (yyval.val) = op_and ((yyvsp[-2].val), (yyvsp[0].val));
+ DESTROY((yyvsp[-1].val));
+ (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
+ (yyloc).first_line=0; (yyloc).last_line=0;;}
break;
case 7:
-#line 178 "ast_expr2.y"
- { yyval.val = op_eq (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 188 "ast_expr2.y"
+ { (yyval.val) = op_eq ((yyvsp[-2].val), (yyvsp[0].val));
+ DESTROY((yyvsp[-1].val));
+ (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
+ (yyloc).first_line=0; (yyloc).last_line=0;;}
break;
case 8:
-#line 181 "ast_expr2.y"
- { yyval.val = op_gt (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 192 "ast_expr2.y"
+ { (yyval.val) = op_gt ((yyvsp[-2].val), (yyvsp[0].val));
+ DESTROY((yyvsp[-1].val));
+ (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
+ (yyloc).first_line=0; (yyloc).last_line=0;;}
break;
case 9:
-#line 184 "ast_expr2.y"
- { yyval.val = op_lt (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 196 "ast_expr2.y"
+ { (yyval.val) = op_lt ((yyvsp[-2].val), (yyvsp[0].val));
+ DESTROY((yyvsp[-1].val));
+ (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
+ (yyloc).first_line=0; (yyloc).last_line=0;;}
break;
case 10:
-#line 187 "ast_expr2.y"
- { yyval.val = op_ge (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 200 "ast_expr2.y"
+ { (yyval.val) = op_ge ((yyvsp[-2].val), (yyvsp[0].val));
+ DESTROY((yyvsp[-1].val));
+ (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
+ (yyloc).first_line=0; (yyloc).last_line=0;;}
break;
case 11:
-#line 190 "ast_expr2.y"
- { yyval.val = op_le (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 204 "ast_expr2.y"
+ { (yyval.val) = op_le ((yyvsp[-2].val), (yyvsp[0].val));
+ DESTROY((yyvsp[-1].val));
+ (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
+ (yyloc).first_line=0; (yyloc).last_line=0;;}
break;
case 12:
-#line 193 "ast_expr2.y"
- { yyval.val = op_ne (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 208 "ast_expr2.y"
+ { (yyval.val) = op_ne ((yyvsp[-2].val), (yyvsp[0].val));
+ DESTROY((yyvsp[-1].val));
+ (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
+ (yyloc).first_line=0; (yyloc).last_line=0;;}
break;
case 13:
-#line 196 "ast_expr2.y"
- { yyval.val = op_plus (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 212 "ast_expr2.y"
+ { (yyval.val) = op_plus ((yyvsp[-2].val), (yyvsp[0].val));
+ DESTROY((yyvsp[-1].val));
+ (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
+ (yyloc).first_line=0; (yyloc).last_line=0;;}
break;
case 14:
-#line 199 "ast_expr2.y"
- { yyval.val = op_minus (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 216 "ast_expr2.y"
+ { (yyval.val) = op_minus ((yyvsp[-2].val), (yyvsp[0].val));
+ DESTROY((yyvsp[-1].val));
+ (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
+ (yyloc).first_line=0; (yyloc).last_line=0;;}
break;
case 15:
-#line 202 "ast_expr2.y"
- { yyval.val = op_negate (yyvsp[0].val);
- yyloc.first_column = yylsp[-1].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 220 "ast_expr2.y"
+ { (yyval.val) = op_negate ((yyvsp[0].val));
+ DESTROY((yyvsp[-1].val));
+ (yyloc).first_column = (yylsp[-1]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
+ (yyloc).first_line=0; (yyloc).last_line=0;;}
break;
case 16:
-#line 205 "ast_expr2.y"
- { yyval.val = op_compl (yyvsp[0].val);
- yyloc.first_column = yylsp[-1].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 224 "ast_expr2.y"
+ { (yyval.val) = op_compl ((yyvsp[0].val));
+ DESTROY((yyvsp[-1].val));
+ (yyloc).first_column = (yylsp[-1]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
+ (yyloc).first_line=0; (yyloc).last_line=0;;}
break;
case 17:
-#line 208 "ast_expr2.y"
- { yyval.val = op_times (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 228 "ast_expr2.y"
+ { (yyval.val) = op_times ((yyvsp[-2].val), (yyvsp[0].val));
+ DESTROY((yyvsp[-1].val));
+ (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
+ (yyloc).first_line=0; (yyloc).last_line=0;;}
break;
case 18:
-#line 211 "ast_expr2.y"
- { yyval.val = op_div (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 232 "ast_expr2.y"
+ { (yyval.val) = op_div ((yyvsp[-2].val), (yyvsp[0].val));
+ DESTROY((yyvsp[-1].val));
+ (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
+ (yyloc).first_line=0; (yyloc).last_line=0;;}
break;
case 19:
-#line 214 "ast_expr2.y"
- { yyval.val = op_rem (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 236 "ast_expr2.y"
+ { (yyval.val) = op_rem ((yyvsp[-2].val), (yyvsp[0].val));
+ DESTROY((yyvsp[-1].val));
+ (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
+ (yyloc).first_line=0; (yyloc).last_line=0;;}
break;
case 20:
-#line 217 "ast_expr2.y"
- { yyval.val = op_colon (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 240 "ast_expr2.y"
+ { (yyval.val) = op_colon ((yyvsp[-2].val), (yyvsp[0].val));
+ DESTROY((yyvsp[-1].val));
+ (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
+ (yyloc).first_line=0; (yyloc).last_line=0;;}
break;
case 21:
-#line 220 "ast_expr2.y"
- { yyval.val = op_eqtilde (yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-2].first_column; yyloc.last_column = yylsp[0].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 244 "ast_expr2.y"
+ { (yyval.val) = op_eqtilde ((yyvsp[-2].val), (yyvsp[0].val));
+ DESTROY((yyvsp[-1].val));
+ (yyloc).first_column = (yylsp[-2]).first_column; (yyloc).last_column = (yylsp[0]).last_column;
+ (yyloc).first_line=0; (yyloc).last_line=0;;}
break;
case 22:
-#line 223 "ast_expr2.y"
- { yyval.val = op_cond (yyvsp[-4].val, yyvsp[-2].val, yyvsp[0].val);
- yyloc.first_column = yylsp[-4].first_column; yyloc.last_column = yylsp[-2].last_column;
- yyloc.first_line=0; yyloc.last_line=0;;}
+#line 248 "ast_expr2.y"
+ { (yyval.val) = op_cond ((yyvsp[-4].val), (yyvsp[-2].val), (yyvsp[0].val));
+ DESTROY((yyvsp[-3].val));
+ DESTROY((yyvsp[-1].val));
+ (yyloc).first_column = (yylsp[-4]).first_column; (yyloc).last_column = (yylsp[-2]).last_column;
+ (yyloc).first_line=0; (yyloc).last_line=0;;}
break;
}
-/* Line 1010 of yacc.c. */
-#line 1384 "ast_expr2.c"
+/* Line 1037 of yacc.c. */
+#line 1445 "ast_expr2.c"
yyvsp -= yylen;
yyssp -= yylen;
@@ -1476,11 +1537,11 @@
yyerror ("syntax error");
}
- yylerrsp = yylsp;
+ yyerror_range[0] = yylloc;
if (yyerrstatus == 3)
{
- /* If just tried and failed to reuse lookahead token after an
+ /* If just tried and failed to reuse look-ahead token after an
error, discard it. */
if (yychar <= YYEOF)
@@ -1490,23 +1551,22 @@
if (yychar == YYEOF)
for (;;)
{
+ yyerror_range[0] = *yylsp;
YYPOPSTACK;
if (yyssp == yyss)
YYABORT;
- YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
- yydestruct (yystos[*yyssp], yyvsp, yylsp);
+ yydestruct ("Error: popping",
+ yystos[*yyssp], yyvsp, yylsp);
}
}
else
{
- YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
- yydestruct (yytoken, &yylval, &yylloc);
+ yydestruct ("Error: discarding", yytoken, &yylval, &yylloc);
yychar = YYEMPTY;
- *++yylerrsp = yylloc;
}
}
- /* Else will try to reuse lookahead token after shifting the error
+ /* Else will try to reuse look-ahead token after shifting the error
token. */
goto yyerrlab1;
@@ -1523,12 +1583,11 @@
goto yyerrorlab;
#endif
+ yyerror_range[0] = yylsp[1-yylen];
+ yylsp -= yylen;
yyvsp -= yylen;
yyssp -= yylen;
yystate = *yyssp;
- yylerrsp = yylsp;
- *++yylerrsp = yyloc;
- yylsp -= yylen;
goto yyerrlab1;
@@ -1556,8 +1615,8 @@
if (yyssp == yyss)
YYABORT;
- YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
- yydestruct (yystos[yystate], yyvsp, yylsp);
+ yyerror_range[0] = *yylsp;
+ yydestruct ("Error: popping", yystos[yystate], yyvsp, yylsp);
YYPOPSTACK;
yystate = *yyssp;
YY_STACK_PRINT (yyss, yyssp);
@@ -1566,11 +1625,16 @@
if (yyn == YYFINAL)
YYACCEPT;
- YYDPRINTF ((stderr, "Shifting error token, "));
-
*++yyvsp = yylval;
- YYLLOC_DEFAULT (yyloc, yylsp, yylerrsp - yylsp);
+
+ yyerror_range[1] = yylloc;
+ /* Using YYLLOC is tempting, but would change the location of
+ the look-ahead. YYLOC is available though. */
+ YYLLOC_DEFAULT (yyloc, yyerror_range - 1, 2);
*++yylsp = yyloc;
+
+ /* Shift the error token. */
+ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
yystate = yyn;
goto yynewstate;
@@ -1587,6 +1651,9 @@
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
yyabortlab:
+ yydestruct ("Error: discarding lookahead",
+ yytoken, &yylval, &yylloc);
+ yychar = YYEMPTY;
yyresult = 1;
goto yyreturn;
@@ -1609,7 +1676,7 @@
}
-#line 228 "ast_expr2.y"
+#line 255 "ast_expr2.y"
static struct val *
@@ -1666,6 +1733,7 @@
}
if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string)
free (vp->u.s);
+ free(vp);
}
Modified: team/murf/bug_6072/ast_expr2.fl
URL: http://svn.digium.com/view/asterisk/team/murf/bug_6072/ast_expr2.fl?rev=8263&r1=8262&r2=8263&view=diff
==============================================================================
--- team/murf/bug_6072/ast_expr2.fl (original)
+++ team/murf/bug_6072/ast_expr2.fl Thu Jan 19 08:46:12 2006
@@ -1,4 +1,9 @@
%{
+/*! \file
+ *
+ * \brief Dialplan Expression Parser
+ */
+
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
@@ -44,7 +49,7 @@
void ast_yyset_column(int column_no, yyscan_t yyscanner);
int ast_yyget_column(yyscan_t yyscanner);
-
+static int curlycount = 0;
%}
%option prefix="ast_yy"
@@ -54,6 +59,7 @@
%option bison-bridge
%option bison-locations
%option noyywrap
+%x var trail
%%
@@ -75,6 +81,8 @@
\:\: { SET_COLUMNS; SET_STRING; return TOK_COLONCOLON;}
\( { SET_COLUMNS; SET_STRING; return TOK_LP;}
\) { SET_COLUMNS; SET_STRING; return TOK_RP;}
+\$\{ {/* gather the contents of ${} expressions, with trailing stuff, into a single TOKEN. They are much more complex now than they used to be */
+ curlycount = 0; BEGIN(var); yymore();}
[ \r] {}
\"[^"]*\" {SET_COLUMNS; SET_STRING; return TOKEN;}
@@ -83,7 +91,14 @@
[0-9]+ { SET_COLUMNS; /* the original behavior of the expression parser was to bring in numbers as a numeric string */
SET_NUMERIC_STRING;
return TOKEN;}
-[a-zA-Z0-9,.';{}\\_^%$#@!]+ {SET_COLUMNS; SET_STRING; return TOKEN;}
+[a-zA-Z0-9,.';\\_^%$#@!]+ {SET_COLUMNS; SET_STRING; return TOKEN;}
+
+<var>[^{}]*\} {curlycount--; if(curlycount < 0){ BEGIN(trail); yymore();} else { yymore();}}
+<var>[^{}]*\{ {curlycount++; yymore(); }
+<trail>[^-\t\r \n$():?%/+=*<>!|&]* {BEGIN(0); SET_COLUMNS; SET_STRING; return TOKEN;}
+<trail>[-\t\r \n$():?%/+=*<>!|&] {char c = yytext[yyleng-1]; BEGIN(0); unput(c); SET_COLUMNS; SET_STRING; return TOKEN;}
+<trail>\$\{ {curlycount = 0; BEGIN(var); yymore(); }
+<trail><<EOF>> {BEGIN(0); SET_COLUMNS; SET_STRING; return TOKEN; /* actually, if an expr is only a variable ref, this could happen a LOT */}
%%
@@ -130,6 +145,7 @@
ast_copy_string(buf, io.val->u.s, length);
#endif /* STANDALONE */
return_value = strlen(buf);
+ free(io.val->u.s);
}
free(io.val);
}
@@ -144,15 +160,6 @@
int i=0;
spacebuf[0] = 0;
-#ifdef WHEN_LOC_MEANS_SOMETHING
- if( loc->first_column > 7990 ) /* if things get out of whack, why crash? */
- loc->first_column = 7990;
- if( loc->last_column > 7990 )
- loc->last_column = 7990;
- for(i=0;i<loc->first_column;i++) spacebuf[i] = ' ';
- for( ;i<loc->last_column;i++) spacebuf[i] = '^';
- spacebuf[i] = 0;
-#endif
for(i=0;i< (int)(yytext - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf);i++) spacebuf2[i] = ' '; /* uh... assuming yyg is defined, then I can use the yycolumn macro,
which is the same thing as... get this:
yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_bs_column
Modified: team/murf/bug_6072/ast_expr2.h
URL: http://svn.digium.com/view/asterisk/team/murf/bug_6072/ast_expr2.h?rev=8263&r1=8262&r2=8263&view=diff
==============================================================================
--- team/murf/bug_6072/ast_expr2.h (original)
+++ team/murf/bug_6072/ast_expr2.h Thu Jan 19 08:46:12 2006
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 1.875d. */
+/* A Bison parser, made by GNU Bison 2.0. */
/* Skeleton parser for Yacc-like parsing with Bison,
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
@@ -78,11 +78,11 @@
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
-#line 137 "ast_expr2.y"
+#line 142 "ast_expr2.y"
typedef union YYSTYPE {
struct val *val;
} YYSTYPE;
-/* Line 1285 of yacc.c. */
+/* Line 1318 of yacc.c. */
#line 87 "ast_expr2.h"
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
Modified: team/murf/bug_6072/ast_expr2.y
URL: http://svn.digium.com/view/asterisk/team/murf/bug_6072/ast_expr2.y?rev=8263&r1=8262&r2=8263&view=diff
==============================================================================
--- team/murf/bug_6072/ast_expr2.y (original)
+++ team/murf/bug_6072/ast_expr2.y Thu Jan 19 08:46:12 2006
@@ -124,7 +124,12 @@
some useful info about the error. Not as easy as it looks, but it
is possible. */
#define ast_yyerror(x) ast_yyerror(x,&yyloc,parseio)
-
+#define DESTROY(x) { \
+if ((x)->type == AST_EXPR_numeric_string || (x)->type == AST_EXPR_string) \
+ free((x)->u.s); \
+ (x)->u.s = 0; \
+ free(x); \
+}
%}
%pure-parser
@@ -158,69 +163,91 @@
%%
start: expr { ((struct parse_io *)parseio)->val = (struct val *)calloc(sizeof(struct val),1);
- ((struct parse_io *)parseio)->val->type = $$->type;
- if( $$->type == AST_EXPR_integer )
- ((struct parse_io *)parseio)->val->u.i = $$->u.i;
+ ((struct parse_io *)parseio)->val->type = $1->type;
+ if( $1->type == AST_EXPR_integer )
+ ((struct parse_io *)parseio)->val->u.i = $1->u.i;
else
- ((struct parse_io *)parseio)->val->u.s = $$->u.s; }
+ ((struct parse_io *)parseio)->val->u.s = $1->u.s;
+ free($1);
+ }
;
expr: TOKEN { $$= $1;}
| TOK_LP expr TOK_RP { $$ = $2;
@$.first_column = @1.first_column; @$.last_column = @3.last_column;
- @$.first_line=0; @$.last_line=0;}
+ @$.first_line=0; @$.last_line=0;
+ DESTROY($1); DESTROY($3); }
| expr TOK_OR expr { $$ = op_or ($1, $3);
+ DESTROY($2);
@$.first_column = @1.first_column; @$.last_column = @3.last_column;
@$.first_line=0; @$.last_line=0;}
| expr TOK_AND expr { $$ = op_and ($1, $3);
+ DESTROY($2);
@$.first_column = @1.first_column; @$.last_column = @3.last_column;
@$.first_line=0; @$.last_line=0;}
| expr TOK_EQ expr { $$ = op_eq ($1, $3);
+ DESTROY($2);
@$.first_column = @1.first_column; @$.last_column = @3.last_column;
@$.first_line=0; @$.last_line=0;}
| expr TOK_GT expr { $$ = op_gt ($1, $3);
+ DESTROY($2);
@$.first_column = @1.first_column; @$.last_column = @3.last_column;
@$.first_line=0; @$.last_line=0;}
| expr TOK_LT expr { $$ = op_lt ($1, $3);
+ DESTROY($2);
@$.first_column = @1.first_column; @$.last_column = @3.last_column;
@$.first_line=0; @$.last_line=0;}
| expr TOK_GE expr { $$ = op_ge ($1, $3);
+ DESTROY($2);
@$.first_column = @1.first_column; @$.last_column = @3.last_column;
@$.first_line=0; @$.last_line=0;}
| expr TOK_LE expr { $$ = op_le ($1, $3);
+ DESTROY($2);
@$.first_column = @1.first_column; @$.last_column = @3.last_column;
@$.first_line=0; @$.last_line=0;}
| expr TOK_NE expr { $$ = op_ne ($1, $3);
+ DESTROY($2);
@$.first_column = @1.first_column; @$.last_column = @3.last_column;
@$.first_line=0; @$.last_line=0;}
| expr TOK_PLUS expr { $$ = op_plus ($1, $3);
+ DESTROY($2);
@$.first_column = @1.first_column; @$.last_column = @3.last_column;
@$.first_line=0; @$.last_line=0;}
| expr TOK_MINUS expr { $$ = op_minus ($1, $3);
+ DESTROY($2);
@$.first_column = @1.first_column; @$.last_column = @3.last_column;
@$.first_line=0; @$.last_line=0;}
| TOK_MINUS expr %prec TOK_COMPL { $$ = op_negate ($2);
+ DESTROY($1);
@$.first_column = @1.first_column; @$.last_column = @2.last_column;
@$.first_line=0; @$.last_line=0;}
| TOK_COMPL expr { $$ = op_compl ($2);
+ DESTROY($1);
@$.first_column = @1.first_column; @$.last_column = @2.last_column;
@$.first_line=0; @$.last_line=0;}
| expr TOK_MULT expr { $$ = op_times ($1, $3);
+ DESTROY($2);
@$.first_column = @1.first_column; @$.last_column = @3.last_column;
@$.first_line=0; @$.last_line=0;}
| expr TOK_DIV expr { $$ = op_div ($1, $3);
+ DESTROY($2);
@$.first_column = @1.first_column; @$.last_column = @3.last_column;
@$.first_line=0; @$.last_line=0;}
| expr TOK_MOD expr { $$ = op_rem ($1, $3);
+ DESTROY($2);
@$.first_column = @1.first_column; @$.last_column = @3.last_column;
@$.first_line=0; @$.last_line=0;}
| expr TOK_COLON expr { $$ = op_colon ($1, $3);
+ DESTROY($2);
@$.first_column = @1.first_column; @$.last_column = @3.last_column;
@$.first_line=0; @$.last_line=0;}
| expr TOK_EQTILDE expr { $$ = op_eqtilde ($1, $3);
+ DESTROY($2);
@$.first_column = @1.first_column; @$.last_column = @3.last_column;
@$.first_line=0; @$.last_line=0;}
| expr TOK_COND expr TOK_COLONCOLON expr { $$ = op_cond ($1, $3, $5);
+ DESTROY($2);
+ DESTROY($4);
@$.first_column = @1.first_column; @$.last_column = @3.last_column;
@$.first_line=0; @$.last_line=0;}
;
@@ -281,6 +308,7 @@
}
if (vp->type == AST_EXPR_string || vp->type == AST_EXPR_numeric_string)
free (vp->u.s);
+ free(vp);
}
Modified: team/murf/bug_6072/ast_expr2f.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug_6072/ast_expr2f.c?rev=8263&r1=8262&r2=8263&view=diff
==============================================================================
--- team/murf/bug_6072/ast_expr2f.c (original)
+++ team/murf/bug_6072/ast_expr2f.c Thu Jan 19 08:46:12 2006
@@ -347,266 +347,266 @@
},
{
- 3, 4, 4, 4, 4, 4, 4, 4, 4, 5,
- 6, 4, 4, 5, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 5, 7, 8, 9, 9, 10, 11, 9,
- 12, 13, 14, 15, 9, 16, 9, 17, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 19, 9,
- 20, 21, 22, 23, 9, 9, 9, 9, 9, 9,
-
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 4, 9, 4, 9, 9, 4, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 24, 9, 4, 4
- },
-
- {
- 3, 4, 4, 4, 4, 4, 4, 4, 4, 5,
- 6, 4, 4, 5, 4, 4, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 4, 4, 5, 7, 8, 9, 9, 10, 11, 9,
-
- 12, 13, 14, 15, 9, 16, 9, 17, 18, 18,
- 18, 18, 18, 18, 18, 18, 18, 18, 19, 9,
- 20, 21, 22, 23, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 4, 9, 4, 9, 9, 4, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 9, 9, 9, 9, 24, 9, 4, 4
- },
-
- {
- -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
-
- -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
- -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
- -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
- -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
- -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
- -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
- -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
- -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
- -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
- -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
-
- -3, -3, -3, -3, -3, -3, -3, -3, -3, -3,
- -3, -3, -3, -3, -3, -3, -3, -3
- },
-
- {
- 3, -4, -4, -4, -4, -4, -4, -4, -4, -4,
- -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
- -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
- -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
- -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
- -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
- -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
- -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
-
- -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
- -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
- -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
- -4, -4, -4, -4, -4, -4, -4, -4, -4, -4,
- -4, -4, -4, -4, -4, -4, -4, -4
- },
-
- {
- 3, -5, -5, -5, -5, -5, -5, -5, -5, -5,
- -5, -5, -5, -5, -5, -5, -5, -5, -5, -5,
- -5, -5, -5, -5, -5, -5, -5, -5, -5, -5,
- -5, -5, -5, -5, -5, -5, -5, -5, -5, -5,
- -5, -5, -5, -5, -5, -5, -5, -5, -5, -5,
-
- -5, -5, -5, -5, -5, -5, -5, -5, -5, -5,
- -5, -5, -5, -5, -5, -5, -5, -5, -5, -5,
- -5, -5, -5, -5, -5, -5, -5, -5, -5, -5,
- -5, -5, -5, -5, -5, -5, -5, -5, -5, -5,
- -5, -5, -5, -5, -5, -5, -5, -5, -5, -5,
- -5, -5, -5, -5, -5, -5, -5, -5, -5, -5,
- -5, -5, -5, -5, -5, -5, -5, -5, -5, -5,
- -5, -5, -5, -5, -5, -5, -5, -5
- },
-
- {
- 3, -6, -6, -6, -6, -6, -6, -6, -6, -6,
- -6, -6, -6, -6, -6, -6, -6, -6, -6, -6,
-
- -6, -6, -6, -6, -6, -6, -6, -6, -6, -6,
- -6, -6, -6, -6, -6, -6, -6, -6, -6, -6,
- -6, -6, -6, -6, -6, -6, -6, -6, -6, -6,
- -6, -6, -6, -6, -6, -6, -6, -6, -6, -6,
- -6, -6, -6, -6, -6, -6, -6, -6, -6, -6,
[... 1424 lines stripped ...]
More information about the asterisk-commits
mailing list