Remove unused functions, members (and a variable)

If we ever need any of these... they're in this commit:

fish_wcswidth_visible()
status_cmd_opts_t::feature_name
completion_t::is_naturally_less_than()
parser_t::set_empty_var_and_fire()
parser_t::get_block_desc()
parser_keywords_skip_arguments()
parser_keywords_is_block()
job_t::has_internal_proc()
fish_wcswidth_visible()
This commit is contained in:
Aaron Gyes 2022-04-09 10:10:44 -07:00
parent 63bd4eda55
commit 0118eafee1
12 changed files with 2 additions and 103 deletions

View file

@ -100,7 +100,6 @@ namespace {
struct status_cmd_opts_t {
int level{1};
maybe_t<job_control_t> new_job_control_mode{};
const wchar_t *feature_name{};
status_cmd_t status_cmd{STATUS_UNDEF};
bool print_help{false};
};

View file

@ -241,10 +241,6 @@ __attribute__((always_inline)) static inline bool natural_compare_completions(
return wcsfilecmp(a.completion.c_str(), b.completion.c_str()) < 0;
}
bool completion_t::is_naturally_less_than(const completion_t &a, const completion_t &b) {
return natural_compare_completions(a, b);
}
void completion_t::prepend_token_prefix(const wcstring &prefix) {
if (this->flags & COMPLETE_REPLACES_TOKEN) {
this->completion.insert(0, prefix);
@ -882,7 +878,7 @@ static void complete_load(const wcstring &name) {
bool completer_t::complete_param_for_command(const wcstring &cmd_orig, const wcstring &popt,
const wcstring &str, bool use_switches,
bool *out_do_file) {
bool use_common = true, use_files = true, has_force = false;
bool use_files = true, has_force = false;
wcstring cmd, path;
parse_cmd_string(cmd_orig, &path, &cmd, ctx.vars);
@ -926,8 +922,7 @@ bool completer_t::complete_param_for_command(const wcstring &cmd_orig, const wcs
// the lock because callouts (like the condition) may add or remove completions. See issue 2.
for (const option_list_t &options : all_options) {
size_t short_opt_pos = short_option_pos(str, options);
bool last_option_requires_param = false;
use_common = true;
bool last_option_requires_param = false, use_common = true;
if (use_switches) {
if (str[0] == L'-') {
// Check if we are entering a combined option and argument (like --color=auto or

View file

@ -87,13 +87,6 @@ class completion_t {
completion_t(completion_t &&) noexcept;
completion_t &operator=(completion_t &&) noexcept;
// Compare two completions. No operating overlaoding to make this always explicit (there's
// potentially multiple ways to compare completions).
//
// "Naturally less than" means in a natural ordering, where digits are treated as numbers. For
// example, foo10 is naturally greater than foo2 (but alphabetically less than it).
static bool is_naturally_less_than(const completion_t &a, const completion_t &b);
/// \return the completion's match rank. Lower ranks are better completions.
uint32_t rank() const { return match.rank(); }

View file

@ -2874,8 +2874,6 @@ static void test_test_brackets() {
null_output_stream_t null{};
io_streams_t streams(null, null);
wcstring_list_t args;
const wchar_t *args1[] = {L"[", L"foo", nullptr};
do_test(builtin_test(parser, streams, args1) != 0);

View file

@ -114,10 +114,6 @@ int parser_t::set_var_and_fire(const wcstring &key, env_mode_flags_t mode, wcstr
return set_var_and_fire(key, mode, std::move(vals));
}
int parser_t::set_empty_var_and_fire(const wcstring &key, env_mode_flags_t mode) {
return set_var_and_fire(key, mode, wcstring_list_t{});
}
block_t *parser_t::push_block(block_t &&block) {
block.src_lineno = parser_t::get_lineno();
block.src_filename = parser_t::current_filename();
@ -140,39 +136,6 @@ void parser_t::pop_block(const block_t *expected) {
if (pop_env) vars().pop();
}
const wchar_t *parser_t::get_block_desc(block_type_t block) {
switch (block) {
case block_type_t::while_block:
return WHILE_BLOCK;
case block_type_t::for_block:
return FOR_BLOCK;
case block_type_t::if_block:
return IF_BLOCK;
case block_type_t::function_call:
return FUNCTION_CALL_BLOCK;
case block_type_t::function_call_no_shadow:
return FUNCTION_CALL_NO_SHADOW_BLOCK;
case block_type_t::switch_block:
return SWITCH_BLOCK;
case block_type_t::subst:
return SUBST_BLOCK;
case block_type_t::top:
return TOP_BLOCK;
case block_type_t::begin:
return BEGIN_BLOCK;
case block_type_t::source:
return SOURCE_BLOCK;
case block_type_t::event:
return EVENT_BLOCK;
case block_type_t::breakpoint:
return BREAKPOINT_BLOCK;
case block_type_t::variable_assignment:
return VARIABLE_ASSIGNMENT_BLOCK;
}
return _(UNKNOWN_BLOCK);
}
const block_t *parser_t::block_at_index(size_t idx) const {
return idx < block_list.size() ? &block_list[idx] : nullptr;
}

View file

@ -380,7 +380,6 @@ class parser_t : public std::enable_shared_from_this<parser_t> {
/// \return a value like ENV_OK.
int set_var_and_fire(const wcstring &key, env_mode_flags_t mode, wcstring val);
int set_var_and_fire(const wcstring &key, env_mode_flags_t mode, wcstring_list_t vals);
int set_empty_var_and_fire(const wcstring &key, env_mode_flags_t mode);
/// Pushes a new block. Returns a pointer to the block, stored in the parser. The pointer is
/// valid until the call to pop_block().
@ -389,9 +388,6 @@ class parser_t : public std::enable_shared_from_this<parser_t> {
/// Remove the outermost block, asserting it's the given one.
void pop_block(const block_t *expected);
/// Return a description of the given blocktype.
static const wchar_t *get_block_desc(block_type_t block);
/// Return the function name for the specified stack frame. Default is one (current frame).
maybe_t<wcstring> get_function_name(int level = 1);

View file

@ -40,10 +40,6 @@ static size_t list_max_length(const string_set_t &list) {
return result;
}
bool parser_keywords_skip_arguments(const wcstring &cmd) {
return cmd == skip_keywords[0] || cmd == skip_keywords[1];
}
bool parser_keywords_is_subcommand(const wcstring &cmd) {
const static string_set_t search_list = ([] {
string_set_t results;
@ -59,14 +55,6 @@ bool parser_keywords_is_subcommand(const wcstring &cmd) {
return cmd.length() <= max_len && search_list.find(cmd) != not_found;
}
bool parser_keywords_is_block(const wcstring &word) {
const static auto max_len = list_max_length(block_keywords);
const static auto not_found = block_keywords.end();
// Everything above is executed only at startup, this is the actual optimized search routine:
return word.length() <= max_len && block_keywords.find(word) != not_found;
}
bool parser_keywords_is_reserved(const wcstring &word) {
const static string_set_t search_list = ([] {
string_set_t results;

View file

@ -20,11 +20,4 @@ bool parser_keywords_is_subcommand(const wcstring &cmd);
/// \return 1 of the command parameter is a command, 0 otherwise
bool parser_keywords_is_reserved(const wcstring &word);
/// Test if the specified string is command that opens a new block.
bool parser_keywords_is_block(const wcstring &word);
/// Check if the specified command is one of the builtins that cannot have arguments, any followin
/// argument is interpreted as a new command.
bool parser_keywords_skip_arguments(const wcstring &cmd);
#endif

View file

@ -310,13 +310,6 @@ void job_t::mark_constructed() {
mut_flags().constructed = true;
}
bool job_t::has_internal_proc() const {
for (const auto &p : processes) {
if (p->is_internal()) return true;
}
return false;
}
bool job_t::has_external_proc() const {
for (const auto &p : processes) {
if (!p->is_internal()) return true;

View file

@ -462,7 +462,6 @@ class job_t : noncopyable_t {
/// \return whether we have internal or external procs, respectively.
/// Internal procs are builtins, blocks, and functions.
/// External procs include exec and external.
bool has_internal_proc() const;
bool has_external_proc() const;
/// \return whether this job, when run, will want a job ID.

View file

@ -315,15 +315,3 @@ int fish_wcwidth_visible(wchar_t widechar) {
if (widechar == L'\b') return -1;
return std::max(0, fish_wcwidth(widechar));
}
int fish_wcswidth_visible(const wcstring &str) {
int res = 0;
for (wchar_t ch : str) {
if (ch == L'\b') {
res += -1;
} else {
res += std::max(0, fish_wcwidth(ch));
}
}
return res;
}

View file

@ -297,10 +297,4 @@ class line_iterator_t {
/// Like fish_wcwidth, but returns 0 for characters with no real width instead of -1.
int fish_wcwidth_visible(wchar_t widechar);
/// The same, but for all chars. Note that this only makes sense if the string has an arbitrary long
/// prefix - backslashes can move the cursor *before* the string.
///
/// In typical usage, you probably want to wrap wcwidth_visible to accumulate the width, but never
/// go below 0.
int fish_wcswidth_visible(const wcstring &str);
#endif