From 6190ae4430f2bdfb02d2ce8f4941cd9b4e65f5a0 Mon Sep 17 00:00:00 2001 From: Tilghman Lesher <tilghman@meg.abyt.es> Date: Wed, 11 Jul 2012 17:16:50 +0000 Subject: [PATCH] Allow the REALTIME() function to report errors back to the caller. Also, do more error checking on the arguments specified to the REALTIME() function and clarify the documentation. While I was editing the file, a few coding guidelines fixups, as well. Review: https://reviewboard.asterisk.org/r/2031/ ........ Merged revisions 369937 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 369938 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@369940 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- funcs/func_realtime.c | 61 ++-- main/ast_expr2.c | 706 +++++++++++++++++++----------------------- main/ast_expr2.h | 14 +- main/ast_expr2f.c | 32 +- res/ael/ael_lex.c | 40 ++- 5 files changed, 414 insertions(+), 439 deletions(-) diff --git a/funcs/func_realtime.c b/funcs/func_realtime.c index 341a47ed9e..bd4b37dfe0 100644 --- a/funcs/func_realtime.c +++ b/funcs/func_realtime.c @@ -2,10 +2,10 @@ * Asterisk -- An open source telephony toolkit. * * Copyright (C) 2005-2006, BJ Weschke. All rights reserved. - * + * * BJ Weschke <bweschke@btwtech.com> - * - * This code is released by the author with no restrictions on usage. + * + * This code is released by the author with no restrictions on usage. * * See http://www.asterisk.org for more information about * the Asterisk project. Please do not directly contact @@ -18,9 +18,9 @@ /*! \file * * \brief REALTIME dialplan function - * + * * \author BJ Weschke <bweschke@btwtech.com> - * + * * \ingroup functions */ @@ -49,7 +49,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") <syntax> <parameter name="family" required="true" /> <parameter name="fieldmatch" required="true" /> - <parameter name="value" /> + <parameter name="matchvalue" /> <parameter name="delim1|field"> <para>Use <replaceable>delim1</replaceable> with <replaceable>delim2</replaceable> on read and <replaceable>field</replaceable> without <replaceable>delim2</replaceable> on @@ -63,11 +63,11 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") </syntax> <description> <para>This function will read or write values from/to a RealTime repository. - REALTIME(....) will read names/values from the repository, and + REALTIME(....) will read names/values from the repository, and REALTIME(....)= will write a new value/field to the repository. On a read, this function returns a delimited text string. The name/value pairs are delimited by <replaceable>delim1</replaceable>, and the name and value are delimited - between each other with delim2. + between each other with delim2. If there is no match, NULL will be returned by the function. On a write, this function will always return NULL.</para> </description> @@ -108,7 +108,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") <syntax> <parameter name="family" required="true" /> <parameter name="fieldmatch" required="true" /> - <parameter name="value" /> + <parameter name="matchvalue" /> <parameter name="delim1" /> <parameter name="delim2" /> </syntax> @@ -130,13 +130,13 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") <syntax> <parameter name="family" required="true" /> <parameter name="fieldmatch" required="true" /> - <parameter name="value" required="true" /> + <parameter name="matchvalue" required="true" /> <parameter name="fieldname" required="true" /> </syntax> <description> <para>This function retrieves a single item, <replaceable>fieldname</replaceable> from the RT engine, where <replaceable>fieldmatch</replaceable> contains the value - <replaceable>value</replaceable>. When written to, the REALTIME_FIELD() function + <replaceable>matchvalue</replaceable>. When written to, the REALTIME_FIELD() function performs identically to the REALTIME() function.</para> </description> <see-also> @@ -153,12 +153,12 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") <syntax> <parameter name="family" required="true" /> <parameter name="fieldmatch" required="true" /> - <parameter name="value" required="true" /> + <parameter name="matchvalue" required="true" /> </syntax> <description> <para>This function retrieves a single record from the RT engine, where <replaceable>fieldmatch</replaceable> contains the value - <replaceable>value</replaceable> and formats the output suitably, such that + <replaceable>matchvalue</replaceable> and formats the output suitably, such that it can be assigned to the HASH() function. The HASH() function then provides a suitable method for retrieving each field value of the record.</para> </description> @@ -175,7 +175,7 @@ AST_THREADSTORAGE(buf1); AST_THREADSTORAGE(buf2); AST_THREADSTORAGE(buf3); -static int function_realtime_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) +static int function_realtime_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { struct ast_variable *var, *head; struct ast_str *out; @@ -190,7 +190,7 @@ static int function_realtime_read(struct ast_channel *chan, const char *cmd, cha ); if (ast_strlen_zero(data)) { - ast_log(LOG_WARNING, "Syntax: REALTIME(family,fieldmatch[,value[,delim1[,delim2]]]) - missing argument!\n"); + ast_log(LOG_WARNING, "Syntax: REALTIME(family,fieldmatch[,matchvalue[,delim1[,delim2]]]) - missing argument!\n"); return -1; } @@ -243,28 +243,35 @@ static int function_realtime_write(struct ast_channel *chan, const char *cmd, ch ); if (ast_strlen_zero(data)) { - ast_log(LOG_WARNING, "Syntax: %s(family,fieldmatch,value,newcol) - missing argument!\n", cmd); + ast_log(LOG_WARNING, "Syntax: %s(family,fieldmatch,matchvalue,updatecol) - missing argument!\n", cmd); return -1; } - if (chan) - ast_autoservice_start(chan); - AST_STANDARD_APP_ARGS(args, data); + if (ast_strlen_zero(args.fieldmatch) || ast_strlen_zero(args.field)) { + ast_log(LOG_WARNING, "Syntax: %s(family,fieldmatch,matchvalue,updatecol) - missing argument!\n", cmd); + return -1; + } + + if (chan) { + ast_autoservice_start(chan); + } + res = ast_update_realtime(args.family, args.fieldmatch, args.value, args.field, (char *)value, SENTINEL); if (res < 0) { ast_log(LOG_WARNING, "Failed to update. Check the debug log for possible data repository related entries.\n"); } - if (chan) + if (chan) { ast_autoservice_stop(chan); + } - return 0; + return res; } -static int realtimefield_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) +static int realtimefield_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { struct ast_variable *var, *head; struct ast_str *escapebuf = ast_str_thread_get(&buf1, 16); @@ -286,14 +293,14 @@ static int realtimefield_read(struct ast_channel *chan, const char *cmd, char *d } if (ast_strlen_zero(data)) { - ast_log(LOG_WARNING, "Syntax: %s(family,fieldmatch,value%s) - missing argument!\n", cmd, which == rtfield ? ",fieldname" : ""); + ast_log(LOG_WARNING, "Syntax: %s(family,fieldmatch,matchvalue%s) - missing argument!\n", cmd, which == rtfield ? ",fieldname" : ""); return -1; } AST_STANDARD_APP_ARGS(args, data); if ((which == rtfield && args.argc != 4) || (which == rthash && args.argc != 3)) { - ast_log(LOG_WARNING, "Syntax: %s(family,fieldmatch,value%s) - missing argument!\n", cmd, which == rtfield ? ",fieldname" : ""); + ast_log(LOG_WARNING, "Syntax: %s(family,fieldmatch,matchvalue%s) - missing argument!\n", cmd, which == rtfield ? ",fieldname" : ""); return -1; } @@ -366,7 +373,7 @@ static int function_realtime_store(struct ast_channel *chan, const char *cmd, ch AST_STANDARD_APP_ARGS(a, data); AST_STANDARD_APP_ARGS(v, valcopy); - res = ast_store_realtime(a.family, + res = ast_store_realtime(a.family, a.f[0], v.v[0], a.f[1], v.v[1], a.f[2], v.v[2], a.f[3], v.v[3], a.f[4], v.v[4], a.f[5], v.v[5], a.f[6], v.v[6], a.f[7], v.v[7], a.f[8], v.v[8], a.f[9], v.v[9], a.f[10], v.v[10], a.f[11], v.v[11], a.f[12], v.v[12], a.f[13], v.v[13], a.f[14], v.v[14], @@ -388,7 +395,7 @@ static int function_realtime_store(struct ast_channel *chan, const char *cmd, ch return 0; } -static int function_realtime_readdestroy(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) +static int function_realtime_readdestroy(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { struct ast_variable *var, *head; struct ast_str *out; @@ -403,7 +410,7 @@ static int function_realtime_readdestroy(struct ast_channel *chan, const char *c ); if (ast_strlen_zero(data)) { - ast_log(LOG_WARNING, "Syntax: REALTIME_DESTROY(family,fieldmatch[,value[,delim1[,delim2]]]) - missing argument!\n"); + ast_log(LOG_WARNING, "Syntax: REALTIME_DESTROY(family,fieldmatch[,matchvalue[,delim1[,delim2]]]) - missing argument!\n"); return -1; } diff --git a/main/ast_expr2.c b/main/ast_expr2.c index 0de96d0d0e..798e3d3ce5 100644 --- a/main/ast_expr2.c +++ b/main/ast_expr2.c @@ -1,8 +1,10 @@ -/* A Bison parser, made by GNU Bison 2.5. */ -/* Bison implementation for Yacc-like parsers in C +/* A Bison parser, made by GNU Bison 2.4.1. */ + +/* Skeleton implementation for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2011 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 @@ -44,7 +46,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.5" +#define YYBISON_VERSION "2.4.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -73,7 +75,7 @@ /* Copy the first part of user declarations. */ -/* Line 268 of yacc.c */ +/* Line 189 of yacc.c */ #line 1 "ast_expr2.y" /* Written by Pace Willisson (pace@blitz.com) @@ -412,8 +414,8 @@ int ast_yyerror(const char *,YYLTYPE *, struct parse_io *); #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);} -/* Line 268 of yacc.c */ -#line 417 "ast_expr2.c" +/* Line 189 of yacc.c */ +#line 419 "ast_expr2.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -472,7 +474,7 @@ int ast_yyerror(const char *,YYLTYPE *, struct parse_io *); typedef union YYSTYPE { -/* Line 293 of yacc.c */ +/* Line 214 of yacc.c */ #line 345 "ast_expr2.y" struct val *val; @@ -480,8 +482,8 @@ typedef union YYSTYPE -/* Line 293 of yacc.c */ -#line 485 "ast_expr2.c" +/* Line 214 of yacc.c */ +#line 487 "ast_expr2.c" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -504,14 +506,14 @@ typedef struct YYLTYPE /* Copy the second part of user declarations. */ -/* Line 343 of yacc.c */ +/* Line 264 of yacc.c */ #line 350 "ast_expr2.y" extern int ast_yylex __P((YYSTYPE *, YYLTYPE *, yyscan_t)); -/* Line 343 of yacc.c */ -#line 515 "ast_expr2.c" +/* Line 264 of yacc.c */ +#line 517 "ast_expr2.c" #ifdef short # undef short @@ -561,7 +563,7 @@ typedef short int yytype_int16; #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS +# if YYENABLE_NLS # if ENABLE_NLS # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) @@ -614,11 +616,11 @@ YYID (yyi) # define alloca _alloca # else # define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ -# ifndef EXIT_SUCCESS -# define EXIT_SUCCESS 0 +# ifndef _STDLIB_H +# define _STDLIB_H 1 # endif # endif # endif @@ -641,24 +643,24 @@ YYID (yyi) # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif -# if (defined __cplusplus && ! defined EXIT_SUCCESS \ +# if (defined __cplusplus && ! defined _STDLIB_H \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ -# ifndef EXIT_SUCCESS -# define EXIT_SUCCESS 0 +# ifndef _STDLIB_H +# define _STDLIB_H 1 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc -# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free -# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif @@ -689,7 +691,23 @@ union yyalloc ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \ + 2 * YYSTACK_GAP_MAXIMUM) -# define YYCOPY_NEEDED 1 +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of @@ -709,26 +727,6 @@ union yyalloc #endif -#if defined YYCOPY_NEEDED && YYCOPY_NEEDED -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (YYID (0)) -# endif -# endif -#endif /* !YYCOPY_NEEDED */ - /* YYFINAL -- State number of the termination state. */ #define YYFINAL 11 /* YYLAST -- Last index in YYTABLE. */ @@ -859,8 +857,8 @@ static const yytype_uint8 yyr2[] = 2, 2, 3, 3, 3, 3, 3, 5, 3 }; -/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. - Performed when YYTABLE doesn't specify something else to do. Zero +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const yytype_uint8 yydefact[] = { @@ -899,7 +897,8 @@ static const yytype_int8 yypgoto[] = /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which - number is the opposite. If YYTABLE_NINF, syntax error. */ + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -1 static const yytype_uint8 yytable[] = { @@ -921,12 +920,6 @@ static const yytype_uint8 yytable[] = 26, 27, 28, 23, 24, 25, 0, 26, 27, 28 }; -#define yypact_value_is_default(yystate) \ - ((yystate) == (-18)) - -#define yytable_value_is_error(yytable_value) \ - YYID (0) - static const yytype_int8 yycheck[] = { 1, 2, 3, 20, 21, 22, 0, 3, 23, 10, @@ -971,18 +964,9 @@ static const yytype_uint8 yystos[] = /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. However, - YYFAIL appears to be in use. Nevertheless, it is formally deprecated - in Bison 2.4.2's NEWS entry, where a plan to phase it out is - discussed. */ + Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab -#if defined YYFAIL - /* This is here to suppress warnings from the GCC cpp's - -Wunused-macros. Normally we don't worry about that warning, but - some users do, and we want to make it easy for users to remove - YYFAIL uses, which will produce warnings from Bison 2.5. */ -#endif #define YYRECOVERING() (!!yyerrstatus) @@ -992,6 +976,7 @@ do \ { \ yychar = (Token); \ yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK (1); \ goto yybackup; \ } \ @@ -1038,7 +1023,7 @@ while (YYID (0)) we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# if YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ @@ -1243,6 +1228,7 @@ int yydebug; # define YYMAXDEPTH 10000 #endif + #if YYERROR_VERBOSE @@ -1345,142 +1331,115 @@ yytnamerr (char *yyres, const char *yystr) } # endif -/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message - about the unexpected token YYTOKEN for the state stack whose top is - YYSSP. +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; - Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is - not large enough to hold the message. In that case, also set - *YYMSG_ALLOC to the required number of bytes. Return 2 if the - required number of bytes is too large to store. */ -static int -yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, - yytype_int16 *yyssp, int yytoken) -{ - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - /* Internationalized format string. */ - const char *yyformat = 0; - /* Arguments of yyformat. */ - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - /* Number of reported tokens (one for the "unexpected", one per - "expected"). */ - int yycount = 0; - - /* There are many possibilities here to consider: - - Assume YYFAIL is not used. It's too flawed to consider. See - <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html> - for details. YYERROR is fine as it does not invoke this - function. - - If this state is a consistent state with a default action, then - the only way this function was invoked is if the default action - is an error action. In that case, don't check for expected - tokens because there are none. - - The only way there can be no lookahead present (in yychar) is if - this state is a consistent state with a default action. Thus, - detecting the absence of a lookahead is sufficient to determine - that there is no unexpected or expected token to report. In that - case, just report a simple "syntax error". - - Don't assume there isn't a lookahead just because this state is a - consistent state with a default action. There might have been a - previous inconsistent state, consistent state with a non-default - action, or user semantic action that manipulated yychar. - - Of course, the expected token list depends on states to have - correct lookahead information, and it depends on the parser not - to perform extra reductions after fetching a lookahead from the - scanner and before detecting a syntax error. Thus, state merging - (from LALR or IELR) and default reductions corrupt the expected - token list. However, the list is correct for canonical LR with - one exception: it will still contain any token that will not be - accepted due to an error action in a later state. - */ - if (yytoken != YYEMPTY) + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else { - int yyn = yypact[*yyssp]; - yyarg[yycount++] = yytname[yytoken]; - if (!yypact_value_is_default (yyn)) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yyx; - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR - && !yytable_value_is_error (yytable[yyx + yyn])) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - } - } + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } - switch (yycount) - { -# define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); -# undef YYCASE_ - } + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; - yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; + if (yysize_overflow) + return YYSIZE_MAXIMUM; - if (*yymsg_alloc < yysize) - { - *yymsg_alloc = 2 * yysize; - if (! (yysize <= *yymsg_alloc - && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) - *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; - return 1; + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; } - - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - { - char *yyp = *yymsg; - int yyi = 0; - while ((*yyp = *yyformat) != '\0') - if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyformat += 2; - } - else - { - yyp++; - yyformat++; - } - } - return 0; } #endif /* YYERROR_VERBOSE */ + /*-----------------------------------------------. | Release the memory associated to this symbol. | @@ -1511,210 +1470,210 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp) { case 4: /* "TOK_COLONCOLON" */ -/* Line 1391 of yacc.c */ +/* Line 1000 of yacc.c */ #line 368 "ast_expr2.y" { free_value((yyvaluep->val)); }; -/* Line 1391 of yacc.c */ -#line 1520 "ast_expr2.c" +/* Line 1000 of yacc.c */ +#line 1479 "ast_expr2.c" break; case 5: /* "TOK_COND" */ -/* Line 1391 of yacc.c */ +/* Line 1000 of yacc.c */ #line 368 "ast_expr2.y" { free_value((yyvaluep->val)); }; -/* Line 1391 of yacc.c */ -#line 1529 "ast_expr2.c" +/* Line 1000 of yacc.c */ +#line 1488 "ast_expr2.c" break; case 6: /* "TOK_OR" */ -/* Line 1391 of yacc.c */ +/* Line 1000 of yacc.c */ #line 368 "ast_expr2.y" { free_value((yyvaluep->val)); }; -/* Line 1391 of yacc.c */ -#line 1538 "ast_expr2.c" +/* Line 1000 of yacc.c */ +#line 1497 "ast_expr2.c" break; case 7: /* "TOK_AND" */ -/* Line 1391 of yacc.c */ +/* Line 1000 of yacc.c */ #line 368 "ast_expr2.y" { free_value((yyvaluep->val)); }; -/* Line 1391 of yacc.c */ -#line 1547 "ast_expr2.c" +/* Line 1000 of yacc.c */ +#line 1506 "ast_expr2.c" break; case 8: /* "TOK_NE" */ -/* Line 1391 of yacc.c */ +/* Line 1000 of yacc.c */ #line 368 "ast_expr2.y" { free_value((yyvaluep->val)); }; -/* Line 1391 of yacc.c */ -#line 1556 "ast_expr2.c" +/* Line 1000 of yacc.c */ +#line 1515 "ast_expr2.c" break; case 9: /* "TOK_LE" */ -/* Line 1391 of yacc.c */ +/* Line 1000 of yacc.c */ #line 368 "ast_expr2.y" { free_value((yyvaluep->val)); }; -/* Line 1391 of yacc.c */ -#line 1565 "ast_expr2.c" +/* Line 1000 of yacc.c */ +#line 1524 "ast_expr2.c" break; case 10: /* "TOK_GE" */ -/* Line 1391 of yacc.c */ +/* Line 1000 of yacc.c */ #line 368 "ast_expr2.y" { free_value((yyvaluep->val)); }; -/* Line 1391 of yacc.c */ -#line 1574 "ast_expr2.c" +/* Line 1000 of yacc.c */ +#line 1533 "ast_expr2.c" break; case 11: /* "TOK_LT" */ -/* Line 1391 of yacc.c */ +/* Line 1000 of yacc.c */ #line 368 "ast_expr2.y" { free_value((yyvaluep->val)); }; -/* Line 1391 of yacc.c */ -#line 1583 "ast_expr2.c" +/* Line 1000 of yacc.c */ +#line 1542 "ast_expr2.c" break; case 12: /* "TOK_GT" */ -/* Line 1391 of yacc.c */ +/* Line 1000 of yacc.c */ #line 368 "ast_expr2.y" { free_value((yyvaluep->val)); }; -/* Line 1391 of yacc.c */ -#line 1592 "ast_expr2.c" +/* Line 1000 of yacc.c */ +#line 1551 "ast_expr2.c" break; case 13: /* "TOK_EQ" */ -/* Line 1391 of yacc.c */ +/* Line 1000 of yacc.c */ #line 368 "ast_expr2.y" { free_value((yyvaluep->val)); }; -/* Line 1391 of yacc.c */ -#line 1601 "ast_expr2.c" +/* Line 1000 of yacc.c */ +#line 1560 "ast_expr2.c" break; case 14: /* "TOK_MINUS" */ -/* Line 1391 of yacc.c */ +/* Line 1000 of yacc.c */ #line 368 "ast_expr2.y" { free_value((yyvaluep->val)); }; -/* Line 1391 of yacc.c */ -#line 1610 "ast_expr2.c" +/* Line 1000 of yacc.c */ +#line 1569 "ast_expr2.c" break; case 15: /* "TOK_PLUS" */ -/* Line 1391 of yacc.c */ +/* Line 1000 of yacc.c */ #line 368 "ast_expr2.y" { free_value((yyvaluep->val)); }; -/* Line 1391 of yacc.c */ -#line 1619 "ast_expr2.c" +/* Line 1000 of yacc.c */ +#line 1578 "ast_expr2.c" break; case 16: /* "TOK_MOD" */ -/* Line 1391 of yacc.c */ +/* Line 1000 of yacc.c */ #line 368 "ast_expr2.y" { free_value((yyvaluep->val)); }; -/* Line 1391 of yacc.c */ -#line 1628 "ast_expr2.c" +/* Line 1000 of yacc.c */ +#line 1587 "ast_expr2.c" break; case 17: /* "TOK_DIV" */ -/* Line 1391 of yacc.c */ +/* Line 1000 of yacc.c */ #line 368 "ast_expr2.y" { free_value((yyvaluep->val)); }; -/* Line 1391 of yacc.c */ -#line 1637 "ast_expr2.c" +/* Line 1000 of yacc.c */ +#line 1596 "ast_expr2.c" break; case 18: /* "TOK_MULT" */ -/* Line 1391 of yacc.c */ +/* Line 1000 of yacc.c */ #line 368 "ast_expr2.y" { free_value((yyvaluep->val)); }; -/* Line 1391 of yacc.c */ -#line 1646 "ast_expr2.c" +/* Line 1000 of yacc.c */ +#line 1605 "ast_expr2.c" break; case 19: /* "TOK_COMPL" */ -/* Line 1391 of yacc.c */ +/* Line 1000 of yacc.c */ #line 368 "ast_expr2.y" { free_value((yyvaluep->val)); }; -/* Line 1391 of yacc.c */ -#line 1655 "ast_expr2.c" +/* Line 1000 of yacc.c */ +#line 1614 "ast_expr2.c" break; case 20: /* "TOK_TILDETILDE" */ -/* Line 1391 of yacc.c */ +/* Line 1000 of yacc.c */ #line 368 "ast_expr2.y" { free_value((yyvaluep->val)); }; -/* Line 1391 of yacc.c */ -#line 1664 "ast_expr2.c" +/* Line 1000 of yacc.c */ +#line 1623 "ast_expr2.c" break; case 21: /* "TOK_EQTILDE" */ -/* Line 1391 of yacc.c */ +/* Line 1000 of yacc.c */ #line 368 "ast_expr2.y" { free_value((yyvaluep->val)); }; -/* Line 1391 of yacc.c */ -#line 1673 "ast_expr2.c" +/* Line 1000 of yacc.c */ +#line 1632 "ast_expr2.c" break; case 22: /* "TOK_COLON" */ -/* Line 1391 of yacc.c */ +/* Line 1000 of yacc.c */ #line 368 "ast_expr2.y" { free_value((yyvaluep->val)); }; -/* Line 1391 of yacc.c */ -#line 1682 "ast_expr2.c" +/* Line 1000 of yacc.c */ +#line 1641 "ast_expr2.c" break; case 23: /* "TOK_LP" */ -/* Line 1391 of yacc.c */ +/* Line 1000 of yacc.c */ #line 368 "ast_expr2.y" { free_value((yyvaluep->val)); }; -/* Line 1391 of yacc.c */ -#line 1691 "ast_expr2.c" +/* Line 1000 of yacc.c */ +#line 1650 "ast_expr2.c" break; case 24: /* "TOK_RP" */ -/* Line 1391 of yacc.c */ +/* Line 1000 of yacc.c */ #line 368 "ast_expr2.y" { free_value((yyvaluep->val)); }; -/* Line 1391 of yacc.c */ -#line 1700 "ast_expr2.c" +/* Line 1000 of yacc.c */ +#line 1659 "ast_expr2.c" break; case 25: /* "TOKEN" */ -/* Line 1391 of yacc.c */ +/* Line 1000 of yacc.c */ #line 368 "ast_expr2.y" { free_value((yyvaluep->val)); }; -/* Line 1391 of yacc.c */ -#line 1709 "ast_expr2.c" +/* Line 1000 of yacc.c */ +#line 1668 "ast_expr2.c" break; case 29: /* "expr" */ -/* Line 1391 of yacc.c */ +/* Line 1000 of yacc.c */ #line 368 "ast_expr2.y" { free_value((yyvaluep->val)); }; -/* Line 1391 of yacc.c */ -#line 1718 "ast_expr2.c" +/* Line 1000 of yacc.c */ +#line 1677 "ast_expr2.c" break; default: @@ -1722,7 +1681,6 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp) } } - /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus @@ -1739,9 +1697,12 @@ int yyparse (); #endif /* ! YYPARSE_PARAM */ -/*----------. -| yyparse. | -`----------*/ + + + +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ @@ -1805,7 +1766,7 @@ YYLTYPE yylloc; YYLTYPE *yylsp; /* The locations where the error started and ended. */ - YYLTYPE yyerror_range[3]; + YYLTYPE yyerror_range[2]; YYSIZE_T yystacksize; @@ -1852,7 +1813,7 @@ YYLTYPE yylloc; yyvsp = yyvs; yylsp = yyls; -#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +#if YYLTYPE_IS_TRIVIAL /* Initialize the default location before parsing starts. */ yylloc.first_line = yylloc.last_line = 1; yylloc.first_column = yylloc.last_column = 1; @@ -1954,7 +1915,7 @@ yybackup: /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; - if (yypact_value_is_default (yyn)) + if (yyn == YYPACT_NINF) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ @@ -1985,8 +1946,8 @@ yybackup: yyn = yytable[yyn]; if (yyn <= 0) { - if (yytable_value_is_error (yyn)) - goto yyerrlab; + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; yyn = -yyn; goto yyreduce; } @@ -2042,7 +2003,7 @@ yyreduce: { case 2: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 374 "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; @@ -2051,287 +2012,276 @@ yyreduce: else ((struct parse_io *)parseio)->val->u.s = (yyvsp[(1) - (1)].val)->u.s; free((yyvsp[(1) - (1)].val)); - } + ;} break; case 3: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 382 "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(""); - } + ;} break; case 4: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 389 "ast_expr2.y" - { (yyval.arglist) = alloc_expr_node(AST_EXPR_NODE_VAL); (yyval.arglist)->val = (yyvsp[(1) - (1)].val);} + { (yyval.arglist) = alloc_expr_node(AST_EXPR_NODE_VAL); (yyval.arglist)->val = (yyvsp[(1) - (1)].val);;} break; case 5: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 390 "ast_expr2.y" {struct expr_node *x = alloc_expr_node(AST_EXPR_NODE_VAL); struct expr_node *t; DESTROY((yyvsp[(2) - (3)].val)); for (t=(yyvsp[(1) - (3)].arglist);t->right;t=t->right) ; - (yyval.arglist) = (yyvsp[(1) - (3)].arglist); t->right = x; x->val = (yyvsp[(3) - (3)].val);} + (yyval.arglist) = (yyvsp[(1) - (3)].arglist); t->right = x; x->val = (yyvsp[(3) - (3)].val);;} break; case 6: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 396 "ast_expr2.y" {struct expr_node *x = alloc_expr_node(AST_EXPR_NODE_VAL); struct expr_node *t; /* NULL args should OK */ DESTROY((yyvsp[(2) - (2)].val)); for (t=(yyvsp[(1) - (2)].arglist);t->right;t=t->right) ; - (yyval.arglist) = (yyvsp[(1) - (2)].arglist); t->right = x; x->val = make_str("");} + (yyval.arglist) = (yyvsp[(1) - (2)].arglist); t->right = x; x->val = make_str("");;} break; case 7: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 405 "ast_expr2.y" { (yyval.val) = op_func((yyvsp[(1) - (4)].val),(yyvsp[(3) - (4)].arglist), ((struct parse_io *)parseio)->chan); DESTROY((yyvsp[(2) - (4)].val)); DESTROY((yyvsp[(4) - (4)].val)); DESTROY((yyvsp[(1) - (4)].val)); destroy_arglist((yyvsp[(3) - (4)].arglist)); - } + ;} break; case 8: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 411 "ast_expr2.y" - {(yyval.val) = (yyvsp[(1) - (1)].val);} + {(yyval.val) = (yyvsp[(1) - (1)].val);;} break; case 9: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 412 "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; - DESTROY((yyvsp[(1) - (3)].val)); DESTROY((yyvsp[(3) - (3)].val)); } + DESTROY((yyvsp[(1) - (3)].val)); DESTROY((yyvsp[(3) - (3)].val)); ;} break; case 10: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 416 "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; - (yyloc).first_line=0; (yyloc).last_line=0;} + (yyloc).first_line=0; (yyloc).last_line=0;;} break; case 11: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 420 "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; - (yyloc).first_line=0; (yyloc).last_line=0;} + (yyloc).first_line=0; (yyloc).last_line=0;;} break; case 12: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 424 "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; - (yyloc).first_line=0; (yyloc).last_line=0;} + (yyloc).first_line=0; (yyloc).last_line=0;;} break; case 13: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 428 "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; - (yyloc).first_line=0; (yyloc).last_line=0;} + (yyloc).first_line=0; (yyloc).last_line=0;;} break; case 14: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 432 "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; - (yyloc).first_line=0; (yyloc).last_line=0;} + (yyloc).first_line=0; (yyloc).last_line=0;;} break; case 15: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 436 "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; - (yyloc).first_line=0; (yyloc).last_line=0;} + (yyloc).first_line=0; (yyloc).last_line=0;;} break; case 16: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 440 "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; - (yyloc).first_line=0; (yyloc).last_line=0;} + (yyloc).first_line=0; (yyloc).last_line=0;;} break; case 17: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 444 "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; - (yyloc).first_line=0; (yyloc).last_line=0;} + (yyloc).first_line=0; (yyloc).last_line=0;;} break; case 18: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 448 "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; - (yyloc).first_line=0; (yyloc).last_line=0;} + (yyloc).first_line=0; (yyloc).last_line=0;;} break; case 19: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 452 "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; - (yyloc).first_line=0; (yyloc).last_line=0;} + (yyloc).first_line=0; (yyloc).last_line=0;;} break; case 20: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 456 "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; - (yyloc).first_line=0; (yyloc).last_line=0;} + (yyloc).first_line=0; (yyloc).last_line=0;;} break; case 21: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 460 "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; - (yyloc).first_line=0; (yyloc).last_line=0;} + (yyloc).first_line=0; (yyloc).last_line=0;;} break; case 22: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 464 "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; - (yyloc).first_line=0; (yyloc).last_line=0;} + (yyloc).first_line=0; (yyloc).last_line=0;;} break; case 23: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 468 "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; - (yyloc).first_line=0; (yyloc).last_line=0;} + (yyloc).first_line=0; (yyloc).last_line=0;;} break; case 24: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 472 "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; - (yyloc).first_line=0; (yyloc).last_line=0;} + (yyloc).first_line=0; (yyloc).last_line=0;;} break; case 25: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 476 "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; - (yyloc).first_line=0; (yyloc).last_line=0;} + (yyloc).first_line=0; (yyloc).last_line=0;;} break; case 26: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 480 "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; - (yyloc).first_line=0; (yyloc).last_line=0;} + (yyloc).first_line=0; (yyloc).last_line=0;;} break; case 27: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 484 "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)); (yyloc).first_column = (yylsp[(1) - (5)]).first_column; (yyloc).last_column = (yylsp[(3) - (5)]).last_column; - (yyloc).first_line=0; (yyloc).last_line=0;} + (yyloc).first_line=0; (yyloc).last_line=0;;} break; case 28: -/* Line 1806 of yacc.c */ +/* Line 1455 of yacc.c */ #line 489 "ast_expr2.y" { (yyval.val) = op_tildetilde ((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; - (yyloc).first_line=0; (yyloc).last_line=0;} + (yyloc).first_line=0; (yyloc).last_line=0;;} break; -/* Line 1806 of yacc.c */ -#line 2322 "ast_expr2.c" +/* Line 1455 of yacc.c */ +#line 2283 "ast_expr2.c" default: break; } - /* User semantic actions sometimes alter yychar, and that requires - that yytoken be updated with the new translation. We take the - approach of translating immediately before every use of yytoken. - One alternative is translating here after every semantic action, - but that translation would be missed if the semantic action invokes - YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or - if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an - incorrect destructor might then be invoked immediately. In the - case of YYERROR or YYBACKUP, subsequent parser actions might lead - to an incorrect destructor call or verbose syntax error message - before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); @@ -2360,10 +2310,6 @@ yyreduce: | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); - /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { @@ -2371,40 +2317,41 @@ yyerrlab: #if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); #else -# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ - yyssp, yytoken) { - char const *yymsgp = YY_("syntax error"); - int yysyntax_error_status; - yysyntax_error_status = YYSYNTAX_ERROR; - if (yysyntax_error_status == 0) - yymsgp = yymsg; - else if (yysyntax_error_status == 1) - { - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); - if (!yymsg) - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - yysyntax_error_status = 2; - } - else - { - yysyntax_error_status = YYSYNTAX_ERROR; - yymsgp = yymsg; - } - } - yyerror (yymsgp); - if (yysyntax_error_status == 2) - goto yyexhaustedlab; + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yymsg); + } + else + { + yyerror (YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } } -# undef YYSYNTAX_ERROR #endif } - yyerror_range[1] = yylloc; + yyerror_range[0] = yylloc; if (yyerrstatus == 3) { @@ -2441,7 +2388,7 @@ yyerrorlab: if (/*CONSTCOND*/ 0) goto yyerrorlab; - yyerror_range[1] = yylsp[1-yylen]; + yyerror_range[0] = yylsp[1-yylen]; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); @@ -2460,7 +2407,7 @@ yyerrlab1: for (;;) { yyn = yypact[yystate]; - if (!yypact_value_is_default (yyn)) + if (yyn != YYPACT_NINF) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) @@ -2475,7 +2422,7 @@ yyerrlab1: if (yyssp == yyss) YYABORT; - yyerror_range[1] = *yylsp; + yyerror_range[0] = *yylsp; yydestruct ("Error: popping", yystos[yystate], yyvsp, yylsp); YYPOPSTACK (1); @@ -2485,10 +2432,10 @@ yyerrlab1: *++yyvsp = yylval; - yyerror_range[2] = yylloc; + yyerror_range[1] = yylloc; /* Using YYLLOC is tempting, but would change the location of the lookahead. YYLOC is available though. */ - YYLLOC_DEFAULT (yyloc, yyerror_range, 2); + YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2); *++yylsp = yyloc; /* Shift the error token. */ @@ -2524,13 +2471,8 @@ yyexhaustedlab: yyreturn: if (yychar != YYEMPTY) - { - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = YYTRANSLATE (yychar); - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval, &yylloc); - } + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, &yylloc); /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); @@ -2555,7 +2497,7 @@ yyreturn: -/* Line 2067 of yacc.c */ +/* Line 1675 of yacc.c */ #line 495 "ast_expr2.y" diff --git a/main/ast_expr2.h b/main/ast_expr2.h index ddbab07dc1..1fefe11f7e 100644 --- a/main/ast_expr2.h +++ b/main/ast_expr2.h @@ -1,8 +1,10 @@ -/* A Bison parser, made by GNU Bison 2.5. */ -/* Bison interface for Yacc-like parsers in C +/* A Bison parser, made by GNU Bison 2.4.1. */ + +/* Skeleton interface for Bison's Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2011 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 @@ -69,7 +71,7 @@ typedef union YYSTYPE { -/* Line 2068 of yacc.c */ +/* Line 1676 of yacc.c */ #line 345 "ast_expr2.y" struct val *val; @@ -77,8 +79,8 @@ typedef union YYSTYPE -/* Line 2068 of yacc.c */ -#line 82 "ast_expr2.h" +/* Line 1676 of yacc.c */ +#line 84 "ast_expr2.h" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ diff --git a/main/ast_expr2f.c b/main/ast_expr2f.c index 675f06b56f..622f0334cc 100644 --- a/main/ast_expr2f.c +++ b/main/ast_expr2f.c @@ -56,7 +56,6 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -87,6 +86,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#endif /* ! C99 */ + #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -160,7 +161,15 @@ typedef void* yyscan_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else #define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -600,7 +609,7 @@ int ast_yyget_column(yyscan_t yyscanner); static int curlycount = 0; static char *expr2_token_subst(const char *mess); -#line 602 "ast_expr2f.c" +#line 611 "ast_expr2f.c" #define INITIAL 0 #define var 1 @@ -697,10 +706,6 @@ int ast_yyget_lineno (yyscan_t yyscanner ); void ast_yyset_lineno (int line_number ,yyscan_t yyscanner ); -int ast_yyget_column (yyscan_t yyscanner ); - -void ast_yyset_column (int column_no ,yyscan_t yyscanner ); - YYSTYPE * ast_yyget_lval (yyscan_t yyscanner ); void ast_yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); @@ -743,7 +748,12 @@ static int input (yyscan_t yyscanner ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else #define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -762,7 +772,7 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - unsigned n; \ + size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -850,7 +860,7 @@ YY_DECL #line 130 "ast_expr2.fl" -#line 852 "ast_expr2f.c" +#line 862 "ast_expr2f.c" yylval = yylval_param; @@ -1196,7 +1206,7 @@ YY_RULE_SETUP #line 238 "ast_expr2.fl" ECHO; YY_BREAK -#line 1198 "ast_expr2f.c" +#line 1208 "ast_expr2f.c" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(var): yyterminate(); @@ -1970,8 +1980,8 @@ YY_BUFFER_STATE ast_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner) /** 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 yybytes the byte buffer to scan + * @param _yybytes_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. */ diff --git a/res/ael/ael_lex.c b/res/ael/ael_lex.c index 7fba129b7c..e255fab70c 100644 --- a/res/ael/ael_lex.c +++ b/res/ael/ael_lex.c @@ -56,7 +56,6 @@ typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -87,6 +86,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#endif /* ! C99 */ + #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -160,7 +161,15 @@ typedef void* yyscan_t; /* Size of default input buffer. */ #ifndef YY_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k. + * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case. + * Ditto for the __ia64__ case accordingly. + */ +#define YY_BUF_SIZE 32768 +#else #define YY_BUF_SIZE 16384 +#endif /* __ia64__ */ #endif /* The state buf must be large enough to hold one state per character in the main buffer. @@ -952,7 +961,7 @@ static void pbcwhere(const char *text, int *line, int *col ) #define STORE_POS #define STORE_LOC #endif -#line 954 "ael_lex.c" +#line 963 "ael_lex.c" #define INITIAL 0 #define paren 1 @@ -1054,10 +1063,6 @@ int ael_yyget_lineno (yyscan_t yyscanner ); void ael_yyset_lineno (int line_number ,yyscan_t yyscanner ); -int ael_yyget_column (yyscan_t yyscanner ); - -void ael_yyset_column (int column_no ,yyscan_t yyscanner ); - YYSTYPE * ael_yyget_lval (yyscan_t yyscanner ); void ael_yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); @@ -1100,7 +1105,12 @@ static int input (yyscan_t yyscanner ); /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE +#ifdef __ia64__ +/* On IA-64, the buffer size is 16k, not 8k */ +#define YY_READ_BUF_SIZE 16384 +#else #define YY_READ_BUF_SIZE 8192 +#endif /* __ia64__ */ #endif /* Copy whatever the last rule matched to the standard output. */ @@ -1119,7 +1129,7 @@ static int input (yyscan_t yyscanner ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - unsigned n; \ + size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -1207,7 +1217,7 @@ YY_DECL #line 217 "ael.flex" -#line 1209 "ael_lex.c" +#line 1219 "ael_lex.c" yylval = yylval_param; @@ -2041,7 +2051,7 @@ YY_RULE_SETUP #line 656 "ael.flex" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 2043 "ael_lex.c" +#line 2053 "ael_lex.c" case YY_END_OF_BUFFER: { @@ -2812,8 +2822,8 @@ YY_BUFFER_STATE ael_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner) /** Setup the input buffer state to scan the given bytes. The next call to ael_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 yybytes the byte buffer to scan + * @param _yybytes_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. */ @@ -3368,7 +3378,9 @@ struct pval *ael2_parse(char *filename, int *errors) if (my_file) free(my_file); my_file = strdup(filename); - stat(filename, &stats); + if (stat(filename, &stats)) { + ast_log(LOG_WARNING, "failed to populate stats from file '%s'\n", filename); + } buffer = (char*)malloc(stats.st_size+2); if (fread(buffer, 1, stats.st_size, fin) != stats.st_size) { ast_log(LOG_ERROR, "fread() failed: %s\n", strerror(errno)); @@ -3438,7 +3450,9 @@ static void setup_filestack(char *fnamebuf2, int fnamebuf_siz, glob_t *globbuf, } else { char *buffer; struct stat stats; - stat(fnamebuf2, &stats); + if (stat(fnamebuf2, &stats)) { + ast_log(LOG_WARNING, "Failed to populate stats from file '%s'\n", fnamebuf2); + } buffer = (char*)malloc(stats.st_size+1); if (fread(buffer, 1, stats.st_size, in1) != stats.st_size) { ast_log(LOG_ERROR, "fread() failed: %s\n", strerror(errno)); -- GitLab