mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-08-08 11:12:36 +02:00
bash-4.4 beta release
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/* parse.y - Yacc grammar for bash. */
|
||||
|
||||
/* Copyright (C) 1989-2012 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1989-2015 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -268,8 +268,6 @@ int parser_state;
|
||||
|
||||
/* Variables to manage the task of reading here documents, because we need to
|
||||
defer the reading until after a complete command has been collected. */
|
||||
#define HEREDOC_MAX 16
|
||||
|
||||
static REDIRECT *redir_stack[HEREDOC_MAX];
|
||||
int need_here_doc;
|
||||
|
||||
@@ -2703,6 +2701,7 @@ gather_here_documents ()
|
||||
make_here_document (redir_stack[r++], line_number);
|
||||
parser_state &= ~PST_HEREDOC;
|
||||
need_here_doc--;
|
||||
redir_stack[r - 1] = 0; /* XXX */
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2710,10 +2709,27 @@ gather_here_documents ()
|
||||
brace partner. */
|
||||
static int open_brace_count;
|
||||
|
||||
/* In the following three macros, `token' is always last_read_token */
|
||||
|
||||
/* Are we in the middle of parsing a redirection where we are about to read
|
||||
a word? This is used to make sure alias expansion doesn't happen in the
|
||||
middle of a redirection, even though we're parsing a simple command. */
|
||||
#define parsing_redirection(token) \
|
||||
(token == '<' || token == '>' || \
|
||||
token == GREATER_GREATER || token == GREATER_BAR || \
|
||||
token == LESS_GREATER || token == LESS_LESS_MINUS || \
|
||||
token == LESS_LESS || token == LESS_LESS_LESS || \
|
||||
token == LESS_AND || token == GREATER_AND || token == AND_GREATER)
|
||||
|
||||
/* Is `token' one that will allow a WORD to be read in a command position?
|
||||
We can read a simple command name on which we should attempt alias expansion
|
||||
or we can read an assignment statement. */
|
||||
#define command_token_position(token) \
|
||||
(((token) == ASSIGNMENT_WORD) || (parser_state&PST_REDIRLIST) || \
|
||||
(((token) == ASSIGNMENT_WORD) || \
|
||||
((parser_state&PST_REDIRLIST) && parsing_redirection(token) == 0) || \
|
||||
((token) != SEMI_SEMI && (token) != SEMI_AND && (token) != SEMI_SEMI_AND && reserved_word_acceptable(token)))
|
||||
|
||||
/* Are we in a position where we can read an assignment statement? */
|
||||
#define assignment_acceptable(token) \
|
||||
(command_token_position(token) && ((parser_state & PST_CASEPAT) == 0))
|
||||
|
||||
@@ -4077,7 +4093,7 @@ xparse_dolparen (base, string, indp, flags)
|
||||
parser_state |= PST_CMDSUBST|PST_EOFTOKEN; /* allow instant ')' */ /*(*/
|
||||
shell_eof_token = ')';
|
||||
|
||||
parse_string (string, "command substitution", sflags, &ep);
|
||||
nc = parse_string (string, "command substitution", sflags, &ep);
|
||||
|
||||
shell_eof_token = orig_eof_token;
|
||||
restore_parser_state (&ps);
|
||||
@@ -4087,6 +4103,11 @@ xparse_dolparen (base, string, indp, flags)
|
||||
|
||||
token_to_read = 0;
|
||||
|
||||
/* If parse_string returns < 0, we need to jump to top level with the
|
||||
negative of the return value */
|
||||
if (nc < 0)
|
||||
jump_to_top_level (-nc); /* XXX */
|
||||
|
||||
/* Need to find how many characters parse_and_execute consumed, update
|
||||
*indp, if flags != 0, copy the portion of the string parsed into RET
|
||||
and return it. If flags & 1 (EX_NOALLOC) we can return NULL. */
|
||||
@@ -5629,6 +5650,10 @@ not_escape:
|
||||
else
|
||||
{
|
||||
RESIZE_MALLOCED_BUFFER (result, result_index, 3, result_size, PROMPT_GROWTH);
|
||||
/* dequote_string should take care of removing this if we are not
|
||||
performing the rest of the word expansions. */
|
||||
if (c == CTLESC || c == CTLNUL)
|
||||
result[result_index++] = CTLESC;
|
||||
result[result_index++] = c;
|
||||
result[result_index] = '\0';
|
||||
}
|
||||
@@ -6122,6 +6147,8 @@ sh_parser_state_t *
|
||||
save_parser_state (ps)
|
||||
sh_parser_state_t *ps;
|
||||
{
|
||||
int i;
|
||||
|
||||
if (ps == 0)
|
||||
ps = (sh_parser_state_t *)xmalloc (sizeof (sh_parser_state_t));
|
||||
if (ps == 0)
|
||||
@@ -6156,6 +6183,16 @@ save_parser_state (ps)
|
||||
ps->echo_input_at_read = echo_input_at_read;
|
||||
ps->need_here_doc = need_here_doc;
|
||||
|
||||
#if 0
|
||||
for (i = 0; i < HEREDOC_MAX; i++)
|
||||
ps->redir_stack[i] = redir_stack[i];
|
||||
#else
|
||||
if (need_here_doc == 0)
|
||||
ps->redir_stack[0] = 0;
|
||||
else
|
||||
memcpy (ps->redir_stack, redir_stack, sizeof (redir_stack[0]) * HEREDOC_MAX);
|
||||
#endif
|
||||
|
||||
ps->token = token;
|
||||
ps->token_buffer_size = token_buffer_size;
|
||||
/* Force reallocation on next call to read_token_word */
|
||||
@@ -6169,6 +6206,8 @@ void
|
||||
restore_parser_state (ps)
|
||||
sh_parser_state_t *ps;
|
||||
{
|
||||
int i;
|
||||
|
||||
if (ps == 0)
|
||||
return;
|
||||
|
||||
@@ -6205,6 +6244,16 @@ restore_parser_state (ps)
|
||||
echo_input_at_read = ps->echo_input_at_read;
|
||||
need_here_doc = ps->need_here_doc;
|
||||
|
||||
#if 0
|
||||
for (i = 0; i < HEREDOC_MAX; i++)
|
||||
redir_stack[i] = ps->redir_stack[i];
|
||||
#else
|
||||
if (need_here_doc == 0)
|
||||
redir_stack[0] = 0;
|
||||
else
|
||||
memcpy (redir_stack, ps->redir_stack, sizeof (redir_stack[0]) * HEREDOC_MAX);
|
||||
#endif
|
||||
|
||||
FREE (token);
|
||||
token = ps->token;
|
||||
token_buffer_size = ps->token_buffer_size;
|
||||
|
||||
Reference in New Issue
Block a user