Reformat CPP files

This commit is contained in:
Johannes Altmanninger 2020-08-04 21:41:14 +02:00
parent 4f6ad69c8a
commit 64601fd4d3
3 changed files with 39 additions and 46 deletions

View File

@ -467,9 +467,8 @@ bool autosuggest_validate_from_history(const history_item_t &item,
}
// Not handled specially so handle it here.
bool cmd_ok = builtin_exists(parsed_command)
|| function_exists_no_autoload(parsed_command)
|| path_get_path(parsed_command, nullptr, ctx.vars);
bool cmd_ok = builtin_exists(parsed_command) || function_exists_no_autoload(parsed_command) ||
path_get_path(parsed_command, nullptr, ctx.vars);
if (cmd_ok) {
const path_list_t &paths = item.get_required_paths();

View File

@ -530,12 +530,10 @@ char_event_t inputter_t::readch(bool allow_commands) {
case readline_cmd_t::func_or: {
// If previous function has right status, we keep reading tokens
if (evt.get_readline() == readline_cmd_t::func_and) {
if (function_status_)
return readch();
if (function_status_) return readch();
} else {
assert(evt.get_readline() == readline_cmd_t::func_or);
if (!function_status_)
return readch();
if (!function_status_) return readch();
}
// Else we flush remaining tokens
do {

View File

@ -1222,47 +1222,43 @@ parser_test_error_bits_t parse_util_detect_errors(const ast::ast_t &ast, const w
// Verify no variable expansions.
wcstring storage;
for (const node_t &node : ast) {
if (const job_continuation_t *jc = node.try_as<job_continuation_t>()) {
// Somewhat clumsy way of checking for a statement without source in a pipeline.
// See if our pipe has source but our statement does not.
if (!jc->pipe.unsourced && !jc->statement.try_source_range().has_value()) {
has_unclosed_pipe = true;
}
} else if (const argument_t *arg = node.try_as<argument_t>()) {
const wcstring &arg_src = arg->source(buff_src, &storage);
res |= parse_util_detect_errors_in_argument(*arg, arg_src, out_errors);
} else if (const ast::job_t *job = node.try_as<ast::job_t>()) {
// Disallow background in the following cases:
//
// foo & ; and bar
// foo & ; or bar
// if foo & ; end
// while foo & ; end
// If it's not a background job, nothing to do.
if (job->bg) {
errored |= detect_errors_in_backgrounded_job(*job, out_errors);
}
} else if (const ast::decorated_statement_t *stmt =
node.try_as<decorated_statement_t>()) {
errored |=
detect_errors_in_decorated_statement(buff_src, *stmt, &storage, out_errors);
} else if (const auto *block = node.try_as<block_statement_t>()) {
// If our 'end' had no source, we are unsourced.
if (block->end.unsourced) has_unclosed_block = true;
errored |=
detect_errors_in_block_redirection_list(block->args_or_redirs, out_errors);
} else if (const auto *ifs = node.try_as<if_statement_t>()) {
// If our 'end' had no source, we are unsourced.
if (ifs->end.unsourced) has_unclosed_block = true;
errored |= detect_errors_in_block_redirection_list(ifs->args_or_redirs, out_errors);
} else if (const auto *switchs = node.try_as<switch_statement_t>()) {
// If our 'end' had no source, we are unsourced.
if (switchs->end.unsourced) has_unclosed_block = true;
errored |=
detect_errors_in_block_redirection_list(switchs->args_or_redirs, out_errors);
for (const node_t &node : ast) {
if (const job_continuation_t *jc = node.try_as<job_continuation_t>()) {
// Somewhat clumsy way of checking for a statement without source in a pipeline.
// See if our pipe has source but our statement does not.
if (!jc->pipe.unsourced && !jc->statement.try_source_range().has_value()) {
has_unclosed_pipe = true;
}
} else if (const argument_t *arg = node.try_as<argument_t>()) {
const wcstring &arg_src = arg->source(buff_src, &storage);
res |= parse_util_detect_errors_in_argument(*arg, arg_src, out_errors);
} else if (const ast::job_t *job = node.try_as<ast::job_t>()) {
// Disallow background in the following cases:
//
// foo & ; and bar
// foo & ; or bar
// if foo & ; end
// while foo & ; end
// If it's not a background job, nothing to do.
if (job->bg) {
errored |= detect_errors_in_backgrounded_job(*job, out_errors);
}
} else if (const ast::decorated_statement_t *stmt = node.try_as<decorated_statement_t>()) {
errored |= detect_errors_in_decorated_statement(buff_src, *stmt, &storage, out_errors);
} else if (const auto *block = node.try_as<block_statement_t>()) {
// If our 'end' had no source, we are unsourced.
if (block->end.unsourced) has_unclosed_block = true;
errored |= detect_errors_in_block_redirection_list(block->args_or_redirs, out_errors);
} else if (const auto *ifs = node.try_as<if_statement_t>()) {
// If our 'end' had no source, we are unsourced.
if (ifs->end.unsourced) has_unclosed_block = true;
errored |= detect_errors_in_block_redirection_list(ifs->args_or_redirs, out_errors);
} else if (const auto *switchs = node.try_as<switch_statement_t>()) {
// If our 'end' had no source, we are unsourced.
if (switchs->end.unsourced) has_unclosed_block = true;
errored |= detect_errors_in_block_redirection_list(switchs->args_or_redirs, out_errors);
}
}
if (errored) res |= PARSER_TEST_ERROR;