Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/bash/src/y.tab.c |
Source code | Switch to Preprocessed file |
Line | Source | Count | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | /* A Bison parser, made by GNU Bison 3.0.4. */ | - | ||||||||||||||||||
2 | - | |||||||||||||||||||
3 | /* Bison implementation for Yacc-like parsers in C | - | ||||||||||||||||||
4 | - | |||||||||||||||||||
5 | Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. | - | ||||||||||||||||||
6 | - | |||||||||||||||||||
7 | This program is free software: you can redistribute it and/or modify | - | ||||||||||||||||||
8 | it under the terms of the GNU General Public License as published by | - | ||||||||||||||||||
9 | the Free Software Foundation, either version 3 of the License, or | - | ||||||||||||||||||
10 | (at your option) any later version. | - | ||||||||||||||||||
11 | - | |||||||||||||||||||
12 | This program is distributed in the hope that it will be useful, | - | ||||||||||||||||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | - | ||||||||||||||||||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | - | ||||||||||||||||||
15 | GNU General Public License for more details. | - | ||||||||||||||||||
16 | - | |||||||||||||||||||
17 | You should have received a copy of the GNU General Public License | - | ||||||||||||||||||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | - | ||||||||||||||||||
19 | - | |||||||||||||||||||
20 | /* As a special exception, you may create a larger work that contains | - | ||||||||||||||||||
21 | part or all of the Bison parser skeleton and distribute that work | - | ||||||||||||||||||
22 | under terms of your choice, so long as that work isn't itself a | - | ||||||||||||||||||
23 | parser generator using the skeleton or a modified version thereof | - | ||||||||||||||||||
24 | as a parser skeleton. Alternatively, if you modify or redistribute | - | ||||||||||||||||||
25 | the parser skeleton itself, you may (at your option) remove this | - | ||||||||||||||||||
26 | special exception, which will cause the skeleton and the resulting | - | ||||||||||||||||||
27 | Bison output files to be licensed under the GNU General Public | - | ||||||||||||||||||
28 | License without this special exception. | - | ||||||||||||||||||
29 | - | |||||||||||||||||||
30 | This special exception was added by the Free Software Foundation in | - | ||||||||||||||||||
31 | version 2.2 of Bison. */ | - | ||||||||||||||||||
32 | - | |||||||||||||||||||
33 | /* C LALR(1) parser skeleton written by Richard Stallman, by | - | ||||||||||||||||||
34 | simplifying the original so-called "semantic" parser. */ | - | ||||||||||||||||||
35 | - | |||||||||||||||||||
36 | /* All symbols defined below should begin with yy or YY, to avoid | - | ||||||||||||||||||
37 | infringing on user name space. This should be done even for local | - | ||||||||||||||||||
38 | variables, as they might otherwise be expanded by user macros. | - | ||||||||||||||||||
39 | There are some unavoidable exceptions within include files to | - | ||||||||||||||||||
40 | define necessary library symbols; they are noted "INFRINGES ON | - | ||||||||||||||||||
41 | USER NAME SPACE" below. */ | - | ||||||||||||||||||
42 | - | |||||||||||||||||||
43 | /* Identify Bison output. */ | - | ||||||||||||||||||
44 | #define YYBISON 1 | - | ||||||||||||||||||
45 | - | |||||||||||||||||||
46 | /* Bison version. */ | - | ||||||||||||||||||
47 | #define YYBISON_VERSION "3.0.4" | - | ||||||||||||||||||
48 | - | |||||||||||||||||||
49 | /* Skeleton name. */ | - | ||||||||||||||||||
50 | #define YYSKELETON_NAME "yacc.c" | - | ||||||||||||||||||
51 | - | |||||||||||||||||||
52 | /* Pure parsers. */ | - | ||||||||||||||||||
53 | #define YYPURE 0 | - | ||||||||||||||||||
54 | - | |||||||||||||||||||
55 | /* Push parsers. */ | - | ||||||||||||||||||
56 | #define YYPUSH 0 | - | ||||||||||||||||||
57 | - | |||||||||||||||||||
58 | /* Pull parsers. */ | - | ||||||||||||||||||
59 | #define YYPULL 1 | - | ||||||||||||||||||
60 | - | |||||||||||||||||||
61 | - | |||||||||||||||||||
62 | - | |||||||||||||||||||
63 | - | |||||||||||||||||||
64 | /* Copy the first part of user declarations. */ | - | ||||||||||||||||||
65 | #line 21 "./parse.y" /* yacc.c:339 */ | - | ||||||||||||||||||
66 | - | |||||||||||||||||||
67 | #include "config.h" | - | ||||||||||||||||||
68 | - | |||||||||||||||||||
69 | #include "bashtypes.h" | - | ||||||||||||||||||
70 | #include "bashansi.h" | - | ||||||||||||||||||
71 | - | |||||||||||||||||||
72 | #include "filecntl.h" | - | ||||||||||||||||||
73 | - | |||||||||||||||||||
74 | #if defined (HAVE_UNISTD_H) | - | ||||||||||||||||||
75 | # include <unistd.h> | - | ||||||||||||||||||
76 | #endif | - | ||||||||||||||||||
77 | - | |||||||||||||||||||
78 | #if defined (HAVE_LOCALE_H) | - | ||||||||||||||||||
79 | # include <locale.h> | - | ||||||||||||||||||
80 | #endif | - | ||||||||||||||||||
81 | - | |||||||||||||||||||
82 | #include <stdio.h> | - | ||||||||||||||||||
83 | #include "chartypes.h" | - | ||||||||||||||||||
84 | #include <signal.h> | - | ||||||||||||||||||
85 | - | |||||||||||||||||||
86 | #include "memalloc.h" | - | ||||||||||||||||||
87 | - | |||||||||||||||||||
88 | #include "bashintl.h" | - | ||||||||||||||||||
89 | - | |||||||||||||||||||
90 | #define NEED_STRFTIME_DECL /* used in externs.h */ | - | ||||||||||||||||||
91 | - | |||||||||||||||||||
92 | #include "shell.h" | - | ||||||||||||||||||
93 | #include "execute_cmd.h" | - | ||||||||||||||||||
94 | #include "typemax.h" /* SIZE_MAX if needed */ | - | ||||||||||||||||||
95 | #include "trap.h" | - | ||||||||||||||||||
96 | #include "flags.h" | - | ||||||||||||||||||
97 | #include "parser.h" | - | ||||||||||||||||||
98 | #include "mailcheck.h" | - | ||||||||||||||||||
99 | #include "test.h" | - | ||||||||||||||||||
100 | #include "builtins.h" | - | ||||||||||||||||||
101 | #include "builtins/common.h" | - | ||||||||||||||||||
102 | #include "builtins/builtext.h" | - | ||||||||||||||||||
103 | - | |||||||||||||||||||
104 | #include "shmbutil.h" | - | ||||||||||||||||||
105 | - | |||||||||||||||||||
106 | #if defined (READLINE) | - | ||||||||||||||||||
107 | # include "bashline.h" | - | ||||||||||||||||||
108 | # include <readline/readline.h> | - | ||||||||||||||||||
109 | #endif /* READLINE */ | - | ||||||||||||||||||
110 | - | |||||||||||||||||||
111 | #if defined (HISTORY) | - | ||||||||||||||||||
112 | # include "bashhist.h" | - | ||||||||||||||||||
113 | # include <readline/history.h> | - | ||||||||||||||||||
114 | #endif /* HISTORY */ | - | ||||||||||||||||||
115 | - | |||||||||||||||||||
116 | #if defined (JOB_CONTROL) | - | ||||||||||||||||||
117 | # include "jobs.h" | - | ||||||||||||||||||
118 | #else | - | ||||||||||||||||||
119 | extern int cleanup_dead_jobs __P((void)); | - | ||||||||||||||||||
120 | #endif /* JOB_CONTROL */ | - | ||||||||||||||||||
121 | - | |||||||||||||||||||
122 | #if defined (ALIAS) | - | ||||||||||||||||||
123 | # include "alias.h" | - | ||||||||||||||||||
124 | #else | - | ||||||||||||||||||
125 | typedef void *alias_t; | - | ||||||||||||||||||
126 | #endif /* ALIAS */ | - | ||||||||||||||||||
127 | - | |||||||||||||||||||
128 | #if defined (PROMPT_STRING_DECODE) | - | ||||||||||||||||||
129 | # ifndef _MINIX | - | ||||||||||||||||||
130 | # include <sys/param.h> | - | ||||||||||||||||||
131 | # endif | - | ||||||||||||||||||
132 | # include <time.h> | - | ||||||||||||||||||
133 | # if defined (TM_IN_SYS_TIME) | - | ||||||||||||||||||
134 | # include <sys/types.h> | - | ||||||||||||||||||
135 | # include <sys/time.h> | - | ||||||||||||||||||
136 | # endif /* TM_IN_SYS_TIME */ | - | ||||||||||||||||||
137 | # include "maxpath.h" | - | ||||||||||||||||||
138 | #endif /* PROMPT_STRING_DECODE */ | - | ||||||||||||||||||
139 | - | |||||||||||||||||||
140 | #define RE_READ_TOKEN -99 | - | ||||||||||||||||||
141 | #define NO_EXPANSION -100 | - | ||||||||||||||||||
142 | - | |||||||||||||||||||
143 | #define END_ALIAS -2 | - | ||||||||||||||||||
144 | - | |||||||||||||||||||
145 | #ifdef DEBUG | - | ||||||||||||||||||
146 | # define YYDEBUG 1 | - | ||||||||||||||||||
147 | #else | - | ||||||||||||||||||
148 | # define YYDEBUG 0 | - | ||||||||||||||||||
149 | #endif | - | ||||||||||||||||||
150 | - | |||||||||||||||||||
151 | #if defined (HANDLE_MULTIBYTE) | - | ||||||||||||||||||
152 | # define last_shell_getc_is_singlebyte \ | - | ||||||||||||||||||
153 | ((shell_input_line_index > 1) \ | - | ||||||||||||||||||
154 | ? shell_input_line_property[shell_input_line_index - 1] \ | - | ||||||||||||||||||
155 | : 1) | - | ||||||||||||||||||
156 | # define MBTEST(x) ((x) && last_shell_getc_is_singlebyte) | - | ||||||||||||||||||
157 | #else | - | ||||||||||||||||||
158 | # define last_shell_getc_is_singlebyte 1 | - | ||||||||||||||||||
159 | # define MBTEST(x) ((x)) | - | ||||||||||||||||||
160 | #endif | - | ||||||||||||||||||
161 | - | |||||||||||||||||||
162 | #if defined (EXTENDED_GLOB) | - | ||||||||||||||||||
163 | extern int extended_glob; | - | ||||||||||||||||||
164 | #endif | - | ||||||||||||||||||
165 | - | |||||||||||||||||||
166 | extern int dump_translatable_strings, dump_po_strings; | - | ||||||||||||||||||
167 | - | |||||||||||||||||||
168 | #if !defined (errno) | - | ||||||||||||||||||
169 | extern int errno; | - | ||||||||||||||||||
170 | #endif | - | ||||||||||||||||||
171 | - | |||||||||||||||||||
172 | /* **************************************************************** */ | - | ||||||||||||||||||
173 | /* */ | - | ||||||||||||||||||
174 | /* "Forward" declarations */ | - | ||||||||||||||||||
175 | /* */ | - | ||||||||||||||||||
176 | /* **************************************************************** */ | - | ||||||||||||||||||
177 | - | |||||||||||||||||||
178 | #ifdef DEBUG | - | ||||||||||||||||||
179 | static void debug_parser __P((int)); | - | ||||||||||||||||||
180 | #endif | - | ||||||||||||||||||
181 | - | |||||||||||||||||||
182 | static int yy_getc __P((void)); | - | ||||||||||||||||||
183 | static int yy_ungetc __P((int)); | - | ||||||||||||||||||
184 | - | |||||||||||||||||||
185 | #if defined (READLINE) | - | ||||||||||||||||||
186 | static int yy_readline_get __P((void)); | - | ||||||||||||||||||
187 | static int yy_readline_unget __P((int)); | - | ||||||||||||||||||
188 | #endif | - | ||||||||||||||||||
189 | - | |||||||||||||||||||
190 | static int yy_string_get __P((void)); | - | ||||||||||||||||||
191 | static int yy_string_unget __P((int)); | - | ||||||||||||||||||
192 | static void rewind_input_string __P((void)); | - | ||||||||||||||||||
193 | static int yy_stream_get __P((void)); | - | ||||||||||||||||||
194 | static int yy_stream_unget __P((int)); | - | ||||||||||||||||||
195 | - | |||||||||||||||||||
196 | static int shell_getc __P((int)); | - | ||||||||||||||||||
197 | static void shell_ungetc __P((int)); | - | ||||||||||||||||||
198 | static void discard_until __P((int)); | - | ||||||||||||||||||
199 | - | |||||||||||||||||||
200 | #if defined (ALIAS) || defined (DPAREN_ARITHMETIC) | - | ||||||||||||||||||
201 | static void push_string __P((char *, int, alias_t *)); | - | ||||||||||||||||||
202 | static void pop_string __P((void)); | - | ||||||||||||||||||
203 | static void free_string_list __P((void)); | - | ||||||||||||||||||
204 | #endif | - | ||||||||||||||||||
205 | - | |||||||||||||||||||
206 | static char *read_a_line __P((int)); | - | ||||||||||||||||||
207 | - | |||||||||||||||||||
208 | static int reserved_word_acceptable __P((int)); | - | ||||||||||||||||||
209 | static int yylex __P((void)); | - | ||||||||||||||||||
210 | - | |||||||||||||||||||
211 | static void push_heredoc __P((REDIRECT *)); | - | ||||||||||||||||||
212 | static char *mk_alexpansion __P((char *)); | - | ||||||||||||||||||
213 | static int alias_expand_token __P((char *)); | - | ||||||||||||||||||
214 | static int time_command_acceptable __P((void)); | - | ||||||||||||||||||
215 | static int special_case_tokens __P((char *)); | - | ||||||||||||||||||
216 | static int read_token __P((int)); | - | ||||||||||||||||||
217 | static char *parse_matched_pair __P((int, int, int, int *, int)); | - | ||||||||||||||||||
218 | static char *parse_comsub __P((int, int, int, int *, int)); | - | ||||||||||||||||||
219 | #if defined (ARRAY_VARS) | - | ||||||||||||||||||
220 | static char *parse_compound_assignment __P((int *)); | - | ||||||||||||||||||
221 | #endif | - | ||||||||||||||||||
222 | #if defined (DPAREN_ARITHMETIC) || defined (ARITH_FOR_COMMAND) | - | ||||||||||||||||||
223 | static int parse_dparen __P((int)); | - | ||||||||||||||||||
224 | static int parse_arith_cmd __P((char **, int)); | - | ||||||||||||||||||
225 | #endif | - | ||||||||||||||||||
226 | #if defined (COND_COMMAND) | - | ||||||||||||||||||
227 | static void cond_error __P((void)); | - | ||||||||||||||||||
228 | static COND_COM *cond_expr __P((void)); | - | ||||||||||||||||||
229 | static COND_COM *cond_or __P((void)); | - | ||||||||||||||||||
230 | static COND_COM *cond_and __P((void)); | - | ||||||||||||||||||
231 | static COND_COM *cond_term __P((void)); | - | ||||||||||||||||||
232 | static int cond_skip_newlines __P((void)); | - | ||||||||||||||||||
233 | static COMMAND *parse_cond_command __P((void)); | - | ||||||||||||||||||
234 | #endif | - | ||||||||||||||||||
235 | #if defined (ARRAY_VARS) | - | ||||||||||||||||||
236 | static int token_is_assignment __P((char *, int)); | - | ||||||||||||||||||
237 | static int token_is_ident __P((char *, int)); | - | ||||||||||||||||||
238 | #endif | - | ||||||||||||||||||
239 | static int read_token_word __P((int)); | - | ||||||||||||||||||
240 | static void discard_parser_constructs __P((int)); | - | ||||||||||||||||||
241 | - | |||||||||||||||||||
242 | static char *error_token_from_token __P((int)); | - | ||||||||||||||||||
243 | static char *error_token_from_text __P((void)); | - | ||||||||||||||||||
244 | static void print_offending_line __P((void)); | - | ||||||||||||||||||
245 | static void report_syntax_error __P((char *)); | - | ||||||||||||||||||
246 | - | |||||||||||||||||||
247 | static void handle_eof_input_unit __P((void)); | - | ||||||||||||||||||
248 | static void prompt_again __P((void)); | - | ||||||||||||||||||
249 | #if 0 | - | ||||||||||||||||||
250 | static void reset_readline_prompt __P((void)); | - | ||||||||||||||||||
251 | #endif | - | ||||||||||||||||||
252 | static void print_prompt __P((void)); | - | ||||||||||||||||||
253 | - | |||||||||||||||||||
254 | #if defined (HANDLE_MULTIBYTE) | - | ||||||||||||||||||
255 | static void set_line_mbstate __P((void)); | - | ||||||||||||||||||
256 | static char *shell_input_line_property = NULL; | - | ||||||||||||||||||
257 | static size_t shell_input_line_propsize = 0; | - | ||||||||||||||||||
258 | #else | - | ||||||||||||||||||
259 | # define set_line_mbstate() | - | ||||||||||||||||||
260 | #endif | - | ||||||||||||||||||
261 | - | |||||||||||||||||||
262 | extern int yyerror __P((const char *)); | - | ||||||||||||||||||
263 | - | |||||||||||||||||||
264 | #ifdef DEBUG | - | ||||||||||||||||||
265 | extern int yydebug; | - | ||||||||||||||||||
266 | #endif | - | ||||||||||||||||||
267 | - | |||||||||||||||||||
268 | /* Default prompt strings */ | - | ||||||||||||||||||
269 | char *primary_prompt = PPROMPT; | - | ||||||||||||||||||
270 | char *secondary_prompt = SPROMPT; | - | ||||||||||||||||||
271 | - | |||||||||||||||||||
272 | /* PROMPT_STRING_POINTER points to one of these, never to an actual string. */ | - | ||||||||||||||||||
273 | char *ps1_prompt, *ps2_prompt; | - | ||||||||||||||||||
274 | - | |||||||||||||||||||
275 | /* Displayed after reading a command but before executing it in an interactive shell */ | - | ||||||||||||||||||
276 | char *ps0_prompt; | - | ||||||||||||||||||
277 | - | |||||||||||||||||||
278 | /* Handle on the current prompt string. Indirectly points through | - | ||||||||||||||||||
279 | ps1_ or ps2_prompt. */ | - | ||||||||||||||||||
280 | char **prompt_string_pointer = (char **)NULL; | - | ||||||||||||||||||
281 | char *current_prompt_string; | - | ||||||||||||||||||
282 | - | |||||||||||||||||||
283 | /* Non-zero means we expand aliases in commands. */ | - | ||||||||||||||||||
284 | int expand_aliases = 0; | - | ||||||||||||||||||
285 | - | |||||||||||||||||||
286 | /* If non-zero, the decoded prompt string undergoes parameter and | - | ||||||||||||||||||
287 | variable substitution, command substitution, arithmetic substitution, | - | ||||||||||||||||||
288 | string expansion, process substitution, and quote removal in | - | ||||||||||||||||||
289 | decode_prompt_string. */ | - | ||||||||||||||||||
290 | int promptvars = 1; | - | ||||||||||||||||||
291 | - | |||||||||||||||||||
292 | /* If non-zero, $'...' and $"..." are expanded when they appear within | - | ||||||||||||||||||
293 | a ${...} expansion, even when the expansion appears within double | - | ||||||||||||||||||
294 | quotes. */ | - | ||||||||||||||||||
295 | int extended_quote = 1; | - | ||||||||||||||||||
296 | - | |||||||||||||||||||
297 | /* The number of lines read from input while creating the current command. */ | - | ||||||||||||||||||
298 | int current_command_line_count; | - | ||||||||||||||||||
299 | - | |||||||||||||||||||
300 | /* The number of lines in a command saved while we run parse_and_execute */ | - | ||||||||||||||||||
301 | int saved_command_line_count; | - | ||||||||||||||||||
302 | - | |||||||||||||||||||
303 | /* The token that currently denotes the end of parse. */ | - | ||||||||||||||||||
304 | int shell_eof_token; | - | ||||||||||||||||||
305 | - | |||||||||||||||||||
306 | /* The token currently being read. */ | - | ||||||||||||||||||
307 | int current_token; | - | ||||||||||||||||||
308 | - | |||||||||||||||||||
309 | /* The current parser state. */ | - | ||||||||||||||||||
310 | int parser_state; | - | ||||||||||||||||||
311 | - | |||||||||||||||||||
312 | /* Variables to manage the task of reading here documents, because we need to | - | ||||||||||||||||||
313 | defer the reading until after a complete command has been collected. */ | - | ||||||||||||||||||
314 | static REDIRECT *redir_stack[HEREDOC_MAX]; | - | ||||||||||||||||||
315 | int need_here_doc; | - | ||||||||||||||||||
316 | - | |||||||||||||||||||
317 | /* Where shell input comes from. History expansion is performed on each | - | ||||||||||||||||||
318 | line when the shell is interactive. */ | - | ||||||||||||||||||
319 | static char *shell_input_line = (char *)NULL; | - | ||||||||||||||||||
320 | static size_t shell_input_line_index; | - | ||||||||||||||||||
321 | static size_t shell_input_line_size; /* Amount allocated for shell_input_line. */ | - | ||||||||||||||||||
322 | static size_t shell_input_line_len; /* strlen (shell_input_line) */ | - | ||||||||||||||||||
323 | - | |||||||||||||||||||
324 | /* Either zero or EOF. */ | - | ||||||||||||||||||
325 | static int shell_input_line_terminator; | - | ||||||||||||||||||
326 | - | |||||||||||||||||||
327 | /* The line number in a script on which a function definition starts. */ | - | ||||||||||||||||||
328 | static int function_dstart; | - | ||||||||||||||||||
329 | - | |||||||||||||||||||
330 | /* The line number in a script on which a function body starts. */ | - | ||||||||||||||||||
331 | static int function_bstart; | - | ||||||||||||||||||
332 | - | |||||||||||||||||||
333 | /* The line number in a script at which an arithmetic for command starts. */ | - | ||||||||||||||||||
334 | static int arith_for_lineno; | - | ||||||||||||||||||
335 | - | |||||||||||||||||||
336 | /* The decoded prompt string. Used if READLINE is not defined or if | - | ||||||||||||||||||
337 | editing is turned off. Analogous to current_readline_prompt. */ | - | ||||||||||||||||||
338 | static char *current_decoded_prompt; | - | ||||||||||||||||||
339 | - | |||||||||||||||||||
340 | /* The last read token, or NULL. read_token () uses this for context | - | ||||||||||||||||||
341 | checking. */ | - | ||||||||||||||||||
342 | static int last_read_token; | - | ||||||||||||||||||
343 | - | |||||||||||||||||||
344 | /* The token read prior to last_read_token. */ | - | ||||||||||||||||||
345 | static int token_before_that; | - | ||||||||||||||||||
346 | - | |||||||||||||||||||
347 | /* The token read prior to token_before_that. */ | - | ||||||||||||||||||
348 | static int two_tokens_ago; | - | ||||||||||||||||||
349 | - | |||||||||||||||||||
350 | static int global_extglob; | - | ||||||||||||||||||
351 | - | |||||||||||||||||||
352 | /* The line number in a script where the word in a `case WORD', `select WORD' | - | ||||||||||||||||||
353 | or `for WORD' begins. This is a nested command maximum, since the array | - | ||||||||||||||||||
354 | index is decremented after a case, select, or for command is parsed. */ | - | ||||||||||||||||||
355 | #define MAX_CASE_NEST 128 | - | ||||||||||||||||||
356 | static int word_lineno[MAX_CASE_NEST+1]; | - | ||||||||||||||||||
357 | static int word_top = -1; | - | ||||||||||||||||||
358 | - | |||||||||||||||||||
359 | /* If non-zero, it is the token that we want read_token to return | - | ||||||||||||||||||
360 | regardless of what text is (or isn't) present to be read. This | - | ||||||||||||||||||
361 | is reset by read_token. If token_to_read == WORD or | - | ||||||||||||||||||
362 | ASSIGNMENT_WORD, yylval.word should be set to word_desc_to_read. */ | - | ||||||||||||||||||
363 | static int token_to_read; | - | ||||||||||||||||||
364 | static WORD_DESC *word_desc_to_read; | - | ||||||||||||||||||
365 | - | |||||||||||||||||||
366 | static REDIRECTEE source; | - | ||||||||||||||||||
367 | static REDIRECTEE redir; | - | ||||||||||||||||||
368 | - | |||||||||||||||||||
369 | static FILE *yyoutstream; | - | ||||||||||||||||||
370 | static FILE *yyerrstream; | - | ||||||||||||||||||
371 | - | |||||||||||||||||||
372 | #line 373 "y.tab.c" /* yacc.c:339 */ | - | ||||||||||||||||||
373 | - | |||||||||||||||||||
374 | # ifndef YY_NULLPTR | - | ||||||||||||||||||
375 | # if defined __cplusplus && 201103L <= __cplusplus | - | ||||||||||||||||||
376 | # define YY_NULLPTR nullptr | - | ||||||||||||||||||
377 | # else | - | ||||||||||||||||||
378 | # define YY_NULLPTR 0 | - | ||||||||||||||||||
379 | # endif | - | ||||||||||||||||||
380 | # endif | - | ||||||||||||||||||
381 | - | |||||||||||||||||||
382 | /* Enabling verbose error messages. */ | - | ||||||||||||||||||
383 | #ifdef YYERROR_VERBOSE | - | ||||||||||||||||||
384 | # undef YYERROR_VERBOSE | - | ||||||||||||||||||
385 | # define YYERROR_VERBOSE 1 | - | ||||||||||||||||||
386 | #else | - | ||||||||||||||||||
387 | # define YYERROR_VERBOSE 0 | - | ||||||||||||||||||
388 | #endif | - | ||||||||||||||||||
389 | - | |||||||||||||||||||
390 | /* In a future release of Bison, this section will be replaced | - | ||||||||||||||||||
391 | by #include "y.tab.h". */ | - | ||||||||||||||||||
392 | #ifndef YY_YY_Y_TAB_H_INCLUDED | - | ||||||||||||||||||
393 | # define YY_YY_Y_TAB_H_INCLUDED | - | ||||||||||||||||||
394 | /* Debug traces. */ | - | ||||||||||||||||||
395 | #ifndef YYDEBUG | - | ||||||||||||||||||
396 | # define YYDEBUG 0 | - | ||||||||||||||||||
397 | #endif | - | ||||||||||||||||||
398 | #if YYDEBUG | - | ||||||||||||||||||
399 | extern int yydebug; | - | ||||||||||||||||||
400 | #endif | - | ||||||||||||||||||
401 | - | |||||||||||||||||||
402 | /* Token type. */ | - | ||||||||||||||||||
403 | #ifndef YYTOKENTYPE | - | ||||||||||||||||||
404 | # define YYTOKENTYPE | - | ||||||||||||||||||
405 | enum yytokentype | - | ||||||||||||||||||
406 | { | - | ||||||||||||||||||
407 | IF = 258, | - | ||||||||||||||||||
408 | THEN = 259, | - | ||||||||||||||||||
409 | ELSE = 260, | - | ||||||||||||||||||
410 | ELIF = 261, | - | ||||||||||||||||||
411 | FI = 262, | - | ||||||||||||||||||
412 | CASE = 263, | - | ||||||||||||||||||
413 | ESAC = 264, | - | ||||||||||||||||||
414 | FOR = 265, | - | ||||||||||||||||||
415 | SELECT = 266, | - | ||||||||||||||||||
416 | WHILE = 267, | - | ||||||||||||||||||
417 | UNTIL = 268, | - | ||||||||||||||||||
418 | DO = 269, | - | ||||||||||||||||||
419 | DONE = 270, | - | ||||||||||||||||||
420 | FUNCTION = 271, | - | ||||||||||||||||||
421 | COPROC = 272, | - | ||||||||||||||||||
422 | COND_START = 273, | - | ||||||||||||||||||
423 | COND_END = 274, | - | ||||||||||||||||||
424 | COND_ERROR = 275, | - | ||||||||||||||||||
425 | IN = 276, | - | ||||||||||||||||||
426 | BANG = 277, | - | ||||||||||||||||||
427 | TIME = 278, | - | ||||||||||||||||||
428 | TIMEOPT = 279, | - | ||||||||||||||||||
429 | TIMEIGN = 280, | - | ||||||||||||||||||
430 | WORD = 281, | - | ||||||||||||||||||
431 | ASSIGNMENT_WORD = 282, | - | ||||||||||||||||||
432 | REDIR_WORD = 283, | - | ||||||||||||||||||
433 | NUMBER = 284, | - | ||||||||||||||||||
434 | ARITH_CMD = 285, | - | ||||||||||||||||||
435 | ARITH_FOR_EXPRS = 286, | - | ||||||||||||||||||
436 | COND_CMD = 287, | - | ||||||||||||||||||
437 | AND_AND = 288, | - | ||||||||||||||||||
438 | OR_OR = 289, | - | ||||||||||||||||||
439 | GREATER_GREATER = 290, | - | ||||||||||||||||||
440 | LESS_LESS = 291, | - | ||||||||||||||||||
441 | LESS_AND = 292, | - | ||||||||||||||||||
442 | LESS_LESS_LESS = 293, | - | ||||||||||||||||||
443 | GREATER_AND = 294, | - | ||||||||||||||||||
444 | SEMI_SEMI = 295, | - | ||||||||||||||||||
445 | SEMI_AND = 296, | - | ||||||||||||||||||
446 | SEMI_SEMI_AND = 297, | - | ||||||||||||||||||
447 | LESS_LESS_MINUS = 298, | - | ||||||||||||||||||
448 | AND_GREATER = 299, | - | ||||||||||||||||||
449 | AND_GREATER_GREATER = 300, | - | ||||||||||||||||||
450 | LESS_GREATER = 301, | - | ||||||||||||||||||
451 | GREATER_BAR = 302, | - | ||||||||||||||||||
452 | BAR_AND = 303, | - | ||||||||||||||||||
453 | yacc_EOF = 304 | - | ||||||||||||||||||
454 | }; | - | ||||||||||||||||||
455 | #endif | - | ||||||||||||||||||
456 | /* Tokens. */ | - | ||||||||||||||||||
457 | #define IF 258 | - | ||||||||||||||||||
458 | #define THEN 259 | - | ||||||||||||||||||
459 | #define ELSE 260 | - | ||||||||||||||||||
460 | #define ELIF 261 | - | ||||||||||||||||||
461 | #define FI 262 | - | ||||||||||||||||||
462 | #define CASE 263 | - | ||||||||||||||||||
463 | #define ESAC 264 | - | ||||||||||||||||||
464 | #define FOR 265 | - | ||||||||||||||||||
465 | #define SELECT 266 | - | ||||||||||||||||||
466 | #define WHILE 267 | - | ||||||||||||||||||
467 | #define UNTIL 268 | - | ||||||||||||||||||
468 | #define DO 269 | - | ||||||||||||||||||
469 | #define DONE 270 | - | ||||||||||||||||||
470 | #define FUNCTION 271 | - | ||||||||||||||||||
471 | #define COPROC 272 | - | ||||||||||||||||||
472 | #define COND_START 273 | - | ||||||||||||||||||
473 | #define COND_END 274 | - | ||||||||||||||||||
474 | #define COND_ERROR 275 | - | ||||||||||||||||||
475 | #define IN 276 | - | ||||||||||||||||||
476 | #define BANG 277 | - | ||||||||||||||||||
477 | #define TIME 278 | - | ||||||||||||||||||
478 | #define TIMEOPT 279 | - | ||||||||||||||||||
479 | #define TIMEIGN 280 | - | ||||||||||||||||||
480 | #define WORD 281 | - | ||||||||||||||||||
481 | #define ASSIGNMENT_WORD 282 | - | ||||||||||||||||||
482 | #define REDIR_WORD 283 | - | ||||||||||||||||||
483 | #define NUMBER 284 | - | ||||||||||||||||||
484 | #define ARITH_CMD 285 | - | ||||||||||||||||||
485 | #define ARITH_FOR_EXPRS 286 | - | ||||||||||||||||||
486 | #define COND_CMD 287 | - | ||||||||||||||||||
487 | #define AND_AND 288 | - | ||||||||||||||||||
488 | #define OR_OR 289 | - | ||||||||||||||||||
489 | #define GREATER_GREATER 290 | - | ||||||||||||||||||
490 | #define LESS_LESS 291 | - | ||||||||||||||||||
491 | #define LESS_AND 292 | - | ||||||||||||||||||
492 | #define LESS_LESS_LESS 293 | - | ||||||||||||||||||
493 | #define GREATER_AND 294 | - | ||||||||||||||||||
494 | #define SEMI_SEMI 295 | - | ||||||||||||||||||
495 | #define SEMI_AND 296 | - | ||||||||||||||||||
496 | #define SEMI_SEMI_AND 297 | - | ||||||||||||||||||
497 | #define LESS_LESS_MINUS 298 | - | ||||||||||||||||||
498 | #define AND_GREATER 299 | - | ||||||||||||||||||
499 | #define AND_GREATER_GREATER 300 | - | ||||||||||||||||||
500 | #define LESS_GREATER 301 | - | ||||||||||||||||||
501 | #define GREATER_BAR 302 | - | ||||||||||||||||||
502 | #define BAR_AND 303 | - | ||||||||||||||||||
503 | #define yacc_EOF 304 | - | ||||||||||||||||||
504 | - | |||||||||||||||||||
505 | /* Value type. */ | - | ||||||||||||||||||
506 | #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED | - | ||||||||||||||||||
507 | - | |||||||||||||||||||
508 | union YYSTYPE | - | ||||||||||||||||||
509 | { | - | ||||||||||||||||||
510 | #line 328 "./parse.y" /* yacc.c:355 */ | - | ||||||||||||||||||
511 | - | |||||||||||||||||||
512 | WORD_DESC *word; /* the word that we read. */ | - | ||||||||||||||||||
513 | int number; /* the number that we read. */ | - | ||||||||||||||||||
514 | WORD_LIST *word_list; | - | ||||||||||||||||||
515 | COMMAND *command; | - | ||||||||||||||||||
516 | REDIRECT *redirect; | - | ||||||||||||||||||
517 | ELEMENT element; | - | ||||||||||||||||||
518 | PATTERN_LIST *pattern; | - | ||||||||||||||||||
519 | - | |||||||||||||||||||
520 | #line 521 "y.tab.c" /* yacc.c:355 */ | - | ||||||||||||||||||
521 | }; | - | ||||||||||||||||||
522 | - | |||||||||||||||||||
523 | typedef union YYSTYPE YYSTYPE; | - | ||||||||||||||||||
524 | # define YYSTYPE_IS_TRIVIAL 1 | - | ||||||||||||||||||
525 | # define YYSTYPE_IS_DECLARED 1 | - | ||||||||||||||||||
526 | #endif | - | ||||||||||||||||||
527 | - | |||||||||||||||||||
528 | - | |||||||||||||||||||
529 | extern YYSTYPE yylval; | - | ||||||||||||||||||
530 | - | |||||||||||||||||||
531 | int yyparse (void); | - | ||||||||||||||||||
532 | - | |||||||||||||||||||
533 | #endif /* !YY_YY_Y_TAB_H_INCLUDED */ | - | ||||||||||||||||||
534 | - | |||||||||||||||||||
535 | /* Copy the second part of user declarations. */ | - | ||||||||||||||||||
536 | - | |||||||||||||||||||
537 | #line 538 "y.tab.c" /* yacc.c:358 */ | - | ||||||||||||||||||
538 | - | |||||||||||||||||||
539 | #ifdef short | - | ||||||||||||||||||
540 | # undef short | - | ||||||||||||||||||
541 | #endif | - | ||||||||||||||||||
542 | - | |||||||||||||||||||
543 | #ifdef YYTYPE_UINT8 | - | ||||||||||||||||||
544 | typedef YYTYPE_UINT8 yytype_uint8; | - | ||||||||||||||||||
545 | #else | - | ||||||||||||||||||
546 | typedef unsigned char yytype_uint8; | - | ||||||||||||||||||
547 | #endif | - | ||||||||||||||||||
548 | - | |||||||||||||||||||
549 | #ifdef YYTYPE_INT8 | - | ||||||||||||||||||
550 | typedef YYTYPE_INT8 yytype_int8; | - | ||||||||||||||||||
551 | #else | - | ||||||||||||||||||
552 | typedef signed char yytype_int8; | - | ||||||||||||||||||
553 | #endif | - | ||||||||||||||||||
554 | - | |||||||||||||||||||
555 | #ifdef YYTYPE_UINT16 | - | ||||||||||||||||||
556 | typedef YYTYPE_UINT16 yytype_uint16; | - | ||||||||||||||||||
557 | #else | - | ||||||||||||||||||
558 | typedef unsigned short int yytype_uint16; | - | ||||||||||||||||||
559 | #endif | - | ||||||||||||||||||
560 | - | |||||||||||||||||||
561 | #ifdef YYTYPE_INT16 | - | ||||||||||||||||||
562 | typedef YYTYPE_INT16 yytype_int16; | - | ||||||||||||||||||
563 | #else | - | ||||||||||||||||||
564 | typedef short int yytype_int16; | - | ||||||||||||||||||
565 | #endif | - | ||||||||||||||||||
566 | - | |||||||||||||||||||
567 | #ifndef YYSIZE_T | - | ||||||||||||||||||
568 | # ifdef __SIZE_TYPE__ | - | ||||||||||||||||||
569 | # define YYSIZE_T __SIZE_TYPE__ | - | ||||||||||||||||||
570 | # elif defined size_t | - | ||||||||||||||||||
571 | # define YYSIZE_T size_t | - | ||||||||||||||||||
572 | # elif ! defined YYSIZE_T | - | ||||||||||||||||||
573 | # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ | - | ||||||||||||||||||
574 | # define YYSIZE_T size_t | - | ||||||||||||||||||
575 | # else | - | ||||||||||||||||||
576 | # define YYSIZE_T unsigned int | - | ||||||||||||||||||
577 | # endif | - | ||||||||||||||||||
578 | #endif | - | ||||||||||||||||||
579 | - | |||||||||||||||||||
580 | #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) | - | ||||||||||||||||||
581 | - | |||||||||||||||||||
582 | #ifndef YY_ | - | ||||||||||||||||||
583 | # if defined YYENABLE_NLS && YYENABLE_NLS | - | ||||||||||||||||||
584 | # if ENABLE_NLS | - | ||||||||||||||||||
585 | # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ | - | ||||||||||||||||||
586 | # define YY_(Msgid) dgettext ("bison-runtime", Msgid) | - | ||||||||||||||||||
587 | # endif | - | ||||||||||||||||||
588 | # endif | - | ||||||||||||||||||
589 | # ifndef YY_ | - | ||||||||||||||||||
590 | # define YY_(Msgid) Msgid | - | ||||||||||||||||||
591 | # endif | - | ||||||||||||||||||
592 | #endif | - | ||||||||||||||||||
593 | - | |||||||||||||||||||
594 | #ifndef YY_ATTRIBUTE | - | ||||||||||||||||||
595 | # if (defined __GNUC__ \ | - | ||||||||||||||||||
596 | && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ | - | ||||||||||||||||||
597 | || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C | - | ||||||||||||||||||
598 | # define YY_ATTRIBUTE(Spec) __attribute__(Spec) | - | ||||||||||||||||||
599 | # else | - | ||||||||||||||||||
600 | # define YY_ATTRIBUTE(Spec) /* empty */ | - | ||||||||||||||||||
601 | # endif | - | ||||||||||||||||||
602 | #endif | - | ||||||||||||||||||
603 | - | |||||||||||||||||||
604 | #ifndef YY_ATTRIBUTE_PURE | - | ||||||||||||||||||
605 | # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) | - | ||||||||||||||||||
606 | #endif | - | ||||||||||||||||||
607 | - | |||||||||||||||||||
608 | #ifndef YY_ATTRIBUTE_UNUSED | - | ||||||||||||||||||
609 | # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) | - | ||||||||||||||||||
610 | #endif | - | ||||||||||||||||||
611 | - | |||||||||||||||||||
612 | #if !defined _Noreturn \ | - | ||||||||||||||||||
613 | && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) | - | ||||||||||||||||||
614 | # if defined _MSC_VER && 1200 <= _MSC_VER | - | ||||||||||||||||||
615 | # define _Noreturn __declspec (noreturn) | - | ||||||||||||||||||
616 | # else | - | ||||||||||||||||||
617 | # define _Noreturn YY_ATTRIBUTE ((__noreturn__)) | - | ||||||||||||||||||
618 | # endif | - | ||||||||||||||||||
619 | #endif | - | ||||||||||||||||||
620 | - | |||||||||||||||||||
621 | /* Suppress unused-variable warnings by "using" E. */ | - | ||||||||||||||||||
622 | #if ! defined lint || defined __GNUC__ | - | ||||||||||||||||||
623 | # define YYUSE(E) ((void) (E)) | - | ||||||||||||||||||
624 | #else | - | ||||||||||||||||||
625 | # define YYUSE(E) /* empty */ | - | ||||||||||||||||||
626 | #endif | - | ||||||||||||||||||
627 | - | |||||||||||||||||||
628 | #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ | - | ||||||||||||||||||
629 | /* Suppress an incorrect diagnostic about yylval being uninitialized. */ | - | ||||||||||||||||||
630 | # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ | - | ||||||||||||||||||
631 | _Pragma ("GCC diagnostic push") \ | - | ||||||||||||||||||
632 | _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ | - | ||||||||||||||||||
633 | _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") | - | ||||||||||||||||||
634 | # define YY_IGNORE_MAYBE_UNINITIALIZED_END \ | - | ||||||||||||||||||
635 | _Pragma ("GCC diagnostic pop") | - | ||||||||||||||||||
636 | #else | - | ||||||||||||||||||
637 | # define YY_INITIAL_VALUE(Value) Value | - | ||||||||||||||||||
638 | #endif | - | ||||||||||||||||||
639 | #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN | - | ||||||||||||||||||
640 | # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN | - | ||||||||||||||||||
641 | # define YY_IGNORE_MAYBE_UNINITIALIZED_END | - | ||||||||||||||||||
642 | #endif | - | ||||||||||||||||||
643 | #ifndef YY_INITIAL_VALUE | - | ||||||||||||||||||
644 | # define YY_INITIAL_VALUE(Value) /* Nothing. */ | - | ||||||||||||||||||
645 | #endif | - | ||||||||||||||||||
646 | - | |||||||||||||||||||
647 | - | |||||||||||||||||||
648 | #if ! defined yyoverflow || YYERROR_VERBOSE | - | ||||||||||||||||||
649 | - | |||||||||||||||||||
650 | /* The parser invokes alloca or malloc; define the necessary symbols. */ | - | ||||||||||||||||||
651 | - | |||||||||||||||||||
652 | # ifdef YYSTACK_USE_ALLOCA | - | ||||||||||||||||||
653 | # if YYSTACK_USE_ALLOCA | - | ||||||||||||||||||
654 | # ifdef __GNUC__ | - | ||||||||||||||||||
655 | # define YYSTACK_ALLOC __builtin_alloca | - | ||||||||||||||||||
656 | # elif defined __BUILTIN_VA_ARG_INCR | - | ||||||||||||||||||
657 | # include <alloca.h> /* INFRINGES ON USER NAME SPACE */ | - | ||||||||||||||||||
658 | # elif defined _AIX | - | ||||||||||||||||||
659 | # define YYSTACK_ALLOC __alloca | - | ||||||||||||||||||
660 | # elif defined _MSC_VER | - | ||||||||||||||||||
661 | # include <malloc.h> /* INFRINGES ON USER NAME SPACE */ | - | ||||||||||||||||||
662 | # define alloca _alloca | - | ||||||||||||||||||
663 | # else | - | ||||||||||||||||||
664 | # define YYSTACK_ALLOC alloca | - | ||||||||||||||||||
665 | # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS | - | ||||||||||||||||||
666 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ | - | ||||||||||||||||||
667 | /* Use EXIT_SUCCESS as a witness for stdlib.h. */ | - | ||||||||||||||||||
668 | # ifndef EXIT_SUCCESS | - | ||||||||||||||||||
669 | # define EXIT_SUCCESS 0 | - | ||||||||||||||||||
670 | # endif | - | ||||||||||||||||||
671 | # endif | - | ||||||||||||||||||
672 | # endif | - | ||||||||||||||||||
673 | # endif | - | ||||||||||||||||||
674 | # endif | - | ||||||||||||||||||
675 | - | |||||||||||||||||||
676 | # ifdef YYSTACK_ALLOC | - | ||||||||||||||||||
677 | /* Pacify GCC's 'empty if-body' warning. */ | - | ||||||||||||||||||
678 | # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) | - | ||||||||||||||||||
679 | # ifndef YYSTACK_ALLOC_MAXIMUM | - | ||||||||||||||||||
680 | /* The OS might guarantee only one guard page at the bottom of the stack, | - | ||||||||||||||||||
681 | and a page size can be as small as 4096 bytes. So we cannot safely | - | ||||||||||||||||||
682 | invoke alloca (N) if N exceeds 4096. Use a slightly smaller number | - | ||||||||||||||||||
683 | to allow for a few compiler-allocated temporary stack slots. */ | - | ||||||||||||||||||
684 | # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ | - | ||||||||||||||||||
685 | # endif | - | ||||||||||||||||||
686 | # else | - | ||||||||||||||||||
687 | # define YYSTACK_ALLOC YYMALLOC | - | ||||||||||||||||||
688 | # define YYSTACK_FREE YYFREE | - | ||||||||||||||||||
689 | # ifndef YYSTACK_ALLOC_MAXIMUM | - | ||||||||||||||||||
690 | # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM | - | ||||||||||||||||||
691 | # endif | - | ||||||||||||||||||
692 | # if (defined __cplusplus && ! defined EXIT_SUCCESS \ | - | ||||||||||||||||||
693 | && ! ((defined YYMALLOC || defined malloc) \ | - | ||||||||||||||||||
694 | && (defined YYFREE || defined free))) | - | ||||||||||||||||||
695 | # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ | - | ||||||||||||||||||
696 | # ifndef EXIT_SUCCESS | - | ||||||||||||||||||
697 | # define EXIT_SUCCESS 0 | - | ||||||||||||||||||
698 | # endif | - | ||||||||||||||||||
699 | # endif | - | ||||||||||||||||||
700 | # ifndef YYMALLOC | - | ||||||||||||||||||
701 | # define YYMALLOC malloc | - | ||||||||||||||||||
702 | # if ! defined malloc && ! defined EXIT_SUCCESS | - | ||||||||||||||||||
703 | void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ | - | ||||||||||||||||||
704 | # endif | - | ||||||||||||||||||
705 | # endif | - | ||||||||||||||||||
706 | # ifndef YYFREE | - | ||||||||||||||||||
707 | # define YYFREE free | - | ||||||||||||||||||
708 | # if ! defined free && ! defined EXIT_SUCCESS | - | ||||||||||||||||||
709 | void free (void *); /* INFRINGES ON USER NAME SPACE */ | - | ||||||||||||||||||
710 | # endif | - | ||||||||||||||||||
711 | # endif | - | ||||||||||||||||||
712 | # endif | - | ||||||||||||||||||
713 | #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ | - | ||||||||||||||||||
714 | - | |||||||||||||||||||
715 | - | |||||||||||||||||||
716 | #if (! defined yyoverflow \ | - | ||||||||||||||||||
717 | && (! defined __cplusplus \ | - | ||||||||||||||||||
718 | || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) | - | ||||||||||||||||||
719 | - | |||||||||||||||||||
720 | /* A type that is properly aligned for any stack member. */ | - | ||||||||||||||||||
721 | union yyalloc | - | ||||||||||||||||||
722 | { | - | ||||||||||||||||||
723 | yytype_int16 yyss_alloc; | - | ||||||||||||||||||
724 | YYSTYPE yyvs_alloc; | - | ||||||||||||||||||
725 | }; | - | ||||||||||||||||||
726 | - | |||||||||||||||||||
727 | /* The size of the maximum gap between one aligned stack and the next. */ | - | ||||||||||||||||||
728 | # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) | - | ||||||||||||||||||
729 | - | |||||||||||||||||||
730 | /* The size of an array large to enough to hold all stacks, each with | - | ||||||||||||||||||
731 | N elements. */ | - | ||||||||||||||||||
732 | # define YYSTACK_BYTES(N) \ | - | ||||||||||||||||||
733 | ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ | - | ||||||||||||||||||
734 | + YYSTACK_GAP_MAXIMUM) | - | ||||||||||||||||||
735 | - | |||||||||||||||||||
736 | # define YYCOPY_NEEDED 1 | - | ||||||||||||||||||
737 | - | |||||||||||||||||||
738 | /* Relocate STACK from its old location to the new one. The | - | ||||||||||||||||||
739 | local variables YYSIZE and YYSTACKSIZE give the old and new number of | - | ||||||||||||||||||
740 | elements in the stack, and YYPTR gives the new location of the | - | ||||||||||||||||||
741 | stack. Advance YYPTR to a properly aligned location for the next | - | ||||||||||||||||||
742 | stack. */ | - | ||||||||||||||||||
743 | # define YYSTACK_RELOCATE(Stack_alloc, Stack) \ | - | ||||||||||||||||||
744 | do \ | - | ||||||||||||||||||
745 | { \ | - | ||||||||||||||||||
746 | YYSIZE_T yynewbytes; \ | - | ||||||||||||||||||
747 | YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ | - | ||||||||||||||||||
748 | Stack = &yyptr->Stack_alloc; \ | - | ||||||||||||||||||
749 | yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ | - | ||||||||||||||||||
750 | yyptr += yynewbytes / sizeof (*yyptr); \ | - | ||||||||||||||||||
751 | } \ | - | ||||||||||||||||||
752 | while (0) | - | ||||||||||||||||||
753 | - | |||||||||||||||||||
754 | #endif | - | ||||||||||||||||||
755 | - | |||||||||||||||||||
756 | #if defined YYCOPY_NEEDED && YYCOPY_NEEDED | - | ||||||||||||||||||
757 | /* Copy COUNT objects from SRC to DST. The source and destination do | - | ||||||||||||||||||
758 | not overlap. */ | - | ||||||||||||||||||
759 | # ifndef YYCOPY | - | ||||||||||||||||||
760 | # if defined __GNUC__ && 1 < __GNUC__ | - | ||||||||||||||||||
761 | # define YYCOPY(Dst, Src, Count) \ | - | ||||||||||||||||||
762 | __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) | - | ||||||||||||||||||
763 | # else | - | ||||||||||||||||||
764 | # define YYCOPY(Dst, Src, Count) \ | - | ||||||||||||||||||
765 | do \ | - | ||||||||||||||||||
766 | { \ | - | ||||||||||||||||||
767 | YYSIZE_T yyi; \ | - | ||||||||||||||||||
768 | for (yyi = 0; yyi < (Count); yyi++) \ | - | ||||||||||||||||||
769 | (Dst)[yyi] = (Src)[yyi]; \ | - | ||||||||||||||||||
770 | } \ | - | ||||||||||||||||||
771 | while (0) | - | ||||||||||||||||||
772 | # endif | - | ||||||||||||||||||
773 | # endif | - | ||||||||||||||||||
774 | #endif /* !YYCOPY_NEEDED */ | - | ||||||||||||||||||
775 | - | |||||||||||||||||||
776 | /* YYFINAL -- State number of the termination state. */ | - | ||||||||||||||||||
777 | #define YYFINAL 117 | - | ||||||||||||||||||
778 | /* YYLAST -- Last index in YYTABLE. */ | - | ||||||||||||||||||
779 | #define YYLAST 609 | - | ||||||||||||||||||
780 | - | |||||||||||||||||||
781 | /* YYNTOKENS -- Number of terminals. */ | - | ||||||||||||||||||
782 | #define YYNTOKENS 61 | - | ||||||||||||||||||
783 | /* YYNNTS -- Number of nonterminals. */ | - | ||||||||||||||||||
784 | #define YYNNTS 38 | - | ||||||||||||||||||
785 | /* YYNRULES -- Number of rules. */ | - | ||||||||||||||||||
786 | #define YYNRULES 168 | - | ||||||||||||||||||
787 | /* YYNSTATES -- Number of states. */ | - | ||||||||||||||||||
788 | #define YYNSTATES 335 | - | ||||||||||||||||||
789 | - | |||||||||||||||||||
790 | /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned | - | ||||||||||||||||||
791 | by yylex, with out-of-bounds checking. */ | - | ||||||||||||||||||
792 | #define YYUNDEFTOK 2 | - | ||||||||||||||||||
793 | #define YYMAXUTOK 304 | - | ||||||||||||||||||
794 | - | |||||||||||||||||||
795 | #define YYTRANSLATE(YYX) \ | - | ||||||||||||||||||
796 | ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) | - | ||||||||||||||||||
797 | - | |||||||||||||||||||
798 | /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM | - | ||||||||||||||||||
799 | as returned by yylex, without out-of-bounds checking. */ | - | ||||||||||||||||||
800 | static const yytype_uint8 yytranslate[] = | - | ||||||||||||||||||
801 | { | - | ||||||||||||||||||
802 | 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, | - | ||||||||||||||||||
803 | 51, 2, 2, 2, 2, 2, 2, 2, 2, 2, | - | ||||||||||||||||||
804 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | - | ||||||||||||||||||
805 | 2, 2, 2, 2, 2, 2, 2, 2, 49, 2, | - | ||||||||||||||||||
806 | 59, 60, 2, 2, 2, 56, 2, 2, 2, 2, | - | ||||||||||||||||||
807 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 50, | - | ||||||||||||||||||
808 | 55, 2, 54, 2, 2, 2, 2, 2, 2, 2, | - | ||||||||||||||||||
809 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | - | ||||||||||||||||||
810 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | - | ||||||||||||||||||
811 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | - | ||||||||||||||||||
812 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | - | ||||||||||||||||||
813 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | - | ||||||||||||||||||
814 | 2, 2, 2, 57, 53, 58, 2, 2, 2, 2, | - | ||||||||||||||||||
815 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | - | ||||||||||||||||||
816 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | - | ||||||||||||||||||
817 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | - | ||||||||||||||||||
818 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | - | ||||||||||||||||||
819 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | - | ||||||||||||||||||
820 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | - | ||||||||||||||||||
821 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | - | ||||||||||||||||||
822 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | - | ||||||||||||||||||
823 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | - | ||||||||||||||||||
824 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | - | ||||||||||||||||||
825 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | - | ||||||||||||||||||
826 | 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | - | ||||||||||||||||||
827 | 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, | - | ||||||||||||||||||
828 | 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, | - | ||||||||||||||||||
829 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, | - | ||||||||||||||||||
830 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, | - | ||||||||||||||||||
831 | 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, | - | ||||||||||||||||||
832 | 45, 46, 47, 48, 52 | - | ||||||||||||||||||
833 | }; | - | ||||||||||||||||||
834 | - | |||||||||||||||||||
835 | #if YYDEBUG | - | ||||||||||||||||||
836 | /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ | - | ||||||||||||||||||
837 | static const yytype_uint16 yyrline[] = | - | ||||||||||||||||||
838 | { | - | ||||||||||||||||||
839 | 0, 381, 381, 392, 401, 416, 432, 442, 444, 448, | - | ||||||||||||||||||
840 | 454, 460, 466, 472, 478, 484, 490, 496, 502, 508, | - | ||||||||||||||||||
841 | 514, 520, 526, 532, 538, 545, 552, 559, 566, 573, | - | ||||||||||||||||||
842 | 580, 586, 592, 598, 604, 610, 616, 622, 628, 634, | - | ||||||||||||||||||
843 | 640, 646, 652, 658, 664, 670, 676, 682, 688, 694, | - | ||||||||||||||||||
844 | 700, 706, 712, 720, 722, 724, 728, 732, 743, 745, | - | ||||||||||||||||||
845 | 749, 751, 753, 769, 771, 775, 777, 779, 781, 783, | - | ||||||||||||||||||
846 | 785, 787, 789, 791, 793, 795, 799, 804, 809, 814, | - | ||||||||||||||||||
847 | 819, 824, 829, 834, 841, 847, 853, 859, 867, 872, | - | ||||||||||||||||||
848 | 877, 882, 887, 892, 899, 904, 909, 916, 919, 922, | - | ||||||||||||||||||
849 | 926, 928, 959, 966, 971, 988, 993, 1010, 1017, 1019, | - | ||||||||||||||||||
850 | 1021, 1026, 1030, 1034, 1038, 1040, 1042, 1046, 1047, 1051, | - | ||||||||||||||||||
851 | 1053, 1055, 1057, 1061, 1063, 1065, 1067, 1069, 1071, 1075, | - | ||||||||||||||||||
852 | 1077, 1086, 1094, 1095, 1101, 1102, 1109, 1113, 1115, 1117, | - | ||||||||||||||||||
853 | 1124, 1126, 1128, 1132, 1133, 1136, 1138, 1140, 1144, 1145, | - | ||||||||||||||||||
854 | 1154, 1167, 1183, 1198, 1200, 1202, 1209, 1212, 1216, 1218, | - | ||||||||||||||||||
855 | 1224, 1230, 1250, 1273, 1275, 1298, 1302, 1304, 1306 | - | ||||||||||||||||||
856 | }; | - | ||||||||||||||||||
857 | #endif | - | ||||||||||||||||||
858 | - | |||||||||||||||||||
859 | #if YYDEBUG || YYERROR_VERBOSE || 0 | - | ||||||||||||||||||
860 | /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. | - | ||||||||||||||||||
861 | First, the terminals, then, starting at YYNTOKENS, nonterminals. */ | - | ||||||||||||||||||
862 | static const char *const yytname[] = | - | ||||||||||||||||||
863 | { | - | ||||||||||||||||||
864 | "$end", "error", "$undefined", "IF", "THEN", "ELSE", "ELIF", "FI", | - | ||||||||||||||||||
865 | "CASE", "ESAC", "FOR", "SELECT", "WHILE", "UNTIL", "DO", "DONE", | - | ||||||||||||||||||
866 | "FUNCTION", "COPROC", "COND_START", "COND_END", "COND_ERROR", "IN", | - | ||||||||||||||||||
867 | "BANG", "TIME", "TIMEOPT", "TIMEIGN", "WORD", "ASSIGNMENT_WORD", | - | ||||||||||||||||||
868 | "REDIR_WORD", "NUMBER", "ARITH_CMD", "ARITH_FOR_EXPRS", "COND_CMD", | - | ||||||||||||||||||
869 | "AND_AND", "OR_OR", "GREATER_GREATER", "LESS_LESS", "LESS_AND", | - | ||||||||||||||||||
870 | "LESS_LESS_LESS", "GREATER_AND", "SEMI_SEMI", "SEMI_AND", | - | ||||||||||||||||||
871 | "SEMI_SEMI_AND", "LESS_LESS_MINUS", "AND_GREATER", "AND_GREATER_GREATER", | - | ||||||||||||||||||
872 | "LESS_GREATER", "GREATER_BAR", "BAR_AND", "'&'", "';'", "'\\n'", | - | ||||||||||||||||||
873 | "yacc_EOF", "'|'", "'>'", "'<'", "'-'", "'{'", "'}'", "'('", "')'", | - | ||||||||||||||||||
874 | "$accept", "inputunit", "word_list", "redirection", | - | ||||||||||||||||||
875 | "simple_command_element", "redirection_list", "simple_command", | - | ||||||||||||||||||
876 | "command", "shell_command", "for_command", "arith_for_command", | - | ||||||||||||||||||
877 | "select_command", "case_command", "function_def", "function_body", | - | ||||||||||||||||||
878 | "subshell", "coproc", "if_command", "group_command", "arith_command", | - | ||||||||||||||||||
879 | "cond_command", "elif_clause", "case_clause", "pattern_list", | - | ||||||||||||||||||
880 | "case_clause_sequence", "pattern", "list", "compound_list", "list0", | - | ||||||||||||||||||
881 | "list1", "simple_list_terminator", "list_terminator", "newline_list", | - | ||||||||||||||||||
882 | "simple_list", "simple_list1", "pipeline_command", "pipeline", | - | ||||||||||||||||||
883 | "timespec", YY_NULLPTR | - | ||||||||||||||||||
884 | }; | - | ||||||||||||||||||
885 | #endif | - | ||||||||||||||||||
886 | - | |||||||||||||||||||
887 | # ifdef YYPRINT | - | ||||||||||||||||||
888 | /* YYTOKNUM[NUM] -- (External) token number corresponding to the | - | ||||||||||||||||||
889 | (internal) symbol number NUM (which must be that of a token). */ | - | ||||||||||||||||||
890 | static const yytype_uint16 yytoknum[] = | - | ||||||||||||||||||
891 | { | - | ||||||||||||||||||
892 | 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, | - | ||||||||||||||||||
893 | 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, | - | ||||||||||||||||||
894 | 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, | - | ||||||||||||||||||
895 | 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, | - | ||||||||||||||||||
896 | 295, 296, 297, 298, 299, 300, 301, 302, 303, 38, | - | ||||||||||||||||||
897 | 59, 10, 304, 124, 62, 60, 45, 123, 125, 40, | - | ||||||||||||||||||
898 | 41 | - | ||||||||||||||||||
899 | }; | - | ||||||||||||||||||
900 | # endif | - | ||||||||||||||||||
901 | - | |||||||||||||||||||
902 | #define YYPACT_NINF -203 | - | ||||||||||||||||||
903 | - | |||||||||||||||||||
904 | #define yypact_value_is_default(Yystate) \ | - | ||||||||||||||||||
905 | (!!((Yystate) == (-203))) | - | ||||||||||||||||||
906 | - | |||||||||||||||||||
907 | #define YYTABLE_NINF -1 | - | ||||||||||||||||||
908 | - | |||||||||||||||||||
909 | #define yytable_value_is_error(Yytable_value) \ | - | ||||||||||||||||||
910 | 0 | - | ||||||||||||||||||
911 | - | |||||||||||||||||||
912 | /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing | - | ||||||||||||||||||
913 | STATE-NUM. */ | - | ||||||||||||||||||
914 | static const yytype_int16 yypact[] = | - | ||||||||||||||||||
915 | { | - | ||||||||||||||||||
916 | 309, -2, -203, -20, 2, 3, -203, -203, 5, 509, | - | ||||||||||||||||||
917 | 31, 359, 45, 33, -203, 252, 554, -203, 76, 102, | - | ||||||||||||||||||
918 | -8, 105, 131, 108, 128, 152, 157, 162, -203, -203, | - | ||||||||||||||||||
919 | 169, 174, -203, -203, 107, -203, -203, 229, -203, 541, | - | ||||||||||||||||||
920 | -203, -203, -203, -203, -203, -203, -203, -203, -203, -203, | - | ||||||||||||||||||
921 | -203, 61, 244, -203, -28, 359, -203, -203, -203, 200, | - | ||||||||||||||||||
922 | 29, -203, 163, 48, 167, 193, 218, 181, 223, 229, | - | ||||||||||||||||||
923 | 541, 233, -203, -203, -203, -203, -203, 217, 203, 243, | - | ||||||||||||||||||
924 | 253, 145, 255, 146, 277, 279, 285, 287, 292, 297, | - | ||||||||||||||||||
925 | 298, 164, 302, 198, 303, 304, 307, 308, 314, -203, | - | ||||||||||||||||||
926 | -203, -203, -203, -203, -203, -203, -203, -203, -203, -203, | - | ||||||||||||||||||
927 | -203, -203, -203, -203, -203, 228, 281, -203, -203, -203, | - | ||||||||||||||||||
928 | -203, 541, -203, -203, -203, -203, -203, 409, 409, -203, | - | ||||||||||||||||||
929 | -203, -203, -203, -203, -203, -203, 210, -203, -13, -203, | - | ||||||||||||||||||
930 | 87, -203, -203, -203, -203, 148, -203, -203, 282, 155, | - | ||||||||||||||||||
931 | 541, 541, -203, -203, -203, -203, -203, -203, -203, -203, | - | ||||||||||||||||||
932 | -203, -203, -203, -203, -203, -203, -203, -203, -203, -203, | - | ||||||||||||||||||
933 | -203, -203, -203, -203, -203, -203, -203, -203, -203, -203, | - | ||||||||||||||||||
934 | -203, -203, -203, -203, -203, -203, 29, 29, 20, 20, | - | ||||||||||||||||||
935 | 459, 459, 104, -203, -203, -203, -203, -203, -203, 46, | - | ||||||||||||||||||
936 | -203, 68, -203, 328, 291, 75, 119, -203, 324, -203, | - | ||||||||||||||||||
937 | 336, 342, -203, 541, -203, 541, 155, -203, -203, -28, | - | ||||||||||||||||||
938 | -28, -203, -203, -203, 351, 29, 29, 29, 29, 29, | - | ||||||||||||||||||
939 | 350, 81, -203, 78, -203, -203, 358, -203, 197, -203, | - | ||||||||||||||||||
940 | 316, -203, -203, -203, -203, -203, -203, 363, 29, 197, | - | ||||||||||||||||||
941 | 321, -203, -203, 155, 541, -203, 373, 361, -203, -203, | - | ||||||||||||||||||
942 | -203, 91, 91, 91, -203, -203, -203, -203, 260, 130, | - | ||||||||||||||||||
943 | -203, -203, 357, -38, 369, 332, -203, -203, -203, 129, | - | ||||||||||||||||||
944 | -203, 376, 334, 378, 341, -203, 210, -203, -203, -203, | - | ||||||||||||||||||
945 | -203, -203, -203, -203, -203, -203, -30, 374, -203, -203, | - | ||||||||||||||||||
946 | -203, 168, -203, -203, -203, -203, -203, -203, 194, 216, | - | ||||||||||||||||||
947 | -203, -203, -203, 29, -203, -203, 386, 349, -203, -203, | - | ||||||||||||||||||
948 | -203, -203, -203, 29, 393, 365, -203, -203, 400, 366, | - | ||||||||||||||||||
949 | -203, -203, -203, -203, -203 | - | ||||||||||||||||||
950 | }; | - | ||||||||||||||||||
951 | - | |||||||||||||||||||
952 | /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. | - | ||||||||||||||||||
953 | Performed when YYTABLE does not specify something else to do. Zero | - | ||||||||||||||||||
954 | means the default is an error. */ | - | ||||||||||||||||||
955 | static const yytype_uint8 yydefact[] = | - | ||||||||||||||||||
956 | { | - | ||||||||||||||||||
957 | 0, 0, 148, 0, 0, 0, 148, 148, 0, 0, | - | ||||||||||||||||||
958 | 0, 0, 166, 53, 54, 0, 0, 112, 0, 0, | - | ||||||||||||||||||
959 | 0, 0, 0, 0, 0, 0, 0, 0, 3, 6, | - | ||||||||||||||||||
960 | 0, 0, 148, 148, 0, 55, 58, 60, 165, 61, | - | ||||||||||||||||||
961 | 65, 75, 69, 66, 63, 71, 64, 70, 72, 73, | - | ||||||||||||||||||
962 | 74, 0, 150, 157, 158, 0, 4, 5, 132, 0, | - | ||||||||||||||||||
963 | 0, 148, 148, 0, 148, 0, 0, 148, 53, 107, | - | ||||||||||||||||||
964 | 103, 0, 146, 145, 147, 162, 159, 167, 0, 0, | - | ||||||||||||||||||
965 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | - | ||||||||||||||||||
966 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, | - | ||||||||||||||||||
967 | 24, 39, 33, 48, 30, 42, 36, 45, 27, 51, | - | ||||||||||||||||||
968 | 52, 21, 18, 9, 10, 0, 0, 1, 53, 59, | - | ||||||||||||||||||
969 | 56, 62, 143, 144, 2, 148, 148, 151, 152, 148, | - | ||||||||||||||||||
970 | 148, 161, 160, 148, 149, 131, 133, 142, 0, 148, | - | ||||||||||||||||||
971 | 0, 148, 148, 148, 148, 0, 148, 148, 0, 0, | - | ||||||||||||||||||
972 | 105, 104, 113, 168, 148, 17, 26, 41, 35, 50, | - | ||||||||||||||||||
973 | 32, 44, 38, 47, 29, 23, 20, 13, 14, 16, | - | ||||||||||||||||||
974 | 25, 40, 34, 49, 31, 43, 37, 46, 28, 22, | - | ||||||||||||||||||
975 | 19, 11, 12, 111, 102, 57, 0, 0, 155, 156, | - | ||||||||||||||||||
976 | 0, 0, 0, 148, 148, 148, 148, 148, 148, 0, | - | ||||||||||||||||||
977 | 148, 0, 148, 0, 0, 0, 0, 148, 0, 148, | - | ||||||||||||||||||
978 | 0, 0, 148, 100, 99, 106, 0, 153, 154, 164, | - | ||||||||||||||||||
979 | 163, 148, 148, 108, 0, 0, 0, 135, 136, 134, | - | ||||||||||||||||||
980 | 0, 117, 148, 0, 148, 148, 0, 7, 0, 148, | - | ||||||||||||||||||
981 | 0, 86, 87, 148, 148, 148, 148, 0, 0, 0, | - | ||||||||||||||||||
982 | 0, 67, 68, 0, 101, 97, 0, 0, 110, 137, | - | ||||||||||||||||||
983 | 138, 139, 140, 141, 96, 123, 125, 127, 118, 0, | - | ||||||||||||||||||
984 | 94, 129, 0, 0, 0, 0, 76, 8, 148, 0, | - | ||||||||||||||||||
985 | 77, 0, 0, 0, 0, 88, 0, 148, 89, 98, | - | ||||||||||||||||||
986 | 109, 148, 124, 126, 128, 95, 0, 0, 148, 78, | - | ||||||||||||||||||
987 | 79, 0, 148, 148, 84, 85, 90, 91, 0, 114, | - | ||||||||||||||||||
988 | 148, 130, 119, 120, 148, 148, 0, 0, 148, 148, | - | ||||||||||||||||||
989 | 148, 116, 121, 122, 0, 0, 82, 83, 0, 0, | - | ||||||||||||||||||
990 | 115, 80, 81, 92, 93 | - | ||||||||||||||||||
991 | }; | - | ||||||||||||||||||
992 | - | |||||||||||||||||||
993 | /* YYPGOTO[NTERM-NUM]. */ | - | ||||||||||||||||||
994 | static const yytype_int16 yypgoto[] = | - | ||||||||||||||||||
995 | { | - | ||||||||||||||||||
996 | -203, -203, 220, -36, -33, -60, 420, -203, -7, -203, | - | ||||||||||||||||||
997 | -203, -203, -203, -203, -123, -203, -203, -203, -203, -203, | - | ||||||||||||||||||
998 | -203, 121, -203, 201, -203, 170, -202, -6, -203, 232, | - | ||||||||||||||||||
999 | -203, -46, -48, -203, -116, 24, 125, -203 | - | ||||||||||||||||||
1000 | }; | - | ||||||||||||||||||
1001 | - | |||||||||||||||||||
1002 | /* YYDEFGOTO[NTERM-NUM]. */ | - | ||||||||||||||||||
1003 | static const yytype_int16 yydefgoto[] = | - | ||||||||||||||||||
1004 | { | - | ||||||||||||||||||
1005 | -1, 34, 238, 35, 36, 121, 37, 38, 39, 40, | - | ||||||||||||||||||
1006 | 41, 42, 43, 44, 214, 45, 46, 47, 48, 49, | - | ||||||||||||||||||
1007 | 50, 224, 230, 231, 232, 273, 58, 59, 135, 136, | - | ||||||||||||||||||
1008 | 124, 75, 60, 51, 52, 137, 54, 55 | - | ||||||||||||||||||
1009 | }; | - | ||||||||||||||||||
1010 | - | |||||||||||||||||||
1011 | /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If | - | ||||||||||||||||||
1012 | positive, shift that token. If negative, reduce the rule whose | - | ||||||||||||||||||
1013 | number is the opposite. If YYTABLE_NINF, syntax error. */ | - | ||||||||||||||||||
1014 | static const yytype_uint16 yytable[] = | - | ||||||||||||||||||
1015 | { | - | ||||||||||||||||||
1016 | 65, 66, 70, 120, 119, 247, 61, 250, 198, 131, | - | ||||||||||||||||||
1017 | 151, 188, 189, 138, 140, 297, 145, 143, 101, 149, | - | ||||||||||||||||||
1018 | 129, 102, 298, 297, 53, 130, 115, 116, 62, 64, | - | ||||||||||||||||||
1019 | 310, 67, 2, 63, 120, 76, 119, 3, 134, 4, | - | ||||||||||||||||||
1020 | 5, 6, 7, 283, 284, 8, 9, 10, 103, 56, | - | ||||||||||||||||||
1021 | 57, 11, 12, 125, 126, 13, 14, 15, 16, 17, | - | ||||||||||||||||||
1022 | 234, 150, 141, 71, 18, 19, 20, 21, 22, 77, | - | ||||||||||||||||||
1023 | 217, 218, 23, 24, 25, 26, 27, 186, 187, 132, | - | ||||||||||||||||||
1024 | 134, 190, 191, 30, 31, 185, 32, 270, 33, 243, | - | ||||||||||||||||||
1025 | 215, 199, 78, 255, 237, 205, 206, 134, 72, 73, | - | ||||||||||||||||||
1026 | 74, 200, 99, 235, 271, 142, 216, 117, 201, 221, | - | ||||||||||||||||||
1027 | 222, 223, 122, 123, 120, 185, 328, 329, 72, 73, | - | ||||||||||||||||||
1028 | 74, 265, 266, 267, 193, 194, 134, 192, 100, 134, | - | ||||||||||||||||||
1029 | 289, 104, 244, 245, 108, 203, 204, 272, 134, 295, | - | ||||||||||||||||||
1030 | 210, 211, 213, 302, 202, 225, 226, 227, 228, 229, | - | ||||||||||||||||||
1031 | 233, 53, 53, 254, 109, 239, 271, 105, 2, 248, | - | ||||||||||||||||||
1032 | 106, 248, 207, 3, 253, 4, 5, 6, 7, 208, | - | ||||||||||||||||||
1033 | 134, 157, 161, 10, 158, 162, 246, 120, 110, 185, | - | ||||||||||||||||||
1034 | 134, 134, 314, 111, 269, 17, 303, 107, 112, 272, | - | ||||||||||||||||||
1035 | 171, 279, 278, 172, 236, 113, 240, 248, 248, 134, | - | ||||||||||||||||||
1036 | 114, 159, 163, 287, 133, 209, 134, 146, 318, 213, | - | ||||||||||||||||||
1037 | 53, 53, 32, 139, 33, 256, 257, 144, 185, 134, | - | ||||||||||||||||||
1038 | 173, 320, 222, 277, 175, 315, 2, 176, 274, 275, | - | ||||||||||||||||||
1039 | 301, 3, 147, 4, 5, 6, 7, 281, 282, 308, | - | ||||||||||||||||||
1040 | 148, 10, 153, 193, 194, 134, 213, 72, 73, 74, | - | ||||||||||||||||||
1041 | 313, 319, 152, 17, 177, 118, 14, 15, 16, 195, | - | ||||||||||||||||||
1042 | 196, 197, 323, 154, 18, 19, 20, 21, 22, 155, | - | ||||||||||||||||||
1043 | 248, 248, 23, 24, 25, 26, 27, 125, 126, 156, | - | ||||||||||||||||||
1044 | 32, 160, 33, 30, 31, 309, 183, 79, 80, 81, | - | ||||||||||||||||||
1045 | 82, 83, 312, 127, 128, 84, 316, 317, 85, 86, | - | ||||||||||||||||||
1046 | 292, 293, 294, 164, 322, 165, 87, 88, 324, 325, | - | ||||||||||||||||||
1047 | 1, 166, 2, 167, 330, 219, 220, 3, 168, 4, | - | ||||||||||||||||||
1048 | 5, 6, 7, 169, 170, 8, 9, 10, 174, 178, | - | ||||||||||||||||||
1049 | 179, 11, 12, 180, 181, 13, 14, 15, 16, 17, | - | ||||||||||||||||||
1050 | 182, 184, 212, 241, 18, 19, 20, 21, 22, 242, | - | ||||||||||||||||||
1051 | 237, 251, 23, 24, 25, 26, 27, 252, 258, 264, | - | ||||||||||||||||||
1052 | 28, 29, 2, 30, 31, 291, 32, 3, 33, 4, | - | ||||||||||||||||||
1053 | 5, 6, 7, 276, 280, 8, 9, 10, 285, 288, | - | ||||||||||||||||||
1054 | 290, 11, 12, 271, 299, 13, 14, 15, 16, 17, | - | ||||||||||||||||||
1055 | 300, 304, 305, 306, 18, 19, 20, 21, 22, 307, | - | ||||||||||||||||||
1056 | 311, 326, 23, 24, 25, 26, 27, 327, 331, 72, | - | ||||||||||||||||||
1057 | 73, 74, 2, 30, 31, 333, 32, 3, 33, 4, | - | ||||||||||||||||||
1058 | 5, 6, 7, 332, 334, 8, 9, 10, 249, 69, | - | ||||||||||||||||||
1059 | 321, 11, 12, 268, 0, 13, 14, 15, 16, 17, | - | ||||||||||||||||||
1060 | 0, 0, 296, 0, 18, 19, 20, 21, 22, 0, | - | ||||||||||||||||||
1061 | 0, 0, 23, 24, 25, 26, 27, 259, 260, 261, | - | ||||||||||||||||||
1062 | 262, 263, 2, 30, 31, 0, 32, 3, 33, 4, | - | ||||||||||||||||||
1063 | 5, 6, 7, 0, 0, 8, 9, 10, 0, 0, | - | ||||||||||||||||||
1064 | 286, 0, 0, 0, 0, 13, 14, 15, 16, 17, | - | ||||||||||||||||||
1065 | 0, 0, 0, 0, 18, 19, 20, 21, 22, 0, | - | ||||||||||||||||||
1066 | 0, 0, 23, 24, 25, 26, 27, 0, 0, 0, | - | ||||||||||||||||||
1067 | 134, 0, 2, 30, 31, 0, 32, 3, 33, 4, | - | ||||||||||||||||||
1068 | 5, 6, 7, 0, 0, 0, 0, 10, 0, 0, | - | ||||||||||||||||||
1069 | 0, 0, 0, 0, 0, 68, 14, 15, 16, 17, | - | ||||||||||||||||||
1070 | 0, 0, 0, 0, 18, 19, 20, 21, 22, 0, | - | ||||||||||||||||||
1071 | 0, 0, 23, 24, 25, 26, 27, 0, 0, 0, | - | ||||||||||||||||||
1072 | 0, 0, 0, 30, 31, 0, 32, 0, 33, 15, | - | ||||||||||||||||||
1073 | 16, 0, 0, 0, 0, 0, 18, 19, 20, 21, | - | ||||||||||||||||||
1074 | 22, 0, 0, 0, 23, 24, 25, 26, 27, 89, | - | ||||||||||||||||||
1075 | 90, 91, 92, 93, 0, 30, 31, 94, 0, 0, | - | ||||||||||||||||||
1076 | 95, 96, 0, 0, 0, 0, 0, 0, 97, 98 | - | ||||||||||||||||||
1077 | }; | - | ||||||||||||||||||
1078 | - | |||||||||||||||||||
1079 | static const yytype_int16 yycheck[] = | - | ||||||||||||||||||
1080 | { | - | ||||||||||||||||||
1081 | 6, 7, 9, 39, 37, 207, 26, 209, 21, 55, | - | ||||||||||||||||||
1082 | 70, 127, 128, 61, 62, 53, 64, 63, 26, 67, | - | ||||||||||||||||||
1083 | 48, 29, 60, 53, 0, 53, 32, 33, 26, 26, | - | ||||||||||||||||||
1084 | 60, 26, 3, 31, 70, 11, 69, 8, 51, 10, | - | ||||||||||||||||||
1085 | 11, 12, 13, 245, 246, 16, 17, 18, 56, 51, | - | ||||||||||||||||||
1086 | 52, 22, 23, 33, 34, 26, 27, 28, 29, 30, | - | ||||||||||||||||||
1087 | 14, 68, 14, 32, 35, 36, 37, 38, 39, 24, | - | ||||||||||||||||||
1088 | 186, 187, 43, 44, 45, 46, 47, 125, 126, 55, | - | ||||||||||||||||||
1089 | 51, 129, 130, 54, 55, 121, 57, 9, 59, 14, | - | ||||||||||||||||||
1090 | 150, 139, 59, 216, 26, 143, 144, 51, 50, 51, | - | ||||||||||||||||||
1091 | 52, 14, 26, 57, 26, 57, 154, 0, 21, 5, | - | ||||||||||||||||||
1092 | 6, 7, 51, 52, 150, 151, 318, 319, 50, 51, | - | ||||||||||||||||||
1093 | 52, 40, 41, 42, 33, 34, 51, 133, 26, 51, | - | ||||||||||||||||||
1094 | 253, 26, 57, 14, 26, 141, 142, 59, 51, 9, | - | ||||||||||||||||||
1095 | 146, 147, 149, 14, 57, 193, 194, 195, 196, 197, | - | ||||||||||||||||||
1096 | 198, 127, 128, 213, 26, 201, 26, 26, 3, 207, | - | ||||||||||||||||||
1097 | 29, 209, 14, 8, 212, 10, 11, 12, 13, 21, | - | ||||||||||||||||||
1098 | 51, 26, 26, 18, 29, 29, 57, 213, 26, 215, | - | ||||||||||||||||||
1099 | 51, 51, 14, 26, 232, 30, 57, 56, 26, 59, | - | ||||||||||||||||||
1100 | 26, 239, 238, 29, 200, 26, 202, 245, 246, 51, | - | ||||||||||||||||||
1101 | 26, 56, 56, 249, 4, 57, 51, 14, 14, 216, | - | ||||||||||||||||||
1102 | 186, 187, 57, 50, 59, 221, 222, 50, 254, 51, | - | ||||||||||||||||||
1103 | 56, 5, 6, 26, 26, 57, 3, 29, 234, 235, | - | ||||||||||||||||||
1104 | 278, 8, 14, 10, 11, 12, 13, 243, 244, 287, | - | ||||||||||||||||||
1105 | 59, 18, 25, 33, 34, 51, 253, 50, 51, 52, | - | ||||||||||||||||||
1106 | 298, 57, 19, 30, 56, 26, 27, 28, 29, 49, | - | ||||||||||||||||||
1107 | 50, 51, 310, 60, 35, 36, 37, 38, 39, 26, | - | ||||||||||||||||||
1108 | 318, 319, 43, 44, 45, 46, 47, 33, 34, 26, | - | ||||||||||||||||||
1109 | 57, 26, 59, 54, 55, 291, 58, 35, 36, 37, | - | ||||||||||||||||||
1110 | 38, 39, 298, 49, 50, 43, 302, 303, 46, 47, | - | ||||||||||||||||||
1111 | 40, 41, 42, 26, 310, 26, 54, 55, 314, 315, | - | ||||||||||||||||||
1112 | 1, 26, 3, 26, 320, 190, 191, 8, 26, 10, | - | ||||||||||||||||||
1113 | 11, 12, 13, 26, 26, 16, 17, 18, 26, 26, | - | ||||||||||||||||||
1114 | 26, 22, 23, 26, 26, 26, 27, 28, 29, 30, | - | ||||||||||||||||||
1115 | 26, 60, 60, 15, 35, 36, 37, 38, 39, 58, | - | ||||||||||||||||||
1116 | 26, 15, 43, 44, 45, 46, 47, 15, 7, 9, | - | ||||||||||||||||||
1117 | 51, 52, 3, 54, 55, 4, 57, 8, 59, 10, | - | ||||||||||||||||||
1118 | 11, 12, 13, 15, 58, 16, 17, 18, 15, 58, | - | ||||||||||||||||||
1119 | 7, 22, 23, 26, 15, 26, 27, 28, 29, 30, | - | ||||||||||||||||||
1120 | 58, 15, 58, 15, 35, 36, 37, 38, 39, 58, | - | ||||||||||||||||||
1121 | 26, 15, 43, 44, 45, 46, 47, 58, 15, 50, | - | ||||||||||||||||||
1122 | 51, 52, 3, 54, 55, 15, 57, 8, 59, 10, | - | ||||||||||||||||||
1123 | 11, 12, 13, 58, 58, 16, 17, 18, 208, 9, | - | ||||||||||||||||||
1124 | 309, 22, 23, 232, -1, 26, 27, 28, 29, 30, | - | ||||||||||||||||||
1125 | -1, -1, 272, -1, 35, 36, 37, 38, 39, -1, | - | ||||||||||||||||||
1126 | -1, -1, 43, 44, 45, 46, 47, 225, 226, 227, | - | ||||||||||||||||||
1127 | 228, 229, 3, 54, 55, -1, 57, 8, 59, 10, | - | ||||||||||||||||||
1128 | 11, 12, 13, -1, -1, 16, 17, 18, -1, -1, | - | ||||||||||||||||||
1129 | 248, -1, -1, -1, -1, 26, 27, 28, 29, 30, | - | ||||||||||||||||||
1130 | -1, -1, -1, -1, 35, 36, 37, 38, 39, -1, | - | ||||||||||||||||||
1131 | -1, -1, 43, 44, 45, 46, 47, -1, -1, -1, | - | ||||||||||||||||||
1132 | 51, -1, 3, 54, 55, -1, 57, 8, 59, 10, | - | ||||||||||||||||||
1133 | 11, 12, 13, -1, -1, -1, -1, 18, -1, -1, | - | ||||||||||||||||||
1134 | -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, | - | ||||||||||||||||||
1135 | -1, -1, -1, -1, 35, 36, 37, 38, 39, -1, | - | ||||||||||||||||||
1136 | -1, -1, 43, 44, 45, 46, 47, -1, -1, -1, | - | ||||||||||||||||||
1137 | -1, -1, -1, 54, 55, -1, 57, -1, 59, 28, | - | ||||||||||||||||||
1138 | 29, -1, -1, -1, -1, -1, 35, 36, 37, 38, | - | ||||||||||||||||||
1139 | 39, -1, -1, -1, 43, 44, 45, 46, 47, 35, | - | ||||||||||||||||||
1140 | 36, 37, 38, 39, -1, 54, 55, 43, -1, -1, | - | ||||||||||||||||||
1141 | 46, 47, -1, -1, -1, -1, -1, -1, 54, 55 | - | ||||||||||||||||||
1142 | }; | - | ||||||||||||||||||
1143 | - | |||||||||||||||||||
1144 | /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing | - | ||||||||||||||||||
1145 | symbol of state STATE-NUM. */ | - | ||||||||||||||||||
1146 | static const yytype_uint8 yystos[] = | - | ||||||||||||||||||
1147 | { | - | ||||||||||||||||||
1148 | 0, 1, 3, 8, 10, 11, 12, 13, 16, 17, | - | ||||||||||||||||||
1149 | 18, 22, 23, 26, 27, 28, 29, 30, 35, 36, | - | ||||||||||||||||||
1150 | 37, 38, 39, 43, 44, 45, 46, 47, 51, 52, | - | ||||||||||||||||||
1151 | 54, 55, 57, 59, 62, 64, 65, 67, 68, 69, | - | ||||||||||||||||||
1152 | 70, 71, 72, 73, 74, 76, 77, 78, 79, 80, | - | ||||||||||||||||||
1153 | 81, 94, 95, 96, 97, 98, 51, 52, 87, 88, | - | ||||||||||||||||||
1154 | 93, 26, 26, 31, 26, 88, 88, 26, 26, 67, | - | ||||||||||||||||||
1155 | 69, 32, 50, 51, 52, 92, 96, 24, 59, 35, | - | ||||||||||||||||||
1156 | 36, 37, 38, 39, 43, 46, 47, 54, 55, 35, | - | ||||||||||||||||||
1157 | 36, 37, 38, 39, 43, 46, 47, 54, 55, 26, | - | ||||||||||||||||||
1158 | 26, 26, 29, 56, 26, 26, 29, 56, 26, 26, | - | ||||||||||||||||||
1159 | 26, 26, 26, 26, 26, 88, 88, 0, 26, 65, | - | ||||||||||||||||||
1160 | 64, 66, 51, 52, 91, 33, 34, 49, 50, 48, | - | ||||||||||||||||||
1161 | 53, 92, 96, 4, 51, 89, 90, 96, 93, 50, | - | ||||||||||||||||||
1162 | 93, 14, 57, 92, 50, 93, 14, 14, 59, 93, | - | ||||||||||||||||||
1163 | 69, 66, 19, 25, 60, 26, 26, 26, 29, 56, | - | ||||||||||||||||||
1164 | 26, 26, 29, 56, 26, 26, 26, 26, 26, 26, | - | ||||||||||||||||||
1165 | 26, 26, 29, 56, 26, 26, 29, 56, 26, 26, | - | ||||||||||||||||||
1166 | 26, 26, 26, 58, 60, 64, 93, 93, 95, 95, | - | ||||||||||||||||||
1167 | 93, 93, 88, 33, 34, 49, 50, 51, 21, 93, | - | ||||||||||||||||||
1168 | 14, 21, 57, 88, 88, 93, 93, 14, 21, 57, | - | ||||||||||||||||||
1169 | 88, 88, 60, 69, 75, 66, 93, 95, 95, 97, | - | ||||||||||||||||||
1170 | 97, 5, 6, 7, 82, 93, 93, 93, 93, 93, | - | ||||||||||||||||||
1171 | 83, 84, 85, 93, 14, 57, 88, 26, 63, 92, | - | ||||||||||||||||||
1172 | 88, 15, 58, 14, 57, 14, 57, 87, 93, 63, | - | ||||||||||||||||||
1173 | 87, 15, 15, 93, 66, 75, 88, 88, 7, 90, | - | ||||||||||||||||||
1174 | 90, 90, 90, 90, 9, 40, 41, 42, 84, 93, | - | ||||||||||||||||||
1175 | 9, 26, 59, 86, 88, 88, 15, 26, 92, 93, | - | ||||||||||||||||||
1176 | 58, 88, 88, 87, 87, 15, 90, 92, 58, 75, | - | ||||||||||||||||||
1177 | 7, 4, 40, 41, 42, 9, 86, 53, 60, 15, | - | ||||||||||||||||||
1178 | 58, 93, 14, 57, 15, 58, 15, 58, 93, 88, | - | ||||||||||||||||||
1179 | 60, 26, 88, 93, 14, 57, 88, 88, 14, 57, | - | ||||||||||||||||||
1180 | 5, 82, 88, 93, 88, 88, 15, 58, 87, 87, | - | ||||||||||||||||||
1181 | 88, 15, 58, 15, 58 | - | ||||||||||||||||||
1182 | }; | - | ||||||||||||||||||
1183 | - | |||||||||||||||||||
1184 | /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ | - | ||||||||||||||||||
1185 | static const yytype_uint8 yyr1[] = | - | ||||||||||||||||||
1186 | { | - | ||||||||||||||||||
1187 | 0, 61, 62, 62, 62, 62, 62, 63, 63, 64, | - | ||||||||||||||||||
1188 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, | - | ||||||||||||||||||
1189 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, | - | ||||||||||||||||||
1190 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, | - | ||||||||||||||||||
1191 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, | - | ||||||||||||||||||
1192 | 64, 64, 64, 65, 65, 65, 66, 66, 67, 67, | - | ||||||||||||||||||
1193 | 68, 68, 68, 68, 68, 69, 69, 69, 69, 69, | - | ||||||||||||||||||
1194 | 69, 69, 69, 69, 69, 69, 70, 70, 70, 70, | - | ||||||||||||||||||
1195 | 70, 70, 70, 70, 71, 71, 71, 71, 72, 72, | - | ||||||||||||||||||
1196 | 72, 72, 72, 72, 73, 73, 73, 74, 74, 74, | - | ||||||||||||||||||
1197 | 75, 75, 76, 77, 77, 77, 77, 77, 78, 78, | - | ||||||||||||||||||
1198 | 78, 79, 80, 81, 82, 82, 82, 83, 83, 84, | - | ||||||||||||||||||
1199 | 84, 84, 84, 85, 85, 85, 85, 85, 85, 86, | - | ||||||||||||||||||
1200 | 86, 87, 88, 88, 89, 89, 89, 90, 90, 90, | - | ||||||||||||||||||
1201 | 90, 90, 90, 91, 91, 92, 92, 92, 93, 93, | - | ||||||||||||||||||
1202 | 94, 94, 94, 95, 95, 95, 95, 95, 96, 96, | - | ||||||||||||||||||
1203 | 96, 96, 96, 97, 97, 97, 98, 98, 98 | - | ||||||||||||||||||
1204 | }; | - | ||||||||||||||||||
1205 | - | |||||||||||||||||||
1206 | /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ | - | ||||||||||||||||||
1207 | static const yytype_uint8 yyr2[] = | - | ||||||||||||||||||
1208 | { | - | ||||||||||||||||||
1209 | 0, 2, 2, 1, 2, 2, 1, 1, 2, 2, | - | ||||||||||||||||||
1210 | 2, 3, 3, 3, 3, 2, 3, 3, 2, 3, | - | ||||||||||||||||||
1211 | 3, 2, 3, 3, 2, 3, 3, 2, 3, 3, | - | ||||||||||||||||||
1212 | 2, 3, 3, 2, 3, 3, 2, 3, 3, 2, | - | ||||||||||||||||||
1213 | 3, 3, 2, 3, 3, 2, 3, 3, 2, 3, | - | ||||||||||||||||||
1214 | 3, 2, 2, 1, 1, 1, 1, 2, 1, 2, | - | ||||||||||||||||||
1215 | 1, 1, 2, 1, 1, 1, 1, 5, 5, 1, | - | ||||||||||||||||||
1216 | 1, 1, 1, 1, 1, 1, 6, 6, 7, 7, | - | ||||||||||||||||||
1217 | 10, 10, 9, 9, 7, 7, 5, 5, 6, 6, | - | ||||||||||||||||||
1218 | 7, 7, 10, 10, 6, 7, 6, 5, 6, 4, | - | ||||||||||||||||||
1219 | 1, 2, 3, 2, 3, 3, 4, 2, 5, 7, | - | ||||||||||||||||||
1220 | 6, 3, 1, 3, 4, 6, 5, 1, 2, 4, | - | ||||||||||||||||||
1221 | 4, 5, 5, 2, 3, 2, 3, 2, 3, 1, | - | ||||||||||||||||||
1222 | 3, 2, 1, 2, 3, 3, 3, 4, 4, 4, | - | ||||||||||||||||||
1223 | 4, 4, 1, 1, 1, 1, 1, 1, 0, 2, | - | ||||||||||||||||||
1224 | 1, 2, 2, 4, 4, 3, 3, 1, 1, 2, | - | ||||||||||||||||||
1225 | 2, 2, 2, 4, 4, 1, 1, 2, 3 | - | ||||||||||||||||||
1226 | }; | - | ||||||||||||||||||
1227 | - | |||||||||||||||||||
1228 | - | |||||||||||||||||||
1229 | #define yyerrok (yyerrstatus = 0) | - | ||||||||||||||||||
1230 | #define yyclearin (yychar = YYEMPTY) | - | ||||||||||||||||||
1231 | #define YYEMPTY (-2) | - | ||||||||||||||||||
1232 | #define YYEOF 0 | - | ||||||||||||||||||
1233 | - | |||||||||||||||||||
1234 | #define YYACCEPT goto yyacceptlab | - | ||||||||||||||||||
1235 | #define YYABORT goto yyabortlab | - | ||||||||||||||||||
1236 | #define YYERROR goto yyerrorlab | - | ||||||||||||||||||
1237 | - | |||||||||||||||||||
1238 | - | |||||||||||||||||||
1239 | #define YYRECOVERING() (!!yyerrstatus) | - | ||||||||||||||||||
1240 | - | |||||||||||||||||||
1241 | #define YYBACKUP(Token, Value) \ | - | ||||||||||||||||||
1242 | do \ | - | ||||||||||||||||||
1243 | if (yychar == YYEMPTY) \ | - | ||||||||||||||||||
1244 | { \ | - | ||||||||||||||||||
1245 | yychar = (Token); \ | - | ||||||||||||||||||
1246 | yylval = (Value); \ | - | ||||||||||||||||||
1247 | YYPOPSTACK (yylen); \ | - | ||||||||||||||||||
1248 | yystate = *yyssp; \ | - | ||||||||||||||||||
1249 | goto yybackup; \ | - | ||||||||||||||||||
1250 | } \ | - | ||||||||||||||||||
1251 | else \ | - | ||||||||||||||||||
1252 | { \ | - | ||||||||||||||||||
1253 | yyerror (YY_("syntax error: cannot back up")); \ | - | ||||||||||||||||||
1254 | YYERROR; \ | - | ||||||||||||||||||
1255 | } \ | - | ||||||||||||||||||
1256 | while (0) | - | ||||||||||||||||||
1257 | - | |||||||||||||||||||
1258 | /* Error token number */ | - | ||||||||||||||||||
1259 | #define YYTERROR 1 | - | ||||||||||||||||||
1260 | #define YYERRCODE 256 | - | ||||||||||||||||||
1261 | - | |||||||||||||||||||
1262 | - | |||||||||||||||||||
1263 | - | |||||||||||||||||||
1264 | /* Enable debugging if requested. */ | - | ||||||||||||||||||
1265 | #if YYDEBUG | - | ||||||||||||||||||
1266 | - | |||||||||||||||||||
1267 | # ifndef YYFPRINTF | - | ||||||||||||||||||
1268 | # include <stdio.h> /* INFRINGES ON USER NAME SPACE */ | - | ||||||||||||||||||
1269 | # define YYFPRINTF fprintf | - | ||||||||||||||||||
1270 | # endif | - | ||||||||||||||||||
1271 | - | |||||||||||||||||||
1272 | # define YYDPRINTF(Args) \ | - | ||||||||||||||||||
1273 | do { \ | - | ||||||||||||||||||
1274 | if (yydebug) \ | - | ||||||||||||||||||
1275 | YYFPRINTF Args; \ | - | ||||||||||||||||||
1276 | } while (0) | - | ||||||||||||||||||
1277 | - | |||||||||||||||||||
1278 | /* This macro is provided for backward compatibility. */ | - | ||||||||||||||||||
1279 | #ifndef YY_LOCATION_PRINT | - | ||||||||||||||||||
1280 | # define YY_LOCATION_PRINT(File, Loc) ((void) 0) | - | ||||||||||||||||||
1281 | #endif | - | ||||||||||||||||||
1282 | - | |||||||||||||||||||
1283 | - | |||||||||||||||||||
1284 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ | - | ||||||||||||||||||
1285 | do { \ | - | ||||||||||||||||||
1286 | if (yydebug) \ | - | ||||||||||||||||||
1287 | { \ | - | ||||||||||||||||||
1288 | YYFPRINTF (stderr, "%s ", Title); \ | - | ||||||||||||||||||
1289 | yy_symbol_print (stderr, \ | - | ||||||||||||||||||
1290 | Type, Value); \ | - | ||||||||||||||||||
1291 | YYFPRINTF (stderr, "\n"); \ | - | ||||||||||||||||||
1292 | } \ | - | ||||||||||||||||||
1293 | } while (0) | - | ||||||||||||||||||
1294 | - | |||||||||||||||||||
1295 | - | |||||||||||||||||||
1296 | /*----------------------------------------. | - | ||||||||||||||||||
1297 | | Print this symbol's value on YYOUTPUT. | | - | ||||||||||||||||||
1298 | `----------------------------------------*/ | - | ||||||||||||||||||
1299 | - | |||||||||||||||||||
1300 | static void | - | ||||||||||||||||||
1301 | yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) | - | ||||||||||||||||||
1302 | { | - | ||||||||||||||||||
1303 | FILE *yyo = yyoutput; | - | ||||||||||||||||||
1304 | YYUSE (yyo); | - | ||||||||||||||||||
1305 | if (!yyvaluep)
| 0 | ||||||||||||||||||
1306 | return; never executed: return; | 0 | ||||||||||||||||||
1307 | # ifdef YYPRINT | - | ||||||||||||||||||
1308 | if (yytype < YYNTOKENS) | - | ||||||||||||||||||
1309 | YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); | - | ||||||||||||||||||
1310 | # endif | - | ||||||||||||||||||
1311 | YYUSE (yytype); | - | ||||||||||||||||||
1312 | } never executed: end of block | 0 | ||||||||||||||||||
1313 | - | |||||||||||||||||||
1314 | - | |||||||||||||||||||
1315 | /*--------------------------------. | - | ||||||||||||||||||
1316 | | Print this symbol on YYOUTPUT. | | - | ||||||||||||||||||
1317 | `--------------------------------*/ | - | ||||||||||||||||||
1318 | - | |||||||||||||||||||
1319 | static void | - | ||||||||||||||||||
1320 | yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) | - | ||||||||||||||||||
1321 | { | - | ||||||||||||||||||
1322 | YYFPRINTF (yyoutput, "%s %s (", | - | ||||||||||||||||||
1323 | yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); | - | ||||||||||||||||||
1324 | - | |||||||||||||||||||
1325 | yy_symbol_value_print (yyoutput, yytype, yyvaluep); | - | ||||||||||||||||||
1326 | YYFPRINTF (yyoutput, ")"); | - | ||||||||||||||||||
1327 | } never executed: end of block | 0 | ||||||||||||||||||
1328 | - | |||||||||||||||||||
1329 | /*------------------------------------------------------------------. | - | ||||||||||||||||||
1330 | | yy_stack_print -- Print the state stack from its BOTTOM up to its | | - | ||||||||||||||||||
1331 | | TOP (included). | | - | ||||||||||||||||||
1332 | `------------------------------------------------------------------*/ | - | ||||||||||||||||||
1333 | - | |||||||||||||||||||
1334 | static void | - | ||||||||||||||||||
1335 | yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) | - | ||||||||||||||||||
1336 | { | - | ||||||||||||||||||
1337 | YYFPRINTF (stderr, "Stack now"); | - | ||||||||||||||||||
1338 | for (; yybottom <= yytop; yybottom++)
| 0 | ||||||||||||||||||
1339 | { | - | ||||||||||||||||||
1340 | int yybot = *yybottom; | - | ||||||||||||||||||
1341 | YYFPRINTF (stderr, " %d", yybot); | - | ||||||||||||||||||
1342 | } never executed: end of block | 0 | ||||||||||||||||||
1343 | YYFPRINTF (stderr, "\n"); | - | ||||||||||||||||||
1344 | } never executed: end of block | 0 | ||||||||||||||||||
1345 | - | |||||||||||||||||||
1346 | # define YY_STACK_PRINT(Bottom, Top) \ | - | ||||||||||||||||||
1347 | do { \ | - | ||||||||||||||||||
1348 | if (yydebug) \ | - | ||||||||||||||||||
1349 | yy_stack_print ((Bottom), (Top)); \ | - | ||||||||||||||||||
1350 | } while (0) | - | ||||||||||||||||||
1351 | - | |||||||||||||||||||
1352 | - | |||||||||||||||||||
1353 | /*------------------------------------------------. | - | ||||||||||||||||||
1354 | | Report that the YYRULE is going to be reduced. | | - | ||||||||||||||||||
1355 | `------------------------------------------------*/ | - | ||||||||||||||||||
1356 | - | |||||||||||||||||||
1357 | static void | - | ||||||||||||||||||
1358 | yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) | - | ||||||||||||||||||
1359 | { | - | ||||||||||||||||||
1360 | unsigned long int yylno = yyrline[yyrule]; | - | ||||||||||||||||||
1361 | int yynrhs = yyr2[yyrule]; | - | ||||||||||||||||||
1362 | int yyi; | - | ||||||||||||||||||
1363 | YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", | - | ||||||||||||||||||
1364 | yyrule - 1, yylno); | - | ||||||||||||||||||
1365 | /* The symbols being reduced. */ | - | ||||||||||||||||||
1366 | for (yyi = 0; yyi < yynrhs; yyi++)
| 0 | ||||||||||||||||||
1367 | { | - | ||||||||||||||||||
1368 | YYFPRINTF (stderr, " $%d = ", yyi + 1); | - | ||||||||||||||||||
1369 | yy_symbol_print (stderr, | - | ||||||||||||||||||
1370 | yystos[yyssp[yyi + 1 - yynrhs]], | - | ||||||||||||||||||
1371 | &(yyvsp[(yyi + 1) - (yynrhs)]) | - | ||||||||||||||||||
1372 | ); | - | ||||||||||||||||||
1373 | YYFPRINTF (stderr, "\n"); | - | ||||||||||||||||||
1374 | } never executed: end of block | 0 | ||||||||||||||||||
1375 | } never executed: end of block | 0 | ||||||||||||||||||
1376 | - | |||||||||||||||||||
1377 | # define YY_REDUCE_PRINT(Rule) \ | - | ||||||||||||||||||
1378 | do { \ | - | ||||||||||||||||||
1379 | if (yydebug) \ | - | ||||||||||||||||||
1380 | yy_reduce_print (yyssp, yyvsp, Rule); \ | - | ||||||||||||||||||
1381 | } while (0) | - | ||||||||||||||||||
1382 | - | |||||||||||||||||||
1383 | /* Nonzero means print parse trace. It is left uninitialized so that | - | ||||||||||||||||||
1384 | multiple parsers can coexist. */ | - | ||||||||||||||||||
1385 | int yydebug; | - | ||||||||||||||||||
1386 | #else /* !YYDEBUG */ | - | ||||||||||||||||||
1387 | # define YYDPRINTF(Args) | - | ||||||||||||||||||
1388 | # define YY_SYMBOL_PRINT(Title, Type, Value, Location) | - | ||||||||||||||||||
1389 | # define YY_STACK_PRINT(Bottom, Top) | - | ||||||||||||||||||
1390 | # define YY_REDUCE_PRINT(Rule) | - | ||||||||||||||||||
1391 | #endif /* !YYDEBUG */ | - | ||||||||||||||||||
1392 | - | |||||||||||||||||||
1393 | - | |||||||||||||||||||
1394 | /* YYINITDEPTH -- initial size of the parser's stacks. */ | - | ||||||||||||||||||
1395 | #ifndef YYINITDEPTH | - | ||||||||||||||||||
1396 | # define YYINITDEPTH 200 | - | ||||||||||||||||||
1397 | #endif | - | ||||||||||||||||||
1398 | - | |||||||||||||||||||
1399 | /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only | - | ||||||||||||||||||
1400 | if the built-in stack extension method is used). | - | ||||||||||||||||||
1401 | - | |||||||||||||||||||
1402 | Do not make this value too large; the results are undefined if | - | ||||||||||||||||||
1403 | YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) | - | ||||||||||||||||||
1404 | evaluated with infinite-precision integer arithmetic. */ | - | ||||||||||||||||||
1405 | - | |||||||||||||||||||
1406 | #ifndef YYMAXDEPTH | - | ||||||||||||||||||
1407 | # define YYMAXDEPTH 10000 | - | ||||||||||||||||||
1408 | #endif | - | ||||||||||||||||||
1409 | - | |||||||||||||||||||
1410 | - | |||||||||||||||||||
1411 | #if YYERROR_VERBOSE | - | ||||||||||||||||||
1412 | - | |||||||||||||||||||
1413 | # ifndef yystrlen | - | ||||||||||||||||||
1414 | # if defined __GLIBC__ && defined _STRING_H | - | ||||||||||||||||||
1415 | # define yystrlen strlen | - | ||||||||||||||||||
1416 | # else | - | ||||||||||||||||||
1417 | /* Return the length of YYSTR. */ | - | ||||||||||||||||||
1418 | static YYSIZE_T | - | ||||||||||||||||||
1419 | yystrlen (const char *yystr) | - | ||||||||||||||||||
1420 | { | - | ||||||||||||||||||
1421 | YYSIZE_T yylen; | - | ||||||||||||||||||
1422 | for (yylen = 0; yystr[yylen]; yylen++) | - | ||||||||||||||||||
1423 | continue; | - | ||||||||||||||||||
1424 | return yylen; | - | ||||||||||||||||||
1425 | } | - | ||||||||||||||||||
1426 | # endif | - | ||||||||||||||||||
1427 | # endif | - | ||||||||||||||||||
1428 | - | |||||||||||||||||||
1429 | # ifndef yystpcpy | - | ||||||||||||||||||
1430 | # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE | - | ||||||||||||||||||
1431 | # define yystpcpy stpcpy | - | ||||||||||||||||||
1432 | # else | - | ||||||||||||||||||
1433 | /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in | - | ||||||||||||||||||
1434 | YYDEST. */ | - | ||||||||||||||||||
1435 | static char * | - | ||||||||||||||||||
1436 | yystpcpy (char *yydest, const char *yysrc) | - | ||||||||||||||||||
1437 | { | - | ||||||||||||||||||
1438 | char *yyd = yydest; | - | ||||||||||||||||||
1439 | const char *yys = yysrc; | - | ||||||||||||||||||
1440 | - | |||||||||||||||||||
1441 | while ((*yyd++ = *yys++) != '\0') | - | ||||||||||||||||||
1442 | continue; | - | ||||||||||||||||||
1443 | - | |||||||||||||||||||
1444 | return yyd - 1; | - | ||||||||||||||||||
1445 | } | - | ||||||||||||||||||
1446 | # endif | - | ||||||||||||||||||
1447 | # endif | - | ||||||||||||||||||
1448 | - | |||||||||||||||||||
1449 | # ifndef yytnamerr | - | ||||||||||||||||||
1450 | /* Copy to YYRES the contents of YYSTR after stripping away unnecessary | - | ||||||||||||||||||
1451 | quotes and backslashes, so that it's suitable for yyerror. The | - | ||||||||||||||||||
1452 | heuristic is that double-quoting is unnecessary unless the string | - | ||||||||||||||||||
1453 | contains an apostrophe, a comma, or backslash (other than | - | ||||||||||||||||||
1454 | backslash-backslash). YYSTR is taken from yytname. If YYRES is | - | ||||||||||||||||||
1455 | null, do not copy; instead, return the length of what the result | - | ||||||||||||||||||
1456 | would have been. */ | - | ||||||||||||||||||
1457 | static YYSIZE_T | - | ||||||||||||||||||
1458 | yytnamerr (char *yyres, const char *yystr) | - | ||||||||||||||||||
1459 | { | - | ||||||||||||||||||
1460 | if (*yystr == '"') | - | ||||||||||||||||||
1461 | { | - | ||||||||||||||||||
1462 | YYSIZE_T yyn = 0; | - | ||||||||||||||||||
1463 | char const *yyp = yystr; | - | ||||||||||||||||||
1464 | - | |||||||||||||||||||
1465 | for (;;) | - | ||||||||||||||||||
1466 | switch (*++yyp) | - | ||||||||||||||||||
1467 | { | - | ||||||||||||||||||
1468 | case '\'': | - | ||||||||||||||||||
1469 | case ',': | - | ||||||||||||||||||
1470 | goto do_not_strip_quotes; | - | ||||||||||||||||||
1471 | - | |||||||||||||||||||
1472 | case '\\': | - | ||||||||||||||||||
1473 | if (*++yyp != '\\') | - | ||||||||||||||||||
1474 | goto do_not_strip_quotes; | - | ||||||||||||||||||
1475 | /* Fall through. */ | - | ||||||||||||||||||
1476 | default: | - | ||||||||||||||||||
1477 | if (yyres) | - | ||||||||||||||||||
1478 | yyres[yyn] = *yyp; | - | ||||||||||||||||||
1479 | yyn++; | - | ||||||||||||||||||
1480 | break; | - | ||||||||||||||||||
1481 | - | |||||||||||||||||||
1482 | case '"': | - | ||||||||||||||||||
1483 | if (yyres) | - | ||||||||||||||||||
1484 | yyres[yyn] = '\0'; | - | ||||||||||||||||||
1485 | return yyn; | - | ||||||||||||||||||
1486 | } | - | ||||||||||||||||||
1487 | do_not_strip_quotes: ; | - | ||||||||||||||||||
1488 | } | - | ||||||||||||||||||
1489 | - | |||||||||||||||||||
1490 | if (! yyres) | - | ||||||||||||||||||
1491 | return yystrlen (yystr); | - | ||||||||||||||||||
1492 | - | |||||||||||||||||||
1493 | return yystpcpy (yyres, yystr) - yyres; | - | ||||||||||||||||||
1494 | } | - | ||||||||||||||||||
1495 | # endif | - | ||||||||||||||||||
1496 | - | |||||||||||||||||||
1497 | /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message | - | ||||||||||||||||||
1498 | about the unexpected token YYTOKEN for the state stack whose top is | - | ||||||||||||||||||
1499 | YYSSP. | - | ||||||||||||||||||
1500 | - | |||||||||||||||||||
1501 | Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is | - | ||||||||||||||||||
1502 | not large enough to hold the message. In that case, also set | - | ||||||||||||||||||
1503 | *YYMSG_ALLOC to the required number of bytes. Return 2 if the | - | ||||||||||||||||||
1504 | required number of bytes is too large to store. */ | - | ||||||||||||||||||
1505 | static int | - | ||||||||||||||||||
1506 | yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, | - | ||||||||||||||||||
1507 | yytype_int16 *yyssp, int yytoken) | - | ||||||||||||||||||
1508 | { | - | ||||||||||||||||||
1509 | YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); | - | ||||||||||||||||||
1510 | YYSIZE_T yysize = yysize0; | - | ||||||||||||||||||
1511 | enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; | - | ||||||||||||||||||
1512 | /* Internationalized format string. */ | - | ||||||||||||||||||
1513 | const char *yyformat = YY_NULLPTR; | - | ||||||||||||||||||
1514 | /* Arguments of yyformat. */ | - | ||||||||||||||||||
1515 | char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; | - | ||||||||||||||||||
1516 | /* Number of reported tokens (one for the "unexpected", one per | - | ||||||||||||||||||
1517 | "expected"). */ | - | ||||||||||||||||||
1518 | int yycount = 0; | - | ||||||||||||||||||
1519 | - | |||||||||||||||||||
1520 | /* There are many possibilities here to consider: | - | ||||||||||||||||||
1521 | - If this state is a consistent state with a default action, then | - | ||||||||||||||||||
1522 | the only way this function was invoked is if the default action | - | ||||||||||||||||||
1523 | is an error action. In that case, don't check for expected | - | ||||||||||||||||||
1524 | tokens because there are none. | - | ||||||||||||||||||
1525 | - The only way there can be no lookahead present (in yychar) is if | - | ||||||||||||||||||
1526 | this state is a consistent state with a default action. Thus, | - | ||||||||||||||||||
1527 | detecting the absence of a lookahead is sufficient to determine | - | ||||||||||||||||||
1528 | that there is no unexpected or expected token to report. In that | - | ||||||||||||||||||
1529 | case, just report a simple "syntax error". | - | ||||||||||||||||||
1530 | - Don't assume there isn't a lookahead just because this state is a | - | ||||||||||||||||||
1531 | consistent state with a default action. There might have been a | - | ||||||||||||||||||
1532 | previous inconsistent state, consistent state with a non-default | - | ||||||||||||||||||
1533 | action, or user semantic action that manipulated yychar. | - | ||||||||||||||||||
1534 | - Of course, the expected token list depends on states to have | - | ||||||||||||||||||
1535 | correct lookahead information, and it depends on the parser not | - | ||||||||||||||||||
1536 | to perform extra reductions after fetching a lookahead from the | - | ||||||||||||||||||
1537 | scanner and before detecting a syntax error. Thus, state merging | - | ||||||||||||||||||
1538 | (from LALR or IELR) and default reductions corrupt the expected | - | ||||||||||||||||||
1539 | token list. However, the list is correct for canonical LR with | - | ||||||||||||||||||
1540 | one exception: it will still contain any token that will not be | - | ||||||||||||||||||
1541 | accepted due to an error action in a later state. | - | ||||||||||||||||||
1542 | */ | - | ||||||||||||||||||
1543 | if (yytoken != YYEMPTY) | - | ||||||||||||||||||
1544 | { | - | ||||||||||||||||||
1545 | int yyn = yypact[*yyssp]; | - | ||||||||||||||||||
1546 | yyarg[yycount++] = yytname[yytoken]; | - | ||||||||||||||||||
1547 | if (!yypact_value_is_default (yyn)) | - | ||||||||||||||||||
1548 | { | - | ||||||||||||||||||
1549 | /* Start YYX at -YYN if negative to avoid negative indexes in | - | ||||||||||||||||||
1550 | YYCHECK. In other words, skip the first -YYN actions for | - | ||||||||||||||||||
1551 | this state because they are default actions. */ | - | ||||||||||||||||||
1552 | int yyxbegin = yyn < 0 ? -yyn : 0; | - | ||||||||||||||||||
1553 | /* Stay within bounds of both yycheck and yytname. */ | - | ||||||||||||||||||
1554 | int yychecklim = YYLAST - yyn + 1; | - | ||||||||||||||||||
1555 | int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; | - | ||||||||||||||||||
1556 | int yyx; | - | ||||||||||||||||||
1557 | - | |||||||||||||||||||
1558 | for (yyx = yyxbegin; yyx < yyxend; ++yyx) | - | ||||||||||||||||||
1559 | if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR | - | ||||||||||||||||||
1560 | && !yytable_value_is_error (yytable[yyx + yyn])) | - | ||||||||||||||||||
1561 | { | - | ||||||||||||||||||
1562 | if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) | - | ||||||||||||||||||
1563 | { | - | ||||||||||||||||||
1564 | yycount = 1; | - | ||||||||||||||||||
1565 | yysize = yysize0; | - | ||||||||||||||||||
1566 | break; | - | ||||||||||||||||||
1567 | } | - | ||||||||||||||||||
1568 | yyarg[yycount++] = yytname[yyx]; | - | ||||||||||||||||||
1569 | { | - | ||||||||||||||||||
1570 | YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); | - | ||||||||||||||||||
1571 | if (! (yysize <= yysize1 | - | ||||||||||||||||||
1572 | && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) | - | ||||||||||||||||||
1573 | return 2; | - | ||||||||||||||||||
1574 | yysize = yysize1; | - | ||||||||||||||||||
1575 | } | - | ||||||||||||||||||
1576 | } | - | ||||||||||||||||||
1577 | } | - | ||||||||||||||||||
1578 | } | - | ||||||||||||||||||
1579 | - | |||||||||||||||||||
1580 | switch (yycount) | - | ||||||||||||||||||
1581 | { | - | ||||||||||||||||||
1582 | # define YYCASE_(N, S) \ | - | ||||||||||||||||||
1583 | case N: \ | - | ||||||||||||||||||
1584 | yyformat = S; \ | - | ||||||||||||||||||
1585 | break | - | ||||||||||||||||||
1586 | YYCASE_(0, YY_("syntax error")); | - | ||||||||||||||||||
1587 | YYCASE_(1, YY_("syntax error, unexpected %s")); | - | ||||||||||||||||||
1588 | YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); | - | ||||||||||||||||||
1589 | YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); | - | ||||||||||||||||||
1590 | YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); | - | ||||||||||||||||||
1591 | YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); | - | ||||||||||||||||||
1592 | # undef YYCASE_ | - | ||||||||||||||||||
1593 | } | - | ||||||||||||||||||
1594 | - | |||||||||||||||||||
1595 | { | - | ||||||||||||||||||
1596 | YYSIZE_T yysize1 = yysize + yystrlen (yyformat); | - | ||||||||||||||||||
1597 | if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) | - | ||||||||||||||||||
1598 | return 2; | - | ||||||||||||||||||
1599 | yysize = yysize1; | - | ||||||||||||||||||
1600 | } | - | ||||||||||||||||||
1601 | - | |||||||||||||||||||
1602 | if (*yymsg_alloc < yysize) | - | ||||||||||||||||||
1603 | { | - | ||||||||||||||||||
1604 | *yymsg_alloc = 2 * yysize; | - | ||||||||||||||||||
1605 | if (! (yysize <= *yymsg_alloc | - | ||||||||||||||||||
1606 | && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) | - | ||||||||||||||||||
1607 | *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; | - | ||||||||||||||||||
1608 | return 1; | - | ||||||||||||||||||
1609 | } | - | ||||||||||||||||||
1610 | - | |||||||||||||||||||
1611 | /* Avoid sprintf, as that infringes on the user's name space. | - | ||||||||||||||||||
1612 | Don't have undefined behavior even if the translation | - | ||||||||||||||||||
1613 | produced a string with the wrong number of "%s"s. */ | - | ||||||||||||||||||
1614 | { | - | ||||||||||||||||||
1615 | char *yyp = *yymsg; | - | ||||||||||||||||||
1616 | int yyi = 0; | - | ||||||||||||||||||
1617 | while ((*yyp = *yyformat) != '\0') | - | ||||||||||||||||||
1618 | if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) | - | ||||||||||||||||||
1619 | { | - | ||||||||||||||||||
1620 | yyp += yytnamerr (yyp, yyarg[yyi++]); | - | ||||||||||||||||||
1621 | yyformat += 2; | - | ||||||||||||||||||
1622 | } | - | ||||||||||||||||||
1623 | else | - | ||||||||||||||||||
1624 | { | - | ||||||||||||||||||
1625 | yyp++; | - | ||||||||||||||||||
1626 | yyformat++; | - | ||||||||||||||||||
1627 | } | - | ||||||||||||||||||
1628 | } | - | ||||||||||||||||||
1629 | return 0; | - | ||||||||||||||||||
1630 | } | - | ||||||||||||||||||
1631 | #endif /* YYERROR_VERBOSE */ | - | ||||||||||||||||||
1632 | - | |||||||||||||||||||
1633 | /*-----------------------------------------------. | - | ||||||||||||||||||
1634 | | Release the memory associated to this symbol. | | - | ||||||||||||||||||
1635 | `-----------------------------------------------*/ | - | ||||||||||||||||||
1636 | - | |||||||||||||||||||
1637 | static void | - | ||||||||||||||||||
1638 | yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) | - | ||||||||||||||||||
1639 | { | - | ||||||||||||||||||
1640 | YYUSE (yyvaluep); | - | ||||||||||||||||||
1641 | if (!yymsg)
| 0-704486 | ||||||||||||||||||
1642 | yymsg = "Deleting"; never executed: yymsg = "Deleting"; | 0 | ||||||||||||||||||
1643 | YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); never executed: end of block
| 0-704486 | ||||||||||||||||||
1644 | - | |||||||||||||||||||
1645 | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN | - | ||||||||||||||||||
1646 | YYUSE (yytype); | - | ||||||||||||||||||
1647 | YY_IGNORE_MAYBE_UNINITIALIZED_END | - | ||||||||||||||||||
1648 | } executed 704486 times by 1 test Executed by:
| 704486 | ||||||||||||||||||
1649 | - | |||||||||||||||||||
1650 | - | |||||||||||||||||||
1651 | - | |||||||||||||||||||
1652 | - | |||||||||||||||||||
1653 | /* The lookahead symbol. */ | - | ||||||||||||||||||
1654 | int yychar; | - | ||||||||||||||||||
1655 | - | |||||||||||||||||||
1656 | /* The semantic value of the lookahead symbol. */ | - | ||||||||||||||||||
1657 | YYSTYPE yylval; | - | ||||||||||||||||||
1658 | /* Number of syntax errors so far. */ | - | ||||||||||||||||||
1659 | int yynerrs; | - | ||||||||||||||||||
1660 | - | |||||||||||||||||||
1661 | - | |||||||||||||||||||
1662 | /*----------. | - | ||||||||||||||||||
1663 | | yyparse. | | - | ||||||||||||||||||
1664 | `----------*/ | - | ||||||||||||||||||
1665 | - | |||||||||||||||||||
1666 | int | - | ||||||||||||||||||
1667 | yyparse (void) | - | ||||||||||||||||||
1668 | { | - | ||||||||||||||||||
1669 | int yystate; | - | ||||||||||||||||||
1670 | /* Number of tokens to shift before error messages enabled. */ | - | ||||||||||||||||||
1671 | int yyerrstatus; | - | ||||||||||||||||||
1672 | - | |||||||||||||||||||
1673 | /* The stacks and their tools: | - | ||||||||||||||||||
1674 | 'yyss': related to states. | - | ||||||||||||||||||
1675 | 'yyvs': related to semantic values. | - | ||||||||||||||||||
1676 | - | |||||||||||||||||||
1677 | Refer to the stacks through separate pointers, to allow yyoverflow | - | ||||||||||||||||||
1678 | to reallocate them elsewhere. */ | - | ||||||||||||||||||
1679 | - | |||||||||||||||||||
1680 | /* The state stack. */ | - | ||||||||||||||||||
1681 | yytype_int16 yyssa[YYINITDEPTH]; | - | ||||||||||||||||||
1682 | yytype_int16 *yyss; | - | ||||||||||||||||||
1683 | yytype_int16 *yyssp; | - | ||||||||||||||||||
1684 | - | |||||||||||||||||||
1685 | /* The semantic value stack. */ | - | ||||||||||||||||||
1686 | YYSTYPE yyvsa[YYINITDEPTH]; | - | ||||||||||||||||||
1687 | YYSTYPE *yyvs; | - | ||||||||||||||||||
1688 | YYSTYPE *yyvsp; | - | ||||||||||||||||||
1689 | - | |||||||||||||||||||
1690 | YYSIZE_T yystacksize; | - | ||||||||||||||||||
1691 | - | |||||||||||||||||||
1692 | int yyn; | - | ||||||||||||||||||
1693 | int yyresult; | - | ||||||||||||||||||
1694 | /* Lookahead token as an internal (translated) token number. */ | - | ||||||||||||||||||
1695 | int yytoken = 0; | - | ||||||||||||||||||
1696 | /* The variables used to return semantic value and location from the | - | ||||||||||||||||||
1697 | action routines. */ | - | ||||||||||||||||||
1698 | YYSTYPE yyval; | - | ||||||||||||||||||
1699 | - | |||||||||||||||||||
1700 | #if YYERROR_VERBOSE | - | ||||||||||||||||||
1701 | /* Buffer for error messages, and its allocated size. */ | - | ||||||||||||||||||
1702 | char yymsgbuf[128]; | - | ||||||||||||||||||
1703 | char *yymsg = yymsgbuf; | - | ||||||||||||||||||
1704 | YYSIZE_T yymsg_alloc = sizeof yymsgbuf; | - | ||||||||||||||||||
1705 | #endif | - | ||||||||||||||||||
1706 | - | |||||||||||||||||||
1707 | #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) | - | ||||||||||||||||||
1708 | - | |||||||||||||||||||
1709 | /* The number of symbols on the RHS of the reduced rule. | - | ||||||||||||||||||
1710 | Keep to zero when no symbol should be popped. */ | - | ||||||||||||||||||
1711 | int yylen = 0; | - | ||||||||||||||||||
1712 | - | |||||||||||||||||||
1713 | yyssp = yyss = yyssa; | - | ||||||||||||||||||
1714 | yyvsp = yyvs = yyvsa; | - | ||||||||||||||||||
1715 | yystacksize = YYINITDEPTH; | - | ||||||||||||||||||
1716 | - | |||||||||||||||||||
1717 | YYDPRINTF ((stderr, "Starting parse\n")); never executed: yyerrstatus = 0; yynerrs = 0;
| 0-907954 | ||||||||||||||||||
1718 | - | |||||||||||||||||||
1719 | yystate = 0; | - | ||||||||||||||||||
1720 | yyerrstatus = 0; | - | ||||||||||||||||||
1721 | yynerrs = 0; | - | ||||||||||||||||||
1722 | yychar = YYEMPTY; /* Cause a token to be read. */ | - | ||||||||||||||||||
1723 | goto yysetstate; executed 907954 times by 1 test Executed by:
| 907954 | ||||||||||||||||||
1724 | - | |||||||||||||||||||
1725 | /*------------------------------------------------------------. | - | ||||||||||||||||||
1726 | | yynewstate -- Push a new state, which is found in yystate. | | - | ||||||||||||||||||
1727 | `------------------------------------------------------------*/ | - | ||||||||||||||||||
1728 | yynewstate: | - | ||||||||||||||||||
1729 | /* In all cases, when you get here, the value and location stacks | - | ||||||||||||||||||
1730 | have just been pushed. So pushing a state here evens the stacks. */ | - | ||||||||||||||||||
1731 | yyssp++; | - | ||||||||||||||||||
1732 | - | |||||||||||||||||||
1733 | yysetstate: code before this statement executed 16104124 times by 1 test: { Executed by:
| 16104124 | ||||||||||||||||||
1734 | *yyssp = yystate; | - | ||||||||||||||||||
1735 | - | |||||||||||||||||||
1736 | if (yyss + yystacksize - 1 <= yyssp)
| 4-17012074 | ||||||||||||||||||
1737 | { | - | ||||||||||||||||||
1738 | /* Get the current used size of the three stacks, in elements. */ | - | ||||||||||||||||||
1739 | YYSIZE_T yysize = yyssp - yyss + 1; | - | ||||||||||||||||||
1740 | - | |||||||||||||||||||
1741 | #ifdef yyoverflow | - | ||||||||||||||||||
1742 | { | - | ||||||||||||||||||
1743 | /* Give user a chance to reallocate the stack. Use copies of | - | ||||||||||||||||||
1744 | these so that the &'s don't force the real ones into | - | ||||||||||||||||||
1745 | memory. */ | - | ||||||||||||||||||
1746 | YYSTYPE *yyvs1 = yyvs; | - | ||||||||||||||||||
1747 | yytype_int16 *yyss1 = yyss; | - | ||||||||||||||||||
1748 | - | |||||||||||||||||||
1749 | /* Each stack pointer address is followed by the size of the | - | ||||||||||||||||||
1750 | data in use in that stack, in bytes. This used to be a | - | ||||||||||||||||||
1751 | conditional around just the two extra args, but that might | - | ||||||||||||||||||
1752 | be undefined if yyoverflow is a macro. */ | - | ||||||||||||||||||
1753 | yyoverflow (YY_("memory exhausted"), | - | ||||||||||||||||||
1754 | &yyss1, yysize * sizeof (*yyssp), | - | ||||||||||||||||||
1755 | &yyvs1, yysize * sizeof (*yyvsp), | - | ||||||||||||||||||
1756 | &yystacksize); | - | ||||||||||||||||||
1757 | - | |||||||||||||||||||
1758 | yyss = yyss1; | - | ||||||||||||||||||
1759 | yyvs = yyvs1; | - | ||||||||||||||||||
1760 | } | - | ||||||||||||||||||
1761 | #else /* no yyoverflow */ | - | ||||||||||||||||||
1762 | # ifndef YYSTACK_RELOCATE | - | ||||||||||||||||||
1763 | goto yyexhaustedlab; | - | ||||||||||||||||||
1764 | # else | - | ||||||||||||||||||
1765 | /* Extend the stack our own way. */ | - | ||||||||||||||||||
1766 | if (YYMAXDEPTH <= yystacksize)
| 0-4 | ||||||||||||||||||
1767 | goto yyexhaustedlab; never executed | 0 | ||||||||||||||||||
1768 | yystacksize *= 2; | - | ||||||||||||||||||
1769 | if (YYMAXDEPTH < yystacksize)
| 0-4 | ||||||||||||||||||
1770 | yystacksize = YYMAXDEPTH; never executed: union yyalloc *yyptr | 0 | ||||||||||||||||||
1771 | - | |||||||||||||||||||
1772 | { | - | ||||||||||||||||||
1773 | yytype_int16 *yyss1 = yyss; | - | ||||||||||||||||||
1774 | union yyalloc *yyptr = | - | ||||||||||||||||||
1775 | (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); | - | ||||||||||||||||||
1776 | if (! yyptr)
| 0-4 | ||||||||||||||||||
1777 | goto yyexhaustedlab; never executed: (yyss1 != yyssa) | 0 | ||||||||||||||||||
1778 | YYSTACK_RELOCATE (yyss_alloc, yyss); | - | ||||||||||||||||||
1779 | YYSTACK_RELOCATE (yyvs_alloc, yyvs); | - | ||||||||||||||||||
1780 | # undef YYSTACK_RELOCATE | - | ||||||||||||||||||
1781 | if (yyss1 != yyssa)
| 1-3 | ||||||||||||||||||
1782 | YYSTACK_FREE (yyss1); executed 3 times by 1 test Executed by:
| 3 | ||||||||||||||||||
1783 | } | - | ||||||||||||||||||
1784 | # endif | - | ||||||||||||||||||
1785 | #endif /* no yyoverflow */ | - | ||||||||||||||||||
1786 | - | |||||||||||||||||||
1787 | yyssp = yyss + yysize - 1; | - | ||||||||||||||||||
1788 | yyvsp = yyvs + yysize - 1; | - | ||||||||||||||||||
1789 | - | |||||||||||||||||||
1790 | YYDPRINTF ((stderr, "Stack size increased to %lu\n", never executed: if (yyss + yystacksize - 1 <= yyssp) goto yyabortlab;
| 0-4 | ||||||||||||||||||
1791 | (unsigned long int) yystacksize)); | - | ||||||||||||||||||
1792 | - | |||||||||||||||||||
1793 | if (yyss + yystacksize - 1 <= yyssp)
| 0-4 | ||||||||||||||||||
1794 | YYABORT; never executed | 0 | ||||||||||||||||||
1795 | } executed 4 times by 1 test: E Executed by:
| 4 | ||||||||||||||||||
1796 | - | |||||||||||||||||||
1797 | YYDPRINTF ((stderr, "Entering state %d\n", yystate)); never executed: ) goto yyacceptlab;
| 0-17012078 | ||||||||||||||||||
1798 | - | |||||||||||||||||||
1799 | if (yystate == YYFINAL)
| 0-17012078 | ||||||||||||||||||
1800 | YYACCEPT; never executed | 0 | ||||||||||||||||||
1801 | - | |||||||||||||||||||
1802 | goto yybackup; executed 17012078 times by 1 test Executed by:
| 17012078 | ||||||||||||||||||
1803 | - | |||||||||||||||||||
1804 | /*-----------. | - | ||||||||||||||||||
1805 | | yybackup. | | - | ||||||||||||||||||
1806 | `-----------*/ | - | ||||||||||||||||||
1807 | yybackup: | - | ||||||||||||||||||
1808 | - | |||||||||||||||||||
1809 | /* Do appropriate processing given the current state. Read a | - | ||||||||||||||||||
1810 | lookahead token if we need one and don't already have one. */ | - | ||||||||||||||||||
1811 | - | |||||||||||||||||||
1812 | /* First try to decide what to do without reference to lookahead token. */ | - | ||||||||||||||||||
1813 | yyn = yypact[yystate]; | - | ||||||||||||||||||
1814 | if (yypact_value_is_default (yyn))
| 8290692-8721386 | ||||||||||||||||||
1815 | goto yydefault; executed 8290692 times by 1 test Executed by:
| 8290692 | ||||||||||||||||||
1816 | - | |||||||||||||||||||
1817 | /* Not known => get a lookahead token if don't already have one. */ | - | ||||||||||||||||||
1818 | - | |||||||||||||||||||
1819 | /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ | - | ||||||||||||||||||
1820 | if (yychar == YYEMPTY)
| 3891937-4829449 | ||||||||||||||||||
1821 | { | - | ||||||||||||||||||
1822 | YYDPRINTF ((stderr, "Reading a token: ")); never executed: if (yychar <= 0)
| 0-4829449 | ||||||||||||||||||
1823 | yychar = yylex (); | - | ||||||||||||||||||
1824 | } executed 4829432 times by 1 test Executed by:
| 4829432 | ||||||||||||||||||
1825 | - | |||||||||||||||||||
1826 | if (yychar <= YYEOF)
| 14-8721355 | ||||||||||||||||||
1827 | { | - | ||||||||||||||||||
1828 | yychar = yytoken = YYEOF; | - | ||||||||||||||||||
1829 | YYDPRINTF ((stderr, "Now at end of input.\n")); never executed: { yytoken = ((unsigned int) (
| 0-14 | ||||||||||||||||||
1830 | } executed 14 times by 1 test Executed by:
| 14 | ||||||||||||||||||
1831 | else | - | ||||||||||||||||||
1832 | { | - | ||||||||||||||||||
1833 | yytoken = YYTRANSLATE (yychar);
| 0-8721355 | ||||||||||||||||||
1834 | YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); never executed
| 0-8721355 | ||||||||||||||||||
1835 | } executed 8721355 times by 1 test: n Executed by:
| 8721355 | ||||||||||||||||||
1836 | - | |||||||||||||||||||
1837 | /* If the proper action on seeing token YYTOKEN is to reduce or to | - | ||||||||||||||||||
1838 | detect an error, take that action. */ | - | ||||||||||||||||||
1839 | yyn += yytoken; | - | ||||||||||||||||||
1840 | if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
| 0-8721357 | ||||||||||||||||||
1841 | goto yydefault; executed 4596290 times by 1 test: if (0) Executed by:
| 4596290 | ||||||||||||||||||
1842 | yyn = yytable[yyn]; | - | ||||||||||||||||||
1843 | if (yyn <= 0)
| 0-4125079 | ||||||||||||||||||
1844 | { | - | ||||||||||||||||||
1845 | if (yytable_value_is_error (yyn)) dead code:
| - | ||||||||||||||||||
1846 | goto yyerrlab; dead code:
| - | ||||||||||||||||||
1847 | yyn = -yyn; | - | ||||||||||||||||||
1848 | goto yyreduce; never executed | 0 | ||||||||||||||||||
1849 | } | - | ||||||||||||||||||
1850 | - | |||||||||||||||||||
1851 | /* Count tokens shifted since error; after three, turn off error | - | ||||||||||||||||||
1852 | status. */ | - | ||||||||||||||||||
1853 | if (yyerrstatus)
| 24-4125055 | ||||||||||||||||||
1854 | yyerrstatus--; executed 24 times by 1 test: err Executed by:
| 24 | ||||||||||||||||||
1855 | - | |||||||||||||||||||
1856 | /* Shift the lookahead token. */ | - | ||||||||||||||||||
1857 | YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); never executed
| 0-4125079 | ||||||||||||||||||
1858 | - | |||||||||||||||||||
1859 | /* Discard the shifted token. */ | - | ||||||||||||||||||
1860 | yychar = YYEMPTY; | - | ||||||||||||||||||
1861 | - | |||||||||||||||||||
1862 | yystate = yyn; | - | ||||||||||||||||||
1863 | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN | - | ||||||||||||||||||
1864 | *++yyvsp = yylval; | - | ||||||||||||||||||
1865 | YY_IGNORE_MAYBE_UNINITIALIZED_END | - | ||||||||||||||||||
1866 | - | |||||||||||||||||||
1867 | goto yynewstate; executed 4125079 times by 1 test: if (yyn == 0) Executed by:
| 4125079 | ||||||||||||||||||
1868 | - | |||||||||||||||||||
1869 | - | |||||||||||||||||||
1870 | /*-----------------------------------------------------------. | - | ||||||||||||||||||
1871 | | yydefault -- do the default action for the current state. | | - | ||||||||||||||||||
1872 | `-----------------------------------------------------------*/ | - | ||||||||||||||||||
1873 | yydefault: | - | ||||||||||||||||||
1874 | yyn = yydefact[yystate]; | - | ||||||||||||||||||
1875 | if (yyn == 0)
| 52-12886930 | ||||||||||||||||||
1876 | goto yyerrlab; executed 52 times by 1 test Executed by:
| 52 | ||||||||||||||||||
1877 | goto yyreduce; executed 12886930 times by 1 test: yylen = yyr2[y Executed by:
| 12886930 | ||||||||||||||||||
1878 | - | |||||||||||||||||||
1879 | - | |||||||||||||||||||
1880 | /*-----------------------------. | - | ||||||||||||||||||
1881 | | yyreduce -- Do a reduction. | | - | ||||||||||||||||||
1882 | `-----------------------------*/ | - | ||||||||||||||||||
1883 | yyreduce: | - | ||||||||||||||||||
1884 | /* yyn is the number of a rule to reduce with. */ | - | ||||||||||||||||||
1885 | yylen = yyr2[yyn]; | - | ||||||||||||||||||
1886 | - | |||||||||||||||||||
1887 | /* If YYLEN is nonzero, implement the default value of the action: | - | ||||||||||||||||||
1888 | '$$ = $1'. | - | ||||||||||||||||||
1889 | - | |||||||||||||||||||
1890 | Otherwise, the following line sets YYVAL to garbage. | - | ||||||||||||||||||
1891 | This behavior is undocumented and Bison | - | ||||||||||||||||||
1892 | users should not rely upon it. Assigning to YYVAL | - | ||||||||||||||||||
1893 | unconditionally makes the parser a bit smaller, and it avoids a | - | ||||||||||||||||||
1894 | GCC warning that YYVAL may be used uninitialized. */ | - | ||||||||||||||||||
1895 | yyval = yyvsp[1-yylen]; | - | ||||||||||||||||||
1896 | - | |||||||||||||||||||
1897 | - | |||||||||||||||||||
1898 | YY_REDUCE_PRINT (yyn); never executed
| 0-12886930 | ||||||||||||||||||
1899 | switch (yyn) | - | ||||||||||||||||||
1900 | { | - | ||||||||||||||||||
1901 | case 2: executed 120189 times by 1 test Executed by:
| 120189 | ||||||||||||||||||
1902 | #line 382 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
1903 | { | - | ||||||||||||||||||
1904 | /* Case of regular command. Discard the error | - | ||||||||||||||||||
1905 | safety net,and return the command just parsed. */ | - | ||||||||||||||||||
1906 | global_command = (yyvsp[-1].command); | - | ||||||||||||||||||
1907 | eof_encountered = 0; | - | ||||||||||||||||||
1908 | /* discard_parser_constructs (0); */ | - | ||||||||||||||||||
1909 | if (parser_state & PST_CMDSUBST) | - | ||||||||||||||||||
1910 | parser_state |= PST_EOFTOKEN; | - | ||||||||||||||||||
1911 | YYACCEPT; | - | ||||||||||||||||||
1912 | } | - | ||||||||||||||||||
1913 | #line 1914 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
1914 | break; dead code: se 5: | - | ||||||||||||||||||
1915 | - | |||||||||||||||||||
1916 | case 3: executed 82100 times by 1 test Executed by:
| 82100 | ||||||||||||||||||
1917 | #line 393 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
1918 | { | - | ||||||||||||||||||
1919 | /* Case of regular command, but not a very | - | ||||||||||||||||||
1920 | interesting one. Return a NULL command. */ | - | ||||||||||||||||||
1921 | global_command = (COMMAND *)NULL; | - | ||||||||||||||||||
1922 | if (parser_state & PST_CMDSUBST) | - | ||||||||||||||||||
1923 | parser_state |= PST_EOFTOKEN; | - | ||||||||||||||||||
1924 | YYACCEPT; | - | ||||||||||||||||||
1925 | } | - | ||||||||||||||||||
1926 | #line 1927 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
1927 | break; dead code: se 6: | - | ||||||||||||||||||
1928 | - | |||||||||||||||||||
1929 | case 4: executed 22 times by 1 test Executed by:
| 22 | ||||||||||||||||||
1930 | #line 402 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
1931 | { | - | ||||||||||||||||||
1932 | /* Error during parsing. Return NULL command. */ | - | ||||||||||||||||||
1933 | global_command = (COMMAND *)NULL; | - | ||||||||||||||||||
1934 | eof_encountered = 0; | - | ||||||||||||||||||
1935 | /* discard_parser_constructs (1); */ | - | ||||||||||||||||||
1936 | if (interactive && parse_and_execute_level == 0) | - | ||||||||||||||||||
1937 | { | - | ||||||||||||||||||
1938 | YYACCEPT; | - | ||||||||||||||||||
1939 | } | - | ||||||||||||||||||
1940 | else | - | ||||||||||||||||||
1941 | { | - | ||||||||||||||||||
1942 | YYABORT; | - | ||||||||||||||||||
1943 | } | - | ||||||||||||||||||
1944 | } | - | ||||||||||||||||||
1945 | #line 1946 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
1946 | break; dead code: se 7: | - | ||||||||||||||||||
1947 | - | |||||||||||||||||||
1948 | case 5: executed 2 times by 1 test Executed by:
| 2 | ||||||||||||||||||
1949 | #line 417 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
1950 | { | - | ||||||||||||||||||
1951 | /* EOF after an error. Do ignoreeof or not. Really | - | ||||||||||||||||||
1952 | only interesting in non-interactive shells */ | - | ||||||||||||||||||
1953 | global_command = (COMMAND *)NULL; | - | ||||||||||||||||||
1954 | last_command_exit_value = 1; | - | ||||||||||||||||||
1955 | handle_eof_input_unit (); | - | ||||||||||||||||||
1956 | if (interactive && parse_and_execute_level == 0) | - | ||||||||||||||||||
1957 | { | - | ||||||||||||||||||
1958 | YYACCEPT; | - | ||||||||||||||||||
1959 | } | - | ||||||||||||||||||
1960 | else | - | ||||||||||||||||||
1961 | { | - | ||||||||||||||||||
1962 | YYABORT; | - | ||||||||||||||||||
1963 | } | - | ||||||||||||||||||
1964 | } | - | ||||||||||||||||||
1965 | #line 1966 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
1966 | break; dead code: se 8: | - | ||||||||||||||||||
1967 | - | |||||||||||||||||||
1968 | case 6: executed 1290 times by 1 test Executed by:
| 1290 | ||||||||||||||||||
1969 | #line 433 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
1970 | { | - | ||||||||||||||||||
1971 | /* Case of EOF seen by itself. Do ignoreeof or | - | ||||||||||||||||||
1972 | not. */ | - | ||||||||||||||||||
1973 | global_command = (COMMAND *)NULL; | - | ||||||||||||||||||
1974 | handle_eof_input_unit (); | - | ||||||||||||||||||
1975 | YYACCEPT; | - | ||||||||||||||||||
1976 | } | - | ||||||||||||||||||
1977 | #line 1978 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
1978 | break; dead code: se 9: | - | ||||||||||||||||||
1979 | - | |||||||||||||||||||
1980 | case 7: executed 25461 times by 1 test Executed by:
| 25461 | ||||||||||||||||||
1981 | #line 443 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
1982 | { (yyval.word_list) = make_word_list ((yyvsp[0].word), (WORD_LIST *)NULL); } | - | ||||||||||||||||||
1983 | #line 1984 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
1984 | break; executed 25461 times by 1 test: se 10: Executed by:
| 25461 | ||||||||||||||||||
1985 | - | |||||||||||||||||||
1986 | case 8: executed 99625 times by 1 test Executed by:
| 99625 | ||||||||||||||||||
1987 | #line 445 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
1988 | { (yyval.word_list) = make_word_list ((yyvsp[0].word), (yyvsp[-1].word_list)); } | - | ||||||||||||||||||
1989 | #line 1990 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
1990 | break; executed 99625 times by 1 test: se 11: Executed by:
| 99625 | ||||||||||||||||||
1991 | - | |||||||||||||||||||
1992 | case 9: executed 8576 times by 1 test Executed by:
| 8576 | ||||||||||||||||||
1993 | #line 449 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
1994 | { | - | ||||||||||||||||||
1995 | source.dest = 1; | - | ||||||||||||||||||
1996 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
1997 | (yyval.redirect) = make_redirection (source, r_output_direction, redir, 0); | - | ||||||||||||||||||
1998 | } | - | ||||||||||||||||||
1999 | #line 2000 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2000 | break; executed 8576 times by 1 test: se 12: Executed by:
| 8576 | ||||||||||||||||||
2001 | - | |||||||||||||||||||
2002 | case 10: executed 1464 times by 1 test Executed by:
| 1464 | ||||||||||||||||||
2003 | #line 455 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2004 | { | - | ||||||||||||||||||
2005 | source.dest = 0; | - | ||||||||||||||||||
2006 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2007 | (yyval.redirect) = make_redirection (source, r_input_direction, redir, 0); | - | ||||||||||||||||||
2008 | } | - | ||||||||||||||||||
2009 | #line 2010 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2010 | break; executed 1464 times by 1 test: se 13: Executed by:
| 1464 | ||||||||||||||||||
2011 | - | |||||||||||||||||||
2012 | case 11: executed 2688 times by 1 test Executed by:
| 2688 | ||||||||||||||||||
2013 | #line 461 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2014 | { | - | ||||||||||||||||||
2015 | source.dest = (yyvsp[-2].number); | - | ||||||||||||||||||
2016 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2017 | (yyval.redirect) = make_redirection (source, r_output_direction, redir, 0); | - | ||||||||||||||||||
2018 | } | - | ||||||||||||||||||
2019 | #line 2020 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2020 | break; executed 2688 times by 1 test: se 14: Executed by:
| 2688 | ||||||||||||||||||
2021 | - | |||||||||||||||||||
2022 | case 12: executed 1408 times by 1 test Executed by:
| 1408 | ||||||||||||||||||
2023 | #line 467 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2024 | { | - | ||||||||||||||||||
2025 | source.dest = (yyvsp[-2].number); | - | ||||||||||||||||||
2026 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2027 | (yyval.redirect) = make_redirection (source, r_input_direction, redir, 0); | - | ||||||||||||||||||
2028 | } | - | ||||||||||||||||||
2029 | #line 2030 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2030 | break; executed 1408 times by 1 test: se 15: Executed by:
| 1408 | ||||||||||||||||||
2031 | - | |||||||||||||||||||
2032 | case 13: executed 7 times by 1 test Executed by:
| 7 | ||||||||||||||||||
2033 | #line 473 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2034 | { | - | ||||||||||||||||||
2035 | source.filename = (yyvsp[-2].word); | - | ||||||||||||||||||
2036 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2037 | (yyval.redirect) = make_redirection (source, r_output_direction, redir, REDIR_VARASSIGN); | - | ||||||||||||||||||
2038 | } | - | ||||||||||||||||||
2039 | #line 2040 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2040 | break; executed 7 times by 1 test: se 16: Executed by:
| 7 | ||||||||||||||||||
2041 | - | |||||||||||||||||||
2042 | case 14: executed 21 times by 1 test Executed by:
| 21 | ||||||||||||||||||
2043 | #line 479 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2044 | { | - | ||||||||||||||||||
2045 | source.filename = (yyvsp[-2].word); | - | ||||||||||||||||||
2046 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2047 | (yyval.redirect) = make_redirection (source, r_input_direction, redir, REDIR_VARASSIGN); | - | ||||||||||||||||||
2048 | } | - | ||||||||||||||||||
2049 | #line 2050 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2050 | break; executed 21 times by 1 test: se 17: Executed by:
| 21 | ||||||||||||||||||
2051 | - | |||||||||||||||||||
2052 | case 15: executed 33 times by 1 test Executed by:
| 33 | ||||||||||||||||||
2053 | #line 485 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2054 | { | - | ||||||||||||||||||
2055 | source.dest = 1; | - | ||||||||||||||||||
2056 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2057 | (yyval.redirect) = make_redirection (source, r_appending_to, redir, 0); | - | ||||||||||||||||||
2058 | } | - | ||||||||||||||||||
2059 | #line 2060 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2060 | break; executed 33 times by 1 test: se 18: Executed by:
| 33 | ||||||||||||||||||
2061 | - | |||||||||||||||||||
2062 | case 16: never executed | 0 | ||||||||||||||||||
2063 | #line 491 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2064 | { | - | ||||||||||||||||||
2065 | source.dest = (yyvsp[-2].number); | - | ||||||||||||||||||
2066 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2067 | (yyval.redirect) = make_redirection (source, r_appending_to, redir, 0); | - | ||||||||||||||||||
2068 | } | - | ||||||||||||||||||
2069 | #line 2070 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2070 | break; never executed: se 19: | 0 | ||||||||||||||||||
2071 | - | |||||||||||||||||||
2072 | case 17: never executed | 0 | ||||||||||||||||||
2073 | #line 497 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2074 | { | - | ||||||||||||||||||
2075 | source.filename = (yyvsp[-2].word); | - | ||||||||||||||||||
2076 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2077 | (yyval.redirect) = make_redirection (source, r_appending_to, redir, REDIR_VARASSIGN); | - | ||||||||||||||||||
2078 | } | - | ||||||||||||||||||
2079 | #line 2080 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2080 | break; never executed: se 20: | 0 | ||||||||||||||||||
2081 | - | |||||||||||||||||||
2082 | case 18: executed 19 times by 1 test Executed by:
| 19 | ||||||||||||||||||
2083 | #line 503 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2084 | { | - | ||||||||||||||||||
2085 | source.dest = 1; | - | ||||||||||||||||||
2086 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2087 | (yyval.redirect) = make_redirection (source, r_output_force, redir, 0); | - | ||||||||||||||||||
2088 | } | - | ||||||||||||||||||
2089 | #line 2090 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2090 | break; executed 19 times by 1 test: se 21: Executed by:
| 19 | ||||||||||||||||||
2091 | - | |||||||||||||||||||
2092 | case 19: never executed | 0 | ||||||||||||||||||
2093 | #line 509 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2094 | { | - | ||||||||||||||||||
2095 | source.dest = (yyvsp[-2].number); | - | ||||||||||||||||||
2096 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2097 | (yyval.redirect) = make_redirection (source, r_output_force, redir, 0); | - | ||||||||||||||||||
2098 | } | - | ||||||||||||||||||
2099 | #line 2100 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2100 | break; never executed: se 22: | 0 | ||||||||||||||||||
2101 | - | |||||||||||||||||||
2102 | case 20: never executed | 0 | ||||||||||||||||||
2103 | #line 515 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2104 | { | - | ||||||||||||||||||
2105 | source.filename = (yyvsp[-2].word); | - | ||||||||||||||||||
2106 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2107 | (yyval.redirect) = make_redirection (source, r_output_force, redir, REDIR_VARASSIGN); | - | ||||||||||||||||||
2108 | } | - | ||||||||||||||||||
2109 | #line 2110 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2110 | break; never executed: se 23: | 0 | ||||||||||||||||||
2111 | - | |||||||||||||||||||
2112 | case 21: never executed | 0 | ||||||||||||||||||
2113 | #line 521 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2114 | { | - | ||||||||||||||||||
2115 | source.dest = 0; | - | ||||||||||||||||||
2116 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2117 | (yyval.redirect) = make_redirection (source, r_input_output, redir, 0); | - | ||||||||||||||||||
2118 | } | - | ||||||||||||||||||
2119 | #line 2120 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2120 | break; never executed: se 24: | 0 | ||||||||||||||||||
2121 | - | |||||||||||||||||||
2122 | case 22: executed 18 times by 1 test Executed by:
| 18 | ||||||||||||||||||
2123 | #line 527 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2124 | { | - | ||||||||||||||||||
2125 | source.dest = (yyvsp[-2].number); | - | ||||||||||||||||||
2126 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2127 | (yyval.redirect) = make_redirection (source, r_input_output, redir, 0); | - | ||||||||||||||||||
2128 | } | - | ||||||||||||||||||
2129 | #line 2130 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2130 | break; executed 18 times by 1 test: se 25: Executed by:
| 18 | ||||||||||||||||||
2131 | - | |||||||||||||||||||
2132 | case 23: never executed | 0 | ||||||||||||||||||
2133 | #line 533 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2134 | { | - | ||||||||||||||||||
2135 | source.filename = (yyvsp[-2].word); | - | ||||||||||||||||||
2136 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2137 | (yyval.redirect) = make_redirection (source, r_input_output, redir, REDIR_VARASSIGN); | - | ||||||||||||||||||
2138 | } | - | ||||||||||||||||||
2139 | #line 2140 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2140 | break; never executed: se 26: | 0 | ||||||||||||||||||
2141 | - | |||||||||||||||||||
2142 | case 24: executed 1710 times by 1 test Executed by:
| 1710 | ||||||||||||||||||
2143 | #line 539 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2144 | { | - | ||||||||||||||||||
2145 | source.dest = 0; | - | ||||||||||||||||||
2146 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2147 | (yyval.redirect) = make_redirection (source, r_reading_until, redir, 0); | - | ||||||||||||||||||
2148 | push_heredoc ((yyval.redirect)); | - | ||||||||||||||||||
2149 | } | - | ||||||||||||||||||
2150 | #line 2151 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2151 | break; executed 1709 times by 1 test: se 27: Executed by:
| 1709 | ||||||||||||||||||
2152 | - | |||||||||||||||||||
2153 | case 25: executed 2 times by 1 test Executed by:
| 2 | ||||||||||||||||||
2154 | #line 546 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2155 | { | - | ||||||||||||||||||
2156 | source.dest = (yyvsp[-2].number); | - | ||||||||||||||||||
2157 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2158 | (yyval.redirect) = make_redirection (source, r_reading_until, redir, 0); | - | ||||||||||||||||||
2159 | push_heredoc ((yyval.redirect)); | - | ||||||||||||||||||
2160 | } | - | ||||||||||||||||||
2161 | #line 2162 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2162 | break; executed 2 times by 1 test: se 28: Executed by:
| 2 | ||||||||||||||||||
2163 | - | |||||||||||||||||||
2164 | case 26: executed 1 time by 1 test Executed by:
| 1 | ||||||||||||||||||
2165 | #line 553 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2166 | { | - | ||||||||||||||||||
2167 | source.filename = (yyvsp[-2].word); | - | ||||||||||||||||||
2168 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2169 | (yyval.redirect) = make_redirection (source, r_reading_until, redir, REDIR_VARASSIGN); | - | ||||||||||||||||||
2170 | push_heredoc ((yyval.redirect)); | - | ||||||||||||||||||
2171 | } | - | ||||||||||||||||||
2172 | #line 2173 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2173 | break; executed 1 time by 1 test: se 29: Executed by:
| 1 | ||||||||||||||||||
2174 | - | |||||||||||||||||||
2175 | case 27: executed 38 times by 1 test Executed by:
| 38 | ||||||||||||||||||
2176 | #line 560 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2177 | { | - | ||||||||||||||||||
2178 | source.dest = 0; | - | ||||||||||||||||||
2179 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2180 | (yyval.redirect) = make_redirection (source, r_deblank_reading_until, redir, 0); | - | ||||||||||||||||||
2181 | push_heredoc ((yyval.redirect)); | - | ||||||||||||||||||
2182 | } | - | ||||||||||||||||||
2183 | #line 2184 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2184 | break; executed 38 times by 1 test: se 30: Executed by:
| 38 | ||||||||||||||||||
2185 | - | |||||||||||||||||||
2186 | case 28: never executed | 0 | ||||||||||||||||||
2187 | #line 567 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2188 | { | - | ||||||||||||||||||
2189 | source.dest = (yyvsp[-2].number); | - | ||||||||||||||||||
2190 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2191 | (yyval.redirect) = make_redirection (source, r_deblank_reading_until, redir, 0); | - | ||||||||||||||||||
2192 | push_heredoc ((yyval.redirect)); | - | ||||||||||||||||||
2193 | } | - | ||||||||||||||||||
2194 | #line 2195 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2195 | break; never executed: se 31: | 0 | ||||||||||||||||||
2196 | - | |||||||||||||||||||
2197 | case 29: never executed | 0 | ||||||||||||||||||
2198 | #line 574 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2199 | { | - | ||||||||||||||||||
2200 | source.filename = (yyvsp[-2].word); | - | ||||||||||||||||||
2201 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2202 | (yyval.redirect) = make_redirection (source, r_deblank_reading_until, redir, REDIR_VARASSIGN); | - | ||||||||||||||||||
2203 | push_heredoc ((yyval.redirect)); | - | ||||||||||||||||||
2204 | } | - | ||||||||||||||||||
2205 | #line 2206 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2206 | break; never executed: se 32: | 0 | ||||||||||||||||||
2207 | - | |||||||||||||||||||
2208 | case 30: executed 65 times by 1 test Executed by:
| 65 | ||||||||||||||||||
2209 | #line 581 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2210 | { | - | ||||||||||||||||||
2211 | source.dest = 0; | - | ||||||||||||||||||
2212 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2213 | (yyval.redirect) = make_redirection (source, r_reading_string, redir, 0); | - | ||||||||||||||||||
2214 | } | - | ||||||||||||||||||
2215 | #line 2216 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2216 | break; executed 65 times by 1 test: se 33: Executed by:
| 65 | ||||||||||||||||||
2217 | - | |||||||||||||||||||
2218 | case 31: never executed | 0 | ||||||||||||||||||
2219 | #line 587 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2220 | { | - | ||||||||||||||||||
2221 | source.dest = (yyvsp[-2].number); | - | ||||||||||||||||||
2222 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2223 | (yyval.redirect) = make_redirection (source, r_reading_string, redir, 0); | - | ||||||||||||||||||
2224 | } | - | ||||||||||||||||||
2225 | #line 2226 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2226 | break; never executed: se 34: | 0 | ||||||||||||||||||
2227 | - | |||||||||||||||||||
2228 | case 32: never executed | 0 | ||||||||||||||||||
2229 | #line 593 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2230 | { | - | ||||||||||||||||||
2231 | source.filename = (yyvsp[-2].word); | - | ||||||||||||||||||
2232 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2233 | (yyval.redirect) = make_redirection (source, r_reading_string, redir, REDIR_VARASSIGN); | - | ||||||||||||||||||
2234 | } | - | ||||||||||||||||||
2235 | #line 2236 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2236 | break; never executed: se 35: | 0 | ||||||||||||||||||
2237 | - | |||||||||||||||||||
2238 | case 33: executed 9 times by 1 test Executed by:
| 9 | ||||||||||||||||||
2239 | #line 599 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2240 | { | - | ||||||||||||||||||
2241 | source.dest = 0; | - | ||||||||||||||||||
2242 | redir.dest = (yyvsp[0].number); | - | ||||||||||||||||||
2243 | (yyval.redirect) = make_redirection (source, r_duplicating_input, redir, 0); | - | ||||||||||||||||||
2244 | } | - | ||||||||||||||||||
2245 | #line 2246 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2246 | break; executed 9 times by 1 test: se 36: Executed by:
| 9 | ||||||||||||||||||
2247 | - | |||||||||||||||||||
2248 | case 34: executed 19 times by 1 test Executed by:
| 19 | ||||||||||||||||||
2249 | #line 605 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2250 | { | - | ||||||||||||||||||
2251 | source.dest = (yyvsp[-2].number); | - | ||||||||||||||||||
2252 | redir.dest = (yyvsp[0].number); | - | ||||||||||||||||||
2253 | (yyval.redirect) = make_redirection (source, r_duplicating_input, redir, 0); | - | ||||||||||||||||||
2254 | } | - | ||||||||||||||||||
2255 | #line 2256 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2256 | break; executed 19 times by 1 test: se 37: Executed by:
| 19 | ||||||||||||||||||
2257 | - | |||||||||||||||||||
2258 | case 35: executed 2 times by 1 test Executed by:
| 2 | ||||||||||||||||||
2259 | #line 611 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2260 | { | - | ||||||||||||||||||
2261 | source.filename = (yyvsp[-2].word); | - | ||||||||||||||||||
2262 | redir.dest = (yyvsp[0].number); | - | ||||||||||||||||||
2263 | (yyval.redirect) = make_redirection (source, r_duplicating_input, redir, REDIR_VARASSIGN); | - | ||||||||||||||||||
2264 | } | - | ||||||||||||||||||
2265 | #line 2266 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2266 | break; executed 2 times by 1 test: se 38: Executed by:
| 2 | ||||||||||||||||||
2267 | - | |||||||||||||||||||
2268 | case 36: executed 20535 times by 1 test Executed by:
| 20535 | ||||||||||||||||||
2269 | #line 617 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2270 | { | - | ||||||||||||||||||
2271 | source.dest = 1; | - | ||||||||||||||||||
2272 | redir.dest = (yyvsp[0].number); | - | ||||||||||||||||||
2273 | (yyval.redirect) = make_redirection (source, r_duplicating_output, redir, 0); | - | ||||||||||||||||||
2274 | } | - | ||||||||||||||||||
2275 | #line 2276 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2276 | break; executed 20535 times by 1 test: se 39: Executed by:
| 20535 | ||||||||||||||||||
2277 | - | |||||||||||||||||||
2278 | case 37: executed 722 times by 1 test Executed by:
| 722 | ||||||||||||||||||
2279 | #line 623 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2280 | { | - | ||||||||||||||||||
2281 | source.dest = (yyvsp[-2].number); | - | ||||||||||||||||||
2282 | redir.dest = (yyvsp[0].number); | - | ||||||||||||||||||
2283 | (yyval.redirect) = make_redirection (source, r_duplicating_output, redir, 0); | - | ||||||||||||||||||
2284 | } | - | ||||||||||||||||||
2285 | #line 2286 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2286 | break; executed 722 times by 1 test: se 40: Executed by:
| 722 | ||||||||||||||||||
2287 | - | |||||||||||||||||||
2288 | case 38: executed 3 times by 1 test Executed by:
| 3 | ||||||||||||||||||
2289 | #line 629 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2290 | { | - | ||||||||||||||||||
2291 | source.filename = (yyvsp[-2].word); | - | ||||||||||||||||||
2292 | redir.dest = (yyvsp[0].number); | - | ||||||||||||||||||
2293 | (yyval.redirect) = make_redirection (source, r_duplicating_output, redir, REDIR_VARASSIGN); | - | ||||||||||||||||||
2294 | } | - | ||||||||||||||||||
2295 | #line 2296 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2296 | break; executed 3 times by 1 test: se 41: Executed by:
| 3 | ||||||||||||||||||
2297 | - | |||||||||||||||||||
2298 | case 39: executed 11 times by 1 test Executed by:
| 11 | ||||||||||||||||||
2299 | #line 635 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2300 | { | - | ||||||||||||||||||
2301 | source.dest = 0; | - | ||||||||||||||||||
2302 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2303 | (yyval.redirect) = make_redirection (source, r_duplicating_input_word, redir, 0); | - | ||||||||||||||||||
2304 | } | - | ||||||||||||||||||
2305 | #line 2306 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2306 | break; executed 11 times by 1 test: se 42: Executed by:
| 11 | ||||||||||||||||||
2307 | - | |||||||||||||||||||
2308 | case 40: executed 6 times by 1 test Executed by:
| 6 | ||||||||||||||||||
2309 | #line 641 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2310 | { | - | ||||||||||||||||||
2311 | source.dest = (yyvsp[-2].number); | - | ||||||||||||||||||
2312 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2313 | (yyval.redirect) = make_redirection (source, r_duplicating_input_word, redir, 0); | - | ||||||||||||||||||
2314 | } | - | ||||||||||||||||||
2315 | #line 2316 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2316 | break; executed 6 times by 1 test: se 43: Executed by:
| 6 | ||||||||||||||||||
2317 | - | |||||||||||||||||||
2318 | case 41: executed 3 times by 1 test Executed by:
| 3 | ||||||||||||||||||
2319 | #line 647 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2320 | { | - | ||||||||||||||||||
2321 | source.filename = (yyvsp[-2].word); | - | ||||||||||||||||||
2322 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2323 | (yyval.redirect) = make_redirection (source, r_duplicating_input_word, redir, REDIR_VARASSIGN); | - | ||||||||||||||||||
2324 | } | - | ||||||||||||||||||
2325 | #line 2326 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2326 | break; executed 3 times by 1 test: se 44: Executed by:
| 3 | ||||||||||||||||||
2327 | - | |||||||||||||||||||
2328 | case 42: executed 111 times by 1 test Executed by:
| 111 | ||||||||||||||||||
2329 | #line 653 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2330 | { | - | ||||||||||||||||||
2331 | source.dest = 1; | - | ||||||||||||||||||
2332 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2333 | (yyval.redirect) = make_redirection (source, r_duplicating_output_word, redir, 0); | - | ||||||||||||||||||
2334 | } | - | ||||||||||||||||||
2335 | #line 2336 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2336 | break; executed 111 times by 1 test: se 45: Executed by:
| 111 | ||||||||||||||||||
2337 | - | |||||||||||||||||||
2338 | case 43: executed 3 times by 1 test Executed by:
| 3 | ||||||||||||||||||
2339 | #line 659 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2340 | { | - | ||||||||||||||||||
2341 | source.dest = (yyvsp[-2].number); | - | ||||||||||||||||||
2342 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2343 | (yyval.redirect) = make_redirection (source, r_duplicating_output_word, redir, 0); | - | ||||||||||||||||||
2344 | } | - | ||||||||||||||||||
2345 | #line 2346 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2346 | break; executed 3 times by 1 test: se 46: Executed by:
| 3 | ||||||||||||||||||
2347 | - | |||||||||||||||||||
2348 | case 44: executed 3 times by 1 test Executed by:
| 3 | ||||||||||||||||||
2349 | #line 665 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2350 | { | - | ||||||||||||||||||
2351 | source.filename = (yyvsp[-2].word); | - | ||||||||||||||||||
2352 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2353 | (yyval.redirect) = make_redirection (source, r_duplicating_output_word, redir, REDIR_VARASSIGN); | - | ||||||||||||||||||
2354 | } | - | ||||||||||||||||||
2355 | #line 2356 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2356 | break; executed 3 times by 1 test: se 47: Executed by:
| 3 | ||||||||||||||||||
2357 | - | |||||||||||||||||||
2358 | case 45: executed 6 times by 1 test Executed by:
| 6 | ||||||||||||||||||
2359 | #line 671 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2360 | { | - | ||||||||||||||||||
2361 | source.dest = 1; | - | ||||||||||||||||||
2362 | redir.dest = 0; | - | ||||||||||||||||||
2363 | (yyval.redirect) = make_redirection (source, r_close_this, redir, 0); | - | ||||||||||||||||||
2364 | } | - | ||||||||||||||||||
2365 | #line 2366 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2366 | break; executed 6 times by 1 test: se 48: Executed by:
| 6 | ||||||||||||||||||
2367 | - | |||||||||||||||||||
2368 | case 46: executed 1017 times by 1 test Executed by:
| 1017 | ||||||||||||||||||
2369 | #line 677 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2370 | { | - | ||||||||||||||||||
2371 | source.dest = (yyvsp[-2].number); | - | ||||||||||||||||||
2372 | redir.dest = 0; | - | ||||||||||||||||||
2373 | (yyval.redirect) = make_redirection (source, r_close_this, redir, 0); | - | ||||||||||||||||||
2374 | } | - | ||||||||||||||||||
2375 | #line 2376 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2376 | break; executed 1017 times by 1 test: se 49: Executed by:
| 1017 | ||||||||||||||||||
2377 | - | |||||||||||||||||||
2378 | case 47: executed 3 times by 1 test Executed by:
| 3 | ||||||||||||||||||
2379 | #line 683 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2380 | { | - | ||||||||||||||||||
2381 | source.filename = (yyvsp[-2].word); | - | ||||||||||||||||||
2382 | redir.dest = 0; | - | ||||||||||||||||||
2383 | (yyval.redirect) = make_redirection (source, r_close_this, redir, REDIR_VARASSIGN); | - | ||||||||||||||||||
2384 | } | - | ||||||||||||||||||
2385 | #line 2386 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2386 | break; executed 3 times by 1 test: se 50: Executed by:
| 3 | ||||||||||||||||||
2387 | - | |||||||||||||||||||
2388 | case 48: executed 1 time by 1 test Executed by:
| 1 | ||||||||||||||||||
2389 | #line 689 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2390 | { | - | ||||||||||||||||||
2391 | source.dest = 0; | - | ||||||||||||||||||
2392 | redir.dest = 0; | - | ||||||||||||||||||
2393 | (yyval.redirect) = make_redirection (source, r_close_this, redir, 0); | - | ||||||||||||||||||
2394 | } | - | ||||||||||||||||||
2395 | #line 2396 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2396 | break; executed 1 time by 1 test: se 51: Executed by:
| 1 | ||||||||||||||||||
2397 | - | |||||||||||||||||||
2398 | case 49: executed 23 times by 1 test Executed by:
| 23 | ||||||||||||||||||
2399 | #line 695 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2400 | { | - | ||||||||||||||||||
2401 | source.dest = (yyvsp[-2].number); | - | ||||||||||||||||||
2402 | redir.dest = 0; | - | ||||||||||||||||||
2403 | (yyval.redirect) = make_redirection (source, r_close_this, redir, 0); | - | ||||||||||||||||||
2404 | } | - | ||||||||||||||||||
2405 | #line 2406 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2406 | break; executed 23 times by 1 test: se 52: Executed by:
| 23 | ||||||||||||||||||
2407 | - | |||||||||||||||||||
2408 | case 50: executed 2 times by 1 test Executed by:
| 2 | ||||||||||||||||||
2409 | #line 701 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2410 | { | - | ||||||||||||||||||
2411 | source.filename = (yyvsp[-2].word); | - | ||||||||||||||||||
2412 | redir.dest = 0; | - | ||||||||||||||||||
2413 | (yyval.redirect) = make_redirection (source, r_close_this, redir, REDIR_VARASSIGN); | - | ||||||||||||||||||
2414 | } | - | ||||||||||||||||||
2415 | #line 2416 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2416 | break; executed 2 times by 1 test: se 53: Executed by:
| 2 | ||||||||||||||||||
2417 | - | |||||||||||||||||||
2418 | case 51: executed 18 times by 1 test Executed by:
| 18 | ||||||||||||||||||
2419 | #line 707 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2420 | { | - | ||||||||||||||||||
2421 | source.dest = 1; | - | ||||||||||||||||||
2422 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2423 | (yyval.redirect) = make_redirection (source, r_err_and_out, redir, 0); | - | ||||||||||||||||||
2424 | } | - | ||||||||||||||||||
2425 | #line 2426 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2426 | break; executed 18 times by 1 test: se 54: Executed by:
| 18 | ||||||||||||||||||
2427 | - | |||||||||||||||||||
2428 | case 52: executed 4 times by 1 test Executed by:
| 4 | ||||||||||||||||||
2429 | #line 713 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2430 | { | - | ||||||||||||||||||
2431 | source.dest = 1; | - | ||||||||||||||||||
2432 | redir.filename = (yyvsp[0].word); | - | ||||||||||||||||||
2433 | (yyval.redirect) = make_redirection (source, r_append_err_and_out, redir, 0); | - | ||||||||||||||||||
2434 | } | - | ||||||||||||||||||
2435 | #line 2436 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2436 | break; executed 4 times by 1 test: se 55: Executed by:
| 4 | ||||||||||||||||||
2437 | - | |||||||||||||||||||
2438 | case 53: executed 1911366 times by 1 test Executed by:
| 1911366 | ||||||||||||||||||
2439 | #line 721 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2440 | { (yyval.element).word = (yyvsp[0].word); (yyval.element).redirect = 0; } | - | ||||||||||||||||||
2441 | #line 2442 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2442 | break; executed 1911366 times by 1 test: se 56: Executed by:
| 1911366 | ||||||||||||||||||
2443 | - | |||||||||||||||||||
2444 | case 54: executed 115176 times by 1 test Executed by:
| 115176 | ||||||||||||||||||
2445 | #line 723 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2446 | { (yyval.element).word = (yyvsp[0].word); (yyval.element).redirect = 0; } | - | ||||||||||||||||||
2447 | #line 2448 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2448 | break; executed 115176 times by 1 test: se 57: Executed by:
| 115176 | ||||||||||||||||||
2449 | - | |||||||||||||||||||
2450 | case 55: executed 35415 times by 1 test Executed by:
| 35415 | ||||||||||||||||||
2451 | #line 725 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2452 | { (yyval.element).redirect = (yyvsp[0].redirect); (yyval.element).word = 0; } | - | ||||||||||||||||||
2453 | #line 2454 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2454 | break; executed 35415 times by 1 test: se 58: Executed by:
| 35415 | ||||||||||||||||||
2455 | - | |||||||||||||||||||
2456 | case 56: executed 3124 times by 1 test Executed by:
| 3124 | ||||||||||||||||||
2457 | #line 729 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2458 | { | - | ||||||||||||||||||
2459 | (yyval.redirect) = (yyvsp[0].redirect); | - | ||||||||||||||||||
2460 | } | - | ||||||||||||||||||
2461 | #line 2462 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2462 | break; executed 3124 times by 1 test: se 59: Executed by:
| 3124 | ||||||||||||||||||
2463 | - | |||||||||||||||||||
2464 | case 57: executed 11 times by 1 test Executed by:
| 11 | ||||||||||||||||||
2465 | #line 733 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2466 | { | - | ||||||||||||||||||
2467 | register REDIRECT *t; | - | ||||||||||||||||||
2468 | - | |||||||||||||||||||
2469 | for (t = (yyvsp[-1].redirect); t->next; t = t->next) | - | ||||||||||||||||||
2470 | ; | - | ||||||||||||||||||
2471 | t->next = (yyvsp[0].redirect); | - | ||||||||||||||||||
2472 | (yyval.redirect) = (yyvsp[-1].redirect); | - | ||||||||||||||||||
2473 | } | - | ||||||||||||||||||
2474 | #line 2475 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2475 | break; executed 11 times by 1 test: se 60: Executed by:
| 11 | ||||||||||||||||||
2476 | - | |||||||||||||||||||
2477 | case 58: executed 1038339 times by 1 test Executed by:
| 1038339 | ||||||||||||||||||
2478 | #line 744 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2479 | { (yyval.command) = make_simple_command ((yyvsp[0].element), (COMMAND *)NULL); } | - | ||||||||||||||||||
2480 | #line 2481 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2481 | break; executed 1038339 times by 1 test: se 61: Executed by:
| 1038339 | ||||||||||||||||||
2482 | - | |||||||||||||||||||
2483 | case 59: executed 1023618 times by 1 test Executed by:
| 1023618 | ||||||||||||||||||
2484 | #line 746 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2485 | { (yyval.command) = make_simple_command ((yyvsp[0].element), (yyvsp[-1].command)); } | - | ||||||||||||||||||
2486 | #line 2487 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2487 | break; executed 1023618 times by 1 test: se 62: Executed by:
| 1023618 | ||||||||||||||||||
2488 | - | |||||||||||||||||||
2489 | case 60: executed 1038337 times by 1 test Executed by:
| 1038337 | ||||||||||||||||||
2490 | #line 750 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2491 | { (yyval.command) = clean_simple_command ((yyvsp[0].command)); } | - | ||||||||||||||||||
2492 | #line 2493 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2493 | break; executed 1038337 times by 1 test: se 63: Executed by:
| 1038337 | ||||||||||||||||||
2494 | - | |||||||||||||||||||
2495 | case 61: executed 164437 times by 1 test Executed by:
| 164437 | ||||||||||||||||||
2496 | #line 752 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2497 | { (yyval.command) = (yyvsp[0].command); } | - | ||||||||||||||||||
2498 | #line 2499 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2499 | break; executed 164437 times by 1 test: se 64: Executed by:
| 164437 | ||||||||||||||||||
2500 | - | |||||||||||||||||||
2501 | case 62: executed 3093 times by 1 test Executed by:
| 3093 | ||||||||||||||||||
2502 | #line 754 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2503 | { | - | ||||||||||||||||||
2504 | COMMAND *tc; | - | ||||||||||||||||||
2505 | - | |||||||||||||||||||
2506 | tc = (yyvsp[-1].command); | - | ||||||||||||||||||
2507 | if (tc && tc->redirects) | - | ||||||||||||||||||
2508 | { | - | ||||||||||||||||||
2509 | register REDIRECT *t; | - | ||||||||||||||||||
2510 | for (t = tc->redirects; t->next; t = t->next) | - | ||||||||||||||||||
2511 | ; | - | ||||||||||||||||||
2512 | t->next = (yyvsp[0].redirect); | - | ||||||||||||||||||
2513 | } | - | ||||||||||||||||||
2514 | else if (tc) | - | ||||||||||||||||||
2515 | tc->redirects = (yyvsp[0].redirect); | - | ||||||||||||||||||
2516 | (yyval.command) = (yyvsp[-1].command); | - | ||||||||||||||||||
2517 | } | - | ||||||||||||||||||
2518 | #line 2519 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2519 | break; executed 3093 times by 1 test: se 65: Executed by:
| 3093 | ||||||||||||||||||
2520 | - | |||||||||||||||||||
2521 | case 63: executed 11211 times by 1 test Executed by:
| 11211 | ||||||||||||||||||
2522 | #line 770 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2523 | { (yyval.command) = (yyvsp[0].command); } | - | ||||||||||||||||||
2524 | #line 2525 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2525 | break; executed 11211 times by 1 test: se 66: Executed by:
| 11211 | ||||||||||||||||||
2526 | - | |||||||||||||||||||
2527 | case 64: executed 37 times by 1 test Executed by:
| 37 | ||||||||||||||||||
2528 | #line 772 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2529 | { (yyval.command) = (yyvsp[0].command); } | - | ||||||||||||||||||
2530 | #line 2531 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2531 | break; executed 37 times by 1 test: se 67: Executed by:
| 37 | ||||||||||||||||||
2532 | - | |||||||||||||||||||
2533 | case 65: executed 25652 times by 1 test Executed by:
| 25652 | ||||||||||||||||||
2534 | #line 776 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2535 | { (yyval.command) = (yyvsp[0].command); } | - | ||||||||||||||||||
2536 | #line 2537 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2537 | break; executed 25652 times by 1 test: se 68: Executed by:
| 25652 | ||||||||||||||||||
2538 | - | |||||||||||||||||||
2539 | case 66: executed 78110 times by 1 test Executed by:
| 78110 | ||||||||||||||||||
2540 | #line 778 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2541 | { (yyval.command) = (yyvsp[0].command); } | - | ||||||||||||||||||
2542 | #line 2543 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2543 | break; executed 78110 times by 1 test: se 69: Executed by:
| 78110 | ||||||||||||||||||
2544 | - | |||||||||||||||||||
2545 | case 67: executed 5156 times by 1 test Executed by:
| 5156 | ||||||||||||||||||
2546 | #line 780 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2547 | { (yyval.command) = make_while_command ((yyvsp[-3].command), (yyvsp[-1].command)); } | - | ||||||||||||||||||
2548 | #line 2549 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2549 | break; executed 5156 times by 1 test: se 70: Executed by:
| 5156 | ||||||||||||||||||
2550 | - | |||||||||||||||||||
2551 | case 68: executed 16 times by 1 test Executed by:
| 16 | ||||||||||||||||||
2552 | #line 782 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2553 | { (yyval.command) = make_until_command ((yyvsp[-3].command), (yyvsp[-1].command)); } | - | ||||||||||||||||||
2554 | #line 2555 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2555 | break; executed 16 times by 1 test: se 71: Executed by:
| 16 | ||||||||||||||||||
2556 | - | |||||||||||||||||||
2557 | case 69: executed 9 times by 1 test Executed by:
| 9 | ||||||||||||||||||
2558 | #line 784 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2559 | { (yyval.command) = (yyvsp[0].command); } | - | ||||||||||||||||||
2560 | #line 2561 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2561 | break; executed 9 times by 1 test: se 72: Executed by:
| 9 | ||||||||||||||||||
2562 | - | |||||||||||||||||||
2563 | case 70: executed 1547 times by 1 test Executed by:
| 1547 | ||||||||||||||||||
2564 | #line 786 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2565 | { (yyval.command) = (yyvsp[0].command); } | - | ||||||||||||||||||
2566 | #line 2567 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2567 | break; executed 1547 times by 1 test: se 73: Executed by:
| 1547 | ||||||||||||||||||
2568 | - | |||||||||||||||||||
2569 | case 71: executed 5977 times by 1 test Executed by:
| 5977 | ||||||||||||||||||
2570 | #line 788 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2571 | { (yyval.command) = (yyvsp[0].command); } | - | ||||||||||||||||||
2572 | #line 2573 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2573 | break; executed 5977 times by 1 test: se 74: Executed by:
| 5977 | ||||||||||||||||||
2574 | - | |||||||||||||||||||
2575 | case 72: executed 12022 times by 1 test Executed by:
| 12022 | ||||||||||||||||||
2576 | #line 790 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2577 | { (yyval.command) = (yyvsp[0].command); } | - | ||||||||||||||||||
2578 | #line 2579 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2579 | break; executed 12022 times by 1 test: se 75: Executed by:
| 12022 | ||||||||||||||||||
2580 | - | |||||||||||||||||||
2581 | case 73: executed 47077 times by 1 test Executed by:
| 47077 | ||||||||||||||||||
2582 | #line 792 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2583 | { (yyval.command) = (yyvsp[0].command); } | - | ||||||||||||||||||
2584 | #line 2585 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2585 | break; executed 47077 times by 1 test: se 76: Executed by:
| 47077 | ||||||||||||||||||
2586 | - | |||||||||||||||||||
2587 | case 74: executed 574 times by 1 test Executed by:
| 574 | ||||||||||||||||||
2588 | #line 794 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2589 | { (yyval.command) = (yyvsp[0].command); } | - | ||||||||||||||||||
2590 | #line 2591 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2591 | break; executed 574 times by 1 test: se 77: Executed by:
| 574 | ||||||||||||||||||
2592 | - | |||||||||||||||||||
2593 | case 75: executed 2639 times by 1 test Executed by:
| 2639 | ||||||||||||||||||
2594 | #line 796 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2595 | { (yyval.command) = (yyvsp[0].command); } | - | ||||||||||||||||||
2596 | #line 2597 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2597 | break; executed 2639 times by 1 test: se 78: Executed by:
| 2639 | ||||||||||||||||||
2598 | - | |||||||||||||||||||
2599 | case 76: executed 1 time by 1 test Executed by:
| 1 | ||||||||||||||||||
2600 | #line 800 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2601 | { | - | ||||||||||||||||||
2602 | (yyval.command) = make_for_command ((yyvsp[-4].word), add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), (yyvsp[-1].command), word_lineno[word_top]); | - | ||||||||||||||||||
2603 | if (word_top > 0) word_top--; | - | ||||||||||||||||||
2604 | } | - | ||||||||||||||||||
2605 | #line 2606 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2606 | break; executed 1 time by 1 test: se 79: Executed by:
| 1 | ||||||||||||||||||
2607 | - | |||||||||||||||||||
2608 | case 77: never executed | 0 | ||||||||||||||||||
2609 | #line 805 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2610 | { | - | ||||||||||||||||||
2611 | (yyval.command) = make_for_command ((yyvsp[-4].word), add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), (yyvsp[-1].command), word_lineno[word_top]); | - | ||||||||||||||||||
2612 | if (word_top > 0) word_top--; | - | ||||||||||||||||||
2613 | } | - | ||||||||||||||||||
2614 | #line 2615 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2615 | break; never executed: se 80: | 0 | ||||||||||||||||||
2616 | - | |||||||||||||||||||
2617 | case 78: executed 2 times by 1 test Executed by:
| 2 | ||||||||||||||||||
2618 | #line 810 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2619 | { | - | ||||||||||||||||||
2620 | (yyval.command) = make_for_command ((yyvsp[-5].word), add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), (yyvsp[-1].command), word_lineno[word_top]); | - | ||||||||||||||||||
2621 | if (word_top > 0) word_top--; | - | ||||||||||||||||||
2622 | } | - | ||||||||||||||||||
2623 | #line 2624 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2624 | break; executed 2 times by 1 test: se 81: Executed by:
| 2 | ||||||||||||||||||
2625 | - | |||||||||||||||||||
2626 | case 79: never executed | 0 | ||||||||||||||||||
2627 | #line 815 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2628 | { | - | ||||||||||||||||||
2629 | (yyval.command) = make_for_command ((yyvsp[-5].word), add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), (yyvsp[-1].command), word_lineno[word_top]); | - | ||||||||||||||||||
2630 | if (word_top > 0) word_top--; | - | ||||||||||||||||||
2631 | } | - | ||||||||||||||||||
2632 | #line 2633 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2633 | break; never executed: se 82: | 0 | ||||||||||||||||||
2634 | - | |||||||||||||||||||
2635 | case 80: executed 25449 times by 1 test Executed by:
| 25449 | ||||||||||||||||||
2636 | #line 820 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2637 | { | - | ||||||||||||||||||
2638 | (yyval.command) = make_for_command ((yyvsp[-8].word), REVERSE_LIST ((yyvsp[-5].word_list), WORD_LIST *), (yyvsp[-1].command), word_lineno[word_top]); | - | ||||||||||||||||||
2639 | if (word_top > 0) word_top--; | - | ||||||||||||||||||
2640 | } | - | ||||||||||||||||||
2641 | #line 2642 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2642 | break; executed 25449 times by 1 test: se 83: Executed by:
| 25449 | ||||||||||||||||||
2643 | - | |||||||||||||||||||
2644 | case 81: never executed | 0 | ||||||||||||||||||
2645 | #line 825 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2646 | { | - | ||||||||||||||||||
2647 | (yyval.command) = make_for_command ((yyvsp[-8].word), REVERSE_LIST ((yyvsp[-5].word_list), WORD_LIST *), (yyvsp[-1].command), word_lineno[word_top]); | - | ||||||||||||||||||
2648 | if (word_top > 0) word_top--; | - | ||||||||||||||||||
2649 | } | - | ||||||||||||||||||
2650 | #line 2651 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2651 | break; never executed: se 84: | 0 | ||||||||||||||||||
2652 | - | |||||||||||||||||||
2653 | case 82: executed 200 times by 1 test Executed by:
| 200 | ||||||||||||||||||
2654 | #line 830 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2655 | { | - | ||||||||||||||||||
2656 | (yyval.command) = make_for_command ((yyvsp[-7].word), (WORD_LIST *)NULL, (yyvsp[-1].command), word_lineno[word_top]); | - | ||||||||||||||||||
2657 | if (word_top > 0) word_top--; | - | ||||||||||||||||||
2658 | } | - | ||||||||||||||||||
2659 | #line 2660 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2660 | break; executed 200 times by 1 test: se 85: Executed by:
| 200 | ||||||||||||||||||
2661 | - | |||||||||||||||||||
2662 | case 83: never executed | 0 | ||||||||||||||||||
2663 | #line 835 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2664 | { | - | ||||||||||||||||||
2665 | (yyval.command) = make_for_command ((yyvsp[-7].word), (WORD_LIST *)NULL, (yyvsp[-1].command), word_lineno[word_top]); | - | ||||||||||||||||||
2666 | if (word_top > 0) word_top--; | - | ||||||||||||||||||
2667 | } | - | ||||||||||||||||||
2668 | #line 2669 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2669 | break; never executed: se 86: | 0 | ||||||||||||||||||
2670 | - | |||||||||||||||||||
2671 | case 84: executed 2239 times by 1 test Executed by:
| 2239 | ||||||||||||||||||
2672 | #line 842 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2673 | { | - | ||||||||||||||||||
2674 | (yyval.command) = make_arith_for_command ((yyvsp[-5].word_list), (yyvsp[-1].command), arith_for_lineno); | - | ||||||||||||||||||
2675 | if ((yyval.command) == 0) YYERROR; | - | ||||||||||||||||||
2676 | if (word_top > 0) word_top--; | - | ||||||||||||||||||
2677 | } | - | ||||||||||||||||||
2678 | #line 2679 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2679 | break; executed 2237 times by 1 test: se 87: Executed by:
| 2237 | ||||||||||||||||||
2680 | - | |||||||||||||||||||
2681 | case 85: never executed | 0 | ||||||||||||||||||
2682 | #line 848 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2683 | { | - | ||||||||||||||||||
2684 | (yyval.command) = make_arith_for_command ((yyvsp[-5].word_list), (yyvsp[-1].command), arith_for_lineno); | - | ||||||||||||||||||
2685 | if ((yyval.command) == 0) YYERROR; | - | ||||||||||||||||||
2686 | if (word_top > 0) word_top--; | - | ||||||||||||||||||
2687 | } | - | ||||||||||||||||||
2688 | #line 2689 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2689 | break; never executed: se 88: | 0 | ||||||||||||||||||
2690 | - | |||||||||||||||||||
2691 | case 86: executed 201 times by 1 test Executed by:
| 201 | ||||||||||||||||||
2692 | #line 854 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2693 | { | - | ||||||||||||||||||
2694 | (yyval.command) = make_arith_for_command ((yyvsp[-3].word_list), (yyvsp[-1].command), arith_for_lineno); | - | ||||||||||||||||||
2695 | if ((yyval.command) == 0) YYERROR; | - | ||||||||||||||||||
2696 | if (word_top > 0) word_top--; | - | ||||||||||||||||||
2697 | } | - | ||||||||||||||||||
2698 | #line 2699 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2699 | break; executed 201 times by 1 test: se 89: Executed by:
| 201 | ||||||||||||||||||
2700 | - | |||||||||||||||||||
2701 | case 87: executed 201 times by 1 test Executed by:
| 201 | ||||||||||||||||||
2702 | #line 860 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2703 | { | - | ||||||||||||||||||
2704 | (yyval.command) = make_arith_for_command ((yyvsp[-3].word_list), (yyvsp[-1].command), arith_for_lineno); | - | ||||||||||||||||||
2705 | if ((yyval.command) == 0) YYERROR; | - | ||||||||||||||||||
2706 | if (word_top > 0) word_top--; | - | ||||||||||||||||||
2707 | } | - | ||||||||||||||||||
2708 | #line 2709 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2709 | break; executed 201 times by 1 test: se 90: Executed by:
| 201 | ||||||||||||||||||
2710 | - | |||||||||||||||||||
2711 | case 88: executed 1 time by 1 test Executed by:
| 1 | ||||||||||||||||||
2712 | #line 868 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2713 | { | - | ||||||||||||||||||
2714 | (yyval.command) = make_select_command ((yyvsp[-4].word), add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), (yyvsp[-1].command), word_lineno[word_top]); | - | ||||||||||||||||||
2715 | if (word_top > 0) word_top--; | - | ||||||||||||||||||
2716 | } | - | ||||||||||||||||||
2717 | #line 2718 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2718 | break; executed 1 time by 1 test: se 91: Executed by:
| 1 | ||||||||||||||||||
2719 | - | |||||||||||||||||||
2720 | case 89: never executed | 0 | ||||||||||||||||||
2721 | #line 873 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2722 | { | - | ||||||||||||||||||
2723 | (yyval.command) = make_select_command ((yyvsp[-4].word), add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), (yyvsp[-1].command), word_lineno[word_top]); | - | ||||||||||||||||||
2724 | if (word_top > 0) word_top--; | - | ||||||||||||||||||
2725 | } | - | ||||||||||||||||||
2726 | #line 2727 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2727 | break; never executed: se 92: | 0 | ||||||||||||||||||
2728 | - | |||||||||||||||||||
2729 | case 90: executed 2 times by 1 test Executed by:
| 2 | ||||||||||||||||||
2730 | #line 878 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2731 | { | - | ||||||||||||||||||
2732 | (yyval.command) = make_select_command ((yyvsp[-5].word), add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), (yyvsp[-1].command), word_lineno[word_top]); | - | ||||||||||||||||||
2733 | if (word_top > 0) word_top--; | - | ||||||||||||||||||
2734 | } | - | ||||||||||||||||||
2735 | #line 2736 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2736 | break; executed 2 times by 1 test: se 93: Executed by:
| 2 | ||||||||||||||||||
2737 | - | |||||||||||||||||||
2738 | case 91: never executed | 0 | ||||||||||||||||||
2739 | #line 883 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2740 | { | - | ||||||||||||||||||
2741 | (yyval.command) = make_select_command ((yyvsp[-5].word), add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), (yyvsp[-1].command), word_lineno[word_top]); | - | ||||||||||||||||||
2742 | if (word_top > 0) word_top--; | - | ||||||||||||||||||
2743 | } | - | ||||||||||||||||||
2744 | #line 2745 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2745 | break; never executed: se 94: | 0 | ||||||||||||||||||
2746 | - | |||||||||||||||||||
2747 | case 92: executed 6 times by 1 test Executed by:
| 6 | ||||||||||||||||||
2748 | #line 888 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2749 | { | - | ||||||||||||||||||
2750 | (yyval.command) = make_select_command ((yyvsp[-8].word), REVERSE_LIST ((yyvsp[-5].word_list), WORD_LIST *), (yyvsp[-1].command), word_lineno[word_top]); | - | ||||||||||||||||||
2751 | if (word_top > 0) word_top--; | - | ||||||||||||||||||
2752 | } | - | ||||||||||||||||||
2753 | #line 2754 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2754 | break; executed 6 times by 1 test: se 95: Executed by:
| 6 | ||||||||||||||||||
2755 | - | |||||||||||||||||||
2756 | case 93: never executed | 0 | ||||||||||||||||||
2757 | #line 893 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2758 | { | - | ||||||||||||||||||
2759 | (yyval.command) = make_select_command ((yyvsp[-8].word), REVERSE_LIST ((yyvsp[-5].word_list), WORD_LIST *), (yyvsp[-1].command), word_lineno[word_top]); | - | ||||||||||||||||||
2760 | if (word_top > 0) word_top--; | - | ||||||||||||||||||
2761 | } | - | ||||||||||||||||||
2762 | #line 2763 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2763 | break; never executed: se 96: | 0 | ||||||||||||||||||
2764 | - | |||||||||||||||||||
2765 | case 94: executed 2 times by 1 test Executed by:
| 2 | ||||||||||||||||||
2766 | #line 900 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2767 | { | - | ||||||||||||||||||
2768 | (yyval.command) = make_case_command ((yyvsp[-4].word), (PATTERN_LIST *)NULL, word_lineno[word_top]); | - | ||||||||||||||||||
2769 | if (word_top > 0) word_top--; | - | ||||||||||||||||||
2770 | } | - | ||||||||||||||||||
2771 | #line 2772 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2772 | break; executed 2 times by 1 test: se 97: Executed by:
| 2 | ||||||||||||||||||
2773 | - | |||||||||||||||||||
2774 | case 95: executed 75601 times by 1 test Executed by:
| 75601 | ||||||||||||||||||
2775 | #line 905 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2776 | { | - | ||||||||||||||||||
2777 | (yyval.command) = make_case_command ((yyvsp[-5].word), (yyvsp[-2].pattern), word_lineno[word_top]); | - | ||||||||||||||||||
2778 | if (word_top > 0) word_top--; | - | ||||||||||||||||||
2779 | } | - | ||||||||||||||||||
2780 | #line 2781 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2781 | break; executed 75601 times by 1 test: se 98: Executed by:
| 75601 | ||||||||||||||||||
2782 | - | |||||||||||||||||||
2783 | case 96: executed 2507 times by 1 test Executed by:
| 2507 | ||||||||||||||||||
2784 | #line 910 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2785 | { | - | ||||||||||||||||||
2786 | (yyval.command) = make_case_command ((yyvsp[-4].word), (yyvsp[-1].pattern), word_lineno[word_top]); | - | ||||||||||||||||||
2787 | if (word_top > 0) word_top--; | - | ||||||||||||||||||
2788 | } | - | ||||||||||||||||||
2789 | #line 2790 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2790 | break; executed 2507 times by 1 test: se 99: Executed by:
| 2507 | ||||||||||||||||||
2791 | - | |||||||||||||||||||
2792 | case 97: executed 11182 times by 1 test Executed by:
| 11182 | ||||||||||||||||||
2793 | #line 917 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2794 | { (yyval.command) = make_function_def ((yyvsp[-4].word), (yyvsp[0].command), function_dstart, function_bstart); } | - | ||||||||||||||||||
2795 | #line 2796 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2796 | break; executed 11182 times by 1 test: se 100 Executed by:
| 11182 | ||||||||||||||||||
2797 | - | |||||||||||||||||||
2798 | case 98: executed 8 times by 1 test Executed by:
| 8 | ||||||||||||||||||
2799 | #line 920 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2800 | { (yyval.command) = make_function_def ((yyvsp[-4].word), (yyvsp[0].command), function_dstart, function_bstart); } | - | ||||||||||||||||||
2801 | #line 2802 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2802 | break; executed 8 times by 1 test: se 101 Executed by:
| 8 | ||||||||||||||||||
2803 | - | |||||||||||||||||||
2804 | case 99: executed 21 times by 1 test Executed by:
| 21 | ||||||||||||||||||
2805 | #line 923 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2806 | { (yyval.command) = make_function_def ((yyvsp[-2].word), (yyvsp[0].command), function_dstart, function_bstart); } | - | ||||||||||||||||||
2807 | #line 2808 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2808 | break; executed 21 times by 1 test: se 102 Executed by:
| 21 | ||||||||||||||||||
2809 | - | |||||||||||||||||||
2810 | case 100: executed 11180 times by 1 test Executed by:
| 11180 | ||||||||||||||||||
2811 | #line 927 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2812 | { (yyval.command) = (yyvsp[0].command); } | - | ||||||||||||||||||
2813 | #line 2814 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2814 | break; executed 11180 times by 1 test: se 103 Executed by:
| 11180 | ||||||||||||||||||
2815 | - | |||||||||||||||||||
2816 | case 101: executed 31 times by 1 test Executed by:
| 31 | ||||||||||||||||||
2817 | #line 929 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2818 | { | - | ||||||||||||||||||
2819 | COMMAND *tc; | - | ||||||||||||||||||
2820 | - | |||||||||||||||||||
2821 | tc = (yyvsp[-1].command); | - | ||||||||||||||||||
2822 | /* According to Posix.2 3.9.5, redirections | - | ||||||||||||||||||
2823 | specified after the body of a function should | - | ||||||||||||||||||
2824 | be attached to the function and performed when | - | ||||||||||||||||||
2825 | the function is executed, not as part of the | - | ||||||||||||||||||
2826 | function definition command. */ | - | ||||||||||||||||||
2827 | /* XXX - I don't think it matters, but we might | - | ||||||||||||||||||
2828 | want to change this in the future to avoid | - | ||||||||||||||||||
2829 | problems differentiating between a function | - | ||||||||||||||||||
2830 | definition with a redirection and a function | - | ||||||||||||||||||
2831 | definition containing a single command with a | - | ||||||||||||||||||
2832 | redirection. The two are semantically equivalent, | - | ||||||||||||||||||
2833 | though -- the only difference is in how the | - | ||||||||||||||||||
2834 | command printing code displays the redirections. */ | - | ||||||||||||||||||
2835 | if (tc && tc->redirects) | - | ||||||||||||||||||
2836 | { | - | ||||||||||||||||||
2837 | register REDIRECT *t; | - | ||||||||||||||||||
2838 | for (t = tc->redirects; t->next; t = t->next) | - | ||||||||||||||||||
2839 | ; | - | ||||||||||||||||||
2840 | t->next = (yyvsp[0].redirect); | - | ||||||||||||||||||
2841 | } | - | ||||||||||||||||||
2842 | else if (tc) | - | ||||||||||||||||||
2843 | tc->redirects = (yyvsp[0].redirect); | - | ||||||||||||||||||
2844 | (yyval.command) = (yyvsp[-1].command); | - | ||||||||||||||||||
2845 | } | - | ||||||||||||||||||
2846 | #line 2847 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2847 | break; executed 31 times by 1 test: se 104 Executed by:
| 31 | ||||||||||||||||||
2848 | - | |||||||||||||||||||
2849 | case 102: executed 5977 times by 1 test Executed by:
| 5977 | ||||||||||||||||||
2850 | #line 960 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2851 | { | - | ||||||||||||||||||
2852 | (yyval.command) = make_subshell_command ((yyvsp[-1].command)); | - | ||||||||||||||||||
2853 | (yyval.command)->flags |= CMD_WANT_SUBSHELL; | - | ||||||||||||||||||
2854 | } | - | ||||||||||||||||||
2855 | #line 2856 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2856 | break; executed 5977 times by 1 test: se 105 Executed by:
| 5977 | ||||||||||||||||||
2857 | - | |||||||||||||||||||
2858 | case 103: executed 5 times by 1 test Executed by:
| 5 | ||||||||||||||||||
2859 | #line 967 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2860 | { | - | ||||||||||||||||||
2861 | (yyval.command) = make_coproc_command ("COPROC", (yyvsp[0].command)); | - | ||||||||||||||||||
2862 | (yyval.command)->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL; | - | ||||||||||||||||||
2863 | } | - | ||||||||||||||||||
2864 | #line 2865 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2865 | break; executed 5 times by 1 test: se 106 Executed by:
| 5 | ||||||||||||||||||
2866 | - | |||||||||||||||||||
2867 | case 104: never executed | 0 | ||||||||||||||||||
2868 | #line 972 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2869 | { | - | ||||||||||||||||||
2870 | COMMAND *tc; | - | ||||||||||||||||||
2871 | - | |||||||||||||||||||
2872 | tc = (yyvsp[-1].command); | - | ||||||||||||||||||
2873 | if (tc && tc->redirects) | - | ||||||||||||||||||
2874 | { | - | ||||||||||||||||||
2875 | register REDIRECT *t; | - | ||||||||||||||||||
2876 | for (t = tc->redirects; t->next; t = t->next) | - | ||||||||||||||||||
2877 | ; | - | ||||||||||||||||||
2878 | t->next = (yyvsp[0].redirect); | - | ||||||||||||||||||
2879 | } | - | ||||||||||||||||||
2880 | else if (tc) | - | ||||||||||||||||||
2881 | tc->redirects = (yyvsp[0].redirect); | - | ||||||||||||||||||
2882 | (yyval.command) = make_coproc_command ("COPROC", (yyvsp[-1].command)); | - | ||||||||||||||||||
2883 | (yyval.command)->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL; | - | ||||||||||||||||||
2884 | } | - | ||||||||||||||||||
2885 | #line 2886 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2886 | break; never executed: se 107 | 0 | ||||||||||||||||||
2887 | - | |||||||||||||||||||
2888 | case 105: executed 31 times by 1 test Executed by:
| 31 | ||||||||||||||||||
2889 | #line 989 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2890 | { | - | ||||||||||||||||||
2891 | (yyval.command) = make_coproc_command ((yyvsp[-1].word)->word, (yyvsp[0].command)); | - | ||||||||||||||||||
2892 | (yyval.command)->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL; | - | ||||||||||||||||||
2893 | } | - | ||||||||||||||||||
2894 | #line 2895 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2895 | break; executed 31 times by 1 test: se 108 Executed by:
| 31 | ||||||||||||||||||
2896 | - | |||||||||||||||||||
2897 | case 106: never executed | 0 | ||||||||||||||||||
2898 | #line 994 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2899 | { | - | ||||||||||||||||||
2900 | COMMAND *tc; | - | ||||||||||||||||||
2901 | - | |||||||||||||||||||
2902 | tc = (yyvsp[-1].command); | - | ||||||||||||||||||
2903 | if (tc && tc->redirects) | - | ||||||||||||||||||
2904 | { | - | ||||||||||||||||||
2905 | register REDIRECT *t; | - | ||||||||||||||||||
2906 | for (t = tc->redirects; t->next; t = t->next) | - | ||||||||||||||||||
2907 | ; | - | ||||||||||||||||||
2908 | t->next = (yyvsp[0].redirect); | - | ||||||||||||||||||
2909 | } | - | ||||||||||||||||||
2910 | else if (tc) | - | ||||||||||||||||||
2911 | tc->redirects = (yyvsp[0].redirect); | - | ||||||||||||||||||
2912 | (yyval.command) = make_coproc_command ((yyvsp[-2].word)->word, (yyvsp[-1].command)); | - | ||||||||||||||||||
2913 | (yyval.command)->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL; | - | ||||||||||||||||||
2914 | } | - | ||||||||||||||||||
2915 | #line 2916 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2916 | break; never executed: se 109 | 0 | ||||||||||||||||||
2917 | - | |||||||||||||||||||
2918 | case 107: executed 1 time by 1 test Executed by:
| 1 | ||||||||||||||||||
2919 | #line 1011 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2920 | { | - | ||||||||||||||||||
2921 | (yyval.command) = make_coproc_command ("COPROC", clean_simple_command ((yyvsp[0].command))); | - | ||||||||||||||||||
2922 | (yyval.command)->flags |= CMD_WANT_SUBSHELL|CMD_COPROC_SUBSHELL; | - | ||||||||||||||||||
2923 | } | - | ||||||||||||||||||
2924 | #line 2925 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2925 | break; executed 1 time by 1 test: se 110 Executed by:
| 1 | ||||||||||||||||||
2926 | - | |||||||||||||||||||
2927 | case 108: executed 1311 times by 1 test Executed by:
| 1311 | ||||||||||||||||||
2928 | #line 1018 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2929 | { (yyval.command) = make_if_command ((yyvsp[-3].command), (yyvsp[-1].command), (COMMAND *)NULL); } | - | ||||||||||||||||||
2930 | #line 2931 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2931 | break; executed 1311 times by 1 test: se 111 Executed by:
| 1311 | ||||||||||||||||||
2932 | - | |||||||||||||||||||
2933 | case 109: executed 175 times by 1 test Executed by:
| 175 | ||||||||||||||||||
2934 | #line 1020 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2935 | { (yyval.command) = make_if_command ((yyvsp[-5].command), (yyvsp[-3].command), (yyvsp[-1].command)); } | - | ||||||||||||||||||
2936 | #line 2937 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2937 | break; executed 175 times by 1 test: se 112 Executed by:
| 175 | ||||||||||||||||||
2938 | - | |||||||||||||||||||
2939 | case 110: executed 61 times by 1 test Executed by:
| 61 | ||||||||||||||||||
2940 | #line 1022 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2941 | { (yyval.command) = make_if_command ((yyvsp[-4].command), (yyvsp[-2].command), (yyvsp[-1].command)); } | - | ||||||||||||||||||
2942 | #line 2943 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2943 | break; executed 61 times by 1 test: se 113 Executed by:
| 61 | ||||||||||||||||||
2944 | - | |||||||||||||||||||
2945 | case 111: executed 12022 times by 1 test Executed by:
| 12022 | ||||||||||||||||||
2946 | #line 1027 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2947 | { (yyval.command) = make_group_command ((yyvsp[-1].command)); } | - | ||||||||||||||||||
2948 | #line 2949 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2949 | break; executed 12022 times by 1 test: se 114 Executed by:
| 12022 | ||||||||||||||||||
2950 | - | |||||||||||||||||||
2951 | case 112: executed 47077 times by 1 test Executed by:
| 47077 | ||||||||||||||||||
2952 | #line 1031 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2953 | { (yyval.command) = make_arith_command ((yyvsp[0].word_list)); } | - | ||||||||||||||||||
2954 | #line 2955 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2955 | break; executed 47077 times by 1 test: se 115 Executed by:
| 47077 | ||||||||||||||||||
2956 | - | |||||||||||||||||||
2957 | case 113: executed 574 times by 1 test Executed by:
| 574 | ||||||||||||||||||
2958 | #line 1035 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2959 | { (yyval.command) = (yyvsp[-1].command); } | - | ||||||||||||||||||
2960 | #line 2961 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2961 | break; executed 574 times by 1 test: se 116 Executed by:
| 574 | ||||||||||||||||||
2962 | - | |||||||||||||||||||
2963 | case 114: executed 9 times by 1 test Executed by:
| 9 | ||||||||||||||||||
2964 | #line 1039 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2965 | { (yyval.command) = make_if_command ((yyvsp[-2].command), (yyvsp[0].command), (COMMAND *)NULL); } | - | ||||||||||||||||||
2966 | #line 2967 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2967 | break; executed 9 times by 1 test: se 118 Executed by:
| 9 | ||||||||||||||||||
2968 | - | |||||||||||||||||||
2969 | case 115: executed 52 times by 1 test Executed by:
| 52 | ||||||||||||||||||
2970 | #line 1041 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2971 | { (yyval.command) = make_if_command ((yyvsp[-4].command), (yyvsp[-2].command), (yyvsp[0].command)); } | - | ||||||||||||||||||
2972 | #line 2973 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2973 | break; executed 52 times by 1 test: se 119 Executed by:
| 52 | ||||||||||||||||||
2974 | - | |||||||||||||||||||
2975 | case 116: executed 13 times by 1 test Executed by:
| 13 | ||||||||||||||||||
2976 | #line 1043 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2977 | { (yyval.command) = make_if_command ((yyvsp[-3].command), (yyvsp[-1].command), (yyvsp[0].command)); } | - | ||||||||||||||||||
2978 | #line 2979 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2979 | break; executed 13 times by 1 test: se 120 Executed by:
| 13 | ||||||||||||||||||
2980 | - | |||||||||||||||||||
2981 | case 118: executed 2271 times by 1 test Executed by:
| 2271 | ||||||||||||||||||
2982 | #line 1048 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2983 | { (yyvsp[0].pattern)->next = (yyvsp[-1].pattern); (yyval.pattern) = (yyvsp[0].pattern); } | - | ||||||||||||||||||
2984 | #line 2985 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2985 | break; executed 2271 times by 1 test: se 121 Executed by:
| 2271 | ||||||||||||||||||
2986 | - | |||||||||||||||||||
2987 | case 119: executed 137001 times by 1 test Executed by:
| 137001 | ||||||||||||||||||
2988 | #line 1052 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2989 | { (yyval.pattern) = make_pattern_list ((yyvsp[-2].word_list), (yyvsp[0].command)); } | - | ||||||||||||||||||
2990 | #line 2991 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2991 | break; executed 137001 times by 1 test: se 122 Executed by:
| 137001 | ||||||||||||||||||
2992 | - | |||||||||||||||||||
2993 | case 120: executed 20386 times by 1 test Executed by:
| 20386 | ||||||||||||||||||
2994 | #line 1054 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
2995 | { (yyval.pattern) = make_pattern_list ((yyvsp[-2].word_list), (COMMAND *)NULL); } | - | ||||||||||||||||||
2996 | #line 2997 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
2997 | break; executed 20386 times by 1 test: se 123 Executed by:
| 20386 | ||||||||||||||||||
2998 | - | |||||||||||||||||||
2999 | case 121: executed 882 times by 1 test Executed by:
| 882 | ||||||||||||||||||
3000 | #line 1056 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3001 | { (yyval.pattern) = make_pattern_list ((yyvsp[-2].word_list), (yyvsp[0].command)); } | - | ||||||||||||||||||
3002 | #line 3003 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3003 | break; executed 882 times by 1 test: se 124 Executed by:
| 882 | ||||||||||||||||||
3004 | - | |||||||||||||||||||
3005 | case 122: executed 1 time by 1 test Executed by:
| 1 | ||||||||||||||||||
3006 | #line 1058 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3007 | { (yyval.pattern) = make_pattern_list ((yyvsp[-2].word_list), (COMMAND *)NULL); } | - | ||||||||||||||||||
3008 | #line 3009 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3009 | break; executed 1 time by 1 test: se 125 Executed by:
| 1 | ||||||||||||||||||
3010 | - | |||||||||||||||||||
3011 | case 123: executed 77871 times by 1 test Executed by:
| 77871 | ||||||||||||||||||
3012 | #line 1062 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3013 | { (yyval.pattern) = (yyvsp[-1].pattern); } | - | ||||||||||||||||||
3014 | #line 3015 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3015 | break; executed 77871 times by 1 test: se 126 Executed by:
| 77871 | ||||||||||||||||||
3016 | - | |||||||||||||||||||
3017 | case 124: executed 77886 times by 1 test Executed by:
| 77886 | ||||||||||||||||||
3018 | #line 1064 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3019 | { (yyvsp[-1].pattern)->next = (yyvsp[-2].pattern); (yyval.pattern) = (yyvsp[-1].pattern); } | - | ||||||||||||||||||
3020 | #line 3021 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3021 | break; executed 77886 times by 1 test: se 127 Executed by:
| 77886 | ||||||||||||||||||
3022 | - | |||||||||||||||||||
3023 | case 125: executed 1 time by 1 test Executed by:
| 1 | ||||||||||||||||||
3024 | #line 1066 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3025 | { (yyvsp[-1].pattern)->flags |= CASEPAT_FALLTHROUGH; (yyval.pattern) = (yyvsp[-1].pattern); } | - | ||||||||||||||||||
3026 | #line 3027 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3027 | break; executed 1 time by 1 test: se 128 Executed by:
| 1 | ||||||||||||||||||
3028 | - | |||||||||||||||||||
3029 | case 126: executed 3 times by 1 test Executed by:
| 3 | ||||||||||||||||||
3030 | #line 1068 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3031 | { (yyvsp[-1].pattern)->flags |= CASEPAT_FALLTHROUGH; (yyvsp[-1].pattern)->next = (yyvsp[-2].pattern); (yyval.pattern) = (yyvsp[-1].pattern); } | - | ||||||||||||||||||
3032 | #line 3033 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3033 | break; executed 3 times by 1 test: se 129 Executed by:
| 3 | ||||||||||||||||||
3034 | - | |||||||||||||||||||
3035 | case 127: never executed | 0 | ||||||||||||||||||
3036 | #line 1070 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3037 | { (yyvsp[-1].pattern)->flags |= CASEPAT_TESTNEXT; (yyval.pattern) = (yyvsp[-1].pattern); } | - | ||||||||||||||||||
3038 | #line 3039 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3039 | break; never executed: se 130 | 0 | ||||||||||||||||||
3040 | - | |||||||||||||||||||
3041 | case 128: executed 2 times by 1 test Executed by:
| 2 | ||||||||||||||||||
3042 | #line 1072 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3043 | { (yyvsp[-1].pattern)->flags |= CASEPAT_TESTNEXT; (yyvsp[-1].pattern)->next = (yyvsp[-2].pattern); (yyval.pattern) = (yyvsp[-1].pattern); } | - | ||||||||||||||||||
3044 | #line 3045 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3045 | break; executed 2 times by 1 test: se 131 Executed by:
| 2 | ||||||||||||||||||
3046 | - | |||||||||||||||||||
3047 | case 129: executed 158270 times by 1 test Executed by:
| 158270 | ||||||||||||||||||
3048 | #line 1076 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3049 | { (yyval.word_list) = make_word_list ((yyvsp[0].word), (WORD_LIST *)NULL); } | - | ||||||||||||||||||
3050 | #line 3051 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3051 | break; executed 158270 times by 1 test: se 133 Executed by:
| 158270 | ||||||||||||||||||
3052 | - | |||||||||||||||||||
3053 | case 130: executed 6830 times by 1 test Executed by:
| 6830 | ||||||||||||||||||
3054 | #line 1078 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3055 | { (yyval.word_list) = make_word_list ((yyvsp[0].word), (yyvsp[-2].word_list)); } | - | ||||||||||||||||||
3056 | #line 3057 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3057 | break; executed 6830 times by 1 test: se 135 Executed by:
| 6830 | ||||||||||||||||||
3058 | - | |||||||||||||||||||
3059 | case 131: executed 95385 times by 1 test Executed by:
| 95385 | ||||||||||||||||||
3060 | #line 1087 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3061 | { | - | ||||||||||||||||||
3062 | (yyval.command) = (yyvsp[0].command); | - | ||||||||||||||||||
3063 | if (need_here_doc) | - | ||||||||||||||||||
3064 | gather_here_documents (); | - | ||||||||||||||||||
3065 | } | - | ||||||||||||||||||
3066 | #line 3067 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3067 | break; executed 95385 times by 1 test: se 137 Executed by:
| 95385 | ||||||||||||||||||
3068 | - | |||||||||||||||||||
3069 | case 133: executed 102619 times by 1 test Executed by:
| 102619 | ||||||||||||||||||
3070 | #line 1096 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3071 | { | - | ||||||||||||||||||
3072 | (yyval.command) = (yyvsp[0].command); | - | ||||||||||||||||||
3073 | } | - | ||||||||||||||||||
3074 | #line 3075 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3075 | break; executed 102619 times by 1 test: se 138 Executed by:
| 102619 | ||||||||||||||||||
3076 | - | |||||||||||||||||||
3077 | case 135: executed 38 times by 1 test Executed by:
| 38 | ||||||||||||||||||
3078 | #line 1103 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3079 | { | - | ||||||||||||||||||
3080 | if ((yyvsp[-2].command)->type == cm_connection) | - | ||||||||||||||||||
3081 | (yyval.command) = connect_async_list ((yyvsp[-2].command), (COMMAND *)NULL, '&'); | - | ||||||||||||||||||
3082 | else | - | ||||||||||||||||||
3083 | (yyval.command) = command_connect ((yyvsp[-2].command), (COMMAND *)NULL, '&'); | - | ||||||||||||||||||
3084 | } | - | ||||||||||||||||||
3085 | #line 3086 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3086 | break; executed 38 times by 1 test: se 139 Executed by:
| 38 | ||||||||||||||||||
3087 | - | |||||||||||||||||||
3088 | case 137: executed 254 times by 1 test Executed by:
| 254 | ||||||||||||||||||
3089 | #line 1114 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3090 | { (yyval.command) = command_connect ((yyvsp[-3].command), (yyvsp[0].command), AND_AND); } | - | ||||||||||||||||||
3091 | #line 3092 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3092 | break; executed 254 times by 1 test: se 140 Executed by:
| 254 | ||||||||||||||||||
3093 | - | |||||||||||||||||||
3094 | case 138: executed 154 times by 1 test Executed by:
| 154 | ||||||||||||||||||
3095 | #line 1116 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3096 | { (yyval.command) = command_connect ((yyvsp[-3].command), (yyvsp[0].command), OR_OR); } | - | ||||||||||||||||||
3097 | #line 3098 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3098 | break; executed 154 times by 1 test: se 141 Executed by:
| 154 | ||||||||||||||||||
3099 | - | |||||||||||||||||||
3100 | case 139: executed 131 times by 1 test Executed by:
| 131 | ||||||||||||||||||
3101 | #line 1118 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3102 | { | - | ||||||||||||||||||
3103 | if ((yyvsp[-3].command)->type == cm_connection) | - | ||||||||||||||||||
3104 | (yyval.command) = connect_async_list ((yyvsp[-3].command), (yyvsp[0].command), '&'); | - | ||||||||||||||||||
3105 | else | - | ||||||||||||||||||
3106 | (yyval.command) = command_connect ((yyvsp[-3].command), (yyvsp[0].command), '&'); | - | ||||||||||||||||||
3107 | } | - | ||||||||||||||||||
3108 | #line 3109 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3109 | break; executed 131 times by 1 test: se 142 Executed by:
| 131 | ||||||||||||||||||
3110 | - | |||||||||||||||||||
3111 | case 140: executed 12828 times by 1 test Executed by:
| 12828 | ||||||||||||||||||
3112 | #line 1125 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3113 | { (yyval.command) = command_connect ((yyvsp[-3].command), (yyvsp[0].command), ';'); } | - | ||||||||||||||||||
3114 | #line 3115 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3115 | break; executed 12828 times by 1 test: se 145 Executed by:
| 12828 | ||||||||||||||||||
3116 | - | |||||||||||||||||||
3117 | case 141: executed 107917 times by 1 test Executed by:
| 107917 | ||||||||||||||||||
3118 | #line 1127 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3119 | { (yyval.command) = command_connect ((yyvsp[-3].command), (yyvsp[0].command), ';'); } | - | ||||||||||||||||||
3120 | #line 3121 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3121 | break; executed 107917 times by 1 test: se 146 Executed by:
| 107917 | ||||||||||||||||||
3122 | - | |||||||||||||||||||
3123 | case 142: executed 319288 times by 1 test Executed by:
| 319288 | ||||||||||||||||||
3124 | #line 1129 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3125 | { (yyval.command) = (yyvsp[0].command); } | - | ||||||||||||||||||
3126 | #line 3127 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3127 | break; executed 319288 times by 1 test: se 147 Executed by:
| 319288 | ||||||||||||||||||
3128 | - | |||||||||||||||||||
3129 | case 145: executed 27310 times by 1 test Executed by:
| 27310 | ||||||||||||||||||
3130 | #line 1137 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3131 | { (yyval.number) = '\n'; } | - | ||||||||||||||||||
3132 | #line 3133 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3133 | break; executed 27310 times by 1 test: se 150 Executed by:
| 27310 | ||||||||||||||||||
3134 | - | |||||||||||||||||||
3135 | case 146: executed 595 times by 1 test Executed by:
| 595 | ||||||||||||||||||
3136 | #line 1139 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3137 | { (yyval.number) = ';'; } | - | ||||||||||||||||||
3138 | #line 3139 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3139 | break; executed 595 times by 1 test: se 151 Executed by:
| 595 | ||||||||||||||||||
3140 | - | |||||||||||||||||||
3141 | case 147: never executed | 0 | ||||||||||||||||||
3142 | #line 1141 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3143 | { (yyval.number) = yacc_EOF; } | - | ||||||||||||||||||
3144 | #line 3145 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3145 | break; never executed: se 152 | 0 | ||||||||||||||||||
3146 | - | |||||||||||||||||||
3147 | case 150: executed 824352 times by 1 test Executed by:
| 824352 | ||||||||||||||||||
3148 | #line 1155 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3149 | { | - | ||||||||||||||||||
3150 | (yyval.command) = (yyvsp[0].command); | - | ||||||||||||||||||
3151 | if (need_here_doc) | - | ||||||||||||||||||
3152 | gather_here_documents (); | - | ||||||||||||||||||
3153 | if ((parser_state & PST_CMDSUBST) && current_token == shell_eof_token) | - | ||||||||||||||||||
3154 | { | - | ||||||||||||||||||
3155 | global_command = (yyvsp[0].command); | - | ||||||||||||||||||
3156 | eof_encountered = 0; | - | ||||||||||||||||||
3157 | rewind_input_string (); | - | ||||||||||||||||||
3158 | YYACCEPT; | - | ||||||||||||||||||
3159 | } | - | ||||||||||||||||||
3160 | } | - | ||||||||||||||||||
3161 | #line 3162 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3162 | break; executed 120029 times by 1 test: se 153 Executed by:
| 120029 | ||||||||||||||||||
3163 | - | |||||||||||||||||||
3164 | case 151: executed 124 times by 1 test Executed by:
| 124 | ||||||||||||||||||
3165 | #line 1168 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3166 | { | - | ||||||||||||||||||
3167 | if ((yyvsp[-1].command)->type == cm_connection) | - | ||||||||||||||||||
3168 | (yyval.command) = connect_async_list ((yyvsp[-1].command), (COMMAND *)NULL, '&'); | - | ||||||||||||||||||
3169 | else | - | ||||||||||||||||||
3170 | (yyval.command) = command_connect ((yyvsp[-1].command), (COMMAND *)NULL, '&'); | - | ||||||||||||||||||
3171 | if (need_here_doc) | - | ||||||||||||||||||
3172 | gather_here_documents (); | - | ||||||||||||||||||
3173 | if ((parser_state & PST_CMDSUBST) && current_token == shell_eof_token) | - | ||||||||||||||||||
3174 | { | - | ||||||||||||||||||
3175 | global_command = (yyvsp[-1].command); | - | ||||||||||||||||||
3176 | eof_encountered = 0; | - | ||||||||||||||||||
3177 | rewind_input_string (); | - | ||||||||||||||||||
3178 | YYACCEPT; | - | ||||||||||||||||||
3179 | } | - | ||||||||||||||||||
3180 | } | - | ||||||||||||||||||
3181 | #line 3182 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3182 | break; executed 124 times by 1 test: se 154 Executed by:
| 124 | ||||||||||||||||||
3183 | - | |||||||||||||||||||
3184 | case 152: executed 49 times by 1 test Executed by:
| 49 | ||||||||||||||||||
3185 | #line 1184 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3186 | { | - | ||||||||||||||||||
3187 | (yyval.command) = (yyvsp[-1].command); | - | ||||||||||||||||||
3188 | if (need_here_doc) | - | ||||||||||||||||||
3189 | gather_here_documents (); | - | ||||||||||||||||||
3190 | if ((parser_state & PST_CMDSUBST) && current_token == shell_eof_token) | - | ||||||||||||||||||
3191 | { | - | ||||||||||||||||||
3192 | global_command = (yyvsp[-1].command); | - | ||||||||||||||||||
3193 | eof_encountered = 0; | - | ||||||||||||||||||
3194 | rewind_input_string (); | - | ||||||||||||||||||
3195 | YYACCEPT; | - | ||||||||||||||||||
3196 | } | - | ||||||||||||||||||
3197 | } | - | ||||||||||||||||||
3198 | #line 3199 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3199 | break; executed 44 times by 1 test: se 155 Executed by:
| 44 | ||||||||||||||||||
3200 | - | |||||||||||||||||||
3201 | case 153: executed 375 times by 1 test Executed by:
| 375 | ||||||||||||||||||
3202 | #line 1199 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3203 | { (yyval.command) = command_connect ((yyvsp[-3].command), (yyvsp[0].command), AND_AND); } | - | ||||||||||||||||||
3204 | #line 3205 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3205 | break; executed 375 times by 1 test: se 156 Executed by:
| 375 | ||||||||||||||||||
3206 | - | |||||||||||||||||||
3207 | case 154: executed 21533 times by 1 test Executed by:
| 21533 | ||||||||||||||||||
3208 | #line 1201 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3209 | { (yyval.command) = command_connect ((yyvsp[-3].command), (yyvsp[0].command), OR_OR); } | - | ||||||||||||||||||
3210 | #line 3211 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3211 | break; executed 21533 times by 1 test: se 157 Executed by:
| 21533 | ||||||||||||||||||
3212 | - | |||||||||||||||||||
3213 | case 155: executed 16 times by 1 test Executed by:
| 16 | ||||||||||||||||||
3214 | #line 1203 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3215 | { | - | ||||||||||||||||||
3216 | if ((yyvsp[-2].command)->type == cm_connection) | - | ||||||||||||||||||
3217 | (yyval.command) = connect_async_list ((yyvsp[-2].command), (yyvsp[0].command), '&'); | - | ||||||||||||||||||
3218 | else | - | ||||||||||||||||||
3219 | (yyval.command) = command_connect ((yyvsp[-2].command), (yyvsp[0].command), '&'); | - | ||||||||||||||||||
3220 | } | - | ||||||||||||||||||
3221 | #line 3222 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3222 | break; executed 16 times by 1 test: se 158 Executed by:
| 16 | ||||||||||||||||||
3223 | - | |||||||||||||||||||
3224 | case 156: executed 37760 times by 1 test Executed by:
| 37760 | ||||||||||||||||||
3225 | #line 1210 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3226 | { (yyval.command) = command_connect ((yyvsp[-2].command), (yyvsp[0].command), ';'); } | - | ||||||||||||||||||
3227 | #line 3228 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3228 | break; executed 37760 times by 1 test: se 159 Executed by:
| 37760 | ||||||||||||||||||
3229 | - | |||||||||||||||||||
3230 | case 157: executed 884209 times by 1 test Executed by:
| 884209 | ||||||||||||||||||
3231 | #line 1213 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3232 | { (yyval.command) = (yyvsp[0].command); } | - | ||||||||||||||||||
3233 | #line 3234 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3234 | break; executed 884209 times by 1 test: se 160 Executed by:
| 884209 | ||||||||||||||||||
3235 | - | |||||||||||||||||||
3236 | case 158: executed 1203492 times by 1 test Executed by:
| 1203492 | ||||||||||||||||||
3237 | #line 1217 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3238 | { (yyval.command) = (yyvsp[0].command); } | - | ||||||||||||||||||
3239 | #line 3240 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3240 | break; executed 1203492 times by 1 test: se 161 Executed by:
| 1203492 | ||||||||||||||||||
3241 | - | |||||||||||||||||||
3242 | case 159: executed 290 times by 1 test Executed by:
| 290 | ||||||||||||||||||
3243 | #line 1219 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3244 | { | - | ||||||||||||||||||
3245 | if ((yyvsp[0].command)) | - | ||||||||||||||||||
3246 | (yyvsp[0].command)->flags ^= CMD_INVERT_RETURN; /* toggle */ | - | ||||||||||||||||||
3247 | (yyval.command) = (yyvsp[0].command); | - | ||||||||||||||||||
3248 | } | - | ||||||||||||||||||
3249 | #line 3250 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3250 | break; executed 290 times by 1 test: se 162 Executed by:
| 290 | ||||||||||||||||||
3251 | - | |||||||||||||||||||
3252 | case 160: executed 14 times by 1 test Executed by:
| 14 | ||||||||||||||||||
3253 | #line 1225 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3254 | { | - | ||||||||||||||||||
3255 | if ((yyvsp[0].command)) | - | ||||||||||||||||||
3256 | (yyvsp[0].command)->flags |= (yyvsp[-1].number); | - | ||||||||||||||||||
3257 | (yyval.command) = (yyvsp[0].command); | - | ||||||||||||||||||
3258 | } | - | ||||||||||||||||||
3259 | #line 3260 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3260 | break; executed 14 times by 1 test: se 163 Executed by:
| 14 | ||||||||||||||||||
3261 | - | |||||||||||||||||||
3262 | case 161: executed 1 time by 1 test Executed by:
| 1 | ||||||||||||||||||
3263 | #line 1231 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3264 | { | - | ||||||||||||||||||
3265 | ELEMENT x; | - | ||||||||||||||||||
3266 | - | |||||||||||||||||||
3267 | /* Boy, this is unclean. `time' by itself can | - | ||||||||||||||||||
3268 | time a null command. We cheat and push a | - | ||||||||||||||||||
3269 | newline back if the list_terminator was a newline | - | ||||||||||||||||||
3270 | to avoid the double-newline problem (one to | - | ||||||||||||||||||
3271 | terminate this, one to terminate the command) */ | - | ||||||||||||||||||
3272 | x.word = 0; | - | ||||||||||||||||||
3273 | x.redirect = 0; | - | ||||||||||||||||||
3274 | (yyval.command) = make_simple_command (x, (COMMAND *)NULL); | - | ||||||||||||||||||
3275 | (yyval.command)->flags |= (yyvsp[-1].number); | - | ||||||||||||||||||
3276 | /* XXX - let's cheat and push a newline back */ | - | ||||||||||||||||||
3277 | if ((yyvsp[0].number) == '\n') | - | ||||||||||||||||||
3278 | token_to_read = '\n'; | - | ||||||||||||||||||
3279 | else if ((yyvsp[0].number) == ';') | - | ||||||||||||||||||
3280 | token_to_read = ';'; | - | ||||||||||||||||||
3281 | parser_state &= ~PST_REDIRLIST; /* make_simple_command sets this */ | - | ||||||||||||||||||
3282 | } | - | ||||||||||||||||||
3283 | #line 3284 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3284 | break; executed 1 time by 1 test: se 164 Executed by:
| 1 | ||||||||||||||||||
3285 | - | |||||||||||||||||||
3286 | case 162: executed 4 times by 1 test Executed by:
| 4 | ||||||||||||||||||
3287 | #line 1251 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3288 | { | - | ||||||||||||||||||
3289 | ELEMENT x; | - | ||||||||||||||||||
3290 | - | |||||||||||||||||||
3291 | /* This is just as unclean. Posix says that `!' | - | ||||||||||||||||||
3292 | by itself should be equivalent to `false'. | - | ||||||||||||||||||
3293 | We cheat and push a | - | ||||||||||||||||||
3294 | newline back if the list_terminator was a newline | - | ||||||||||||||||||
3295 | to avoid the double-newline problem (one to | - | ||||||||||||||||||
3296 | terminate this, one to terminate the command) */ | - | ||||||||||||||||||
3297 | x.word = 0; | - | ||||||||||||||||||
3298 | x.redirect = 0; | - | ||||||||||||||||||
3299 | (yyval.command) = make_simple_command (x, (COMMAND *)NULL); | - | ||||||||||||||||||
3300 | (yyval.command)->flags |= CMD_INVERT_RETURN; | - | ||||||||||||||||||
3301 | /* XXX - let's cheat and push a newline back */ | - | ||||||||||||||||||
3302 | if ((yyvsp[0].number) == '\n') | - | ||||||||||||||||||
3303 | token_to_read = '\n'; | - | ||||||||||||||||||
3304 | if ((yyvsp[0].number) == ';') | - | ||||||||||||||||||
3305 | token_to_read = ';'; | - | ||||||||||||||||||
3306 | parser_state &= ~PST_REDIRLIST; /* make_simple_command sets this */ | - | ||||||||||||||||||
3307 | } | - | ||||||||||||||||||
3308 | #line 3309 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3309 | break; executed 4 times by 1 test: se 165 Executed by:
| 4 | ||||||||||||||||||
3310 | - | |||||||||||||||||||
3311 | case 163: executed 13621 times by 1 test Executed by:
| 13621 | ||||||||||||||||||
3312 | #line 1274 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3313 | { (yyval.command) = command_connect ((yyvsp[-3].command), (yyvsp[0].command), '|'); } | - | ||||||||||||||||||
3314 | #line 3315 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3315 | break; executed 13621 times by 1 test: se 166 Executed by:
| 13621 | ||||||||||||||||||
3316 | - | |||||||||||||||||||
3317 | case 164: executed 2 times by 1 test Executed by:
| 2 | ||||||||||||||||||
3318 | #line 1276 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3319 | { | - | ||||||||||||||||||
3320 | /* Make cmd1 |& cmd2 equivalent to cmd1 2>&1 | cmd2 */ | - | ||||||||||||||||||
3321 | COMMAND *tc; | - | ||||||||||||||||||
3322 | REDIRECTEE rd, sd; | - | ||||||||||||||||||
3323 | REDIRECT *r; | - | ||||||||||||||||||
3324 | - | |||||||||||||||||||
3325 | tc = (yyvsp[-3].command)->type == cm_simple ? (COMMAND *)(yyvsp[-3].command)->value.Simple : (yyvsp[-3].command); | - | ||||||||||||||||||
3326 | sd.dest = 2; | - | ||||||||||||||||||
3327 | rd.dest = 1; | - | ||||||||||||||||||
3328 | r = make_redirection (sd, r_duplicating_output, rd, 0); | - | ||||||||||||||||||
3329 | if (tc->redirects) | - | ||||||||||||||||||
3330 | { | - | ||||||||||||||||||
3331 | register REDIRECT *t; | - | ||||||||||||||||||
3332 | for (t = tc->redirects; t->next; t = t->next) | - | ||||||||||||||||||
3333 | ; | - | ||||||||||||||||||
3334 | t->next = r; | - | ||||||||||||||||||
3335 | } | - | ||||||||||||||||||
3336 | else | - | ||||||||||||||||||
3337 | tc->redirects = r; | - | ||||||||||||||||||
3338 | - | |||||||||||||||||||
3339 | (yyval.command) = command_connect ((yyvsp[-3].command), (yyvsp[0].command), '|'); | - | ||||||||||||||||||
3340 | } | - | ||||||||||||||||||
3341 | #line 3342 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3342 | break; executed 2 times by 1 test: se 167 Executed by:
| 2 | ||||||||||||||||||
3343 | - | |||||||||||||||||||
3344 | case 165: executed 1217115 times by 1 test Executed by:
| 1217115 | ||||||||||||||||||
3345 | #line 1299 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3346 | { (yyval.command) = (yyvsp[0].command); } | - | ||||||||||||||||||
3347 | #line 3348 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3348 | break; executed 1217115 times by 1 test: se 168 Executed by:
| 1217115 | ||||||||||||||||||
3349 | - | |||||||||||||||||||
3350 | case 166: executed 7 times by 1 test: defau Executed by:
| 7 | ||||||||||||||||||
3351 | #line 1303 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3352 | { (yyval.number) = CMD_TIME_PIPELINE; } | - | ||||||||||||||||||
3353 | #line 3354 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3354 | break; executed 7 times by 1 test: end of block Executed by:
| 7 | ||||||||||||||||||
3355 | - | |||||||||||||||||||
3356 | case 167: executed 7 times by 1 test: tderr Executed by:
| 7 | ||||||||||||||||||
3357 | #line 1305 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3358 | { (yyval.number) = CMD_TIME_PIPELINE|CMD_TIME_POSIX; } | - | ||||||||||||||||||
3359 | #line 3360 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3360 | break; executed 7 times by 1 test: %s ", Executed by:
| 7 | ||||||||||||||||||
3361 | - | |||||||||||||||||||
3362 | case 168: executed 1 time by 1 test: yyr1[yyn Executed by:
| 1 | ||||||||||||||||||
3363 | #line 1307 "./parse.y" /* yacc.c:1646 */ | - | ||||||||||||||||||
3364 | { (yyval.number) = CMD_TIME_PIPELINE|CMD_TIME_POSIX; } | - | ||||||||||||||||||
3365 | #line 3366 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3366 | break; executed 1 time by 1 test: err Executed by:
| 1 | ||||||||||||||||||
3367 | - | |||||||||||||||||||
3368 | - | |||||||||||||||||||
3369 | #line 3370 "y.tab.c" /* yacc.c:1646 */ | - | ||||||||||||||||||
3370 | default: break; executed 1449710 times by 1 test: hile ( Executed by:
executed 1449710 times by 1 test: "); } } Executed by:
| 1449710 | ||||||||||||||||||
3371 | } | - | ||||||||||||||||||
3372 | /* User semantic actions sometimes alter yychar, and that requires | - | ||||||||||||||||||
3373 | that yytoken be updated with the new translation. We take the | - | ||||||||||||||||||
3374 | approach of translating immediately before every use of yytoken. | - | ||||||||||||||||||
3375 | One alternative is translating here after every semantic action, | - | ||||||||||||||||||
3376 | but that translation would be missed if the semantic action invokes | - | ||||||||||||||||||
3377 | YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or | - | ||||||||||||||||||
3378 | if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an | - | ||||||||||||||||||
3379 | incorrect destructor might then be invoked immediately. In the | - | ||||||||||||||||||
3380 | case of YYERROR or YYBACKUP, subsequent parser actions might lead | - | ||||||||||||||||||
3381 | to an incorrect destructor call or verbose syntax error message | - | ||||||||||||||||||
3382 | before the lookahead is translated. */ | - | ||||||||||||||||||
3383 | YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); never executed
| 0-11978996 | ||||||||||||||||||
3384 | - | |||||||||||||||||||
3385 | YYPOPSTACK (yylen); | - | ||||||||||||||||||
3386 | yylen = 0; | - | ||||||||||||||||||
3387 | YY_STACK_PRINT (yyss, yyssp); never executed
| 0-11978996 | ||||||||||||||||||
3388 | - | |||||||||||||||||||
3389 | *++yyvsp = yyval; | - | ||||||||||||||||||
3390 | - | |||||||||||||||||||
3391 | /* Now 'shift' the result of the reduction. Determine what state | - | ||||||||||||||||||
3392 | that goes to, based on the state we popped back to and the rule | - | ||||||||||||||||||
3393 | number reduced by. */ | - | ||||||||||||||||||
3394 | - | |||||||||||||||||||
3395 | yyn = yyr1[yyn]; | - | ||||||||||||||||||
3396 | - | |||||||||||||||||||
3397 | yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; | - | ||||||||||||||||||
3398 | if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
| 275323-8737159 | ||||||||||||||||||
3399 | yystate = yytable[yystate]; executed 3474998 times by 1 test Executed by:
| 3474998 | ||||||||||||||||||
3400 | else | - | ||||||||||||||||||
3401 | yystate = yydefgoto[yyn - YYNTOKENS]; executed 8503998 times by 1 test: rlab: Executed by:
| 8503998 | ||||||||||||||||||
3402 | - | |||||||||||||||||||
3403 | goto yynewstate; executed 11978996 times by 1 test Executed by:
| 11978996 | ||||||||||||||||||
3404 | - | |||||||||||||||||||
3405 | - | |||||||||||||||||||
3406 | /*--------------------------------------. | - | ||||||||||||||||||
3407 | | yyerrlab -- here on detecting error. | | - | ||||||||||||||||||
3408 | `--------------------------------------*/ | - | ||||||||||||||||||
3409 | yyerrlab: | - | ||||||||||||||||||
3410 | /* Make sure we have latest lookahead translation. See comments at | - | ||||||||||||||||||
3411 | user semantic actions for why this is necessary. */ | - | ||||||||||||||||||
3412 | yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
| 0-52 | ||||||||||||||||||
3413 | - | |||||||||||||||||||
3414 | /* If not already recovering from an error, report this error. */ | - | ||||||||||||||||||
3415 | if (!yyerrstatus)
| 25-27 | ||||||||||||||||||
3416 | { | - | ||||||||||||||||||
3417 | ++yynerrs; | - | ||||||||||||||||||
3418 | #if ! YYERROR_VERBOSE | - | ||||||||||||||||||
3419 | yyerror (YY_("syntax error")); | - | ||||||||||||||||||
3420 | #else | - | ||||||||||||||||||
3421 | # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ | - | ||||||||||||||||||
3422 | yyssp, yytoken) | - | ||||||||||||||||||
3423 | { | - | ||||||||||||||||||
3424 | char const *yymsgp = YY_("syntax error"); | - | ||||||||||||||||||
3425 | int yysyntax_error_status; | - | ||||||||||||||||||
3426 | yysyntax_error_status = YYSYNTAX_ERROR; | - | ||||||||||||||||||
3427 | if (yysyntax_error_status == 0) | - | ||||||||||||||||||
3428 | yymsgp = yymsg; | - | ||||||||||||||||||
3429 | else if (yysyntax_error_status == 1) | - | ||||||||||||||||||
3430 | { | - | ||||||||||||||||||
3431 | if (yymsg != yymsgbuf) | - | ||||||||||||||||||
3432 | YYSTACK_FREE (yymsg); | - | ||||||||||||||||||
3433 | yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); | - | ||||||||||||||||||
3434 | if (!yymsg) | - | ||||||||||||||||||
3435 | { | - | ||||||||||||||||||
3436 | yymsg = yymsgbuf; | - | ||||||||||||||||||
3437 | yymsg_alloc = sizeof yymsgbuf; | - | ||||||||||||||||||
3438 | yysyntax_error_status = 2; | - | ||||||||||||||||||
3439 | } | - | ||||||||||||||||||
3440 | else | - | ||||||||||||||||||
3441 | { | - | ||||||||||||||||||
3442 | yysyntax_error_status = YYSYNTAX_ERROR; | - | ||||||||||||||||||
3443 | yymsgp = yymsg; | - | ||||||||||||||||||
3444 | } | - | ||||||||||||||||||
3445 | } | - | ||||||||||||||||||
3446 | yyerror (yymsgp); | - | ||||||||||||||||||
3447 | if (yysyntax_error_status == 2) | - | ||||||||||||||||||
3448 | goto yyexhaustedlab; | - | ||||||||||||||||||
3449 | } | - | ||||||||||||||||||
3450 | # undef YYSYNTAX_ERROR | - | ||||||||||||||||||
3451 | #endif | - | ||||||||||||||||||
3452 | } executed 27 times by 1 test Executed by:
| 27 | ||||||||||||||||||
3453 | - | |||||||||||||||||||
3454 | - | |||||||||||||||||||
3455 | - | |||||||||||||||||||
3456 | if (yyerrstatus == 3)
| 25-27 | ||||||||||||||||||
3457 | { | - | ||||||||||||||||||
3458 | /* If just tried and failed to reuse lookahead token after an | - | ||||||||||||||||||
3459 | error, discard it. */ | - | ||||||||||||||||||
3460 | - | |||||||||||||||||||
3461 | if (yychar <= YYEOF)
| 5-20 | ||||||||||||||||||
3462 | { | - | ||||||||||||||||||
3463 | /* Return failure if at end of input. */ | - | ||||||||||||||||||
3464 | if (yychar == YYEOF)
| 0-5 | ||||||||||||||||||
3465 | YYABORT; executed 5 times by 1 test Executed by:
| 5 | ||||||||||||||||||
3466 | } never executed | 0 | ||||||||||||||||||
3467 | else | - | ||||||||||||||||||
3468 | { | - | ||||||||||||||||||
3469 | yydestruct ("Error: discarding", | - | ||||||||||||||||||
3470 | yytoken, &yylval); | - | ||||||||||||||||||
3471 | yychar = YYEMPTY; | - | ||||||||||||||||||
3472 | } executed 20 times by 1 test Executed by:
| 20 | ||||||||||||||||||
3473 | } | - | ||||||||||||||||||
3474 | - | |||||||||||||||||||
3475 | /* Else will try to reuse lookahead token after shifting the error | - | ||||||||||||||||||
3476 | token. */ | - | ||||||||||||||||||
3477 | goto yyerrlab1; executed 47 times by 1 test Executed by:
| 47 | ||||||||||||||||||
3478 | - | |||||||||||||||||||
3479 | - | |||||||||||||||||||
3480 | /*---------------------------------------------------. | - | ||||||||||||||||||
3481 | | yyerrorlab -- error raised explicitly by YYERROR. | | - | ||||||||||||||||||
3482 | `---------------------------------------------------*/ | - | ||||||||||||||||||
3483 | yyerrorlab: | - | ||||||||||||||||||
3484 | - | |||||||||||||||||||
3485 | /* Pacify compilers like GCC when the user code never invokes | - | ||||||||||||||||||
3486 | YYERROR and the label yyerrorlab therefore never appears in user | - | ||||||||||||||||||
3487 | code. */ | - | ||||||||||||||||||
3488 | if (/*CONSTCOND*/ 0) dead code: = *yyssp; goto yyerrlab1; | - | ||||||||||||||||||
3489 | goto yyerrorlab; dead code: = *yyssp; goto yyerrlab1; | - | ||||||||||||||||||
3490 | - | |||||||||||||||||||
3491 | /* Do not reclaim the symbols of the rule whose action triggered | - | ||||||||||||||||||
3492 | this YYERROR. */ | - | ||||||||||||||||||
3493 | YYPOPSTACK (yylen); | - | ||||||||||||||||||
3494 | yylen = 0; | - | ||||||||||||||||||
3495 | YY_STACK_PRINT (yyss, yyssp); never executed
| 0-2 | ||||||||||||||||||
3496 | yystate = *yyssp; | - | ||||||||||||||||||
3497 | goto yyerrlab1; executed 2 times by 1 test Executed by:
| 2 | ||||||||||||||||||
3498 | - | |||||||||||||||||||
3499 | - | |||||||||||||||||||
3500 | /*-------------------------------------------------------------. | - | ||||||||||||||||||
3501 | | yyerrlab1 -- common code for both syntax error and YYERROR. | | - | ||||||||||||||||||
3502 | `-------------------------------------------------------------*/ | - | ||||||||||||||||||
3503 | yyerrlab1: | - | ||||||||||||||||||
3504 | yyerrstatus = 3; /* Each real token shifted decrements this. */ | - | ||||||||||||||||||
3505 | - | |||||||||||||||||||
3506 | for (;;) | - | ||||||||||||||||||
3507 | { | - | ||||||||||||||||||
3508 | yyn = yypact[yystate]; | - | ||||||||||||||||||
3509 | if (!yypact_value_is_default (yyn))
| 25-152 | ||||||||||||||||||
3510 | { | - | ||||||||||||||||||
3511 | yyn += YYTERROR; | - | ||||||||||||||||||
3512 | if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
| 0-128 | ||||||||||||||||||
3513 | { | - | ||||||||||||||||||
3514 | yyn = yytable[yyn]; | - | ||||||||||||||||||
3515 | if (0 < yyn)
| 0-49 | ||||||||||||||||||
3516 | break; executed 49 times by 1 test Executed by:
| 49 | ||||||||||||||||||
3517 | } never executed: r | 0 | ||||||||||||||||||
3518 | } executed 103 times by 1 test Executed by:
| 103 | ||||||||||||||||||
3519 | - | |||||||||||||||||||
3520 | /* Pop the current state because it cannot handle the error token. */ | - | ||||||||||||||||||
3521 | if (yyssp == yyss)
| 0-128 | ||||||||||||||||||
3522 | YYABORT; never executed | 0 | ||||||||||||||||||
3523 | - | |||||||||||||||||||
3524 | - | |||||||||||||||||||
3525 | yydestruct ("Error: popping", | - | ||||||||||||||||||
3526 | yystos[yystate], yyvsp); | - | ||||||||||||||||||
3527 | YYPOPSTACK (1); | - | ||||||||||||||||||
3528 | yystate = *yyssp; | - | ||||||||||||||||||
3529 | YY_STACK_PRINT (yyss, yyssp); never executed
| 0-128 | ||||||||||||||||||
3530 | } executed 128 times by 1 test Executed by:
| 128 | ||||||||||||||||||
3531 | - | |||||||||||||||||||
3532 | YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN | - | ||||||||||||||||||
3533 | *++yyvsp = yylval; | - | ||||||||||||||||||
3534 | YY_IGNORE_MAYBE_UNINITIALIZED_END | - | ||||||||||||||||||
3535 | - | |||||||||||||||||||
3536 | - | |||||||||||||||||||
3537 | /* Shift the error token. */ | - | ||||||||||||||||||
3538 | YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); never executed
| 0-49 | ||||||||||||||||||
3539 | - | |||||||||||||||||||
3540 | yystate = yyn; | - | ||||||||||||||||||
3541 | goto yynewstate; executed 49 times by 1 test Executed by:
| 49 | ||||||||||||||||||
3542 | - | |||||||||||||||||||
3543 | - | |||||||||||||||||||
3544 | /*-------------------------------------. | - | ||||||||||||||||||
3545 | | yyacceptlab -- YYACCEPT comes here. | | - | ||||||||||||||||||
3546 | `-------------------------------------*/ | - | ||||||||||||||||||
3547 | yyacceptlab: | - | ||||||||||||||||||
3548 | yyresult = 0; | - | ||||||||||||||||||
3549 | goto yyreturn; executed 907907 times by 1 test Executed by:
| 907907 | ||||||||||||||||||
3550 | - | |||||||||||||||||||
3551 | /*-----------------------------------. | - | ||||||||||||||||||
3552 | | yyabortlab -- YYABORT comes here. | | - | ||||||||||||||||||
3553 | `-----------------------------------*/ | - | ||||||||||||||||||
3554 | yyabortlab: | - | ||||||||||||||||||
3555 | yyresult = 1; | - | ||||||||||||||||||
3556 | goto yyreturn; executed 29 times by 1 test: return: Executed by:
| 29 | ||||||||||||||||||
3557 | - | |||||||||||||||||||
3558 | #if !defined yyoverflow || YYERROR_VERBOSE | - | ||||||||||||||||||
3559 | /*-------------------------------------------------. | - | ||||||||||||||||||
3560 | | yyexhaustedlab -- memory exhaustion comes here. | | - | ||||||||||||||||||
3561 | `-------------------------------------------------*/ | - | ||||||||||||||||||
3562 | yyexhaustedlab: | - | ||||||||||||||||||
3563 | yyerror (YY_("memory exhausted")); | - | ||||||||||||||||||
3564 | yyresult = 2; | - | ||||||||||||||||||
3565 | /* Fall through. */ | - | ||||||||||||||||||
3566 | #endif | - | ||||||||||||||||||
3567 | - | |||||||||||||||||||
3568 | yyreturn: code before this statement never executed: do { if | 0 | ||||||||||||||||||
3569 | if (yychar != YYEMPTY)
| 203603-704333 | ||||||||||||||||||
3570 | { | - | ||||||||||||||||||
3571 | /* Make sure we have latest lookahead translation. See comments at | - | ||||||||||||||||||
3572 | user semantic actions for why this is necessary. */ | - | ||||||||||||||||||
3573 | yytoken = YYTRANSLATE (yychar);
| 0-704333 | ||||||||||||||||||
3574 | yydestruct ("Cleanup: discarding lookahead", | - | ||||||||||||||||||
3575 | yytoken, &yylval); | - | ||||||||||||||||||
3576 | } executed 704333 times by 1 test Executed by:
| 704333 | ||||||||||||||||||
3577 | /* Do not reclaim the symbols of the rule whose action triggered | - | ||||||||||||||||||
3578 | this YYABORT or YYACCEPT. */ | - | ||||||||||||||||||
3579 | YYPOPSTACK (yylen); | - | ||||||||||||||||||
3580 | YY_STACK_PRINT (yyss, yyssp); never executed
| 0-907936 | ||||||||||||||||||
3581 | while (yyssp != yyss)
| 5-907936 | ||||||||||||||||||
3582 | { | - | ||||||||||||||||||
3583 | yydestruct ("Cleanup: popping", | - | ||||||||||||||||||
3584 | yystos[*yyssp], yyvsp); | - | ||||||||||||||||||
3585 | YYPOPSTACK (1); | - | ||||||||||||||||||
3586 | } executed 5 times by 1 test Executed by:
| 5 | ||||||||||||||||||
3587 | #ifndef yyoverflow | - | ||||||||||||||||||
3588 | if (yyss != yyssa)
| 1-907935 | ||||||||||||||||||
3589 | YYSTACK_FREE (yyss); executed 1 time by 1 test Executed by:
| 1 | ||||||||||||||||||
3590 | #endif | - | ||||||||||||||||||
3591 | #if YYERROR_VERBOSE | - | ||||||||||||||||||
3592 | if (yymsg != yymsgbuf) | - | ||||||||||||||||||
3593 | YYSTACK_FREE (yymsg); | - | ||||||||||||||||||
3594 | #endif | - | ||||||||||||||||||
3595 | return yyresult; executed 907936 times by 1 test Executed by:
| 907936 | ||||||||||||||||||
3596 | } | - | ||||||||||||||||||
3597 | #line 1309 "./parse.y" /* yacc.c:1906 */ | - | ||||||||||||||||||
3598 | - | |||||||||||||||||||
3599 | - | |||||||||||||||||||
3600 | /* Initial size to allocate for tokens, and the | - | ||||||||||||||||||
3601 | amount to grow them by. */ | - | ||||||||||||||||||
3602 | #define TOKEN_DEFAULT_INITIAL_SIZE 496 | - | ||||||||||||||||||
3603 | #define TOKEN_DEFAULT_GROW_SIZE 512 | - | ||||||||||||||||||
3604 | - | |||||||||||||||||||
3605 | /* Should we call prompt_again? */ | - | ||||||||||||||||||
3606 | #define SHOULD_PROMPT() \ | - | ||||||||||||||||||
3607 | (interactive && (bash_input.type == st_stdin || bash_input.type == st_stream)) | - | ||||||||||||||||||
3608 | - | |||||||||||||||||||
3609 | #if defined (ALIAS) | - | ||||||||||||||||||
3610 | # define expanding_alias() (pushed_string_list && pushed_string_list->expander) | - | ||||||||||||||||||
3611 | #else | - | ||||||||||||||||||
3612 | # define expanding_alias() 0 | - | ||||||||||||||||||
3613 | #endif | - | ||||||||||||||||||
3614 | - | |||||||||||||||||||
3615 | /* Global var is non-zero when end of file has been reached. */ | - | ||||||||||||||||||
3616 | int EOF_Reached = 0; | - | ||||||||||||||||||
3617 | - | |||||||||||||||||||
3618 | #ifdef DEBUG | - | ||||||||||||||||||
3619 | static void | - | ||||||||||||||||||
3620 | debug_parser (i) | - | ||||||||||||||||||
3621 | int i; | - | ||||||||||||||||||
3622 | { | - | ||||||||||||||||||
3623 | #if YYDEBUG != 0 | - | ||||||||||||||||||
3624 | yydebug = i; | - | ||||||||||||||||||
3625 | yyoutstream = stdout; | - | ||||||||||||||||||
3626 | yyerrstream = stderr; | - | ||||||||||||||||||
3627 | #endif | - | ||||||||||||||||||
3628 | } | - | ||||||||||||||||||
3629 | #endif | - | ||||||||||||||||||
3630 | - | |||||||||||||||||||
3631 | /* yy_getc () returns the next available character from input or EOF. | - | ||||||||||||||||||
3632 | yy_ungetc (c) makes `c' the next character to read. | - | ||||||||||||||||||
3633 | init_yy_io (get, unget, type, location) makes the function GET the | - | ||||||||||||||||||
3634 | installed function for getting the next character, makes UNGET the | - | ||||||||||||||||||
3635 | installed function for un-getting a character, sets the type of stream | - | ||||||||||||||||||
3636 | (either string or file) from TYPE, and makes LOCATION point to where | - | ||||||||||||||||||
3637 | the input is coming from. */ | - | ||||||||||||||||||
3638 | - | |||||||||||||||||||
3639 | /* Unconditionally returns end-of-file. */ | - | ||||||||||||||||||
3640 | int | - | ||||||||||||||||||
3641 | return_EOF () | - | ||||||||||||||||||
3642 | { | - | ||||||||||||||||||
3643 | return (EOF); | - | ||||||||||||||||||
3644 | } | - | ||||||||||||||||||
3645 | - | |||||||||||||||||||
3646 | /* Variable containing the current get and unget functions. | - | ||||||||||||||||||
3647 | See ./input.h for a clearer description. */ | - | ||||||||||||||||||
3648 | BASH_INPUT bash_input; | - | ||||||||||||||||||
3649 | - | |||||||||||||||||||
3650 | /* Set all of the fields in BASH_INPUT to NULL. Free bash_input.name if it | - | ||||||||||||||||||
3651 | is non-null, avoiding a memory leak. */ | - | ||||||||||||||||||
3652 | void | - | ||||||||||||||||||
3653 | initialize_bash_input () | - | ||||||||||||||||||
3654 | { | - | ||||||||||||||||||
3655 | bash_input.type = st_none; | - | ||||||||||||||||||
3656 | FREE (bash_input.name); | - | ||||||||||||||||||
3657 | bash_input.name = (char *)NULL; | - | ||||||||||||||||||
3658 | bash_input.location.file = (FILE *)NULL; | - | ||||||||||||||||||
3659 | bash_input.location.string = (char *)NULL; | - | ||||||||||||||||||
3660 | bash_input.getter = (sh_cget_func_t *)NULL; | - | ||||||||||||||||||
3661 | bash_input.ungetter = (sh_cunget_func_t *)NULL; | - | ||||||||||||||||||
3662 | } | - | ||||||||||||||||||
3663 | - | |||||||||||||||||||
3664 | /* Set the contents of the current bash input stream from | - | ||||||||||||||||||
3665 | GET, UNGET, TYPE, NAME, and LOCATION. */ | - | ||||||||||||||||||
3666 | void | - | ||||||||||||||||||
3667 | init_yy_io (get, unget, type, name, location) | - | ||||||||||||||||||
3668 | sh_cget_func_t *get; | - | ||||||||||||||||||
3669 | sh_cunget_func_t *unget; | - | ||||||||||||||||||
3670 | enum stream_type type; | - | ||||||||||||||||||
3671 | const char *name; | - | ||||||||||||||||||
3672 | INPUT_STREAM location; | - | ||||||||||||||||||
3673 | { | - | ||||||||||||||||||
3674 | bash_input.type = type; | - | ||||||||||||||||||
3675 | FREE (bash_input.name); | - | ||||||||||||||||||
3676 | bash_input.name = name ? savestring (name) : (char *)NULL; | - | ||||||||||||||||||
3677 | - | |||||||||||||||||||
3678 | /* XXX */ | - | ||||||||||||||||||
3679 | #if defined (CRAY) | - | ||||||||||||||||||
3680 | memcpy((char *)&bash_input.location.string, (char *)&location.string, sizeof(location)); | - | ||||||||||||||||||
3681 | #else | - | ||||||||||||||||||
3682 | bash_input.location = location; | - | ||||||||||||||||||
3683 | #endif | - | ||||||||||||||||||
3684 | bash_input.getter = get; | - | ||||||||||||||||||
3685 | bash_input.ungetter = unget; | - | ||||||||||||||||||
3686 | } | - | ||||||||||||||||||
3687 | - | |||||||||||||||||||
3688 | char * | - | ||||||||||||||||||
3689 | yy_input_name () | - | ||||||||||||||||||
3690 | { | - | ||||||||||||||||||
3691 | return (bash_input.name ? bash_input.name : "stdin"); | - | ||||||||||||||||||
3692 | } | - | ||||||||||||||||||
3693 | - | |||||||||||||||||||
3694 | /* Call this to get the next character of input. */ | - | ||||||||||||||||||
3695 | static int | - | ||||||||||||||||||
3696 | yy_getc () | - | ||||||||||||||||||
3697 | { | - | ||||||||||||||||||
3698 | return (*(bash_input.getter)) (); | - | ||||||||||||||||||
3699 | } | - | ||||||||||||||||||
3700 | - | |||||||||||||||||||
3701 | /* Call this to unget C. That is, to make C the next character | - | ||||||||||||||||||
3702 | to be read. */ | - | ||||||||||||||||||
3703 | static int | - | ||||||||||||||||||
3704 | yy_ungetc (c) | - | ||||||||||||||||||
3705 | int c; | - | ||||||||||||||||||
3706 | { | - | ||||||||||||||||||
3707 | return (*(bash_input.ungetter)) (c); | - | ||||||||||||||||||
3708 | } | - | ||||||||||||||||||
3709 | - | |||||||||||||||||||
3710 | #if defined (BUFFERED_INPUT) | - | ||||||||||||||||||
3711 | #ifdef INCLUDE_UNUSED | - | ||||||||||||||||||
3712 | int | - | ||||||||||||||||||
3713 | input_file_descriptor () | - | ||||||||||||||||||
3714 | { | - | ||||||||||||||||||
3715 | switch (bash_input.type) | - | ||||||||||||||||||
3716 | { | - | ||||||||||||||||||
3717 | case st_stream: | - | ||||||||||||||||||
3718 | return (fileno (bash_input.location.file)); | - | ||||||||||||||||||
3719 | case st_bstream: | - | ||||||||||||||||||
3720 | return (bash_input.location.buffered_fd); | - | ||||||||||||||||||
3721 | case st_stdin: | - | ||||||||||||||||||
3722 | default: | - | ||||||||||||||||||
3723 | return (fileno (stdin)); | - | ||||||||||||||||||
3724 | } | - | ||||||||||||||||||
3725 | } | - | ||||||||||||||||||
3726 | #endif | - | ||||||||||||||||||
3727 | #endif /* BUFFERED_INPUT */ | - | ||||||||||||||||||
3728 | - | |||||||||||||||||||
3729 | /* **************************************************************** */ | - | ||||||||||||||||||
3730 | /* */ | - | ||||||||||||||||||
3731 | /* Let input be read from readline (). */ | - | ||||||||||||||||||
3732 | /* */ | - | ||||||||||||||||||
3733 | /* **************************************************************** */ | - | ||||||||||||||||||
3734 | - | |||||||||||||||||||
3735 | #if defined (READLINE) | - | ||||||||||||||||||
3736 | char *current_readline_prompt = (char *)NULL; | - | ||||||||||||||||||
3737 | char *current_readline_line = (char *)NULL; | - | ||||||||||||||||||
3738 | int current_readline_line_index = 0; | - | ||||||||||||||||||
3739 | - | |||||||||||||||||||
3740 | static int | - | ||||||||||||||||||
3741 | yy_readline_get () | - | ||||||||||||||||||
3742 | { | - | ||||||||||||||||||
3743 | SigHandler *old_sigint; | - | ||||||||||||||||||
3744 | int line_len; | - | ||||||||||||||||||
3745 | unsigned char c; | - | ||||||||||||||||||
3746 | - | |||||||||||||||||||
3747 | if (current_readline_line == 0) | - | ||||||||||||||||||
3748 | { | - | ||||||||||||||||||
3749 | if (bash_readline_initialized == 0) | - | ||||||||||||||||||
3750 | initialize_readline (); | - | ||||||||||||||||||
3751 | - | |||||||||||||||||||
3752 | #if defined (JOB_CONTROL) | - | ||||||||||||||||||
3753 | if (job_control) | - | ||||||||||||||||||
3754 | give_terminal_to (shell_pgrp, 0); | - | ||||||||||||||||||
3755 | #endif /* JOB_CONTROL */ | - | ||||||||||||||||||
3756 | - | |||||||||||||||||||
3757 | old_sigint = IMPOSSIBLE_TRAP_HANDLER; | - | ||||||||||||||||||
3758 | if (signal_is_ignored (SIGINT) == 0) | - | ||||||||||||||||||
3759 | { | - | ||||||||||||||||||
3760 | /* interrupt_immediately++; */ | - | ||||||||||||||||||
3761 | old_sigint = (SigHandler *)set_signal_handler (SIGINT, sigint_sighandler); | - | ||||||||||||||||||
3762 | } | - | ||||||||||||||||||
3763 | - | |||||||||||||||||||
3764 | sh_unset_nodelay_mode (fileno (rl_instream)); /* just in case */ | - | ||||||||||||||||||
3765 | current_readline_line = readline (current_readline_prompt ? | - | ||||||||||||||||||
3766 | current_readline_prompt : ""); | - | ||||||||||||||||||
3767 | - | |||||||||||||||||||
3768 | CHECK_TERMSIG; | - | ||||||||||||||||||
3769 | if (signal_is_ignored (SIGINT) == 0) | - | ||||||||||||||||||
3770 | { | - | ||||||||||||||||||
3771 | /* interrupt_immediately--; */ | - | ||||||||||||||||||
3772 | if (old_sigint != IMPOSSIBLE_TRAP_HANDLER) | - | ||||||||||||||||||
3773 | set_signal_handler (SIGINT, old_sigint); | - | ||||||||||||||||||
3774 | } | - | ||||||||||||||||||
3775 | - | |||||||||||||||||||
3776 | #if 0 | - | ||||||||||||||||||
3777 | /* Reset the prompt to the decoded value of prompt_string_pointer. */ | - | ||||||||||||||||||
3778 | reset_readline_prompt (); | - | ||||||||||||||||||
3779 | #endif | - | ||||||||||||||||||
3780 | - | |||||||||||||||||||
3781 | if (current_readline_line == 0) | - | ||||||||||||||||||
3782 | return (EOF); | - | ||||||||||||||||||
3783 | - | |||||||||||||||||||
3784 | current_readline_line_index = 0; | - | ||||||||||||||||||
3785 | line_len = strlen (current_readline_line); | - | ||||||||||||||||||
3786 | - | |||||||||||||||||||
3787 | current_readline_line = (char *)xrealloc (current_readline_line, 2 + line_len); | - | ||||||||||||||||||
3788 | current_readline_line[line_len++] = '\n'; | - | ||||||||||||||||||
3789 | current_readline_line[line_len] = '\0'; | - | ||||||||||||||||||
3790 | } | - | ||||||||||||||||||
3791 | - | |||||||||||||||||||
3792 | if (current_readline_line[current_readline_line_index] == 0) | - | ||||||||||||||||||
3793 | { | - | ||||||||||||||||||
3794 | free (current_readline_line); | - | ||||||||||||||||||
3795 | current_readline_line = (char *)NULL; | - | ||||||||||||||||||
3796 | return (yy_readline_get ()); | - | ||||||||||||||||||
3797 | } | - | ||||||||||||||||||
3798 | else | - | ||||||||||||||||||
3799 | { | - | ||||||||||||||||||
3800 | c = current_readline_line[current_readline_line_index++]; | - | ||||||||||||||||||
3801 | return (c); | - | ||||||||||||||||||
3802 | } | - | ||||||||||||||||||
3803 | } | - | ||||||||||||||||||
3804 | - | |||||||||||||||||||
3805 | static int | - | ||||||||||||||||||
3806 | yy_readline_unget (c) | - | ||||||||||||||||||
3807 | int c; | - | ||||||||||||||||||
3808 | { | - | ||||||||||||||||||
3809 | if (current_readline_line_index && current_readline_line) | - | ||||||||||||||||||
3810 | current_readline_line[--current_readline_line_index] = c; | - | ||||||||||||||||||
3811 | return (c); | - | ||||||||||||||||||
3812 | } | - | ||||||||||||||||||
3813 | - | |||||||||||||||||||
3814 | void | - | ||||||||||||||||||
3815 | with_input_from_stdin () | - | ||||||||||||||||||
3816 | { | - | ||||||||||||||||||
3817 | INPUT_STREAM location; | - | ||||||||||||||||||
3818 | - | |||||||||||||||||||
3819 | if (bash_input.type != st_stdin && stream_on_stack (st_stdin) == 0) | - | ||||||||||||||||||
3820 | { | - | ||||||||||||||||||
3821 | location.string = current_readline_line; | - | ||||||||||||||||||
3822 | init_yy_io (yy_readline_get, yy_readline_unget, | - | ||||||||||||||||||
3823 | st_stdin, "readline stdin", location); | - | ||||||||||||||||||
3824 | } | - | ||||||||||||||||||
3825 | } | - | ||||||||||||||||||
3826 | - | |||||||||||||||||||
3827 | #else /* !READLINE */ | - | ||||||||||||||||||
3828 | - | |||||||||||||||||||
3829 | void | - | ||||||||||||||||||
3830 | with_input_from_stdin () | - | ||||||||||||||||||
3831 | { | - | ||||||||||||||||||
3832 | with_input_from_stream (stdin, "stdin"); | - | ||||||||||||||||||
3833 | } | - | ||||||||||||||||||
3834 | #endif /* !READLINE */ | - | ||||||||||||||||||
3835 | - | |||||||||||||||||||
3836 | /* **************************************************************** */ | - | ||||||||||||||||||
3837 | /* */ | - | ||||||||||||||||||
3838 | /* Let input come from STRING. STRING is zero terminated. */ | - | ||||||||||||||||||
3839 | /* */ | - | ||||||||||||||||||
3840 | /* **************************************************************** */ | - | ||||||||||||||||||
3841 | - | |||||||||||||||||||
3842 | static int | - | ||||||||||||||||||
3843 | yy_string_get () | - | ||||||||||||||||||
3844 | { | - | ||||||||||||||||||
3845 | register char *string; | - | ||||||||||||||||||
3846 | register unsigned char c; | - | ||||||||||||||||||
3847 | - | |||||||||||||||||||
3848 | string = bash_input.location.string; | - | ||||||||||||||||||
3849 | - | |||||||||||||||||||
3850 | /* If the string doesn't exist, or is empty, EOF found. */ | - | ||||||||||||||||||
3851 | if (string && *string) | - | ||||||||||||||||||
3852 | { | - | ||||||||||||||||||
3853 | c = *string++; | - | ||||||||||||||||||
3854 | bash_input.location.string = string; | - | ||||||||||||||||||
3855 | return (c); | - | ||||||||||||||||||
3856 | } | - | ||||||||||||||||||
3857 | else | - | ||||||||||||||||||
3858 | return (EOF); | - | ||||||||||||||||||
3859 | } | - | ||||||||||||||||||
3860 | - | |||||||||||||||||||
3861 | static int | - | ||||||||||||||||||
3862 | yy_string_unget (c) | - | ||||||||||||||||||
3863 | int c; | - | ||||||||||||||||||
3864 | { | - | ||||||||||||||||||
3865 | *(--bash_input.location.string) = c; | - | ||||||||||||||||||
3866 | return (c); | - | ||||||||||||||||||
3867 | } | - | ||||||||||||||||||
3868 | - | |||||||||||||||||||
3869 | void | - | ||||||||||||||||||
3870 | with_input_from_string (string, name) | - | ||||||||||||||||||
3871 | char *string; | - | ||||||||||||||||||
3872 | const char *name; | - | ||||||||||||||||||
3873 | { | - | ||||||||||||||||||
3874 | INPUT_STREAM location; | - | ||||||||||||||||||
3875 | - | |||||||||||||||||||
3876 | location.string = string; | - | ||||||||||||||||||
3877 | init_yy_io (yy_string_get, yy_string_unget, st_string, name, location); | - | ||||||||||||||||||
3878 | } | - | ||||||||||||||||||
3879 | - | |||||||||||||||||||
3880 | /* Count the number of characters we've consumed from bash_input.location.string | - | ||||||||||||||||||
3881 | and read into shell_input_line, but have not returned from shell_getc. | - | ||||||||||||||||||
3882 | That is the true input location. Rewind bash_input.location.string by | - | ||||||||||||||||||
3883 | that number of characters, so it points to the last character actually | - | ||||||||||||||||||
3884 | consumed by the parser. */ | - | ||||||||||||||||||
3885 | static void | - | ||||||||||||||||||
3886 | rewind_input_string () | - | ||||||||||||||||||
3887 | { | - | ||||||||||||||||||
3888 | int xchars; | - | ||||||||||||||||||
3889 | - | |||||||||||||||||||
3890 | /* number of unconsumed characters in the input -- XXX need to take newlines | - | ||||||||||||||||||
3891 | into account, e.g., $(...\n) */ | - | ||||||||||||||||||
3892 | xchars = shell_input_line_len - shell_input_line_index; | - | ||||||||||||||||||
3893 | if (bash_input.location.string[-1] == '\n') | - | ||||||||||||||||||
3894 | xchars++; | - | ||||||||||||||||||
3895 | - | |||||||||||||||||||
3896 | /* XXX - how to reflect bash_input.location.string back to string passed to | - | ||||||||||||||||||
3897 | parse_and_execute or xparse_dolparen? xparse_dolparen needs to know how | - | ||||||||||||||||||
3898 | far into the string we parsed. parse_and_execute knows where bash_input. | - | ||||||||||||||||||
3899 | location.string is, and how far from orig_string that is -- that's the | - | ||||||||||||||||||
3900 | number of characters the command consumed. */ | - | ||||||||||||||||||
3901 | - | |||||||||||||||||||
3902 | /* bash_input.location.string - xchars should be where we parsed to */ | - | ||||||||||||||||||
3903 | /* need to do more validation on xchars value for sanity -- test cases. */ | - | ||||||||||||||||||
3904 | bash_input.location.string -= xchars; | - | ||||||||||||||||||
3905 | } | - | ||||||||||||||||||
3906 | - | |||||||||||||||||||
3907 | /* **************************************************************** */ | - | ||||||||||||||||||
3908 | /* */ | - | ||||||||||||||||||
3909 | /* Let input come from STREAM. */ | - | ||||||||||||||||||
3910 | /* */ | - | ||||||||||||||||||
3911 | /* **************************************************************** */ | - | ||||||||||||||||||
3912 | - | |||||||||||||||||||
3913 | /* These two functions used to test the value of the HAVE_RESTARTABLE_SYSCALLS | - | ||||||||||||||||||
3914 | define, and just use getc/ungetc if it was defined, but since bash | - | ||||||||||||||||||
3915 | installs its signal handlers without the SA_RESTART flag, some signals | - | ||||||||||||||||||
3916 | (like SIGCHLD, SIGWINCH, etc.) received during a read(2) will not cause | - | ||||||||||||||||||
3917 | the read to be restarted. We need to restart it ourselves. */ | - | ||||||||||||||||||
3918 | - | |||||||||||||||||||
3919 | static int | - | ||||||||||||||||||
3920 | yy_stream_get () | - | ||||||||||||||||||
3921 | { | - | ||||||||||||||||||
3922 | int result; | - | ||||||||||||||||||
3923 | - | |||||||||||||||||||
3924 | result = EOF; | - | ||||||||||||||||||
3925 | if (bash_input.location.file) | - | ||||||||||||||||||
3926 | { | - | ||||||||||||||||||
3927 | /* XXX - don't need terminate_immediately; getc_with_restart checks | - | ||||||||||||||||||
3928 | for terminating signals itself if read returns < 0 */ | - | ||||||||||||||||||
3929 | result = getc_with_restart (bash_input.location.file); | - | ||||||||||||||||||
3930 | } | - | ||||||||||||||||||
3931 | return (result); | - | ||||||||||||||||||
3932 | } | - | ||||||||||||||||||
3933 | - | |||||||||||||||||||
3934 | static int | - | ||||||||||||||||||
3935 | yy_stream_unget (c) | - | ||||||||||||||||||
3936 | int c; | - | ||||||||||||||||||
3937 | { | - | ||||||||||||||||||
3938 | return (ungetc_with_restart (c, bash_input.location.file)); | - | ||||||||||||||||||
3939 | } | - | ||||||||||||||||||
3940 | - | |||||||||||||||||||
3941 | void | - | ||||||||||||||||||
3942 | with_input_from_stream (stream, name) | - | ||||||||||||||||||
3943 | FILE *stream; | - | ||||||||||||||||||
3944 | const char *name; | - | ||||||||||||||||||
3945 | { | - | ||||||||||||||||||
3946 | INPUT_STREAM location; | - | ||||||||||||||||||
3947 | - | |||||||||||||||||||
3948 | location.file = stream; | - | ||||||||||||||||||
3949 | init_yy_io (yy_stream_get, yy_stream_unget, st_stream, name, location); | - | ||||||||||||||||||
3950 | } | - | ||||||||||||||||||
3951 | - | |||||||||||||||||||
3952 | typedef struct stream_saver { | - | ||||||||||||||||||
3953 | struct stream_saver *next; | - | ||||||||||||||||||
3954 | BASH_INPUT bash_input; | - | ||||||||||||||||||
3955 | int line; | - | ||||||||||||||||||
3956 | #if defined (BUFFERED_INPUT) | - | ||||||||||||||||||
3957 | BUFFERED_STREAM *bstream; | - | ||||||||||||||||||
3958 | #endif /* BUFFERED_INPUT */ | - | ||||||||||||||||||
3959 | } STREAM_SAVER; | - | ||||||||||||||||||
3960 | - | |||||||||||||||||||
3961 | /* The globally known line number. */ | - | ||||||||||||||||||
3962 | int line_number = 0; | - | ||||||||||||||||||
3963 | - | |||||||||||||||||||
3964 | /* The line number offset set by assigning to LINENO. Not currently used. */ | - | ||||||||||||||||||
3965 | int line_number_base = 0; | - | ||||||||||||||||||
3966 | - | |||||||||||||||||||
3967 | #if defined (COND_COMMAND) | - | ||||||||||||||||||
3968 | static int cond_lineno; | - | ||||||||||||||||||
3969 | static int cond_token; | - | ||||||||||||||||||
3970 | #endif | - | ||||||||||||||||||
3971 | - | |||||||||||||||||||
3972 | STREAM_SAVER *stream_list = (STREAM_SAVER *)NULL; | - | ||||||||||||||||||
3973 | - | |||||||||||||||||||
3974 | void | - | ||||||||||||||||||
3975 | push_stream (reset_lineno) | - | ||||||||||||||||||
3976 | int reset_lineno; | - | ||||||||||||||||||
3977 | { | - | ||||||||||||||||||
3978 | STREAM_SAVER *saver = (STREAM_SAVER *)xmalloc (sizeof (STREAM_SAVER)); | - | ||||||||||||||||||
3979 | - | |||||||||||||||||||
3980 | xbcopy ((char *)&bash_input, (char *)&(saver->bash_input), sizeof (BASH_INPUT)); | - | ||||||||||||||||||
3981 | - | |||||||||||||||||||
3982 | #if defined (BUFFERED_INPUT) | - | ||||||||||||||||||
3983 | saver->bstream = (BUFFERED_STREAM *)NULL; | - | ||||||||||||||||||
3984 | /* If we have a buffered stream, clear out buffers[fd]. */ | - | ||||||||||||||||||
3985 | if (bash_input.type == st_bstream && bash_input.location.buffered_fd >= 0) | - | ||||||||||||||||||
3986 | saver->bstream = set_buffered_stream (bash_input.location.buffered_fd, | - | ||||||||||||||||||
3987 | (BUFFERED_STREAM *)NULL); | - | ||||||||||||||||||
3988 | #endif /* BUFFERED_INPUT */ | - | ||||||||||||||||||
3989 | - | |||||||||||||||||||
3990 | saver->line = line_number; | - | ||||||||||||||||||
3991 | bash_input.name = (char *)NULL; | - | ||||||||||||||||||
3992 | saver->next = stream_list; | - | ||||||||||||||||||
3993 | stream_list = saver; | - | ||||||||||||||||||
3994 | EOF_Reached = 0; | - | ||||||||||||||||||
3995 | if (reset_lineno) | - | ||||||||||||||||||
3996 | line_number = 0; | - | ||||||||||||||||||
3997 | } | - | ||||||||||||||||||
3998 | - | |||||||||||||||||||
3999 | void | - | ||||||||||||||||||
4000 | pop_stream () | - | ||||||||||||||||||
4001 | { | - | ||||||||||||||||||
4002 | if (!stream_list) | - | ||||||||||||||||||
4003 | EOF_Reached = 1; | - | ||||||||||||||||||
4004 | else | - | ||||||||||||||||||
4005 | { | - | ||||||||||||||||||
4006 | STREAM_SAVER *saver = stream_list; | - | ||||||||||||||||||
4007 | - | |||||||||||||||||||
4008 | EOF_Reached = 0; | - | ||||||||||||||||||
4009 | stream_list = stream_list->next; | - | ||||||||||||||||||
4010 | - | |||||||||||||||||||
4011 | init_yy_io (saver->bash_input.getter, | - | ||||||||||||||||||
4012 | saver->bash_input.ungetter, | - | ||||||||||||||||||
4013 | saver->bash_input.type, | - | ||||||||||||||||||
4014 | saver->bash_input.name, | - | ||||||||||||||||||
4015 | saver->bash_input.location); | - | ||||||||||||||||||
4016 | - | |||||||||||||||||||
4017 | #if defined (BUFFERED_INPUT) | - | ||||||||||||||||||
4018 | /* If we have a buffered stream, restore buffers[fd]. */ | - | ||||||||||||||||||
4019 | /* If the input file descriptor was changed while this was on the | - | ||||||||||||||||||
4020 | save stack, update the buffered fd to the new file descriptor and | - | ||||||||||||||||||
4021 | re-establish the buffer <-> bash_input fd correspondence. */ | - | ||||||||||||||||||
4022 | if (bash_input.type == st_bstream && bash_input.location.buffered_fd >= 0) | - | ||||||||||||||||||
4023 | { | - | ||||||||||||||||||
4024 | if (bash_input_fd_changed) | - | ||||||||||||||||||
4025 | { | - | ||||||||||||||||||
4026 | bash_input_fd_changed = 0; | - | ||||||||||||||||||
4027 | if (default_buffered_input >= 0) | - | ||||||||||||||||||
4028 | { | - | ||||||||||||||||||
4029 | bash_input.location.buffered_fd = default_buffered_input; | - | ||||||||||||||||||
4030 | saver->bstream->b_fd = default_buffered_input; | - | ||||||||||||||||||
4031 | SET_CLOSE_ON_EXEC (default_buffered_input); | - | ||||||||||||||||||
4032 | } | - | ||||||||||||||||||
4033 | } | - | ||||||||||||||||||
4034 | /* XXX could free buffered stream returned as result here. */ | - | ||||||||||||||||||
4035 | set_buffered_stream (bash_input.location.buffered_fd, saver->bstream); | - | ||||||||||||||||||
4036 | } | - | ||||||||||||||||||
4037 | #endif /* BUFFERED_INPUT */ | - | ||||||||||||||||||
4038 | - | |||||||||||||||||||
4039 | line_number = saver->line; | - | ||||||||||||||||||
4040 | - | |||||||||||||||||||
4041 | FREE (saver->bash_input.name); | - | ||||||||||||||||||
4042 | free (saver); | - | ||||||||||||||||||
4043 | } | - | ||||||||||||||||||
4044 | } | - | ||||||||||||||||||
4045 | - | |||||||||||||||||||
4046 | /* Return 1 if a stream of type TYPE is saved on the stack. */ | - | ||||||||||||||||||
4047 | int | - | ||||||||||||||||||
4048 | stream_on_stack (type) | - | ||||||||||||||||||
4049 | enum stream_type type; | - | ||||||||||||||||||
4050 | { | - | ||||||||||||||||||
4051 | register STREAM_SAVER *s; | - | ||||||||||||||||||
4052 | - | |||||||||||||||||||
4053 | for (s = stream_list; s; s = s->next) | - | ||||||||||||||||||
4054 | if (s->bash_input.type == type) | - | ||||||||||||||||||
4055 | return 1; | - | ||||||||||||||||||
4056 | return 0; | - | ||||||||||||||||||
4057 | } | - | ||||||||||||||||||
4058 | - | |||||||||||||||||||
4059 | /* Save the current token state and return it in a malloced array. */ | - | ||||||||||||||||||
4060 | int * | - | ||||||||||||||||||
4061 | save_token_state () | - | ||||||||||||||||||
4062 | { | - | ||||||||||||||||||
4063 | int *ret; | - | ||||||||||||||||||
4064 | - | |||||||||||||||||||
4065 | ret = (int *)xmalloc (4 * sizeof (int)); | - | ||||||||||||||||||
4066 | ret[0] = last_read_token; | - | ||||||||||||||||||
4067 | ret[1] = token_before_that; | - | ||||||||||||||||||
4068 | ret[2] = two_tokens_ago; | - | ||||||||||||||||||
4069 | ret[3] = current_token; | - | ||||||||||||||||||
4070 | return ret; | - | ||||||||||||||||||
4071 | } | - | ||||||||||||||||||
4072 | - | |||||||||||||||||||
4073 | void | - | ||||||||||||||||||
4074 | restore_token_state (ts) | - | ||||||||||||||||||
4075 | int *ts; | - | ||||||||||||||||||
4076 | { | - | ||||||||||||||||||
4077 | if (ts == 0) | - | ||||||||||||||||||
4078 | return; | - | ||||||||||||||||||
4079 | last_read_token = ts[0]; | - | ||||||||||||||||||
4080 | token_before_that = ts[1]; | - | ||||||||||||||||||
4081 | two_tokens_ago = ts[2]; | - | ||||||||||||||||||
4082 | current_token = ts[3]; | - | ||||||||||||||||||
4083 | } | - | ||||||||||||||||||
4084 | - | |||||||||||||||||||
4085 | /* | - | ||||||||||||||||||
4086 | * This is used to inhibit alias expansion and reserved word recognition | - | ||||||||||||||||||
4087 | * inside case statement pattern lists. A `case statement pattern list' is: | - | ||||||||||||||||||
4088 | * | - | ||||||||||||||||||
4089 | * everything between the `in' in a `case word in' and the next ')' | - | ||||||||||||||||||
4090 | * or `esac' | - | ||||||||||||||||||
4091 | * everything between a `;;' and the next `)' or `esac' | - | ||||||||||||||||||
4092 | */ | - | ||||||||||||||||||
4093 | - | |||||||||||||||||||
4094 | #if defined (ALIAS) || defined (DPAREN_ARITHMETIC) | - | ||||||||||||||||||
4095 | - | |||||||||||||||||||
4096 | #define END_OF_ALIAS 0 | - | ||||||||||||||||||
4097 | - | |||||||||||||||||||
4098 | /* | - | ||||||||||||||||||
4099 | * Pseudo-global variables used in implementing token-wise alias expansion. | - | ||||||||||||||||||
4100 | */ | - | ||||||||||||||||||
4101 | - | |||||||||||||||||||
4102 | /* | - | ||||||||||||||||||
4103 | * Pushing and popping strings. This works together with shell_getc to | - | ||||||||||||||||||
4104 | * implement alias expansion on a per-token basis. | - | ||||||||||||||||||
4105 | */ | - | ||||||||||||||||||
4106 | - | |||||||||||||||||||
4107 | #define PSH_ALIAS 0x01 | - | ||||||||||||||||||
4108 | #define PSH_DPAREN 0x02 | - | ||||||||||||||||||
4109 | #define PSH_SOURCE 0x04 | - | ||||||||||||||||||
4110 | - | |||||||||||||||||||
4111 | typedef struct string_saver { | - | ||||||||||||||||||
4112 | struct string_saver *next; | - | ||||||||||||||||||
4113 | int expand_alias; /* Value to set expand_alias to when string is popped. */ | - | ||||||||||||||||||
4114 | char *saved_line; | - | ||||||||||||||||||
4115 | #if defined (ALIAS) | - | ||||||||||||||||||
4116 | alias_t *expander; /* alias that caused this line to be pushed. */ | - | ||||||||||||||||||
4117 | #endif | - | ||||||||||||||||||
4118 | size_t saved_line_size, saved_line_index; | - | ||||||||||||||||||
4119 | int saved_line_terminator; | - | ||||||||||||||||||
4120 | int flags; | - | ||||||||||||||||||
4121 | } STRING_SAVER; | - | ||||||||||||||||||
4122 | - | |||||||||||||||||||
4123 | STRING_SAVER *pushed_string_list = (STRING_SAVER *)NULL; | - | ||||||||||||||||||
4124 | - | |||||||||||||||||||
4125 | /* | - | ||||||||||||||||||
4126 | * Push the current shell_input_line onto a stack of such lines and make S | - | ||||||||||||||||||
4127 | * the current input. Used when expanding aliases. EXPAND is used to set | - | ||||||||||||||||||
4128 | * the value of expand_next_token when the string is popped, so that the | - | ||||||||||||||||||
4129 | * word after the alias in the original line is handled correctly when the | - | ||||||||||||||||||
4130 | * alias expands to multiple words. TOKEN is the token that was expanded | - | ||||||||||||||||||
4131 | * into S; it is saved and used to prevent infinite recursive expansion. | - | ||||||||||||||||||
4132 | */ | - | ||||||||||||||||||
4133 | static void | - | ||||||||||||||||||
4134 | push_string (s, expand, ap) | - | ||||||||||||||||||
4135 | char *s; | - | ||||||||||||||||||
4136 | int expand; | - | ||||||||||||||||||
4137 | alias_t *ap; | - | ||||||||||||||||||
4138 | { | - | ||||||||||||||||||
4139 | STRING_SAVER *temp = (STRING_SAVER *)xmalloc (sizeof (STRING_SAVER)); | - | ||||||||||||||||||
4140 | - | |||||||||||||||||||
4141 | temp->expand_alias = expand; | - | ||||||||||||||||||
4142 | temp->saved_line = shell_input_line; | - | ||||||||||||||||||
4143 | temp->saved_line_size = shell_input_line_size; | - | ||||||||||||||||||
4144 | temp->saved_line_index = shell_input_line_index; | - | ||||||||||||||||||
4145 | temp->saved_line_terminator = shell_input_line_terminator; | - | ||||||||||||||||||
4146 | temp->flags = 0; | - | ||||||||||||||||||
4147 | #if defined (ALIAS) | - | ||||||||||||||||||
4148 | temp->expander = ap; | - | ||||||||||||||||||
4149 | if (ap) | - | ||||||||||||||||||
4150 | temp->flags = PSH_ALIAS; | - | ||||||||||||||||||
4151 | #endif | - | ||||||||||||||||||
4152 | temp->next = pushed_string_list; | - | ||||||||||||||||||
4153 | pushed_string_list = temp; | - | ||||||||||||||||||
4154 | - | |||||||||||||||||||
4155 | #if defined (ALIAS) | - | ||||||||||||||||||
4156 | if (ap) | - | ||||||||||||||||||
4157 | ap->flags |= AL_BEINGEXPANDED; | - | ||||||||||||||||||
4158 | #endif | - | ||||||||||||||||||
4159 | - | |||||||||||||||||||
4160 | shell_input_line = s; | - | ||||||||||||||||||
4161 | shell_input_line_size = STRLEN (s); | - | ||||||||||||||||||
4162 | shell_input_line_index = 0; | - | ||||||||||||||||||
4163 | shell_input_line_terminator = '\0'; | - | ||||||||||||||||||
4164 | #if 0 | - | ||||||||||||||||||
4165 | parser_state &= ~PST_ALEXPNEXT; /* XXX */ | - | ||||||||||||||||||
4166 | #endif | - | ||||||||||||||||||
4167 | - | |||||||||||||||||||
4168 | set_line_mbstate (); | - | ||||||||||||||||||
4169 | } | - | ||||||||||||||||||
4170 | - | |||||||||||||||||||
4171 | /* | - | ||||||||||||||||||
4172 | * Make the top of the pushed_string stack be the current shell input. | - | ||||||||||||||||||
4173 | * Only called when there is something on the stack. Called from shell_getc | - | ||||||||||||||||||
4174 | * when it thinks it has consumed the string generated by an alias expansion | - | ||||||||||||||||||
4175 | * and needs to return to the original input line. | - | ||||||||||||||||||
4176 | */ | - | ||||||||||||||||||
4177 | static void | - | ||||||||||||||||||
4178 | pop_string () | - | ||||||||||||||||||
4179 | { | - | ||||||||||||||||||
4180 | STRING_SAVER *t; | - | ||||||||||||||||||
4181 | - | |||||||||||||||||||
4182 | FREE (shell_input_line); | - | ||||||||||||||||||
4183 | shell_input_line = pushed_string_list->saved_line; | - | ||||||||||||||||||
4184 | shell_input_line_index = pushed_string_list->saved_line_index; | - | ||||||||||||||||||
4185 | shell_input_line_size = pushed_string_list->saved_line_size; | - | ||||||||||||||||||
4186 | shell_input_line_terminator = pushed_string_list->saved_line_terminator; | - | ||||||||||||||||||
4187 | - | |||||||||||||||||||
4188 | if (pushed_string_list->expand_alias) | - | ||||||||||||||||||
4189 | parser_state |= PST_ALEXPNEXT; | - | ||||||||||||||||||
4190 | else | - | ||||||||||||||||||
4191 | parser_state &= ~PST_ALEXPNEXT; | - | ||||||||||||||||||
4192 | - | |||||||||||||||||||
4193 | t = pushed_string_list; | - | ||||||||||||||||||
4194 | pushed_string_list = pushed_string_list->next; | - | ||||||||||||||||||
4195 | - | |||||||||||||||||||
4196 | #if defined (ALIAS) | - | ||||||||||||||||||
4197 | if (t->expander) | - | ||||||||||||||||||
4198 | t->expander->flags &= ~AL_BEINGEXPANDED; | - | ||||||||||||||||||
4199 | #endif | - | ||||||||||||||||||
4200 | - | |||||||||||||||||||
4201 | free ((char *)t); | - | ||||||||||||||||||
4202 | - | |||||||||||||||||||
4203 | set_line_mbstate (); | - | ||||||||||||||||||
4204 | } | - | ||||||||||||||||||
4205 | - | |||||||||||||||||||
4206 | static void | - | ||||||||||||||||||
4207 | free_string_list () | - | ||||||||||||||||||
4208 | { | - | ||||||||||||||||||
4209 | register STRING_SAVER *t, *t1; | - | ||||||||||||||||||
4210 | - | |||||||||||||||||||
4211 | for (t = pushed_string_list; t; ) | - | ||||||||||||||||||
4212 | { | - | ||||||||||||||||||
4213 | t1 = t->next; | - | ||||||||||||||||||
4214 | FREE (t->saved_line); | - | ||||||||||||||||||
4215 | #if defined (ALIAS) | - | ||||||||||||||||||
4216 | if (t->expander) | - | ||||||||||||||||||
4217 | t->expander->flags &= ~AL_BEINGEXPANDED; | - | ||||||||||||||||||
4218 | #endif | - | ||||||||||||||||||
4219 | free ((char *)t); | - | ||||||||||||||||||
4220 | t = t1; | - | ||||||||||||||||||
4221 | } | - | ||||||||||||||||||
4222 | pushed_string_list = (STRING_SAVER *)NULL; | - | ||||||||||||||||||
4223 | } | - | ||||||||||||||||||
4224 | - | |||||||||||||||||||
4225 | #endif /* ALIAS || DPAREN_ARITHMETIC */ | - | ||||||||||||||||||
4226 | - | |||||||||||||||||||
4227 | void | - | ||||||||||||||||||
4228 | free_pushed_string_input () | - | ||||||||||||||||||
4229 | { | - | ||||||||||||||||||
4230 | #if defined (ALIAS) || defined (DPAREN_ARITHMETIC) | - | ||||||||||||||||||
4231 | free_string_list (); | - | ||||||||||||||||||
4232 | #endif | - | ||||||||||||||||||
4233 | } | - | ||||||||||||||||||
4234 | - | |||||||||||||||||||
4235 | int | - | ||||||||||||||||||
4236 | parser_expanding_alias () | - | ||||||||||||||||||
4237 | { | - | ||||||||||||||||||
4238 | return (expanding_alias ()); | - | ||||||||||||||||||
4239 | } | - | ||||||||||||||||||
4240 | - | |||||||||||||||||||
4241 | void | - | ||||||||||||||||||
4242 | parser_save_alias () | - | ||||||||||||||||||
4243 | { | - | ||||||||||||||||||
4244 | #if defined (ALIAS) || defined (DPAREN_ARITHMETIC) | - | ||||||||||||||||||
4245 | push_string ((char *)NULL, 0, (alias_t *)NULL); | - | ||||||||||||||||||
4246 | pushed_string_list->flags = PSH_SOURCE; /* XXX - for now */ | - | ||||||||||||||||||
4247 | #else | - | ||||||||||||||||||
4248 | ; | - | ||||||||||||||||||
4249 | #endif | - | ||||||||||||||||||
4250 | } | - | ||||||||||||||||||
4251 | - | |||||||||||||||||||
4252 | void | - | ||||||||||||||||||
4253 | parser_restore_alias () | - | ||||||||||||||||||
4254 | { | - | ||||||||||||||||||
4255 | #if defined (ALIAS) || defined (DPAREN_ARITHMETIC) | - | ||||||||||||||||||
4256 | if (pushed_string_list) | - | ||||||||||||||||||
4257 | pop_string (); | - | ||||||||||||||||||
4258 | #else | - | ||||||||||||||||||
4259 | ; | - | ||||||||||||||||||
4260 | #endif | - | ||||||||||||||||||
4261 | } | - | ||||||||||||||||||
4262 | - | |||||||||||||||||||
4263 | #if defined (ALIAS) | - | ||||||||||||||||||
4264 | /* Before freeing AP, make sure that there aren't any cases of pointer | - | ||||||||||||||||||
4265 | aliasing that could cause us to reference freed memory later on. */ | - | ||||||||||||||||||
4266 | void | - | ||||||||||||||||||
4267 | clear_string_list_expander (ap) | - | ||||||||||||||||||
4268 | alias_t *ap; | - | ||||||||||||||||||
4269 | { | - | ||||||||||||||||||
4270 | register STRING_SAVER *t; | - | ||||||||||||||||||
4271 | - | |||||||||||||||||||
4272 | for (t = pushed_string_list; t; t = t->next) | - | ||||||||||||||||||
4273 | { | - | ||||||||||||||||||
4274 | if (t->expander && t->expander == ap) | - | ||||||||||||||||||
4275 | t->expander = 0; | - | ||||||||||||||||||
4276 | } | - | ||||||||||||||||||
4277 | } | - | ||||||||||||||||||
4278 | #endif | - | ||||||||||||||||||
4279 | - | |||||||||||||||||||
4280 | void | - | ||||||||||||||||||
4281 | clear_shell_input_line () | - | ||||||||||||||||||
4282 | { | - | ||||||||||||||||||
4283 | if (shell_input_line) | - | ||||||||||||||||||
4284 | shell_input_line[shell_input_line_index = 0] = '\0'; | - | ||||||||||||||||||
4285 | } | - | ||||||||||||||||||
4286 | - | |||||||||||||||||||
4287 | /* Return a line of text, taken from wherever yylex () reads input. | - | ||||||||||||||||||
4288 | If there is no more input, then we return NULL. If REMOVE_QUOTED_NEWLINE | - | ||||||||||||||||||
4289 | is non-zero, we remove unquoted \<newline> pairs. This is used by | - | ||||||||||||||||||
4290 | read_secondary_line to read here documents. */ | - | ||||||||||||||||||
4291 | static char * | - | ||||||||||||||||||
4292 | read_a_line (remove_quoted_newline) | - | ||||||||||||||||||
4293 | int remove_quoted_newline; | - | ||||||||||||||||||
4294 | { | - | ||||||||||||||||||
4295 | static char *line_buffer = (char *)NULL; | - | ||||||||||||||||||
4296 | static int buffer_size = 0; | - | ||||||||||||||||||
4297 | int indx, c, peekc, pass_next; | - | ||||||||||||||||||
4298 | - | |||||||||||||||||||
4299 | #if defined (READLINE) | - | ||||||||||||||||||
4300 | if (no_line_editing && SHOULD_PROMPT ()) | - | ||||||||||||||||||
4301 | #else | - | ||||||||||||||||||
4302 | if (SHOULD_PROMPT ()) | - | ||||||||||||||||||
4303 | #endif | - | ||||||||||||||||||
4304 | print_prompt (); | - | ||||||||||||||||||
4305 | - | |||||||||||||||||||
4306 | pass_next = indx = 0; | - | ||||||||||||||||||
4307 | while (1) | - | ||||||||||||||||||
4308 | { | - | ||||||||||||||||||
4309 | /* Allow immediate exit if interrupted during input. */ | - | ||||||||||||||||||
4310 | QUIT; | - | ||||||||||||||||||
4311 | - | |||||||||||||||||||
4312 | c = yy_getc (); | - | ||||||||||||||||||
4313 | - | |||||||||||||||||||
4314 | /* Ignore null bytes in input. */ | - | ||||||||||||||||||
4315 | if (c == 0) | - | ||||||||||||||||||
4316 | { | - | ||||||||||||||||||
4317 | #if 0 | - | ||||||||||||||||||
4318 | internal_warning ("read_a_line: ignored null byte in input"); | - | ||||||||||||||||||
4319 | #endif | - | ||||||||||||||||||
4320 | continue; | - | ||||||||||||||||||
4321 | } | - | ||||||||||||||||||
4322 | - | |||||||||||||||||||
4323 | /* If there is no more input, then we return NULL. */ | - | ||||||||||||||||||
4324 | if (c == EOF) | - | ||||||||||||||||||
4325 | { | - | ||||||||||||||||||
4326 | if (interactive && bash_input.type == st_stream) | - | ||||||||||||||||||
4327 | clearerr (stdin); | - | ||||||||||||||||||
4328 | if (indx == 0) | - | ||||||||||||||||||
4329 | return ((char *)NULL); | - | ||||||||||||||||||
4330 | c = '\n'; | - | ||||||||||||||||||
4331 | } | - | ||||||||||||||||||
4332 | - | |||||||||||||||||||
4333 | /* `+2' in case the final character in the buffer is a newline. */ | - | ||||||||||||||||||
4334 | RESIZE_MALLOCED_BUFFER (line_buffer, indx, 2, buffer_size, 128); | - | ||||||||||||||||||
4335 | - | |||||||||||||||||||
4336 | /* IF REMOVE_QUOTED_NEWLINES is non-zero, we are reading a | - | ||||||||||||||||||
4337 | here document with an unquoted delimiter. In this case, | - | ||||||||||||||||||
4338 | the line will be expanded as if it were in double quotes. | - | ||||||||||||||||||
4339 | We allow a backslash to escape the next character, but we | - | ||||||||||||||||||
4340 | need to treat the backslash specially only if a backslash | - | ||||||||||||||||||
4341 | quoting a backslash-newline pair appears in the line. */ | - | ||||||||||||||||||
4342 | if (pass_next) | - | ||||||||||||||||||
4343 | { | - | ||||||||||||||||||
4344 | line_buffer[indx++] = c; | - | ||||||||||||||||||
4345 | pass_next = 0; | - | ||||||||||||||||||
4346 | } | - | ||||||||||||||||||
4347 | else if (c == '\\' && remove_quoted_newline) | - | ||||||||||||||||||
4348 | { | - | ||||||||||||||||||
4349 | QUIT; | - | ||||||||||||||||||
4350 | peekc = yy_getc (); | - | ||||||||||||||||||
4351 | if (peekc == '\n') | - | ||||||||||||||||||
4352 | { | - | ||||||||||||||||||
4353 | line_number++; | - | ||||||||||||||||||
4354 | continue; /* Make the unquoted \<newline> pair disappear. */ | - | ||||||||||||||||||
4355 | } | - | ||||||||||||||||||
4356 | else | - | ||||||||||||||||||
4357 | { | - | ||||||||||||||||||
4358 | yy_ungetc (peekc); | - | ||||||||||||||||||
4359 | pass_next = 1; | - | ||||||||||||||||||
4360 | line_buffer[indx++] = c; /* Preserve the backslash. */ | - | ||||||||||||||||||
4361 | } | - | ||||||||||||||||||
4362 | } | - | ||||||||||||||||||
4363 | else | - | ||||||||||||||||||
4364 | line_buffer[indx++] = c; | - | ||||||||||||||||||
4365 | - | |||||||||||||||||||
4366 | if (c == '\n') | - | ||||||||||||||||||
4367 | { | - | ||||||||||||||||||
4368 | line_buffer[indx] = '\0'; | - | ||||||||||||||||||
4369 | return (line_buffer); | - | ||||||||||||||||||
4370 | } | - | ||||||||||||||||||
4371 | } | - | ||||||||||||||||||
4372 | } | - | ||||||||||||||||||
4373 | - | |||||||||||||||||||
4374 | /* Return a line as in read_a_line (), but insure that the prompt is | - | ||||||||||||||||||
4375 | the secondary prompt. This is used to read the lines of a here | - | ||||||||||||||||||
4376 | document. REMOVE_QUOTED_NEWLINE is non-zero if we should remove | - | ||||||||||||||||||
4377 | newlines quoted with backslashes while reading the line. It is | - | ||||||||||||||||||
4378 | non-zero unless the delimiter of the here document was quoted. */ | - | ||||||||||||||||||
4379 | char * | - | ||||||||||||||||||
4380 | read_secondary_line (remove_quoted_newline) | - | ||||||||||||||||||
4381 | int remove_quoted_newline; | - | ||||||||||||||||||
4382 | { | - | ||||||||||||||||||
4383 | char *ret; | - | ||||||||||||||||||
4384 | int n, c; | - | ||||||||||||||||||
4385 | - | |||||||||||||||||||
4386 | prompt_string_pointer = &ps2_prompt; | - | ||||||||||||||||||
4387 | if (SHOULD_PROMPT()) | - | ||||||||||||||||||
4388 | prompt_again (); | - | ||||||||||||||||||
4389 | ret = read_a_line (remove_quoted_newline); | - | ||||||||||||||||||
4390 | #if defined (HISTORY) | - | ||||||||||||||||||
4391 | if (ret && remember_on_history && (parser_state & PST_HEREDOC)) | - | ||||||||||||||||||
4392 | { | - | ||||||||||||||||||
4393 | /* To make adding the here-document body right, we need to rely on | - | ||||||||||||||||||
4394 | history_delimiting_chars() returning \n for the first line of the | - | ||||||||||||||||||
4395 | here-document body and the null string for the second and subsequent | - | ||||||||||||||||||
4396 | lines, so we avoid double newlines. | - | ||||||||||||||||||
4397 | current_command_line_count == 2 for the first line of the body. */ | - | ||||||||||||||||||
4398 | - | |||||||||||||||||||
4399 | current_command_line_count++; | - | ||||||||||||||||||
4400 | maybe_add_history (ret); | - | ||||||||||||||||||
4401 | } | - | ||||||||||||||||||
4402 | #endif /* HISTORY */ | - | ||||||||||||||||||
4403 | return ret; | - | ||||||||||||||||||
4404 | } | - | ||||||||||||||||||
4405 | - | |||||||||||||||||||
4406 | /* **************************************************************** */ | - | ||||||||||||||||||
4407 | /* */ | - | ||||||||||||||||||
4408 | /* YYLEX () */ | - | ||||||||||||||||||
4409 | /* */ | - | ||||||||||||||||||
4410 | /* **************************************************************** */ | - | ||||||||||||||||||
4411 | - | |||||||||||||||||||
4412 | /* Reserved words. These are only recognized as the first word of a | - | ||||||||||||||||||
4413 | command. */ | - | ||||||||||||||||||
4414 | STRING_INT_ALIST word_token_alist[] = { | - | ||||||||||||||||||
4415 | { "if", IF }, | - | ||||||||||||||||||
4416 | { "then", THEN }, | - | ||||||||||||||||||
4417 | { "else", ELSE }, | - | ||||||||||||||||||
4418 | { "elif", ELIF }, | - | ||||||||||||||||||
4419 | { "fi", FI }, | - | ||||||||||||||||||
4420 | { "case", CASE }, | - | ||||||||||||||||||
4421 | { "esac", ESAC }, | - | ||||||||||||||||||
4422 | { "for", FOR }, | - | ||||||||||||||||||
4423 | #if defined (SELECT_COMMAND) | - | ||||||||||||||||||
4424 | { "select", SELECT }, | - | ||||||||||||||||||
4425 | #endif | - | ||||||||||||||||||
4426 | { "while", WHILE }, | - | ||||||||||||||||||
4427 | { "until", UNTIL }, | - | ||||||||||||||||||
4428 | { "do", DO }, | - | ||||||||||||||||||
4429 | { "done", DONE }, | - | ||||||||||||||||||
4430 | { "in", IN }, | - | ||||||||||||||||||
4431 | { "function", FUNCTION }, | - | ||||||||||||||||||
4432 | #if defined (COMMAND_TIMING) | - | ||||||||||||||||||
4433 | { "time", TIME }, | - | ||||||||||||||||||
4434 | #endif | - | ||||||||||||||||||
4435 | { "{", '{' }, | - | ||||||||||||||||||
4436 | { "}", '}' }, | - | ||||||||||||||||||
4437 | { "!", BANG }, | - | ||||||||||||||||||
4438 | #if defined (COND_COMMAND) | - | ||||||||||||||||||
4439 | { "[[", COND_START }, | - | ||||||||||||||||||
4440 | { "]]", COND_END }, | - | ||||||||||||||||||
4441 | #endif | - | ||||||||||||||||||
4442 | #if defined (COPROCESS_SUPPORT) | - | ||||||||||||||||||
4443 | { "coproc", COPROC }, | - | ||||||||||||||||||
4444 | #endif | - | ||||||||||||||||||
4445 | { (char *)NULL, 0} | - | ||||||||||||||||||
4446 | }; | - | ||||||||||||||||||
4447 | - | |||||||||||||||||||
4448 | /* other tokens that can be returned by read_token() */ | - | ||||||||||||||||||
4449 | STRING_INT_ALIST other_token_alist[] = { | - | ||||||||||||||||||
4450 | /* Multiple-character tokens with special values */ | - | ||||||||||||||||||
4451 | { "--", TIMEIGN }, | - | ||||||||||||||||||
4452 | { "-p", TIMEOPT }, | - | ||||||||||||||||||
4453 | { "&&", AND_AND }, | - | ||||||||||||||||||
4454 | { "||", OR_OR }, | - | ||||||||||||||||||
4455 | { ">>", GREATER_GREATER }, | - | ||||||||||||||||||
4456 | { "<<", LESS_LESS }, | - | ||||||||||||||||||
4457 | { "<&", LESS_AND }, | - | ||||||||||||||||||
4458 | { ">&", GREATER_AND }, | - | ||||||||||||||||||
4459 | { ";;", SEMI_SEMI }, | - | ||||||||||||||||||
4460 | { ";&", SEMI_AND }, | - | ||||||||||||||||||
4461 | { ";;&", SEMI_SEMI_AND }, | - | ||||||||||||||||||
4462 | { "<<-", LESS_LESS_MINUS }, | - | ||||||||||||||||||
4463 | { "<<<", LESS_LESS_LESS }, | - | ||||||||||||||||||
4464 | { "&>", AND_GREATER }, | - | ||||||||||||||||||
4465 | { "&>>", AND_GREATER_GREATER }, | - | ||||||||||||||||||
4466 | { "<>", LESS_GREATER }, | - | ||||||||||||||||||
4467 | { ">|", GREATER_BAR }, | - | ||||||||||||||||||
4468 | { "|&", BAR_AND }, | - | ||||||||||||||||||
4469 | { "EOF", yacc_EOF }, | - | ||||||||||||||||||
4470 | /* Tokens whose value is the character itself */ | - | ||||||||||||||||||
4471 | { ">", '>' }, | - | ||||||||||||||||||
4472 | { "<", '<' }, | - | ||||||||||||||||||
4473 | { "-", '-' }, | - | ||||||||||||||||||
4474 | { "{", '{' }, | - | ||||||||||||||||||
4475 | { "}", '}' }, | - | ||||||||||||||||||
4476 | { ";", ';' }, | - | ||||||||||||||||||
4477 | { "(", '(' }, | - | ||||||||||||||||||
4478 | { ")", ')' }, | - | ||||||||||||||||||
4479 | { "|", '|' }, | - | ||||||||||||||||||
4480 | { "&", '&' }, | - | ||||||||||||||||||
4481 | { "newline", '\n' }, | - | ||||||||||||||||||
4482 | { (char *)NULL, 0} | - | ||||||||||||||||||
4483 | }; | - | ||||||||||||||||||
4484 | - | |||||||||||||||||||
4485 | /* others not listed here: | - | ||||||||||||||||||
4486 | WORD look at yylval.word | - | ||||||||||||||||||
4487 | ASSIGNMENT_WORD look at yylval.word | - | ||||||||||||||||||
4488 | NUMBER look at yylval.number | - | ||||||||||||||||||
4489 | ARITH_CMD look at yylval.word_list | - | ||||||||||||||||||
4490 | ARITH_FOR_EXPRS look at yylval.word_list | - | ||||||||||||||||||
4491 | COND_CMD look at yylval.command | - | ||||||||||||||||||
4492 | */ | - | ||||||||||||||||||
4493 | - | |||||||||||||||||||
4494 | /* These are used by read_token_word, but appear up here so that shell_getc | - | ||||||||||||||||||
4495 | can use them to decide when to add otherwise blank lines to the history. */ | - | ||||||||||||||||||
4496 | - | |||||||||||||||||||
4497 | /* The primary delimiter stack. */ | - | ||||||||||||||||||
4498 | struct dstack dstack = { (char *)NULL, 0, 0 }; | - | ||||||||||||||||||
4499 | - | |||||||||||||||||||
4500 | /* A temporary delimiter stack to be used when decoding prompt strings. | - | ||||||||||||||||||
4501 | This is needed because command substitutions in prompt strings (e.g., PS2) | - | ||||||||||||||||||
4502 | can screw up the parser's quoting state. */ | - | ||||||||||||||||||
4503 | static struct dstack temp_dstack = { (char *)NULL, 0, 0 }; | - | ||||||||||||||||||
4504 | - | |||||||||||||||||||
4505 | /* Macro for accessing the top delimiter on the stack. Returns the | - | ||||||||||||||||||
4506 | delimiter or zero if none. */ | - | ||||||||||||||||||
4507 | #define current_delimiter(ds) \ | - | ||||||||||||||||||
4508 | (ds.delimiter_depth ? ds.delimiters[ds.delimiter_depth - 1] : 0) | - | ||||||||||||||||||
4509 | - | |||||||||||||||||||
4510 | #define push_delimiter(ds, character) \ | - | ||||||||||||||||||
4511 | do \ | - | ||||||||||||||||||
4512 | { \ | - | ||||||||||||||||||
4513 | if (ds.delimiter_depth + 2 > ds.delimiter_space) \ | - | ||||||||||||||||||
4514 | ds.delimiters = (char *)xrealloc \ | - | ||||||||||||||||||
4515 | (ds.delimiters, (ds.delimiter_space += 10) * sizeof (char)); \ | - | ||||||||||||||||||
4516 | ds.delimiters[ds.delimiter_depth] = character; \ | - | ||||||||||||||||||
4517 | ds.delimiter_depth++; \ | - | ||||||||||||||||||
4518 | } \ | - | ||||||||||||||||||
4519 | while (0) | - | ||||||||||||||||||
4520 | - | |||||||||||||||||||
4521 | #define pop_delimiter(ds) ds.delimiter_depth-- | - | ||||||||||||||||||
4522 | - | |||||||||||||||||||
4523 | /* Return the next shell input character. This always reads characters | - | ||||||||||||||||||
4524 | from shell_input_line; when that line is exhausted, it is time to | - | ||||||||||||||||||
4525 | read the next line. This is called by read_token when the shell is | - | ||||||||||||||||||
4526 | processing normal command input. */ | - | ||||||||||||||||||
4527 | - | |||||||||||||||||||
4528 | /* This implements one-character lookahead/lookbehind across physical input | - | ||||||||||||||||||
4529 | lines, to avoid something being lost because it's pushed back with | - | ||||||||||||||||||
4530 | shell_ungetc when we're at the start of a line. */ | - | ||||||||||||||||||
4531 | static int eol_ungetc_lookahead = 0; | - | ||||||||||||||||||
4532 | - | |||||||||||||||||||
4533 | static int | - | ||||||||||||||||||
4534 | shell_getc (remove_quoted_newline) | - | ||||||||||||||||||
4535 | int remove_quoted_newline; | - | ||||||||||||||||||
4536 | { | - | ||||||||||||||||||
4537 | register int i; | - | ||||||||||||||||||
4538 | int c, truncating, last_was_backslash; | - | ||||||||||||||||||
4539 | unsigned char uc; | - | ||||||||||||||||||
4540 | - | |||||||||||||||||||
4541 | QUIT; | - | ||||||||||||||||||
4542 | - | |||||||||||||||||||
4543 | last_was_backslash = 0; | - | ||||||||||||||||||
4544 | if (sigwinch_received) | - | ||||||||||||||||||
4545 | { | - | ||||||||||||||||||
4546 | sigwinch_received = 0; | - | ||||||||||||||||||
4547 | get_new_window_size (0, (int *)0, (int *)0); | - | ||||||||||||||||||
4548 | } | - | ||||||||||||||||||
4549 | - | |||||||||||||||||||
4550 | if (eol_ungetc_lookahead) | - | ||||||||||||||||||
4551 | { | - | ||||||||||||||||||
4552 | c = eol_ungetc_lookahead; | - | ||||||||||||||||||
4553 | eol_ungetc_lookahead = 0; | - | ||||||||||||||||||
4554 | return (c); | - | ||||||||||||||||||
4555 | } | - | ||||||||||||||||||
4556 | - | |||||||||||||||||||
4557 | #if defined (ALIAS) || defined (DPAREN_ARITHMETIC) | - | ||||||||||||||||||
4558 | /* If shell_input_line[shell_input_line_index] == 0, but there is | - | ||||||||||||||||||
4559 | something on the pushed list of strings, then we don't want to go | - | ||||||||||||||||||
4560 | off and get another line. We let the code down below handle it. */ | - | ||||||||||||||||||
4561 | - | |||||||||||||||||||
4562 | if (!shell_input_line || ((!shell_input_line[shell_input_line_index]) && | - | ||||||||||||||||||
4563 | (pushed_string_list == (STRING_SAVER *)NULL))) | - | ||||||||||||||||||
4564 | #else /* !ALIAS && !DPAREN_ARITHMETIC */ | - | ||||||||||||||||||
4565 | if (!shell_input_line || !shell_input_line[shell_input_line_index]) | - | ||||||||||||||||||
4566 | #endif /* !ALIAS && !DPAREN_ARITHMETIC */ | - | ||||||||||||||||||
4567 | { | - | ||||||||||||||||||
4568 | line_number++; | - | ||||||||||||||||||
4569 | - | |||||||||||||||||||
4570 | /* Let's not let one really really long line blow up memory allocation */ | - | ||||||||||||||||||
4571 | if (shell_input_line && shell_input_line_size >= 32768) | - | ||||||||||||||||||
4572 | { | - | ||||||||||||||||||
4573 | free (shell_input_line); | - | ||||||||||||||||||
4574 | shell_input_line = 0; | - | ||||||||||||||||||
4575 | shell_input_line_size = 0; | - | ||||||||||||||||||
4576 | } | - | ||||||||||||||||||
4577 | - | |||||||||||||||||||
4578 | restart_read: | - | ||||||||||||||||||
4579 | - | |||||||||||||||||||
4580 | /* Allow immediate exit if interrupted during input. */ | - | ||||||||||||||||||
4581 | QUIT; | - | ||||||||||||||||||
4582 | - | |||||||||||||||||||
4583 | i = truncating = 0; | - | ||||||||||||||||||
4584 | shell_input_line_terminator = 0; | - | ||||||||||||||||||
4585 | - | |||||||||||||||||||
4586 | /* If the shell is interatctive, but not currently printing a prompt | - | ||||||||||||||||||
4587 | (interactive_shell && interactive == 0), we don't want to print | - | ||||||||||||||||||
4588 | notifies or cleanup the jobs -- we want to defer it until we do | - | ||||||||||||||||||
4589 | print the next prompt. */ | - | ||||||||||||||||||
4590 | if (interactive_shell == 0 || SHOULD_PROMPT()) | - | ||||||||||||||||||
4591 | { | - | ||||||||||||||||||
4592 | #if defined (JOB_CONTROL) | - | ||||||||||||||||||
4593 | /* This can cause a problem when reading a command as the result | - | ||||||||||||||||||
4594 | of a trap, when the trap is called from flush_child. This call | - | ||||||||||||||||||
4595 | had better not cause jobs to disappear from the job table in | - | ||||||||||||||||||
4596 | that case, or we will have big trouble. */ | - | ||||||||||||||||||
4597 | notify_and_cleanup (); | - | ||||||||||||||||||
4598 | #else /* !JOB_CONTROL */ | - | ||||||||||||||||||
4599 | cleanup_dead_jobs (); | - | ||||||||||||||||||
4600 | #endif /* !JOB_CONTROL */ | - | ||||||||||||||||||
4601 | } | - | ||||||||||||||||||
4602 | - | |||||||||||||||||||
4603 | #if defined (READLINE) | - | ||||||||||||||||||
4604 | if (no_line_editing && SHOULD_PROMPT()) | - | ||||||||||||||||||
4605 | #else | - | ||||||||||||||||||
4606 | if (SHOULD_PROMPT()) | - | ||||||||||||||||||
4607 | #endif | - | ||||||||||||||||||
4608 | print_prompt (); | - | ||||||||||||||||||
4609 | - | |||||||||||||||||||
4610 | if (bash_input.type == st_stream) | - | ||||||||||||||||||
4611 | clearerr (stdin); | - | ||||||||||||||||||
4612 | - | |||||||||||||||||||
4613 | while (1) | - | ||||||||||||||||||
4614 | { | - | ||||||||||||||||||
4615 | c = yy_getc (); | - | ||||||||||||||||||
4616 | - | |||||||||||||||||||
4617 | /* Allow immediate exit if interrupted during input. */ | - | ||||||||||||||||||
4618 | QUIT; | - | ||||||||||||||||||
4619 | - | |||||||||||||||||||
4620 | if (c == '\0') | - | ||||||||||||||||||
4621 | { | - | ||||||||||||||||||
4622 | #if 0 | - | ||||||||||||||||||
4623 | internal_warning ("shell_getc: ignored null byte in input"); | - | ||||||||||||||||||
4624 | #endif | - | ||||||||||||||||||
4625 | /* If we get EOS while parsing a string, treat it as EOF so we | - | ||||||||||||||||||
4626 | don't just keep looping. Happens very rarely */ | - | ||||||||||||||||||
4627 | if (bash_input.type == st_string) | - | ||||||||||||||||||
4628 | { | - | ||||||||||||||||||
4629 | if (i == 0) | - | ||||||||||||||||||
4630 | shell_input_line_terminator = EOF; | - | ||||||||||||||||||
4631 | shell_input_line[i] = '\0'; | - | ||||||||||||||||||
4632 | c = EOF; | - | ||||||||||||||||||
4633 | break; | - | ||||||||||||||||||
4634 | } | - | ||||||||||||||||||
4635 | continue; | - | ||||||||||||||||||
4636 | } | - | ||||||||||||||||||
4637 | - | |||||||||||||||||||
4638 | /* Theoretical overflow */ | - | ||||||||||||||||||
4639 | /* If we can't put 256 bytes more into the buffer, allocate | - | ||||||||||||||||||
4640 | everything we can and fill it as full as we can. */ | - | ||||||||||||||||||
4641 | /* XXX - we ignore rest of line using `truncating' flag */ | - | ||||||||||||||||||
4642 | if (shell_input_line_size > (SIZE_MAX - 256)) | - | ||||||||||||||||||
4643 | { | - | ||||||||||||||||||
4644 | size_t n; | - | ||||||||||||||||||
4645 | - | |||||||||||||||||||
4646 | n = SIZE_MAX - i; /* how much more can we put into the buffer? */ | - | ||||||||||||||||||
4647 | if (n <= 2) /* we have to save 1 for the newline added below */ | - | ||||||||||||||||||
4648 | { | - | ||||||||||||||||||
4649 | if (truncating == 0) | - | ||||||||||||||||||
4650 | internal_warning(_("shell_getc: shell_input_line_size (%zu) exceeds SIZE_MAX (%lu): line truncated"), shell_input_line_size, (unsigned long)SIZE_MAX); | - | ||||||||||||||||||
4651 | shell_input_line[i] = '\0'; | - | ||||||||||||||||||
4652 | truncating = 1; | - | ||||||||||||||||||
4653 | } | - | ||||||||||||||||||
4654 | if (shell_input_line_size < SIZE_MAX) | - | ||||||||||||||||||
4655 | { | - | ||||||||||||||||||
4656 | shell_input_line_size = SIZE_MAX; | - | ||||||||||||||||||
4657 | shell_input_line = xrealloc (shell_input_line, shell_input_line_size); | - | ||||||||||||||||||
4658 | } | - | ||||||||||||||||||
4659 | } | - | ||||||||||||||||||
4660 | else | - | ||||||||||||||||||
4661 | RESIZE_MALLOCED_BUFFER (shell_input_line, i, 2, shell_input_line_size, 256); | - | ||||||||||||||||||
4662 | - | |||||||||||||||||||
4663 | if (c == EOF) | - | ||||||||||||||||||
4664 | { | - | ||||||||||||||||||
4665 | if (bash_input.type == st_stream) | - | ||||||||||||||||||
4666 | clearerr (stdin); | - | ||||||||||||||||||
4667 | - | |||||||||||||||||||
4668 | if (i == 0) | - | ||||||||||||||||||
4669 | shell_input_line_terminator = EOF; | - | ||||||||||||||||||
4670 | - | |||||||||||||||||||
4671 | shell_input_line[i] = '\0'; | - | ||||||||||||||||||
4672 | break; | - | ||||||||||||||||||
4673 | } | - | ||||||||||||||||||
4674 | - | |||||||||||||||||||
4675 | if (truncating == 0 || c == '\n') | - | ||||||||||||||||||
4676 | shell_input_line[i++] = c; | - | ||||||||||||||||||
4677 | - | |||||||||||||||||||
4678 | if (c == '\n') | - | ||||||||||||||||||
4679 | { | - | ||||||||||||||||||
4680 | shell_input_line[--i] = '\0'; | - | ||||||||||||||||||
4681 | current_command_line_count++; | - | ||||||||||||||||||
4682 | break; | - | ||||||||||||||||||
4683 | } | - | ||||||||||||||||||
4684 | - | |||||||||||||||||||
4685 | last_was_backslash = last_was_backslash == 0 && c == '\\'; | - | ||||||||||||||||||
4686 | } | - | ||||||||||||||||||
4687 | - | |||||||||||||||||||
4688 | shell_input_line_index = 0; | - | ||||||||||||||||||
4689 | shell_input_line_len = i; /* == strlen (shell_input_line) */ | - | ||||||||||||||||||
4690 | - | |||||||||||||||||||
4691 | set_line_mbstate (); | - | ||||||||||||||||||
4692 | - | |||||||||||||||||||
4693 | #if defined (HISTORY) | - | ||||||||||||||||||
4694 | if (remember_on_history && shell_input_line && shell_input_line[0]) | - | ||||||||||||||||||
4695 | { | - | ||||||||||||||||||
4696 | char *expansions; | - | ||||||||||||||||||
4697 | # if defined (BANG_HISTORY) | - | ||||||||||||||||||
4698 | int old_hist; | - | ||||||||||||||||||
4699 | - | |||||||||||||||||||
4700 | /* If the current delimiter is a single quote, we should not be | - | ||||||||||||||||||
4701 | performing history expansion, even if we're on a different | - | ||||||||||||||||||
4702 | line from the original single quote. */ | - | ||||||||||||||||||
4703 | old_hist = history_expansion_inhibited; | - | ||||||||||||||||||
4704 | if (current_delimiter (dstack) == '\'') | - | ||||||||||||||||||
4705 | history_expansion_inhibited = 1; | - | ||||||||||||||||||
4706 | # endif | - | ||||||||||||||||||
4707 | /* Calling with a third argument of 1 allows remember_on_history to | - | ||||||||||||||||||
4708 | determine whether or not the line is saved to the history list */ | - | ||||||||||||||||||
4709 | expansions = pre_process_line (shell_input_line, 1, 1); | - | ||||||||||||||||||
4710 | # if defined (BANG_HISTORY) | - | ||||||||||||||||||
4711 | history_expansion_inhibited = old_hist; | - | ||||||||||||||||||
4712 | # endif | - | ||||||||||||||||||
4713 | if (expansions != shell_input_line) | - | ||||||||||||||||||
4714 | { | - | ||||||||||||||||||
4715 | free (shell_input_line); | - | ||||||||||||||||||
4716 | shell_input_line = expansions; | - | ||||||||||||||||||
4717 | shell_input_line_len = shell_input_line ? | - | ||||||||||||||||||
4718 | strlen (shell_input_line) : 0; | - | ||||||||||||||||||
4719 | if (shell_input_line_len == 0) | - | ||||||||||||||||||
4720 | current_command_line_count--; | - | ||||||||||||||||||
4721 | - | |||||||||||||||||||
4722 | /* We have to force the xrealloc below because we don't know | - | ||||||||||||||||||
4723 | the true allocated size of shell_input_line anymore. */ | - | ||||||||||||||||||
4724 | shell_input_line_size = shell_input_line_len; | - | ||||||||||||||||||
4725 | - | |||||||||||||||||||
4726 | set_line_mbstate (); | - | ||||||||||||||||||
4727 | } | - | ||||||||||||||||||
4728 | } | - | ||||||||||||||||||
4729 | /* Try to do something intelligent with blank lines encountered while | - | ||||||||||||||||||
4730 | entering multi-line commands. XXX - this is grotesque */ | - | ||||||||||||||||||
4731 | else if (remember_on_history && shell_input_line && | - | ||||||||||||||||||
4732 | shell_input_line[0] == '\0' && | - | ||||||||||||||||||
4733 | current_command_line_count > 1) | - | ||||||||||||||||||
4734 | { | - | ||||||||||||||||||
4735 | if (current_delimiter (dstack)) | - | ||||||||||||||||||
4736 | /* We know shell_input_line[0] == 0 and we're reading some sort of | - | ||||||||||||||||||
4737 | quoted string. This means we've got a line consisting of only | - | ||||||||||||||||||
4738 | a newline in a quoted string. We want to make sure this line | - | ||||||||||||||||||
4739 | gets added to the history. */ | - | ||||||||||||||||||
4740 | maybe_add_history (shell_input_line); | - | ||||||||||||||||||
4741 | else | - | ||||||||||||||||||
4742 | { | - | ||||||||||||||||||
4743 | char *hdcs; | - | ||||||||||||||||||
4744 | hdcs = history_delimiting_chars (shell_input_line); | - | ||||||||||||||||||
4745 | if (hdcs && hdcs[0] == ';') | - | ||||||||||||||||||
4746 | maybe_add_history (shell_input_line); | - | ||||||||||||||||||
4747 | } | - | ||||||||||||||||||
4748 | } | - | ||||||||||||||||||
4749 | - | |||||||||||||||||||
4750 | #endif /* HISTORY */ | - | ||||||||||||||||||
4751 | - | |||||||||||||||||||
4752 | if (shell_input_line) | - | ||||||||||||||||||
4753 | { | - | ||||||||||||||||||
4754 | /* Lines that signify the end of the shell's input should not be | - | ||||||||||||||||||
4755 | echoed. We should not echo lines while parsing command | - | ||||||||||||||||||
4756 | substitutions with recursive calls into the parsing engine; those | - | ||||||||||||||||||
4757 | should only be echoed once when we read the word. That is the | - | ||||||||||||||||||
4758 | reason for the test against shell_eof_token, which is set to a | - | ||||||||||||||||||
4759 | right paren when parsing the contents of command substitutions. */ | - | ||||||||||||||||||
4760 | if (echo_input_at_read && (shell_input_line[0] || | - | ||||||||||||||||||
4761 | shell_input_line_terminator != EOF) && | - | ||||||||||||||||||
4762 | shell_eof_token == 0) | - | ||||||||||||||||||
4763 | fprintf (stderr, "%s\n", shell_input_line); | - | ||||||||||||||||||
4764 | } | - | ||||||||||||||||||
4765 | else | - | ||||||||||||||||||
4766 | { | - | ||||||||||||||||||
4767 | shell_input_line_size = 0; | - | ||||||||||||||||||
4768 | prompt_string_pointer = ¤t_prompt_string; | - | ||||||||||||||||||
4769 | if (SHOULD_PROMPT ()) | - | ||||||||||||||||||
4770 | prompt_again (); | - | ||||||||||||||||||
4771 | goto restart_read; | - | ||||||||||||||||||
4772 | } | - | ||||||||||||||||||
4773 | - | |||||||||||||||||||
4774 | /* Add the newline to the end of this string, iff the string does | - | ||||||||||||||||||
4775 | not already end in an EOF character. */ | - | ||||||||||||||||||
4776 | if (shell_input_line_terminator != EOF) | - | ||||||||||||||||||
4777 | { | - | ||||||||||||||||||
4778 | if (shell_input_line_size < SIZE_MAX-3 && (shell_input_line_len+3 > shell_input_line_size)) | - | ||||||||||||||||||
4779 | shell_input_line = (char *)xrealloc (shell_input_line, | - | ||||||||||||||||||
4780 | 1 + (shell_input_line_size += 2)); | - | ||||||||||||||||||
4781 | - | |||||||||||||||||||
4782 | /* Don't add a newline to a string that ends with a backslash if we're | - | ||||||||||||||||||
4783 | going to be removing quoted newlines, since that will eat the | - | ||||||||||||||||||
4784 | backslash. Add another backslash instead (will be removed by | - | ||||||||||||||||||
4785 | word expansion). */ | - | ||||||||||||||||||
4786 | if (bash_input.type == st_string && expanding_alias() == 0 && last_was_backslash && c == EOF && remove_quoted_newline) | - | ||||||||||||||||||
4787 | shell_input_line[shell_input_line_len] = '\\'; | - | ||||||||||||||||||
4788 | else | - | ||||||||||||||||||
4789 | shell_input_line[shell_input_line_len] = '\n'; | - | ||||||||||||||||||
4790 | shell_input_line[shell_input_line_len + 1] = '\0'; | - | ||||||||||||||||||
4791 | - | |||||||||||||||||||
4792 | set_line_mbstate (); | - | ||||||||||||||||||
4793 | } | - | ||||||||||||||||||
4794 | } | - | ||||||||||||||||||
4795 | - | |||||||||||||||||||
4796 | next_alias_char: | - | ||||||||||||||||||
4797 | uc = shell_input_line[shell_input_line_index]; | - | ||||||||||||||||||
4798 | - | |||||||||||||||||||
4799 | if (uc) | - | ||||||||||||||||||
4800 | shell_input_line_index++; | - | ||||||||||||||||||
4801 | - | |||||||||||||||||||
4802 | #if defined (ALIAS) || defined (DPAREN_ARITHMETIC) | - | ||||||||||||||||||
4803 | /* If UC is NULL, we have reached the end of the current input string. If | - | ||||||||||||||||||
4804 | pushed_string_list is non-empty, it's time to pop to the previous string | - | ||||||||||||||||||
4805 | because we have fully consumed the result of the last alias expansion. | - | ||||||||||||||||||
4806 | Do it transparently; just return the next character of the string popped | - | ||||||||||||||||||
4807 | to. */ | - | ||||||||||||||||||
4808 | /* If pushed_string_list != 0 but pushed_string_list->expander == 0 (not | - | ||||||||||||||||||
4809 | currently tested) and the flags value is not PSH_SOURCE, we are not | - | ||||||||||||||||||
4810 | parsing an alias, we have just saved one (push_string, when called by | - | ||||||||||||||||||
4811 | the parse_dparen code) In this case, just go on as well. The PSH_SOURCE | - | ||||||||||||||||||
4812 | case is handled below. */ | - | ||||||||||||||||||
4813 | - | |||||||||||||||||||
4814 | /* If we're at the end of an alias expansion add a space to make sure that | - | ||||||||||||||||||
4815 | the alias remains marked as being in use while we expand its last word. | - | ||||||||||||||||||
4816 | This makes sure that pop_string doesn't mark the alias as not in use | - | ||||||||||||||||||
4817 | before the string resulting from the alias expansion is tokenized and | - | ||||||||||||||||||
4818 | checked for alias expansion, preventing recursion. At this point, the | - | ||||||||||||||||||
4819 | last character in shell_input_line is the last character of the alias | - | ||||||||||||||||||
4820 | expansion. We test that last character to determine whether or not to | - | ||||||||||||||||||
4821 | return the space that will delimit the token and postpone the pop_string. | - | ||||||||||||||||||
4822 | This set of conditions duplicates what used to be in mk_alexpansion () | - | ||||||||||||||||||
4823 | below, with the addition that we don't add a space if we're currently | - | ||||||||||||||||||
4824 | reading a quoted string. */ | - | ||||||||||||||||||
4825 | #ifndef OLD_ALIAS_HACK | - | ||||||||||||||||||
4826 | if (uc == 0 && pushed_string_list && pushed_string_list->flags != PSH_SOURCE && | - | ||||||||||||||||||
4827 | shell_input_line_index > 0 && | - | ||||||||||||||||||
4828 | shell_input_line[shell_input_line_index-1] != ' ' && | - | ||||||||||||||||||
4829 | shell_input_line[shell_input_line_index-1] != '\n' && | - | ||||||||||||||||||
4830 | shellmeta (shell_input_line[shell_input_line_index-1]) == 0 && | - | ||||||||||||||||||
4831 | (current_delimiter (dstack) != '\'' && current_delimiter (dstack) != '"')) | - | ||||||||||||||||||
4832 | { | - | ||||||||||||||||||
4833 | return ' '; /* END_ALIAS */ | - | ||||||||||||||||||
4834 | } | - | ||||||||||||||||||
4835 | #endif | - | ||||||||||||||||||
4836 | - | |||||||||||||||||||
4837 | pop_alias: | - | ||||||||||||||||||
4838 | if (uc == 0 && pushed_string_list && pushed_string_list->flags != PSH_SOURCE) | - | ||||||||||||||||||
4839 | { | - | ||||||||||||||||||
4840 | pop_string (); | - | ||||||||||||||||||
4841 | uc = shell_input_line[shell_input_line_index]; | - | ||||||||||||||||||
4842 | if (uc) | - | ||||||||||||||||||
4843 | shell_input_line_index++; | - | ||||||||||||||||||
4844 | } | - | ||||||||||||||||||
4845 | #endif /* ALIAS || DPAREN_ARITHMETIC */ | - | ||||||||||||||||||
4846 | - | |||||||||||||||||||
4847 | if MBTEST(uc == '\\' && remove_quoted_newline && shell_input_line[shell_input_line_index] == '\n') | - | ||||||||||||||||||
4848 | { | - | ||||||||||||||||||
4849 | if (SHOULD_PROMPT ()) | - | ||||||||||||||||||
4850 | prompt_again (); | - | ||||||||||||||||||
4851 | line_number++; | - | ||||||||||||||||||
4852 | /* What do we do here if we're expanding an alias whose definition | - | ||||||||||||||||||
4853 | includes an escaped newline? If that's the last character in the | - | ||||||||||||||||||
4854 | alias expansion, we just pop the pushed string list (recall that | - | ||||||||||||||||||
4855 | we inhibit the appending of a space if newline is the last | - | ||||||||||||||||||
4856 | character). If it's not the last character, we need to consume the | - | ||||||||||||||||||
4857 | quoted newline and move to the next character in the expansion. */ | - | ||||||||||||||||||
4858 | #if defined (ALIAS) | - | ||||||||||||||||||
4859 | if (expanding_alias () && shell_input_line[shell_input_line_index+1] == '\0') | - | ||||||||||||||||||
4860 | { | - | ||||||||||||||||||
4861 | uc = 0; | - | ||||||||||||||||||
4862 | goto pop_alias; | - | ||||||||||||||||||
4863 | } | - | ||||||||||||||||||
4864 | else if (expanding_alias () && shell_input_line[shell_input_line_index+1] != '\0') | - | ||||||||||||||||||
4865 | { | - | ||||||||||||||||||
4866 | shell_input_line_index++; /* skip newline */ | - | ||||||||||||||||||
4867 | goto next_alias_char; /* and get next character */ | - | ||||||||||||||||||
4868 | } | - | ||||||||||||||||||
4869 | else | - | ||||||||||||||||||
4870 | #endif | - | ||||||||||||||||||
4871 | goto restart_read; | - | ||||||||||||||||||
4872 | } | - | ||||||||||||||||||
4873 | - | |||||||||||||||||||
4874 | if (uc == 0 && shell_input_line_terminator == EOF) | - | ||||||||||||||||||
4875 | return ((shell_input_line_index != 0) ? '\n' : EOF); | - | ||||||||||||||||||
4876 | - | |||||||||||||||||||
4877 | #if defined (ALIAS) || defined (DPAREN_ARITHMETIC) | - | ||||||||||||||||||
4878 | /* We already know that we are not parsing an alias expansion because of the | - | ||||||||||||||||||
4879 | check for expanding_alias() above. This knows how parse_and_execute | - | ||||||||||||||||||
4880 | handles switching to st_string input while an alias is being expanded, | - | ||||||||||||||||||
4881 | hence the check for pushed_string_list without pushed_string_list->expander | - | ||||||||||||||||||
4882 | and the check for PSH_SOURCE as pushed_string_list->flags. | - | ||||||||||||||||||
4883 | parse_and_execute and parse_string both change the input type to st_string | - | ||||||||||||||||||
4884 | and place the string to be parsed and executed into location.string, so | - | ||||||||||||||||||
4885 | we should not stop reading that until the pointer is '\0'. | - | ||||||||||||||||||
4886 | The check for shell_input_line_terminator may be superfluous. | - | ||||||||||||||||||
4887 | - | |||||||||||||||||||
4888 | This solves the problem of `.' inside a multi-line alias with embedded | - | ||||||||||||||||||
4889 | newlines executing things out of order. */ | - | ||||||||||||||||||
4890 | if (uc == 0 && bash_input.type == st_string && *bash_input.location.string && | - | ||||||||||||||||||
4891 | pushed_string_list && pushed_string_list->flags == PSH_SOURCE && | - | ||||||||||||||||||
4892 | shell_input_line_terminator == 0) | - | ||||||||||||||||||
4893 | { | - | ||||||||||||||||||
4894 | shell_input_line_index = 0; | - | ||||||||||||||||||
4895 | goto restart_read; | - | ||||||||||||||||||
4896 | } | - | ||||||||||||||||||
4897 | #endif | - | ||||||||||||||||||
4898 | - | |||||||||||||||||||
4899 | return (uc); | - | ||||||||||||||||||
4900 | } | - | ||||||||||||||||||
4901 | - | |||||||||||||||||||
4902 | /* Put C back into the input for the shell. This might need changes for | - | ||||||||||||||||||
4903 | HANDLE_MULTIBYTE around EOLs. Since we (currently) never push back a | - | ||||||||||||||||||
4904 | character different than we read, shell_input_line_property doesn't need | - | ||||||||||||||||||
4905 | to change when manipulating shell_input_line. The define for | - | ||||||||||||||||||
4906 | last_shell_getc_is_singlebyte should take care of it, though. */ | - | ||||||||||||||||||
4907 | static void | - | ||||||||||||||||||
4908 | shell_ungetc (c) | - | ||||||||||||||||||
4909 | int c; | - | ||||||||||||||||||
4910 | { | - | ||||||||||||||||||
4911 | if (shell_input_line && shell_input_line_index) | - | ||||||||||||||||||
4912 | shell_input_line[--shell_input_line_index] = c; | - | ||||||||||||||||||
4913 | else | - | ||||||||||||||||||
4914 | eol_ungetc_lookahead = c; | - | ||||||||||||||||||
4915 | } | - | ||||||||||||||||||
4916 | - | |||||||||||||||||||
4917 | char * | - | ||||||||||||||||||
4918 | parser_remaining_input () | - | ||||||||||||||||||
4919 | { | - | ||||||||||||||||||
4920 | if (shell_input_line == 0) | - | ||||||||||||||||||
4921 | return 0; | - | ||||||||||||||||||
4922 | if ((int)shell_input_line_index < 0 || shell_input_line_index >= shell_input_line_len) | - | ||||||||||||||||||
4923 | return ""; /* XXX */ | - | ||||||||||||||||||
4924 | return (shell_input_line + shell_input_line_index); | - | ||||||||||||||||||
4925 | } | - | ||||||||||||||||||
4926 | - | |||||||||||||||||||
4927 | #ifdef INCLUDE_UNUSED | - | ||||||||||||||||||
4928 | /* Back the input pointer up by one, effectively `ungetting' a character. */ | - | ||||||||||||||||||
4929 | static void | - | ||||||||||||||||||
4930 | shell_ungetchar () | - | ||||||||||||||||||
4931 | { | - | ||||||||||||||||||
4932 | if (shell_input_line && shell_input_line_index) | - | ||||||||||||||||||
4933 | shell_input_line_index--; | - | ||||||||||||||||||
4934 | } | - | ||||||||||||||||||
4935 | #endif | - | ||||||||||||||||||
4936 | - | |||||||||||||||||||
4937 | /* Discard input until CHARACTER is seen, then push that character back | - | ||||||||||||||||||
4938 | onto the input stream. */ | - | ||||||||||||||||||
4939 | static void | - | ||||||||||||||||||
4940 | discard_until (character) | - | ||||||||||||||||||
4941 | int character; | - | ||||||||||||||||||
4942 | { | - | ||||||||||||||||||
4943 | int c; | - | ||||||||||||||||||
4944 | - | |||||||||||||||||||
4945 | while ((c = shell_getc (0)) != EOF && c != character) | - | ||||||||||||||||||
4946 | ; | - | ||||||||||||||||||
4947 | - | |||||||||||||||||||
4948 | if (c != EOF) | - | ||||||||||||||||||
4949 | shell_ungetc (c); | - | ||||||||||||||||||
4950 | } | - | ||||||||||||||||||
4951 | - | |||||||||||||||||||
4952 | void | - | ||||||||||||||||||
4953 | execute_variable_command (command, vname) | - | ||||||||||||||||||
4954 | char *command, *vname; | - | ||||||||||||||||||
4955 | { | - | ||||||||||||||||||
4956 | char *last_lastarg; | - | ||||||||||||||||||
4957 | sh_parser_state_t ps; | - | ||||||||||||||||||
4958 | - | |||||||||||||||||||
4959 | save_parser_state (&ps); | - | ||||||||||||||||||
4960 | last_lastarg = get_string_value ("_"); | - | ||||||||||||||||||
4961 | if (last_lastarg) | - | ||||||||||||||||||
4962 | last_lastarg = savestring (last_lastarg); | - | ||||||||||||||||||
4963 | - | |||||||||||||||||||
4964 | parse_and_execute (savestring (command), vname, SEVAL_NONINT|SEVAL_NOHIST); | - | ||||||||||||||||||
4965 | - | |||||||||||||||||||
4966 | restore_parser_state (&ps); | - | ||||||||||||||||||
4967 | bind_variable ("_", last_lastarg, 0); | - | ||||||||||||||||||
4968 | FREE (last_lastarg); | - | ||||||||||||||||||
4969 | - | |||||||||||||||||||
4970 | if (token_to_read == '\n') /* reset_parser was called */ | - | ||||||||||||||||||
4971 | token_to_read = 0; | - | ||||||||||||||||||
4972 | } | - | ||||||||||||||||||
4973 | - | |||||||||||||||||||
4974 | void | - | ||||||||||||||||||
4975 | push_token (x) | - | ||||||||||||||||||
4976 | int x; | - | ||||||||||||||||||
4977 | { | - | ||||||||||||||||||
4978 | two_tokens_ago = token_before_that; | - | ||||||||||||||||||
4979 | token_before_that = last_read_token; | - | ||||||||||||||||||
4980 | last_read_token = current_token; | - | ||||||||||||||||||
4981 | - | |||||||||||||||||||
4982 | current_token = x; | - | ||||||||||||||||||
4983 | } | - | ||||||||||||||||||
4984 | - | |||||||||||||||||||
4985 | /* Place to remember the token. We try to keep the buffer | - | ||||||||||||||||||
4986 | at a reasonable size, but it can grow. */ | - | ||||||||||||||||||
4987 | static char *token = (char *)NULL; | - | ||||||||||||||||||
4988 | - | |||||||||||||||||||
4989 | /* Current size of the token buffer. */ | - | ||||||||||||||||||
4990 | static int token_buffer_size; | - | ||||||||||||||||||
4991 | - | |||||||||||||||||||
4992 | /* Command to read_token () explaining what we want it to do. */ | - | ||||||||||||||||||
4993 | #define READ 0 | - | ||||||||||||||||||
4994 | #define RESET 1 | - | ||||||||||||||||||
4995 | #define prompt_is_ps1 \ | - | ||||||||||||||||||
4996 | (!prompt_string_pointer || prompt_string_pointer == &ps1_prompt) | - | ||||||||||||||||||
4997 | - | |||||||||||||||||||
4998 | /* Function for yyparse to call. yylex keeps track of | - | ||||||||||||||||||
4999 | the last two tokens read, and calls read_token. */ | - | ||||||||||||||||||
5000 | static int | - | ||||||||||||||||||
5001 | yylex () | - | ||||||||||||||||||
5002 | { | - | ||||||||||||||||||
5003 | if (interactive && (current_token == 0 || current_token == '\n')) | - | ||||||||||||||||||
5004 | { | - | ||||||||||||||||||
5005 | /* Before we print a prompt, we might have to check mailboxes. | - | ||||||||||||||||||
5006 | We do this only if it is time to do so. Notice that only here | - | ||||||||||||||||||
5007 | is the mail alarm reset; nothing takes place in check_mail () | - | ||||||||||||||||||
5008 | except the checking of mail. Please don't change this. */ | - | ||||||||||||||||||
5009 | if (prompt_is_ps1 && parse_and_execute_level == 0 && time_to_check_mail ()) | - | ||||||||||||||||||
5010 | { | - | ||||||||||||||||||
5011 | check_mail (); | - | ||||||||||||||||||
5012 | reset_mail_timer (); | - | ||||||||||||||||||
5013 | } | - | ||||||||||||||||||
5014 | - | |||||||||||||||||||
5015 | /* Avoid printing a prompt if we're not going to read anything, e.g. | - | ||||||||||||||||||
5016 | after resetting the parser with read_token (RESET). */ | - | ||||||||||||||||||
5017 | if (token_to_read == 0 && SHOULD_PROMPT ()) | - | ||||||||||||||||||
5018 | prompt_again (); | - | ||||||||||||||||||
5019 | } | - | ||||||||||||||||||
5020 | - | |||||||||||||||||||
5021 | two_tokens_ago = token_before_that; | - | ||||||||||||||||||
5022 | token_before_that = last_read_token; | - | ||||||||||||||||||
5023 | last_read_token = current_token; | - | ||||||||||||||||||
5024 | current_token = read_token (READ); | - | ||||||||||||||||||
5025 | - | |||||||||||||||||||
5026 | if ((parser_state & PST_EOFTOKEN) && current_token == shell_eof_token) | - | ||||||||||||||||||
5027 | { | - | ||||||||||||||||||
5028 | current_token = yacc_EOF; | - | ||||||||||||||||||
5029 | if (bash_input.type == st_string) | - | ||||||||||||||||||
5030 | rewind_input_string (); | - | ||||||||||||||||||
5031 | } | - | ||||||||||||||||||
5032 | parser_state &= ~PST_EOFTOKEN; /* ??? */ | - | ||||||||||||||||||
5033 | - | |||||||||||||||||||
5034 | return (current_token); | - | ||||||||||||||||||
5035 | } | - | ||||||||||||||||||
5036 | - | |||||||||||||||||||
5037 | /* When non-zero, we have read the required tokens | - | ||||||||||||||||||
5038 | which allow ESAC to be the next one read. */ | - | ||||||||||||||||||
5039 | static int esacs_needed_count; | - | ||||||||||||||||||
5040 | - | |||||||||||||||||||
5041 | /* When non-zero, we can read IN as an acceptable token, regardless of how | - | ||||||||||||||||||
5042 | many newlines we read. */ | - | ||||||||||||||||||
5043 | static int expecting_in_token; | - | ||||||||||||||||||
5044 | - | |||||||||||||||||||
5045 | static void | - | ||||||||||||||||||
5046 | push_heredoc (r) | - | ||||||||||||||||||
5047 | REDIRECT *r; | - | ||||||||||||||||||
5048 | { | - | ||||||||||||||||||
5049 | if (need_here_doc >= HEREDOC_MAX) | - | ||||||||||||||||||
5050 | { | - | ||||||||||||||||||
5051 | last_command_exit_value = EX_BADUSAGE; | - | ||||||||||||||||||
5052 | need_here_doc = 0; | - | ||||||||||||||||||
5053 | report_syntax_error (_("maximum here-document count exceeded")); | - | ||||||||||||||||||
5054 | reset_parser (); | - | ||||||||||||||||||
5055 | exit_shell (last_command_exit_value); | - | ||||||||||||||||||
5056 | } | - | ||||||||||||||||||
5057 | redir_stack[need_here_doc++] = r; | - | ||||||||||||||||||
5058 | } | - | ||||||||||||||||||
5059 | - | |||||||||||||||||||
5060 | void | - | ||||||||||||||||||
5061 | gather_here_documents () | - | ||||||||||||||||||
5062 | { | - | ||||||||||||||||||
5063 | int r; | - | ||||||||||||||||||
5064 | - | |||||||||||||||||||
5065 | r = 0; | - | ||||||||||||||||||
5066 | here_doc_first_line = 1; | - | ||||||||||||||||||
5067 | while (need_here_doc > 0) | - | ||||||||||||||||||
5068 | { | - | ||||||||||||||||||
5069 | parser_state |= PST_HEREDOC; | - | ||||||||||||||||||
5070 | make_here_document (redir_stack[r++], line_number); | - | ||||||||||||||||||
5071 | parser_state &= ~PST_HEREDOC; | - | ||||||||||||||||||
5072 | need_here_doc--; | - | ||||||||||||||||||
5073 | redir_stack[r - 1] = 0; /* XXX */ | - | ||||||||||||||||||
5074 | } | - | ||||||||||||||||||
5075 | here_doc_first_line = 0; /* just in case */ | - | ||||||||||||||||||
5076 | } | - | ||||||||||||||||||
5077 | - | |||||||||||||||||||
5078 | /* When non-zero, an open-brace used to create a group is awaiting a close | - | ||||||||||||||||||
5079 | brace partner. */ | - | ||||||||||||||||||
5080 | static int open_brace_count; | - | ||||||||||||||||||
5081 | - | |||||||||||||||||||
5082 | /* In the following three macros, `token' is always last_read_token */ | - | ||||||||||||||||||
5083 | - | |||||||||||||||||||
5084 | /* Are we in the middle of parsing a redirection where we are about to read | - | ||||||||||||||||||
5085 | a word? This is used to make sure alias expansion doesn't happen in the | - | ||||||||||||||||||
5086 | middle of a redirection, even though we're parsing a simple command. */ | - | ||||||||||||||||||
5087 | #define parsing_redirection(token) \ | - | ||||||||||||||||||
5088 | (token == '<' || token == '>' || \ | - | ||||||||||||||||||
5089 | token == GREATER_GREATER || token == GREATER_BAR || \ | - | ||||||||||||||||||
5090 | token == LESS_GREATER || token == LESS_LESS_MINUS || \ | - | ||||||||||||||||||
5091 | token == LESS_LESS || token == LESS_LESS_LESS || \ | - | ||||||||||||||||||
5092 | token == LESS_AND || token == GREATER_AND || token == AND_GREATER) | - | ||||||||||||||||||
5093 | - | |||||||||||||||||||
5094 | /* Is `token' one that will allow a WORD to be read in a command position? | - | ||||||||||||||||||
5095 | We can read a simple command name on which we should attempt alias expansion | - | ||||||||||||||||||
5096 | or we can read an assignment statement. */ | - | ||||||||||||||||||
5097 | #define command_token_position(token) \ | - | ||||||||||||||||||
5098 | (((token) == ASSIGNMENT_WORD) || \ | - | ||||||||||||||||||
5099 | ((parser_state&PST_REDIRLIST) && parsing_redirection(token) == 0) || \ | - | ||||||||||||||||||
5100 | ((token) != SEMI_SEMI && (token) != SEMI_AND && (token) != SEMI_SEMI_AND && reserved_word_acceptable(token))) | - | ||||||||||||||||||
5101 | - | |||||||||||||||||||
5102 | /* Are we in a position where we can read an assignment statement? */ | - | ||||||||||||||||||
5103 | #define assignment_acceptable(token) \ | - | ||||||||||||||||||
5104 | (command_token_position(token) && ((parser_state & PST_CASEPAT) == 0)) | - | ||||||||||||||||||
5105 | - | |||||||||||||||||||
5106 | /* Check to see if TOKEN is a reserved word and return the token | - | ||||||||||||||||||
5107 | value if it is. */ | - | ||||||||||||||||||
5108 | #define CHECK_FOR_RESERVED_WORD(tok) \ | - | ||||||||||||||||||
5109 | do { \ | - | ||||||||||||||||||
5110 | if (!dollar_present && !quoted && \ | - | ||||||||||||||||||
5111 | reserved_word_acceptable (last_read_token)) \ | - | ||||||||||||||||||
5112 | { \ | - | ||||||||||||||||||
5113 | int i; \ | - | ||||||||||||||||||
5114 | for (i = 0; word_token_alist[i].word != (char *)NULL; i++) \ | - | ||||||||||||||||||
5115 | if (STREQ (tok, word_token_alist[i].word)) \ | - | ||||||||||||||||||
5116 | { \ | - | ||||||||||||||||||
5117 | if ((parser_state & PST_CASEPAT) && (word_token_alist[i].token != ESAC)) \ | - | ||||||||||||||||||
5118 | break; \ | - | ||||||||||||||||||
5119 | if (word_token_alist[i].token == TIME && time_command_acceptable () == 0) \ | - | ||||||||||||||||||
5120 | break; \ | - | ||||||||||||||||||
5121 | if ((parser_state & PST_CASEPAT) && last_read_token == '|' && word_token_alist[i].token == ESAC) \ | - | ||||||||||||||||||
5122 | break; /* Posix grammar rule 4 */ \ | - | ||||||||||||||||||
5123 | if (word_token_alist[i].token == ESAC) \ | - | ||||||||||||||||||
5124 | parser_state &= ~(PST_CASEPAT|PST_CASESTMT); \ | - | ||||||||||||||||||
5125 | else if (word_token_alist[i].token == CASE) \ | - | ||||||||||||||||||
5126 | parser_state |= PST_CASESTMT; \ | - | ||||||||||||||||||
5127 | else if (word_token_alist[i].token == COND_END) \ | - | ||||||||||||||||||
5128 | parser_state &= ~(PST_CONDCMD|PST_CONDEXPR); \ | - | ||||||||||||||||||
5129 | else if (word_token_alist[i].token == COND_START) \ | - | ||||||||||||||||||
5130 | parser_state |= PST_CONDCMD; \ | - | ||||||||||||||||||
5131 | else if (word_token_alist[i].token == '{') \ | - | ||||||||||||||||||
5132 | open_brace_count++; \ | - | ||||||||||||||||||
5133 | else if (word_token_alist[i].token == '}' && open_brace_count) \ | - | ||||||||||||||||||
5134 | open_brace_count--; \ | - | ||||||||||||||||||
5135 | return (word_token_alist[i].token); \ | - | ||||||||||||||||||
5136 | } \ | - | ||||||||||||||||||
5137 | } \ | - | ||||||||||||||||||
5138 | } while (0) | - | ||||||||||||||||||
5139 | - | |||||||||||||||||||
5140 | #if defined (ALIAS) | - | ||||||||||||||||||
5141 | - | |||||||||||||||||||
5142 | /* OK, we have a token. Let's try to alias expand it, if (and only if) | - | ||||||||||||||||||
5143 | it's eligible. | - | ||||||||||||||||||
5144 | - | |||||||||||||||||||
5145 | It is eligible for expansion if EXPAND_ALIASES is set, and | - | ||||||||||||||||||
5146 | the token is unquoted and the last token read was a command | - | ||||||||||||||||||
5147 | separator (or expand_next_token is set), and we are currently | - | ||||||||||||||||||
5148 | processing an alias (pushed_string_list is non-empty) and this | - | ||||||||||||||||||
5149 | token is not the same as the current or any previously | - | ||||||||||||||||||
5150 | processed alias. | - | ||||||||||||||||||
5151 | - | |||||||||||||||||||
5152 | Special cases that disqualify: | - | ||||||||||||||||||
5153 | In a pattern list in a case statement (parser_state & PST_CASEPAT). */ | - | ||||||||||||||||||
5154 | - | |||||||||||||||||||
5155 | static char * | - | ||||||||||||||||||
5156 | mk_alexpansion (s) | - | ||||||||||||||||||
5157 | char *s; | - | ||||||||||||||||||
5158 | { | - | ||||||||||||||||||
5159 | int l; | - | ||||||||||||||||||
5160 | char *r; | - | ||||||||||||||||||
5161 | - | |||||||||||||||||||
5162 | l = strlen (s); | - | ||||||||||||||||||
5163 | r = xmalloc (l + 2); | - | ||||||||||||||||||
5164 | strcpy (r, s); | - | ||||||||||||||||||
5165 | #ifdef OLD_ALIAS_HACK | - | ||||||||||||||||||
5166 | /* If the last character in the alias is a newline, don't add a trailing | - | ||||||||||||||||||
5167 | space to the expansion. Works with shell_getc above. */ | - | ||||||||||||||||||
5168 | /* Need to do something about the case where the alias expansion contains | - | ||||||||||||||||||
5169 | an unmatched quoted string, since appending this space affects the | - | ||||||||||||||||||
5170 | subsequent output. */ | - | ||||||||||||||||||
5171 | if (l > 0 && r[l - 1] != ' ' && r[l - 1] != '\n' && shellmeta(r[l - 1]) == 0) | - | ||||||||||||||||||
5172 | r[l++] = ' '; | - | ||||||||||||||||||
5173 | #endif | - | ||||||||||||||||||
5174 | r[l] = '\0'; | - | ||||||||||||||||||
5175 | return r; | - | ||||||||||||||||||
5176 | } | - | ||||||||||||||||||
5177 | - | |||||||||||||||||||
5178 | static int | - | ||||||||||||||||||
5179 | alias_expand_token (tokstr) | - | ||||||||||||||||||
5180 | char *tokstr; | - | ||||||||||||||||||
5181 | { | - | ||||||||||||||||||
5182 | char *expanded; | - | ||||||||||||||||||
5183 | alias_t *ap; | - | ||||||||||||||||||
5184 | - | |||||||||||||||||||
5185 | if (((parser_state & PST_ALEXPNEXT) || command_token_position (last_read_token)) && | - | ||||||||||||||||||
5186 | (parser_state & PST_CASEPAT) == 0) | - | ||||||||||||||||||
5187 | { | - | ||||||||||||||||||
5188 | ap = find_alias (tokstr); | - | ||||||||||||||||||
5189 | - | |||||||||||||||||||
5190 | /* Currently expanding this token. */ | - | ||||||||||||||||||
5191 | if (ap && (ap->flags & AL_BEINGEXPANDED)) | - | ||||||||||||||||||
5192 | return (NO_EXPANSION); | - | ||||||||||||||||||
5193 | - | |||||||||||||||||||
5194 | #ifdef OLD_ALIAS_HACK | - | ||||||||||||||||||
5195 | /* mk_alexpansion puts an extra space on the end of the alias expansion, | - | ||||||||||||||||||
5196 | so the lookahead by the parser works right (the alias needs to remain | - | ||||||||||||||||||
5197 | `in use' while parsing its last word to avoid alias recursion for | - | ||||||||||||||||||
5198 | something like "alias echo=echo"). If this gets changed, make sure | - | ||||||||||||||||||
5199 | the code in shell_getc that deals with reaching the end of an | - | ||||||||||||||||||
5200 | expanded alias is changed with it. */ | - | ||||||||||||||||||
5201 | #endif | - | ||||||||||||||||||
5202 | expanded = ap ? mk_alexpansion (ap->value) : (char *)NULL; | - | ||||||||||||||||||
5203 | - | |||||||||||||||||||
5204 | if (expanded) | - | ||||||||||||||||||
5205 | { | - | ||||||||||||||||||
5206 | push_string (expanded, ap->flags & AL_EXPANDNEXT, ap); | - | ||||||||||||||||||
5207 | return (RE_READ_TOKEN); | - | ||||||||||||||||||
5208 | } | - | ||||||||||||||||||
5209 | else | - | ||||||||||||||||||
5210 | /* This is an eligible token that does not have an expansion. */ | - | ||||||||||||||||||
5211 | return (NO_EXPANSION); | - | ||||||||||||||||||
5212 | } | - | ||||||||||||||||||
5213 | return (NO_EXPANSION); | - | ||||||||||||||||||
5214 | } | - | ||||||||||||||||||
5215 | #endif /* ALIAS */ | - | ||||||||||||||||||
5216 | - | |||||||||||||||||||
5217 | static int | - | ||||||||||||||||||
5218 | time_command_acceptable () | - | ||||||||||||||||||
5219 | { | - | ||||||||||||||||||
5220 | #if defined (COMMAND_TIMING) | - | ||||||||||||||||||
5221 | int i; | - | ||||||||||||||||||
5222 | - | |||||||||||||||||||
5223 | if (posixly_correct && shell_compatibility_level > 41) | - | ||||||||||||||||||
5224 | { | - | ||||||||||||||||||
5225 | /* Quick check of the rest of the line to find the next token. If it | - | ||||||||||||||||||
5226 | begins with a `-', Posix says to not return `time' as the token. | - | ||||||||||||||||||
5227 | This was interp 267. */ | - | ||||||||||||||||||
5228 | i = shell_input_line_index; | - | ||||||||||||||||||
5229 | while (i < shell_input_line_len && (shell_input_line[i] == ' ' || shell_input_line[i] == '\t')) | - | ||||||||||||||||||
5230 | i++; | - | ||||||||||||||||||
5231 | if (shell_input_line[i] == '-') | - | ||||||||||||||||||
5232 | return 0; | - | ||||||||||||||||||
5233 | } | - | ||||||||||||||||||
5234 | - | |||||||||||||||||||
5235 | switch (last_read_token) | - | ||||||||||||||||||
5236 | { | - | ||||||||||||||||||
5237 | case 0: | - | ||||||||||||||||||
5238 | case ';': | - | ||||||||||||||||||
5239 | case '\n': | - | ||||||||||||||||||
5240 | if (token_before_that == '|') | - | ||||||||||||||||||
5241 | return (0); | - | ||||||||||||||||||
5242 | /* FALLTHROUGH */ | - | ||||||||||||||||||
5243 | case AND_AND: | - | ||||||||||||||||||
5244 | case OR_OR: | - | ||||||||||||||||||
5245 | case '&': | - | ||||||||||||||||||
5246 | case WHILE: | - | ||||||||||||||||||
5247 | case DO: | - | ||||||||||||||||||
5248 | case UNTIL: | - | ||||||||||||||||||
5249 | case IF: | - | ||||||||||||||||||
5250 | case THEN: | - | ||||||||||||||||||
5251 | case ELIF: | - | ||||||||||||||||||
5252 | case ELSE: | - | ||||||||||||||||||
5253 | case '{': /* } */ | - | ||||||||||||||||||
5254 | case '(': /* )( */ | - | ||||||||||||||||||
5255 | case ')': /* only valid in case statement */ | - | ||||||||||||||||||
5256 | case BANG: /* ! time pipeline */ | - | ||||||||||||||||||
5257 | case TIME: /* time time pipeline */ | - | ||||||||||||||||||
5258 | case TIMEOPT: /* time -p time pipeline */ | - | ||||||||||||||||||
5259 | case TIMEIGN: /* time -p -- ... */ | - | ||||||||||||||||||
5260 | return 1; | - | ||||||||||||||||||
5261 | default: | - | ||||||||||||||||||
5262 | return 0; | - | ||||||||||||||||||
5263 | } | - | ||||||||||||||||||
5264 | #else | - | ||||||||||||||||||
5265 | return 0; | - | ||||||||||||||||||
5266 | #endif /* COMMAND_TIMING */ | - | ||||||||||||||||||
5267 | } | - | ||||||||||||||||||
5268 | - | |||||||||||||||||||
5269 | /* Handle special cases of token recognition: | - | ||||||||||||||||||
5270 | IN is recognized if the last token was WORD and the token | - | ||||||||||||||||||
5271 | before that was FOR or CASE or SELECT. | - | ||||||||||||||||||
5272 | - | |||||||||||||||||||
5273 | DO is recognized if the last token was WORD and the token | - | ||||||||||||||||||
5274 | before that was FOR or SELECT. | - | ||||||||||||||||||
5275 | - | |||||||||||||||||||
5276 | ESAC is recognized if the last token caused `esacs_needed_count' | - | ||||||||||||||||||
5277 | to be set | - | ||||||||||||||||||
5278 | - | |||||||||||||||||||
5279 | `{' is recognized if the last token as WORD and the token | - | ||||||||||||||||||
5280 | before that was FUNCTION, or if we just parsed an arithmetic | - | ||||||||||||||||||
5281 | `for' command. | - | ||||||||||||||||||
5282 | - | |||||||||||||||||||
5283 | `}' is recognized if there is an unclosed `{' present. | - | ||||||||||||||||||
5284 | - | |||||||||||||||||||
5285 | `-p' is returned as TIMEOPT if the last read token was TIME. | - | ||||||||||||||||||
5286 | `--' is returned as TIMEIGN if the last read token was TIMEOPT. | - | ||||||||||||||||||
5287 | - | |||||||||||||||||||
5288 | ']]' is returned as COND_END if the parser is currently parsing | - | ||||||||||||||||||
5289 | a conditional expression ((parser_state & PST_CONDEXPR) != 0) | - | ||||||||||||||||||
5290 | - | |||||||||||||||||||
5291 | `time' is returned as TIME if and only if it is immediately | - | ||||||||||||||||||
5292 | preceded by one of `;', `\n', `||', `&&', or `&'. | - | ||||||||||||||||||
5293 | */ | - | ||||||||||||||||||
5294 | - | |||||||||||||||||||
5295 | static int | - | ||||||||||||||||||
5296 | special_case_tokens (tokstr) | - | ||||||||||||||||||
5297 | char *tokstr; | - | ||||||||||||||||||
5298 | { | - | ||||||||||||||||||
5299 | /* Posix grammar rule 6 */ | - | ||||||||||||||||||
5300 | if ((last_read_token == WORD) && | - | ||||||||||||||||||
5301 | ((token_before_that == FOR) || (token_before_that == CASE) || (token_before_that == SELECT)) && | - | ||||||||||||||||||
5302 | (tokstr[0] == 'i' && tokstr[1] == 'n' && tokstr[2] == 0)) | - | ||||||||||||||||||
5303 | { | - | ||||||||||||||||||
5304 | if (token_before_that == CASE) | - | ||||||||||||||||||
5305 | { | - | ||||||||||||||||||
5306 | parser_state |= PST_CASEPAT; | - | ||||||||||||||||||
5307 | esacs_needed_count++; | - | ||||||||||||||||||
5308 | } | - | ||||||||||||||||||
5309 | if (expecting_in_token) | - | ||||||||||||||||||
5310 | expecting_in_token--; | - | ||||||||||||||||||
5311 | return (IN); | - | ||||||||||||||||||
5312 | } | - | ||||||||||||||||||
5313 | - | |||||||||||||||||||
5314 | /* bash-5.0: leaving above code intact for now, but it should eventually be | - | ||||||||||||||||||
5315 | removed in favor of this clause. */ | - | ||||||||||||||||||
5316 | /* Posix grammar rule 6 */ | - | ||||||||||||||||||
5317 | if (expecting_in_token && (last_read_token == WORD || last_read_token == '\n') && | - | ||||||||||||||||||
5318 | (tokstr[0] == 'i' && tokstr[1] == 'n' && tokstr[2] == 0)) | - | ||||||||||||||||||
5319 | { | - | ||||||||||||||||||
5320 | if (parser_state & PST_CASESTMT) | - | ||||||||||||||||||
5321 | { | - | ||||||||||||||||||
5322 | parser_state |= PST_CASEPAT; | - | ||||||||||||||||||
5323 | esacs_needed_count++; | - | ||||||||||||||||||
5324 | } | - | ||||||||||||||||||
5325 | expecting_in_token--; | - | ||||||||||||||||||
5326 | return (IN); | - | ||||||||||||||||||
5327 | } | - | ||||||||||||||||||
5328 | /* Posix grammar rule 6, third word in FOR: for i; do command-list; done */ | - | ||||||||||||||||||
5329 | else if (expecting_in_token && (last_read_token == '\n' || last_read_token == ';') && | - | ||||||||||||||||||
5330 | (tokstr[0] == 'd' && tokstr[1] == 'o' && tokstr[2] == '\0')) | - | ||||||||||||||||||
5331 | { | - | ||||||||||||||||||
5332 | expecting_in_token--; | - | ||||||||||||||||||
5333 | return (DO); | - | ||||||||||||||||||
5334 | } | - | ||||||||||||||||||
5335 | - | |||||||||||||||||||
5336 | /* for i do; command-list; done */ | - | ||||||||||||||||||
5337 | if (last_read_token == WORD && | - | ||||||||||||||||||
5338 | #if defined (SELECT_COMMAND) | - | ||||||||||||||||||
5339 | (token_before_that == FOR || token_before_that == SELECT) && | - | ||||||||||||||||||
5340 | #else | - | ||||||||||||||||||
5341 | (token_before_that == FOR) && | - | ||||||||||||||||||
5342 | #endif | - | ||||||||||||||||||
5343 | (tokstr[0] == 'd' && tokstr[1] == 'o' && tokstr[2] == '\0')) | - | ||||||||||||||||||
5344 | { | - | ||||||||||||||||||
5345 | if (expecting_in_token) | - | ||||||||||||||||||
5346 | expecting_in_token--; | - | ||||||||||||||||||
5347 | return (DO); | - | ||||||||||||||||||
5348 | } | - | ||||||||||||||||||
5349 | - | |||||||||||||||||||
5350 | /* Ditto for ESAC in the CASE case. | - | ||||||||||||||||||
5351 | Specifically, this handles "case word in esac", which is a legal | - | ||||||||||||||||||
5352 | construct, certainly because someone will pass an empty arg to the | - | ||||||||||||||||||
5353 | case construct, and we don't want it to barf. Of course, we should | - | ||||||||||||||||||
5354 | insist that the case construct has at least one pattern in it, but | - | ||||||||||||||||||
5355 | the designers disagree. */ | - | ||||||||||||||||||
5356 | if (esacs_needed_count) | - | ||||||||||||||||||
5357 | { | - | ||||||||||||||||||
5358 | if (last_read_token == IN && STREQ (tokstr, "esac")) | - | ||||||||||||||||||
5359 | { | - | ||||||||||||||||||
5360 | esacs_needed_count--; | - | ||||||||||||||||||
5361 | parser_state &= ~PST_CASEPAT; | - | ||||||||||||||||||
5362 | return (ESAC); | - | ||||||||||||||||||
5363 | } | - | ||||||||||||||||||
5364 | } | - | ||||||||||||||||||
5365 | - | |||||||||||||||||||
5366 | /* The start of a shell function definition. */ | - | ||||||||||||||||||
5367 | if (parser_state & PST_ALLOWOPNBRC) | - | ||||||||||||||||||
5368 | { | - | ||||||||||||||||||
5369 | parser_state &= ~PST_ALLOWOPNBRC; | - | ||||||||||||||||||
5370 | if (tokstr[0] == '{' && tokstr[1] == '\0') /* } */ | - | ||||||||||||||||||
5371 | { | - | ||||||||||||||||||
5372 | open_brace_count++; | - | ||||||||||||||||||
5373 | function_bstart = line_number; | - | ||||||||||||||||||
5374 | return ('{'); /* } */ | - | ||||||||||||||||||
5375 | } | - | ||||||||||||||||||
5376 | } | - | ||||||||||||||||||
5377 | - | |||||||||||||||||||
5378 | /* We allow a `do' after a for ((...)) without an intervening | - | ||||||||||||||||||
5379 | list_terminator */ | - | ||||||||||||||||||
5380 | if (last_read_token == ARITH_FOR_EXPRS && tokstr[0] == 'd' && tokstr[1] == 'o' && !tokstr[2]) | - | ||||||||||||||||||
5381 | return (DO); | - | ||||||||||||||||||
5382 | if (last_read_token == ARITH_FOR_EXPRS && tokstr[0] == '{' && tokstr[1] == '\0') /* } */ | - | ||||||||||||||||||
5383 | { | - | ||||||||||||||||||
5384 | open_brace_count++; | - | ||||||||||||||||||
5385 | return ('{'); /* } */ | - | ||||||||||||||||||
5386 | } | - | ||||||||||||||||||
5387 | - | |||||||||||||||||||
5388 | if (open_brace_count && reserved_word_acceptable (last_read_token) && tokstr[0] == '}' && !tokstr[1]) | - | ||||||||||||||||||
5389 | { | - | ||||||||||||||||||
5390 | open_brace_count--; /* { */ | - | ||||||||||||||||||
5391 | return ('}'); | - | ||||||||||||||||||
5392 | } | - | ||||||||||||||||||
5393 | - | |||||||||||||||||||
5394 | #if defined (COMMAND_TIMING) | - | ||||||||||||||||||
5395 | /* Handle -p after `time'. */ | - | ||||||||||||||||||
5396 | if (last_read_token == TIME && tokstr[0] == '-' && tokstr[1] == 'p' && !tokstr[2]) | - | ||||||||||||||||||
5397 | return (TIMEOPT); | - | ||||||||||||||||||
5398 | /* Handle -- after `time -p'. */ | - | ||||||||||||||||||
5399 | if (last_read_token == TIMEOPT && tokstr[0] == '-' && tokstr[1] == '-' && !tokstr[2]) | - | ||||||||||||||||||
5400 | return (TIMEIGN); | - | ||||||||||||||||||
5401 | #endif | - | ||||||||||||||||||
5402 | - | |||||||||||||||||||
5403 | #if defined (COND_COMMAND) /* [[ */ | - | ||||||||||||||||||
5404 | if ((parser_state & PST_CONDEXPR) && tokstr[0] == ']' && tokstr[1] == ']' && tokstr[2] == '\0') | - | ||||||||||||||||||
5405 | return (COND_END); | - | ||||||||||||||||||
5406 | #endif | - | ||||||||||||||||||
5407 | - | |||||||||||||||||||
5408 | return (-1); | - | ||||||||||||||||||
5409 | } | - | ||||||||||||||||||
5410 | - | |||||||||||||||||||
5411 | /* Called from shell.c when Control-C is typed at top level. Or | - | ||||||||||||||||||
5412 | by the error rule at top level. */ | - | ||||||||||||||||||
5413 | void | - | ||||||||||||||||||
5414 | reset_parser () | - | ||||||||||||||||||
5415 | { | - | ||||||||||||||||||
5416 | dstack.delimiter_depth = 0; /* No delimiters found so far. */ | - | ||||||||||||||||||
5417 | open_brace_count = 0; | - | ||||||||||||||||||
5418 | - | |||||||||||||||||||
5419 | #if defined (EXTENDED_GLOB) | - | ||||||||||||||||||
5420 | /* Reset to global value of extended glob */ | - | ||||||||||||||||||
5421 | if (parser_state & PST_EXTPAT) | - | ||||||||||||||||||
5422 | extended_glob = global_extglob; | - | ||||||||||||||||||
5423 | #endif | - | ||||||||||||||||||
5424 | - | |||||||||||||||||||
5425 | parser_state = 0; | - | ||||||||||||||||||
5426 | here_doc_first_line = 0; | - | ||||||||||||||||||
5427 | - | |||||||||||||||||||
5428 | #if defined (ALIAS) || defined (DPAREN_ARITHMETIC) | - | ||||||||||||||||||
5429 | if (pushed_string_list) | - | ||||||||||||||||||
5430 | free_string_list (); | - | ||||||||||||||||||
5431 | #endif /* ALIAS || DPAREN_ARITHMETIC */ | - | ||||||||||||||||||
5432 | - | |||||||||||||||||||
5433 | /* This is where we resynchronize to the next newline on error/reset */ | - | ||||||||||||||||||
5434 | if (shell_input_line) | - | ||||||||||||||||||
5435 | { | - | ||||||||||||||||||
5436 | free (shell_input_line); | - | ||||||||||||||||||
5437 | shell_input_line = (char *)NULL; | - | ||||||||||||||||||
5438 | shell_input_line_size = shell_input_line_index = 0; | - | ||||||||||||||||||
5439 | } | - | ||||||||||||||||||
5440 | - | |||||||||||||||||||
5441 | FREE (word_desc_to_read); | - | ||||||||||||||||||
5442 | word_desc_to_read = (WORD_DESC *)NULL; | - | ||||||||||||||||||
5443 | - | |||||||||||||||||||
5444 | eol_ungetc_lookahead = 0; | - | ||||||||||||||||||
5445 | - | |||||||||||||||||||
5446 | current_token = '\n'; /* XXX */ | - | ||||||||||||||||||
5447 | last_read_token = '\n'; | - | ||||||||||||||||||
5448 | token_to_read = '\n'; | - | ||||||||||||||||||
5449 | } | - | ||||||||||||||||||
5450 | - | |||||||||||||||||||
5451 | /* Read the next token. Command can be READ (normal operation) or | - | ||||||||||||||||||
5452 | RESET (to normalize state). */ | - | ||||||||||||||||||
5453 | static int | - | ||||||||||||||||||
5454 | read_token (command) | - | ||||||||||||||||||
5455 | int command; | - | ||||||||||||||||||
5456 | { | - | ||||||||||||||||||
5457 | int character; /* Current character. */ | - | ||||||||||||||||||
5458 | int peek_char; /* Temporary look-ahead character. */ | - | ||||||||||||||||||
5459 | int result; /* The thing to return. */ | - | ||||||||||||||||||
5460 | - | |||||||||||||||||||
5461 | if (command == RESET) | - | ||||||||||||||||||
5462 | { | - | ||||||||||||||||||
5463 | reset_parser (); | - | ||||||||||||||||||
5464 | return ('\n'); | - | ||||||||||||||||||
5465 | } | - | ||||||||||||||||||
5466 | - | |||||||||||||||||||
5467 | if (token_to_read) | - | ||||||||||||||||||
5468 | { | - | ||||||||||||||||||
5469 | result = token_to_read; | - | ||||||||||||||||||
5470 | if (token_to_read == WORD || token_to_read == ASSIGNMENT_WORD) | - | ||||||||||||||||||
5471 | { | - | ||||||||||||||||||
5472 | yylval.word = word_desc_to_read; | - | ||||||||||||||||||
5473 | word_desc_to_read = (WORD_DESC *)NULL; | - | ||||||||||||||||||
5474 | } | - | ||||||||||||||||||
5475 | token_to_read = 0; | - | ||||||||||||||||||
5476 | return (result); | - | ||||||||||||||||||
5477 | } | - | ||||||||||||||||||
5478 | - | |||||||||||||||||||
5479 | #if defined (COND_COMMAND) | - | ||||||||||||||||||
5480 | if ((parser_state & (PST_CONDCMD|PST_CONDEXPR)) == PST_CONDCMD) | - | ||||||||||||||||||
5481 | { | - | ||||||||||||||||||
5482 | cond_lineno = line_number; | - | ||||||||||||||||||
5483 | parser_state |= PST_CONDEXPR; | - | ||||||||||||||||||
5484 | yylval.command = parse_cond_command (); | - | ||||||||||||||||||
5485 | if (cond_token != COND_END) | - | ||||||||||||||||||
5486 | { | - | ||||||||||||||||||
5487 | cond_error (); | - | ||||||||||||||||||
5488 | return (-1); | - | ||||||||||||||||||
5489 | } | - | ||||||||||||||||||
5490 | token_to_read = COND_END; | - | ||||||||||||||||||
5491 | parser_state &= ~(PST_CONDEXPR|PST_CONDCMD); | - | ||||||||||||||||||
5492 | return (COND_CMD); | - | ||||||||||||||||||
5493 | } | - | ||||||||||||||||||
5494 | #endif | - | ||||||||||||||||||
5495 | - | |||||||||||||||||||
5496 | #if defined (ALIAS) | - | ||||||||||||||||||
5497 | /* This is a place to jump back to once we have successfully expanded a | - | ||||||||||||||||||
5498 | token with an alias and pushed the string with push_string () */ | - | ||||||||||||||||||
5499 | re_read_token: | - | ||||||||||||||||||
5500 | #endif /* ALIAS */ | - | ||||||||||||||||||
5501 | - | |||||||||||||||||||
5502 | /* Read a single word from input. Start by skipping blanks. */ | - | ||||||||||||||||||
5503 | while ((character = shell_getc (1)) != EOF && shellblank (character)) | - | ||||||||||||||||||
5504 | ; | - | ||||||||||||||||||
5505 | - | |||||||||||||||||||
5506 | if (character == EOF) | - | ||||||||||||||||||
5507 | { | - | ||||||||||||||||||
5508 | EOF_Reached = 1; | - | ||||||||||||||||||
5509 | return (yacc_EOF); | - | ||||||||||||||||||
5510 | } | - | ||||||||||||||||||
5511 | - | |||||||||||||||||||
5512 | /* If we hit the end of the string and we're not expanding an alias (e.g., | - | ||||||||||||||||||
5513 | we are eval'ing a string that is an incomplete command), return EOF */ | - | ||||||||||||||||||
5514 | if (character == '\0' && bash_input.type == st_string && expanding_alias() == 0) | - | ||||||||||||||||||
5515 | { | - | ||||||||||||||||||
5516 | #if defined (DEBUG) | - | ||||||||||||||||||
5517 | itrace("shell_getc: bash_input.location.string = `%s'", bash_input.location.string); | - | ||||||||||||||||||
5518 | #endif | - | ||||||||||||||||||
5519 | EOF_Reached = 1; | - | ||||||||||||||||||
5520 | return (yacc_EOF); | - | ||||||||||||||||||
5521 | } | - | ||||||||||||||||||
5522 | - | |||||||||||||||||||
5523 | if MBTEST(character == '#' && (!interactive || interactive_comments)) | - | ||||||||||||||||||
5524 | { | - | ||||||||||||||||||
5525 | /* A comment. Discard until EOL or EOF, and then return a newline. */ | - | ||||||||||||||||||
5526 | discard_until ('\n'); | - | ||||||||||||||||||
5527 | shell_getc (0); | - | ||||||||||||||||||
5528 | character = '\n'; /* this will take the next if statement and return. */ | - | ||||||||||||||||||
5529 | } | - | ||||||||||||||||||
5530 | - | |||||||||||||||||||
5531 | if (character == '\n') | - | ||||||||||||||||||
5532 | { | - | ||||||||||||||||||
5533 | /* If we're about to return an unquoted newline, we can go and collect | - | ||||||||||||||||||
5534 | the text of any pending here document. */ | - | ||||||||||||||||||
5535 | if (need_here_doc) | - | ||||||||||||||||||
5536 | gather_here_documents (); | - | ||||||||||||||||||
5537 | - | |||||||||||||||||||
5538 | #if defined (ALIAS) | - | ||||||||||||||||||
5539 | parser_state &= ~PST_ALEXPNEXT; | - | ||||||||||||||||||
5540 | #endif /* ALIAS */ | - | ||||||||||||||||||
5541 | - | |||||||||||||||||||
5542 | parser_state &= ~PST_ASSIGNOK; | - | ||||||||||||||||||
5543 | - | |||||||||||||||||||
5544 | return (character); | - | ||||||||||||||||||
5545 | } | - | ||||||||||||||||||
5546 | - | |||||||||||||||||||
5547 | if (parser_state & PST_REGEXP) | - | ||||||||||||||||||
5548 | goto tokword; | - | ||||||||||||||||||
5549 | - | |||||||||||||||||||
5550 | /* Shell meta-characters. */ | - | ||||||||||||||||||
5551 | if MBTEST(shellmeta (character) && ((parser_state & PST_DBLPAREN) == 0)) | - | ||||||||||||||||||
5552 | { | - | ||||||||||||||||||
5553 | #if defined (ALIAS) | - | ||||||||||||||||||
5554 | /* Turn off alias tokenization iff this character sequence would | - | ||||||||||||||||||
5555 | not leave us ready to read a command. */ | - | ||||||||||||||||||
5556 | if (character == '<' || character == '>') | - | ||||||||||||||||||
5557 | parser_state &= ~PST_ALEXPNEXT; | - | ||||||||||||||||||
5558 | #endif /* ALIAS */ | - | ||||||||||||||||||
5559 | - | |||||||||||||||||||
5560 | parser_state &= ~PST_ASSIGNOK; | - | ||||||||||||||||||
5561 | - | |||||||||||||||||||
5562 | /* If we are parsing a command substitution and we have read a character | - | ||||||||||||||||||
5563 | that marks the end of it, don't bother to skip over quoted newlines | - | ||||||||||||||||||
5564 | when we read the next token. We're just interested in a character | - | ||||||||||||||||||
5565 | that will turn this into a two-character token, so we let the higher | - | ||||||||||||||||||
5566 | layers deal with quoted newlines following the command substitution. */ | - | ||||||||||||||||||
5567 | if ((parser_state & PST_CMDSUBST) && character == shell_eof_token) | - | ||||||||||||||||||
5568 | peek_char = shell_getc (0); | - | ||||||||||||||||||
5569 | else | - | ||||||||||||||||||
5570 | peek_char = shell_getc (1); | - | ||||||||||||||||||
5571 | - | |||||||||||||||||||
5572 | if (character == peek_char) | - | ||||||||||||||||||
5573 | { | - | ||||||||||||||||||
5574 | switch (character) | - | ||||||||||||||||||
5575 | { | - | ||||||||||||||||||
5576 | case '<': | - | ||||||||||||||||||
5577 | /* If '<' then we could be at "<<" or at "<<-". We have to | - | ||||||||||||||||||
5578 | look ahead one more character. */ | - | ||||||||||||||||||
5579 | peek_char = shell_getc (1); | - | ||||||||||||||||||
5580 | if MBTEST(peek_char == '-') | - | ||||||||||||||||||
5581 | return (LESS_LESS_MINUS); | - | ||||||||||||||||||
5582 | else if MBTEST(peek_char == '<') | - | ||||||||||||||||||
5583 | return (LESS_LESS_LESS); | - | ||||||||||||||||||
5584 | else | - | ||||||||||||||||||
5585 | { | - | ||||||||||||||||||
5586 | shell_ungetc (peek_char); | - | ||||||||||||||||||
5587 | return (LESS_LESS); | - | ||||||||||||||||||
5588 | } | - | ||||||||||||||||||
5589 | - | |||||||||||||||||||
5590 | case '>': | - | ||||||||||||||||||
5591 | return (GREATER_GREATER); | - | ||||||||||||||||||
5592 | - | |||||||||||||||||||
5593 | case ';': | - | ||||||||||||||||||
5594 | parser_state |= PST_CASEPAT; | - | ||||||||||||||||||
5595 | #if defined (ALIAS) | - | ||||||||||||||||||
5596 | parser_state &= ~PST_ALEXPNEXT; | - | ||||||||||||||||||
5597 | #endif /* ALIAS */ | - | ||||||||||||||||||
5598 | - | |||||||||||||||||||
5599 | peek_char = shell_getc (1); | - | ||||||||||||||||||
5600 | if MBTEST(peek_char == '&') | - | ||||||||||||||||||
5601 | return (SEMI_SEMI_AND); | - | ||||||||||||||||||
5602 | else | - | ||||||||||||||||||
5603 | { | - | ||||||||||||||||||
5604 | shell_ungetc (peek_char); | - | ||||||||||||||||||
5605 | return (SEMI_SEMI); | - | ||||||||||||||||||
5606 | } | - | ||||||||||||||||||
5607 | - | |||||||||||||||||||
5608 | case '&': | - | ||||||||||||||||||
5609 | return (AND_AND); | - | ||||||||||||||||||
5610 | - | |||||||||||||||||||
5611 | case '|': | - | ||||||||||||||||||
5612 | return (OR_OR); | - | ||||||||||||||||||
5613 | - | |||||||||||||||||||
5614 | #if defined (DPAREN_ARITHMETIC) || defined (ARITH_FOR_COMMAND) | - | ||||||||||||||||||
5615 | case '(': /* ) */ | - | ||||||||||||||||||
5616 | result = parse_dparen (character); | - | ||||||||||||||||||
5617 | if (result == -2) | - | ||||||||||||||||||
5618 | break; | - | ||||||||||||||||||
5619 | else | - | ||||||||||||||||||
5620 | return result; | - | ||||||||||||||||||
5621 | #endif | - | ||||||||||||||||||
5622 | } | - | ||||||||||||||||||
5623 | } | - | ||||||||||||||||||
5624 | else if MBTEST(character == '<' && peek_char == '&') | - | ||||||||||||||||||
5625 | return (LESS_AND); | - | ||||||||||||||||||
5626 | else if MBTEST(character == '>' && peek_char == '&') | - | ||||||||||||||||||
5627 | return (GREATER_AND); | - | ||||||||||||||||||
5628 | else if MBTEST(character == '<' && peek_char == '>') | - | ||||||||||||||||||
5629 | return (LESS_GREATER); | - | ||||||||||||||||||
5630 | else if MBTEST(character == '>' && peek_char == '|') | - | ||||||||||||||||||
5631 | return (GREATER_BAR); | - | ||||||||||||||||||
5632 | else if MBTEST(character == '&' && peek_char == '>') | - | ||||||||||||||||||
5633 | { | - | ||||||||||||||||||
5634 | peek_char = shell_getc (1); | - | ||||||||||||||||||
5635 | if MBTEST(peek_char == '>') | - | ||||||||||||||||||
5636 | return (AND_GREATER_GREATER); | - | ||||||||||||||||||
5637 | else | - | ||||||||||||||||||
5638 | { | - | ||||||||||||||||||
5639 | shell_ungetc (peek_char); | - | ||||||||||||||||||
5640 | return (AND_GREATER); | - | ||||||||||||||||||
5641 | } | - | ||||||||||||||||||
5642 | } | - | ||||||||||||||||||
5643 | else if MBTEST(character == '|' && peek_char == '&') | - | ||||||||||||||||||
5644 | return (BAR_AND); | - | ||||||||||||||||||
5645 | else if MBTEST(character == ';' && peek_char == '&') | - | ||||||||||||||||||
5646 | { | - | ||||||||||||||||||
5647 | parser_state |= PST_CASEPAT; | - | ||||||||||||||||||
5648 | #if defined (ALIAS) | - | ||||||||||||||||||
5649 | parser_state &= ~PST_ALEXPNEXT; | - | ||||||||||||||||||
5650 | #endif /* ALIAS */ | - | ||||||||||||||||||
5651 | return (SEMI_AND); | - | ||||||||||||||||||
5652 | } | - | ||||||||||||||||||
5653 | - | |||||||||||||||||||
5654 | shell_ungetc (peek_char); | - | ||||||||||||||||||
5655 | - | |||||||||||||||||||
5656 | /* If we look like we are reading the start of a function | - | ||||||||||||||||||
5657 | definition, then let the reader know about it so that | - | ||||||||||||||||||
5658 | we will do the right thing with `{'. */ | - | ||||||||||||||||||
5659 | if MBTEST(character == ')' && last_read_token == '(' && token_before_that == WORD) | - | ||||||||||||||||||
5660 | { | - | ||||||||||||||||||
5661 | parser_state |= PST_ALLOWOPNBRC; | - | ||||||||||||||||||
5662 | #if defined (ALIAS) | - | ||||||||||||||||||
5663 | parser_state &= ~PST_ALEXPNEXT; | - | ||||||||||||||||||
5664 | #endif /* ALIAS */ | - | ||||||||||||||||||
5665 | function_dstart = line_number; | - | ||||||||||||||||||
5666 | } | - | ||||||||||||||||||
5667 | - | |||||||||||||||||||
5668 | /* case pattern lists may be preceded by an optional left paren. If | - | ||||||||||||||||||
5669 | we're not trying to parse a case pattern list, the left paren | - | ||||||||||||||||||
5670 | indicates a subshell. */ | - | ||||||||||||||||||
5671 | if MBTEST(character == '(' && (parser_state & PST_CASEPAT) == 0) /* ) */ | - | ||||||||||||||||||
5672 | parser_state |= PST_SUBSHELL; | - | ||||||||||||||||||
5673 | /*(*/ | - | ||||||||||||||||||
5674 | else if MBTEST((parser_state & PST_CASEPAT) && character == ')') | - | ||||||||||||||||||
5675 | parser_state &= ~PST_CASEPAT; | - | ||||||||||||||||||
5676 | /*(*/ | - | ||||||||||||||||||
5677 | else if MBTEST((parser_state & PST_SUBSHELL) && character == ')') | - | ||||||||||||||||||
5678 | parser_state &= ~PST_SUBSHELL; | - | ||||||||||||||||||
5679 | - | |||||||||||||||||||
5680 | #if defined (PROCESS_SUBSTITUTION) | - | ||||||||||||||||||
5681 | /* Check for the constructs which introduce process substitution. | - | ||||||||||||||||||
5682 | Shells running in `posix mode' don't do process substitution. */ | - | ||||||||||||||||||
5683 | if MBTEST(posixly_correct || ((character != '>' && character != '<') || peek_char != '(')) /*)*/ | - | ||||||||||||||||||
5684 | #endif /* PROCESS_SUBSTITUTION */ | - | ||||||||||||||||||
5685 | return (character); | - | ||||||||||||||||||
5686 | } | - | ||||||||||||||||||
5687 | - | |||||||||||||||||||
5688 | /* Hack <&- (close stdin) case. Also <&N- (dup and close). */ | - | ||||||||||||||||||
5689 | if MBTEST(character == '-' && (last_read_token == LESS_AND || last_read_token == GREATER_AND)) | - | ||||||||||||||||||
5690 | return (character); | - | ||||||||||||||||||
5691 | - | |||||||||||||||||||
5692 | tokword: | - | ||||||||||||||||||
5693 | /* Okay, if we got this far, we have to read a word. Read one, | - | ||||||||||||||||||
5694 | and then check it against the known ones. */ | - | ||||||||||||||||||
5695 | result = read_token_word (character); | - | ||||||||||||||||||
5696 | #if defined (ALIAS) | - | ||||||||||||||||||
5697 | if (result == RE_READ_TOKEN) | - | ||||||||||||||||||
5698 | goto re_read_token; | - | ||||||||||||||||||
5699 | #endif | - | ||||||||||||||||||
5700 | return result; | - | ||||||||||||||||||
5701 | } | - | ||||||||||||||||||
5702 | - | |||||||||||||||||||
5703 | /* | - | ||||||||||||||||||
5704 | * Match a $(...) or other grouping construct. This has to handle embedded | - | ||||||||||||||||||
5705 | * quoted strings ('', ``, "") and nested constructs. It also must handle | - | ||||||||||||||||||
5706 | * reprompting the user, if necessary, after reading a newline, and returning | - | ||||||||||||||||||
5707 | * correct error values if it reads EOF. | - | ||||||||||||||||||
5708 | */ | - | ||||||||||||||||||
5709 | #define P_FIRSTCLOSE 0x0001 | - | ||||||||||||||||||
5710 | #define P_ALLOWESC 0x0002 | - | ||||||||||||||||||
5711 | #define P_DQUOTE 0x0004 | - | ||||||||||||||||||
5712 | #define P_COMMAND 0x0008 /* parsing a command, so look for comments */ | - | ||||||||||||||||||
5713 | #define P_BACKQUOTE 0x0010 /* parsing a backquoted command substitution */ | - | ||||||||||||||||||
5714 | #define P_ARRAYSUB 0x0020 /* parsing a [...] array subscript for assignment */ | - | ||||||||||||||||||
5715 | #define P_DOLBRACE 0x0040 /* parsing a ${...} construct */ | - | ||||||||||||||||||
5716 | - | |||||||||||||||||||
5717 | /* Lexical state while parsing a grouping construct or $(...). */ | - | ||||||||||||||||||
5718 | #define LEX_WASDOL 0x0001 | - | ||||||||||||||||||
5719 | #define LEX_CKCOMMENT 0x0002 | - | ||||||||||||||||||
5720 | #define LEX_INCOMMENT 0x0004 | - | ||||||||||||||||||
5721 | #define LEX_PASSNEXT 0x0008 | - | ||||||||||||||||||
5722 | #define LEX_RESWDOK 0x0010 | - | ||||||||||||||||||
5723 | #define LEX_CKCASE 0x0020 | - | ||||||||||||||||||
5724 | #define LEX_INCASE 0x0040 | - | ||||||||||||||||||
5725 | #define LEX_INHEREDOC 0x0080 | - | ||||||||||||||||||
5726 | #define LEX_HEREDELIM 0x0100 /* reading here-doc delimiter */ | - | ||||||||||||||||||
5727 | #define LEX_STRIPDOC 0x0200 /* <<- strip tabs from here doc delim */ | - | ||||||||||||||||||
5728 | #define LEX_QUOTEDDOC 0x0400 /* here doc with quoted delim */ | - | ||||||||||||||||||
5729 | #define LEX_INWORD 0x0800 | - | ||||||||||||||||||
5730 | #define LEX_GTLT 0x1000 | - | ||||||||||||||||||
5731 | - | |||||||||||||||||||
5732 | #define COMSUB_META(ch) ((ch) == ';' || (ch) == '&' || (ch) == '|') | - | ||||||||||||||||||
5733 | - | |||||||||||||||||||
5734 | #define CHECK_NESTRET_ERROR() \ | - | ||||||||||||||||||
5735 | do { \ | - | ||||||||||||||||||
5736 | if (nestret == &matched_pair_error) \ | - | ||||||||||||||||||
5737 | { \ | - | ||||||||||||||||||
5738 | free (ret); \ | - | ||||||||||||||||||
5739 | return &matched_pair_error; \ | - | ||||||||||||||||||
5740 | } \ | - | ||||||||||||||||||
5741 | } while (0) | - | ||||||||||||||||||
5742 | - | |||||||||||||||||||
5743 | #define APPEND_NESTRET() \ | - | ||||||||||||||||||
5744 | do { \ | - | ||||||||||||||||||
5745 | if (nestlen) \ | - | ||||||||||||||||||
5746 | { \ | - | ||||||||||||||||||
5747 | RESIZE_MALLOCED_BUFFER (ret, retind, nestlen, retsize, 64); \ | - | ||||||||||||||||||
5748 | strcpy (ret + retind, nestret); \ | - | ||||||||||||||||||
5749 | retind += nestlen; \ | - | ||||||||||||||||||
5750 | } \ | - | ||||||||||||||||||
5751 | } while (0) | - | ||||||||||||||||||
5752 | - | |||||||||||||||||||
5753 | static char matched_pair_error; | - | ||||||||||||||||||
5754 | - | |||||||||||||||||||
5755 | static char * | - | ||||||||||||||||||
5756 | parse_matched_pair (qc, open, close, lenp, flags) | - | ||||||||||||||||||
5757 | int qc; /* `"' if this construct is within double quotes */ | - | ||||||||||||||||||
5758 | int open, close; | - | ||||||||||||||||||
5759 | int *lenp, flags; | - | ||||||||||||||||||
5760 | { | - | ||||||||||||||||||
5761 | int count, ch, prevch, tflags; | - | ||||||||||||||||||
5762 | int nestlen, ttranslen, start_lineno; | - | ||||||||||||||||||
5763 | char *ret, *nestret, *ttrans; | - | ||||||||||||||||||
5764 | int retind, retsize, rflags; | - | ||||||||||||||||||
5765 | int dolbrace_state; | - | ||||||||||||||||||
5766 | - | |||||||||||||||||||
5767 | dolbrace_state = (flags & P_DOLBRACE) ? DOLBRACE_PARAM : 0; | - | ||||||||||||||||||
5768 | - | |||||||||||||||||||
5769 | /*itrace("parse_matched_pair[%d]: open = %c close = %c flags = %d", line_number, open, close, flags);*/ | - | ||||||||||||||||||
5770 | count = 1; | - | ||||||||||||||||||
5771 | tflags = 0; | - | ||||||||||||||||||
5772 | - | |||||||||||||||||||
5773 | if ((flags & P_COMMAND) && qc != '`' && qc != '\'' && qc != '"' && (flags & P_DQUOTE) == 0) | - | ||||||||||||||||||
5774 | tflags |= LEX_CKCOMMENT; | - | ||||||||||||||||||
5775 | - | |||||||||||||||||||
5776 | /* RFLAGS is the set of flags we want to pass to recursive calls. */ | - | ||||||||||||||||||
5777 | rflags = (qc == '"') ? P_DQUOTE : (flags & P_DQUOTE); | - | ||||||||||||||||||
5778 | - | |||||||||||||||||||
5779 | ret = (char *)xmalloc (retsize = 64); | - | ||||||||||||||||||
5780 | retind = 0; | - | ||||||||||||||||||
5781 | - | |||||||||||||||||||
5782 | start_lineno = line_number; | - | ||||||||||||||||||
5783 | ch = EOF; /* just in case */ | - | ||||||||||||||||||
5784 | while (count) | - | ||||||||||||||||||
5785 | { | - | ||||||||||||||||||
5786 | prevch = ch; | - | ||||||||||||||||||
5787 | ch = shell_getc (qc != '\'' && (tflags & (LEX_PASSNEXT)) == 0); | - | ||||||||||||||||||
5788 | - | |||||||||||||||||||
5789 | if (ch == EOF) | - | ||||||||||||||||||
5790 | { | - | ||||||||||||||||||
5791 | free (ret); | - | ||||||||||||||||||
5792 | parser_error (start_lineno, _("unexpected EOF while looking for matching `%c'"), close); | - | ||||||||||||||||||
5793 | EOF_Reached = 1; /* XXX */ | - | ||||||||||||||||||
5794 | return (&matched_pair_error); | - | ||||||||||||||||||
5795 | } | - | ||||||||||||||||||
5796 | - | |||||||||||||||||||
5797 | /* Possible reprompting. */ | - | ||||||||||||||||||
5798 | if (ch == '\n' && SHOULD_PROMPT ()) | - | ||||||||||||||||||
5799 | prompt_again (); | - | ||||||||||||||||||
5800 | - | |||||||||||||||||||
5801 | /* Don't bother counting parens or doing anything else if in a comment | - | ||||||||||||||||||
5802 | or part of a case statement */ | - | ||||||||||||||||||
5803 | if (tflags & LEX_INCOMMENT) | - | ||||||||||||||||||
5804 | { | - | ||||||||||||||||||
5805 | /* Add this character. */ | - | ||||||||||||||||||
5806 | RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64); | - | ||||||||||||||||||
5807 | ret[retind++] = ch; | - | ||||||||||||||||||
5808 | - | |||||||||||||||||||
5809 | if (ch == '\n') | - | ||||||||||||||||||
5810 | tflags &= ~LEX_INCOMMENT; | - | ||||||||||||||||||
5811 | - | |||||||||||||||||||
5812 | continue; | - | ||||||||||||||||||
5813 | } | - | ||||||||||||||||||
5814 | - | |||||||||||||||||||
5815 | /* Not exactly right yet, should handle shell metacharacters, too. If | - | ||||||||||||||||||
5816 | any changes are made to this test, make analogous changes to subst.c: | - | ||||||||||||||||||
5817 | extract_delimited_string(). */ | - | ||||||||||||||||||
5818 | else if MBTEST((tflags & LEX_CKCOMMENT) && (tflags & LEX_INCOMMENT) == 0 && ch == '#' && (retind == 0 || ret[retind-1] == '\n' || shellblank (ret[retind - 1]))) | - | ||||||||||||||||||
5819 | tflags |= LEX_INCOMMENT; | - | ||||||||||||||||||
5820 | - | |||||||||||||||||||
5821 | if (tflags & LEX_PASSNEXT) /* last char was backslash */ | - | ||||||||||||||||||
5822 | { | - | ||||||||||||||||||
5823 | tflags &= ~LEX_PASSNEXT; | - | ||||||||||||||||||
5824 | if (qc != '\'' && ch == '\n') /* double-quoted \<newline> disappears. */ | - | ||||||||||||||||||
5825 | { | - | ||||||||||||||||||
5826 | if (retind > 0) | - | ||||||||||||||||||
5827 | retind--; /* swallow previously-added backslash */ | - | ||||||||||||||||||
5828 | continue; | - | ||||||||||||||||||
5829 | } | - | ||||||||||||||||||
5830 | - | |||||||||||||||||||
5831 | RESIZE_MALLOCED_BUFFER (ret, retind, 2, retsize, 64); | - | ||||||||||||||||||
5832 | if MBTEST(ch == CTLESC) | - | ||||||||||||||||||
5833 | ret[retind++] = CTLESC; | - | ||||||||||||||||||
5834 | ret[retind++] = ch; | - | ||||||||||||||||||
5835 | continue; | - | ||||||||||||||||||
5836 | } | - | ||||||||||||||||||
5837 | /* If we're reparsing the input (e.g., from parse_string_to_word_list), | - | ||||||||||||||||||
5838 | we've already prepended CTLESC to single-quoted results of $'...'. | - | ||||||||||||||||||
5839 | We may want to do this for other CTLESC-quoted characters in | - | ||||||||||||||||||
5840 | reparse, too. */ | - | ||||||||||||||||||
5841 | else if MBTEST((parser_state & PST_REPARSE) && open == '\'' && (ch == CTLESC || ch == CTLNUL)) | - | ||||||||||||||||||
5842 | { | - | ||||||||||||||||||
5843 | RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64); | - | ||||||||||||||||||
5844 | ret[retind++] = ch; | - | ||||||||||||||||||
5845 | continue; | - | ||||||||||||||||||
5846 | } | - | ||||||||||||||||||
5847 | else if MBTEST(ch == CTLESC || ch == CTLNUL) /* special shell escapes */ | - | ||||||||||||||||||
5848 | { | - | ||||||||||||||||||
5849 | RESIZE_MALLOCED_BUFFER (ret, retind, 2, retsize, 64); | - | ||||||||||||||||||
5850 | ret[retind++] = CTLESC; | - | ||||||||||||||||||
5851 | ret[retind++] = ch; | - | ||||||||||||||||||
5852 | continue; | - | ||||||||||||||||||
5853 | } | - | ||||||||||||||||||
5854 | else if MBTEST(ch == close) /* ending delimiter */ | - | ||||||||||||||||||
5855 | count--; | - | ||||||||||||||||||
5856 | /* handle nested ${...} specially. */ | - | ||||||||||||||||||
5857 | else if MBTEST(open != close && (tflags & LEX_WASDOL) && open == '{' && ch == open) /* } */ | - | ||||||||||||||||||
5858 | count++; | - | ||||||||||||||||||
5859 | else if MBTEST(((flags & P_FIRSTCLOSE) == 0) && ch == open) /* nested begin */ | - | ||||||||||||||||||
5860 | count++; | - | ||||||||||||||||||
5861 | - | |||||||||||||||||||
5862 | /* Add this character. */ | - | ||||||||||||||||||
5863 | RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64); | - | ||||||||||||||||||
5864 | ret[retind++] = ch; | - | ||||||||||||||||||
5865 | - | |||||||||||||||||||
5866 | /* If we just read the ending character, don't bother continuing. */ | - | ||||||||||||||||||
5867 | if (count == 0) | - | ||||||||||||||||||
5868 | break; | - | ||||||||||||||||||
5869 | - | |||||||||||||||||||
5870 | if (open == '\'') /* '' inside grouping construct */ | - | ||||||||||||||||||
5871 | { | - | ||||||||||||||||||
5872 | if MBTEST((flags & P_ALLOWESC) && ch == '\\') | - | ||||||||||||||||||
5873 | tflags |= LEX_PASSNEXT; | - | ||||||||||||||||||
5874 | continue; | - | ||||||||||||||||||
5875 | } | - | ||||||||||||||||||
5876 | - | |||||||||||||||||||
5877 | if MBTEST(ch == '\\') /* backslashes */ | - | ||||||||||||||||||
5878 | tflags |= LEX_PASSNEXT; | - | ||||||||||||||||||
5879 | - | |||||||||||||||||||
5880 | /* Based on which dolstate is currently in (param, op, or word), | - | ||||||||||||||||||
5881 | decide what the op is. We're really only concerned if it's % or | - | ||||||||||||||||||
5882 | #, so we can turn on a flag that says whether or not we should | - | ||||||||||||||||||
5883 | treat single quotes as special when inside a double-quoted | - | ||||||||||||||||||
5884 | ${...}. This logic must agree with subst.c:extract_dollar_brace_string | - | ||||||||||||||||||
5885 | since they share the same defines. */ | - | ||||||||||||||||||
5886 | /* FLAG POSIX INTERP 221 */ | - | ||||||||||||||||||
5887 | if (flags & P_DOLBRACE) | - | ||||||||||||||||||
5888 | { | - | ||||||||||||||||||
5889 | /* ${param%[%]word} */ | - | ||||||||||||||||||
5890 | if MBTEST(dolbrace_state == DOLBRACE_PARAM && ch == '%' && retind > 1) | - | ||||||||||||||||||
5891 | dolbrace_state = DOLBRACE_QUOTE; | - | ||||||||||||||||||
5892 | /* ${param#[#]word} */ | - | ||||||||||||||||||
5893 | else if MBTEST(dolbrace_state == DOLBRACE_PARAM && ch == '#' && retind > 1) | - | ||||||||||||||||||
5894 | dolbrace_state = DOLBRACE_QUOTE; | - | ||||||||||||||||||
5895 | /* ${param/[/]pat/rep} */ | - | ||||||||||||||||||
5896 | else if MBTEST(dolbrace_state == DOLBRACE_PARAM && ch == '/' && retind > 1) | - | ||||||||||||||||||
5897 | dolbrace_state = DOLBRACE_QUOTE2; /* XXX */ | - | ||||||||||||||||||
5898 | /* ${param^[^]pat} */ | - | ||||||||||||||||||
5899 | else if MBTEST(dolbrace_state == DOLBRACE_PARAM && ch == '^' && retind > 1) | - | ||||||||||||||||||
5900 | dolbrace_state = DOLBRACE_QUOTE; | - | ||||||||||||||||||
5901 | /* ${param,[,]pat} */ | - | ||||||||||||||||||
5902 | else if MBTEST(dolbrace_state == DOLBRACE_PARAM && ch == ',' && retind > 1) | - | ||||||||||||||||||
5903 | dolbrace_state = DOLBRACE_QUOTE; | - | ||||||||||||||||||
5904 | else if MBTEST(dolbrace_state == DOLBRACE_PARAM && strchr ("#%^,~:-=?+/", ch) != 0) | - | ||||||||||||||||||
5905 | dolbrace_state = DOLBRACE_OP; | - | ||||||||||||||||||
5906 | else if MBTEST(dolbrace_state == DOLBRACE_OP && strchr ("#%^,~:-=?+/", ch) == 0) | - | ||||||||||||||||||
5907 | dolbrace_state = DOLBRACE_WORD; | - | ||||||||||||||||||
5908 | } | - | ||||||||||||||||||
5909 | - | |||||||||||||||||||
5910 | /* The big hammer. Single quotes aren't special in double quotes. The | - | ||||||||||||||||||
5911 | problem is that Posix used to say the single quotes are semi-special: | - | ||||||||||||||||||
5912 | within a double-quoted ${...} construct "an even number of | - | ||||||||||||||||||
5913 | unescaped double-quotes or single-quotes, if any, shall occur." */ | - | ||||||||||||||||||
5914 | /* This was changed in Austin Group Interp 221 */ | - | ||||||||||||||||||
5915 | if MBTEST(posixly_correct && shell_compatibility_level > 41 && dolbrace_state != DOLBRACE_QUOTE && dolbrace_state != DOLBRACE_QUOTE2 && (flags & P_DQUOTE) && (flags & P_DOLBRACE) && ch == '\'') | - | ||||||||||||||||||
5916 | continue; | - | ||||||||||||||||||
5917 | - | |||||||||||||||||||
5918 | /* Could also check open == '`' if we want to parse grouping constructs | - | ||||||||||||||||||
5919 | inside old-style command substitution. */ | - | ||||||||||||||||||
5920 | if (open != close) /* a grouping construct */ | - | ||||||||||||||||||
5921 | { | - | ||||||||||||||||||
5922 | if MBTEST(shellquote (ch)) | - | ||||||||||||||||||
5923 | { | - | ||||||||||||||||||
5924 | /* '', ``, or "" inside $(...) or other grouping construct. */ | - | ||||||||||||||||||
5925 | push_delimiter (dstack, ch); | - | ||||||||||||||||||
5926 | if MBTEST((tflags & LEX_WASDOL) && ch == '\'') /* $'...' inside group */ | - | ||||||||||||||||||
5927 | nestret = parse_matched_pair (ch, ch, ch, &nestlen, P_ALLOWESC|rflags); | - | ||||||||||||||||||
5928 | else | - | ||||||||||||||||||
5929 | nestret = parse_matched_pair (ch, ch, ch, &nestlen, rflags); | - | ||||||||||||||||||
5930 | pop_delimiter (dstack); | - | ||||||||||||||||||
5931 | CHECK_NESTRET_ERROR (); | - | ||||||||||||||||||
5932 | - | |||||||||||||||||||
5933 | if MBTEST((tflags & LEX_WASDOL) && ch == '\'' && (extended_quote || (rflags & P_DQUOTE) == 0)) | - | ||||||||||||||||||
5934 | { | - | ||||||||||||||||||
5935 | /* Translate $'...' here. */ | - | ||||||||||||||||||
5936 | ttrans = ansiexpand (nestret, 0, nestlen - 1, &ttranslen); | - | ||||||||||||||||||
5937 | free (nestret); | - | ||||||||||||||||||
5938 | - | |||||||||||||||||||
5939 | /* If we're parsing a double-quoted brace expansion and we are | - | ||||||||||||||||||
5940 | not in a place where single quotes are treated specially, | - | ||||||||||||||||||
5941 | make sure we single-quote the results of the ansi | - | ||||||||||||||||||
5942 | expansion because quote removal should remove them later */ | - | ||||||||||||||||||
5943 | /* FLAG POSIX INTERP 221 */ | - | ||||||||||||||||||
5944 | if ((shell_compatibility_level > 42) && (rflags & P_DQUOTE) && (dolbrace_state == DOLBRACE_QUOTE2) && (flags & P_DOLBRACE)) | - | ||||||||||||||||||
5945 | { | - | ||||||||||||||||||
5946 | nestret = sh_single_quote (ttrans); | - | ||||||||||||||||||
5947 | free (ttrans); | - | ||||||||||||||||||
5948 | nestlen = strlen (nestret); | - | ||||||||||||||||||
5949 | } | - | ||||||||||||||||||
5950 | else if ((rflags & P_DQUOTE) == 0) | - | ||||||||||||||||||
5951 | { | - | ||||||||||||||||||
5952 | nestret = sh_single_quote (ttrans); | - | ||||||||||||||||||
5953 | free (ttrans); | - | ||||||||||||||||||
5954 | nestlen = strlen (nestret); | - | ||||||||||||||||||
5955 | } | - | ||||||||||||||||||
5956 | else | - | ||||||||||||||||||
5957 | { | - | ||||||||||||||||||
5958 | nestret = ttrans; | - | ||||||||||||||||||
5959 | nestlen = ttranslen; | - | ||||||||||||||||||
5960 | } | - | ||||||||||||||||||
5961 | retind -= 2; /* back up before the $' */ | - | ||||||||||||||||||
5962 | } | - | ||||||||||||||||||
5963 | else if MBTEST((tflags & LEX_WASDOL) && ch == '"' && (extended_quote || (rflags & P_DQUOTE) == 0)) | - | ||||||||||||||||||
5964 | { | - | ||||||||||||||||||
5965 | /* Locale expand $"..." here. */ | - | ||||||||||||||||||
5966 | ttrans = localeexpand (nestret, 0, nestlen - 1, start_lineno, &ttranslen); | - | ||||||||||||||||||
5967 | free (nestret); | - | ||||||||||||||||||
5968 | - | |||||||||||||||||||
5969 | nestret = sh_mkdoublequoted (ttrans, ttranslen, 0); | - | ||||||||||||||||||
5970 | free (ttrans); | - | ||||||||||||||||||
5971 | nestlen = ttranslen + 2; | - | ||||||||||||||||||
5972 | retind -= 2; /* back up before the $" */ | - | ||||||||||||||||||
5973 | } | - | ||||||||||||||||||
5974 | - | |||||||||||||||||||
5975 | APPEND_NESTRET (); | - | ||||||||||||||||||
5976 | FREE (nestret); | - | ||||||||||||||||||
5977 | } | - | ||||||||||||||||||
5978 | else if ((flags & (P_ARRAYSUB|P_DOLBRACE)) && (tflags & LEX_WASDOL) && (ch == '(' || ch == '{' || ch == '[')) /* ) } ] */ | - | ||||||||||||||||||
5979 | goto parse_dollar_word; | - | ||||||||||||||||||
5980 | #if defined (PROCESS_SUBSTITUTION) | - | ||||||||||||||||||
5981 | /* XXX - technically this should only be recognized at the start of | - | ||||||||||||||||||
5982 | a word */ | - | ||||||||||||||||||
5983 | else if ((flags & (P_ARRAYSUB|P_DOLBRACE)) && (tflags & LEX_GTLT) && (ch == '(')) /* ) */ | - | ||||||||||||||||||
5984 | goto parse_dollar_word; | - | ||||||||||||||||||
5985 | #endif | - | ||||||||||||||||||
5986 | } | - | ||||||||||||||||||
5987 | /* Parse an old-style command substitution within double quotes as a | - | ||||||||||||||||||
5988 | single word. */ | - | ||||||||||||||||||
5989 | /* XXX - sh and ksh93 don't do this - XXX */ | - | ||||||||||||||||||
5990 | else if MBTEST(open == '"' && ch == '`') | - | ||||||||||||||||||
5991 | { | - | ||||||||||||||||||
5992 | nestret = parse_matched_pair (0, '`', '`', &nestlen, rflags); | - | ||||||||||||||||||
5993 | - | |||||||||||||||||||
5994 | CHECK_NESTRET_ERROR (); | - | ||||||||||||||||||
5995 | APPEND_NESTRET (); | - | ||||||||||||||||||
5996 | - | |||||||||||||||||||
5997 | FREE (nestret); | - | ||||||||||||||||||
5998 | } | - | ||||||||||||||||||
5999 | else if MBTEST(open != '`' && (tflags & LEX_WASDOL) && (ch == '(' || ch == '{' || ch == '[')) /* ) } ] */ | - | ||||||||||||||||||
6000 | /* check for $(), $[], or ${} inside quoted string. */ | - | ||||||||||||||||||
6001 | { | - | ||||||||||||||||||
6002 | parse_dollar_word: | - | ||||||||||||||||||
6003 | if (open == ch) /* undo previous increment */ | - | ||||||||||||||||||
6004 | count--; | - | ||||||||||||||||||
6005 | if (ch == '(') /* ) */ | - | ||||||||||||||||||
6006 | nestret = parse_comsub (0, '(', ')', &nestlen, (rflags|P_COMMAND) & ~P_DQUOTE); | - | ||||||||||||||||||
6007 | else if (ch == '{') /* } */ | - | ||||||||||||||||||
6008 | nestret = parse_matched_pair (0, '{', '}', &nestlen, P_FIRSTCLOSE|P_DOLBRACE|rflags); | - | ||||||||||||||||||
6009 | else if (ch == '[') /* ] */ | - | ||||||||||||||||||
6010 | nestret = parse_matched_pair (0, '[', ']', &nestlen, rflags); | - | ||||||||||||||||||
6011 | - | |||||||||||||||||||
6012 | CHECK_NESTRET_ERROR (); | - | ||||||||||||||||||
6013 | APPEND_NESTRET (); | - | ||||||||||||||||||
6014 | - | |||||||||||||||||||
6015 | FREE (nestret); | - | ||||||||||||||||||
6016 | } | - | ||||||||||||||||||
6017 | #if defined (PROCESS_SUBSTITUTION) | - | ||||||||||||||||||
6018 | if MBTEST((ch == '<' || ch == '>') && (tflags & LEX_GTLT) == 0) | - | ||||||||||||||||||
6019 | tflags |= LEX_GTLT; | - | ||||||||||||||||||
6020 | else | - | ||||||||||||||||||
6021 | tflags &= ~LEX_GTLT; | - | ||||||||||||||||||
6022 | #endif | - | ||||||||||||||||||
6023 | if MBTEST(ch == '$' && (tflags & LEX_WASDOL) == 0) | - | ||||||||||||||||||
6024 | tflags |= LEX_WASDOL; | - | ||||||||||||||||||
6025 | else | - | ||||||||||||||||||
6026 | tflags &= ~LEX_WASDOL; | - | ||||||||||||||||||
6027 | } | - | ||||||||||||||||||
6028 | - | |||||||||||||||||||
6029 | ret[retind] = '\0'; | - | ||||||||||||||||||
6030 | if (lenp) | - | ||||||||||||||||||
6031 | *lenp = retind; | - | ||||||||||||||||||
6032 | /*itrace("parse_matched_pair[%d]: returning %s", line_number, ret);*/ | - | ||||||||||||||||||
6033 | return ret; | - | ||||||||||||||||||
6034 | } | - | ||||||||||||||||||
6035 | - | |||||||||||||||||||
6036 | #if defined (DEBUG) | - | ||||||||||||||||||
6037 | static void | - | ||||||||||||||||||
6038 | dump_tflags (flags) | - | ||||||||||||||||||
6039 | int flags; | - | ||||||||||||||||||
6040 | { | - | ||||||||||||||||||
6041 | int f; | - | ||||||||||||||||||
6042 | - | |||||||||||||||||||
6043 | f = flags; | - | ||||||||||||||||||
6044 | fprintf (stderr, "%d -> ", f); | - | ||||||||||||||||||
6045 | if (f & LEX_WASDOL) | - | ||||||||||||||||||
6046 | { | - | ||||||||||||||||||
6047 | f &= ~LEX_WASDOL; | - | ||||||||||||||||||
6048 | fprintf (stderr, "LEX_WASDOL%s", f ? "|" : ""); | - | ||||||||||||||||||
6049 | } | - | ||||||||||||||||||
6050 | if (f & LEX_CKCOMMENT) | - | ||||||||||||||||||
6051 | { | - | ||||||||||||||||||
6052 | f &= ~LEX_CKCOMMENT; | - | ||||||||||||||||||
6053 | fprintf (stderr, "LEX_CKCOMMENT%s", f ? "|" : ""); | - | ||||||||||||||||||
6054 | } | - | ||||||||||||||||||
6055 | if (f & LEX_INCOMMENT) | - | ||||||||||||||||||
6056 | { | - | ||||||||||||||||||
6057 | f &= ~LEX_INCOMMENT; | - | ||||||||||||||||||
6058 | fprintf (stderr, "LEX_INCOMMENT%s", f ? "|" : ""); | - | ||||||||||||||||||
6059 | } | - | ||||||||||||||||||
6060 | if (f & LEX_PASSNEXT) | - | ||||||||||||||||||
6061 | { | - | ||||||||||||||||||
6062 | f &= ~LEX_PASSNEXT; | - | ||||||||||||||||||
6063 | fprintf (stderr, "LEX_PASSNEXT%s", f ? "|" : ""); | - | ||||||||||||||||||
6064 | } | - | ||||||||||||||||||
6065 | if (f & LEX_RESWDOK) | - | ||||||||||||||||||
6066 | { | - | ||||||||||||||||||
6067 | f &= ~LEX_RESWDOK; | - | ||||||||||||||||||
6068 | fprintf (stderr, "LEX_RESWDOK%s", f ? "|" : ""); | - | ||||||||||||||||||
6069 | } | - | ||||||||||||||||||
6070 | if (f & LEX_CKCASE) | - | ||||||||||||||||||
6071 | { | - | ||||||||||||||||||
6072 | f &= ~LEX_CKCASE; | - | ||||||||||||||||||
6073 | fprintf (stderr, "LEX_CKCASE%s", f ? "|" : ""); | - | ||||||||||||||||||
6074 | } | - | ||||||||||||||||||
6075 | if (f & LEX_INCASE) | - | ||||||||||||||||||
6076 | { | - | ||||||||||||||||||
6077 | f &= ~LEX_INCASE; | - | ||||||||||||||||||
6078 | fprintf (stderr, "LEX_INCASE%s", f ? "|" : ""); | - | ||||||||||||||||||
6079 | } | - | ||||||||||||||||||
6080 | if (f & LEX_INHEREDOC) | - | ||||||||||||||||||
6081 | { | - | ||||||||||||||||||
6082 | f &= ~LEX_INHEREDOC; | - | ||||||||||||||||||
6083 | fprintf (stderr, "LEX_INHEREDOC%s", f ? "|" : ""); | - | ||||||||||||||||||
6084 | } | - | ||||||||||||||||||
6085 | if (f & LEX_HEREDELIM) | - | ||||||||||||||||||
6086 | { | - | ||||||||||||||||||
6087 | f &= ~LEX_HEREDELIM; | - | ||||||||||||||||||
6088 | fprintf (stderr, "LEX_HEREDELIM%s", f ? "|" : ""); | - | ||||||||||||||||||
6089 | } | - | ||||||||||||||||||
6090 | if (f & LEX_STRIPDOC) | - | ||||||||||||||||||
6091 | { | - | ||||||||||||||||||
6092 | f &= ~LEX_STRIPDOC; | - | ||||||||||||||||||
6093 | fprintf (stderr, "LEX_WASDOL%s", f ? "|" : ""); | - | ||||||||||||||||||
6094 | } | - | ||||||||||||||||||
6095 | if (f & LEX_QUOTEDDOC) | - | ||||||||||||||||||
6096 | { | - | ||||||||||||||||||
6097 | f &= ~LEX_QUOTEDDOC; | - | ||||||||||||||||||
6098 | fprintf (stderr, "LEX_QUOTEDDOC%s", f ? "|" : ""); | - | ||||||||||||||||||
6099 | } | - | ||||||||||||||||||
6100 | if (f & LEX_INWORD) | - | ||||||||||||||||||
6101 | { | - | ||||||||||||||||||
6102 | f &= ~LEX_INWORD; | - | ||||||||||||||||||
6103 | fprintf (stderr, "LEX_INWORD%s", f ? "|" : ""); | - | ||||||||||||||||||
6104 | } | - | ||||||||||||||||||
6105 | - | |||||||||||||||||||
6106 | fprintf (stderr, "\n"); | - | ||||||||||||||||||
6107 | fflush (stderr); | - | ||||||||||||||||||
6108 | } | - | ||||||||||||||||||
6109 | #endif | - | ||||||||||||||||||
6110 | - | |||||||||||||||||||
6111 | /* Parse a $(...) command substitution. This is messier than I'd like, and | - | ||||||||||||||||||
6112 | reproduces a lot more of the token-reading code than I'd like. */ | - | ||||||||||||||||||
6113 | static char * | - | ||||||||||||||||||
6114 | parse_comsub (qc, open, close, lenp, flags) | - | ||||||||||||||||||
6115 | int qc; /* `"' if this construct is within double quotes */ | - | ||||||||||||||||||
6116 | int open, close; | - | ||||||||||||||||||
6117 | int *lenp, flags; | - | ||||||||||||||||||
6118 | { | - | ||||||||||||||||||
6119 | int count, ch, peekc, tflags, lex_rwlen, lex_wlen, lex_firstind; | - | ||||||||||||||||||
6120 | int nestlen, ttranslen, start_lineno; | - | ||||||||||||||||||
6121 | char *ret, *nestret, *ttrans, *heredelim; | - | ||||||||||||||||||
6122 | int retind, retsize, rflags, hdlen; | - | ||||||||||||||||||
6123 | - | |||||||||||||||||||
6124 | /* Posix interp 217 says arithmetic expressions have precedence, so | - | ||||||||||||||||||
6125 | assume $(( introduces arithmetic expansion and parse accordingly. */ | - | ||||||||||||||||||
6126 | peekc = shell_getc (0); | - | ||||||||||||||||||
6127 | shell_ungetc (peekc); | - | ||||||||||||||||||
6128 | if (peekc == '(') | - | ||||||||||||||||||
6129 | return (parse_matched_pair (qc, open, close, lenp, 0)); | - | ||||||||||||||||||
6130 | - | |||||||||||||||||||
6131 | /*itrace("parse_comsub: qc = `%c' open = %c close = %c", qc, open, close);*/ | - | ||||||||||||||||||
6132 | count = 1; | - | ||||||||||||||||||
6133 | tflags = LEX_RESWDOK; | - | ||||||||||||||||||
6134 | - | |||||||||||||||||||
6135 | if ((flags & P_COMMAND) && qc != '\'' && qc != '"' && (flags & P_DQUOTE) == 0) | - | ||||||||||||||||||
6136 | tflags |= LEX_CKCASE; | - | ||||||||||||||||||
6137 | if ((tflags & LEX_CKCASE) && (interactive == 0 || interactive_comments)) | - | ||||||||||||||||||
6138 | tflags |= LEX_CKCOMMENT; | - | ||||||||||||||||||
6139 | - | |||||||||||||||||||
6140 | /* RFLAGS is the set of flags we want to pass to recursive calls. */ | - | ||||||||||||||||||
6141 | rflags = (flags & P_DQUOTE); | - | ||||||||||||||||||
6142 | - | |||||||||||||||||||
6143 | ret = (char *)xmalloc (retsize = 64); | - | ||||||||||||||||||
6144 | retind = 0; | - | ||||||||||||||||||
6145 | - | |||||||||||||||||||
6146 | start_lineno = line_number; | - | ||||||||||||||||||
6147 | lex_rwlen = lex_wlen = 0; | - | ||||||||||||||||||
6148 | - | |||||||||||||||||||
6149 | heredelim = 0; | - | ||||||||||||||||||
6150 | lex_firstind = -1; | - | ||||||||||||||||||
6151 | - | |||||||||||||||||||
6152 | while (count) | - | ||||||||||||||||||
6153 | { | - | ||||||||||||||||||
6154 | comsub_readchar: | - | ||||||||||||||||||
6155 | ch = shell_getc (qc != '\'' && (tflags & (LEX_INCOMMENT|LEX_PASSNEXT|LEX_QUOTEDDOC)) == 0); | - | ||||||||||||||||||
6156 | - | |||||||||||||||||||
6157 | if (ch == EOF) | - | ||||||||||||||||||
6158 | { | - | ||||||||||||||||||
6159 | eof_error: | - | ||||||||||||||||||
6160 | free (ret); | - | ||||||||||||||||||
6161 | FREE (heredelim); | - | ||||||||||||||||||
6162 | parser_error (start_lineno, _("unexpected EOF while looking for matching `%c'"), close); | - | ||||||||||||||||||
6163 | EOF_Reached = 1; /* XXX */ | - | ||||||||||||||||||
6164 | return (&matched_pair_error); | - | ||||||||||||||||||
6165 | } | - | ||||||||||||||||||
6166 | - | |||||||||||||||||||
6167 | /* If we hit the end of a line and are reading the contents of a here | - | ||||||||||||||||||
6168 | document, and it's not the same line that the document starts on, | - | ||||||||||||||||||
6169 | check for this line being the here doc delimiter. Otherwise, if | - | ||||||||||||||||||
6170 | we're in a here document, mark the next character as the beginning | - | ||||||||||||||||||
6171 | of a line. */ | - | ||||||||||||||||||
6172 | if (ch == '\n') | - | ||||||||||||||||||
6173 | { | - | ||||||||||||||||||
6174 | if ((tflags & LEX_HEREDELIM) && heredelim) | - | ||||||||||||||||||
6175 | { | - | ||||||||||||||||||
6176 | tflags &= ~LEX_HEREDELIM; | - | ||||||||||||||||||
6177 | tflags |= LEX_INHEREDOC; | - | ||||||||||||||||||
6178 | lex_firstind = retind + 1; | - | ||||||||||||||||||
6179 | } | - | ||||||||||||||||||
6180 | else if (tflags & LEX_INHEREDOC) | - | ||||||||||||||||||
6181 | { | - | ||||||||||||||||||
6182 | int tind; | - | ||||||||||||||||||
6183 | tind = lex_firstind; | - | ||||||||||||||||||
6184 | while ((tflags & LEX_STRIPDOC) && ret[tind] == '\t') | - | ||||||||||||||||||
6185 | tind++; | - | ||||||||||||||||||
6186 | if (retind-tind == hdlen && STREQN (ret + tind, heredelim, hdlen)) | - | ||||||||||||||||||
6187 | { | - | ||||||||||||||||||
6188 | tflags &= ~(LEX_STRIPDOC|LEX_INHEREDOC|LEX_QUOTEDDOC); | - | ||||||||||||||||||
6189 | /*itrace("parse_comsub:%d: found here doc end `%s'", line_number, ret + tind);*/ | - | ||||||||||||||||||
6190 | free (heredelim); | - | ||||||||||||||||||
6191 | heredelim = 0; | - | ||||||||||||||||||
6192 | lex_firstind = -1; | - | ||||||||||||||||||
6193 | } | - | ||||||||||||||||||
6194 | else | - | ||||||||||||||||||
6195 | lex_firstind = retind + 1; | - | ||||||||||||||||||
6196 | } | - | ||||||||||||||||||
6197 | } | - | ||||||||||||||||||
6198 | - | |||||||||||||||||||
6199 | /* Possible reprompting. */ | - | ||||||||||||||||||
6200 | if (ch == '\n' && SHOULD_PROMPT ()) | - | ||||||||||||||||||
6201 | prompt_again (); | - | ||||||||||||||||||
6202 | - | |||||||||||||||||||
6203 | /* XXX -- possibly allow here doc to be delimited by ending right | - | ||||||||||||||||||
6204 | paren. */ | - | ||||||||||||||||||
6205 | if ((tflags & LEX_INHEREDOC) && ch == close && count == 1) | - | ||||||||||||||||||
6206 | { | - | ||||||||||||||||||
6207 | int tind; | - | ||||||||||||||||||
6208 | /*itrace("parse_comsub:%d: in here doc, ch == close, retind - firstind = %d hdlen = %d retind = %d", line_number, retind-lex_firstind, hdlen, retind);*/ | - | ||||||||||||||||||
6209 | tind = lex_firstind; | - | ||||||||||||||||||
6210 | while ((tflags & LEX_STRIPDOC) && ret[tind] == '\t') | - | ||||||||||||||||||
6211 | tind++; | - | ||||||||||||||||||
6212 | if (retind-tind == hdlen && STREQN (ret + tind, heredelim, hdlen)) | - | ||||||||||||||||||
6213 | { | - | ||||||||||||||||||
6214 | tflags &= ~(LEX_STRIPDOC|LEX_INHEREDOC|LEX_QUOTEDDOC); | - | ||||||||||||||||||
6215 | /*itrace("parse_comsub:%d: found here doc end `%*s'", line_number, hdlen, ret + tind);*/ | - | ||||||||||||||||||
6216 | free (heredelim); | - | ||||||||||||||||||
6217 | heredelim = 0; | - | ||||||||||||||||||
6218 | lex_firstind = -1; | - | ||||||||||||||||||
6219 | } | - | ||||||||||||||||||
6220 | } | - | ||||||||||||||||||
6221 | - | |||||||||||||||||||
6222 | /* Don't bother counting parens or doing anything else if in a comment or | - | ||||||||||||||||||
6223 | here document (not exactly right for here-docs -- if we want to allow | - | ||||||||||||||||||
6224 | recursive calls to parse_comsub to have their own here documents, | - | ||||||||||||||||||
6225 | change the LEX_INHEREDOC to LEX_QUOTEDDOC here and uncomment the next | - | ||||||||||||||||||
6226 | clause below. Note that to make this work completely, we need to make | - | ||||||||||||||||||
6227 | additional changes to allow xparse_dolparen to work right when the | - | ||||||||||||||||||
6228 | command substitution is parsed, because read_secondary_line doesn't know | - | ||||||||||||||||||
6229 | to recursively parse through command substitutions embedded in here- | - | ||||||||||||||||||
6230 | documents */ | - | ||||||||||||||||||
6231 | if (tflags & (LEX_INCOMMENT|LEX_INHEREDOC)) | - | ||||||||||||||||||
6232 | { | - | ||||||||||||||||||
6233 | /* Add this character. */ | - | ||||||||||||||||||
6234 | RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64); | - | ||||||||||||||||||
6235 | ret[retind++] = ch; | - | ||||||||||||||||||
6236 | - | |||||||||||||||||||
6237 | if ((tflags & LEX_INCOMMENT) && ch == '\n') | - | ||||||||||||||||||
6238 | { | - | ||||||||||||||||||
6239 | /*itrace("parse_comsub:%d: lex_incomment -> 0 ch = `%c'", line_number, ch);*/ | - | ||||||||||||||||||
6240 | tflags &= ~LEX_INCOMMENT; | - | ||||||||||||||||||
6241 | } | - | ||||||||||||||||||
6242 | - | |||||||||||||||||||
6243 | continue; | - | ||||||||||||||||||
6244 | } | - | ||||||||||||||||||
6245 | #if 0 | - | ||||||||||||||||||
6246 | /* If we're going to recursively parse a command substitution inside a | - | ||||||||||||||||||
6247 | here-document, make sure we call parse_comsub recursively below. See | - | ||||||||||||||||||
6248 | above for additional caveats. */ | - | ||||||||||||||||||
6249 | if ((tflags & LEX_INHEREDOC) && ((tflags & LEX_WASDOL) == 0 || ch != '(')) /*)*/ | - | ||||||||||||||||||
6250 | { | - | ||||||||||||||||||
6251 | /* Add this character. */ | - | ||||||||||||||||||
6252 | RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64); | - | ||||||||||||||||||
6253 | ret[retind++] = ch; | - | ||||||||||||||||||
6254 | if MBTEST(ch == '$') | - | ||||||||||||||||||
6255 | tflags |= LEX_WASDOL; | - | ||||||||||||||||||
6256 | else | - | ||||||||||||||||||
6257 | tflags &= ~LEX_WASDOL; | - | ||||||||||||||||||
6258 | } | - | ||||||||||||||||||
6259 | #endif | - | ||||||||||||||||||
6260 | - | |||||||||||||||||||
6261 | if (tflags & LEX_PASSNEXT) /* last char was backslash */ | - | ||||||||||||||||||
6262 | { | - | ||||||||||||||||||
6263 | /*itrace("parse_comsub:%d: lex_passnext -> 0 ch = `%c' (%d)", line_number, ch, __LINE__);*/ | - | ||||||||||||||||||
6264 | tflags &= ~LEX_PASSNEXT; | - | ||||||||||||||||||
6265 | if (qc != '\'' && ch == '\n') /* double-quoted \<newline> disappears. */ | - | ||||||||||||||||||
6266 | { | - | ||||||||||||||||||
6267 | if (retind > 0) | - | ||||||||||||||||||
6268 | retind--; /* swallow previously-added backslash */ | - | ||||||||||||||||||
6269 | continue; | - | ||||||||||||||||||
6270 | } | - | ||||||||||||||||||
6271 | - | |||||||||||||||||||
6272 | RESIZE_MALLOCED_BUFFER (ret, retind, 2, retsize, 64); | - | ||||||||||||||||||
6273 | if MBTEST(ch == CTLESC) | - | ||||||||||||||||||
6274 | ret[retind++] = CTLESC; | - | ||||||||||||||||||
6275 | ret[retind++] = ch; | - | ||||||||||||||||||
6276 | continue; | - | ||||||||||||||||||
6277 | } | - | ||||||||||||||||||
6278 | - | |||||||||||||||||||
6279 | /* If this is a shell break character, we are not in a word. If not, | - | ||||||||||||||||||
6280 | we either start or continue a word. */ | - | ||||||||||||||||||
6281 | if MBTEST(shellbreak (ch)) | - | ||||||||||||||||||
6282 | { | - | ||||||||||||||||||
6283 | tflags &= ~LEX_INWORD; | - | ||||||||||||||||||
6284 | /*itrace("parse_comsub:%d: lex_inword -> 0 ch = `%c' (%d)", line_number, ch, __LINE__);*/ | - | ||||||||||||||||||
6285 | } | - | ||||||||||||||||||
6286 | else | - | ||||||||||||||||||
6287 | { | - | ||||||||||||||||||
6288 | if (tflags & LEX_INWORD) | - | ||||||||||||||||||
6289 | { | - | ||||||||||||||||||
6290 | lex_wlen++; | - | ||||||||||||||||||
6291 | /*itrace("parse_comsub:%d: lex_inword == 1 ch = `%c' lex_wlen = %d (%d)", line_number, ch, lex_wlen, __LINE__);*/ | - | ||||||||||||||||||
6292 | } | - | ||||||||||||||||||
6293 | else | - | ||||||||||||||||||
6294 | { | - | ||||||||||||||||||
6295 | /*itrace("parse_comsub:%d: lex_inword -> 1 ch = `%c' (%d)", line_number, ch, __LINE__);*/ | - | ||||||||||||||||||
6296 | tflags |= LEX_INWORD; | - | ||||||||||||||||||
6297 | lex_wlen = 0; | - | ||||||||||||||||||
6298 | if (tflags & LEX_RESWDOK) | - | ||||||||||||||||||
6299 | lex_rwlen = 0; | - | ||||||||||||||||||
6300 | } | - | ||||||||||||||||||
6301 | } | - | ||||||||||||||||||
6302 | - | |||||||||||||||||||
6303 | /* Skip whitespace */ | - | ||||||||||||||||||
6304 | if MBTEST(shellblank (ch) && (tflags & LEX_HEREDELIM) == 0 && lex_rwlen == 0) | - | ||||||||||||||||||
6305 | { | - | ||||||||||||||||||
6306 | /* Add this character. */ | - | ||||||||||||||||||
6307 | RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64); | - | ||||||||||||||||||
6308 | ret[retind++] = ch; | - | ||||||||||||||||||
6309 | continue; | - | ||||||||||||||||||
6310 | } | - | ||||||||||||||||||
6311 | - | |||||||||||||||||||
6312 | /* Either we are looking for the start of the here-doc delimiter | - | ||||||||||||||||||
6313 | (lex_firstind == -1) or we are reading one (lex_firstind >= 0). | - | ||||||||||||||||||
6314 | If this character is a shell break character and we are reading | - | ||||||||||||||||||
6315 | the delimiter, save it and note that we are now reading a here | - | ||||||||||||||||||
6316 | document. If we've found the start of the delimiter, note it by | - | ||||||||||||||||||
6317 | setting lex_firstind. Backslashes can quote shell metacharacters | - | ||||||||||||||||||
6318 | in here-doc delimiters. */ | - | ||||||||||||||||||
6319 | if (tflags & LEX_HEREDELIM) | - | ||||||||||||||||||
6320 | { | - | ||||||||||||||||||
6321 | if (lex_firstind == -1 && shellbreak (ch) == 0) | - | ||||||||||||||||||
6322 | lex_firstind = retind; | - | ||||||||||||||||||
6323 | #if 0 | - | ||||||||||||||||||
6324 | else if (heredelim && (tflags & LEX_PASSNEXT) == 0 && ch == '\n') | - | ||||||||||||||||||
6325 | { | - | ||||||||||||||||||
6326 | tflags |= LEX_INHEREDOC; | - | ||||||||||||||||||
6327 | tflags &= ~LEX_HEREDELIM; | - | ||||||||||||||||||
6328 | lex_firstind = retind + 1; | - | ||||||||||||||||||
6329 | } | - | ||||||||||||||||||
6330 | #endif | - | ||||||||||||||||||
6331 | else if (lex_firstind >= 0 && (tflags & LEX_PASSNEXT) == 0 && shellbreak (ch)) | - | ||||||||||||||||||
6332 | { | - | ||||||||||||||||||
6333 | if (heredelim == 0) | - | ||||||||||||||||||
6334 | { | - | ||||||||||||||||||
6335 | nestret = substring (ret, lex_firstind, retind); | - | ||||||||||||||||||
6336 | heredelim = string_quote_removal (nestret, 0); | - | ||||||||||||||||||
6337 | hdlen = STRLEN(heredelim); | - | ||||||||||||||||||
6338 | /*itrace("parse_comsub:%d: found here doc delimiter `%s' (%d)", line_number, heredelim, hdlen);*/ | - | ||||||||||||||||||
6339 | if (STREQ (heredelim, nestret) == 0) | - | ||||||||||||||||||
6340 | tflags |= LEX_QUOTEDDOC; | - | ||||||||||||||||||
6341 | free (nestret); | - | ||||||||||||||||||
6342 | } | - | ||||||||||||||||||
6343 | if (ch == '\n') | - | ||||||||||||||||||
6344 | { | - | ||||||||||||||||||
6345 | tflags |= LEX_INHEREDOC; | - | ||||||||||||||||||
6346 | tflags &= ~LEX_HEREDELIM; | - | ||||||||||||||||||
6347 | lex_firstind = retind + 1; | - | ||||||||||||||||||
6348 | } | - | ||||||||||||||||||
6349 | else | - | ||||||||||||||||||
6350 | lex_firstind = -1; | - | ||||||||||||||||||
6351 | } | - | ||||||||||||||||||
6352 | } | - | ||||||||||||||||||
6353 | - | |||||||||||||||||||
6354 | /* Meta-characters that can introduce a reserved word. Not perfect yet. */ | - | ||||||||||||||||||
6355 | if MBTEST((tflags & LEX_RESWDOK) == 0 && (tflags & LEX_CKCASE) && (tflags & LEX_INCOMMENT) == 0 && (shellmeta(ch) || ch == '\n')) | - | ||||||||||||||||||
6356 | { | - | ||||||||||||||||||
6357 | /* Add this character. */ | - | ||||||||||||||||||
6358 | RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64); | - | ||||||||||||||||||
6359 | ret[retind++] = ch; | - | ||||||||||||||||||
6360 | peekc = shell_getc (1); | - | ||||||||||||||||||
6361 | if (ch == peekc && (ch == '&' || ch == '|' || ch == ';')) /* two-character tokens */ | - | ||||||||||||||||||
6362 | { | - | ||||||||||||||||||
6363 | RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64); | - | ||||||||||||||||||
6364 | ret[retind++] = peekc; | - | ||||||||||||||||||
6365 | /*itrace("parse_comsub:%d: set lex_reswordok = 1, ch = `%c'", line_number, ch);*/ | - | ||||||||||||||||||
6366 | tflags |= LEX_RESWDOK; | - | ||||||||||||||||||
6367 | lex_rwlen = 0; | - | ||||||||||||||||||
6368 | continue; | - | ||||||||||||||||||
6369 | } | - | ||||||||||||||||||
6370 | else if (ch == '\n' || COMSUB_META(ch)) | - | ||||||||||||||||||
6371 | { | - | ||||||||||||||||||
6372 | shell_ungetc (peekc); | - | ||||||||||||||||||
6373 | /*itrace("parse_comsub:%d: set lex_reswordok = 1, ch = `%c'", line_number, ch);*/ | - | ||||||||||||||||||
6374 | tflags |= LEX_RESWDOK; | - | ||||||||||||||||||
6375 | lex_rwlen = 0; | - | ||||||||||||||||||
6376 | continue; | - | ||||||||||||||||||
6377 | } | - | ||||||||||||||||||
6378 | else if (ch == EOF) | - | ||||||||||||||||||
6379 | goto eof_error; | - | ||||||||||||||||||
6380 | else | - | ||||||||||||||||||
6381 | { | - | ||||||||||||||||||
6382 | /* `unget' the character we just added and fall through */ | - | ||||||||||||||||||
6383 | retind--; | - | ||||||||||||||||||
6384 | shell_ungetc (peekc); | - | ||||||||||||||||||
6385 | } | - | ||||||||||||||||||
6386 | } | - | ||||||||||||||||||
6387 | - | |||||||||||||||||||
6388 | /* If we can read a reserved word, try to read one. */ | - | ||||||||||||||||||
6389 | if (tflags & LEX_RESWDOK) | - | ||||||||||||||||||
6390 | { | - | ||||||||||||||||||
6391 | if MBTEST(islower ((unsigned char)ch)) | - | ||||||||||||||||||
6392 | { | - | ||||||||||||||||||
6393 | /* Add this character. */ | - | ||||||||||||||||||
6394 | RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64); | - | ||||||||||||||||||
6395 | ret[retind++] = ch; | - | ||||||||||||||||||
6396 | lex_rwlen++; | - | ||||||||||||||||||
6397 | continue; | - | ||||||||||||||||||
6398 | } | - | ||||||||||||||||||
6399 | else if MBTEST(lex_rwlen == 4 && shellbreak (ch)) | - | ||||||||||||||||||
6400 | { | - | ||||||||||||||||||
6401 | if (STREQN (ret + retind - 4, "case", 4)) | - | ||||||||||||||||||
6402 | { | - | ||||||||||||||||||
6403 | tflags |= LEX_INCASE; | - | ||||||||||||||||||
6404 | tflags &= ~LEX_RESWDOK; | - | ||||||||||||||||||
6405 | /*itrace("parse_comsub:%d: found `case', lex_incase -> 1 lex_reswdok -> 0", line_number);*/ | - | ||||||||||||||||||
6406 | } | - | ||||||||||||||||||
6407 | else if (STREQN (ret + retind - 4, "esac", 4)) | - | ||||||||||||||||||
6408 | { | - | ||||||||||||||||||
6409 | tflags &= ~LEX_INCASE; | - | ||||||||||||||||||
6410 | /*itrace("parse_comsub:%d: found `esac', lex_incase -> 0 lex_reswdok -> 1", line_number);*/ | - | ||||||||||||||||||
6411 | tflags |= LEX_RESWDOK; | - | ||||||||||||||||||
6412 | lex_rwlen = 0; | - | ||||||||||||||||||
6413 | } | - | ||||||||||||||||||
6414 | else if (STREQN (ret + retind - 4, "done", 4) || | - | ||||||||||||||||||
6415 | STREQN (ret + retind - 4, "then", 4) || | - | ||||||||||||||||||
6416 | STREQN (ret + retind - 4, "else", 4) || | - | ||||||||||||||||||
6417 | STREQN (ret + retind - 4, "elif", 4) || | - | ||||||||||||||||||
6418 | STREQN (ret + retind - 4, "time", 4)) | - | ||||||||||||||||||
6419 | { | - | ||||||||||||||||||
6420 | /* these are four-character reserved words that can be | - | ||||||||||||||||||
6421 | followed by a reserved word; anything else turns off | - | ||||||||||||||||||
6422 | the reserved-word-ok flag */ | - | ||||||||||||||||||
6423 | /*itrace("parse_comsub:%d: found `%.4s', lex_reswdok -> 1", line_number, ret+retind-4);*/ | - | ||||||||||||||||||
6424 | tflags |= LEX_RESWDOK; | - | ||||||||||||||||||
6425 | lex_rwlen = 0; | - | ||||||||||||||||||
6426 | } | - | ||||||||||||||||||
6427 | else if (shellmeta (ch) == 0) | - | ||||||||||||||||||
6428 | { | - | ||||||||||||||||||
6429 | tflags &= ~LEX_RESWDOK; | - | ||||||||||||||||||
6430 | /*itrace("parse_comsub:%d: found `%.4s', lex_reswdok -> 0", line_number, ret+retind-4);*/ | - | ||||||||||||||||||
6431 | } | - | ||||||||||||||||||
6432 | else /* can't be in a reserved word any more */ | - | ||||||||||||||||||
6433 | lex_rwlen = 0; | - | ||||||||||||||||||
6434 | } | - | ||||||||||||||||||
6435 | else if MBTEST((tflags & LEX_CKCOMMENT) && ch == '#' && (lex_rwlen == 0 || ((tflags & LEX_INWORD) && lex_wlen == 0))) | - | ||||||||||||||||||
6436 | ; /* don't modify LEX_RESWDOK if we're starting a comment */ | - | ||||||||||||||||||
6437 | /* Allow `do' followed by space, tab, or newline to preserve the | - | ||||||||||||||||||
6438 | RESWDOK flag, but reset the reserved word length counter so we | - | ||||||||||||||||||
6439 | can read another one. */ | - | ||||||||||||||||||
6440 | else if MBTEST(((tflags & LEX_INCASE) == 0) && | - | ||||||||||||||||||
6441 | (isblank((unsigned char)ch) || ch == '\n') && | - | ||||||||||||||||||
6442 | lex_rwlen == 2 && | - | ||||||||||||||||||
6443 | STREQN (ret + retind - 2, "do", 2)) | - | ||||||||||||||||||
6444 | { | - | ||||||||||||||||||
6445 | /*itrace("parse_comsub:%d: lex_incase == 0 found `%c', found \"do\"", line_number, ch);*/ | - | ||||||||||||||||||
6446 | lex_rwlen = 0; | - | ||||||||||||||||||
6447 | } | - | ||||||||||||||||||
6448 | else if MBTEST((tflags & LEX_INCASE) && ch != '\n') | - | ||||||||||||||||||
6449 | /* If we can read a reserved word and we're in case, we're at the | - | ||||||||||||||||||
6450 | point where we can read a new pattern list or an esac. We | - | ||||||||||||||||||
6451 | handle the esac case above. If we read a newline, we want to | - | ||||||||||||||||||
6452 | leave LEX_RESWDOK alone. If we read anything else, we want to | - | ||||||||||||||||||
6453 | turn off LEX_RESWDOK, since we're going to read a pattern list. */ | - | ||||||||||||||||||
6454 | { | - | ||||||||||||||||||
6455 | tflags &= ~LEX_RESWDOK; | - | ||||||||||||||||||
6456 | /*itrace("parse_comsub:%d: lex_incase == 1 found `%c', lex_reswordok -> 0", line_number, ch);*/ | - | ||||||||||||||||||
6457 | } | - | ||||||||||||||||||
6458 | else if MBTEST(shellbreak (ch) == 0) | - | ||||||||||||||||||
6459 | { | - | ||||||||||||||||||
6460 | tflags &= ~LEX_RESWDOK; | - | ||||||||||||||||||
6461 | /*itrace("parse_comsub:%d: found `%c', lex_reswordok -> 0", line_number, ch);*/ | - | ||||||||||||||||||
6462 | } | - | ||||||||||||||||||
6463 | #if 0 | - | ||||||||||||||||||
6464 | /* If we find a space or tab but have read something and it's not | - | ||||||||||||||||||
6465 | `do', turn off the reserved-word-ok flag */ | - | ||||||||||||||||||
6466 | else if MBTEST(isblank ((unsigned char)ch) && lex_rwlen > 0) | - | ||||||||||||||||||
6467 | { | - | ||||||||||||||||||
6468 | tflags &= ~LEX_RESWDOK; | - | ||||||||||||||||||
6469 | /*itrace("parse_comsub:%d: found `%c', lex_reswordok -> 0", line_number, ch);*/ | - | ||||||||||||||||||
6470 | } | - | ||||||||||||||||||
6471 | #endif | - | ||||||||||||||||||
6472 | } | - | ||||||||||||||||||
6473 | - | |||||||||||||||||||
6474 | /* Might be the start of a here-doc delimiter */ | - | ||||||||||||||||||
6475 | if MBTEST((tflags & LEX_INCOMMENT) == 0 && (tflags & LEX_CKCASE) && ch == '<') | - | ||||||||||||||||||
6476 | { | - | ||||||||||||||||||
6477 | /* Add this character. */ | - | ||||||||||||||||||
6478 | RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64); | - | ||||||||||||||||||
6479 | ret[retind++] = ch; | - | ||||||||||||||||||
6480 | peekc = shell_getc (1); | - | ||||||||||||||||||
6481 | if (peekc == EOF) | - | ||||||||||||||||||
6482 | goto eof_error; | - | ||||||||||||||||||
6483 | if (peekc == ch) | - | ||||||||||||||||||
6484 | { | - | ||||||||||||||||||
6485 | RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64); | - | ||||||||||||||||||
6486 | ret[retind++] = peekc; | - | ||||||||||||||||||
6487 | peekc = shell_getc (1); | - | ||||||||||||||||||
6488 | if (peekc == EOF) | - | ||||||||||||||||||
6489 | goto eof_error; | - | ||||||||||||||||||
6490 | if (peekc == '-') | - | ||||||||||||||||||
6491 | { | - | ||||||||||||||||||
6492 | RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64); | - | ||||||||||||||||||
6493 | ret[retind++] = peekc; | - | ||||||||||||||||||
6494 | tflags |= LEX_STRIPDOC; | - | ||||||||||||||||||
6495 | } | - | ||||||||||||||||||
6496 | else | - | ||||||||||||||||||
6497 | shell_ungetc (peekc); | - | ||||||||||||||||||
6498 | if (peekc != '<') | - | ||||||||||||||||||
6499 | { | - | ||||||||||||||||||
6500 | tflags |= LEX_HEREDELIM; | - | ||||||||||||||||||
6501 | lex_firstind = -1; | - | ||||||||||||||||||
6502 | } | - | ||||||||||||||||||
6503 | continue; | - | ||||||||||||||||||
6504 | } | - | ||||||||||||||||||
6505 | else | - | ||||||||||||||||||
6506 | { | - | ||||||||||||||||||
6507 | shell_ungetc (peekc); /* not a here-doc, start over */ | - | ||||||||||||||||||
6508 | continue; | - | ||||||||||||||||||
6509 | } | - | ||||||||||||||||||
6510 | } | - | ||||||||||||||||||
6511 | else if MBTEST((tflags & LEX_CKCOMMENT) && (tflags & LEX_INCOMMENT) == 0 && ch == '#' && (((tflags & LEX_RESWDOK) && lex_rwlen == 0) || ((tflags & LEX_INWORD) && lex_wlen == 0))) | - | ||||||||||||||||||
6512 | { | - | ||||||||||||||||||
6513 | /*itrace("parse_comsub:%d: lex_incomment -> 1 (%d)", line_number, __LINE__);*/ | - | ||||||||||||||||||
6514 | tflags |= LEX_INCOMMENT; | - | ||||||||||||||||||
6515 | } | - | ||||||||||||||||||
6516 | - | |||||||||||||||||||
6517 | if MBTEST(ch == CTLESC || ch == CTLNUL) /* special shell escapes */ | - | ||||||||||||||||||
6518 | { | - | ||||||||||||||||||
6519 | RESIZE_MALLOCED_BUFFER (ret, retind, 2, retsize, 64); | - | ||||||||||||||||||
6520 | ret[retind++] = CTLESC; | - | ||||||||||||||||||
6521 | ret[retind++] = ch; | - | ||||||||||||||||||
6522 | continue; | - | ||||||||||||||||||
6523 | } | - | ||||||||||||||||||
6524 | #if 0 | - | ||||||||||||||||||
6525 | else if MBTEST((tflags & LEX_INCASE) && ch == close && close == ')') | - | ||||||||||||||||||
6526 | tflags &= ~LEX_INCASE; /* XXX */ | - | ||||||||||||||||||
6527 | #endif | - | ||||||||||||||||||
6528 | else if MBTEST(ch == close && (tflags & LEX_INCASE) == 0) /* ending delimiter */ | - | ||||||||||||||||||
6529 | { | - | ||||||||||||||||||
6530 | count--; | - | ||||||||||||||||||
6531 | /*itrace("parse_comsub:%d: found close: count = %d", line_number, count);*/ | - | ||||||||||||||||||
6532 | } | - | ||||||||||||||||||
6533 | else if MBTEST(((flags & P_FIRSTCLOSE) == 0) && (tflags & LEX_INCASE) == 0 && ch == open) /* nested begin */ | - | ||||||||||||||||||
6534 | { | - | ||||||||||||||||||
6535 | count++; | - | ||||||||||||||||||
6536 | /*itrace("parse_comsub:%d: found open: count = %d", line_number, count);*/ | - | ||||||||||||||||||
6537 | } | - | ||||||||||||||||||
6538 | - | |||||||||||||||||||
6539 | /* Add this character. */ | - | ||||||||||||||||||
6540 | RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64); | - | ||||||||||||||||||
6541 | ret[retind++] = ch; | - | ||||||||||||||||||
6542 | - | |||||||||||||||||||
6543 | /* If we just read the ending character, don't bother continuing. */ | - | ||||||||||||||||||
6544 | if (count == 0) | - | ||||||||||||||||||
6545 | break; | - | ||||||||||||||||||
6546 | - | |||||||||||||||||||
6547 | if MBTEST(ch == '\\') /* backslashes */ | - | ||||||||||||||||||
6548 | tflags |= LEX_PASSNEXT; | - | ||||||||||||||||||
6549 | - | |||||||||||||||||||
6550 | if MBTEST(shellquote (ch)) | - | ||||||||||||||||||
6551 | { | - | ||||||||||||||||||
6552 | /* '', ``, or "" inside $(...). */ | - | ||||||||||||||||||
6553 | push_delimiter (dstack, ch); | - | ||||||||||||||||||
6554 | if MBTEST((tflags & LEX_WASDOL) && ch == '\'') /* $'...' inside group */ | - | ||||||||||||||||||
6555 | nestret = parse_matched_pair (ch, ch, ch, &nestlen, P_ALLOWESC|rflags); | - | ||||||||||||||||||
6556 | else | - | ||||||||||||||||||
6557 | nestret = parse_matched_pair (ch, ch, ch, &nestlen, rflags); | - | ||||||||||||||||||
6558 | pop_delimiter (dstack); | - | ||||||||||||||||||
6559 | CHECK_NESTRET_ERROR (); | - | ||||||||||||||||||
6560 | - | |||||||||||||||||||
6561 | if MBTEST((tflags & LEX_WASDOL) && ch == '\'' && (extended_quote || (rflags & P_DQUOTE) == 0)) | - | ||||||||||||||||||
6562 | { | - | ||||||||||||||||||
6563 | /* Translate $'...' here. */ | - | ||||||||||||||||||
6564 | ttrans = ansiexpand (nestret, 0, nestlen - 1, &ttranslen); | - | ||||||||||||||||||
6565 | free (nestret); | - | ||||||||||||||||||
6566 | - | |||||||||||||||||||
6567 | if ((rflags & P_DQUOTE) == 0) | - | ||||||||||||||||||
6568 | { | - | ||||||||||||||||||
6569 | nestret = sh_single_quote (ttrans); | - | ||||||||||||||||||
6570 | free (ttrans); | - | ||||||||||||||||||
6571 | nestlen = strlen (nestret); | - | ||||||||||||||||||
6572 | } | - | ||||||||||||||||||
6573 | else | - | ||||||||||||||||||
6574 | { | - | ||||||||||||||||||
6575 | nestret = ttrans; | - | ||||||||||||||||||
6576 | nestlen = ttranslen; | - | ||||||||||||||||||
6577 | } | - | ||||||||||||||||||
6578 | retind -= 2; /* back up before the $' */ | - | ||||||||||||||||||
6579 | } | - | ||||||||||||||||||
6580 | else if MBTEST((tflags & LEX_WASDOL) && ch == '"' && (extended_quote || (rflags & P_DQUOTE) == 0)) | - | ||||||||||||||||||
6581 | { | - | ||||||||||||||||||
6582 | /* Locale expand $"..." here. */ | - | ||||||||||||||||||
6583 | ttrans = localeexpand (nestret, 0, nestlen - 1, start_lineno, &ttranslen); | - | ||||||||||||||||||
6584 | free (nestret); | - | ||||||||||||||||||
6585 | - | |||||||||||||||||||
6586 | nestret = sh_mkdoublequoted (ttrans, ttranslen, 0); | - | ||||||||||||||||||
6587 | free (ttrans); | - | ||||||||||||||||||
6588 | nestlen = ttranslen + 2; | - | ||||||||||||||||||
6589 | retind -= 2; /* back up before the $" */ | - | ||||||||||||||||||
6590 | } | - | ||||||||||||||||||
6591 | - | |||||||||||||||||||
6592 | APPEND_NESTRET (); | - | ||||||||||||||||||
6593 | FREE (nestret); | - | ||||||||||||||||||
6594 | } | - | ||||||||||||||||||
6595 | else if MBTEST((tflags & LEX_WASDOL) && (ch == '(' || ch == '{' || ch == '[')) /* ) } ] */ | - | ||||||||||||||||||
6596 | /* check for $(), $[], or ${} inside command substitution. */ | - | ||||||||||||||||||
6597 | { | - | ||||||||||||||||||
6598 | if ((tflags & LEX_INCASE) == 0 && open == ch) /* undo previous increment */ | - | ||||||||||||||||||
6599 | count--; | - | ||||||||||||||||||
6600 | if (ch == '(') /* ) */ | - | ||||||||||||||||||
6601 | nestret = parse_comsub (0, '(', ')', &nestlen, (rflags|P_COMMAND) & ~P_DQUOTE); | - | ||||||||||||||||||
6602 | else if (ch == '{') /* } */ | - | ||||||||||||||||||
6603 | nestret = parse_matched_pair (0, '{', '}', &nestlen, P_FIRSTCLOSE|P_DOLBRACE|rflags); | - | ||||||||||||||||||
6604 | else if (ch == '[') /* ] */ | - | ||||||||||||||||||
6605 | nestret = parse_matched_pair (0, '[', ']', &nestlen, rflags); | - | ||||||||||||||||||
6606 | - | |||||||||||||||||||
6607 | CHECK_NESTRET_ERROR (); | - | ||||||||||||||||||
6608 | APPEND_NESTRET (); | - | ||||||||||||||||||
6609 | - | |||||||||||||||||||
6610 | FREE (nestret); | - | ||||||||||||||||||
6611 | } | - | ||||||||||||||||||
6612 | if MBTEST(ch == '$' && (tflags & LEX_WASDOL) == 0) | - | ||||||||||||||||||
6613 | tflags |= LEX_WASDOL; | - | ||||||||||||||||||
6614 | else | - | ||||||||||||||||||
6615 | tflags &= ~LEX_WASDOL; | - | ||||||||||||||||||
6616 | } | - | ||||||||||||||||||
6617 | - | |||||||||||||||||||
6618 | FREE (heredelim); | - | ||||||||||||||||||
6619 | ret[retind] = '\0'; | - | ||||||||||||||||||
6620 | if (lenp) | - | ||||||||||||||||||
6621 | *lenp = retind; | - | ||||||||||||||||||
6622 | /*itrace("parse_comsub:%d: returning `%s'", line_number, ret);*/ | - | ||||||||||||||||||
6623 | return ret; | - | ||||||||||||||||||
6624 | } | - | ||||||||||||||||||
6625 | - | |||||||||||||||||||
6626 | /* Recursively call the parser to parse a $(...) command substitution. */ | - | ||||||||||||||||||
6627 | char * | - | ||||||||||||||||||
6628 | xparse_dolparen (base, string, indp, flags) | - | ||||||||||||||||||
6629 | char *base; | - | ||||||||||||||||||
6630 | char *string; | - | ||||||||||||||||||
6631 | int *indp; | - | ||||||||||||||||||
6632 | int flags; | - | ||||||||||||||||||
6633 | { | - | ||||||||||||||||||
6634 | sh_parser_state_t ps; | - | ||||||||||||||||||
6635 | sh_input_line_state_t ls; | - | ||||||||||||||||||
6636 | int orig_ind, nc, sflags, orig_eof_token; | - | ||||||||||||||||||
6637 | char *ret, *ep, *ostring; | - | ||||||||||||||||||
6638 | #if defined (ALIAS) || defined (DPAREN_ARITHMETIC) | - | ||||||||||||||||||
6639 | STRING_SAVER *saved_pushed_strings; | - | ||||||||||||||||||
6640 | #endif | - | ||||||||||||||||||
6641 | - | |||||||||||||||||||
6642 | /*debug_parser(1);*/ | - | ||||||||||||||||||
6643 | orig_ind = *indp; | - | ||||||||||||||||||
6644 | ostring = string; | - | ||||||||||||||||||
6645 | - | |||||||||||||||||||
6646 | if (*string == 0) | - | ||||||||||||||||||
6647 | { | - | ||||||||||||||||||
6648 | if (flags & SX_NOALLOC) | - | ||||||||||||||||||
6649 | return (char *)NULL; | - | ||||||||||||||||||
6650 | - | |||||||||||||||||||
6651 | ret = xmalloc (1); | - | ||||||||||||||||||
6652 | ret[0] = '\0'; | - | ||||||||||||||||||
6653 | return ret; | - | ||||||||||||||||||
6654 | } | - | ||||||||||||||||||
6655 | - | |||||||||||||||||||
6656 | /*itrace("xparse_dolparen: size = %d shell_input_line = `%s'", shell_input_line_size, shell_input_line);*/ | - | ||||||||||||||||||
6657 | sflags = SEVAL_NONINT|SEVAL_NOHIST|SEVAL_NOFREE; | - | ||||||||||||||||||
6658 | if (flags & SX_NOLONGJMP) | - | ||||||||||||||||||
6659 | sflags |= SEVAL_NOLONGJMP; | - | ||||||||||||||||||
6660 | save_parser_state (&ps); | - | ||||||||||||||||||
6661 | save_input_line_state (&ls); | - | ||||||||||||||||||
6662 | orig_eof_token = shell_eof_token; | - | ||||||||||||||||||
6663 | #if defined (ALIAS) || defined (DPAREN_ARITHMETIC) | - | ||||||||||||||||||
6664 | saved_pushed_strings = pushed_string_list; /* separate parsing context */ | - | ||||||||||||||||||
6665 | pushed_string_list = (STRING_SAVER *)NULL; | - | ||||||||||||||||||
6666 | #endif | - | ||||||||||||||||||
6667 | - | |||||||||||||||||||
6668 | /*(*/ | - | ||||||||||||||||||
6669 | parser_state |= PST_CMDSUBST|PST_EOFTOKEN; /* allow instant ')' */ /*(*/ | - | ||||||||||||||||||
6670 | shell_eof_token = ')'; | - | ||||||||||||||||||
6671 | - | |||||||||||||||||||
6672 | /* Should we save and restore the bison/yacc lookahead token (yychar) here? | - | ||||||||||||||||||
6673 | Or only if it's not YYEMPTY? */ | - | ||||||||||||||||||
6674 | - | |||||||||||||||||||
6675 | nc = parse_string (string, "command substitution", sflags, &ep); | - | ||||||||||||||||||
6676 | - | |||||||||||||||||||
6677 | if (current_token == shell_eof_token) | - | ||||||||||||||||||
6678 | yyclearin; /* might want to clear lookahead token unconditionally */ | - | ||||||||||||||||||
6679 | - | |||||||||||||||||||
6680 | shell_eof_token = orig_eof_token; | - | ||||||||||||||||||
6681 | restore_parser_state (&ps); | - | ||||||||||||||||||
6682 | reset_parser (); | - | ||||||||||||||||||
6683 | /* reset_parser clears shell_input_line and associated variables */ | - | ||||||||||||||||||
6684 | restore_input_line_state (&ls); | - | ||||||||||||||||||
6685 | - | |||||||||||||||||||
6686 | #if defined (ALIAS) || defined (DPAREN_ARITHMETIC) | - | ||||||||||||||||||
6687 | pushed_string_list = saved_pushed_strings; | - | ||||||||||||||||||
6688 | #endif | - | ||||||||||||||||||
6689 | - | |||||||||||||||||||
6690 | token_to_read = 0; | - | ||||||||||||||||||
6691 | - | |||||||||||||||||||
6692 | /* If parse_string returns < 0, we need to jump to top level with the | - | ||||||||||||||||||
6693 | negative of the return value. We abandon the rest of this input line | - | ||||||||||||||||||
6694 | first */ | - | ||||||||||||||||||
6695 | if (nc < 0) | - | ||||||||||||||||||
6696 | { | - | ||||||||||||||||||
6697 | clear_shell_input_line (); /* XXX */ | - | ||||||||||||||||||
6698 | jump_to_top_level (-nc); /* XXX */ | - | ||||||||||||||||||
6699 | } | - | ||||||||||||||||||
6700 | - | |||||||||||||||||||
6701 | /* Need to find how many characters parse_and_execute consumed, update | - | ||||||||||||||||||
6702 | *indp, if flags != 0, copy the portion of the string parsed into RET | - | ||||||||||||||||||
6703 | and return it. If flags & 1 (SX_NOALLOC) we can return NULL. */ | - | ||||||||||||||||||
6704 | - | |||||||||||||||||||
6705 | /*(*/ | - | ||||||||||||||||||
6706 | if (ep[-1] != ')') | - | ||||||||||||||||||
6707 | { | - | ||||||||||||||||||
6708 | #if DEBUG | - | ||||||||||||||||||
6709 | if (ep[-1] != '\n') | - | ||||||||||||||||||
6710 | itrace("xparse_dolparen:%d: ep[-1] != RPAREN (%d), ep = `%s'", line_number, ep[-1], ep); | - | ||||||||||||||||||
6711 | #endif | - | ||||||||||||||||||
6712 | while (ep > ostring && ep[-1] == '\n') ep--; | - | ||||||||||||||||||
6713 | } | - | ||||||||||||||||||
6714 | - | |||||||||||||||||||
6715 | nc = ep - ostring; | - | ||||||||||||||||||
6716 | *indp = ep - base - 1; | - | ||||||||||||||||||
6717 | - | |||||||||||||||||||
6718 | /*(*/ | - | ||||||||||||||||||
6719 | #if DEBUG | - | ||||||||||||||||||
6720 | if (base[*indp] != ')') | - | ||||||||||||||||||
6721 | itrace("xparse_dolparen:%d: base[%d] != RPAREN (%d), base = `%s'", line_number, *indp, base[*indp], base); | - | ||||||||||||||||||
6722 | if (*indp < orig_ind) | - | ||||||||||||||||||
6723 | itrace("xparse_dolparen:%d: *indp (%d) < orig_ind (%d), orig_string = `%s'", line_number, *indp, orig_ind, ostring); | - | ||||||||||||||||||
6724 | #endif | - | ||||||||||||||||||
6725 | - | |||||||||||||||||||
6726 | if (flags & SX_NOALLOC) | - | ||||||||||||||||||
6727 | return (char *)NULL; | - | ||||||||||||||||||
6728 | - | |||||||||||||||||||
6729 | if (nc == 0) | - | ||||||||||||||||||
6730 | { | - | ||||||||||||||||||
6731 | ret = xmalloc (1); | - | ||||||||||||||||||
6732 | ret[0] = '\0'; | - | ||||||||||||||||||
6733 | } | - | ||||||||||||||||||
6734 | else | - | ||||||||||||||||||
6735 | ret = substring (ostring, 0, nc - 1); | - | ||||||||||||||||||
6736 | - | |||||||||||||||||||
6737 | return ret; | - | ||||||||||||||||||
6738 | } | - | ||||||||||||||||||
6739 | - | |||||||||||||||||||
6740 | #if defined (DPAREN_ARITHMETIC) || defined (ARITH_FOR_COMMAND) | - | ||||||||||||||||||
6741 | /* Parse a double-paren construct. It can be either an arithmetic | - | ||||||||||||||||||
6742 | command, an arithmetic `for' command, or a nested subshell. Returns | - | ||||||||||||||||||
6743 | the parsed token, -1 on error, or -2 if we didn't do anything and | - | ||||||||||||||||||
6744 | should just go on. */ | - | ||||||||||||||||||
6745 | static int | - | ||||||||||||||||||
6746 | parse_dparen (c) | - | ||||||||||||||||||
6747 | int c; | - | ||||||||||||||||||
6748 | { | - | ||||||||||||||||||
6749 | int cmdtyp, sline; | - | ||||||||||||||||||
6750 | char *wval; | - | ||||||||||||||||||
6751 | WORD_DESC *wd; | - | ||||||||||||||||||
6752 | - | |||||||||||||||||||
6753 | #if defined (ARITH_FOR_COMMAND) | - | ||||||||||||||||||
6754 | if (last_read_token == FOR) | - | ||||||||||||||||||
6755 | { | - | ||||||||||||||||||
6756 | arith_for_lineno = line_number; | - | ||||||||||||||||||
6757 | cmdtyp = parse_arith_cmd (&wval, 0); | - | ||||||||||||||||||
6758 | if (cmdtyp == 1) | - | ||||||||||||||||||
6759 | { | - | ||||||||||||||||||
6760 | wd = alloc_word_desc (); | - | ||||||||||||||||||
6761 | wd->word = wval; | - | ||||||||||||||||||
6762 | yylval.word_list = make_word_list (wd, (WORD_LIST *)NULL); | - | ||||||||||||||||||
6763 | return (ARITH_FOR_EXPRS); | - | ||||||||||||||||||
6764 | } | - | ||||||||||||||||||
6765 | else | - | ||||||||||||||||||
6766 | return -1; /* ERROR */ | - | ||||||||||||||||||
6767 | } | - | ||||||||||||||||||
6768 | #endif | - | ||||||||||||||||||
6769 | - | |||||||||||||||||||
6770 | #if defined (DPAREN_ARITHMETIC) | - | ||||||||||||||||||
6771 | if (reserved_word_acceptable (last_read_token)) | - | ||||||||||||||||||
6772 | { | - | ||||||||||||||||||
6773 | sline = line_number; | - | ||||||||||||||||||
6774 | - | |||||||||||||||||||
6775 | cmdtyp = parse_arith_cmd (&wval, 0); | - | ||||||||||||||||||
6776 | if (cmdtyp == 1) /* arithmetic command */ | - | ||||||||||||||||||
6777 | { | - | ||||||||||||||||||
6778 | wd = alloc_word_desc (); | - | ||||||||||||||||||
6779 | wd->word = wval; | - | ||||||||||||||||||
6780 | wd->flags = W_QUOTED|W_NOSPLIT|W_NOGLOB|W_DQUOTE; | - | ||||||||||||||||||
6781 | yylval.word_list = make_word_list (wd, (WORD_LIST *)NULL); | - | ||||||||||||||||||
6782 | return (ARITH_CMD); | - | ||||||||||||||||||
6783 | } | - | ||||||||||||||||||
6784 | else if (cmdtyp == 0) /* nested subshell */ | - | ||||||||||||||||||
6785 | { | - | ||||||||||||||||||
6786 | push_string (wval, 0, (alias_t *)NULL); | - | ||||||||||||||||||
6787 | pushed_string_list->flags = PSH_DPAREN; | - | ||||||||||||||||||
6788 | if ((parser_state & PST_CASEPAT) == 0) | - | ||||||||||||||||||
6789 | parser_state |= PST_SUBSHELL; | - | ||||||||||||||||||
6790 | return (c); | - | ||||||||||||||||||
6791 | } | - | ||||||||||||||||||
6792 | else /* ERROR */ | - | ||||||||||||||||||
6793 | return -1; | - | ||||||||||||||||||
6794 | } | - | ||||||||||||||||||
6795 | #endif | - | ||||||||||||||||||
6796 | - | |||||||||||||||||||
6797 | return -2; /* XXX */ | - | ||||||||||||||||||
6798 | } | - | ||||||||||||||||||
6799 | - | |||||||||||||||||||
6800 | /* We've seen a `(('. Look for the matching `))'. If we get it, return 1. | - | ||||||||||||||||||
6801 | If not, assume it's a nested subshell for backwards compatibility and | - | ||||||||||||||||||
6802 | return 0. In any case, put the characters we've consumed into a locally- | - | ||||||||||||||||||
6803 | allocated buffer and make *ep point to that buffer. Return -1 on an | - | ||||||||||||||||||
6804 | error, for example EOF. */ | - | ||||||||||||||||||
6805 | static int | - | ||||||||||||||||||
6806 | parse_arith_cmd (ep, adddq) | - | ||||||||||||||||||
6807 | char **ep; | - | ||||||||||||||||||
6808 | int adddq; | - | ||||||||||||||||||
6809 | { | - | ||||||||||||||||||
6810 | int exp_lineno, rval, c; | - | ||||||||||||||||||
6811 | char *ttok, *tokstr; | - | ||||||||||||||||||
6812 | int ttoklen; | - | ||||||||||||||||||
6813 | - | |||||||||||||||||||
6814 | exp_lineno = line_number; | - | ||||||||||||||||||
6815 | ttok = parse_matched_pair (0, '(', ')', &ttoklen, 0); | - | ||||||||||||||||||
6816 | rval = 1; | - | ||||||||||||||||||
6817 | if (ttok == &matched_pair_error) | - | ||||||||||||||||||
6818 | return -1; | - | ||||||||||||||||||
6819 | /* Check that the next character is the closing right paren. If | - | ||||||||||||||||||
6820 | not, this is a syntax error. ( */ | - | ||||||||||||||||||
6821 | c = shell_getc (0); | - | ||||||||||||||||||
6822 | if MBTEST(c != ')') | - | ||||||||||||||||||
6823 | rval = 0; | - | ||||||||||||||||||
6824 | - | |||||||||||||||||||
6825 | tokstr = (char *)xmalloc (ttoklen + 4); | - | ||||||||||||||||||
6826 | - | |||||||||||||||||||
6827 | /* if ADDDQ != 0 then (( ... )) -> "..." */ | - | ||||||||||||||||||
6828 | if (rval == 1 && adddq) /* arith cmd, add double quotes */ | - | ||||||||||||||||||
6829 | { | - | ||||||||||||||||||
6830 | tokstr[0] = '"'; | - | ||||||||||||||||||
6831 | strncpy (tokstr + 1, ttok, ttoklen - 1); | - | ||||||||||||||||||
6832 | tokstr[ttoklen] = '"'; | - | ||||||||||||||||||
6833 | tokstr[ttoklen+1] = '\0'; | - | ||||||||||||||||||
6834 | } | - | ||||||||||||||||||
6835 | else if (rval == 1) /* arith cmd, don't add double quotes */ | - | ||||||||||||||||||
6836 | { | - | ||||||||||||||||||
6837 | strncpy (tokstr, ttok, ttoklen - 1); | - | ||||||||||||||||||
6838 | tokstr[ttoklen-1] = '\0'; | - | ||||||||||||||||||
6839 | } | - | ||||||||||||||||||
6840 | else /* nested subshell */ | - | ||||||||||||||||||
6841 | { | - | ||||||||||||||||||
6842 | tokstr[0] = '('; | - | ||||||||||||||||||
6843 | strncpy (tokstr + 1, ttok, ttoklen - 1); | - | ||||||||||||||||||
6844 | tokstr[ttoklen] = ')'; | - | ||||||||||||||||||
6845 | tokstr[ttoklen+1] = c; | - | ||||||||||||||||||
6846 | tokstr[ttoklen+2] = '\0'; | - | ||||||||||||||||||
6847 | } | - | ||||||||||||||||||
6848 | - | |||||||||||||||||||
6849 | *ep = tokstr; | - | ||||||||||||||||||
6850 | FREE (ttok); | - | ||||||||||||||||||
6851 | return rval; | - | ||||||||||||||||||
6852 | } | - | ||||||||||||||||||
6853 | #endif /* DPAREN_ARITHMETIC || ARITH_FOR_COMMAND */ | - | ||||||||||||||||||
6854 | - | |||||||||||||||||||
6855 | #if defined (COND_COMMAND) | - | ||||||||||||||||||
6856 | static void | - | ||||||||||||||||||
6857 | cond_error () | - | ||||||||||||||||||
6858 | { | - | ||||||||||||||||||
6859 | char *etext; | - | ||||||||||||||||||
6860 | - | |||||||||||||||||||
6861 | if (EOF_Reached && cond_token != COND_ERROR) /* [[ */ | - | ||||||||||||||||||
6862 | parser_error (cond_lineno, _("unexpected EOF while looking for `]]'")); | - | ||||||||||||||||||
6863 | else if (cond_token != COND_ERROR) | - | ||||||||||||||||||
6864 | { | - | ||||||||||||||||||
6865 | if (etext = error_token_from_token (cond_token)) | - | ||||||||||||||||||
6866 | { | - | ||||||||||||||||||
6867 | parser_error (cond_lineno, _("syntax error in conditional expression: unexpected token `%s'"), etext); | - | ||||||||||||||||||
6868 | free (etext); | - | ||||||||||||||||||
6869 | } | - | ||||||||||||||||||
6870 | else | - | ||||||||||||||||||
6871 | parser_error (cond_lineno, _("syntax error in conditional expression")); | - | ||||||||||||||||||
6872 | } | - | ||||||||||||||||||
6873 | } | - | ||||||||||||||||||
6874 | - | |||||||||||||||||||
6875 | static COND_COM * | - | ||||||||||||||||||
6876 | cond_expr () | - | ||||||||||||||||||
6877 | { | - | ||||||||||||||||||
6878 | return (cond_or ()); | - | ||||||||||||||||||
6879 | } | - | ||||||||||||||||||
6880 | - | |||||||||||||||||||
6881 | static COND_COM * | - | ||||||||||||||||||
6882 | cond_or () | - | ||||||||||||||||||
6883 | { | - | ||||||||||||||||||
6884 | COND_COM *l, *r; | - | ||||||||||||||||||
6885 | - | |||||||||||||||||||
6886 | l = cond_and (); | - | ||||||||||||||||||
6887 | if (cond_token == OR_OR) | - | ||||||||||||||||||
6888 | { | - | ||||||||||||||||||
6889 | r = cond_or (); | - | ||||||||||||||||||
6890 | l = make_cond_node (COND_OR, (WORD_DESC *)NULL, l, r); | - | ||||||||||||||||||
6891 | } | - | ||||||||||||||||||
6892 | return l; | - | ||||||||||||||||||
6893 | } | - | ||||||||||||||||||
6894 | - | |||||||||||||||||||
6895 | static COND_COM * | - | ||||||||||||||||||
6896 | cond_and () | - | ||||||||||||||||||
6897 | { | - | ||||||||||||||||||
6898 | COND_COM *l, *r; | - | ||||||||||||||||||
6899 | - | |||||||||||||||||||
6900 | l = cond_term (); | - | ||||||||||||||||||
6901 | if (cond_token == AND_AND) | - | ||||||||||||||||||
6902 | { | - | ||||||||||||||||||
6903 | r = cond_and (); | - | ||||||||||||||||||
6904 | l = make_cond_node (COND_AND, (WORD_DESC *)NULL, l, r); | - | ||||||||||||||||||
6905 | } | - | ||||||||||||||||||
6906 | return l; | - | ||||||||||||||||||
6907 | } | - | ||||||||||||||||||
6908 | - | |||||||||||||||||||
6909 | static int | - | ||||||||||||||||||
6910 | cond_skip_newlines () | - | ||||||||||||||||||
6911 | { | - | ||||||||||||||||||
6912 | while ((cond_token = read_token (READ)) == '\n') | - | ||||||||||||||||||
6913 | { | - | ||||||||||||||||||
6914 | if (SHOULD_PROMPT ()) | - | ||||||||||||||||||
6915 | prompt_again (); | - | ||||||||||||||||||
6916 | } | - | ||||||||||||||||||
6917 | return (cond_token); | - | ||||||||||||||||||
6918 | } | - | ||||||||||||||||||
6919 | - | |||||||||||||||||||
6920 | #define COND_RETURN_ERROR() \ | - | ||||||||||||||||||
6921 | do { cond_token = COND_ERROR; return ((COND_COM *)NULL); } while (0) | - | ||||||||||||||||||
6922 | - | |||||||||||||||||||
6923 | static COND_COM * | - | ||||||||||||||||||
6924 | cond_term () | - | ||||||||||||||||||
6925 | { | - | ||||||||||||||||||
6926 | WORD_DESC *op; | - | ||||||||||||||||||
6927 | COND_COM *term, *tleft, *tright; | - | ||||||||||||||||||
6928 | int tok, lineno; | - | ||||||||||||||||||
6929 | char *etext; | - | ||||||||||||||||||
6930 | - | |||||||||||||||||||
6931 | /* Read a token. It can be a left paren, a `!', a unary operator, or a | - | ||||||||||||||||||
6932 | word that should be the first argument of a binary operator. Start by | - | ||||||||||||||||||
6933 | skipping newlines, since this is a compound command. */ | - | ||||||||||||||||||
6934 | tok = cond_skip_newlines (); | - | ||||||||||||||||||
6935 | lineno = line_number; | - | ||||||||||||||||||
6936 | if (tok == COND_END) | - | ||||||||||||||||||
6937 | { | - | ||||||||||||||||||
6938 | COND_RETURN_ERROR (); | - | ||||||||||||||||||
6939 | } | - | ||||||||||||||||||
6940 | else if (tok == '(') | - | ||||||||||||||||||
6941 | { | - | ||||||||||||||||||
6942 | term = cond_expr (); | - | ||||||||||||||||||
6943 | if (cond_token != ')') | - | ||||||||||||||||||
6944 | { | - | ||||||||||||||||||
6945 | if (term) | - | ||||||||||||||||||
6946 | dispose_cond_node (term); /* ( */ | - | ||||||||||||||||||
6947 | if (etext = error_token_from_token (cond_token)) | - | ||||||||||||||||||
6948 | { | - | ||||||||||||||||||
6949 | parser_error (lineno, _("unexpected token `%s', expected `)'"), etext); | - | ||||||||||||||||||
6950 | free (etext); | - | ||||||||||||||||||
6951 | } | - | ||||||||||||||||||
6952 | else | - | ||||||||||||||||||
6953 | parser_error (lineno, _("expected `)'")); | - | ||||||||||||||||||
6954 | COND_RETURN_ERROR (); | - | ||||||||||||||||||
6955 | } | - | ||||||||||||||||||
6956 | term = make_cond_node (COND_EXPR, (WORD_DESC *)NULL, term, (COND_COM *)NULL); | - | ||||||||||||||||||
6957 | (void)cond_skip_newlines (); | - | ||||||||||||||||||
6958 | } | - | ||||||||||||||||||
6959 | else if (tok == BANG || (tok == WORD && (yylval.word->word[0] == '!' && yylval.word->word[1] == '\0'))) | - | ||||||||||||||||||
6960 | { | - | ||||||||||||||||||
6961 | if (tok == WORD) | - | ||||||||||||||||||
6962 | dispose_word (yylval.word); /* not needed */ | - | ||||||||||||||||||
6963 | term = cond_term (); | - | ||||||||||||||||||
6964 | if (term) | - | ||||||||||||||||||
6965 | term->flags |= CMD_INVERT_RETURN; | - | ||||||||||||||||||
6966 | } | - | ||||||||||||||||||
6967 | else if (tok == WORD && yylval.word->word[0] == '-' && yylval.word->word[1] && yylval.word->word[2] == 0 && test_unop (yylval.word->word)) | - | ||||||||||||||||||
6968 | { | - | ||||||||||||||||||
6969 | op = yylval.word; | - | ||||||||||||||||||
6970 | tok = read_token (READ); | - | ||||||||||||||||||
6971 | if (tok == WORD) | - | ||||||||||||||||||
6972 | { | - | ||||||||||||||||||
6973 | tleft = make_cond_node (COND_TERM, yylval.word, (COND_COM *)NULL, (COND_COM *)NULL); | - | ||||||||||||||||||
6974 | term = make_cond_node (COND_UNARY, op, tleft, (COND_COM *)NULL); | - | ||||||||||||||||||
6975 | } | - | ||||||||||||||||||
6976 | else | - | ||||||||||||||||||
6977 | { | - | ||||||||||||||||||
6978 | dispose_word (op); | - | ||||||||||||||||||
6979 | if (etext = error_token_from_token (tok)) | - | ||||||||||||||||||
6980 | { | - | ||||||||||||||||||
6981 | parser_error (line_number, _("unexpected argument `%s' to conditional unary operator"), etext); | - | ||||||||||||||||||
6982 | free (etext); | - | ||||||||||||||||||
6983 | } | - | ||||||||||||||||||
6984 | else | - | ||||||||||||||||||
6985 | parser_error (line_number, _("unexpected argument to conditional unary operator")); | - | ||||||||||||||||||
6986 | COND_RETURN_ERROR (); | - | ||||||||||||||||||
6987 | } | - | ||||||||||||||||||
6988 | - | |||||||||||||||||||
6989 | (void)cond_skip_newlines (); | - | ||||||||||||||||||
6990 | } | - | ||||||||||||||||||
6991 | else if (tok == WORD) /* left argument to binary operator */ | - | ||||||||||||||||||
6992 | { | - | ||||||||||||||||||
6993 | /* lhs */ | - | ||||||||||||||||||
6994 | tleft = make_cond_node (COND_TERM, yylval.word, (COND_COM *)NULL, (COND_COM *)NULL); | - | ||||||||||||||||||
6995 | - | |||||||||||||||||||
6996 | /* binop */ | - | ||||||||||||||||||
6997 | tok = read_token (READ); | - | ||||||||||||||||||
6998 | if (tok == WORD && test_binop (yylval.word->word)) | - | ||||||||||||||||||
6999 | { | - | ||||||||||||||||||
7000 | op = yylval.word; | - | ||||||||||||||||||
7001 | if (op->word[0] == '=' && (op->word[1] == '\0' || (op->word[1] == '=' && op->word[2] == '\0'))) | - | ||||||||||||||||||
7002 | parser_state |= PST_EXTPAT; | - | ||||||||||||||||||
7003 | else if (op->word[0] == '!' && op->word[1] == '=' && op->word[2] == '\0') | - | ||||||||||||||||||
7004 | parser_state |= PST_EXTPAT; | - | ||||||||||||||||||
7005 | } | - | ||||||||||||||||||
7006 | #if defined (COND_REGEXP) | - | ||||||||||||||||||
7007 | else if (tok == WORD && STREQ (yylval.word->word, "=~")) | - | ||||||||||||||||||
7008 | { | - | ||||||||||||||||||
7009 | op = yylval.word; | - | ||||||||||||||||||
7010 | parser_state |= PST_REGEXP; | - | ||||||||||||||||||
7011 | } | - | ||||||||||||||||||
7012 | #endif | - | ||||||||||||||||||
7013 | else if (tok == '<' || tok == '>') | - | ||||||||||||||||||
7014 | op = make_word_from_token (tok); /* ( */ | - | ||||||||||||||||||
7015 | /* There should be a check before blindly accepting the `)' that we have | - | ||||||||||||||||||
7016 | seen the opening `('. */ | - | ||||||||||||||||||
7017 | else if (tok == COND_END || tok == AND_AND || tok == OR_OR || tok == ')') | - | ||||||||||||||||||
7018 | { | - | ||||||||||||||||||
7019 | /* Special case. [[ x ]] is equivalent to [[ -n x ]], just like | - | ||||||||||||||||||
7020 | the test command. Similarly for [[ x && expr ]] or | - | ||||||||||||||||||
7021 | [[ x || expr ]] or [[ (x) ]]. */ | - | ||||||||||||||||||
7022 | op = make_word ("-n"); | - | ||||||||||||||||||
7023 | term = make_cond_node (COND_UNARY, op, tleft, (COND_COM *)NULL); | - | ||||||||||||||||||
7024 | cond_token = tok; | - | ||||||||||||||||||
7025 | return (term); | - | ||||||||||||||||||
7026 | } | - | ||||||||||||||||||
7027 | else | - | ||||||||||||||||||
7028 | { | - | ||||||||||||||||||
7029 | if (etext = error_token_from_token (tok)) | - | ||||||||||||||||||
7030 | { | - | ||||||||||||||||||
7031 | parser_error (line_number, _("unexpected token `%s', conditional binary operator expected"), etext); | - | ||||||||||||||||||
7032 | free (etext); | - | ||||||||||||||||||
7033 | } | - | ||||||||||||||||||
7034 | else | - | ||||||||||||||||||
7035 | parser_error (line_number, _("conditional binary operator expected")); | - | ||||||||||||||||||
7036 | dispose_cond_node (tleft); | - | ||||||||||||||||||
7037 | COND_RETURN_ERROR (); | - | ||||||||||||||||||
7038 | } | - | ||||||||||||||||||
7039 | - | |||||||||||||||||||
7040 | /* rhs */ | - | ||||||||||||||||||
7041 | if (parser_state & PST_EXTPAT) | - | ||||||||||||||||||
7042 | extended_glob = 1; | - | ||||||||||||||||||
7043 | tok = read_token (READ); | - | ||||||||||||||||||
7044 | if (parser_state & PST_EXTPAT) | - | ||||||||||||||||||
7045 | extended_glob = global_extglob; | - | ||||||||||||||||||
7046 | parser_state &= ~(PST_REGEXP|PST_EXTPAT); | - | ||||||||||||||||||
7047 | - | |||||||||||||||||||
7048 | if (tok == WORD) | - | ||||||||||||||||||
7049 | { | - | ||||||||||||||||||
7050 | tright = make_cond_node (COND_TERM, yylval.word, (COND_COM *)NULL, (COND_COM *)NULL); | - | ||||||||||||||||||
7051 | term = make_cond_node (COND_BINARY, op, tleft, tright); | - | ||||||||||||||||||
7052 | } | - | ||||||||||||||||||
7053 | else | - | ||||||||||||||||||
7054 | { | - | ||||||||||||||||||
7055 | if (etext = error_token_from_token (tok)) | - | ||||||||||||||||||
7056 | { | - | ||||||||||||||||||
7057 | parser_error (line_number, _("unexpected argument `%s' to conditional binary operator"), etext); | - | ||||||||||||||||||
7058 | free (etext); | - | ||||||||||||||||||
7059 | } | - | ||||||||||||||||||
7060 | else | - | ||||||||||||||||||
7061 | parser_error (line_number, _("unexpected argument to conditional binary operator")); | - | ||||||||||||||||||
7062 | dispose_cond_node (tleft); | - | ||||||||||||||||||
7063 | dispose_word (op); | - | ||||||||||||||||||
7064 | COND_RETURN_ERROR (); | - | ||||||||||||||||||
7065 | } | - | ||||||||||||||||||
7066 | - | |||||||||||||||||||
7067 | (void)cond_skip_newlines (); | - | ||||||||||||||||||
7068 | } | - | ||||||||||||||||||
7069 | else | - | ||||||||||||||||||
7070 | { | - | ||||||||||||||||||
7071 | if (tok < 256) | - | ||||||||||||||||||
7072 | parser_error (line_number, _("unexpected token `%c' in conditional command"), tok); | - | ||||||||||||||||||
7073 | else if (etext = error_token_from_token (tok)) | - | ||||||||||||||||||
7074 | { | - | ||||||||||||||||||
7075 | parser_error (line_number, _("unexpected token `%s' in conditional command"), etext); | - | ||||||||||||||||||
7076 | free (etext); | - | ||||||||||||||||||
7077 | } | - | ||||||||||||||||||
7078 | else | - | ||||||||||||||||||
7079 | parser_error (line_number, _("unexpected token %d in conditional command"), tok); | - | ||||||||||||||||||
7080 | COND_RETURN_ERROR (); | - | ||||||||||||||||||
7081 | } | - | ||||||||||||||||||
7082 | return (term); | - | ||||||||||||||||||
7083 | } | - | ||||||||||||||||||
7084 | - | |||||||||||||||||||
7085 | /* This is kind of bogus -- we slip a mini recursive-descent parser in | - | ||||||||||||||||||
7086 | here to handle the conditional statement syntax. */ | - | ||||||||||||||||||
7087 | static COMMAND * | - | ||||||||||||||||||
7088 | parse_cond_command () | - | ||||||||||||||||||
7089 | { | - | ||||||||||||||||||
7090 | COND_COM *cexp; | - | ||||||||||||||||||
7091 | - | |||||||||||||||||||
7092 | global_extglob = extended_glob; | - | ||||||||||||||||||
7093 | cexp = cond_expr (); | - | ||||||||||||||||||
7094 | return (make_cond_command (cexp)); | - | ||||||||||||||||||
7095 | } | - | ||||||||||||||||||
7096 | #endif | - | ||||||||||||||||||
7097 | - | |||||||||||||||||||
7098 | #if defined (ARRAY_VARS) | - | ||||||||||||||||||
7099 | /* When this is called, it's guaranteed that we don't care about anything | - | ||||||||||||||||||
7100 | in t beyond i. We use a buffer with room for the characters we add just | - | ||||||||||||||||||
7101 | in case assignment() ends up doing something like parsing a command | - | ||||||||||||||||||
7102 | substitution that will reallocate atoken. We don't want to write beyond | - | ||||||||||||||||||
7103 | the end of an allocated buffer. */ | - | ||||||||||||||||||
7104 | static int | - | ||||||||||||||||||
7105 | token_is_assignment (t, i) | - | ||||||||||||||||||
7106 | char *t; | - | ||||||||||||||||||
7107 | int i; | - | ||||||||||||||||||
7108 | { | - | ||||||||||||||||||
7109 | int r; | - | ||||||||||||||||||
7110 | char *atoken; | - | ||||||||||||||||||
7111 | - | |||||||||||||||||||
7112 | atoken = xmalloc (i + 3); | - | ||||||||||||||||||
7113 | memcpy (atoken, t, i); | - | ||||||||||||||||||
7114 | atoken[i] = '='; | - | ||||||||||||||||||
7115 | atoken[i+1] = '\0'; | - | ||||||||||||||||||
7116 | - | |||||||||||||||||||
7117 | r = assignment (atoken, (parser_state & PST_COMPASSIGN) != 0); | - | ||||||||||||||||||
7118 | - | |||||||||||||||||||
7119 | free (atoken); | - | ||||||||||||||||||
7120 | - | |||||||||||||||||||
7121 | /* XXX - check that r == i to avoid returning false positive for | - | ||||||||||||||||||
7122 | t containing `=' before t[i]. */ | - | ||||||||||||||||||
7123 | return (r > 0 && r == i); | - | ||||||||||||||||||
7124 | } | - | ||||||||||||||||||
7125 | - | |||||||||||||||||||
7126 | /* XXX - possible changes here for `+=' */ | - | ||||||||||||||||||
7127 | static int | - | ||||||||||||||||||
7128 | token_is_ident (t, i) | - | ||||||||||||||||||
7129 | char *t; | - | ||||||||||||||||||
7130 | int i; | - | ||||||||||||||||||
7131 | { | - | ||||||||||||||||||
7132 | unsigned char c; | - | ||||||||||||||||||
7133 | int r; | - | ||||||||||||||||||
7134 | - | |||||||||||||||||||
7135 | c = t[i]; | - | ||||||||||||||||||
7136 | t[i] = '\0'; | - | ||||||||||||||||||
7137 | r = legal_identifier (t); | - | ||||||||||||||||||
7138 | t[i] = c; | - | ||||||||||||||||||
7139 | return r; | - | ||||||||||||||||||
7140 | } | - | ||||||||||||||||||
7141 | #endif | - | ||||||||||||||||||
7142 | - | |||||||||||||||||||
7143 | static int | - | ||||||||||||||||||
7144 | read_token_word (character) | - | ||||||||||||||||||
7145 | int character; | - | ||||||||||||||||||
7146 | { | - | ||||||||||||||||||
7147 | /* The value for YYLVAL when a WORD is read. */ | - | ||||||||||||||||||
7148 | WORD_DESC *the_word; | - | ||||||||||||||||||
7149 | - | |||||||||||||||||||
7150 | /* Index into the token that we are building. */ | - | ||||||||||||||||||
7151 | int token_index; | - | ||||||||||||||||||
7152 | - | |||||||||||||||||||
7153 | /* ALL_DIGITS becomes zero when we see a non-digit. */ | - | ||||||||||||||||||
7154 | int all_digit_token; | - | ||||||||||||||||||
7155 | - | |||||||||||||||||||
7156 | /* DOLLAR_PRESENT becomes non-zero if we see a `$'. */ | - | ||||||||||||||||||
7157 | int dollar_present; | - | ||||||||||||||||||
7158 | - | |||||||||||||||||||
7159 | /* COMPOUND_ASSIGNMENT becomes non-zero if we are parsing a compound | - | ||||||||||||||||||
7160 | assignment. */ | - | ||||||||||||||||||
7161 | int compound_assignment; | - | ||||||||||||||||||
7162 | - | |||||||||||||||||||
7163 | /* QUOTED becomes non-zero if we see one of ("), ('), (`), or (\). */ | - | ||||||||||||||||||
7164 | int quoted; | - | ||||||||||||||||||
7165 | - | |||||||||||||||||||
7166 | /* Non-zero means to ignore the value of the next character, and just | - | ||||||||||||||||||
7167 | to add it no matter what. */ | - | ||||||||||||||||||
7168 | int pass_next_character; | - | ||||||||||||||||||
7169 | - | |||||||||||||||||||
7170 | /* The current delimiting character. */ | - | ||||||||||||||||||
7171 | int cd; | - | ||||||||||||||||||
7172 | int result, peek_char; | - | ||||||||||||||||||
7173 | char *ttok, *ttrans; | - | ||||||||||||||||||
7174 | int ttoklen, ttranslen; | - | ||||||||||||||||||
7175 | intmax_t lvalue; | - | ||||||||||||||||||
7176 | - | |||||||||||||||||||
7177 | if (token_buffer_size < TOKEN_DEFAULT_INITIAL_SIZE) | - | ||||||||||||||||||
7178 | token = (char *)xrealloc (token, token_buffer_size = TOKEN_DEFAULT_INITIAL_SIZE); | - | ||||||||||||||||||
7179 | - | |||||||||||||||||||
7180 | token_index = 0; | - | ||||||||||||||||||
7181 | all_digit_token = DIGIT (character); | - | ||||||||||||||||||
7182 | dollar_present = quoted = pass_next_character = compound_assignment = 0; | - | ||||||||||||||||||
7183 | - | |||||||||||||||||||
7184 | for (;;) | - | ||||||||||||||||||
7185 | { | - | ||||||||||||||||||
7186 | if (character == EOF) | - | ||||||||||||||||||
7187 | goto got_token; | - | ||||||||||||||||||
7188 | - | |||||||||||||||||||
7189 | if (pass_next_character) | - | ||||||||||||||||||
7190 | { | - | ||||||||||||||||||
7191 | pass_next_character = 0; | - | ||||||||||||||||||
7192 | goto got_escaped_character; | - | ||||||||||||||||||
7193 | } | - | ||||||||||||||||||
7194 | - | |||||||||||||||||||
7195 | cd = current_delimiter (dstack); | - | ||||||||||||||||||
7196 | - | |||||||||||||||||||
7197 | /* Handle backslashes. Quote lots of things when not inside of | - | ||||||||||||||||||
7198 | double-quotes, quote some things inside of double-quotes. */ | - | ||||||||||||||||||
7199 | if MBTEST(character == '\\') | - | ||||||||||||||||||
7200 | { | - | ||||||||||||||||||
7201 | peek_char = shell_getc (0); | - | ||||||||||||||||||
7202 | - | |||||||||||||||||||
7203 | /* Backslash-newline is ignored in all cases except | - | ||||||||||||||||||
7204 | when quoted with single quotes. */ | - | ||||||||||||||||||
7205 | if (peek_char == '\n') | - | ||||||||||||||||||
7206 | { | - | ||||||||||||||||||
7207 | character = '\n'; | - | ||||||||||||||||||
7208 | goto next_character; | - | ||||||||||||||||||
7209 | } | - | ||||||||||||||||||
7210 | else | - | ||||||||||||||||||
7211 | { | - | ||||||||||||||||||
7212 | shell_ungetc (peek_char); | - | ||||||||||||||||||
7213 | - | |||||||||||||||||||
7214 | /* If the next character is to be quoted, note it now. */ | - | ||||||||||||||||||
7215 | if (cd == 0 || cd == '`' || | - | ||||||||||||||||||
7216 | (cd == '"' && peek_char >= 0 && (sh_syntaxtab[peek_char] & CBSDQUOTE))) | - | ||||||||||||||||||
7217 | pass_next_character++; | - | ||||||||||||||||||
7218 | - | |||||||||||||||||||
7219 | quoted = 1; | - | ||||||||||||||||||
7220 | goto got_character; | - | ||||||||||||||||||
7221 | } | - | ||||||||||||||||||
7222 | } | - | ||||||||||||||||||
7223 | - | |||||||||||||||||||
7224 | /* Parse a matched pair of quote characters. */ | - | ||||||||||||||||||
7225 | if MBTEST(shellquote (character)) | - | ||||||||||||||||||
7226 | { | - | ||||||||||||||||||
7227 | push_delimiter (dstack, character); | - | ||||||||||||||||||
7228 | ttok = parse_matched_pair (character, character, character, &ttoklen, (character == '`') ? P_COMMAND : 0); | - | ||||||||||||||||||
7229 | pop_delimiter (dstack); | - | ||||||||||||||||||
7230 | if (ttok == &matched_pair_error) | - | ||||||||||||||||||
7231 | return -1; /* Bail immediately. */ | - | ||||||||||||||||||
7232 | RESIZE_MALLOCED_BUFFER (token, token_index, ttoklen + 2, | - | ||||||||||||||||||
7233 | token_buffer_size, TOKEN_DEFAULT_GROW_SIZE); | - | ||||||||||||||||||
7234 | token[token_index++] = character; | - | ||||||||||||||||||
7235 | strcpy (token + token_index, ttok); | - | ||||||||||||||||||
7236 | token_index += ttoklen; | - | ||||||||||||||||||
7237 | all_digit_token = 0; | - | ||||||||||||||||||
7238 | quoted = 1; | - | ||||||||||||||||||
7239 | dollar_present |= (character == '"' && strchr (ttok, '$') != 0); | - | ||||||||||||||||||
7240 | FREE (ttok); | - | ||||||||||||||||||
7241 | goto next_character; | - | ||||||||||||||||||
7242 | } | - | ||||||||||||||||||
7243 | - | |||||||||||||||||||
7244 | #ifdef COND_REGEXP | - | ||||||||||||||||||
7245 | /* When parsing a regexp as a single word inside a conditional command, | - | ||||||||||||||||||
7246 | we need to special-case characters special to both the shell and | - | ||||||||||||||||||
7247 | regular expressions. Right now, that is only '(' and '|'. */ /*)*/ | - | ||||||||||||||||||
7248 | if MBTEST((parser_state & PST_REGEXP) && (character == '(' || character == '|')) /*)*/ | - | ||||||||||||||||||
7249 | { | - | ||||||||||||||||||
7250 | if (character == '|') | - | ||||||||||||||||||
7251 | goto got_character; | - | ||||||||||||||||||
7252 | - | |||||||||||||||||||
7253 | push_delimiter (dstack, character); | - | ||||||||||||||||||
7254 | ttok = parse_matched_pair (cd, '(', ')', &ttoklen, 0); | - | ||||||||||||||||||
7255 | pop_delimiter (dstack); | - | ||||||||||||||||||
7256 | if (ttok == &matched_pair_error) | - | ||||||||||||||||||
7257 | return -1; /* Bail immediately. */ | - | ||||||||||||||||||
7258 | RESIZE_MALLOCED_BUFFER (token, token_index, ttoklen + 2, | - | ||||||||||||||||||
7259 | token_buffer_size, TOKEN_DEFAULT_GROW_SIZE); | - | ||||||||||||||||||
7260 | token[token_index++] = character; | - | ||||||||||||||||||
7261 | strcpy (token + token_index, ttok); | - | ||||||||||||||||||
7262 | token_index += ttoklen; | - | ||||||||||||||||||
7263 | FREE (ttok); | - | ||||||||||||||||||
7264 | dollar_present = all_digit_token = 0; | - | ||||||||||||||||||
7265 | goto next_character; | - | ||||||||||||||||||
7266 | } | - | ||||||||||||||||||
7267 | #endif /* COND_REGEXP */ | - | ||||||||||||||||||
7268 | - | |||||||||||||||||||
7269 | #ifdef EXTENDED_GLOB | - | ||||||||||||||||||
7270 | /* Parse a ksh-style extended pattern matching specification. */ | - | ||||||||||||||||||
7271 | if MBTEST(extended_glob && PATTERN_CHAR (character)) | - | ||||||||||||||||||
7272 | { | - | ||||||||||||||||||
7273 | peek_char = shell_getc (1); | - | ||||||||||||||||||
7274 | if MBTEST(peek_char == '(') /* ) */ | - | ||||||||||||||||||
7275 | { | - | ||||||||||||||||||
7276 | push_delimiter (dstack, peek_char); | - | ||||||||||||||||||
7277 | ttok = parse_matched_pair (cd, '(', ')', &ttoklen, 0); | - | ||||||||||||||||||
7278 | pop_delimiter (dstack); | - | ||||||||||||||||||
7279 | if (ttok == &matched_pair_error) | - | ||||||||||||||||||
7280 | return -1; /* Bail immediately. */ | - | ||||||||||||||||||
7281 | RESIZE_MALLOCED_BUFFER (token, token_index, ttoklen + 3, | - | ||||||||||||||||||
7282 | token_buffer_size, | - | ||||||||||||||||||
7283 | TOKEN_DEFAULT_GROW_SIZE); | - | ||||||||||||||||||
7284 | token[token_index++] = character; | - | ||||||||||||||||||
7285 | token[token_index++] = peek_char; | - | ||||||||||||||||||
7286 | strcpy (token + token_index, ttok); | - | ||||||||||||||||||
7287 | token_index += ttoklen; | - | ||||||||||||||||||
7288 | FREE (ttok); | - | ||||||||||||||||||
7289 | dollar_present = all_digit_token = 0; | - | ||||||||||||||||||
7290 | goto next_character; | - | ||||||||||||||||||
7291 | } | - | ||||||||||||||||||
7292 | else | - | ||||||||||||||||||
7293 | shell_ungetc (peek_char); | - | ||||||||||||||||||
7294 | } | - | ||||||||||||||||||
7295 | #endif /* EXTENDED_GLOB */ | - | ||||||||||||||||||
7296 | - | |||||||||||||||||||
7297 | /* If the delimiter character is not single quote, parse some of | - | ||||||||||||||||||
7298 | the shell expansions that must be read as a single word. */ | - | ||||||||||||||||||
7299 | if (shellexp (character)) | - | ||||||||||||||||||
7300 | { | - | ||||||||||||||||||
7301 | peek_char = shell_getc (1); | - | ||||||||||||||||||
7302 | /* $(...), <(...), >(...), $((...)), ${...}, and $[...] constructs */ | - | ||||||||||||||||||
7303 | if MBTEST(peek_char == '(' || | - | ||||||||||||||||||
7304 | ((peek_char == '{' || peek_char == '[') && character == '$')) /* ) ] } */ | - | ||||||||||||||||||
7305 | { | - | ||||||||||||||||||
7306 | if (peek_char == '{') /* } */ | - | ||||||||||||||||||
7307 | ttok = parse_matched_pair (cd, '{', '}', &ttoklen, P_FIRSTCLOSE|P_DOLBRACE); | - | ||||||||||||||||||
7308 | else if (peek_char == '(') /* ) */ | - | ||||||||||||||||||
7309 | { | - | ||||||||||||||||||
7310 | /* XXX - push and pop the `(' as a delimiter for use by | - | ||||||||||||||||||
7311 | the command-oriented-history code. This way newlines | - | ||||||||||||||||||
7312 | appearing in the $(...) string get added to the | - | ||||||||||||||||||
7313 | history literally rather than causing a possibly- | - | ||||||||||||||||||
7314 | incorrect `;' to be added. ) */ | - | ||||||||||||||||||
7315 | push_delimiter (dstack, peek_char); | - | ||||||||||||||||||
7316 | ttok = parse_comsub (cd, '(', ')', &ttoklen, P_COMMAND); | - | ||||||||||||||||||
7317 | pop_delimiter (dstack); | - | ||||||||||||||||||
7318 | } | - | ||||||||||||||||||
7319 | else | - | ||||||||||||||||||
7320 | ttok = parse_matched_pair (cd, '[', ']', &ttoklen, 0); | - | ||||||||||||||||||
7321 | if (ttok == &matched_pair_error) | - | ||||||||||||||||||
7322 | return -1; /* Bail immediately. */ | - | ||||||||||||||||||
7323 | RESIZE_MALLOCED_BUFFER (token, token_index, ttoklen + 3, | - | ||||||||||||||||||
7324 | token_buffer_size, | - | ||||||||||||||||||
7325 | TOKEN_DEFAULT_GROW_SIZE); | - | ||||||||||||||||||
7326 | token[token_index++] = character; | - | ||||||||||||||||||
7327 | token[token_index++] = peek_char; | - | ||||||||||||||||||
7328 | strcpy (token + token_index, ttok); | - | ||||||||||||||||||
7329 | token_index += ttoklen; | - | ||||||||||||||||||
7330 | FREE (ttok); | - | ||||||||||||||||||
7331 | dollar_present = 1; | - | ||||||||||||||||||
7332 | all_digit_token = 0; | - | ||||||||||||||||||
7333 | goto next_character; | - | ||||||||||||||||||
7334 | } | - | ||||||||||||||||||
7335 | /* This handles $'...' and $"..." new-style quoted strings. */ | - | ||||||||||||||||||
7336 | else if MBTEST(character == '$' && (peek_char == '\'' || peek_char == '"')) | - | ||||||||||||||||||
7337 | { | - | ||||||||||||||||||
7338 | int first_line; | - | ||||||||||||||||||
7339 | - | |||||||||||||||||||
7340 | first_line = line_number; | - | ||||||||||||||||||
7341 | push_delimiter (dstack, peek_char); | - | ||||||||||||||||||
7342 | ttok = parse_matched_pair (peek_char, peek_char, peek_char, | - | ||||||||||||||||||
7343 | &ttoklen, | - | ||||||||||||||||||
7344 | (peek_char == '\'') ? P_ALLOWESC : 0); | - | ||||||||||||||||||
7345 | pop_delimiter (dstack); | - | ||||||||||||||||||
7346 | if (ttok == &matched_pair_error) | - | ||||||||||||||||||
7347 | return -1; | - | ||||||||||||||||||
7348 | if (peek_char == '\'') | - | ||||||||||||||||||
7349 | { | - | ||||||||||||||||||
7350 | ttrans = ansiexpand (ttok, 0, ttoklen - 1, &ttranslen); | - | ||||||||||||||||||
7351 | free (ttok); | - | ||||||||||||||||||
7352 | - | |||||||||||||||||||
7353 | /* Insert the single quotes and correctly quote any | - | ||||||||||||||||||
7354 | embedded single quotes (allowed because P_ALLOWESC was | - | ||||||||||||||||||
7355 | passed to parse_matched_pair). */ | - | ||||||||||||||||||
7356 | ttok = sh_single_quote (ttrans); | - | ||||||||||||||||||
7357 | free (ttrans); | - | ||||||||||||||||||
7358 | ttranslen = strlen (ttok); | - | ||||||||||||||||||
7359 | ttrans = ttok; | - | ||||||||||||||||||
7360 | } | - | ||||||||||||||||||
7361 | else | - | ||||||||||||||||||
7362 | { | - | ||||||||||||||||||
7363 | /* Try to locale-expand the converted string. */ | - | ||||||||||||||||||
7364 | ttrans = localeexpand (ttok, 0, ttoklen - 1, first_line, &ttranslen); | - | ||||||||||||||||||
7365 | free (ttok); | - | ||||||||||||||||||
7366 | - | |||||||||||||||||||
7367 | /* Add the double quotes back */ | - | ||||||||||||||||||
7368 | ttok = sh_mkdoublequoted (ttrans, ttranslen, 0); | - | ||||||||||||||||||
7369 | free (ttrans); | - | ||||||||||||||||||
7370 | ttranslen += 2; | - | ||||||||||||||||||
7371 | ttrans = ttok; | - | ||||||||||||||||||
7372 | } | - | ||||||||||||||||||
7373 | - | |||||||||||||||||||
7374 | RESIZE_MALLOCED_BUFFER (token, token_index, ttranslen + 1, | - | ||||||||||||||||||
7375 | token_buffer_size, | - | ||||||||||||||||||
7376 | TOKEN_DEFAULT_GROW_SIZE); | - | ||||||||||||||||||
7377 | strcpy (token + token_index, ttrans); | - | ||||||||||||||||||
7378 | token_index += ttranslen; | - | ||||||||||||||||||
7379 | FREE (ttrans); | - | ||||||||||||||||||
7380 | quoted = 1; | - | ||||||||||||||||||
7381 | all_digit_token = 0; | - | ||||||||||||||||||
7382 | goto next_character; | - | ||||||||||||||||||
7383 | } | - | ||||||||||||||||||
7384 | /* This could eventually be extended to recognize all of the | - | ||||||||||||||||||
7385 | shell's single-character parameter expansions, and set flags.*/ | - | ||||||||||||||||||
7386 | else if MBTEST(character == '$' && peek_char == '$') | - | ||||||||||||||||||
7387 | { | - | ||||||||||||||||||
7388 | RESIZE_MALLOCED_BUFFER (token, token_index, 3, | - | ||||||||||||||||||
7389 | token_buffer_size, | - | ||||||||||||||||||
7390 | TOKEN_DEFAULT_GROW_SIZE); | - | ||||||||||||||||||
7391 | token[token_index++] = '$'; | - | ||||||||||||||||||
7392 | token[token_index++] = peek_char; | - | ||||||||||||||||||
7393 | dollar_present = 1; | - | ||||||||||||||||||
7394 | all_digit_token = 0; | - | ||||||||||||||||||
7395 | goto next_character; | - | ||||||||||||||||||
7396 | } | - | ||||||||||||||||||
7397 | else | - | ||||||||||||||||||
7398 | shell_ungetc (peek_char); | - | ||||||||||||||||||
7399 | } | - | ||||||||||||||||||
7400 | - | |||||||||||||||||||
7401 | #if defined (ARRAY_VARS) | - | ||||||||||||||||||
7402 | /* Identify possible array subscript assignment; match [...]. If | - | ||||||||||||||||||
7403 | parser_state&PST_COMPASSIGN, we need to parse [sub]=words treating | - | ||||||||||||||||||
7404 | `sub' as if it were enclosed in double quotes. */ | - | ||||||||||||||||||
7405 | else if MBTEST(character == '[' && /* ] */ | - | ||||||||||||||||||
7406 | ((token_index > 0 && assignment_acceptable (last_read_token) && token_is_ident (token, token_index)) || | - | ||||||||||||||||||
7407 | (token_index == 0 && (parser_state&PST_COMPASSIGN)))) | - | ||||||||||||||||||
7408 | { | - | ||||||||||||||||||
7409 | ttok = parse_matched_pair (cd, '[', ']', &ttoklen, P_ARRAYSUB); | - | ||||||||||||||||||
7410 | if (ttok == &matched_pair_error) | - | ||||||||||||||||||
7411 | return -1; /* Bail immediately. */ | - | ||||||||||||||||||
7412 | RESIZE_MALLOCED_BUFFER (token, token_index, ttoklen + 2, | - | ||||||||||||||||||
7413 | token_buffer_size, | - | ||||||||||||||||||
7414 | TOKEN_DEFAULT_GROW_SIZE); | - | ||||||||||||||||||
7415 | token[token_index++] = character; | - | ||||||||||||||||||
7416 | strcpy (token + token_index, ttok); | - | ||||||||||||||||||
7417 | token_index += ttoklen; | - | ||||||||||||||||||
7418 | FREE (ttok); | - | ||||||||||||||||||
7419 | all_digit_token = 0; | - | ||||||||||||||||||
7420 | goto next_character; | - | ||||||||||||||||||
7421 | } | - | ||||||||||||||||||
7422 | /* Identify possible compound array variable assignment. */ | - | ||||||||||||||||||
7423 | else if MBTEST(character == '=' && token_index > 0 && (assignment_acceptable (last_read_token) || (parser_state & PST_ASSIGNOK)) && token_is_assignment (token, token_index)) | - | ||||||||||||||||||
7424 | { | - | ||||||||||||||||||
7425 | peek_char = shell_getc (1); | - | ||||||||||||||||||
7426 | if MBTEST(peek_char == '(') /* ) */ | - | ||||||||||||||||||
7427 | { | - | ||||||||||||||||||
7428 | ttok = parse_compound_assignment (&ttoklen); | - | ||||||||||||||||||
7429 | - | |||||||||||||||||||
7430 | RESIZE_MALLOCED_BUFFER (token, token_index, ttoklen + 4, | - | ||||||||||||||||||
7431 | token_buffer_size, | - | ||||||||||||||||||
7432 | TOKEN_DEFAULT_GROW_SIZE); | - | ||||||||||||||||||
7433 | - | |||||||||||||||||||
7434 | token[token_index++] = '='; | - | ||||||||||||||||||
7435 | token[token_index++] = '('; | - | ||||||||||||||||||
7436 | if (ttok) | - | ||||||||||||||||||
7437 | { | - | ||||||||||||||||||
7438 | strcpy (token + token_index, ttok); | - | ||||||||||||||||||
7439 | token_index += ttoklen; | - | ||||||||||||||||||
7440 | } | - | ||||||||||||||||||
7441 | token[token_index++] = ')'; | - | ||||||||||||||||||
7442 | FREE (ttok); | - | ||||||||||||||||||
7443 | all_digit_token = 0; | - | ||||||||||||||||||
7444 | compound_assignment = 1; | - | ||||||||||||||||||
7445 | #if 1 | - | ||||||||||||||||||
7446 | goto next_character; | - | ||||||||||||||||||
7447 | #else | - | ||||||||||||||||||
7448 | goto got_token; /* ksh93 seems to do this */ | - | ||||||||||||||||||
7449 | #endif | - | ||||||||||||||||||
7450 | } | - | ||||||||||||||||||
7451 | else | - | ||||||||||||||||||
7452 | shell_ungetc (peek_char); | - | ||||||||||||||||||
7453 | } | - | ||||||||||||||||||
7454 | #endif | - | ||||||||||||||||||
7455 | - | |||||||||||||||||||
7456 | /* When not parsing a multi-character word construct, shell meta- | - | ||||||||||||||||||
7457 | characters break words. */ | - | ||||||||||||||||||
7458 | if MBTEST(shellbreak (character)) | - | ||||||||||||||||||
7459 | { | - | ||||||||||||||||||
7460 | shell_ungetc (character); | - | ||||||||||||||||||
7461 | goto got_token; | - | ||||||||||||||||||
7462 | } | - | ||||||||||||||||||
7463 | - | |||||||||||||||||||
7464 | got_character: | - | ||||||||||||||||||
7465 | if (character == CTLESC || character == CTLNUL) | - | ||||||||||||||||||
7466 | { | - | ||||||||||||||||||
7467 | RESIZE_MALLOCED_BUFFER (token, token_index, 2, token_buffer_size, | - | ||||||||||||||||||
7468 | TOKEN_DEFAULT_GROW_SIZE); | - | ||||||||||||||||||
7469 | token[token_index++] = CTLESC; | - | ||||||||||||||||||
7470 | } | - | ||||||||||||||||||
7471 | else | - | ||||||||||||||||||
7472 | got_escaped_character: | - | ||||||||||||||||||
7473 | RESIZE_MALLOCED_BUFFER (token, token_index, 1, token_buffer_size, | - | ||||||||||||||||||
7474 | TOKEN_DEFAULT_GROW_SIZE); | - | ||||||||||||||||||
7475 | - | |||||||||||||||||||
7476 | token[token_index++] = character; | - | ||||||||||||||||||
7477 | - | |||||||||||||||||||
7478 | all_digit_token &= DIGIT (character); | - | ||||||||||||||||||
7479 | dollar_present |= character == '$'; | - | ||||||||||||||||||
7480 | - | |||||||||||||||||||
7481 | next_character: | - | ||||||||||||||||||
7482 | if (character == '\n' && SHOULD_PROMPT ()) | - | ||||||||||||||||||
7483 | prompt_again (); | - | ||||||||||||||||||
7484 | - | |||||||||||||||||||
7485 | /* We want to remove quoted newlines (that is, a \<newline> pair) | - | ||||||||||||||||||
7486 | unless we are within single quotes or pass_next_character is | - | ||||||||||||||||||
7487 | set (the shell equivalent of literal-next). */ | - | ||||||||||||||||||
7488 | cd = current_delimiter (dstack); | - | ||||||||||||||||||
7489 | character = shell_getc (cd != '\'' && pass_next_character == 0); | - | ||||||||||||||||||
7490 | } /* end for (;;) */ | - | ||||||||||||||||||
7491 | - | |||||||||||||||||||
7492 | got_token: | - | ||||||||||||||||||
7493 | - | |||||||||||||||||||
7494 | /* Calls to RESIZE_MALLOCED_BUFFER ensure there is sufficient room. */ | - | ||||||||||||||||||
7495 | token[token_index] = '\0'; | - | ||||||||||||||||||
7496 | - | |||||||||||||||||||
7497 | /* Check to see what thing we should return. If the last_read_token | - | ||||||||||||||||||
7498 | is a `<', or a `&', or the character which ended this token is | - | ||||||||||||||||||
7499 | a '>' or '<', then, and ONLY then, is this input token a NUMBER. | - | ||||||||||||||||||
7500 | Otherwise, it is just a word, and should be returned as such. */ | - | ||||||||||||||||||
7501 | if MBTEST(all_digit_token && (character == '<' || character == '>' || | - | ||||||||||||||||||
7502 | last_read_token == LESS_AND || | - | ||||||||||||||||||
7503 | last_read_token == GREATER_AND)) | - | ||||||||||||||||||
7504 | { | - | ||||||||||||||||||
7505 | if (legal_number (token, &lvalue) && (int)lvalue == lvalue) | - | ||||||||||||||||||
7506 | { | - | ||||||||||||||||||
7507 | yylval.number = lvalue; | - | ||||||||||||||||||
7508 | return (NUMBER); | - | ||||||||||||||||||
7509 | } | - | ||||||||||||||||||
7510 | } | - | ||||||||||||||||||
7511 | - | |||||||||||||||||||
7512 | /* Check for special case tokens. */ | - | ||||||||||||||||||
7513 | result = (last_shell_getc_is_singlebyte) ? special_case_tokens (token) : -1; | - | ||||||||||||||||||
7514 | if (result >= 0) | - | ||||||||||||||||||
7515 | return result; | - | ||||||||||||||||||
7516 | - | |||||||||||||||||||
7517 | #if defined (ALIAS) | - | ||||||||||||||||||
7518 | /* Posix.2 does not allow reserved words to be aliased, so check for all | - | ||||||||||||||||||
7519 | of them, including special cases, before expanding the current token | - | ||||||||||||||||||
7520 | as an alias. */ | - | ||||||||||||||||||
7521 | if MBTEST(posixly_correct) | - | ||||||||||||||||||
7522 | CHECK_FOR_RESERVED_WORD (token); | - | ||||||||||||||||||
7523 | - | |||||||||||||||||||
7524 | /* Aliases are expanded iff EXPAND_ALIASES is non-zero, and quoting | - | ||||||||||||||||||
7525 | inhibits alias expansion. */ | - | ||||||||||||||||||
7526 | if (expand_aliases && quoted == 0) | - | ||||||||||||||||||
7527 | { | - | ||||||||||||||||||
7528 | result = alias_expand_token (token); | - | ||||||||||||||||||
7529 | if (result == RE_READ_TOKEN) | - | ||||||||||||||||||
7530 | return (RE_READ_TOKEN); | - | ||||||||||||||||||
7531 | else if (result == NO_EXPANSION) | - | ||||||||||||||||||
7532 | parser_state &= ~PST_ALEXPNEXT; | - | ||||||||||||||||||
7533 | } | - | ||||||||||||||||||
7534 | - | |||||||||||||||||||
7535 | /* If not in Posix.2 mode, check for reserved words after alias | - | ||||||||||||||||||
7536 | expansion. */ | - | ||||||||||||||||||
7537 | if MBTEST(posixly_correct == 0) | - | ||||||||||||||||||
7538 | #endif | - | ||||||||||||||||||
7539 | CHECK_FOR_RESERVED_WORD (token); | - | ||||||||||||||||||
7540 | - | |||||||||||||||||||
7541 | the_word = alloc_word_desc (); | - | ||||||||||||||||||
7542 | the_word->word = (char *)xmalloc (1 + token_index); | - | ||||||||||||||||||
7543 | the_word->flags = 0; | - | ||||||||||||||||||
7544 | strcpy (the_word->word, token); | - | ||||||||||||||||||
7545 | if (dollar_present) | - | ||||||||||||||||||
7546 | the_word->flags |= W_HASDOLLAR; | - | ||||||||||||||||||
7547 | if (quoted) | - | ||||||||||||||||||
7548 | the_word->flags |= W_QUOTED; /*(*/ | - | ||||||||||||||||||
7549 | if (compound_assignment && token[token_index-1] == ')') | - | ||||||||||||||||||
7550 | the_word->flags |= W_COMPASSIGN; | - | ||||||||||||||||||
7551 | /* A word is an assignment if it appears at the beginning of a | - | ||||||||||||||||||
7552 | simple command, or after another assignment word. This is | - | ||||||||||||||||||
7553 | context-dependent, so it cannot be handled in the grammar. */ | - | ||||||||||||||||||
7554 | if (assignment (token, (parser_state & PST_COMPASSIGN) != 0)) | - | ||||||||||||||||||
7555 | { | - | ||||||||||||||||||
7556 | the_word->flags |= W_ASSIGNMENT; | - | ||||||||||||||||||
7557 | /* Don't perform word splitting on assignment statements. */ | - | ||||||||||||||||||
7558 | if (assignment_acceptable (last_read_token) || (parser_state & PST_COMPASSIGN) != 0) | - | ||||||||||||||||||
7559 | { | - | ||||||||||||||||||
7560 | the_word->flags |= W_NOSPLIT; | - | ||||||||||||||||||
7561 | if (parser_state & PST_COMPASSIGN) | - | ||||||||||||||||||
7562 | the_word->flags |= W_NOGLOB; /* XXX - W_NOBRACE? */ | - | ||||||||||||||||||
7563 | } | - | ||||||||||||||||||
7564 | } | - | ||||||||||||||||||
7565 | - | |||||||||||||||||||
7566 | if (command_token_position (last_read_token)) | - | ||||||||||||||||||
7567 | { | - | ||||||||||||||||||
7568 | struct builtin *b; | - | ||||||||||||||||||
7569 | b = builtin_address_internal (token, 0); | - | ||||||||||||||||||
7570 | if (b && (b->flags & ASSIGNMENT_BUILTIN)) | - | ||||||||||||||||||
7571 | parser_state |= PST_ASSIGNOK; | - | ||||||||||||||||||
7572 | else if (STREQ (token, "eval") || STREQ (token, "let")) | - | ||||||||||||||||||
7573 | parser_state |= PST_ASSIGNOK; | - | ||||||||||||||||||
7574 | } | - | ||||||||||||||||||
7575 | - | |||||||||||||||||||
7576 | yylval.word = the_word; | - | ||||||||||||||||||
7577 | - | |||||||||||||||||||
7578 | if (token[0] == '{' && token[token_index-1] == '}' && | - | ||||||||||||||||||
7579 | (character == '<' || character == '>')) | - | ||||||||||||||||||
7580 | { | - | ||||||||||||||||||
7581 | /* can use token; already copied to the_word */ | - | ||||||||||||||||||
7582 | token[token_index-1] = '\0'; | - | ||||||||||||||||||
7583 | #if defined (ARRAY_VARS) | - | ||||||||||||||||||
7584 | if (legal_identifier (token+1) || valid_array_reference (token+1, 0)) | - | ||||||||||||||||||
7585 | #else | - | ||||||||||||||||||
7586 | if (legal_identifier (token+1)) | - | ||||||||||||||||||
7587 | #endif | - | ||||||||||||||||||
7588 | { | - | ||||||||||||||||||
7589 | strcpy (the_word->word, token+1); | - | ||||||||||||||||||
7590 | /*itrace("read_token_word: returning REDIR_WORD for %s", the_word->word);*/ | - | ||||||||||||||||||
7591 | return (REDIR_WORD); | - | ||||||||||||||||||
7592 | } | - | ||||||||||||||||||
7593 | else | - | ||||||||||||||||||
7594 | /* valid_array_reference can call the parser recursively; need to | - | ||||||||||||||||||
7595 | make sure that yylval.word doesn't change if we are going to | - | ||||||||||||||||||
7596 | return WORD or ASSIGNMENT_WORD */ | - | ||||||||||||||||||
7597 | yylval.word = the_word; | - | ||||||||||||||||||
7598 | } | - | ||||||||||||||||||
7599 | - | |||||||||||||||||||
7600 | result = ((the_word->flags & (W_ASSIGNMENT|W_NOSPLIT)) == (W_ASSIGNMENT|W_NOSPLIT)) | - | ||||||||||||||||||
7601 | ? ASSIGNMENT_WORD : WORD; | - | ||||||||||||||||||
7602 | - | |||||||||||||||||||
7603 | switch (last_read_token) | - | ||||||||||||||||||
7604 | { | - | ||||||||||||||||||
7605 | case FUNCTION: | - | ||||||||||||||||||
7606 | parser_state |= PST_ALLOWOPNBRC; | - | ||||||||||||||||||
7607 | function_dstart = line_number; | - | ||||||||||||||||||
7608 | break; | - | ||||||||||||||||||
7609 | case CASE: | - | ||||||||||||||||||
7610 | case SELECT: | - | ||||||||||||||||||
7611 | case FOR: | - | ||||||||||||||||||
7612 | if (word_top < MAX_CASE_NEST) | - | ||||||||||||||||||
7613 | word_top++; | - | ||||||||||||||||||
7614 | word_lineno[word_top] = line_number; | - | ||||||||||||||||||
7615 | expecting_in_token++; | - | ||||||||||||||||||
7616 | break; | - | ||||||||||||||||||
7617 | } | - | ||||||||||||||||||
7618 | - | |||||||||||||||||||
7619 | return (result); | - | ||||||||||||||||||
7620 | } | - | ||||||||||||||||||
7621 | - | |||||||||||||||||||
7622 | /* Return 1 if TOKSYM is a token that after being read would allow | - | ||||||||||||||||||
7623 | a reserved word to be seen, else 0. */ | - | ||||||||||||||||||
7624 | static int | - | ||||||||||||||||||
7625 | reserved_word_acceptable (toksym) | - | ||||||||||||||||||
7626 | int toksym; | - | ||||||||||||||||||
7627 | { | - | ||||||||||||||||||
7628 | switch (toksym) | - | ||||||||||||||||||
7629 | { | - | ||||||||||||||||||
7630 | case '\n': | - | ||||||||||||||||||
7631 | case ';': | - | ||||||||||||||||||
7632 | case '(': | - | ||||||||||||||||||
7633 | case ')': | - | ||||||||||||||||||
7634 | case '|': | - | ||||||||||||||||||
7635 | case '&': | - | ||||||||||||||||||
7636 | case '{': | - | ||||||||||||||||||
7637 | case '}': /* XXX */ | - | ||||||||||||||||||
7638 | case AND_AND: | - | ||||||||||||||||||
7639 | case BANG: | - | ||||||||||||||||||
7640 | case BAR_AND: | - | ||||||||||||||||||
7641 | case DO: | - | ||||||||||||||||||
7642 | case DONE: | - | ||||||||||||||||||
7643 | case ELIF: | - | ||||||||||||||||||
7644 | case ELSE: | - | ||||||||||||||||||
7645 | case ESAC: | - | ||||||||||||||||||
7646 | case FI: | - | ||||||||||||||||||
7647 | case IF: | - | ||||||||||||||||||
7648 | case OR_OR: | - | ||||||||||||||||||
7649 | case SEMI_SEMI: | - | ||||||||||||||||||
7650 | case SEMI_AND: | - | ||||||||||||||||||
7651 | case SEMI_SEMI_AND: | - | ||||||||||||||||||
7652 | case THEN: | - | ||||||||||||||||||
7653 | case TIME: | - | ||||||||||||||||||
7654 | case TIMEOPT: | - | ||||||||||||||||||
7655 | case TIMEIGN: | - | ||||||||||||||||||
7656 | case COPROC: | - | ||||||||||||||||||
7657 | case UNTIL: | - | ||||||||||||||||||
7658 | case WHILE: | - | ||||||||||||||||||
7659 | case 0: | - | ||||||||||||||||||
7660 | return 1; | - | ||||||||||||||||||
7661 | default: | - | ||||||||||||||||||
7662 | #if defined (COPROCESS_SUPPORT) | - | ||||||||||||||||||
7663 | if (last_read_token == WORD && token_before_that == COPROC) | - | ||||||||||||||||||
7664 | return 1; | - | ||||||||||||||||||
7665 | #endif | - | ||||||||||||||||||
7666 | if (last_read_token == WORD && token_before_that == FUNCTION) | - | ||||||||||||||||||
7667 | return 1; | - | ||||||||||||||||||
7668 | return 0; | - | ||||||||||||||||||
7669 | } | - | ||||||||||||||||||
7670 | } | - | ||||||||||||||||||
7671 | - | |||||||||||||||||||
7672 | /* Return the index of TOKEN in the alist of reserved words, or -1 if | - | ||||||||||||||||||
7673 | TOKEN is not a shell reserved word. */ | - | ||||||||||||||||||
7674 | int | - | ||||||||||||||||||
7675 | find_reserved_word (tokstr) | - | ||||||||||||||||||
7676 | char *tokstr; | - | ||||||||||||||||||
7677 | { | - | ||||||||||||||||||
7678 | int i; | - | ||||||||||||||||||
7679 | for (i = 0; word_token_alist[i].word; i++) | - | ||||||||||||||||||
7680 | if (STREQ (tokstr, word_token_alist[i].word)) | - | ||||||||||||||||||
7681 | return i; | - | ||||||||||||||||||
7682 | return -1; | - | ||||||||||||||||||
7683 | } | - | ||||||||||||||||||
7684 | - | |||||||||||||||||||
7685 | /* An interface to let the rest of the shell (primarily the completion | - | ||||||||||||||||||
7686 | system) know what the parser is expecting. */ | - | ||||||||||||||||||
7687 | int | - | ||||||||||||||||||
7688 | parser_in_command_position () | - | ||||||||||||||||||
7689 | { | - | ||||||||||||||||||
7690 | return (command_token_position (last_read_token)); | - | ||||||||||||||||||
7691 | } | - | ||||||||||||||||||
7692 | - | |||||||||||||||||||
7693 | #if 0 | - | ||||||||||||||||||
7694 | #if defined (READLINE) | - | ||||||||||||||||||
7695 | /* Called after each time readline is called. This insures that whatever | - | ||||||||||||||||||
7696 | the new prompt string is gets propagated to readline's local prompt | - | ||||||||||||||||||
7697 | variable. */ | - | ||||||||||||||||||
7698 | static void | - | ||||||||||||||||||
7699 | reset_readline_prompt () | - | ||||||||||||||||||
7700 | { | - | ||||||||||||||||||
7701 | char *temp_prompt; | - | ||||||||||||||||||
7702 | - | |||||||||||||||||||
7703 | if (prompt_string_pointer) | - | ||||||||||||||||||
7704 | { | - | ||||||||||||||||||
7705 | temp_prompt = (*prompt_string_pointer) | - | ||||||||||||||||||
7706 | ? decode_prompt_string (*prompt_string_pointer) | - | ||||||||||||||||||
7707 | : (char *)NULL; | - | ||||||||||||||||||
7708 | - | |||||||||||||||||||
7709 | if (temp_prompt == 0) | - | ||||||||||||||||||
7710 | { | - | ||||||||||||||||||
7711 | temp_prompt = (char *)xmalloc (1); | - | ||||||||||||||||||
7712 | temp_prompt[0] = '\0'; | - | ||||||||||||||||||
7713 | } | - | ||||||||||||||||||
7714 | - | |||||||||||||||||||
7715 | FREE (current_readline_prompt); | - | ||||||||||||||||||
7716 | current_readline_prompt = temp_prompt; | - | ||||||||||||||||||
7717 | } | - | ||||||||||||||||||
7718 | } | - | ||||||||||||||||||
7719 | #endif /* READLINE */ | - | ||||||||||||||||||
7720 | #endif /* 0 */ | - | ||||||||||||||||||
7721 | - | |||||||||||||||||||
7722 | #if defined (HISTORY) | - | ||||||||||||||||||
7723 | /* A list of tokens which can be followed by newlines, but not by | - | ||||||||||||||||||
7724 | semi-colons. When concatenating multiple lines of history, the | - | ||||||||||||||||||
7725 | newline separator for such tokens is replaced with a space. */ | - | ||||||||||||||||||
7726 | static const int no_semi_successors[] = { | - | ||||||||||||||||||
7727 | '\n', '{', '(', ')', ';', '&', '|', | - | ||||||||||||||||||
7728 | CASE, DO, ELSE, IF, SEMI_SEMI, SEMI_AND, SEMI_SEMI_AND, THEN, UNTIL, | - | ||||||||||||||||||
7729 | WHILE, AND_AND, OR_OR, IN, | - | ||||||||||||||||||
7730 | 0 | - | ||||||||||||||||||
7731 | }; | - | ||||||||||||||||||
7732 | - | |||||||||||||||||||
7733 | /* If we are not within a delimited expression, try to be smart | - | ||||||||||||||||||
7734 | about which separators can be semi-colons and which must be | - | ||||||||||||||||||
7735 | newlines. Returns the string that should be added into the | - | ||||||||||||||||||
7736 | history entry. LINE is the line we're about to add; it helps | - | ||||||||||||||||||
7737 | make some more intelligent decisions in certain cases. */ | - | ||||||||||||||||||
7738 | char * | - | ||||||||||||||||||
7739 | history_delimiting_chars (line) | - | ||||||||||||||||||
7740 | const char *line; | - | ||||||||||||||||||
7741 | { | - | ||||||||||||||||||
7742 | static int last_was_heredoc = 0; /* was the last entry the start of a here document? */ | - | ||||||||||||||||||
7743 | register int i; | - | ||||||||||||||||||
7744 | - | |||||||||||||||||||
7745 | if ((parser_state & PST_HEREDOC) == 0) | - | ||||||||||||||||||
7746 | last_was_heredoc = 0; | - | ||||||||||||||||||
7747 | - | |||||||||||||||||||
7748 | if (dstack.delimiter_depth != 0) | - | ||||||||||||||||||
7749 | return ("\n"); | - | ||||||||||||||||||
7750 | - | |||||||||||||||||||
7751 | /* We look for current_command_line_count == 2 because we are looking to | - | ||||||||||||||||||
7752 | add the first line of the body of the here document (the second line | - | ||||||||||||||||||
7753 | of the command). We also keep LAST_WAS_HEREDOC as a private sentinel | - | ||||||||||||||||||
7754 | variable to note when we think we added the first line of a here doc | - | ||||||||||||||||||
7755 | (the one with a "<<" somewhere in it) */ | - | ||||||||||||||||||
7756 | if (parser_state & PST_HEREDOC) | - | ||||||||||||||||||
7757 | { | - | ||||||||||||||||||
7758 | if (last_was_heredoc) | - | ||||||||||||||||||
7759 | { | - | ||||||||||||||||||
7760 | last_was_heredoc = 0; | - | ||||||||||||||||||
7761 | return "\n"; | - | ||||||||||||||||||
7762 | } | - | ||||||||||||||||||
7763 | return (here_doc_first_line ? "\n" : ""); | - | ||||||||||||||||||
7764 | } | - | ||||||||||||||||||
7765 | - | |||||||||||||||||||
7766 | if (parser_state & PST_COMPASSIGN) | - | ||||||||||||||||||
7767 | return (" "); | - | ||||||||||||||||||
7768 | - | |||||||||||||||||||
7769 | /* First, handle some special cases. */ | - | ||||||||||||||||||
7770 | /*(*/ | - | ||||||||||||||||||
7771 | /* If we just read `()', assume it's a function definition, and don't | - | ||||||||||||||||||
7772 | add a semicolon. If the token before the `)' was not `(', and we're | - | ||||||||||||||||||
7773 | not in the midst of parsing a case statement, assume it's a | - | ||||||||||||||||||
7774 | parenthesized command and add the semicolon. */ | - | ||||||||||||||||||
7775 | /*)(*/ | - | ||||||||||||||||||
7776 | if (token_before_that == ')') | - | ||||||||||||||||||
7777 | { | - | ||||||||||||||||||
7778 | if (two_tokens_ago == '(') /*)*/ /* function def */ | - | ||||||||||||||||||
7779 | return " "; | - | ||||||||||||||||||
7780 | /* This does not work for subshells inside case statement | - | ||||||||||||||||||
7781 | command lists. It's a suboptimal solution. */ | - | ||||||||||||||||||
7782 | else if (parser_state & PST_CASESTMT) /* case statement pattern */ | - | ||||||||||||||||||
7783 | return " "; | - | ||||||||||||||||||
7784 | else | - | ||||||||||||||||||
7785 | return "; "; /* (...) subshell */ | - | ||||||||||||||||||
7786 | } | - | ||||||||||||||||||
7787 | else if (token_before_that == WORD && two_tokens_ago == FUNCTION) | - | ||||||||||||||||||
7788 | return " "; /* function def using `function name' without `()' */ | - | ||||||||||||||||||
7789 | - | |||||||||||||||||||
7790 | /* If we're not in a here document, but we think we're about to parse one, | - | ||||||||||||||||||
7791 | and we would otherwise return a `;', return a newline to delimit the | - | ||||||||||||||||||
7792 | line with the here-doc delimiter */ | - | ||||||||||||||||||
7793 | else if ((parser_state & PST_HEREDOC) == 0 && current_command_line_count > 1 && last_read_token == '\n' && strstr (line, "<<")) | - | ||||||||||||||||||
7794 | { | - | ||||||||||||||||||
7795 | last_was_heredoc = 1; | - | ||||||||||||||||||
7796 | return "\n"; | - | ||||||||||||||||||
7797 | } | - | ||||||||||||||||||
7798 | else if ((parser_state & PST_HEREDOC) == 0 && current_command_line_count > 1 && need_here_doc > 0) | - | ||||||||||||||||||
7799 | return "\n"; | - | ||||||||||||||||||
7800 | else if (token_before_that == WORD && two_tokens_ago == FOR) | - | ||||||||||||||||||
7801 | { | - | ||||||||||||||||||
7802 | /* Tricky. `for i\nin ...' should not have a semicolon, but | - | ||||||||||||||||||
7803 | `for i\ndo ...' should. We do what we can. */ | - | ||||||||||||||||||
7804 | for (i = shell_input_line_index; whitespace (shell_input_line[i]); i++) | - | ||||||||||||||||||
7805 | ; | - | ||||||||||||||||||
7806 | if (shell_input_line[i] && shell_input_line[i] == 'i' && shell_input_line[i+1] == 'n') | - | ||||||||||||||||||
7807 | return " "; | - | ||||||||||||||||||
7808 | return ";"; | - | ||||||||||||||||||
7809 | } | - | ||||||||||||||||||
7810 | else if (two_tokens_ago == CASE && token_before_that == WORD && (parser_state & PST_CASESTMT)) | - | ||||||||||||||||||
7811 | return " "; | - | ||||||||||||||||||
7812 | - | |||||||||||||||||||
7813 | for (i = 0; no_semi_successors[i]; i++) | - | ||||||||||||||||||
7814 | { | - | ||||||||||||||||||
7815 | if (token_before_that == no_semi_successors[i]) | - | ||||||||||||||||||
7816 | return (" "); | - | ||||||||||||||||||
7817 | } | - | ||||||||||||||||||
7818 | - | |||||||||||||||||||
7819 | if (line_isblank (line)) | - | ||||||||||||||||||
7820 | return (""); | - | ||||||||||||||||||
7821 | - | |||||||||||||||||||
7822 | return ("; "); | - | ||||||||||||||||||
7823 | } | - | ||||||||||||||||||
7824 | #endif /* HISTORY */ | - | ||||||||||||||||||
7825 | - | |||||||||||||||||||
7826 | /* Issue a prompt, or prepare to issue a prompt when the next character | - | ||||||||||||||||||
7827 | is read. */ | - | ||||||||||||||||||
7828 | static void | - | ||||||||||||||||||
7829 | prompt_again () | - | ||||||||||||||||||
7830 | { | - | ||||||||||||||||||
7831 | char *temp_prompt; | - | ||||||||||||||||||
7832 | - | |||||||||||||||||||
7833 | if (interactive == 0 || expanding_alias ()) /* XXX */ | - | ||||||||||||||||||
7834 | return; | - | ||||||||||||||||||
7835 | - | |||||||||||||||||||
7836 | ps1_prompt = get_string_value ("PS1"); | - | ||||||||||||||||||
7837 | ps2_prompt = get_string_value ("PS2"); | - | ||||||||||||||||||
7838 | - | |||||||||||||||||||
7839 | ps0_prompt = get_string_value ("PS0"); | - | ||||||||||||||||||
7840 | - | |||||||||||||||||||
7841 | if (!prompt_string_pointer) | - | ||||||||||||||||||
7842 | prompt_string_pointer = &ps1_prompt; | - | ||||||||||||||||||
7843 | - | |||||||||||||||||||
7844 | temp_prompt = *prompt_string_pointer | - | ||||||||||||||||||
7845 | ? decode_prompt_string (*prompt_string_pointer) | - | ||||||||||||||||||
7846 | : (char *)NULL; | - | ||||||||||||||||||
7847 | - | |||||||||||||||||||
7848 | if (temp_prompt == 0) | - | ||||||||||||||||||
7849 | { | - | ||||||||||||||||||
7850 | temp_prompt = (char *)xmalloc (1); | - | ||||||||||||||||||
7851 | temp_prompt[0] = '\0'; | - | ||||||||||||||||||
7852 | } | - | ||||||||||||||||||
7853 | - | |||||||||||||||||||
7854 | current_prompt_string = *prompt_string_pointer; | - | ||||||||||||||||||
7855 | prompt_string_pointer = &ps2_prompt; | - | ||||||||||||||||||
7856 | - | |||||||||||||||||||
7857 | #if defined (READLINE) | - | ||||||||||||||||||
7858 | if (!no_line_editing) | - | ||||||||||||||||||
7859 | { | - | ||||||||||||||||||
7860 | FREE (current_readline_prompt); | - | ||||||||||||||||||
7861 | current_readline_prompt = temp_prompt; | - | ||||||||||||||||||
7862 | } | - | ||||||||||||||||||
7863 | else | - | ||||||||||||||||||
7864 | #endif /* READLINE */ | - | ||||||||||||||||||
7865 | { | - | ||||||||||||||||||
7866 | FREE (current_decoded_prompt); | - | ||||||||||||||||||
7867 | current_decoded_prompt = temp_prompt; | - | ||||||||||||||||||
7868 | } | - | ||||||||||||||||||
7869 | } | - | ||||||||||||||||||
7870 | - | |||||||||||||||||||
7871 | int | - | ||||||||||||||||||
7872 | get_current_prompt_level () | - | ||||||||||||||||||
7873 | { | - | ||||||||||||||||||
7874 | return ((current_prompt_string && current_prompt_string == ps2_prompt) ? 2 : 1); | - | ||||||||||||||||||
7875 | } | - | ||||||||||||||||||
7876 | - | |||||||||||||||||||
7877 | void | - | ||||||||||||||||||
7878 | set_current_prompt_level (x) | - | ||||||||||||||||||
7879 | int x; | - | ||||||||||||||||||
7880 | { | - | ||||||||||||||||||
7881 | prompt_string_pointer = (x == 2) ? &ps2_prompt : &ps1_prompt; | - | ||||||||||||||||||
7882 | current_prompt_string = *prompt_string_pointer; | - | ||||||||||||||||||
7883 | } | - | ||||||||||||||||||
7884 | - | |||||||||||||||||||
7885 | static void | - | ||||||||||||||||||
7886 | print_prompt () | - | ||||||||||||||||||
7887 | { | - | ||||||||||||||||||
7888 | fprintf (stderr, "%s", current_decoded_prompt); | - | ||||||||||||||||||
7889 | fflush (stderr); | - | ||||||||||||||||||
7890 | } | - | ||||||||||||||||||
7891 | - | |||||||||||||||||||
7892 | #if defined (HISTORY) | - | ||||||||||||||||||
7893 | /* The history library increments the history offset as soon as it stores | - | ||||||||||||||||||
7894 | the first line of a potentially multi-line command, so we compensate | - | ||||||||||||||||||
7895 | here by returning one fewer when appropriate. */ | - | ||||||||||||||||||
7896 | static int | - | ||||||||||||||||||
7897 | prompt_history_number (pmt) | - | ||||||||||||||||||
7898 | char *pmt; | - | ||||||||||||||||||
7899 | { | - | ||||||||||||||||||
7900 | int ret; | - | ||||||||||||||||||
7901 | - | |||||||||||||||||||
7902 | ret = history_number (); | - | ||||||||||||||||||
7903 | if (ret == 1) | - | ||||||||||||||||||
7904 | return ret; | - | ||||||||||||||||||
7905 | - | |||||||||||||||||||
7906 | if (pmt == ps1_prompt) /* are we expanding $PS1? */ | - | ||||||||||||||||||
7907 | return ret; | - | ||||||||||||||||||
7908 | else if (pmt == ps2_prompt && command_oriented_history == 0) | - | ||||||||||||||||||
7909 | return ret; /* not command oriented history */ | - | ||||||||||||||||||
7910 | else if (pmt == ps2_prompt && command_oriented_history && current_command_first_line_saved) | - | ||||||||||||||||||
7911 | return ret - 1; | - | ||||||||||||||||||
7912 | else | - | ||||||||||||||||||
7913 | return ret - 1; /* PS0, PS4, ${var@P}, PS2 other cases */ | - | ||||||||||||||||||
7914 | } | - | ||||||||||||||||||
7915 | #endif | - | ||||||||||||||||||
7916 | - | |||||||||||||||||||
7917 | /* Return a string which will be printed as a prompt. The string | - | ||||||||||||||||||
7918 | may contain special characters which are decoded as follows: | - | ||||||||||||||||||
7919 | - | |||||||||||||||||||
7920 | \a bell (ascii 07) | - | ||||||||||||||||||
7921 | \d the date in Day Mon Date format | - | ||||||||||||||||||
7922 | \e escape (ascii 033) | - | ||||||||||||||||||
7923 | \h the hostname up to the first `.' | - | ||||||||||||||||||
7924 | \H the hostname | - | ||||||||||||||||||
7925 | \j the number of active jobs | - | ||||||||||||||||||
7926 | \l the basename of the shell's tty device name | - | ||||||||||||||||||
7927 | \n CRLF | - | ||||||||||||||||||
7928 | \r CR | - | ||||||||||||||||||
7929 | \s the name of the shell | - | ||||||||||||||||||
7930 | \t the time in 24-hour hh:mm:ss format | - | ||||||||||||||||||
7931 | \T the time in 12-hour hh:mm:ss format | - | ||||||||||||||||||
7932 | \@ the time in 12-hour hh:mm am/pm format | - | ||||||||||||||||||
7933 | \A the time in 24-hour hh:mm format | - | ||||||||||||||||||
7934 | \D{fmt} the result of passing FMT to strftime(3) | - | ||||||||||||||||||
7935 | \u your username | - | ||||||||||||||||||
7936 | \v the version of bash (e.g., 2.00) | - | ||||||||||||||||||
7937 | \V the release of bash, version + patchlevel (e.g., 2.00.0) | - | ||||||||||||||||||
7938 | \w the current working directory | - | ||||||||||||||||||
7939 | \W the last element of $PWD | - | ||||||||||||||||||
7940 | \! the history number of this command | - | ||||||||||||||||||
7941 | \# the command number of this command | - | ||||||||||||||||||
7942 | \$ a $ or a # if you are root | - | ||||||||||||||||||
7943 | \nnn character code nnn in octal | - | ||||||||||||||||||
7944 | \\ a backslash | - | ||||||||||||||||||
7945 | \[ begin a sequence of non-printing chars | - | ||||||||||||||||||
7946 | \] end a sequence of non-printing chars | - | ||||||||||||||||||
7947 | */ | - | ||||||||||||||||||
7948 | #define PROMPT_GROWTH 48 | - | ||||||||||||||||||
7949 | char * | - | ||||||||||||||||||
7950 | decode_prompt_string (string) | - | ||||||||||||||||||
7951 | char *string; | - | ||||||||||||||||||
7952 | { | - | ||||||||||||||||||
7953 | WORD_LIST *list; | - | ||||||||||||||||||
7954 | char *result, *t, *orig_string; | - | ||||||||||||||||||
7955 | struct dstack save_dstack; | - | ||||||||||||||||||
7956 | int last_exit_value, last_comsub_pid; | - | ||||||||||||||||||
7957 | #if defined (PROMPT_STRING_DECODE) | - | ||||||||||||||||||
7958 | size_t result_size; | - | ||||||||||||||||||
7959 | int result_index; | - | ||||||||||||||||||
7960 | int c, n, i; | - | ||||||||||||||||||
7961 | char *temp, *t_host, octal_string[4]; | - | ||||||||||||||||||
7962 | struct tm *tm; | - | ||||||||||||||||||
7963 | time_t the_time; | - | ||||||||||||||||||
7964 | char timebuf[128]; | - | ||||||||||||||||||
7965 | char *timefmt; | - | ||||||||||||||||||
7966 | - | |||||||||||||||||||
7967 | result = (char *)xmalloc (result_size = PROMPT_GROWTH); | - | ||||||||||||||||||
7968 | result[result_index = 0] = 0; | - | ||||||||||||||||||
7969 | temp = (char *)NULL; | - | ||||||||||||||||||
7970 | orig_string = string; | - | ||||||||||||||||||
7971 | - | |||||||||||||||||||
7972 | while (c = *string++) | - | ||||||||||||||||||
7973 | { | - | ||||||||||||||||||
7974 | if (posixly_correct && c == '!') | - | ||||||||||||||||||
7975 | { | - | ||||||||||||||||||
7976 | if (*string == '!') | - | ||||||||||||||||||
7977 | { | - | ||||||||||||||||||
7978 | temp = savestring ("!"); | - | ||||||||||||||||||
7979 | goto add_string; | - | ||||||||||||||||||
7980 | } | - | ||||||||||||||||||
7981 | else | - | ||||||||||||||||||
7982 | { | - | ||||||||||||||||||
7983 | #if !defined (HISTORY) | - | ||||||||||||||||||
7984 | temp = savestring ("1"); | - | ||||||||||||||||||
7985 | #else /* HISTORY */ | - | ||||||||||||||||||
7986 | temp = itos (prompt_history_number (orig_string)); | - | ||||||||||||||||||
7987 | #endif /* HISTORY */ | - | ||||||||||||||||||
7988 | string--; /* add_string increments string again. */ | - | ||||||||||||||||||
7989 | goto add_string; | - | ||||||||||||||||||
7990 | } | - | ||||||||||||||||||
7991 | } | - | ||||||||||||||||||
7992 | if (c == '\\') | - | ||||||||||||||||||
7993 | { | - | ||||||||||||||||||
7994 | c = *string; | - | ||||||||||||||||||
7995 | - | |||||||||||||||||||
7996 | switch (c) | - | ||||||||||||||||||
7997 | { | - | ||||||||||||||||||
7998 | case '0': | - | ||||||||||||||||||
7999 | case '1': | - | ||||||||||||||||||
8000 | case '2': | - | ||||||||||||||||||
8001 | case '3': | - | ||||||||||||||||||
8002 | case '4': | - | ||||||||||||||||||
8003 | case '5': | - | ||||||||||||||||||
8004 | case '6': | - | ||||||||||||||||||
8005 | case '7': | - | ||||||||||||||||||
8006 | strncpy (octal_string, string, 3); | - | ||||||||||||||||||
8007 | octal_string[3] = '\0'; | - | ||||||||||||||||||
8008 | - | |||||||||||||||||||
8009 | n = read_octal (octal_string); | - | ||||||||||||||||||
8010 | temp = (char *)xmalloc (3); | - | ||||||||||||||||||
8011 | - | |||||||||||||||||||
8012 | if (n == CTLESC || n == CTLNUL) | - | ||||||||||||||||||
8013 | { | - | ||||||||||||||||||
8014 | temp[0] = CTLESC; | - | ||||||||||||||||||
8015 | temp[1] = n; | - | ||||||||||||||||||
8016 | temp[2] = '\0'; | - | ||||||||||||||||||
8017 | } | - | ||||||||||||||||||
8018 | else if (n == -1) | - | ||||||||||||||||||
8019 | { | - | ||||||||||||||||||
8020 | temp[0] = '\\'; | - | ||||||||||||||||||
8021 | temp[1] = '\0'; | - | ||||||||||||||||||
8022 | } | - | ||||||||||||||||||
8023 | else | - | ||||||||||||||||||
8024 | { | - | ||||||||||||||||||
8025 | temp[0] = n; | - | ||||||||||||||||||
8026 | temp[1] = '\0'; | - | ||||||||||||||||||
8027 | } | - | ||||||||||||||||||
8028 | - | |||||||||||||||||||
8029 | for (c = 0; n != -1 && c < 3 && ISOCTAL (*string); c++) | - | ||||||||||||||||||
8030 | string++; | - | ||||||||||||||||||
8031 | - | |||||||||||||||||||
8032 | c = 0; /* tested at add_string: */ | - | ||||||||||||||||||
8033 | goto add_string; | - | ||||||||||||||||||
8034 | - | |||||||||||||||||||
8035 | case 'd': | - | ||||||||||||||||||
8036 | case 't': | - | ||||||||||||||||||
8037 | case 'T': | - | ||||||||||||||||||
8038 | case '@': | - | ||||||||||||||||||
8039 | case 'A': | - | ||||||||||||||||||
8040 | /* Make the current time/date into a string. */ | - | ||||||||||||||||||
8041 | (void) time (&the_time); | - | ||||||||||||||||||
8042 | #if defined (HAVE_TZSET) | - | ||||||||||||||||||
8043 | sv_tz ("TZ"); /* XXX -- just make sure */ | - | ||||||||||||||||||
8044 | #endif | - | ||||||||||||||||||
8045 | tm = localtime (&the_time); | - | ||||||||||||||||||
8046 | - | |||||||||||||||||||
8047 | if (c == 'd') | - | ||||||||||||||||||
8048 | n = strftime (timebuf, sizeof (timebuf), "%a %b %d", tm); | - | ||||||||||||||||||
8049 | else if (c == 't') | - | ||||||||||||||||||
8050 | n = strftime (timebuf, sizeof (timebuf), "%H:%M:%S", tm); | - | ||||||||||||||||||
8051 | else if (c == 'T') | - | ||||||||||||||||||
8052 | n = strftime (timebuf, sizeof (timebuf), "%I:%M:%S", tm); | - | ||||||||||||||||||
8053 | else if (c == '@') | - | ||||||||||||||||||
8054 | n = strftime (timebuf, sizeof (timebuf), "%I:%M %p", tm); | - | ||||||||||||||||||
8055 | else if (c == 'A') | - | ||||||||||||||||||
8056 | n = strftime (timebuf, sizeof (timebuf), "%H:%M", tm); | - | ||||||||||||||||||
8057 | - | |||||||||||||||||||
8058 | if (n == 0) | - | ||||||||||||||||||
8059 | timebuf[0] = '\0'; | - | ||||||||||||||||||
8060 | else | - | ||||||||||||||||||
8061 | timebuf[sizeof(timebuf) - 1] = '\0'; | - | ||||||||||||||||||
8062 | - | |||||||||||||||||||
8063 | temp = savestring (timebuf); | - | ||||||||||||||||||
8064 | goto add_string; | - | ||||||||||||||||||
8065 | - | |||||||||||||||||||
8066 | case 'D': /* strftime format */ | - | ||||||||||||||||||
8067 | if (string[1] != '{') /* } */ | - | ||||||||||||||||||
8068 | goto not_escape; | - | ||||||||||||||||||
8069 | - | |||||||||||||||||||
8070 | (void) time (&the_time); | - | ||||||||||||||||||
8071 | tm = localtime (&the_time); | - | ||||||||||||||||||
8072 | string += 2; /* skip { */ | - | ||||||||||||||||||
8073 | timefmt = xmalloc (strlen (string) + 3); | - | ||||||||||||||||||
8074 | for (t = timefmt; *string && *string != '}'; ) | - | ||||||||||||||||||
8075 | *t++ = *string++; | - | ||||||||||||||||||
8076 | *t = '\0'; | - | ||||||||||||||||||
8077 | c = *string; /* tested at add_string */ | - | ||||||||||||||||||
8078 | if (timefmt[0] == '\0') | - | ||||||||||||||||||
8079 | { | - | ||||||||||||||||||
8080 | timefmt[0] = '%'; | - | ||||||||||||||||||
8081 | timefmt[1] = 'X'; /* locale-specific current time */ | - | ||||||||||||||||||
8082 | timefmt[2] = '\0'; | - | ||||||||||||||||||
8083 | } | - | ||||||||||||||||||
8084 | n = strftime (timebuf, sizeof (timebuf), timefmt, tm); | - | ||||||||||||||||||
8085 | free (timefmt); | - | ||||||||||||||||||
8086 | - | |||||||||||||||||||
8087 | if (n == 0) | - | ||||||||||||||||||
8088 | timebuf[0] = '\0'; | - | ||||||||||||||||||
8089 | else | - | ||||||||||||||||||
8090 | timebuf[sizeof(timebuf) - 1] = '\0'; | - | ||||||||||||||||||
8091 | - | |||||||||||||||||||
8092 | if (promptvars || posixly_correct) | - | ||||||||||||||||||
8093 | /* Make sure that expand_prompt_string is called with a | - | ||||||||||||||||||
8094 | second argument of Q_DOUBLE_QUOTES if we use this | - | ||||||||||||||||||
8095 | function here. */ | - | ||||||||||||||||||
8096 | temp = sh_backslash_quote_for_double_quotes (timebuf); | - | ||||||||||||||||||
8097 | else | - | ||||||||||||||||||
8098 | temp = savestring (timebuf); | - | ||||||||||||||||||
8099 | goto add_string; | - | ||||||||||||||||||
8100 | - | |||||||||||||||||||
8101 | case 'n': | - | ||||||||||||||||||
8102 | temp = (char *)xmalloc (3); | - | ||||||||||||||||||
8103 | temp[0] = no_line_editing ? '\n' : '\r'; | - | ||||||||||||||||||
8104 | temp[1] = no_line_editing ? '\0' : '\n'; | - | ||||||||||||||||||
8105 | temp[2] = '\0'; | - | ||||||||||||||||||
8106 | goto add_string; | - | ||||||||||||||||||
8107 | - | |||||||||||||||||||
8108 | case 's': | - | ||||||||||||||||||
8109 | temp = base_pathname (shell_name); | - | ||||||||||||||||||
8110 | /* Try to quote anything the user can set in the file system */ | - | ||||||||||||||||||
8111 | if (promptvars || posixly_correct) | - | ||||||||||||||||||
8112 | temp = sh_backslash_quote_for_double_quotes (temp); | - | ||||||||||||||||||
8113 | else | - | ||||||||||||||||||
8114 | temp = savestring (temp); | - | ||||||||||||||||||
8115 | goto add_string; | - | ||||||||||||||||||
8116 | - | |||||||||||||||||||
8117 | case 'v': | - | ||||||||||||||||||
8118 | case 'V': | - | ||||||||||||||||||
8119 | temp = (char *)xmalloc (16); | - | ||||||||||||||||||
8120 | if (c == 'v') | - | ||||||||||||||||||
8121 | strcpy (temp, dist_version); | - | ||||||||||||||||||
8122 | else | - | ||||||||||||||||||
8123 | sprintf (temp, "%s.%d", dist_version, patch_level); | - | ||||||||||||||||||
8124 | goto add_string; | - | ||||||||||||||||||
8125 | - | |||||||||||||||||||
8126 | case 'w': | - | ||||||||||||||||||
8127 | case 'W': | - | ||||||||||||||||||
8128 | { | - | ||||||||||||||||||
8129 | /* Use the value of PWD because it is much more efficient. */ | - | ||||||||||||||||||
8130 | char t_string[PATH_MAX]; | - | ||||||||||||||||||
8131 | int tlen; | - | ||||||||||||||||||
8132 | - | |||||||||||||||||||
8133 | temp = get_string_value ("PWD"); | - | ||||||||||||||||||
8134 | - | |||||||||||||||||||
8135 | if (temp == 0) | - | ||||||||||||||||||
8136 | { | - | ||||||||||||||||||
8137 | if (getcwd (t_string, sizeof(t_string)) == 0) | - | ||||||||||||||||||
8138 | { | - | ||||||||||||||||||
8139 | t_string[0] = '.'; | - | ||||||||||||||||||
8140 | tlen = 1; | - | ||||||||||||||||||
8141 | } | - | ||||||||||||||||||
8142 | else | - | ||||||||||||||||||
8143 | tlen = strlen (t_string); | - | ||||||||||||||||||
8144 | } | - | ||||||||||||||||||
8145 | else | - | ||||||||||||||||||
8146 | { | - | ||||||||||||||||||
8147 | tlen = sizeof (t_string) - 1; | - | ||||||||||||||||||
8148 | strncpy (t_string, temp, tlen); | - | ||||||||||||||||||
8149 | } | - | ||||||||||||||||||
8150 | t_string[tlen] = '\0'; | - | ||||||||||||||||||
8151 | - | |||||||||||||||||||
8152 | #if defined (MACOSX) | - | ||||||||||||||||||
8153 | /* Convert from "fs" format to "input" format */ | - | ||||||||||||||||||
8154 | temp = fnx_fromfs (t_string, strlen (t_string)); | - | ||||||||||||||||||
8155 | if (temp != t_string) | - | ||||||||||||||||||
8156 | strcpy (t_string, temp); | - | ||||||||||||||||||
8157 | #endif | - | ||||||||||||||||||
8158 | - | |||||||||||||||||||
8159 | #define ROOT_PATH(x) ((x)[0] == '/' && (x)[1] == 0) | - | ||||||||||||||||||
8160 | #define DOUBLE_SLASH_ROOT(x) ((x)[0] == '/' && (x)[1] == '/' && (x)[2] == 0) | - | ||||||||||||||||||
8161 | /* Abbreviate \W as ~ if $PWD == $HOME */ | - | ||||||||||||||||||
8162 | if (c == 'W' && (((t = get_string_value ("HOME")) == 0) || STREQ (t, t_string) == 0)) | - | ||||||||||||||||||
8163 | { | - | ||||||||||||||||||
8164 | if (ROOT_PATH (t_string) == 0 && DOUBLE_SLASH_ROOT (t_string) == 0) | - | ||||||||||||||||||
8165 | { | - | ||||||||||||||||||
8166 | t = strrchr (t_string, '/'); | - | ||||||||||||||||||
8167 | if (t) | - | ||||||||||||||||||
8168 | memmove (t_string, t + 1, strlen (t)); /* strlen(t) to copy NULL */ | - | ||||||||||||||||||
8169 | } | - | ||||||||||||||||||
8170 | } | - | ||||||||||||||||||
8171 | #undef ROOT_PATH | - | ||||||||||||||||||
8172 | #undef DOUBLE_SLASH_ROOT | - | ||||||||||||||||||
8173 | else | - | ||||||||||||||||||
8174 | { | - | ||||||||||||||||||
8175 | /* polite_directory_format is guaranteed to return a string | - | ||||||||||||||||||
8176 | no longer than PATH_MAX - 1 characters. */ | - | ||||||||||||||||||
8177 | temp = polite_directory_format (t_string); | - | ||||||||||||||||||
8178 | if (temp != t_string) | - | ||||||||||||||||||
8179 | strcpy (t_string, temp); | - | ||||||||||||||||||
8180 | } | - | ||||||||||||||||||
8181 | - | |||||||||||||||||||
8182 | temp = trim_pathname (t_string, PATH_MAX - 1); | - | ||||||||||||||||||
8183 | /* If we're going to be expanding the prompt string later, | - | ||||||||||||||||||
8184 | quote the directory name. */ | - | ||||||||||||||||||
8185 | if (promptvars || posixly_correct) | - | ||||||||||||||||||
8186 | /* Make sure that expand_prompt_string is called with a | - | ||||||||||||||||||
8187 | second argument of Q_DOUBLE_QUOTES if we use this | - | ||||||||||||||||||
8188 | function here. */ | - | ||||||||||||||||||
8189 | temp = sh_backslash_quote_for_double_quotes (t_string); | - | ||||||||||||||||||
8190 | else | - | ||||||||||||||||||
8191 | temp = savestring (t_string); | - | ||||||||||||||||||
8192 | - | |||||||||||||||||||
8193 | goto add_string; | - | ||||||||||||||||||
8194 | } | - | ||||||||||||||||||
8195 | - | |||||||||||||||||||
8196 | case 'u': | - | ||||||||||||||||||
8197 | if (current_user.user_name == 0) | - | ||||||||||||||||||
8198 | get_current_user_info (); | - | ||||||||||||||||||
8199 | temp = savestring (current_user.user_name); | - | ||||||||||||||||||
8200 | goto add_string; | - | ||||||||||||||||||
8201 | - | |||||||||||||||||||
8202 | case 'h': | - | ||||||||||||||||||
8203 | case 'H': | - | ||||||||||||||||||
8204 | t_host = savestring (current_host_name); | - | ||||||||||||||||||
8205 | if (c == 'h' && (t = (char *)strchr (t_host, '.'))) | - | ||||||||||||||||||
8206 | *t = '\0'; | - | ||||||||||||||||||
8207 | if (promptvars || posixly_correct) | - | ||||||||||||||||||
8208 | /* Make sure that expand_prompt_string is called with a | - | ||||||||||||||||||
8209 | second argument of Q_DOUBLE_QUOTES if we use this | - | ||||||||||||||||||
8210 | function here. */ | - | ||||||||||||||||||
8211 | temp = sh_backslash_quote_for_double_quotes (t_host); | - | ||||||||||||||||||
8212 | else | - | ||||||||||||||||||
8213 | temp = savestring (t_host); | - | ||||||||||||||||||
8214 | free (t_host); | - | ||||||||||||||||||
8215 | goto add_string; | - | ||||||||||||||||||
8216 | - | |||||||||||||||||||
8217 | case '#': | - | ||||||||||||||||||
8218 | n = current_command_number; | - | ||||||||||||||||||
8219 | /* If we have already incremented current_command_number (PS4, | - | ||||||||||||||||||
8220 | ${var@P}), compensate */ | - | ||||||||||||||||||
8221 | if (orig_string != ps0_prompt && orig_string != ps1_prompt && orig_string != ps2_prompt) | - | ||||||||||||||||||
8222 | n--; | - | ||||||||||||||||||
8223 | temp = itos (n); | - | ||||||||||||||||||
8224 | goto add_string; | - | ||||||||||||||||||
8225 | - | |||||||||||||||||||
8226 | case '!': | - | ||||||||||||||||||
8227 | #if !defined (HISTORY) | - | ||||||||||||||||||
8228 | temp = savestring ("1"); | - | ||||||||||||||||||
8229 | #else /* HISTORY */ | - | ||||||||||||||||||
8230 | temp = itos (prompt_history_number (orig_string)); | - | ||||||||||||||||||
8231 | #endif /* HISTORY */ | - | ||||||||||||||||||
8232 | goto add_string; | - | ||||||||||||||||||
8233 | - | |||||||||||||||||||
8234 | case '$': | - | ||||||||||||||||||
8235 | t = temp = (char *)xmalloc (3); | - | ||||||||||||||||||
8236 | if ((promptvars || posixly_correct) && (current_user.euid != 0)) | - | ||||||||||||||||||
8237 | *t++ = '\\'; | - | ||||||||||||||||||
8238 | *t++ = current_user.euid == 0 ? '#' : '$'; | - | ||||||||||||||||||
8239 | *t = '\0'; | - | ||||||||||||||||||
8240 | goto add_string; | - | ||||||||||||||||||
8241 | - | |||||||||||||||||||
8242 | case 'j': | - | ||||||||||||||||||
8243 | temp = itos (count_all_jobs ()); | - | ||||||||||||||||||
8244 | goto add_string; | - | ||||||||||||||||||
8245 | - | |||||||||||||||||||
8246 | case 'l': | - | ||||||||||||||||||
8247 | #if defined (HAVE_TTYNAME) | - | ||||||||||||||||||
8248 | temp = (char *)ttyname (fileno (stdin)); | - | ||||||||||||||||||
8249 | t = temp ? base_pathname (temp) : "tty"; | - | ||||||||||||||||||
8250 | temp = savestring (t); | - | ||||||||||||||||||
8251 | #else | - | ||||||||||||||||||
8252 | temp = savestring ("tty"); | - | ||||||||||||||||||
8253 | #endif /* !HAVE_TTYNAME */ | - | ||||||||||||||||||
8254 | goto add_string; | - | ||||||||||||||||||
8255 | - | |||||||||||||||||||
8256 | #if defined (READLINE) | - | ||||||||||||||||||
8257 | case '[': | - | ||||||||||||||||||
8258 | case ']': | - | ||||||||||||||||||
8259 | if (no_line_editing) | - | ||||||||||||||||||
8260 | { | - | ||||||||||||||||||
8261 | string++; | - | ||||||||||||||||||
8262 | break; | - | ||||||||||||||||||
8263 | } | - | ||||||||||||||||||
8264 | temp = (char *)xmalloc (3); | - | ||||||||||||||||||
8265 | n = (c == '[') ? RL_PROMPT_START_IGNORE : RL_PROMPT_END_IGNORE; | - | ||||||||||||||||||
8266 | i = 0; | - | ||||||||||||||||||
8267 | if (n == CTLESC || n == CTLNUL) | - | ||||||||||||||||||
8268 | temp[i++] = CTLESC; | - | ||||||||||||||||||
8269 | temp[i++] = n; | - | ||||||||||||||||||
8270 | temp[i] = '\0'; | - | ||||||||||||||||||
8271 | goto add_string; | - | ||||||||||||||||||
8272 | #endif /* READLINE */ | - | ||||||||||||||||||
8273 | - | |||||||||||||||||||
8274 | case '\\': | - | ||||||||||||||||||
8275 | case 'a': | - | ||||||||||||||||||
8276 | case 'e': | - | ||||||||||||||||||
8277 | case 'r': | - | ||||||||||||||||||
8278 | temp = (char *)xmalloc (2); | - | ||||||||||||||||||
8279 | if (c == 'a') | - | ||||||||||||||||||
8280 | temp[0] = '\07'; | - | ||||||||||||||||||
8281 | else if (c == 'e') | - | ||||||||||||||||||
8282 | temp[0] = '\033'; | - | ||||||||||||||||||
8283 | else if (c == 'r') | - | ||||||||||||||||||
8284 | temp[0] = '\r'; | - | ||||||||||||||||||
8285 | else /* (c == '\\') */ | - | ||||||||||||||||||
8286 | temp[0] = c; | - | ||||||||||||||||||
8287 | temp[1] = '\0'; | - | ||||||||||||||||||
8288 | goto add_string; | - | ||||||||||||||||||
8289 | - | |||||||||||||||||||
8290 | default: | - | ||||||||||||||||||
8291 | not_escape: | - | ||||||||||||||||||
8292 | temp = (char *)xmalloc (3); | - | ||||||||||||||||||
8293 | temp[0] = '\\'; | - | ||||||||||||||||||
8294 | temp[1] = c; | - | ||||||||||||||||||
8295 | temp[2] = '\0'; | - | ||||||||||||||||||
8296 | - | |||||||||||||||||||
8297 | add_string: | - | ||||||||||||||||||
8298 | if (c) | - | ||||||||||||||||||
8299 | string++; | - | ||||||||||||||||||
8300 | result = | - | ||||||||||||||||||
8301 | sub_append_string (temp, result, &result_index, &result_size); | - | ||||||||||||||||||
8302 | temp = (char *)NULL; /* Freed in sub_append_string (). */ | - | ||||||||||||||||||
8303 | result[result_index] = '\0'; | - | ||||||||||||||||||
8304 | break; | - | ||||||||||||||||||
8305 | } | - | ||||||||||||||||||
8306 | } | - | ||||||||||||||||||
8307 | else | - | ||||||||||||||||||
8308 | { | - | ||||||||||||||||||
8309 | RESIZE_MALLOCED_BUFFER (result, result_index, 3, result_size, PROMPT_GROWTH); | - | ||||||||||||||||||
8310 | /* dequote_string should take care of removing this if we are not | - | ||||||||||||||||||
8311 | performing the rest of the word expansions. */ | - | ||||||||||||||||||
8312 | if (c == CTLESC || c == CTLNUL) | - | ||||||||||||||||||
8313 | result[result_index++] = CTLESC; | - | ||||||||||||||||||
8314 | result[result_index++] = c; | - | ||||||||||||||||||
8315 | result[result_index] = '\0'; | - | ||||||||||||||||||
8316 | } | - | ||||||||||||||||||
8317 | } | - | ||||||||||||||||||
8318 | #else /* !PROMPT_STRING_DECODE */ | - | ||||||||||||||||||
8319 | result = savestring (string); | - | ||||||||||||||||||
8320 | #endif /* !PROMPT_STRING_DECODE */ | - | ||||||||||||||||||
8321 | - | |||||||||||||||||||
8322 | /* Save the delimiter stack and point `dstack' to temp space so any | - | ||||||||||||||||||
8323 | command substitutions in the prompt string won't result in screwing | - | ||||||||||||||||||
8324 | up the parser's quoting state. */ | - | ||||||||||||||||||
8325 | save_dstack = dstack; | - | ||||||||||||||||||
8326 | dstack = temp_dstack; | - | ||||||||||||||||||
8327 | dstack.delimiter_depth = 0; | - | ||||||||||||||||||
8328 | - | |||||||||||||||||||
8329 | /* Perform variable and parameter expansion and command substitution on | - | ||||||||||||||||||
8330 | the prompt string. */ | - | ||||||||||||||||||
8331 | if (promptvars || posixly_correct) | - | ||||||||||||||||||
8332 | { | - | ||||||||||||||||||
8333 | last_exit_value = last_command_exit_value; | - | ||||||||||||||||||
8334 | last_comsub_pid = last_command_subst_pid; | - | ||||||||||||||||||
8335 | list = expand_prompt_string (result, Q_DOUBLE_QUOTES, 0); | - | ||||||||||||||||||
8336 | free (result); | - | ||||||||||||||||||
8337 | result = string_list (list); | - | ||||||||||||||||||
8338 | dispose_words (list); | - | ||||||||||||||||||
8339 | last_command_exit_value = last_exit_value; | - | ||||||||||||||||||
8340 | last_command_subst_pid = last_comsub_pid; | - | ||||||||||||||||||
8341 | } | - | ||||||||||||||||||
8342 | else | - | ||||||||||||||||||
8343 | { | - | ||||||||||||||||||
8344 | t = dequote_string (result); | - | ||||||||||||||||||
8345 | free (result); | - | ||||||||||||||||||
8346 | result = t; | - | ||||||||||||||||||
8347 | } | - | ||||||||||||||||||
8348 | - | |||||||||||||||||||
8349 | dstack = save_dstack; | - | ||||||||||||||||||
8350 | - | |||||||||||||||||||
8351 | return (result); | - | ||||||||||||||||||
8352 | } | - | ||||||||||||||||||
8353 | - | |||||||||||||||||||
8354 | /************************************************ | - | ||||||||||||||||||
8355 | * * | - | ||||||||||||||||||
8356 | * ERROR HANDLING * | - | ||||||||||||||||||
8357 | * * | - | ||||||||||||||||||
8358 | ************************************************/ | - | ||||||||||||||||||
8359 | - | |||||||||||||||||||
8360 | /* Report a syntax error, and restart the parser. Call here for fatal | - | ||||||||||||||||||
8361 | errors. */ | - | ||||||||||||||||||
8362 | int | - | ||||||||||||||||||
8363 | yyerror (msg) | - | ||||||||||||||||||
8364 | const char *msg; | - | ||||||||||||||||||
8365 | { | - | ||||||||||||||||||
8366 | report_syntax_error ((char *)NULL); | - | ||||||||||||||||||
8367 | reset_parser (); | - | ||||||||||||||||||
8368 | return (0); | - | ||||||||||||||||||
8369 | } | - | ||||||||||||||||||
8370 | - | |||||||||||||||||||
8371 | static char * | - | ||||||||||||||||||
8372 | error_token_from_token (tok) | - | ||||||||||||||||||
8373 | int tok; | - | ||||||||||||||||||
8374 | { | - | ||||||||||||||||||
8375 | char *t; | - | ||||||||||||||||||
8376 | - | |||||||||||||||||||
8377 | if (t = find_token_in_alist (tok, word_token_alist, 0)) | - | ||||||||||||||||||
8378 | return t; | - | ||||||||||||||||||
8379 | - | |||||||||||||||||||
8380 | if (t = find_token_in_alist (tok, other_token_alist, 0)) | - | ||||||||||||||||||
8381 | return t; | - | ||||||||||||||||||
8382 | - | |||||||||||||||||||
8383 | t = (char *)NULL; | - | ||||||||||||||||||
8384 | /* This stuff is dicy and needs closer inspection */ | - | ||||||||||||||||||
8385 | switch (current_token) | - | ||||||||||||||||||
8386 | { | - | ||||||||||||||||||
8387 | case WORD: | - | ||||||||||||||||||
8388 | case ASSIGNMENT_WORD: | - | ||||||||||||||||||
8389 | if (yylval.word) | - | ||||||||||||||||||
8390 | t = savestring (yylval.word->word); | - | ||||||||||||||||||
8391 | break; | - | ||||||||||||||||||
8392 | case NUMBER: | - | ||||||||||||||||||
8393 | t = itos (yylval.number); | - | ||||||||||||||||||
8394 | break; | - | ||||||||||||||||||
8395 | case ARITH_CMD: | - | ||||||||||||||||||
8396 | if (yylval.word_list) | - | ||||||||||||||||||
8397 | t = string_list (yylval.word_list); | - | ||||||||||||||||||
8398 | break; | - | ||||||||||||||||||
8399 | case ARITH_FOR_EXPRS: | - | ||||||||||||||||||
8400 | if (yylval.word_list) | - | ||||||||||||||||||
8401 | t = string_list_internal (yylval.word_list, " ; "); | - | ||||||||||||||||||
8402 | break; | - | ||||||||||||||||||
8403 | case COND_CMD: | - | ||||||||||||||||||
8404 | t = (char *)NULL; /* punt */ | - | ||||||||||||||||||
8405 | break; | - | ||||||||||||||||||
8406 | } | - | ||||||||||||||||||
8407 | - | |||||||||||||||||||
8408 | return t; | - | ||||||||||||||||||
8409 | } | - | ||||||||||||||||||
8410 | - | |||||||||||||||||||
8411 | static char * | - | ||||||||||||||||||
8412 | error_token_from_text () | - | ||||||||||||||||||
8413 | { | - | ||||||||||||||||||
8414 | char *msg, *t; | - | ||||||||||||||||||
8415 | int token_end, i; | - | ||||||||||||||||||
8416 | - | |||||||||||||||||||
8417 | t = shell_input_line; | - | ||||||||||||||||||
8418 | i = shell_input_line_index; | - | ||||||||||||||||||
8419 | token_end = 0; | - | ||||||||||||||||||
8420 | msg = (char *)NULL; | - | ||||||||||||||||||
8421 | - | |||||||||||||||||||
8422 | if (i && t[i] == '\0') | - | ||||||||||||||||||
8423 | i--; | - | ||||||||||||||||||
8424 | - | |||||||||||||||||||
8425 | while (i && (whitespace (t[i]) || t[i] == '\n')) | - | ||||||||||||||||||
8426 | i--; | - | ||||||||||||||||||
8427 | - | |||||||||||||||||||
8428 | if (i) | - | ||||||||||||||||||
8429 | token_end = i + 1; | - | ||||||||||||||||||
8430 | - | |||||||||||||||||||
8431 | while (i && (member (t[i], " \n\t;|&") == 0)) | - | ||||||||||||||||||
8432 | i--; | - | ||||||||||||||||||
8433 | - | |||||||||||||||||||
8434 | while (i != token_end && (whitespace (t[i]) || t[i] == '\n')) | - | ||||||||||||||||||
8435 | i++; | - | ||||||||||||||||||
8436 | - | |||||||||||||||||||
8437 | /* Return our idea of the offending token. */ | - | ||||||||||||||||||
8438 | if (token_end || (i == 0 && token_end == 0)) | - | ||||||||||||||||||
8439 | { | - | ||||||||||||||||||
8440 | if (token_end) | - | ||||||||||||||||||
8441 | msg = substring (t, i, token_end); | - | ||||||||||||||||||
8442 | else /* one-character token */ | - | ||||||||||||||||||
8443 | { | - | ||||||||||||||||||
8444 | msg = (char *)xmalloc (2); | - | ||||||||||||||||||
8445 | msg[0] = t[i]; | - | ||||||||||||||||||
8446 | msg[1] = '\0'; | - | ||||||||||||||||||
8447 | } | - | ||||||||||||||||||
8448 | } | - | ||||||||||||||||||
8449 | - | |||||||||||||||||||
8450 | return (msg); | - | ||||||||||||||||||
8451 | } | - | ||||||||||||||||||
8452 | - | |||||||||||||||||||
8453 | static void | - | ||||||||||||||||||
8454 | print_offending_line () | - | ||||||||||||||||||
8455 | { | - | ||||||||||||||||||
8456 | char *msg; | - | ||||||||||||||||||
8457 | int token_end; | - | ||||||||||||||||||
8458 | - | |||||||||||||||||||
8459 | msg = savestring (shell_input_line); | - | ||||||||||||||||||
8460 | token_end = strlen (msg); | - | ||||||||||||||||||
8461 | while (token_end && msg[token_end - 1] == '\n') | - | ||||||||||||||||||
8462 | msg[--token_end] = '\0'; | - | ||||||||||||||||||
8463 | - | |||||||||||||||||||
8464 | parser_error (line_number, "`%s'", msg); | - | ||||||||||||||||||
8465 | free (msg); | - | ||||||||||||||||||
8466 | } | - | ||||||||||||||||||
8467 | - | |||||||||||||||||||
8468 | /* Report a syntax error with line numbers, etc. | - | ||||||||||||||||||
8469 | Call here for recoverable errors. If you have a message to print, | - | ||||||||||||||||||
8470 | then place it in MESSAGE, otherwise pass NULL and this will figure | - | ||||||||||||||||||
8471 | out an appropriate message for you. */ | - | ||||||||||||||||||
8472 | static void | - | ||||||||||||||||||
8473 | report_syntax_error (message) | - | ||||||||||||||||||
8474 | char *message; | - | ||||||||||||||||||
8475 | { | - | ||||||||||||||||||
8476 | char *msg, *p; | - | ||||||||||||||||||
8477 | - | |||||||||||||||||||
8478 | if (message) | - | ||||||||||||||||||
8479 | { | - | ||||||||||||||||||
8480 | parser_error (line_number, "%s", message); | - | ||||||||||||||||||
8481 | if (interactive && EOF_Reached) | - | ||||||||||||||||||
8482 | EOF_Reached = 0; | - | ||||||||||||||||||
8483 | last_command_exit_value = parse_and_execute_level ? EX_BADSYNTAX : EX_BADUSAGE; | - | ||||||||||||||||||
8484 | return; | - | ||||||||||||||||||
8485 | } | - | ||||||||||||||||||
8486 | - | |||||||||||||||||||
8487 | /* If the line of input we're reading is not null, try to find the | - | ||||||||||||||||||
8488 | objectionable token. First, try to figure out what token the | - | ||||||||||||||||||
8489 | parser's complaining about by looking at current_token. */ | - | ||||||||||||||||||
8490 | if (current_token != 0 && EOF_Reached == 0 && (msg = error_token_from_token (current_token))) | - | ||||||||||||||||||
8491 | { | - | ||||||||||||||||||
8492 | if (ansic_shouldquote (msg)) | - | ||||||||||||||||||
8493 | { | - | ||||||||||||||||||
8494 | p = ansic_quote (msg, 0, NULL); | - | ||||||||||||||||||
8495 | free (msg); | - | ||||||||||||||||||
8496 | msg = p; | - | ||||||||||||||||||
8497 | } | - | ||||||||||||||||||
8498 | parser_error (line_number, _("syntax error near unexpected token `%s'"), msg); | - | ||||||||||||||||||
8499 | free (msg); | - | ||||||||||||||||||
8500 | - | |||||||||||||||||||
8501 | if (interactive == 0) | - | ||||||||||||||||||
8502 | print_offending_line (); | - | ||||||||||||||||||
8503 | - | |||||||||||||||||||
8504 | last_command_exit_value = parse_and_execute_level ? EX_BADSYNTAX : EX_BADUSAGE; | - | ||||||||||||||||||
8505 | return; | - | ||||||||||||||||||
8506 | } | - | ||||||||||||||||||
8507 | - | |||||||||||||||||||
8508 | /* If looking at the current token doesn't prove fruitful, try to find the | - | ||||||||||||||||||
8509 | offending token by analyzing the text of the input line near the current | - | ||||||||||||||||||
8510 | input line index and report what we find. */ | - | ||||||||||||||||||
8511 | if (shell_input_line && *shell_input_line) | - | ||||||||||||||||||
8512 | { | - | ||||||||||||||||||
8513 | msg = error_token_from_text (); | - | ||||||||||||||||||
8514 | if (msg) | - | ||||||||||||||||||
8515 | { | - | ||||||||||||||||||
8516 | parser_error (line_number, _("syntax error near `%s'"), msg); | - | ||||||||||||||||||
8517 | free (msg); | - | ||||||||||||||||||
8518 | } | - | ||||||||||||||||||
8519 | - | |||||||||||||||||||
8520 | /* If not interactive, print the line containing the error. */ | - | ||||||||||||||||||
8521 | if (interactive == 0) | - | ||||||||||||||||||
8522 | print_offending_line (); | - | ||||||||||||||||||
8523 | } | - | ||||||||||||||||||
8524 | else | - | ||||||||||||||||||
8525 | { | - | ||||||||||||||||||
8526 | msg = EOF_Reached ? _("syntax error: unexpected end of file") : _("syntax error"); | - | ||||||||||||||||||
8527 | parser_error (line_number, "%s", msg); | - | ||||||||||||||||||
8528 | /* When the shell is interactive, this file uses EOF_Reached | - | ||||||||||||||||||
8529 | only for error reporting. Other mechanisms are used to | - | ||||||||||||||||||
8530 | decide whether or not to exit. */ | - | ||||||||||||||||||
8531 | if (interactive && EOF_Reached) | - | ||||||||||||||||||
8532 | EOF_Reached = 0; | - | ||||||||||||||||||
8533 | } | - | ||||||||||||||||||
8534 | - | |||||||||||||||||||
8535 | last_command_exit_value = parse_and_execute_level ? EX_BADSYNTAX : EX_BADUSAGE; | - | ||||||||||||||||||
8536 | } | - | ||||||||||||||||||
8537 | - | |||||||||||||||||||
8538 | /* ??? Needed function. ??? We have to be able to discard the constructs | - | ||||||||||||||||||
8539 | created during parsing. In the case of error, we want to return | - | ||||||||||||||||||
8540 | allocated objects to the memory pool. In the case of no error, we want | - | ||||||||||||||||||
8541 | to throw away the information about where the allocated objects live. | - | ||||||||||||||||||
8542 | (dispose_command () will actually free the command.) */ | - | ||||||||||||||||||
8543 | static void | - | ||||||||||||||||||
8544 | discard_parser_constructs (error_p) | - | ||||||||||||||||||
8545 | int error_p; | - | ||||||||||||||||||
8546 | { | - | ||||||||||||||||||
8547 | } | - | ||||||||||||||||||
8548 | - | |||||||||||||||||||
8549 | /************************************************ | - | ||||||||||||||||||
8550 | * * | - | ||||||||||||||||||
8551 | * EOF HANDLING * | - | ||||||||||||||||||
8552 | * * | - | ||||||||||||||||||
8553 | ************************************************/ | - | ||||||||||||||||||
8554 | - | |||||||||||||||||||
8555 | /* Do that silly `type "bye" to exit' stuff. You know, "ignoreeof". */ | - | ||||||||||||||||||
8556 | - | |||||||||||||||||||
8557 | /* A flag denoting whether or not ignoreeof is set. */ | - | ||||||||||||||||||
8558 | int ignoreeof = 0; | - | ||||||||||||||||||
8559 | - | |||||||||||||||||||
8560 | /* The number of times that we have encountered an EOF character without | - | ||||||||||||||||||
8561 | another character intervening. When this gets above the limit, the | - | ||||||||||||||||||
8562 | shell terminates. */ | - | ||||||||||||||||||
8563 | int eof_encountered = 0; | - | ||||||||||||||||||
8564 | - | |||||||||||||||||||
8565 | /* The limit for eof_encountered. */ | - | ||||||||||||||||||
8566 | int eof_encountered_limit = 10; | - | ||||||||||||||||||
8567 | - | |||||||||||||||||||
8568 | /* If we have EOF as the only input unit, this user wants to leave | - | ||||||||||||||||||
8569 | the shell. If the shell is not interactive, then just leave. | - | ||||||||||||||||||
8570 | Otherwise, if ignoreeof is set, and we haven't done this the | - | ||||||||||||||||||
8571 | required number of times in a row, print a message. */ | - | ||||||||||||||||||
8572 | static void | - | ||||||||||||||||||
8573 | handle_eof_input_unit () | - | ||||||||||||||||||
8574 | { | - | ||||||||||||||||||
8575 | if (interactive) | - | ||||||||||||||||||
8576 | { | - | ||||||||||||||||||
8577 | /* shell.c may use this to decide whether or not to write out the | - | ||||||||||||||||||
8578 | history, among other things. We use it only for error reporting | - | ||||||||||||||||||
8579 | in this file. */ | - | ||||||||||||||||||
8580 | if (EOF_Reached) | - | ||||||||||||||||||
8581 | EOF_Reached = 0; | - | ||||||||||||||||||
8582 | - | |||||||||||||||||||
8583 | /* If the user wants to "ignore" eof, then let her do so, kind of. */ | - | ||||||||||||||||||
8584 | if (ignoreeof) | - | ||||||||||||||||||
8585 | { | - | ||||||||||||||||||
8586 | if (eof_encountered < eof_encountered_limit) | - | ||||||||||||||||||
8587 | { | - | ||||||||||||||||||
8588 | fprintf (stderr, _("Use \"%s\" to leave the shell.\n"), | - | ||||||||||||||||||
8589 | login_shell ? "logout" : "exit"); | - | ||||||||||||||||||
8590 | eof_encountered++; | - | ||||||||||||||||||
8591 | /* Reset the parsing state. */ | - | ||||||||||||||||||
8592 | last_read_token = current_token = '\n'; | - | ||||||||||||||||||
8593 | /* Reset the prompt string to be $PS1. */ | - | ||||||||||||||||||
8594 | prompt_string_pointer = (char **)NULL; | - | ||||||||||||||||||
8595 | prompt_again (); | - | ||||||||||||||||||
8596 | return; | - | ||||||||||||||||||
8597 | } | - | ||||||||||||||||||
8598 | } | - | ||||||||||||||||||
8599 | - | |||||||||||||||||||
8600 | /* In this case EOF should exit the shell. Do it now. */ | - | ||||||||||||||||||
8601 | reset_parser (); | - | ||||||||||||||||||
8602 | exit_builtin ((WORD_LIST *)NULL); | - | ||||||||||||||||||
8603 | } | - | ||||||||||||||||||
8604 | else | - | ||||||||||||||||||
8605 | { | - | ||||||||||||||||||
8606 | /* We don't write history files, etc., for non-interactive shells. */ | - | ||||||||||||||||||
8607 | EOF_Reached = 1; | - | ||||||||||||||||||
8608 | } | - | ||||||||||||||||||
8609 | } | - | ||||||||||||||||||
8610 | - | |||||||||||||||||||
8611 | /************************************************ | - | ||||||||||||||||||
8612 | * * | - | ||||||||||||||||||
8613 | * STRING PARSING FUNCTIONS * | - | ||||||||||||||||||
8614 | * * | - | ||||||||||||||||||
8615 | ************************************************/ | - | ||||||||||||||||||
8616 | - | |||||||||||||||||||
8617 | /* It's very important that these two functions treat the characters | - | ||||||||||||||||||
8618 | between ( and ) identically. */ | - | ||||||||||||||||||
8619 | - | |||||||||||||||||||
8620 | static WORD_LIST parse_string_error; | - | ||||||||||||||||||
8621 | - | |||||||||||||||||||
8622 | /* Take a string and run it through the shell parser, returning the | - | ||||||||||||||||||
8623 | resultant word list. Used by compound array assignment. */ | - | ||||||||||||||||||
8624 | WORD_LIST * | - | ||||||||||||||||||
8625 | parse_string_to_word_list (s, flags, whom) | - | ||||||||||||||||||
8626 | char *s; | - | ||||||||||||||||||
8627 | int flags; | - | ||||||||||||||||||
8628 | const char *whom; | - | ||||||||||||||||||
8629 | { | - | ||||||||||||||||||
8630 | WORD_LIST *wl; | - | ||||||||||||||||||
8631 | int tok, orig_current_token, orig_line_number, orig_input_terminator; | - | ||||||||||||||||||
8632 | int orig_line_count; | - | ||||||||||||||||||
8633 | int old_echo_input, old_expand_aliases; | - | ||||||||||||||||||
8634 | #if defined (HISTORY) | - | ||||||||||||||||||
8635 | int old_remember_on_history, old_history_expansion_inhibited; | - | ||||||||||||||||||
8636 | #endif | - | ||||||||||||||||||
8637 | - | |||||||||||||||||||
8638 | #if defined (HISTORY) | - | ||||||||||||||||||
8639 | old_remember_on_history = remember_on_history; | - | ||||||||||||||||||
8640 | # if defined (BANG_HISTORY) | - | ||||||||||||||||||
8641 | old_history_expansion_inhibited = history_expansion_inhibited; | - | ||||||||||||||||||
8642 | # endif | - | ||||||||||||||||||
8643 | bash_history_disable (); | - | ||||||||||||||||||
8644 | #endif | - | ||||||||||||||||||
8645 | - | |||||||||||||||||||
8646 | orig_line_number = line_number; | - | ||||||||||||||||||
8647 | orig_line_count = current_command_line_count; | - | ||||||||||||||||||
8648 | orig_input_terminator = shell_input_line_terminator; | - | ||||||||||||||||||
8649 | old_echo_input = echo_input_at_read; | - | ||||||||||||||||||
8650 | old_expand_aliases = expand_aliases; | - | ||||||||||||||||||
8651 | - | |||||||||||||||||||
8652 | push_stream (1); | - | ||||||||||||||||||
8653 | last_read_token = WORD; /* WORD to allow reserved words here */ | - | ||||||||||||||||||
8654 | current_command_line_count = 0; | - | ||||||||||||||||||
8655 | echo_input_at_read = expand_aliases = 0; | - | ||||||||||||||||||
8656 | - | |||||||||||||||||||
8657 | with_input_from_string (s, whom); | - | ||||||||||||||||||
8658 | wl = (WORD_LIST *)NULL; | - | ||||||||||||||||||
8659 | - | |||||||||||||||||||
8660 | if (flags & 1) | - | ||||||||||||||||||
8661 | parser_state |= PST_COMPASSIGN|PST_REPARSE; | - | ||||||||||||||||||
8662 | - | |||||||||||||||||||
8663 | while ((tok = read_token (READ)) != yacc_EOF) | - | ||||||||||||||||||
8664 | { | - | ||||||||||||||||||
8665 | if (tok == '\n' && *bash_input.location.string == '\0') | - | ||||||||||||||||||
8666 | break; | - | ||||||||||||||||||
8667 | if (tok == '\n') /* Allow newlines in compound assignments */ | - | ||||||||||||||||||
8668 | continue; | - | ||||||||||||||||||
8669 | if (tok != WORD && tok != ASSIGNMENT_WORD) | - | ||||||||||||||||||
8670 | { | - | ||||||||||||||||||
8671 | line_number = orig_line_number + line_number - 1; | - | ||||||||||||||||||
8672 | orig_current_token = current_token; | - | ||||||||||||||||||
8673 | current_token = tok; | - | ||||||||||||||||||
8674 | yyerror (NULL); /* does the right thing */ | - | ||||||||||||||||||
8675 | current_token = orig_current_token; | - | ||||||||||||||||||
8676 | if (wl) | - | ||||||||||||||||||
8677 | dispose_words (wl); | - | ||||||||||||||||||
8678 | wl = &parse_string_error; | - | ||||||||||||||||||
8679 | break; | - | ||||||||||||||||||
8680 | } | - | ||||||||||||||||||
8681 | wl = make_word_list (yylval.word, wl); | - | ||||||||||||||||||
8682 | } | - | ||||||||||||||||||
8683 | - | |||||||||||||||||||
8684 | last_read_token = '\n'; | - | ||||||||||||||||||
8685 | pop_stream (); | - | ||||||||||||||||||
8686 | - | |||||||||||||||||||
8687 | #if defined (HISTORY) | - | ||||||||||||||||||
8688 | remember_on_history = old_remember_on_history; | - | ||||||||||||||||||
8689 | # if defined (BANG_HISTORY) | - | ||||||||||||||||||
8690 | history_expansion_inhibited = old_history_expansion_inhibited; | - | ||||||||||||||||||
8691 | # endif /* BANG_HISTORY */ | - | ||||||||||||||||||
8692 | #endif /* HISTORY */ | - | ||||||||||||||||||
8693 | - | |||||||||||||||||||
8694 | echo_input_at_read = old_echo_input; | - | ||||||||||||||||||
8695 | expand_aliases = old_expand_aliases; | - | ||||||||||||||||||
8696 | - | |||||||||||||||||||
8697 | current_command_line_count = orig_line_count; | - | ||||||||||||||||||
8698 | shell_input_line_terminator = orig_input_terminator; | - | ||||||||||||||||||
8699 | - | |||||||||||||||||||
8700 | if (flags & 1) | - | ||||||||||||||||||
8701 | parser_state &= ~(PST_COMPASSIGN|PST_REPARSE); | - | ||||||||||||||||||
8702 | - | |||||||||||||||||||
8703 | if (wl == &parse_string_error) | - | ||||||||||||||||||
8704 | { | - | ||||||||||||||||||
8705 | last_command_exit_value = EXECUTION_FAILURE; | - | ||||||||||||||||||
8706 | if (interactive_shell == 0 && posixly_correct) | - | ||||||||||||||||||
8707 | jump_to_top_level (FORCE_EOF); | - | ||||||||||||||||||
8708 | else | - | ||||||||||||||||||
8709 | jump_to_top_level (DISCARD); | - | ||||||||||||||||||
8710 | } | - | ||||||||||||||||||
8711 | - | |||||||||||||||||||
8712 | return (REVERSE_LIST (wl, WORD_LIST *)); | - | ||||||||||||||||||
8713 | } | - | ||||||||||||||||||
8714 | - | |||||||||||||||||||
8715 | static char * | - | ||||||||||||||||||
8716 | parse_compound_assignment (retlenp) | - | ||||||||||||||||||
8717 | int *retlenp; | - | ||||||||||||||||||
8718 | { | - | ||||||||||||||||||
8719 | WORD_LIST *wl, *rl; | - | ||||||||||||||||||
8720 | int tok, orig_line_number, orig_token_size, orig_last_token, assignok; | - | ||||||||||||||||||
8721 | char *saved_token, *ret; | - | ||||||||||||||||||
8722 | - | |||||||||||||||||||
8723 | saved_token = token; | - | ||||||||||||||||||
8724 | orig_token_size = token_buffer_size; | - | ||||||||||||||||||
8725 | orig_line_number = line_number; | - | ||||||||||||||||||
8726 | orig_last_token = last_read_token; | - | ||||||||||||||||||
8727 | - | |||||||||||||||||||
8728 | last_read_token = WORD; /* WORD to allow reserved words here */ | - | ||||||||||||||||||
8729 | - | |||||||||||||||||||
8730 | token = (char *)NULL; | - | ||||||||||||||||||
8731 | token_buffer_size = 0; | - | ||||||||||||||||||
8732 | - | |||||||||||||||||||
8733 | assignok = parser_state&PST_ASSIGNOK; /* XXX */ | - | ||||||||||||||||||
8734 | - | |||||||||||||||||||
8735 | wl = (WORD_LIST *)NULL; /* ( */ | - | ||||||||||||||||||
8736 | parser_state |= PST_COMPASSIGN; | - | ||||||||||||||||||
8737 | - | |||||||||||||||||||
8738 | while ((tok = read_token (READ)) != ')') | - | ||||||||||||||||||
8739 | { | - | ||||||||||||||||||
8740 | if (tok == '\n') /* Allow newlines in compound assignments */ | - | ||||||||||||||||||
8741 | { | - | ||||||||||||||||||
8742 | if (SHOULD_PROMPT ()) | - | ||||||||||||||||||
8743 | prompt_again (); | - | ||||||||||||||||||
8744 | continue; | - | ||||||||||||||||||
8745 | } | - | ||||||||||||||||||
8746 | if (tok != WORD && tok != ASSIGNMENT_WORD) | - | ||||||||||||||||||
8747 | { | - | ||||||||||||||||||
8748 | current_token = tok; /* for error reporting */ | - | ||||||||||||||||||
8749 | if (tok == yacc_EOF) /* ( */ | - | ||||||||||||||||||
8750 | parser_error (orig_line_number, _("unexpected EOF while looking for matching `)'")); | - | ||||||||||||||||||
8751 | else | - | ||||||||||||||||||
8752 | yyerror(NULL); /* does the right thing */ | - | ||||||||||||||||||
8753 | if (wl) | - | ||||||||||||||||||
8754 | dispose_words (wl); | - | ||||||||||||||||||
8755 | wl = &parse_string_error; | - | ||||||||||||||||||
8756 | break; | - | ||||||||||||||||||
8757 | } | - | ||||||||||||||||||
8758 | wl = make_word_list (yylval.word, wl); | - | ||||||||||||||||||
8759 | } | - | ||||||||||||||||||
8760 | - | |||||||||||||||||||
8761 | FREE (token); | - | ||||||||||||||||||
8762 | token = saved_token; | - | ||||||||||||||||||
8763 | token_buffer_size = orig_token_size; | - | ||||||||||||||||||
8764 | - | |||||||||||||||||||
8765 | parser_state &= ~PST_COMPASSIGN; | - | ||||||||||||||||||
8766 | - | |||||||||||||||||||
8767 | if (wl == &parse_string_error) | - | ||||||||||||||||||
8768 | { | - | ||||||||||||||||||
8769 | last_command_exit_value = EXECUTION_FAILURE; | - | ||||||||||||||||||
8770 | last_read_token = '\n'; /* XXX */ | - | ||||||||||||||||||
8771 | if (interactive_shell == 0 && posixly_correct) | - | ||||||||||||||||||
8772 | jump_to_top_level (FORCE_EOF); | - | ||||||||||||||||||
8773 | else | - | ||||||||||||||||||
8774 | jump_to_top_level (DISCARD); | - | ||||||||||||||||||
8775 | } | - | ||||||||||||||||||
8776 | - | |||||||||||||||||||
8777 | last_read_token = orig_last_token; /* XXX - was WORD? */ | - | ||||||||||||||||||
8778 | - | |||||||||||||||||||
8779 | if (wl) | - | ||||||||||||||||||
8780 | { | - | ||||||||||||||||||
8781 | rl = REVERSE_LIST (wl, WORD_LIST *); | - | ||||||||||||||||||
8782 | ret = string_list (rl); | - | ||||||||||||||||||
8783 | dispose_words (rl); | - | ||||||||||||||||||
8784 | } | - | ||||||||||||||||||
8785 | else | - | ||||||||||||||||||
8786 | ret = (char *)NULL; | - | ||||||||||||||||||
8787 | - | |||||||||||||||||||
8788 | if (retlenp) | - | ||||||||||||||||||
8789 | *retlenp = (ret && *ret) ? strlen (ret) : 0; | - | ||||||||||||||||||
8790 | - | |||||||||||||||||||
8791 | if (assignok) | - | ||||||||||||||||||
8792 | parser_state |= PST_ASSIGNOK; | - | ||||||||||||||||||
8793 | - | |||||||||||||||||||
8794 | return ret; | - | ||||||||||||||||||
8795 | } | - | ||||||||||||||||||
8796 | - | |||||||||||||||||||
8797 | /************************************************ | - | ||||||||||||||||||
8798 | * * | - | ||||||||||||||||||
8799 | * SAVING AND RESTORING PARTIAL PARSE STATE * | - | ||||||||||||||||||
8800 | * * | - | ||||||||||||||||||
8801 | ************************************************/ | - | ||||||||||||||||||
8802 | - | |||||||||||||||||||
8803 | sh_parser_state_t * | - | ||||||||||||||||||
8804 | save_parser_state (ps) | - | ||||||||||||||||||
8805 | sh_parser_state_t *ps; | - | ||||||||||||||||||
8806 | { | - | ||||||||||||||||||
8807 | if (ps == 0) | - | ||||||||||||||||||
8808 | ps = (sh_parser_state_t *)xmalloc (sizeof (sh_parser_state_t)); | - | ||||||||||||||||||
8809 | if (ps == 0) | - | ||||||||||||||||||
8810 | return ((sh_parser_state_t *)NULL); | - | ||||||||||||||||||
8811 | - | |||||||||||||||||||
8812 | ps->parser_state = parser_state; | - | ||||||||||||||||||
8813 | ps->token_state = save_token_state (); | - | ||||||||||||||||||
8814 | - | |||||||||||||||||||
8815 | ps->input_line_terminator = shell_input_line_terminator; | - | ||||||||||||||||||
8816 | ps->eof_encountered = eof_encountered; | - | ||||||||||||||||||
8817 | - | |||||||||||||||||||
8818 | ps->prompt_string_pointer = prompt_string_pointer; | - | ||||||||||||||||||
8819 | - | |||||||||||||||||||
8820 | ps->current_command_line_count = current_command_line_count; | - | ||||||||||||||||||
8821 | - | |||||||||||||||||||
8822 | #if defined (HISTORY) | - | ||||||||||||||||||
8823 | ps->remember_on_history = remember_on_history; | - | ||||||||||||||||||
8824 | # if defined (BANG_HISTORY) | - | ||||||||||||||||||
8825 | ps->history_expansion_inhibited = history_expansion_inhibited; | - | ||||||||||||||||||
8826 | # endif | - | ||||||||||||||||||
8827 | #endif | - | ||||||||||||||||||
8828 | - | |||||||||||||||||||
8829 | ps->last_command_exit_value = last_command_exit_value; | - | ||||||||||||||||||
8830 | #if defined (ARRAY_VARS) | - | ||||||||||||||||||
8831 | ps->pipestatus = save_pipestatus_array (); | - | ||||||||||||||||||
8832 | #endif | - | ||||||||||||||||||
8833 | - | |||||||||||||||||||
8834 | ps->last_shell_builtin = last_shell_builtin; | - | ||||||||||||||||||
8835 | ps->this_shell_builtin = this_shell_builtin; | - | ||||||||||||||||||
8836 | - | |||||||||||||||||||
8837 | ps->expand_aliases = expand_aliases; | - | ||||||||||||||||||
8838 | ps->echo_input_at_read = echo_input_at_read; | - | ||||||||||||||||||
8839 | ps->need_here_doc = need_here_doc; | - | ||||||||||||||||||
8840 | ps->here_doc_first_line = here_doc_first_line; | - | ||||||||||||||||||
8841 | - | |||||||||||||||||||
8842 | if (need_here_doc == 0) | - | ||||||||||||||||||
8843 | ps->redir_stack[0] = 0; | - | ||||||||||||||||||
8844 | else | - | ||||||||||||||||||
8845 | memcpy (ps->redir_stack, redir_stack, sizeof (redir_stack[0]) * HEREDOC_MAX); | - | ||||||||||||||||||
8846 | - | |||||||||||||||||||
8847 | ps->token = token; | - | ||||||||||||||||||
8848 | ps->token_buffer_size = token_buffer_size; | - | ||||||||||||||||||
8849 | /* Force reallocation on next call to read_token_word */ | - | ||||||||||||||||||
8850 | token = 0; | - | ||||||||||||||||||
8851 | token_buffer_size = 0; | - | ||||||||||||||||||
8852 | - | |||||||||||||||||||
8853 | return (ps); | - | ||||||||||||||||||
8854 | } | - | ||||||||||||||||||
8855 | - | |||||||||||||||||||
8856 | void | - | ||||||||||||||||||
8857 | restore_parser_state (ps) | - | ||||||||||||||||||
8858 | sh_parser_state_t *ps; | - | ||||||||||||||||||
8859 | { | - | ||||||||||||||||||
8860 | int i; | - | ||||||||||||||||||
8861 | - | |||||||||||||||||||
8862 | if (ps == 0) | - | ||||||||||||||||||
8863 | return; | - | ||||||||||||||||||
8864 | - | |||||||||||||||||||
8865 | parser_state = ps->parser_state; | - | ||||||||||||||||||
8866 | if (ps->token_state) | - | ||||||||||||||||||
8867 | { | - | ||||||||||||||||||
8868 | restore_token_state (ps->token_state); | - | ||||||||||||||||||
8869 | free (ps->token_state); | - | ||||||||||||||||||
8870 | } | - | ||||||||||||||||||
8871 | - | |||||||||||||||||||
8872 | shell_input_line_terminator = ps->input_line_terminator; | - | ||||||||||||||||||
8873 | eof_encountered = ps->eof_encountered; | - | ||||||||||||||||||
8874 | - | |||||||||||||||||||
8875 | prompt_string_pointer = ps->prompt_string_pointer; | - | ||||||||||||||||||
8876 | - | |||||||||||||||||||
8877 | current_command_line_count = ps->current_command_line_count; | - | ||||||||||||||||||
8878 | - | |||||||||||||||||||
8879 | #if defined (HISTORY) | - | ||||||||||||||||||
8880 | remember_on_history = ps->remember_on_history; | - | ||||||||||||||||||
8881 | # if defined (BANG_HISTORY) | - | ||||||||||||||||||
8882 | history_expansion_inhibited = ps->history_expansion_inhibited; | - | ||||||||||||||||||
8883 | # endif | - | ||||||||||||||||||
8884 | #endif | - | ||||||||||||||||||
8885 | - | |||||||||||||||||||
8886 | last_command_exit_value = ps->last_command_exit_value; | - | ||||||||||||||||||
8887 | #if defined (ARRAY_VARS) | - | ||||||||||||||||||
8888 | restore_pipestatus_array (ps->pipestatus); | - | ||||||||||||||||||
8889 | #endif | - | ||||||||||||||||||
8890 | - | |||||||||||||||||||
8891 | last_shell_builtin = ps->last_shell_builtin; | - | ||||||||||||||||||
8892 | this_shell_builtin = ps->this_shell_builtin; | - | ||||||||||||||||||
8893 | - | |||||||||||||||||||
8894 | expand_aliases = ps->expand_aliases; | - | ||||||||||||||||||
8895 | echo_input_at_read = ps->echo_input_at_read; | - | ||||||||||||||||||
8896 | need_here_doc = ps->need_here_doc; | - | ||||||||||||||||||
8897 | here_doc_first_line = ps->here_doc_first_line; | - | ||||||||||||||||||
8898 | - | |||||||||||||||||||
8899 | #if 0 | - | ||||||||||||||||||
8900 | for (i = 0; i < HEREDOC_MAX; i++) | - | ||||||||||||||||||
8901 | redir_stack[i] = ps->redir_stack[i]; | - | ||||||||||||||||||
8902 | #else | - | ||||||||||||||||||
8903 | if (need_here_doc == 0) | - | ||||||||||||||||||
8904 | redir_stack[0] = 0; | - | ||||||||||||||||||
8905 | else | - | ||||||||||||||||||
8906 | memcpy (redir_stack, ps->redir_stack, sizeof (redir_stack[0]) * HEREDOC_MAX); | - | ||||||||||||||||||
8907 | #endif | - | ||||||||||||||||||
8908 | - | |||||||||||||||||||
8909 | FREE (token); | - | ||||||||||||||||||
8910 | token = ps->token; | - | ||||||||||||||||||
8911 | token_buffer_size = ps->token_buffer_size; | - | ||||||||||||||||||
8912 | } | - | ||||||||||||||||||
8913 | - | |||||||||||||||||||
8914 | sh_input_line_state_t * | - | ||||||||||||||||||
8915 | save_input_line_state (ls) | - | ||||||||||||||||||
8916 | sh_input_line_state_t *ls; | - | ||||||||||||||||||
8917 | { | - | ||||||||||||||||||
8918 | if (ls == 0) | - | ||||||||||||||||||
8919 | ls = (sh_input_line_state_t *)xmalloc (sizeof (sh_input_line_state_t)); | - | ||||||||||||||||||
8920 | if (ls == 0) | - | ||||||||||||||||||
8921 | return ((sh_input_line_state_t *)NULL); | - | ||||||||||||||||||
8922 | - | |||||||||||||||||||
8923 | ls->input_line = shell_input_line; | - | ||||||||||||||||||
8924 | ls->input_line_size = shell_input_line_size; | - | ||||||||||||||||||
8925 | ls->input_line_len = shell_input_line_len; | - | ||||||||||||||||||
8926 | ls->input_line_index = shell_input_line_index; | - | ||||||||||||||||||
8927 | - | |||||||||||||||||||
8928 | /* force reallocation */ | - | ||||||||||||||||||
8929 | shell_input_line = 0; | - | ||||||||||||||||||
8930 | shell_input_line_size = shell_input_line_len = shell_input_line_index = 0; | - | ||||||||||||||||||
8931 | - | |||||||||||||||||||
8932 | return ls; | - | ||||||||||||||||||
8933 | } | - | ||||||||||||||||||
8934 | - | |||||||||||||||||||
8935 | void | - | ||||||||||||||||||
8936 | restore_input_line_state (ls) | - | ||||||||||||||||||
8937 | sh_input_line_state_t *ls; | - | ||||||||||||||||||
8938 | { | - | ||||||||||||||||||
8939 | FREE (shell_input_line); | - | ||||||||||||||||||
8940 | shell_input_line = ls->input_line; | - | ||||||||||||||||||
8941 | shell_input_line_size = ls->input_line_size; | - | ||||||||||||||||||
8942 | shell_input_line_len = ls->input_line_len; | - | ||||||||||||||||||
8943 | shell_input_line_index = ls->input_line_index; | - | ||||||||||||||||||
8944 | - | |||||||||||||||||||
8945 | set_line_mbstate (); | - | ||||||||||||||||||
8946 | } | - | ||||||||||||||||||
8947 | - | |||||||||||||||||||
8948 | /************************************************ | - | ||||||||||||||||||
8949 | * * | - | ||||||||||||||||||
8950 | * MULTIBYTE CHARACTER HANDLING * | - | ||||||||||||||||||
8951 | * * | - | ||||||||||||||||||
8952 | ************************************************/ | - | ||||||||||||||||||
8953 | - | |||||||||||||||||||
8954 | #if defined (HANDLE_MULTIBYTE) | - | ||||||||||||||||||
8955 | - | |||||||||||||||||||
8956 | /* We don't let the property buffer get larger than this unless the line is */ | - | ||||||||||||||||||
8957 | #define MAX_PROPSIZE 32768 | - | ||||||||||||||||||
8958 | - | |||||||||||||||||||
8959 | static void | - | ||||||||||||||||||
8960 | set_line_mbstate () | - | ||||||||||||||||||
8961 | { | - | ||||||||||||||||||
8962 | int c; | - | ||||||||||||||||||
8963 | size_t i, previ, len; | - | ||||||||||||||||||
8964 | mbstate_t mbs, prevs; | - | ||||||||||||||||||
8965 | size_t mbclen; | - | ||||||||||||||||||
8966 | - | |||||||||||||||||||
8967 | if (shell_input_line == NULL) | - | ||||||||||||||||||
8968 | return; | - | ||||||||||||||||||
8969 | len = strlen (shell_input_line); /* XXX - shell_input_line_len ? */ | - | ||||||||||||||||||
8970 | if (len == 0) | - | ||||||||||||||||||
8971 | return; | - | ||||||||||||||||||
8972 | if (shell_input_line_propsize >= MAX_PROPSIZE && len < MAX_PROPSIZE>>1) | - | ||||||||||||||||||
8973 | { | - | ||||||||||||||||||
8974 | free (shell_input_line_property); | - | ||||||||||||||||||
8975 | shell_input_line_property = 0; | - | ||||||||||||||||||
8976 | shell_input_line_propsize = 0; | - | ||||||||||||||||||
8977 | } | - | ||||||||||||||||||
8978 | if (len+1 > shell_input_line_propsize) | - | ||||||||||||||||||
8979 | { | - | ||||||||||||||||||
8980 | shell_input_line_propsize = len + 1; | - | ||||||||||||||||||
8981 | shell_input_line_property = (char *)xrealloc (shell_input_line_property, shell_input_line_propsize); | - | ||||||||||||||||||
8982 | } | - | ||||||||||||||||||
8983 | - | |||||||||||||||||||
8984 | /* XXX - use whether or not we are in a UTF-8 locale to avoid calls to | - | ||||||||||||||||||
8985 | mbrlen */ | - | ||||||||||||||||||
8986 | memset (&prevs, '\0', sizeof (mbstate_t)); | - | ||||||||||||||||||
8987 | for (i = previ = 0; i < len; i++) | - | ||||||||||||||||||
8988 | { | - | ||||||||||||||||||
8989 | mbs = prevs; | - | ||||||||||||||||||
8990 | - | |||||||||||||||||||
8991 | c = shell_input_line[i]; | - | ||||||||||||||||||
8992 | if (c == EOF) | - | ||||||||||||||||||
8993 | { | - | ||||||||||||||||||
8994 | size_t j; | - | ||||||||||||||||||
8995 | for (j = i; j < len; j++) | - | ||||||||||||||||||
8996 | shell_input_line_property[j] = 1; | - | ||||||||||||||||||
8997 | break; | - | ||||||||||||||||||
8998 | } | - | ||||||||||||||||||
8999 | - | |||||||||||||||||||
9000 | /* I'd love to take more advantage of UTF-8's properties in a UTF-8 | - | ||||||||||||||||||
9001 | locale, but mbrlen changes the mbstate_t on every call even when | - | ||||||||||||||||||
9002 | presented with single-byte characters. */ | - | ||||||||||||||||||
9003 | mbclen = mbrlen (shell_input_line + previ, i - previ + 1, &mbs); | - | ||||||||||||||||||
9004 | if (mbclen == 1 || mbclen == (size_t)-1) | - | ||||||||||||||||||
9005 | { | - | ||||||||||||||||||
9006 | mbclen = 1; | - | ||||||||||||||||||
9007 | previ = i + 1; | - | ||||||||||||||||||
9008 | } | - | ||||||||||||||||||
9009 | else if (mbclen == (size_t)-2) | - | ||||||||||||||||||
9010 | mbclen = 0; | - | ||||||||||||||||||
9011 | else if (mbclen > 1) | - | ||||||||||||||||||
9012 | { | - | ||||||||||||||||||
9013 | mbclen = 0; | - | ||||||||||||||||||
9014 | previ = i + 1; | - | ||||||||||||||||||
9015 | prevs = mbs; | - | ||||||||||||||||||
9016 | } | - | ||||||||||||||||||
9017 | else | - | ||||||||||||||||||
9018 | { | - | ||||||||||||||||||
9019 | /* XXX - what to do if mbrlen returns 0? (null wide character) */ | - | ||||||||||||||||||
9020 | size_t j; | - | ||||||||||||||||||
9021 | for (j = i; j < len; j++) | - | ||||||||||||||||||
9022 | shell_input_line_property[j] = 1; | - | ||||||||||||||||||
9023 | break; | - | ||||||||||||||||||
9024 | } | - | ||||||||||||||||||
9025 | - | |||||||||||||||||||
9026 | shell_input_line_property[i] = mbclen; | - | ||||||||||||||||||
9027 | } | - | ||||||||||||||||||
9028 | } | - | ||||||||||||||||||
9029 | #endif /* HANDLE_MULTIBYTE */ | - | ||||||||||||||||||
Source code | Switch to Preprocessed file |