diff options
Diffstat (limited to 'command.c')
-rw-r--r-- | command.c | 564 |
1 files changed, 254 insertions, 310 deletions
@@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.5. */ +/* A Bison parser, made by GNU Bison 2.6.2. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2012 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 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.5" +#define YYBISON_VERSION "2.6.2" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -58,8 +58,6 @@ /* Pull parsers. */ #define YYPULL 1 -/* Using locations. */ -#define YYLSP_NEEDED 0 /* Substitute the variable and function names. */ #define yyparse zzparse @@ -70,10 +68,8 @@ #define yydebug zzdebug #define yynerrs zznerrs - /* Copy the first part of user declarations. */ - -/* Line 268 of yacc.c */ +/* Line 336 of yacc.c */ #line 26 "command.y" #include "awk.h" @@ -89,20 +85,20 @@ static void yyerror(const char *mesg, ...); static int find_command(const char *token, size_t toklen); -static int want_nodeval = FALSE; +static bool want_nodeval = false; static int cmd_idx = -1; /* index of current command in cmd table */ static int repeat_idx = -1; /* index of last repeatable command in command table */ static CMDARG *arg_list = NULL; /* list of arguments */ static long errcount = 0; static char *lexptr_begin = NULL; -static int in_commands = FALSE; +static bool in_commands = false; static int num_dim; -static int in_eval = FALSE; +static bool in_eval = false; static const char start_EVAL[] = "function @eval(){"; static const char end_EVAL[] = "}"; -static CMDARG *append_statement(CMDARG *alist, char *stmt); +static CMDARG *append_statement(CMDARG *stmt_list, char *stmt); static char *next_word(char *p, int len, char **endp); static NODE *concat_args(CMDARG *a, int count); @@ -141,14 +137,16 @@ static void append_cmdarg(CMDARG *arg); static int find_argument(CMDARG *arg); #define YYSTYPE CMDARG * +/* Line 336 of yacc.c */ +#line 142 "command.c" -/* Line 268 of yacc.c */ -#line 147 "command.c" - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif +# ifndef YY_NULL +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULL nullptr +# else +# define YY_NULL 0 +# endif +# endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE @@ -158,11 +156,17 @@ static int find_argument(CMDARG *arg); # define YYERROR_VERBOSE 0 #endif -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 +/* In a future release of Bison, this section will be replaced + by #include "". */ +#ifndef ZZ_ +# define ZZ_ +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int zzdebug; #endif - /* Tokens. */ #ifndef YYTOKENTYPE @@ -268,7 +272,6 @@ static int find_argument(CMDARG *arg); - #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 @@ -276,12 +279,28 @@ typedef int YYSTYPE; # define YYSTYPE_IS_DECLARED 1 #endif +extern YYSTYPE zzlval; -/* Copy the second part of user declarations. */ +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int zzparse (void *YYPARSE_PARAM); +#else +int zzparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int zzparse (void); +#else +int zzparse (); +#endif +#endif /* ! YYPARSE_PARAM */ +#endif /* !ZZ_ */ -/* Line 343 of yacc.c */ -#line 285 "command.c" +/* Copy the second part of user declarations. */ + +/* Line 353 of yacc.c */ +#line 304 "command.c" #ifdef short # undef short @@ -386,6 +405,7 @@ YYID (yyi) # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ + /* Use EXIT_SUCCESS as a witness for stdlib.h. */ # ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 # endif @@ -475,20 +495,20 @@ union yyalloc #endif #if defined YYCOPY_NEEDED && YYCOPY_NEEDED -/* Copy COUNT objects from FROM to TO. The source and destination do +/* Copy COUNT objects from SRC to DST. 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))) +# define YYCOPY(Dst, Src, Count) \ + __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) # else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ +# define YYCOPY(Dst, Src, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (Dst)[yyi] = (Src)[yyi]; \ + } \ while (YYID (0)) # endif # endif @@ -640,7 +660,7 @@ static const yytype_uint16 yyrline[] = }; #endif -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +#if YYDEBUG || YYERROR_VERBOSE || 0 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = @@ -664,7 +684,7 @@ static const char *const yytname[] = "printf_args", "list_args", "integer_range", "opt_integer_list", "integer_list", "exp_list", "subscript", "subscript_list", "variable", "node", "opt_plus_integer", "opt_integer", "plus_integer", "integer", - "nls", 0 + "nls", YY_NULL }; #endif @@ -916,17 +936,18 @@ static const yytype_uint8 yystos[] = #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (1); \ - goto yybackup; \ - } \ - else \ - { \ +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ yyerror (YY_("syntax error: cannot back up")); \ YYERROR; \ } \ @@ -936,32 +957,33 @@ while (YYID (0)) #define YYTERROR 1 #define YYERRCODE 256 - /* 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) \ - do \ - if (YYID (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; \ - } \ +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (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 (YYID (0)) #endif +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) + + /* This macro is provided for backward compatibility. */ @@ -1020,6 +1042,8 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep) YYSTYPE const * const yyvaluep; #endif { + FILE *yyo = yyoutput; + YYUSE (yyo); if (!yyvaluep) return; # ifdef YYPRINT @@ -1266,12 +1290,12 @@ static int yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yytype_int16 *yyssp, int yytoken) { - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); + YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]); YYSIZE_T yysize = yysize0; YYSIZE_T yysize1; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; /* Internationalized format string. */ - const char *yyformat = 0; + const char *yyformat = YY_NULL; /* Arguments of yyformat. */ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; /* Number of reported tokens (one for the "unexpected", one per @@ -1331,7 +1355,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, break; } yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]); if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; @@ -1422,20 +1446,6 @@ yydestruct (yymsg, yytype, yyvaluep) } -/* Prevent warnings from -Wmissing-prototypes. */ -#ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus -int yyparse (void *YYPARSE_PARAM); -#else -int yyparse (); -#endif -#else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus -int yyparse (void); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ /* The lookahead symbol. */ @@ -1480,7 +1490,7 @@ yyparse () `yyss': related to states. `yyvs': related to semantic values. - Refer to the stacks thru separate pointers, to allow yyoverflow + Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ @@ -1534,7 +1544,6 @@ yyparse () The wasted elements are never initialized. */ yyssp = yyss; yyvsp = yyvs; - goto yysetstate; /*------------------------------------------------------------. @@ -1712,12 +1721,11 @@ yyreduce: switch (yyn) { case 3: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 109 "command.y" { cmd_idx = -1; - want_nodeval = FALSE; + want_nodeval = false; if (lexptr_begin != NULL) { if (input_from_tty && lexptr_begin[0] != '\0') add_history(lexptr_begin); @@ -1732,13 +1740,12 @@ yyreduce: break; case 5: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 128 "command.y" { if (errcount == 0 && cmd_idx >= 0) { Func_cmd cmdfunc; - int terminate = FALSE; + bool terminate = false; CMDARG *args; int ctype = 0; @@ -1772,7 +1779,7 @@ yyreduce: if (in_commands) cmdfunc = do_commands; cmd_idx = -1; - want_nodeval = FALSE; + want_nodeval = false; args = arg_list; arg_list = NULL; @@ -1787,8 +1794,7 @@ yyreduce: break; case 6: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 178 "command.y" { yyerrok; @@ -1796,15 +1802,13 @@ yyreduce: break; case 22: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 212 "command.y" - { want_nodeval = TRUE; } + { want_nodeval = true; } break; case 23: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 217 "command.y" { if (errcount == 0) { @@ -1818,14 +1822,13 @@ yyreduce: rl_inhibit_completion = 1; } cmd_idx = -1; - in_eval = TRUE; + in_eval = true; } } break; case 24: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 236 "command.y" { (yyval) = append_statement(arg_list, (char *) start_EVAL); @@ -1837,15 +1840,13 @@ yyreduce: break; case 25: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 243 "command.y" { (yyval) = append_statement((yyvsp[(1) - (2)]), lexptr_begin); } break; case 26: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 244 "command.y" { (yyval) = (yyvsp[(3) - (4)]); @@ -1853,8 +1854,7 @@ yyreduce: break; case 27: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 251 "command.y" { arg_list = append_statement((yyvsp[(2) - (3)]), (char *) end_EVAL); @@ -1869,13 +1869,12 @@ yyreduce: rl_inhibit_completion = 0; } cmd_idx = find_command("eval", 4); - in_eval = FALSE; + in_eval = false; } break; case 28: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 267 "command.y" { NODE *n; @@ -1890,8 +1889,7 @@ yyreduce: break; case 34: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 286 "command.y" { if (cmdtab[cmd_idx].class == D_FRAME @@ -1901,8 +1899,7 @@ yyreduce: break; case 35: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 292 "command.y" { int idx = find_argument((yyvsp[(2) - (2)])); @@ -1918,50 +1915,43 @@ yyreduce: break; case 38: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 305 "command.y" - { want_nodeval = TRUE; } + { want_nodeval = true; } break; case 40: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 306 "command.y" - { want_nodeval = TRUE; } + { want_nodeval = true; } break; case 46: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 311 "command.y" - { want_nodeval = TRUE; } + { want_nodeval = true; } break; case 49: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 313 "command.y" - { want_nodeval = TRUE; } + { want_nodeval = true; } break; case 51: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 314 "command.y" - { want_nodeval = TRUE; } + { want_nodeval = true; } break; case 53: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 315 "command.y" - { want_nodeval = TRUE; } + { want_nodeval = true; } break; case 57: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 319 "command.y" { if (in_cmd_src((yyvsp[(2) - (2)])->a_string)) @@ -1970,8 +1960,7 @@ yyreduce: break; case 58: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 324 "command.y" { if (! input_from_tty) @@ -1980,8 +1969,7 @@ yyreduce: break; case 59: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 329 "command.y" { int type = 0; @@ -1994,12 +1982,12 @@ yyreduce: ; else if (in_commands) yyerror(_("Can't use command `commands' for breakpoint/watchpoint commands")); - else if ((yyvsp[(2) - (2)]) == NULL && ! (type = has_break_or_watch_point(&num, TRUE))) + else if ((yyvsp[(2) - (2)]) == NULL && ! (type = has_break_or_watch_point(&num, true))) yyerror(_("no breakpoint/watchpoint has been set yet")); - else if ((yyvsp[(2) - (2)]) != NULL && ! (type = has_break_or_watch_point(&num, FALSE))) + else if ((yyvsp[(2) - (2)]) != NULL && ! (type = has_break_or_watch_point(&num, false))) yyerror(_("invalid breakpoint/watchpoint number")); if (type) { - in_commands = TRUE; + in_commands = true; if (input_from_tty) { dbg_prompt = commands_prompt; fprintf(out_fp, _("Type commands for when %s %d is hit, one per line.\n"), @@ -2011,8 +1999,7 @@ yyreduce: break; case 60: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 355 "command.y" { if (! in_commands) @@ -2020,14 +2007,13 @@ yyreduce: else { if (input_from_tty) dbg_prompt = dgawk_prompt; - in_commands = FALSE; + in_commands = false; } } break; case 61: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 365 "command.y" { if (! in_commands) @@ -2036,8 +2022,7 @@ yyreduce: break; case 62: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 370 "command.y" { int idx = find_argument((yyvsp[(2) - (2)])); @@ -2053,28 +2038,25 @@ yyreduce: break; case 63: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 381 "command.y" - { want_nodeval = TRUE; } + { want_nodeval = true; } break; case 64: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 382 "command.y" { int type; int num = (yyvsp[(2) - (4)])->a_int; - type = has_break_or_watch_point(&num, FALSE); + type = has_break_or_watch_point(&num, false); if (! type) yyerror(_("condition: invalid breakpoint/watchpoint number")); } break; case 65: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 390 "command.y" { if (in_commands) { @@ -2089,8 +2071,7 @@ yyreduce: break; case 66: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 404 "command.y" { if ((yyvsp[(1) - (1)]) != NULL) { @@ -2104,43 +2085,37 @@ yyreduce: break; case 68: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 418 "command.y" { (yyval) = NULL; } break; case 69: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 423 "command.y" { (yyval) = NULL; } break; case 74: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 432 "command.y" { (yyval) = NULL; } break; case 75: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 437 "command.y" { (yyval) = NULL; } break; case 77: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 440 "command.y" { (yyval) = NULL; } break; case 78: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 445 "command.y" { NODE *n; @@ -2151,15 +2126,13 @@ yyreduce: break; case 79: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 455 "command.y" { (yyval) = NULL; } break; case 80: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 457 "command.y" { if (find_option((yyvsp[(1) - (1)])->a_string) < 0) @@ -2168,8 +2141,7 @@ yyreduce: break; case 81: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 462 "command.y" { if (find_option((yyvsp[(1) - (3)])->a_string) < 0) @@ -2178,8 +2150,7 @@ yyreduce: break; case 82: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 470 "command.y" { NODE *n; @@ -2196,57 +2167,49 @@ yyreduce: break; case 83: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 486 "command.y" { (yyval) = NULL; } break; case 88: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 495 "command.y" { (yyval) = NULL; } break; case 89: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 496 "command.y" - { want_nodeval = TRUE; } + { want_nodeval = true; } break; case 92: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 498 "command.y" - { want_nodeval = TRUE; } + { want_nodeval = true; } break; case 95: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 504 "command.y" { (yyval) = NULL; } break; case 97: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 510 "command.y" { (yyval) = NULL; } break; case 99: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 516 "command.y" { (yyval) = NULL; } break; case 104: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 528 "command.y" { int idx = find_argument((yyvsp[(1) - (2)])); @@ -2262,8 +2225,7 @@ yyreduce: break; case 106: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 544 "command.y" { (yyvsp[(2) - (2)])->type = D_array; /* dump all items */ @@ -2272,8 +2234,7 @@ yyreduce: break; case 107: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 549 "command.y" { (yyvsp[(2) - (3)])->type = D_array; @@ -2282,22 +2243,19 @@ yyreduce: break; case 117: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 575 "command.y" { (yyval) = NULL; } break; case 118: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 577 "command.y" { (yyval) = NULL; } break; case 119: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 579 "command.y" { CMDARG *a; @@ -2308,8 +2266,7 @@ yyreduce: break; case 126: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 595 "command.y" { if ((yyvsp[(1) - (3)])->a_int > (yyvsp[(3) - (3)])->a_int) @@ -2322,29 +2279,25 @@ yyreduce: break; case 127: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 607 "command.y" { (yyval) = NULL; } break; case 134: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 621 "command.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 135: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 623 "command.y" { (yyval) = (yyvsp[(1) - (3)]); } break; case 137: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 629 "command.y" { CMDARG *a; @@ -2363,22 +2316,19 @@ yyreduce: break; case 139: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 648 "command.y" { (yyval) = (yyvsp[(1) - (1)]); num_dim = 1; } break; case 140: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 650 "command.y" { (yyval) = (yyvsp[(1) - (2)]); num_dim++; } break; case 142: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 656 "command.y" { NODE *n = (yyvsp[(2) - (2)])->a_node; @@ -2391,8 +2341,7 @@ yyreduce: break; case 143: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 665 "command.y" { /* a_string is array name, a_count is dimension count */ @@ -2403,15 +2352,13 @@ yyreduce: break; case 144: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 675 "command.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 145: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 677 "command.y" { NODE *n = (yyvsp[(2) - (2)])->a_node; @@ -2422,50 +2369,44 @@ yyreduce: break; case 146: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 684 "command.y" { NODE *n = (yyvsp[(2) - (2)])->a_node; if ((n->flags & NUMBER) == 0) yyerror(_("non-numeric value found, numeric expected")); else - (yyvsp[(2) - (2)])->a_node->numbr = - n->numbr; + negate_num(n); (yyval) = (yyvsp[(2) - (2)]); } break; case 147: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 696 "command.y" { (yyval) = NULL; } break; case 148: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 698 "command.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 149: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 703 "command.y" { (yyval) = NULL; } break; case 150: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 705 "command.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 151: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 710 "command.y" { if ((yyvsp[(1) - (1)])->a_int == 0) @@ -2475,8 +2416,7 @@ yyreduce: break; case 152: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 716 "command.y" { if ((yyvsp[(2) - (2)])->a_int == 0) @@ -2486,22 +2426,19 @@ yyreduce: break; case 153: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 725 "command.y" { (yyval) = (yyvsp[(1) - (1)]); } break; case 154: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 727 "command.y" { (yyval) = (yyvsp[(2) - (2)]); } break; case 155: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 729 "command.y" { (yyvsp[(2) - (2)])->a_int = - (yyvsp[(2) - (2)])->a_int; @@ -2510,8 +2447,7 @@ yyreduce: break; case 156: - -/* Line 1806 of yacc.c */ +/* Line 1787 of yacc.c */ #line 737 "command.y" { if (lexptr_begin != NULL) { @@ -2524,9 +2460,8 @@ yyreduce: break; - -/* Line 1806 of yacc.c */ -#line 2542 "command.c" +/* Line 1787 of yacc.c */ +#line 2477 "command.c" default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -2713,7 +2648,7 @@ yyabortlab: yyresult = 1; goto yyreturn; -#if !defined(yyoverflow) || YYERROR_VERBOSE +#if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -2755,8 +2690,7 @@ yyreturn: } - -/* Line 2067 of yacc.c */ +/* Line 2048 of yacc.c */ #line 747 "command.y" @@ -2764,7 +2698,7 @@ yyreturn: /* append_statement --- append 'stmt' to the list of eval awk statements */ static CMDARG * -append_statement(CMDARG *alist, char *stmt) +append_statement(CMDARG *stmt_list, char *stmt) { CMDARG *a, *arg; char *s; @@ -2774,7 +2708,7 @@ append_statement(CMDARG *alist, char *stmt) if (stmt == start_EVAL) { len = sizeof(start_EVAL); - for (a = alist; a != NULL; a = a->next) + for (a = stmt_list; a != NULL; a = a->next) len += strlen(a->a_string) + 1; /* 1 for ',' */ len += EVALSIZE; @@ -2786,7 +2720,7 @@ append_statement(CMDARG *alist, char *stmt) slen = sizeof("function @eval(") - 1; memcpy(s, start_EVAL, slen); - for (a = alist; a != NULL; a = a->next) { + for (a = stmt_list; a != NULL; a = a->next) { len = strlen(a->a_string); memcpy(s + slen, a->a_string, len); slen += len; @@ -2800,14 +2734,14 @@ append_statement(CMDARG *alist, char *stmt) } len = strlen(stmt) + 1; /* 1 for newline */ - s = alist->a_string; + s = stmt_list->a_string; slen = strlen(s); - ssize = alist->a_count; + ssize = stmt_list->a_count; if (len > ssize - slen) { ssize = slen + len + EVALSIZE; erealloc(s, char *, (ssize + 2) * sizeof(char), "append_statement"); - alist->a_string = s; - alist->a_count = ssize; + stmt_list->a_string = s; + stmt_list->a_count = ssize; } memcpy(s + slen, stmt, len); slen += len; @@ -2817,8 +2751,8 @@ append_statement(CMDARG *alist, char *stmt) } if (stmt == end_EVAL) - erealloc(alist->a_string, char *, slen + 2, "append_statement"); - return alist; + erealloc(stmt_list->a_string, char *, slen + 2, "append_statement"); + return stmt_list; #undef EVALSIZE } @@ -3179,7 +3113,7 @@ again: if (c == '"') { char *str, *p; int flags = ALREADY_MALLOCED; - int esc_seen = FALSE; + bool esc_seen = false; toklen = lexend - lexptr; emalloc(str, char *, toklen + 2, "yylex"); @@ -3194,7 +3128,7 @@ err: } if (c == '\\') { c = *++lexptr; - esc_seen = TRUE; + esc_seen = true; if (want_nodeval || c != '"') *p++ = '\\'; } @@ -3207,7 +3141,7 @@ err: if (! want_nodeval) { yylval = mk_cmdarg(D_string); - yylval->a_string = estrdup(str, p - str); + yylval->a_string = str; append_cmdarg(yylval); return D_STRING; } else { /* awk string */ @@ -3253,22 +3187,37 @@ err: return D_STRING; } - /* assert(want_nodval == TRUE); */ - /* look for awk number */ if (isdigit((unsigned char) tokstart[0])) { - double d; + NODE *r = NULL; errno = 0; - d = strtod(tokstart, &lexptr); +#ifdef HAVE_MPFR + if (do_mpfr) { + int tval; + r = mpg_float(); + tval = mpfr_strtofr(r->mpg_numbr, tokstart, & lexptr, 0, ROUND_MODE); + IEEE_FMT(r->mpg_numbr, tval); + if (mpfr_integer_p(r->mpg_numbr)) { + /* integral value, convert to a GMP type. */ + NODE *tmp = r; + r = mpg_integer(); + mpfr_get_z(r->mpg_i, tmp->mpg_numbr, MPFR_RNDZ); + unref(tmp); + } + } else +#endif + r = make_number(strtod(tokstart, & lexptr)); + if (errno != 0) { yyerror(strerror(errno)); + unref(r); errno = 0; return '\n'; } yylval = mk_cmdarg(D_node); - yylval->a_node = make_number(d); + yylval->a_node = r; append_cmdarg(yylval); return D_NODE; } @@ -3376,7 +3325,7 @@ find_command(const char *token, size_t toklen) { char *name, *abrv; int i, k; - int try_exact = TRUE; + bool try_exact = true; int abrv_match = -1; int partial_match = -1; @@ -3398,8 +3347,10 @@ find_command(const char *token, size_t toklen) && strncmp(name, token, toklen) == 0 ) return i; - if (*name > *token) - try_exact = FALSE; + + if (*name > *token || i == (k - 1)) + try_exact = false; + if (abrv_match < 0) { abrv = cmdtab[i].abbrvn; if (abrv[0] == token[0]) { @@ -3452,7 +3403,7 @@ do_help(CMDARG *arg, int cmd) fprintf(out_fp, _("undefined command: %s\n"), name); } - return FALSE; + return false; } @@ -3501,7 +3452,7 @@ command_completion(const char *text, int start, int end) int idx; int len; - rl_attempted_completion_over = TRUE; /* no default filename completion please */ + rl_attempted_completion_over = true; /* no default filename completion please */ this_cmd = D_illegal; len = start; @@ -3539,6 +3490,7 @@ command_completion(const char *text, int start, int end) return NULL; } } + if (this_cmd == D_print || this_cmd == D_printf) return rl_completion_matches(text, variable_generator); return NULL; @@ -3599,7 +3551,7 @@ argument_generator(const char *text, int state) { static size_t textlen; static int idx; - char *name; + const char *name; if (! state) { /* first time */ textlen = strlen(text); @@ -3607,12 +3559,12 @@ argument_generator(const char *text, int state) } if (this_cmd == D_help) { - while ((name = (char *) cmdtab[idx++].name) != NULL) { + while ((name = cmdtab[idx++].name) != NULL) { if (strncmp(name, text, textlen) == 0) return estrdup(name, strlen(name)); } } else { - while ((name = (char *) argtab[idx].name) != NULL) { + while ((name = argtab[idx].name) != NULL) { if (this_cmd != argtab[idx++].cmd) continue; if (strncmp(name, text, textlen) == 0) @@ -3629,45 +3581,39 @@ variable_generator(const char *text, int state) { static size_t textlen; static int idx = 0; - static char **pnames = NULL; - static NODE **var_table = NULL; - char *name; - NODE *hp; + static NODE *func = NULL; + static NODE **vars = NULL; + const char *name; + NODE *r; if (! state) { /* first time */ textlen = strlen(text); - if (var_table != NULL) - efree(var_table); - var_table = get_varlist(); + if (vars != NULL) + efree(vars); + vars = variable_list(); idx = 0; - pnames = get_parmlist(); /* names of function params in - * current context; the array - * is NULL terminated in - * awkgram.y (func_install). - */ + func = get_function(); /* function in current context */ } /* function params */ - while (pnames != NULL) { - name = pnames[idx]; - if (name == NULL) { - pnames = NULL; /* don't try to match params again */ + while (func != NULL) { + if (idx >= func->param_cnt) { + func = NULL; /* don't try to match params again */ idx = 0; break; } - idx++; + name = func->fparms[idx++].param; if (strncmp(name, text, textlen) == 0) return estrdup(name, strlen(name)); } /* globals */ - while ((hp = var_table[idx]) != NULL) { - idx++; - if (hp->hvalue->type == Node_func) - continue; - if (strncmp(hp->hname, text, textlen) == 0) - return estrdup(hp->hname, hp->hlength); + while ((r = vars[idx++]) != NULL) { + name = r->vname; + if (strncmp(name, text, textlen) == 0) + return estrdup(name, strlen(name)); } + return NULL; } @@ -3692,5 +3638,3 @@ history_expand_line(char **line) } #endif - - |