diff --git a/complete.cpp b/complete.cpp index 385176bed..07bc7cc01 100644 --- a/complete.cpp +++ b/complete.cpp @@ -324,18 +324,6 @@ completion_t &completion_t::operator=(const completion_t &him) return *this; } - -wcstring_list_t completions_to_wcstring_list(const std::vector &list) -{ - wcstring_list_t strings; - strings.reserve(list.size()); - for (std::vector::const_iterator iter = list.begin(); iter != list.end(); ++iter) - { - strings.push_back(iter->completion); - } - return strings; -} - bool completion_t::is_alphabetically_less_than(const completion_t &a, const completion_t &b) { return a.completion < b.completion; @@ -412,8 +400,6 @@ public: void complete_param_expand(const wcstring &str, bool do_file); - void debug_print_completions(); - void complete_cmd(const wcstring &str, bool use_function, bool use_builtin, @@ -1659,14 +1645,6 @@ void completer_t::complete_param_expand(const wcstring &sstr, bool do_file) } } -void completer_t::debug_print_completions() -{ - for (size_t i=0; i < completions.size(); i++) - { - printf("- Completion: %ls\n", completions.at(i).completion.c_str()); - } -} - /** Complete the specified string as an environment variable */ diff --git a/complete.h b/complete.h index b5ad98c5e..cf9638b00 100644 --- a/complete.h +++ b/complete.h @@ -136,9 +136,6 @@ enum }; typedef uint32_t completion_request_flags_t; -/** Given a list of completions, returns a list of their completion fields */ -wcstring_list_t completions_to_wcstring_list(const std::vector &completions); - /** Add a completion. diff --git a/env_universal_common.cpp b/env_universal_common.cpp index c39cfdc1e..07d325238 100644 --- a/env_universal_common.cpp +++ b/env_universal_common.cpp @@ -97,14 +97,6 @@ void env_universal_common_init(void (*cb)(fish_message_type_t type, const wchar_ callback = cb; } -/** - Remove variable with specified name -*/ -bool env_universal_common_remove(const wcstring &name) -{ - return default_universal_vars().remove(name); -} - /** Test if the message msg contains the command cmd */ @@ -120,19 +112,6 @@ static bool match(const wchar_t *msg, const wchar_t *cmd) return true; } -void env_universal_common_set(const wchar_t *key, const wchar_t *val, bool exportv) -{ - CHECK(key,); - CHECK(val,); - - default_universal_vars().set(key, val, exportv); - - if (callback) - { - callback(exportv?SET_EXPORT:SET, key, val); - } -} - static void report_error(int err_code, const wchar_t *err_format, ...) { va_list va; @@ -252,23 +231,6 @@ static bool append_file_entry(fish_message_type_t type, const wcstring &key_in, return success; } -wcstring_list_t env_universal_get_names(bool show_exported, bool show_unexported) -{ - return default_universal_vars().get_names(show_exported, show_unexported); - -} - - -env_var_t env_universal_get(const wcstring &name) -{ - return default_universal_vars().get(name); -} - -bool env_universal_common_get_export(const wcstring &name) -{ - return default_universal_vars().get_export(name); -} - env_universal_t::env_universal_t(const wcstring &path) : explicit_vars_path(path), tried_renaming(false), last_read_file(kInvalidFileID) { VOMIT_ON_FAILURE(pthread_mutex_init(&lock, NULL)); diff --git a/fish_indent.cpp b/fish_indent.cpp index 21ffd47f7..ddd9189b2 100644 --- a/fish_indent.cpp +++ b/fish_indent.cpp @@ -336,6 +336,7 @@ int main(int argc, char **argv) { print_help("fish_indent", 1); exit(0); + assert(0 && "Unreachable code reached"); break; } @@ -346,6 +347,8 @@ int main(int argc, char **argv) program_name, get_fish_version()); exit(0); + assert(0 && "Unreachable code reached"); + break; } case 'i': diff --git a/input.cpp b/input.cpp index c909f5ab1..088793812 100644 --- a/input.cpp +++ b/input.cpp @@ -330,14 +330,6 @@ void input_function_set_status(bool status) input_function_status = status; } -/** - Returns the nth argument for a given input function -*/ -wchar_t input_function_get_arg(int index) -{ - return input_function_args[index]; -} - /* Helper function to compare the lengths of sequences */ static bool length_is_greater_than(const input_mapping_t &m1, const input_mapping_t &m2) { diff --git a/pager.cpp b/pager.cpp index 04be06195..c4a6fc058 100644 --- a/pager.cpp +++ b/pager.cpp @@ -30,7 +30,8 @@ static size_t divide_round_up(size_t numer, size_t denom) return 0; assert(denom > 0); - return numer / denom + (numer % denom ? 1 : 0); + bool has_rem = (numer % denom) > 0; + return numer / denom + (has_rem ? 1 : 0); } /** @@ -393,7 +394,7 @@ void pager_t::refilter_completions() void pager_t::set_completions(const completion_list_t &raw_completions) { // Get completion infos out of it - unfiltered_completion_infos = process_completions_into_infos(raw_completions, prefix.c_str()); + unfiltered_completion_infos = process_completions_into_infos(raw_completions, prefix); // Maybe join them if (prefix == L"-") @@ -626,7 +627,7 @@ bool pager_t::completion_try_print(size_t cols, const wcstring &prefix, const co if (! progress_text.empty()) { line_t &line = rendering->screen_data.add_line(); - print_max(progress_text.c_str(), highlight_spec_pager_progress | highlight_make_background(highlight_spec_pager_progress), term_width, true /* has_more */, &line); + print_max(progress_text, highlight_spec_pager_progress | highlight_make_background(highlight_spec_pager_progress), term_width, true /* has_more */, &line); } if (search_field_shown) diff --git a/parse_tree.cpp b/parse_tree.cpp index bdf3aaceb..42b1bcd0a 100644 --- a/parse_tree.cpp +++ b/parse_tree.cpp @@ -1428,19 +1428,6 @@ const parse_node_t *parse_node_tree_t::get_parent(const parse_node_t &node, pars return result; } -const parse_node_t *parse_node_tree_t::get_first_ancestor_of_type(const parse_node_t &node, parse_token_type_t desired_type) const -{ - const parse_node_t *ancestor = &node; - while ((ancestor = this->get_parent(*ancestor))) - { - if (ancestor->type == desired_type) - { - break; - } - } - return ancestor; -} - static void find_nodes_recursive(const parse_node_tree_t &tree, const parse_node_t &parent, parse_token_type_t type, parse_node_tree_t::parse_node_list_t *result, size_t max_count) { if (result->size() < max_count) diff --git a/parse_tree.h b/parse_tree.h index 58484ce4d..8a86e70b2 100644 --- a/parse_tree.h +++ b/parse_tree.h @@ -148,9 +148,6 @@ class parse_node_tree_t : public std::vector /* Get the node corresponding to the parent of the given node, or NULL if there is no such child. If expected_type is provided, only returns the parent if it is of that type. Note the asymmetry: get_child asserts since the children are known, but get_parent does not, since the parent may not be known. */ const parse_node_t *get_parent(const parse_node_t &node, parse_token_type_t expected_type = token_type_invalid) const; - /* Returns the first ancestor of the given type, or NULL. */ - const parse_node_t *get_first_ancestor_of_type(const parse_node_t &node, parse_token_type_t desired_type) const; - /* Find all the nodes of a given type underneath a given node, up to max_count of them */ typedef std::vector parse_node_list_t; parse_node_list_t find_nodes(const parse_node_t &parent, parse_token_type_t type, size_t max_count = (size_t)(-1)) const; diff --git a/parse_util.cpp b/parse_util.cpp index e89883c90..0b2d79fac 100644 --- a/parse_util.cpp +++ b/parse_util.cpp @@ -53,7 +53,7 @@ int parse_util_lineno(const wchar_t *str, size_t offset) return 0; int res = 1; - for (size_t i=0; str[i] && ihas_next; } -int tokenizer_t::line_number_of_character_at_offset(size_t offset) -{ - // we want to return (one plus) the number of newlines at offsets less than the given offset - // cached_lineno_count is the number of newlines at indexes less than cached_lineno_offset - const wchar_t *str = orig_buff; - if (! str) - return 0; - - // easy hack to handle 0 - if (offset == 0) - return 1; - - size_t i; - if (offset > cached_lineno_offset) - { - for (i = cached_lineno_offset; str[i] && ic_str(); + return val->c_str(); //looks dangerous but is safe, since the string is stored in the map } const wchar_t *wgetenv(const wcstring &name)