mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-24 11:37:10 +08:00
Merge pull request #6447 from neheb/clang2
Several more small clang-tidy cleanups
This commit is contained in:
commit
033a832687
|
@ -27,7 +27,7 @@ int builtin_eval(parser_t &parser, io_streams_t &streams, wchar_t **argv) {
|
|||
const auto cached_exec_count = parser.libdata().exec_count;
|
||||
int status = STATUS_CMD_OK;
|
||||
if (argc > 1) {
|
||||
if (parser.eval(std::move(new_cmd), *streams.io_chain) != eval_result_t::ok) {
|
||||
if (parser.eval(new_cmd, *streams.io_chain) != eval_result_t::ok) {
|
||||
status = STATUS_CMD_ERROR;
|
||||
} else if (cached_exec_count == parser.libdata().exec_count) {
|
||||
// Issue #5692, in particular, to catch `eval ""`, `eval "begin; end;"`, etc.
|
||||
|
|
|
@ -65,7 +65,7 @@ const enum_map<status_cmd_t> status_enum_map[] = {
|
|||
#define status_enum_map_len (sizeof status_enum_map / sizeof *status_enum_map)
|
||||
|
||||
#define CHECK_FOR_UNEXPECTED_STATUS_ARGS(status_cmd) \
|
||||
if (args.size() != 0) { \
|
||||
if (!args.empty()) { \
|
||||
const wchar_t *subcmd_str = enum_to_str(status_cmd, status_enum_map); \
|
||||
if (!subcmd_str) subcmd_str = L"default"; \
|
||||
streams.err.append_format(BUILTIN_ERR_ARG_COUNT2, cmd, subcmd_str, 0, args.size()); \
|
||||
|
|
|
@ -615,7 +615,7 @@ class string_matcher_t {
|
|||
|
||||
public:
|
||||
string_matcher_t(options_t opts_, io_streams_t &streams_)
|
||||
: opts(std::move(opts_)), streams(streams_), total_matched(0) {}
|
||||
: opts(opts_), streams(streams_), total_matched(0) {}
|
||||
|
||||
virtual ~string_matcher_t() = default;
|
||||
virtual bool report_matches(const wcstring &arg) = 0;
|
||||
|
@ -888,7 +888,7 @@ class string_replacer_t {
|
|||
|
||||
public:
|
||||
string_replacer_t(const wchar_t *argv0_, options_t opts_, io_streams_t &streams_)
|
||||
: argv0(argv0_), opts(std::move(opts_)), total_replaced(0), streams(streams_) {}
|
||||
: argv0(argv0_), opts(opts_), total_replaced(0), streams(streams_) {}
|
||||
|
||||
virtual ~string_replacer_t() = default;
|
||||
int replace_count() const { return total_replaced; }
|
||||
|
@ -901,10 +901,10 @@ class literal_replacer_t : public string_replacer_t {
|
|||
size_t patlen;
|
||||
|
||||
public:
|
||||
literal_replacer_t(const wchar_t *argv0, const wcstring &pattern_, const wchar_t *replacement_,
|
||||
literal_replacer_t(const wchar_t *argv0, wcstring pattern_, const wchar_t *replacement_,
|
||||
const options_t &opts, io_streams_t &streams)
|
||||
: string_replacer_t(argv0, opts, streams),
|
||||
pattern(pattern_),
|
||||
pattern(std::move(pattern_)),
|
||||
replacement(replacement_),
|
||||
patlen(pattern.length()) {}
|
||||
|
||||
|
|
|
@ -217,7 +217,7 @@ struct range_t {
|
|||
/// Base class for expressions.
|
||||
class expression {
|
||||
protected:
|
||||
expression(token_t what, range_t where) : token(what), range(std::move(where)) {}
|
||||
expression(token_t what, range_t where) : token(what), range(where) {}
|
||||
|
||||
public:
|
||||
const token_t token;
|
||||
|
@ -266,7 +266,7 @@ class combining_expression : public expression {
|
|||
const std::vector<token_t> combiners;
|
||||
|
||||
combining_expression(token_t tok, range_t where, std::vector<unique_ptr<expression>> exprs,
|
||||
const std::vector<token_t> &combs)
|
||||
std::vector<token_t> combs)
|
||||
: expression(tok, where), subjects(std::move(exprs)), combiners(std::move(combs)) {
|
||||
// We should have one more subject than combiner.
|
||||
assert(subjects.size() == combiners.size() + 1);
|
||||
|
@ -311,7 +311,7 @@ unique_ptr<expression> test_parser::parse_unary_expression(unsigned int start, u
|
|||
token_t tok = token_for_string(arg(start))->tok;
|
||||
if (tok == test_bang) {
|
||||
unique_ptr<expression> subject(parse_unary_expression(start + 1, end));
|
||||
if (subject.get()) {
|
||||
if (subject) {
|
||||
return make_unique<unary_operator>(tok, range_t(start, subject->range.end),
|
||||
move(subject));
|
||||
}
|
||||
|
@ -496,7 +496,7 @@ unique_ptr<expression> test_parser::parse_4_arg_expression(unsigned int start, u
|
|||
token_t first_token = token_for_string(arg(start))->tok;
|
||||
if (first_token == test_bang) {
|
||||
unique_ptr<expression> subject(parse_3_arg_expression(start + 1, end));
|
||||
if (subject.get()) {
|
||||
if (subject) {
|
||||
result = make_unique<unary_operator>(first_token, range_t(start, subject->range.end),
|
||||
move(subject));
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ static owning_lock<struct winsize> s_termsize{k_invalid_termsize};
|
|||
static relaxed_atomic_bool_t s_termsize_valid{false};
|
||||
|
||||
static char *wcs2str_internal(const wchar_t *in, char *out);
|
||||
static void debug_shared(const wchar_t msg_level, const wcstring &msg);
|
||||
static void debug_shared(wchar_t msg_level, const wcstring &msg);
|
||||
|
||||
#if defined(OS_IS_CYGWIN) || defined(WSL)
|
||||
// MS Windows tty devices do not currently have either a read or write timestamp. Those
|
||||
|
@ -205,8 +205,7 @@ bool is_windows_subsystem_for_linux() {
|
|||
#ifdef HAVE_BACKTRACE_SYMBOLS
|
||||
// This function produces a stack backtrace with demangled function & method names. It is based on
|
||||
// https://gist.github.com/fmela/591333 but adapted to the style of the fish project.
|
||||
[[gnu::noinline]] static const wcstring_list_t demangled_backtrace(int max_frames,
|
||||
int skip_levels) {
|
||||
[[gnu::noinline]] static wcstring_list_t demangled_backtrace(int max_frames, int skip_levels) {
|
||||
void *callstack[128];
|
||||
const int n_max_frames = sizeof(callstack) / sizeof(callstack[0]);
|
||||
int n_frames = backtrace(callstack, n_max_frames);
|
||||
|
|
|
@ -104,7 +104,7 @@ typedef struct complete_entry_opt {
|
|||
// Completion flags.
|
||||
complete_flags_t flags;
|
||||
|
||||
const wcstring localized_desc() const { return C_(desc); }
|
||||
wcstring localized_desc() const { return C_(desc); }
|
||||
|
||||
size_t expected_dash_count() const {
|
||||
switch (this->type) {
|
||||
|
@ -209,7 +209,7 @@ completion_t::completion_t(wcstring comp, wcstring desc, string_fuzzy_match_t ma
|
|||
complete_flags_t flags_val)
|
||||
: completion(std::move(comp)),
|
||||
description(std::move(desc)),
|
||||
match(std::move(mat)),
|
||||
match(mat),
|
||||
flags(resolve_auto_space(completion, flags_val)) {}
|
||||
|
||||
completion_t::completion_t(const completion_t &) = default;
|
||||
|
@ -389,9 +389,9 @@ class completer_t {
|
|||
const std::vector<tok_t> &args);
|
||||
|
||||
public:
|
||||
completer_t(const environment_t &vars, const std::shared_ptr<parser_t> &parser, wcstring c,
|
||||
completer_t(const environment_t &vars, std::shared_ptr<parser_t> parser, wcstring c,
|
||||
completion_request_flags_t f)
|
||||
: vars(vars), parser(parser), cmd(std::move(c)), flags(f) {}
|
||||
: vars(vars), parser(std::move(parser)), cmd(std::move(c)), flags(f) {}
|
||||
|
||||
void perform();
|
||||
|
||||
|
@ -1649,16 +1649,16 @@ void complete(const wcstring &cmd_with_subcmds, std::vector<completion_t> *out_c
|
|||
|
||||
/// Print the short switch \c opt, and the argument \c arg to the specified
|
||||
/// wcstring, but only if \c argument isn't an empty string.
|
||||
static void append_switch(wcstring &out, wchar_t opt, const wcstring arg) {
|
||||
static void append_switch(wcstring &out, wchar_t opt, const wcstring &arg) {
|
||||
if (arg.empty()) return;
|
||||
append_format(out, L" -%lc %ls", opt, escape_string(arg, ESCAPE_ALL).c_str());
|
||||
}
|
||||
static void append_switch(wcstring &out, const wcstring opt, const wcstring arg) {
|
||||
static void append_switch(wcstring &out, const wcstring &opt, const wcstring &arg) {
|
||||
if (arg.empty()) return;
|
||||
append_format(out, L" --%ls %ls", opt.c_str(), escape_string(arg, ESCAPE_ALL).c_str());
|
||||
}
|
||||
static void append_switch(wcstring &out, wchar_t opt) { append_format(out, L" -%lc", opt); }
|
||||
static void append_switch(wcstring &out, const wcstring opt) {
|
||||
static void append_switch(wcstring &out, const wcstring &opt) {
|
||||
append_format(out, L" --%ls", opt.c_str());
|
||||
}
|
||||
|
||||
|
|
10
src/env.cpp
10
src/env.cpp
|
@ -848,7 +848,7 @@ class env_stack_impl_t final : public env_scoped_impl_t {
|
|||
return make_unique<env_stack_impl_t>(std::move(local), s_global_node);
|
||||
}
|
||||
|
||||
virtual ~env_stack_impl_t() = default;
|
||||
~env_stack_impl_t() override = default;
|
||||
|
||||
private:
|
||||
/// The scopes of caller functions, which are currently shadowed.
|
||||
|
@ -878,7 +878,7 @@ class env_stack_impl_t final : public env_scoped_impl_t {
|
|||
|
||||
/// Remove a variable from the chain \p node.
|
||||
/// \return true if the variable was found and removed.
|
||||
bool remove_from_chain(env_node_ref_t node, const wcstring &key) const {
|
||||
bool remove_from_chain(const env_node_ref_t &node, const wcstring &key) const {
|
||||
for (auto cursor = node; cursor; cursor = cursor->next) {
|
||||
auto iter = cursor->env.find(key);
|
||||
if (iter != cursor->env.end()) {
|
||||
|
@ -901,7 +901,7 @@ class env_stack_impl_t final : public env_scoped_impl_t {
|
|||
void set_universal(const wcstring &key, wcstring_list_t val, const query_t &query);
|
||||
|
||||
/// Set a variable in a given node \p node.
|
||||
void set_in_node(env_node_ref_t node, const wcstring &key, wcstring_list_t &&val,
|
||||
void set_in_node(const env_node_ref_t &node, const wcstring &key, wcstring_list_t &&val,
|
||||
const var_flags_t &flags);
|
||||
|
||||
// Implement the default behavior of 'set' by finding the node for an unspecified scope.
|
||||
|
@ -970,8 +970,8 @@ static wcstring_list_t colon_split(const wcstring_list_t &val) {
|
|||
return split_val;
|
||||
}
|
||||
|
||||
void env_stack_impl_t::set_in_node(env_node_ref_t node, const wcstring &key, wcstring_list_t &&val,
|
||||
const var_flags_t &flags) {
|
||||
void env_stack_impl_t::set_in_node(const env_node_ref_t &node, const wcstring &key,
|
||||
wcstring_list_t &&val, const var_flags_t &flags) {
|
||||
env_var_t &var = node->env[key];
|
||||
|
||||
// Use an explicit exports, or inherit from the existing variable.
|
||||
|
|
|
@ -277,9 +277,9 @@ void env_universal_t::set_internal(const wcstring &key, const env_var_t &var) {
|
|||
}
|
||||
}
|
||||
|
||||
void env_universal_t::set(const wcstring &key, env_var_t var) {
|
||||
void env_universal_t::set(const wcstring &key, const env_var_t &var) {
|
||||
scoped_lock locker(lock);
|
||||
this->set_internal(key, std::move(var));
|
||||
this->set_internal(key, var);
|
||||
}
|
||||
|
||||
bool env_universal_t::remove_internal(const wcstring &key) {
|
||||
|
|
|
@ -103,7 +103,7 @@ class env_universal_t {
|
|||
maybe_t<env_var_t::env_var_flags_t> get_flags(const wcstring &name) const;
|
||||
|
||||
// Sets a variable.
|
||||
void set(const wcstring &key, env_var_t var);
|
||||
void set(const wcstring &key, const env_var_t &var);
|
||||
|
||||
// Removes a variable. Returns true if it was found, false if not.
|
||||
bool remove(const wcstring &key);
|
||||
|
|
10
src/exec.cpp
10
src/exec.cpp
|
@ -241,7 +241,7 @@ static void on_process_created(const std::shared_ptr<job_t> &j, pid_t child_pid)
|
|||
/// (stdout), and there is a dup2 3->1, then we need to write to fd 3. Then exit the internal
|
||||
/// process.
|
||||
static bool run_internal_process(process_t *p, std::string outdata, std::string errdata,
|
||||
io_chain_t ios) {
|
||||
const io_chain_t &ios) {
|
||||
p->check_generations_before_launch();
|
||||
|
||||
// We want both the dup2s and the io_chain_ts to be kept alive by the background thread, because
|
||||
|
@ -748,8 +748,8 @@ static proc_performer_t get_performer_for_process(process_t *p, const job_t *job
|
|||
/// \p conflicts contains the list of fds which pipes should avoid.
|
||||
/// \p allow_buffering if true, permit buffering the output.
|
||||
/// \return true on success, false on error.
|
||||
static bool exec_block_or_func_process(parser_t &parser, std::shared_ptr<job_t> j, process_t *p,
|
||||
const fd_set_t &conflicts, io_chain_t io_chain,
|
||||
static bool exec_block_or_func_process(parser_t &parser, const std::shared_ptr<job_t> &j,
|
||||
process_t *p, const fd_set_t &conflicts, io_chain_t io_chain,
|
||||
bool allow_buffering) {
|
||||
// Create an output buffer if we're piping to another process.
|
||||
shared_ptr<io_bufferfill_t> block_output_bufferfill{};
|
||||
|
@ -807,7 +807,7 @@ static bool exec_block_or_func_process(parser_t &parser, std::shared_ptr<job_t>
|
|||
/// \p deferred_pipes represents the pipes from our deferred process; if set ensure they get closed
|
||||
/// in any child. If \p is_deferred_run is true, then this is a deferred run; this affects how
|
||||
/// certain buffering works. \returns true on success, false on exec error.
|
||||
static bool exec_process_in_job(parser_t &parser, process_t *p, std::shared_ptr<job_t> j,
|
||||
static bool exec_process_in_job(parser_t &parser, process_t *p, const std::shared_ptr<job_t> &j,
|
||||
const io_chain_t &block_io, autoclose_pipes_t pipes,
|
||||
const fd_set_t &conflicts, const autoclose_pipes_t &deferred_pipes,
|
||||
size_t stdout_read_limit, bool is_deferred_run = false) {
|
||||
|
@ -995,7 +995,7 @@ static bool should_claim_process_group_for_job(const shared_ptr<job_t> &j) {
|
|||
DIE("unreachable");
|
||||
}
|
||||
|
||||
bool exec_job(parser_t &parser, shared_ptr<job_t> j, const job_lineage_t &lineage) {
|
||||
bool exec_job(parser_t &parser, const shared_ptr<job_t> &j, const job_lineage_t &lineage) {
|
||||
assert(j && "null job_t passed to exec_job!");
|
||||
|
||||
// Set to true if something goes wrong while executing the job, in which case the cleanup
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
class job_t;
|
||||
struct job_lineage_t;
|
||||
class parser_t;
|
||||
bool exec_job(parser_t &parser, std::shared_ptr<job_t> j, const job_lineage_t &lineage);
|
||||
bool exec_job(parser_t &parser, const std::shared_ptr<job_t> &j, const job_lineage_t &lineage);
|
||||
|
||||
/// Evaluate the expression cmd in a subshell, add the outputs into the list l. On return, the
|
||||
/// status flag as returned bu \c proc_gfet_last_status will not be changed.
|
||||
|
|
|
@ -873,9 +873,9 @@ class expander_t {
|
|||
expand_result_t stage_home_and_self(wcstring input, std::vector<completion_t> *out);
|
||||
expand_result_t stage_wildcards(wcstring path_to_expand, std::vector<completion_t> *out);
|
||||
|
||||
expander_t(const environment_t &vars, const std::shared_ptr<parser_t> &parser,
|
||||
expand_flags_t flags, parse_error_list_t *errors)
|
||||
: vars(vars), parser(parser), flags(flags), errors(errors) {}
|
||||
expander_t(const environment_t &vars, std::shared_ptr<parser_t> parser, expand_flags_t flags,
|
||||
parse_error_list_t *errors)
|
||||
: vars(vars), parser(std::move(parser)), flags(flags), errors(errors) {}
|
||||
|
||||
public:
|
||||
static expand_result_t expand_string(wcstring input, std::vector<completion_t> *out_completions,
|
||||
|
|
|
@ -166,7 +166,8 @@ void function_add(wcstring name, wcstring description, function_properties_ref_t
|
|||
|
||||
// Create and store a new function.
|
||||
auto ins = funcset->funcs.emplace(
|
||||
std::move(name), function_info_t(props, std::move(description), filename, is_autoload));
|
||||
std::move(name),
|
||||
function_info_t(std::move(props), std::move(description), filename, is_autoload));
|
||||
assert(ins.second && "Function should not already be present in the table");
|
||||
(void)ins;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "common.h"
|
||||
|
@ -427,9 +428,9 @@ bool inputter_t::mapping_is_match(const input_mapping_t &m) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void inputter_t::queue_ch(char_event_t ch) { event_queue_.push_back(ch); }
|
||||
void inputter_t::queue_ch(const char_event_t &ch) { event_queue_.push_back(std::move(ch)); }
|
||||
|
||||
void inputter_t::push_front(char_event_t ch) { event_queue_.push_front(ch); }
|
||||
void inputter_t::push_front(const char_event_t &ch) { event_queue_.push_front(std::move(ch)); }
|
||||
|
||||
/// \return the first mapping that matches, walking first over the user's mapping list, then the
|
||||
/// preset list. \return null if nothing matches.
|
||||
|
|
|
@ -57,10 +57,10 @@ class inputter_t {
|
|||
|
||||
/// Enqueue a char event to the queue of unread characters that input_readch will return before
|
||||
/// actually reading from fd 0.
|
||||
void queue_ch(char_event_t ch);
|
||||
void queue_ch(const char_event_t &ch);
|
||||
|
||||
/// Enqueue a char event to the front of the queue; this will be the next event returned.
|
||||
void push_front(char_event_t ch);
|
||||
void push_front(const char_event_t &ch);
|
||||
|
||||
/// Sets the return status of the most recently executed input function.
|
||||
void function_set_status(bool status) { function_status_ = status; }
|
||||
|
|
|
@ -225,6 +225,6 @@ char_event_t input_event_queue_t::readch_timed(bool dequeue_timeouts) {
|
|||
return result;
|
||||
}
|
||||
|
||||
void input_event_queue_t::push_back(char_event_t ch) { queue_.push_back(ch); }
|
||||
void input_event_queue_t::push_back(const char_event_t& ch) { queue_.push_back(ch); }
|
||||
|
||||
void input_event_queue_t::push_front(char_event_t ch) { queue_.push_front(ch); }
|
||||
void input_event_queue_t::push_front(const char_event_t& ch) { queue_.push_front(ch); }
|
||||
|
|
|
@ -186,11 +186,11 @@ class input_event_queue_t {
|
|||
|
||||
/// Enqueue a character or a readline function to the queue of unread characters that
|
||||
/// readch will return before actually reading from fd 0.
|
||||
void push_back(char_event_t ch);
|
||||
void push_back(const char_event_t& ch);
|
||||
|
||||
/// Add a character or a readline function to the front of the queue of unread characters. This
|
||||
/// will be the next character returned by readch.
|
||||
void push_front(char_event_t ch);
|
||||
void push_front(const char_event_t& ch);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -278,7 +278,7 @@ void io_chain_t::print() const {
|
|||
std::fwprintf(stderr, L"Chain %p (%ld items):\n", this, (long)this->size());
|
||||
for (size_t i = 0; i < this->size(); i++) {
|
||||
const auto &io = this->at(i);
|
||||
if (io.get() == nullptr) {
|
||||
if (io == nullptr) {
|
||||
std::fwprintf(stderr, L"\t(null)\n");
|
||||
} else {
|
||||
std::fwprintf(stderr, L"\t%lu: fd:%d, ", (unsigned long)i, io->fd);
|
||||
|
|
|
@ -1049,7 +1049,7 @@ eval_result_t parse_execution_context_t::apply_variable_assignments(
|
|||
vals.emplace_back(std::move(completion.completion));
|
||||
}
|
||||
if (proc) proc->variable_assignments.push_back({variable_name, vals});
|
||||
parser->vars().set(std::move(variable_name), ENV_LOCAL | ENV_EXPORT, std::move(vals));
|
||||
parser->vars().set(variable_name, ENV_LOCAL | ENV_EXPORT, std::move(vals));
|
||||
}
|
||||
return eval_result_t::ok;
|
||||
}
|
||||
|
@ -1410,13 +1410,13 @@ eval_result_t parse_execution_context_t::run_job_list(tnode_t<Type> job_list,
|
|||
result = this->run_job_conjunction(job_conj, associated_block);
|
||||
}
|
||||
if (timer_started) {
|
||||
auto t1 = std::move(active_timers.back());
|
||||
auto t1 = active_timers.back();
|
||||
active_timers.pop_back();
|
||||
auto t2 = timer_snapshot_t::take();
|
||||
|
||||
// Well, this is awkward. By defining `time` as a decorator and not a built-in, there's
|
||||
// no associated stream for its output!
|
||||
auto output = timer_snapshot_t::print_delta(std::move(t1), std::move(t2), true);
|
||||
auto output = timer_snapshot_t::print_delta(t1, t2, true);
|
||||
std::fwprintf(stderr, L"%S\n", output.c_str());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ class parse_execution_context_t {
|
|||
// Determines the list of redirections for a node. Returns none() on failure, for example, an
|
||||
// invalid fd.
|
||||
bool determine_redirections(tnode_t<grammar::arguments_or_redirections_list> node,
|
||||
redirection_spec_list_t *out_redirs);
|
||||
redirection_spec_list_t *out_redirections);
|
||||
|
||||
eval_result_t run_1_job(tnode_t<grammar::job> job, const block_t *associated_block);
|
||||
eval_result_t run_job_conjunction(tnode_t<grammar::job_conjunction> job_expr,
|
||||
|
|
|
@ -110,7 +110,7 @@ void parser_t::skip_all_blocks() {
|
|||
|
||||
// Given a new-allocated block, push it onto our block list, acquiring ownership.
|
||||
block_t *parser_t::push_block(block_t &&block) {
|
||||
block_t new_current{std::move(block)};
|
||||
block_t new_current{block};
|
||||
const enum block_type_t type = new_current.type();
|
||||
new_current.src_lineno = parser_t::get_lineno();
|
||||
|
||||
|
@ -147,7 +147,7 @@ void parser_t::pop_block(const block_t *expected) {
|
|||
assert(!block_list.empty() && "empty block list");
|
||||
|
||||
// Acquire ownership out of the block list.
|
||||
block_t old = std::move(block_list.front());
|
||||
block_t old = block_list.front();
|
||||
block_list.pop_front();
|
||||
|
||||
if (old.wants_pop_env) vars().pop();
|
||||
|
@ -626,7 +626,7 @@ eval_result_t parser_t::eval(const wcstring &cmd, const io_chain_t &io,
|
|||
}
|
||||
}
|
||||
|
||||
eval_result_t parser_t::eval(parsed_source_ref_t ps, const io_chain_t &io,
|
||||
eval_result_t parser_t::eval(const parsed_source_ref_t &ps, const io_chain_t &io,
|
||||
enum block_type_t block_type) {
|
||||
assert(block_type == block_type_t::top || block_type == block_type_t::subst);
|
||||
if (!ps->tree.empty()) {
|
||||
|
@ -640,8 +640,8 @@ eval_result_t parser_t::eval(parsed_source_ref_t ps, const io_chain_t &io,
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
eval_result_t parser_t::eval_node(parsed_source_ref_t ps, tnode_t<T> node, job_lineage_t lineage,
|
||||
block_type_t block_type) {
|
||||
eval_result_t parser_t::eval_node(const parsed_source_ref_t &ps, tnode_t<T> node,
|
||||
job_lineage_t lineage, block_type_t block_type) {
|
||||
static_assert(
|
||||
std::is_same<T, grammar::statement>::value || std::is_same<T, grammar::job_list>::value,
|
||||
"Unexpected node type");
|
||||
|
@ -683,9 +683,9 @@ eval_result_t parser_t::eval_node(parsed_source_ref_t ps, tnode_t<T> node, job_l
|
|||
}
|
||||
|
||||
// Explicit instantiations. TODO: use overloads instead?
|
||||
template eval_result_t parser_t::eval_node(parsed_source_ref_t, tnode_t<grammar::statement>,
|
||||
template eval_result_t parser_t::eval_node(const parsed_source_ref_t &, tnode_t<grammar::statement>,
|
||||
job_lineage_t, block_type_t);
|
||||
template eval_result_t parser_t::eval_node(parsed_source_ref_t, tnode_t<grammar::job_list>,
|
||||
template eval_result_t parser_t::eval_node(const parsed_source_ref_t &, tnode_t<grammar::job_list>,
|
||||
job_lineage_t, block_type_t);
|
||||
|
||||
void parser_t::get_backtrace(const wcstring &src, const parse_error_list_t &errors,
|
||||
|
|
|
@ -268,13 +268,13 @@ class parser_t : public std::enable_shared_from_this<parser_t> {
|
|||
|
||||
/// Evaluate the parsed source ps.
|
||||
/// Because the source has been parsed, a syntax error is impossible.
|
||||
eval_result_t eval(parsed_source_ref_t ps, const io_chain_t &io,
|
||||
eval_result_t eval(const parsed_source_ref_t &ps, const io_chain_t &io,
|
||||
block_type_t block_type = block_type_t::top);
|
||||
|
||||
/// Evaluates a node.
|
||||
/// The node type must be grammar::statement or grammar::job_list.
|
||||
template <typename T>
|
||||
eval_result_t eval_node(parsed_source_ref_t ps, tnode_t<T> node, job_lineage_t lineage,
|
||||
eval_result_t eval_node(const parsed_source_ref_t &ps, tnode_t<T> node, job_lineage_t lineage,
|
||||
block_type_t block_type = block_type_t::top);
|
||||
|
||||
/// Evaluate line as a list of parameters, i.e. tokenize it and perform parameter expansion and
|
||||
|
|
|
@ -269,7 +269,7 @@ void process_t::check_generations_before_launch() {
|
|||
gens_ = topic_monitor_t::principal().current_generations();
|
||||
}
|
||||
|
||||
job_t::job_t(job_id_t job_id, const properties_t &props, job_lineage_t lineage)
|
||||
job_t::job_t(job_id_t job_id, const properties_t &props, const job_lineage_t &lineage)
|
||||
: properties(props),
|
||||
job_id(job_id),
|
||||
root_constructed(lineage.root_constructed ? lineage.root_constructed : this->constructed) {}
|
||||
|
|
|
@ -320,7 +320,7 @@ class job_t {
|
|||
void operator=(const job_t &) = delete;
|
||||
|
||||
public:
|
||||
job_t(job_id_t job_id, const properties_t &props, job_lineage_t lineage);
|
||||
job_t(job_id_t job_id, const properties_t &props, const job_lineage_t &lineage);
|
||||
~job_t();
|
||||
|
||||
/// Returns the command as a wchar_t *. */
|
||||
|
|
|
@ -1299,7 +1299,7 @@ static std::function<autosuggestion_result_t(void)> get_autosuggestion_performer
|
|||
|
||||
history_search_t searcher(*history, search_string, history_search_type_t::prefix);
|
||||
while (!reader_test_should_cancel() && searcher.go_backwards()) {
|
||||
history_item_t item = searcher.current_item();
|
||||
const history_item_t &item = searcher.current_item();
|
||||
|
||||
// Skip items with newlines because they make terrible autosuggestions.
|
||||
if (item.str().find(L'\n') != wcstring::npos) continue;
|
||||
|
@ -2754,7 +2754,7 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat
|
|||
if (abbreviation_expanded) {
|
||||
// It's our reponsibility to rehighlight and repaint. But everything we do
|
||||
// below triggers a repaint.
|
||||
command_test_result = test_func(parser(), el->text.c_str());
|
||||
command_test_result = test_func(parser(), el->text);
|
||||
|
||||
// If the command is OK, then we're going to execute it. We still want to do
|
||||
// syntax highlighting, but a synchronous variant that performs no I/O, so
|
||||
|
|
|
@ -278,7 +278,7 @@ maybe_t<prompt_layout_t> layout_cache_t::find_prompt_layout(const wcstring &inpu
|
|||
|
||||
void layout_cache_t::add_prompt_layout(wcstring input, prompt_layout_t layout) {
|
||||
assert(!find_prompt_layout(input) && "Should not have a prompt layout for this input");
|
||||
prompt_cache_.emplace_front(std::move(input), std::move(layout));
|
||||
prompt_cache_.emplace_front(std::move(input), layout);
|
||||
if (prompt_cache_.size() > prompt_cache_max_size) {
|
||||
prompt_cache_.pop_back();
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ enum {
|
|||
curly_braces = 1 << 2,
|
||||
char_escape = 1 << 3,
|
||||
};
|
||||
}
|
||||
} // namespace tok_modes
|
||||
using tok_mode_t = uint32_t;
|
||||
|
||||
/// Read the next token as a string.
|
||||
|
|
|
@ -130,7 +130,7 @@ bool wreaddir_for_dirs(DIR *dir, wcstring *out_name) {
|
|||
return result != nullptr;
|
||||
}
|
||||
|
||||
const wcstring wgetcwd() {
|
||||
wcstring wgetcwd() {
|
||||
char cwd[PATH_MAX];
|
||||
char *res = getcwd(cwd, sizeof(cwd));
|
||||
if (res) {
|
||||
|
|
|
@ -71,7 +71,7 @@ void safe_perror(const char *message);
|
|||
const char *safe_strerror(int err);
|
||||
|
||||
/// Wide character version of getcwd().
|
||||
const wcstring wgetcwd();
|
||||
wcstring wgetcwd();
|
||||
|
||||
/// Wide character version of realpath function.
|
||||
/// \returns the canonicalized path, or none if the path is invalid.
|
||||
|
|
Loading…
Reference in New Issue
Block a user