summaryrefslogtreecommitdiffhomepage
path: root/src/parser.c
diff options
context:
space:
mode:
authorSean Kurtz <seankurtz75@gmail.com>2026-11-28 14:16:41 -0600
committerGitHub <noreply@github.com>2026-11-28 14:16:41 -0600
commit95d31d2d7d5fd7de81d6d5e2caedcdc369ca0fcf (patch)
tree4959b8d43268945543be4061b8fccd95d04592b1 /src/parser.c
parent625908ab56c7c554506d61c83c7001bca19a05f6 (diff)
parent6fe2aff8d6611bf45704ba86120efa23950bfa80 (diff)
downloadzash-95d31d2d7d5fd7de81d6d5e2caedcdc369ca0fcf.tar.gz
Merge pull request #46 from skurtz97/fix/review-2026-11-28
Fixes from the 2026-11-28 code review
Diffstat (limited to 'src/parser.c')
-rw-r--r--src/parser.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/parser.c b/src/parser.c
index 70bc96a..98d4c0b 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -112,14 +112,14 @@ static heredoc *here_head;
/**
* @brief Where the next pending here-document is linked.
*/
+static heredoc **here_tail = &here_head;
+
/**
* @brief The lexer is inside `[[ ]]`, where `<` and `>` are comparison
* operators, not redirections.
*/
static bool in_cond;
-static heredoc **here_tail = &here_head;
-
/**
* @brief Set by input_fill() when an alias whose value ends in a blank runs
* out: the next word is then subject to alias substitution too.
@@ -2139,6 +2139,8 @@ typedef struct parser_state {
bool tok_pushed;
heredoc *here_head;
heredoc **here_tail;
+ bool in_cond;
+ bool alias_ended_blank;
} parser_state;
static_assert(sizeof(parser_state) <= PARSER_STATE_SIZE,
@@ -2150,7 +2152,8 @@ static_assert(sizeof(parser_state) <= PARSER_STATE_SIZE,
*/
void parser_save(void *state) {
parser_state *ps = state;
- *ps = (parser_state){pa, tok, tok_pushed, here_head, here_tail};
+ *ps = (parser_state){pa, tok, tok_pushed, here_head, here_tail, in_cond,
+ alias_ended_blank};
if (here_tail == &here_head)
ps->here_tail = nullptr;
parser_reset();
@@ -2166,4 +2169,6 @@ void parser_restore(const void *state) {
tok_pushed = ps->tok_pushed;
here_head = ps->here_head;
here_tail = ps->here_tail ? ps->here_tail : &here_head;
+ in_cond = ps->in_cond;
+ alias_ended_blank = ps->alias_ended_blank;
}