Reformat CPP files

This commit is contained in:
ridiculousfish 2020-07-12 12:20:38 -07:00
parent f1a59e83c5
commit 9ee5075fc3
7 changed files with 17 additions and 20 deletions

View File

@ -153,7 +153,6 @@ struct optional_t {
bool has_value() const { return contents != nullptr; } bool has_value() const { return contents != nullptr; }
}; };
namespace horrible_template_goop { namespace horrible_template_goop {
// void if B is true, SFINAE'd away otherwise. // void if B is true, SFINAE'd away otherwise.
@ -1015,4 +1014,4 @@ class ast_t {
}; };
} // namespace ast } // namespace ast
#endif // FISH_AST_H #endif // FISH_AST_H

View File

@ -87,8 +87,10 @@
static const char *const *s_arguments; static const char *const *s_arguments;
static int s_test_run_count = 0; static int s_test_run_count = 0;
#define system_assert(command) if (system(command)) \ #define system_assert(command) \
{ err(L"Non-zero result on line %d: %s", __LINE__, command); } if (system(command)) { \
err(L"Non-zero result on line %d: %s", __LINE__, command); \
}
// Indicate if we should test the given function. Either we test everything (all arguments) or we // Indicate if we should test the given function. Either we test everything (all arguments) or we
// run only tests that have a prefix in s_arguments. // run only tests that have a prefix in s_arguments.

View File

@ -1078,7 +1078,7 @@ void highlighter_t::visit(const ast::decorated_statement_t &stmt) {
void highlighter_t::visit(const ast::redirection_t &redir) { void highlighter_t::visit(const ast::redirection_t &redir) {
maybe_t<pipe_or_redir_t> oper = maybe_t<pipe_or_redir_t> oper =
pipe_or_redir_t::from_string(redir.oper.source(this->buff)); // like 2> pipe_or_redir_t::from_string(redir.oper.source(this->buff)); // like 2>
wcstring target = redir.target.source(this->buff); // like &1 or file path wcstring target = redir.target.source(this->buff); // like &1 or file path
assert(oper.has_value() && assert(oper.has_value() &&
"Should have successfully parsed a pipe_or_redir_t since it was in our ast"); "Should have successfully parsed a pipe_or_redir_t since it was in our ast");
@ -1177,9 +1177,8 @@ void highlighter_t::visit(const ast::redirection_t &redir) {
} }
// NOCLOB means that we must not overwrite files that exist. // NOCLOB means that we must not overwrite files that exist.
target_is_valid = target_is_valid = file_is_writable &&
file_is_writable && !(file_exists && oper->mode == redirection_mode_t::noclob);
!(file_exists && oper->mode == redirection_mode_t::noclob);
break; break;
} }
} }

View File

@ -25,20 +25,19 @@ struct parse_token_t {
enum parse_token_type_t type; // The type of the token as represented by the parser enum parse_token_type_t type; // The type of the token as represented by the parser
enum parse_keyword_t keyword { enum parse_keyword_t keyword {
parse_keyword_t::none parse_keyword_t::none
}; // Any keyword represented by this token }; // Any keyword represented by this token
bool has_dash_prefix{false}; // Hackish: whether the source contains a dash prefix bool has_dash_prefix{false}; // Hackish: whether the source contains a dash prefix
bool is_help_argument{false}; // Hackish: whether the source looks like '-h' or '--help' bool is_help_argument{false}; // Hackish: whether the source looks like '-h' or '--help'
bool is_newline{false}; // Hackish: if TOK_END, whether the source is a newline. bool is_newline{false}; // Hackish: if TOK_END, whether the source is a newline.
bool may_be_variable_assignment{false}; // Hackish: whether this token is a string like FOO=bar bool may_be_variable_assignment{false}; // Hackish: whether this token is a string like FOO=bar
tokenizer_error_t tok_error{tokenizer_error_t::none}; // If this is a tokenizer error, that error. tokenizer_error_t tok_error{
tokenizer_error_t::none}; // If this is a tokenizer error, that error.
source_offset_t source_start{SOURCE_OFFSET_INVALID}; source_offset_t source_start{SOURCE_OFFSET_INVALID};
source_offset_t source_length{0}; source_offset_t source_length{0};
/// \return the source range. /// \return the source range.
/// Note the start may be invalid. /// Note the start may be invalid.
source_range_t range() const { source_range_t range() const { return source_range_t{source_start, source_length}; }
return source_range_t{source_start, source_length};
}
/// \return whether we are a string with the dash prefix set. /// \return whether we are a string with the dash prefix set.
bool is_dash_prefix_string() const { bool is_dash_prefix_string() const {

View File

@ -671,7 +671,6 @@ std::vector<int> parse_util_compute_indents(const wcstring &src) {
} }
} }
node_visitor(*this).accept_children_of(&node); node_visitor(*this).accept_children_of(&node);
indent -= dec; indent -= dec;
} }

View File

@ -220,6 +220,7 @@ struct eval_res_t {
class parser_t : public std::enable_shared_from_this<parser_t> { class parser_t : public std::enable_shared_from_this<parser_t> {
friend class parse_execution_context_t; friend class parse_execution_context_t;
private: private:
/// The current execution context. /// The current execution context.
std::unique_ptr<parse_execution_context_t> execution_context; std::unique_ptr<parse_execution_context_t> execution_context;

View File

@ -885,9 +885,7 @@ void reader_data_t::kill(editable_line_t *el, size_t begin_idx, size_t length, i
} }
// This is called from a signal handler! // This is called from a signal handler!
void reader_handle_sigint() { void reader_handle_sigint() { interrupted = SIGINT; }
interrupted = SIGINT;
}
/// Make sure buffers are large enough to hold the current string length. /// Make sure buffers are large enough to hold the current string length.
void reader_data_t::command_line_changed(const editable_line_t *el) { void reader_data_t::command_line_changed(const editable_line_t *el) {