mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-15 14:41:14 -03:00
Clean up parser_t's block stack
Currently the block stack is just a vector of pointers. Clients must manually use new() to allocate a block, and then transfer ownership to the stack (so must NOT delete it). Give the parser itself responsibility for allocating blocks too, so that it takes over both allocation and deletion. Use unique_ptr to make deletion less error-prone.
This commit is contained in:
@@ -629,8 +629,8 @@ void exec_job(parser_t &parser, job_t *j) {
|
||||
debug(0, _(L"Unknown function '%ls'"), p->argv0());
|
||||
break;
|
||||
}
|
||||
function_block_t *newv = new function_block_t(p, func_name, shadow_scope);
|
||||
parser.push_block(newv);
|
||||
|
||||
function_block_t *fb = parser.push_block<function_block_t>(p, func_name, shadow_scope);
|
||||
|
||||
// Setting variables might trigger an event handler, hence we need to unblock
|
||||
// signals.
|
||||
@@ -661,7 +661,7 @@ void exec_job(parser_t &parser, job_t *j) {
|
||||
}
|
||||
|
||||
parser.allow_function();
|
||||
parser.pop_block();
|
||||
parser.pop_block(fb);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user