Delete wcstring_list_t

We don't want it in Rust. Remove it to smoothen the transition.
This commit is contained in:
Johannes Altmanninger 2023-04-19 00:19:10 +02:00
parent db5c9badad
commit 6ede7f8009
71 changed files with 379 additions and 384 deletions

View file

@ -39,7 +39,7 @@ end
function cleanup_syname
set -l symname $argv[1]
set symname (string replace --all 'std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> >' 'wcstring' $symname)
set symname (string replace --all 'std::__1::vector<wcstring, std::__1::allocator<wcstring > >' 'wcstring_list_t' $symname)
set symname (string replace --all 'std::__1::vector<wcstring, std::__1::allocator<wcstring > >' 'std::vector<wcstring>' $symname)
echo $symname
end

View file

@ -92,10 +92,7 @@
{ symbol: ["assert", "private", '"../common.h"', "public"] },
{ symbol: ["wcstring", "private", '"common.h"', "public"] },
{ symbol: ["wcstring", "private", '"../common.h"', "public"] },
{ symbol: ["wcstring_list_t", "private", '"common.h"', "public"] },
{ symbol: ["wcstring_list_t", "private", '"../common.h"', "public"] },
{ symbol: ["wcstring", "private", '"flog.h"', "public"] },
{ symbol: ["wcstring_list_t", "private", '"flog.h"', "public"] },
{ symbol: ["size_t", "private", "<cstddef>", "public"] },
{ symbol: ["mutex", "private", "<mutex>", "public"] },
{ symbol: ["sig_atomic_t", "private", "<csignal>", "public"] },

View file

@ -1021,7 +1021,7 @@ pub const HAS_WORKING_TTY_TIMESTAMPS: bool = true;
/// empty string.
pub static EMPTY_STRING: WString = WString::new();
/// A global, empty wcstring_list_t. This is useful for functions which wish to return a reference
/// A global, empty string list. This is useful for functions which wish to return a reference
/// to an empty string.
pub static EMPTY_STRING_LIST: Vec<WString> = vec![];

View file

@ -37,7 +37,7 @@ class autoload_file_cache_t {
using timestamp_t = std::chrono::time_point<std::chrono::steady_clock>;
/// The directories from which to load.
const wcstring_list_t dirs_{};
const std::vector<wcstring> dirs_{};
/// Our LRU cache of checks that were misses.
/// The key is the command, the value is the time of the check.
@ -64,13 +64,13 @@ class autoload_file_cache_t {
public:
/// Initialize with a set of directories.
explicit autoload_file_cache_t(wcstring_list_t dirs) : dirs_(std::move(dirs)) {}
explicit autoload_file_cache_t(std::vector<wcstring> dirs) : dirs_(std::move(dirs)) {}
/// Initialize with empty directories.
autoload_file_cache_t() = default;
/// \return the directories.
const wcstring_list_t &dirs() const { return dirs_; }
const std::vector<wcstring> &dirs() const { return dirs_; }
/// Check if a command \p cmd can be loaded.
/// If \p allow_stale is true, allow stale entries; otherwise discard them.
@ -170,8 +170,8 @@ bool autoload_t::can_autoload(const wcstring &cmd) {
bool autoload_t::has_attempted_autoload(const wcstring &cmd) { return cache_->is_cached(cmd); }
wcstring_list_t autoload_t::get_autoloaded_commands() const {
wcstring_list_t result;
std::vector<wcstring> autoload_t::get_autoloaded_commands() const {
std::vector<wcstring> result;
result.reserve(autoloaded_files_.size());
for (const auto &kv : autoloaded_files_) {
result.push_back(kv.first);
@ -185,11 +185,11 @@ maybe_t<wcstring> autoload_t::resolve_command(const wcstring &cmd, const environ
if (maybe_t<env_var_t> mvar = env.get(env_var_name_)) {
return resolve_command(cmd, mvar->as_list());
} else {
return resolve_command(cmd, wcstring_list_t{});
return resolve_command(cmd, std::vector<wcstring>{});
}
}
maybe_t<wcstring> autoload_t::resolve_command(const wcstring &cmd, const wcstring_list_t &paths) {
maybe_t<wcstring> autoload_t::resolve_command(const wcstring &cmd, const std::vector<wcstring> &paths) {
// Are we currently in the process of autoloading this?
if (current_autoloading_.count(cmd) > 0) return none();

View file

@ -47,7 +47,7 @@ class autoload_t {
/// Like resolve_autoload(), but accepts the paths directly.
/// This is exposed for testing.
maybe_t<wcstring> resolve_command(const wcstring &cmd, const wcstring_list_t &paths);
maybe_t<wcstring> resolve_command(const wcstring &cmd, const std::vector<wcstring> &paths);
friend autoload_tester_t;
@ -94,7 +94,7 @@ class autoload_t {
/// \return the names of all commands that have been autoloaded. Note this includes "in-flight"
/// commands.
wcstring_list_t get_autoloaded_commands() const;
std::vector<wcstring> get_autoloaded_commands() const;
/// Mark that all autoloaded files have been forgotten.
/// Future calls to path_to_autoload() will return previously-returned paths.

View file

@ -68,7 +68,7 @@
static maybe_t<RustBuiltin> try_get_rust_builtin(const wcstring &cmd);
static maybe_t<int> builtin_run_rust(parser_t &parser, io_streams_t &streams,
const wcstring_list_t &argv, RustBuiltin builtin);
const std::vector<wcstring> &argv, RustBuiltin builtin);
/// Counts the number of arguments in the specified null-terminated array
int builtin_count_args(const wchar_t *const *argv) {
@ -433,7 +433,7 @@ static const wchar_t *const help_builtins[] = {L"for", L"while", L"function", L
static bool cmd_needs_help(const wcstring &cmd) { return contains(help_builtins, cmd); }
/// Execute a builtin command
proc_status_t builtin_run(parser_t &parser, const wcstring_list_t &argv, io_streams_t &streams) {
proc_status_t builtin_run(parser_t &parser, const std::vector<wcstring> &argv, io_streams_t &streams) {
if (argv.empty()) return proc_status_t::from_exit_code(STATUS_INVALID_ARGS);
const wcstring &cmdname = argv.front();
@ -491,8 +491,8 @@ proc_status_t builtin_run(parser_t &parser, const wcstring_list_t &argv, io_stre
}
/// Returns a list of all builtin names.
wcstring_list_t builtin_get_names() {
wcstring_list_t result;
std::vector<wcstring> builtin_get_names() {
std::vector<wcstring> result;
result.reserve(BUILTIN_COUNT);
for (const auto &builtin_data : builtin_datas) {
result.push_back(builtin_data.name);
@ -577,7 +577,7 @@ static maybe_t<RustBuiltin> try_get_rust_builtin(const wcstring &cmd) {
}
static maybe_t<int> builtin_run_rust(parser_t &parser, io_streams_t &streams,
const wcstring_list_t &argv, RustBuiltin builtin) {
const std::vector<wcstring> &argv, RustBuiltin builtin) {
int status_code;
bool update_status = rust_run_builtin(parser, streams, argv, builtin, status_code);
if (update_status) {

View file

@ -80,9 +80,9 @@ struct builtin_data_t {
bool builtin_exists(const wcstring &cmd);
proc_status_t builtin_run(parser_t &parser, const wcstring_list_t &argv, io_streams_t &streams);
proc_status_t builtin_run(parser_t &parser, const std::vector<wcstring> &argv, io_streams_t &streams);
wcstring_list_t builtin_get_names();
std::vector<wcstring> builtin_get_names();
wcstring_list_ffi_t builtin_get_names_ffi();
void builtin_get_names(completion_list_t *list);
const wchar_t *builtin_get_desc(const wcstring &name);

View file

@ -35,7 +35,7 @@ struct option_spec_t {
wchar_t short_flag;
wcstring long_flag;
wcstring validation_command;
wcstring_list_t vals;
std::vector<wcstring> vals;
bool short_flag_valid{true};
int num_allowed{0};
int num_seen{0};
@ -52,8 +52,8 @@ struct argparse_cmd_opts_t {
size_t max_args = SIZE_MAX;
wchar_t implicit_int_flag = L'\0';
wcstring name;
wcstring_list_t raw_exclusive_flags;
wcstring_list_t argv;
std::vector<wcstring> raw_exclusive_flags;
std::vector<wcstring> argv;
std::unordered_map<wchar_t, option_spec_ref_t> options;
std::unordered_map<wcstring, wchar_t> long_to_short_flag;
std::vector<std::vector<wchar_t>> exclusive_flag_sets;
@ -124,7 +124,7 @@ static int check_for_mutually_exclusive_flags(const argparse_cmd_opts_t &opts,
// information to parse the values associated with any `--exclusive` flags.
static int parse_exclusive_args(argparse_cmd_opts_t &opts, io_streams_t &streams) {
for (const wcstring &raw_xflags : opts.raw_exclusive_flags) {
const wcstring_list_t xflags = split_string(raw_xflags, L',');
const std::vector<wcstring> xflags = split_string(raw_xflags, L',');
if (xflags.size() < 2) {
streams.err.append_format(_(L"%ls: exclusive flag string '%ls' is not valid\n"),
opts.name.c_str(), raw_xflags.c_str());
@ -473,7 +473,7 @@ static int validate_arg(parser_t &parser, const argparse_cmd_opts_t &opts, optio
// Obviously if there is no arg validation command we assume the arg is okay.
if (opt_spec->validation_command.empty()) return STATUS_CMD_OK;
wcstring_list_t cmd_output;
std::vector<wcstring> cmd_output;
auto &vars = parser.vars();

View file

@ -75,7 +75,7 @@ class builtin_bind_t {
/// Returns false if no binding with that sequence and mode exists.
bool builtin_bind_t::list_one(const wcstring &seq, const wcstring &bind_mode, bool user,
parser_t &parser, io_streams_t &streams) {
wcstring_list_t ecmds;
std::vector<wcstring> ecmds;
wcstring sets_mode, out;
if (!input_mappings_->get(seq, bind_mode, &ecmds, user, &sets_mode)) {
@ -161,7 +161,7 @@ void builtin_bind_t::list(const wchar_t *bind_mode, bool user, parser_t &parser,
/// \param all if set, all terminfo key binding names will be printed. If not set, only ones that
/// are defined for this terminal are printed.
void builtin_bind_t::key_names(bool all, io_streams_t &streams) {
const wcstring_list_t names = input_terminfo_get_names(!all);
const std::vector<wcstring> names = input_terminfo_get_names(!all);
for (const wcstring &name : names) {
streams.out.append(name);
streams.out.push(L'\n');
@ -170,7 +170,7 @@ void builtin_bind_t::key_names(bool all, io_streams_t &streams) {
/// Print all the special key binding functions to string buffer used for standard output.
void builtin_bind_t::function_names(io_streams_t &streams) {
wcstring_list_t names = input_function_get_names();
std::vector<wcstring> names = input_function_get_names();
for (const auto &name : names) {
auto seq = name.c_str();

View file

@ -33,8 +33,8 @@
/// Silly function.
static void builtin_complete_add2(const wcstring &cmd, bool cmd_is_path, const wchar_t *short_opt,
const wcstring_list_t &gnu_opts, const wcstring_list_t &old_opts,
completion_mode_t result_mode, const wcstring_list_t &condition,
const std::vector<wcstring> &gnu_opts, const std::vector<wcstring> &old_opts,
completion_mode_t result_mode, const std::vector<wcstring> &condition,
const wchar_t *comp, const wchar_t *desc,
complete_flags_t flags) {
for (const wchar_t *s = short_opt; *s; s++) {
@ -59,10 +59,10 @@ static void builtin_complete_add2(const wcstring &cmd, bool cmd_is_path, const w
}
/// Silly function.
static void builtin_complete_add(const wcstring_list_t &cmds, const wcstring_list_t &paths,
const wchar_t *short_opt, const wcstring_list_t &gnu_opt,
const wcstring_list_t &old_opt, completion_mode_t result_mode,
const wcstring_list_t &condition, const wchar_t *comp,
static void builtin_complete_add(const std::vector<wcstring> &cmds, const std::vector<wcstring> &paths,
const wchar_t *short_opt, const std::vector<wcstring> &gnu_opt,
const std::vector<wcstring> &old_opt, completion_mode_t result_mode,
const std::vector<wcstring> &condition, const wchar_t *comp,
const wchar_t *desc, complete_flags_t flags) {
for (const wcstring &cmd : cmds) {
builtin_complete_add2(cmd, false /* not path */, short_opt, gnu_opt, old_opt, result_mode,
@ -76,8 +76,8 @@ static void builtin_complete_add(const wcstring_list_t &cmds, const wcstring_lis
}
static void builtin_complete_remove_cmd(const wcstring &cmd, bool cmd_is_path,
const wchar_t *short_opt, const wcstring_list_t &gnu_opt,
const wcstring_list_t &old_opt) {
const wchar_t *short_opt, const std::vector<wcstring> &gnu_opt,
const std::vector<wcstring> &old_opt) {
bool removed = false;
for (const wchar_t *s = short_opt; *s; s++) {
complete_remove(cmd, cmd_is_path, wcstring{*s}, option_type_short);
@ -100,9 +100,9 @@ static void builtin_complete_remove_cmd(const wcstring &cmd, bool cmd_is_path,
}
}
static void builtin_complete_remove(const wcstring_list_t &cmds, const wcstring_list_t &paths,
const wchar_t *short_opt, const wcstring_list_t &gnu_opt,
const wcstring_list_t &old_opt) {
static void builtin_complete_remove(const std::vector<wcstring> &cmds, const std::vector<wcstring> &paths,
const wchar_t *short_opt, const std::vector<wcstring> &gnu_opt,
const std::vector<wcstring> &old_opt) {
for (const wcstring &cmd : cmds) {
builtin_complete_remove_cmd(cmd, false /* not path */, short_opt, gnu_opt, old_opt);
}
@ -137,15 +137,15 @@ maybe_t<int> builtin_complete(parser_t &parser, io_streams_t &streams, const wch
completion_mode_t result_mode{};
int remove = 0;
wcstring short_opt;
wcstring_list_t gnu_opt, old_opt, subcommand;
std::vector<wcstring> gnu_opt, old_opt, subcommand;
const wchar_t *comp = L"", *desc = L"";
wcstring_list_t condition;
std::vector<wcstring> condition;
bool do_complete = false;
bool have_do_complete_param = false;
wcstring do_complete_param;
wcstring_list_t cmd_to_complete;
wcstring_list_t path;
wcstring_list_t wrap_targets;
std::vector<wcstring> cmd_to_complete;
std::vector<wcstring> path;
std::vector<wcstring> wrap_targets;
bool preserve_order = false;
bool unescape_output = true;

View file

@ -38,9 +38,9 @@ struct function_cmd_opts_t {
bool shadow_scope = true;
wcstring description;
std::vector<event_description_t> events;
wcstring_list_t named_arguments;
wcstring_list_t inherit_vars;
wcstring_list_t wrap_targets;
std::vector<wcstring> named_arguments;
std::vector<wcstring> inherit_vars;
std::vector<wcstring> wrap_targets;
};
} // namespace
@ -229,13 +229,13 @@ static int validate_function_name(int argc, const wchar_t *const *argv, wcstring
/// Define a function. Calls into `function.cpp` to perform the heavy lifting of defining a
/// function.
int builtin_function(parser_t &parser, io_streams_t &streams, const wcstring_list_t &c_args,
int builtin_function(parser_t &parser, io_streams_t &streams, const std::vector<wcstring> &c_args,
const parsed_source_ref_t &source, const ast::block_statement_t &func_node) {
assert(source.has_value() && "Missing source in builtin_function");
// The wgetopt function expects 'function' as the first argument. Make a new wcstring_list with
// that property. This is needed because this builtin has a different signature than the other
// builtins.
wcstring_list_t args = {L"function"};
std::vector<wcstring> args = {L"function"};
args.insert(args.end(), c_args.begin(), c_args.end());
null_terminated_array_t<wchar_t> argv_array(args);

View file

@ -9,6 +9,6 @@
class parser_t;
struct io_streams_t;
int builtin_function(parser_t &parser, io_streams_t &streams, const wcstring_list_t &c_args,
int builtin_function(parser_t &parser, io_streams_t &streams, const std::vector<wcstring> &c_args,
const parsed_source_ref_t &source, const ast::block_statement_t &func_node);
#endif

View file

@ -298,7 +298,7 @@ maybe_t<int> builtin_functions(parser_t &parser, io_streams_t &streams, const wc
}
if (opts.list || argc == optind) {
wcstring_list_t names = function_get_names(opts.show_hidden);
std::vector<wcstring> names = function_get_names(opts.show_hidden);
std::sort(names.begin(), names.end());
bool is_screen = !streams.out_is_redirected && isatty(STDOUT_FILENO);
if (is_screen) {

View file

@ -88,7 +88,7 @@ static bool set_hist_cmd(const wchar_t *cmd, hist_cmd_t *hist_cmd, hist_cmd_t su
}
static bool check_for_unexpected_hist_args(const history_cmd_opts_t &opts, const wchar_t *cmd,
const wcstring_list_t &args, io_streams_t &streams) {
const std::vector<wcstring> &args, io_streams_t &streams) {
if (opts.history_search_type_defined || opts.show_time_format || opts.null_terminate) {
const wchar_t *subcmd_str = enum_to_str(opts.hist_cmd, hist_enum_map);
streams.err.append_format(_(L"%ls: %ls: subcommand takes no options\n"), cmd, subcmd_str);
@ -243,7 +243,7 @@ maybe_t<int> builtin_history(parser_t &parser, io_streams_t &streams, const wcha
// Every argument that we haven't consumed already is an argument for a subcommand (e.g., a
// search term).
const wcstring_list_t args(argv + optind, argv + argc);
const std::vector<wcstring> args(argv + optind, argv + argc);
// Establish appropriate defaults.
if (opts.hist_cmd == HIST_UNDEF) opts.hist_cmd = HIST_SEARCH;

View file

@ -243,7 +243,7 @@ static int handle_flag_t(const wchar_t **argv, parser_t &parser, io_streams_t &s
if (opts->type_valid) {
if (!opts->have_type) opts->type = 0;
opts->have_type = true;
wcstring_list_t types = split_string_tok(w.woptarg, L",");
std::vector<wcstring> types = split_string_tok(w.woptarg, L",");
for (const auto &t : types) {
if (t == L"file") {
opts->type |= TYPE_FILE;
@ -275,7 +275,7 @@ static int handle_flag_p(const wchar_t **argv, parser_t &parser, io_streams_t &s
if (opts->perm_valid) {
if (!opts->have_perm) opts->perm = 0;
opts->have_perm = true;
wcstring_list_t perms = split_string_tok(w.woptarg, L",");
std::vector<wcstring> perms = split_string_tok(w.woptarg, L",");
for (const auto &p : perms) {
if (p == L"read") {
opts->perm |= PERM_READ;
@ -800,7 +800,7 @@ static int path_sort(parser_t &parser, io_streams_t &streams, int argc, const wc
}
}
wcstring_list_t list;
std::vector<wcstring> list;
arg_iterator_t aiter(argv, optind, streams, opts.null_in);
while (const wcstring *arg = aiter.nextstr()) {
list.push_back(*arg);

View file

@ -533,7 +533,7 @@ maybe_t<int> builtin_read(parser_t &parser, io_streams_t &streams, const wchar_t
auto tok = new_tokenizer(buff.c_str(), TOK_ACCEPT_UNFINISHED);
if (opts.array) {
// Array mode: assign each token as a separate element of the sole var.
wcstring_list_t tokens;
std::vector<wcstring> tokens;
while (auto t = tok->next()) {
auto text = *tok->text_of(*t);
if (auto out = unescape_string(text, UNESCAPE_DEFAULT)) {
@ -576,7 +576,7 @@ maybe_t<int> builtin_read(parser_t &parser, io_streams_t &streams, const wchar_t
size_t x = std::max(static_cast<size_t>(1), buff.size());
size_t n_splits =
(opts.array || static_cast<size_t>(vars_left()) > x) ? x : vars_left();
wcstring_list_t chars;
std::vector<wcstring> chars;
chars.reserve(n_splits);
int i = 0;
@ -606,11 +606,11 @@ maybe_t<int> builtin_read(parser_t &parser, io_streams_t &streams, const wchar_t
if (!opts.have_delimiter) {
// We're using IFS, so tokenize the buffer using each IFS char. This is for backward
// compatibility with old versions of fish.
wcstring_list_t tokens = split_string_tok(buff, opts.delimiter);
std::vector<wcstring> tokens = split_string_tok(buff, opts.delimiter);
parser.set_var_and_fire(*var_ptr++, opts.place, std::move(tokens));
} else {
// We're using a delimiter provided by the user so use the `string split` behavior.
wcstring_list_t splits;
std::vector<wcstring> splits;
split_about(buff.begin(), buff.end(), opts.delimiter.begin(), opts.delimiter.end(),
&splits);
@ -622,7 +622,7 @@ maybe_t<int> builtin_read(parser_t &parser, io_streams_t &streams, const wchar_t
// We're using IFS, so tokenize the buffer using each IFS char. This is for backward
// compatibility with old versions of fish.
// Note the final variable gets any remaining text.
wcstring_list_t var_vals = split_string_tok(buff, opts.delimiter, vars_left());
std::vector<wcstring> var_vals = split_string_tok(buff, opts.delimiter, vars_left());
size_t val_idx = 0;
while (vars_left()) {
wcstring val;
@ -633,7 +633,7 @@ maybe_t<int> builtin_read(parser_t &parser, io_streams_t &streams, const wchar_t
}
} else {
// We're using a delimiter provided by the user so use the `string split` behavior.
wcstring_list_t splits;
std::vector<wcstring> splits;
// We're making at most argc - 1 splits so the last variable
// is set to the remaining string.
split_about(buff.begin(), buff.end(), opts.delimiter.begin(), opts.delimiter.end(),

View file

@ -301,7 +301,7 @@ static void handle_env_return(int retval, const wchar_t *cmd, const wcstring &ke
/// Call vars.set. If this is a path variable, e.g. PATH, validate the elements. On error, print a
/// description of the problem to stderr.
static int env_set_reporting_errors(const wchar_t *cmd, const wcstring &key, int scope,
wcstring_list_t list, io_streams_t &streams, parser_t &parser) {
std::vector<wcstring> list, io_streams_t &streams, parser_t &parser) {
int retval = parser.set_var_and_fire(key, scope | ENV_USER, std::move(list));
// If this returned OK, the parser already fired the event.
handle_env_return(retval, cmd, key, streams);
@ -396,7 +396,7 @@ static maybe_t<split_var_t> split_var_and_indexes(const wchar_t *arg, env_mode_f
/// Given a list of values and 1-based indexes, return a new list with those elements removed.
/// Note this deliberately accepts both args by value, as it modifies them both.
static wcstring_list_t erased_at_indexes(wcstring_list_t input, std::vector<long> indexes) {
static std::vector<wcstring> erased_at_indexes(std::vector<wcstring> input, std::vector<long> indexes) {
// Sort our indexes into *descending* order.
std::sort(indexes.begin(), indexes.end(), std::greater<long>());
@ -436,7 +436,7 @@ static int builtin_set_list(const wchar_t *cmd, set_cmd_opts_t &opts, int argc,
UNUSED(parser);
bool names_only = opts.list;
wcstring_list_t names = parser.vars().get_names(compute_scope(opts));
std::vector<wcstring> names = parser.vars().get_names(compute_scope(opts));
sort(names.begin(), names.end());
for (const auto &key : names) {
@ -538,7 +538,7 @@ static void show_scope(const wchar_t *var_name, int scope, io_streams_t &streams
const wchar_t *exportv = var->exports() ? _(L"exported") : _(L"unexported");
const wchar_t *pathvarv = var->is_pathvar() ? _(L" a path variable") : L"";
wcstring_list_t vals = var->as_list();
std::vector<wcstring> vals = var->as_list();
streams.out.append_format(_(L"$%ls: set in %ls scope, %ls,%ls with %d elements"), var_name,
scope_name, exportv, pathvarv, vals.size());
// HACK: PWD can be set, depending on how you ask.
@ -570,7 +570,7 @@ static int builtin_set_show(const wchar_t *cmd, const set_cmd_opts_t &opts, int
const auto &vars = parser.vars();
auto inheriteds = env_get_inherited();
if (argc == 0) { // show all vars
wcstring_list_t names = vars.get_names(ENV_USER);
std::vector<wcstring> names = vars.get_names(ENV_USER);
sort(names.begin(), names.end());
for (const auto &name : names) {
if (name == L"history") continue;
@ -656,7 +656,7 @@ static int builtin_set_erase(const wchar_t *cmd, set_cmd_opts_t &opts, int argc,
}
} else { // remove just the specified indexes of the var
if (!split->var) return STATUS_CMD_ERROR;
wcstring_list_t result = erased_at_indexes(split->var->as_list(), split->indexes);
std::vector<wcstring> result = erased_at_indexes(split->var->as_list(), split->indexes);
retval = env_set_reporting_errors(cmd, split->varname, scope, std::move(result),
streams, parser);
}
@ -674,9 +674,9 @@ static int builtin_set_erase(const wchar_t *cmd, set_cmd_opts_t &opts, int argc,
/// Return a list of new values for the variable \p varname, respecting the \p opts.
/// The arguments are given as the argc, argv pair.
/// This handles the simple case where there are no indexes.
static wcstring_list_t new_var_values(const wcstring &varname, const set_cmd_opts_t &opts, int argc,
static std::vector<wcstring> new_var_values(const wcstring &varname, const set_cmd_opts_t &opts, int argc,
const wchar_t *const *argv, const environment_t &vars) {
wcstring_list_t result;
std::vector<wcstring> result;
if (!opts.prepend && !opts.append) {
// Not prepending or appending.
result.assign(argv, argv + argc);
@ -704,7 +704,7 @@ static wcstring_list_t new_var_values(const wcstring &varname, const set_cmd_opt
}
/// This handles the more difficult case of setting individual slices of a var.
static wcstring_list_t new_var_values_by_index(const split_var_t &split, int argc,
static std::vector<wcstring> new_var_values_by_index(const split_var_t &split, int argc,
const wchar_t *const *argv) {
assert(static_cast<size_t>(argc) == split.indexes.size() &&
"Must have the same number of indexes as arguments");
@ -712,7 +712,7 @@ static wcstring_list_t new_var_values_by_index(const split_var_t &split, int arg
// Inherit any existing values.
// Note unlike the append/prepend case, we start with a variable in the same scope as we are
// setting.
wcstring_list_t result;
std::vector<wcstring> result;
if (split.var) result = split.var->as_list();
// For each (index, argument) pair, set the element in our \p result to the replacement string.
@ -788,7 +788,7 @@ static int builtin_set_set(const wchar_t *cmd, set_cmd_opts_t &opts, int argc, c
}
}
wcstring_list_t new_values;
std::vector<wcstring> new_values;
if (split->indexes.empty()) {
// Handle the simple, common, case. Set the var to the specified values.
new_values = new_var_values(split->varname, opts, argc, argv, parser.vars());

View file

@ -65,7 +65,7 @@ static void print_modifiers(outputter_t &outp, bool bold, bool underline, bool i
}
}
static void print_colors(io_streams_t &streams, wcstring_list_t args, bool bold, bool underline,
static void print_colors(io_streams_t &streams, std::vector<wcstring> args, bool bold, bool underline,
bool italics, bool dim, bool reverse, rgb_color_t bg) {
outputter_t outp;
if (args.empty()) args = rgb_color_t::named_color_names();
@ -184,7 +184,7 @@ maybe_t<int> builtin_set_color(parser_t &parser, io_streams_t &streams, const wc
if (bgcolor && bg.is_special()) {
bg = rgb_color_t(L"");
}
wcstring_list_t args(argv + w.woptind, argv + argc);
std::vector<wcstring> args(argv + w.woptind, argv + argc);
print_colors(streams, args, bold, underline, italics, dim, reverse, bg);
return STATUS_CMD_OK;
}

View file

@ -98,7 +98,7 @@ maybe_t<int> builtin_source(parser_t &parser, io_streams_t &streams, const wchar
// Construct argv from our null-terminated list.
// This is slightly subtle. If this is a bare `source` with no args then `argv + optind` already
// points to the end of argv. Otherwise we want to skip the file name to get to the args if any.
wcstring_list_t argv_list;
std::vector<wcstring> argv_list;
const wchar_t *const *remaining_args = argv + optind + (argc == optind ? 0 : 1);
for (size_t i = 0, len = null_terminated_array_length(remaining_args); i < len; i++) {
argv_list.push_back(remaining_args[i]);

View file

@ -314,7 +314,7 @@ maybe_t<int> builtin_status(parser_t &parser, io_streams_t &streams, const wchar
}
// Every argument that we haven't consumed already is an argument for a subcommand.
const wcstring_list_t args(argv + optind, argv + argc);
const std::vector<wcstring> args(argv + optind, argv + argc);
switch (opts.status_cmd) {
case STATUS_UNDEF: {

View file

@ -340,7 +340,7 @@ static int handle_flag_f(const wchar_t **argv, parser_t &parser, io_streams_t &s
return STATUS_CMD_OK;
} else if (opts->fields_valid) {
for (const wcstring &s : split_string(w.woptarg, L',')) {
wcstring_list_t range = split_string(s, L'-');
std::vector<wcstring> range = split_string(s, L'-');
if (range.size() == 2) {
int begin = fish_wcstoi(range.at(0).c_str());
if (begin <= 0 || errno == ERANGE) {
@ -919,7 +919,7 @@ static maybe_t<re::regex_t> try_compile_regex(const wcstring &pattern, const opt
/// Check if a list of capture group names is valid for variables. If any are invalid then report an
/// error to \p streams. \return true if all names are valid.
static bool validate_capture_group_names(const wcstring_list_t &capture_group_names,
static bool validate_capture_group_names(const std::vector<wcstring> &capture_group_names,
io_streams_t &streams) {
for (const wcstring &name : capture_group_names) {
if (env_var_t::flags_for(name.c_str()) & env_var_t::flag_read_only) {
@ -943,12 +943,12 @@ class regex_matcher_t final : public string_matcher_t {
match_data_t match_data_;
// map from group name to matched substrings, for the first argument.
std::map<wcstring, wcstring_list_t> first_match_captures_;
std::map<wcstring, std::vector<wcstring>> first_match_captures_;
void populate_captures_from_match(const wcstring &subject) {
for (auto &kv : first_match_captures_) {
const auto &name = kv.first;
wcstring_list_t &vals = kv.second;
std::vector<wcstring> &vals = kv.second;
// If there are multiple named groups and --all was used, we need to ensure that
// the indexes are always in sync between the variables. If an optional named
@ -1011,7 +1011,7 @@ class regex_matcher_t final : public string_matcher_t {
: string_matcher_t(opts), regex_(std::move(regex)), match_data_(regex_.prepare()) {
// Populate first_match_captures_ with the capture group names and empty lists.
for (const wcstring &name : regex_.capture_group_names()) {
first_match_captures_.emplace(name, wcstring_list_t{});
first_match_captures_.emplace(name, std::vector<wcstring>{});
}
}
@ -1372,12 +1372,12 @@ static int string_split_maybe0(parser_t &parser, io_streams_t &streams, int argc
const wcstring sep = is_split0 ? wcstring(1, L'\0') : wcstring(opts.arg1);
std::vector<wcstring_list_t> all_splits;
std::vector<std::vector<wcstring>> all_splits;
size_t split_count = 0;
size_t arg_count = 0;
arg_iterator_t aiter(argv, optind, streams, !is_split0);
while (const wcstring *arg = aiter.nextstr()) {
wcstring_list_t splits;
std::vector<wcstring> splits;
if (opts.right) {
split_about(arg->rbegin(), arg->rend(), sep.rbegin(), sep.rend(), &splits, opts.max,
opts.no_empty);

View file

@ -121,9 +121,9 @@ class number_t {
};
static bool binary_primary_evaluate(test_expressions::token_t token, const wcstring &left,
const wcstring &right, wcstring_list_t &errors);
const wcstring &right, std::vector<wcstring> &errors);
static bool unary_primary_evaluate(test_expressions::token_t token, const wcstring &arg,
io_streams_t *streams, wcstring_list_t &errors);
io_streams_t *streams, std::vector<wcstring> &errors);
enum { UNARY_PRIMARY = 1 << 0, BINARY_PRIMARY = 1 << 1 };
@ -195,8 +195,8 @@ static const token_info_t *token_for_string(const wcstring &str) {
class expression;
class test_parser {
private:
wcstring_list_t strings;
wcstring_list_t errors;
std::vector<wcstring> strings;
std::vector<wcstring> errors;
int error_idx;
unique_ptr<expression> error(unsigned int idx, const wchar_t *fmt, ...);
@ -205,7 +205,7 @@ class test_parser {
const wcstring &arg(unsigned int idx) { return strings.at(idx); }
public:
explicit test_parser(wcstring_list_t val) : strings(std::move(val)) {}
explicit test_parser(std::vector<wcstring> val) : strings(std::move(val)) {}
unique_ptr<expression> parse_expression(unsigned int start, unsigned int end);
unique_ptr<expression> parse_3_arg_expression(unsigned int start, unsigned int end);
@ -219,7 +219,7 @@ class test_parser {
unique_ptr<expression> parse_binary_primary(unsigned int start, unsigned int end);
unique_ptr<expression> parse_just_a_string(unsigned int start, unsigned int end);
static unique_ptr<expression> parse_args(const wcstring_list_t &args, wcstring &err,
static unique_ptr<expression> parse_args(const std::vector<wcstring> &args, wcstring &err,
const wchar_t *program_name);
};
@ -242,7 +242,7 @@ class expression {
virtual ~expression() = default;
/// Evaluate returns true if the expression is true (i.e. STATUS_CMD_OK).
virtual bool evaluate(io_streams_t *streams, wcstring_list_t &errors) = 0;
virtual bool evaluate(io_streams_t *streams, std::vector<wcstring> &errors) = 0;
};
/// Single argument like -n foo or "just a string".
@ -251,7 +251,7 @@ class unary_primary final : public expression {
wcstring arg;
unary_primary(token_t tok, range_t where, wcstring what)
: expression(tok, where), arg(std::move(what)) {}
bool evaluate(io_streams_t *streams, wcstring_list_t &errors) override;
bool evaluate(io_streams_t *streams, std::vector<wcstring> &errors) override;
};
/// Two argument primary like foo != bar.
@ -262,7 +262,7 @@ class binary_primary final : public expression {
binary_primary(token_t tok, range_t where, wcstring left, wcstring right)
: expression(tok, where), arg_left(std::move(left)), arg_right(std::move(right)) {}
bool evaluate(io_streams_t *streams, wcstring_list_t &errors) override;
bool evaluate(io_streams_t *streams, std::vector<wcstring> &errors) override;
};
/// Unary operator like bang.
@ -271,7 +271,7 @@ class unary_operator final : public expression {
unique_ptr<expression> subject;
unary_operator(token_t tok, range_t where, unique_ptr<expression> exp)
: expression(tok, where), subject(std::move(exp)) {}
bool evaluate(io_streams_t *streams, wcstring_list_t &errors) override;
bool evaluate(io_streams_t *streams, std::vector<wcstring> &errors) override;
};
/// Combining expression. Contains a list of AND or OR expressions. It takes more than two so that
@ -290,7 +290,7 @@ class combining_expression final : public expression {
~combining_expression() override = default;
bool evaluate(io_streams_t *streams, wcstring_list_t &errors) override;
bool evaluate(io_streams_t *streams, std::vector<wcstring> &errors) override;
};
/// Parenthetical expression.
@ -300,7 +300,7 @@ class parenthetical_expression final : public expression {
parenthetical_expression(token_t tok, range_t where, unique_ptr<expression> expr)
: expression(tok, where), contents(std::move(expr)) {}
bool evaluate(io_streams_t *streams, wcstring_list_t &errors) override;
bool evaluate(io_streams_t *streams, std::vector<wcstring> &errors) override;
};
void test_parser::add_error(unsigned int idx, const wchar_t *fmt, ...) {
@ -559,7 +559,7 @@ unique_ptr<expression> test_parser::parse_expression(unsigned int start, unsigne
}
}
unique_ptr<expression> test_parser::parse_args(const wcstring_list_t &args, wcstring &err,
unique_ptr<expression> test_parser::parse_args(const std::vector<wcstring> &args, wcstring &err,
const wchar_t *program_name) {
// Empty list and one-arg list should be handled by caller.
assert(args.size() > 1);
@ -614,15 +614,15 @@ unique_ptr<expression> test_parser::parse_args(const wcstring_list_t &args, wcst
return result;
}
bool unary_primary::evaluate(io_streams_t *streams, wcstring_list_t &errors) {
bool unary_primary::evaluate(io_streams_t *streams, std::vector<wcstring> &errors) {
return unary_primary_evaluate(token, arg, streams, errors);
}
bool binary_primary::evaluate(io_streams_t *, wcstring_list_t &errors) {
bool binary_primary::evaluate(io_streams_t *, std::vector<wcstring> &errors) {
return binary_primary_evaluate(token, arg_left, arg_right, errors);
}
bool unary_operator::evaluate(io_streams_t *streams, wcstring_list_t &errors) {
bool unary_operator::evaluate(io_streams_t *streams, std::vector<wcstring> &errors) {
if (token == test_bang) {
assert(subject.get());
return !subject->evaluate(streams, errors);
@ -632,7 +632,7 @@ bool unary_operator::evaluate(io_streams_t *streams, wcstring_list_t &errors) {
return false;
}
bool combining_expression::evaluate(io_streams_t *streams, wcstring_list_t &errors) {
bool combining_expression::evaluate(io_streams_t *streams, std::vector<wcstring> &errors) {
if (token == test_combine_and || token == test_combine_or) {
assert(!subjects.empty()); //!OCLINT(multiple unary operator)
assert(combiners.size() + 1 == subjects.size());
@ -674,7 +674,7 @@ bool combining_expression::evaluate(io_streams_t *streams, wcstring_list_t &erro
return false;
}
bool parenthetical_expression::evaluate(io_streams_t *streams, wcstring_list_t &errors) {
bool parenthetical_expression::evaluate(io_streams_t *streams, std::vector<wcstring> &errors) {
return contents->evaluate(streams, errors);
}
@ -696,7 +696,7 @@ static bool parse_double(const wcstring &argstr, double *out_res) {
// example, should we interpret 0x10 as 0, 10, or 16? Here we use only base 10 and use wcstoll,
// which allows for leading + and -, and whitespace. This is consistent, albeit a bit more lenient
// since we allow trailing whitespace, with other implementations such as bash.
static bool parse_number(const wcstring &arg, number_t *number, wcstring_list_t &errors) {
static bool parse_number(const wcstring &arg, number_t *number, std::vector<wcstring> &errors) {
const wchar_t *argcs = arg.c_str();
double floating = 0;
bool got_float = parse_double(arg, &floating);
@ -742,7 +742,7 @@ static bool parse_number(const wcstring &arg, number_t *number, wcstring_list_t
}
static bool binary_primary_evaluate(test_expressions::token_t token, const wcstring &left,
const wcstring &right, wcstring_list_t &errors) {
const wcstring &right, std::vector<wcstring> &errors) {
using namespace test_expressions;
number_t ln, rn;
switch (token) {
@ -793,7 +793,7 @@ static bool binary_primary_evaluate(test_expressions::token_t token, const wcstr
}
static bool unary_primary_evaluate(test_expressions::token_t token, const wcstring &arg,
io_streams_t *streams, wcstring_list_t &errors) {
io_streams_t *streams, std::vector<wcstring> &errors) {
using namespace test_expressions;
struct stat buf;
switch (token) {
@ -905,7 +905,7 @@ maybe_t<int> builtin_test(parser_t &parser, io_streams_t &streams, const wchar_t
}
// Collect the arguments into a list.
const wcstring_list_t args(argv + 1, argv + 1 + argc);
const std::vector<wcstring> args(argv + 1, argv + 1 + argc);
if (argc == 0) {
return STATUS_INVALID_ARGS; // Per 1003.1, exit false.
@ -923,7 +923,7 @@ maybe_t<int> builtin_test(parser_t &parser, io_streams_t &streams, const wchar_t
return STATUS_CMD_ERROR;
}
wcstring_list_t eval_errors;
std::vector<wcstring> eval_errors;
bool result = expr->evaluate(&streams, eval_errors);
if (!eval_errors.empty()) {
if (!should_suppress_stderr_for_tests()) {

View file

@ -139,8 +139,8 @@ static constexpr named_color_t named_colors[] = {
};
ASSERT_SORTED_BY_NAME(named_colors);
wcstring_list_t rgb_color_t::named_color_names() {
wcstring_list_t result;
std::vector<wcstring> rgb_color_t::named_color_names() {
std::vector<wcstring> result;
constexpr size_t colors_count = sizeof(named_colors) / sizeof(named_colors[0]);
result.reserve(1 + colors_count);
for (const auto &named_color : named_colors) {

View file

@ -167,7 +167,7 @@ class rgb_color_t {
bool operator!=(const rgb_color_t &other) const { return !(*this == other); }
/// Returns the names of all named colors.
static wcstring_list_t named_color_names(void);
static std::vector<wcstring> named_color_names(void);
};
static_assert(sizeof(rgb_color_t) <= 4, "rgb_color_t is too big");

View file

@ -58,7 +58,7 @@
struct termios shell_modes;
const wcstring g_empty_string{};
const wcstring_list_t g_empty_string_list{};
const std::vector<wcstring> g_empty_string_list{};
/// This allows us to notice when we've forked.
static relaxed_atomic_bool_t is_forked_proc{false};
@ -172,13 +172,13 @@ 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 wcstring_list_t demangled_backtrace(int max_frames, int skip_levels) {
[[gnu::noinline]] static std::vector<wcstring> 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);
char **symbols = backtrace_symbols(callstack, n_frames);
wchar_t text[1024];
wcstring_list_t backtrace_text;
std::vector<wcstring> backtrace_text;
if (skip_levels + max_frames < n_frames) n_frames = skip_levels + max_frames;
@ -207,7 +207,7 @@ bool is_windows_subsystem_for_linux() {
[[gnu::noinline]] void show_stackframe(int frame_count, int skip_levels) {
if (frame_count < 1) return;
wcstring_list_t bt = demangled_backtrace(frame_count, skip_levels + 2);
std::vector<wcstring> bt = demangled_backtrace(frame_count, skip_levels + 2);
FLOG(error, L"Backtrace:\n" + join_strings(bt, L'\n') + L'\n');
}

View file

@ -57,7 +57,6 @@
// Common string type.
typedef std::wstring wcstring;
typedef std::vector<wcstring> wcstring_list_t;
struct termsize_t;
@ -200,9 +199,9 @@ extern const bool has_working_tty_timestamps;
/// empty string.
extern const wcstring g_empty_string;
/// A global, empty wcstring_list_t. This is useful for functions which wish to return a reference
/// to an empty string.
extern const wcstring_list_t g_empty_string_list;
/// A global, empty std::vector<wcstring>. This is useful for functions which wish to return a
/// reference to an empty string.
extern const std::vector<wcstring> g_empty_string_list;
// Pause for input, then exit the program. If supported, print a backtrace first.
#define FATAL_EXIT() \

View file

@ -97,7 +97,7 @@ struct complete_entry_opt_t {
/// Description of the completion.
wcstring desc;
// Conditions under which to use the option, expanded and evaluated at completion time.
wcstring_list_t conditions;
std::vector<wcstring> conditions;
/// Type of the option: args_only, short, single_long, or double_long.
complete_option_type_t type;
/// Determines how completions should be performed on the argument after the switch.
@ -163,7 +163,7 @@ using completion_entry_map_t = std::map<completion_key_t, completion_entry_t>;
static owning_lock<completion_entry_map_t> s_completion_map;
/// Completion "wrapper" support. The map goes from wrapping-command to wrapped-command-list.
using wrapper_map_t = std::unordered_map<wcstring, wcstring_list_t>;
using wrapper_map_t = std::unordered_map<wcstring, std::vector<wcstring>>;
static owning_lock<wrapper_map_t> wrapper_map;
description_func_t const_desc(const wcstring &s) {
@ -334,7 +334,7 @@ class completer_t {
completion_receiver_t completions;
/// Commands which we would have tried to load, if we had a parser.
wcstring_list_t needs_load;
std::vector<wcstring> needs_load;
/// Table of completions conditions that have already been tested and the corresponding test
/// results.
@ -363,7 +363,7 @@ class completer_t {
bool complete_variable(const wcstring &str, size_t start_offset);
bool condition_test(const wcstring &condition);
bool conditions_test(const wcstring_list_t &conditions);
bool conditions_test(const std::vector<wcstring> &conditions);
void complete_strings(const wcstring &wc_escaped, const description_func_t &desc_func,
const completion_list_t &possible_comp, complete_flags_t flags,
@ -380,7 +380,7 @@ class completer_t {
// Bag of data to support expanding a command's arguments using custom completions, including
// the wrap chain.
struct custom_arg_data_t {
explicit custom_arg_data_t(wcstring_list_t *vars) : var_assignments(vars) { assert(vars); }
explicit custom_arg_data_t(std::vector<wcstring> *vars) : var_assignments(vars) { assert(vars); }
// The unescaped argument before the argument which is being completed, or empty if none.
wcstring previous_argument{};
@ -402,7 +402,7 @@ class completer_t {
// The list of variable assignments: escaped strings of the form VAR=VAL.
// This may be temporarily appended to as we explore the wrap chain.
// When completing, variable assignments are really set in a local scope.
wcstring_list_t *var_assignments;
std::vector<wcstring> *var_assignments;
// The set of wrapped commands which we have visited, and so should not be explored again.
std::set<wcstring> visited_wrapped_commands{};
@ -413,7 +413,7 @@ class completer_t {
void walk_wrap_chain(const wcstring &cmd, const wcstring &cmdline, source_range_t cmdrange,
custom_arg_data_t *ad);
cleanup_t apply_var_assignments(const wcstring_list_t &var_assignments);
cleanup_t apply_var_assignments(const std::vector<wcstring> &var_assignments);
bool empty() const { return completions.empty(); }
@ -430,7 +430,7 @@ class completer_t {
completion_list_t acquire_completions() { return completions.take(); }
wcstring_list_t acquire_needs_load() { return std::move(needs_load); }
std::vector<wcstring> acquire_needs_load() { return std::move(needs_load); }
};
// Autoloader for completions.
@ -462,7 +462,7 @@ bool completer_t::condition_test(const wcstring &condition) {
return test_res;
}
bool completer_t::conditions_test(const wcstring_list_t &conditions) {
bool completer_t::conditions_test(const std::vector<wcstring> &conditions) {
for (const auto &c : conditions) {
if (!condition_test(c)) return false;
}
@ -575,7 +575,7 @@ void completer_t::complete_cmd_desc(const wcstring &str) {
// First locate a list of possible descriptions using a single call to apropos or a direct
// search if we know the location of the whatis database. This can take some time on slower
// systems with a large set of manuals, but it should be ok since apropos is only called once.
wcstring_list_t list;
std::vector<wcstring> list;
(void)exec_subshell(lookup_cmd, *ctx.parser, list, false /* don't apply exit status */);
// Then discard anything that is not a possible completion and put the result into a
@ -657,7 +657,7 @@ void completer_t::complete_cmd(const wcstring &str_cmd) {
if (str_cmd.empty() || (str_cmd.find(L'/') == wcstring::npos && str_cmd.at(0) != L'~')) {
bool include_hidden = !str_cmd.empty() && str_cmd.at(0) == L'_';
wcstring_list_t names = function_get_names(include_hidden);
std::vector<wcstring> names = function_get_names(include_hidden);
for (wcstring &name : names) {
// Append all known matching functions
append_completion(&possible_comp, std::move(name));
@ -1312,7 +1312,7 @@ bool completer_t::try_complete_user(const wcstring &str) {
// If we have variable assignments, attempt to apply them in our parser. As soon as the return
// value goes out of scope, the variables will be removed from the parser.
cleanup_t completer_t::apply_var_assignments(const wcstring_list_t &var_assignments) {
cleanup_t completer_t::apply_var_assignments(const std::vector<wcstring> &var_assignments) {
if (!ctx.parser || var_assignments.empty()) return cleanup_t{[] {}};
env_stack_t &vars = ctx.parser->vars();
assert(&vars == &ctx.vars &&
@ -1335,7 +1335,7 @@ cleanup_t completer_t::apply_var_assignments(const wcstring_list_t &var_assignme
auto expand_ret = expand_string(expression, &expression_expanded, expand_flags, ctx);
// If expansion succeeds, set the value; if it fails (e.g. it has a cmdsub) set an empty
// value anyways.
wcstring_list_t vals;
std::vector<wcstring> vals;
if (expand_ret == expand_result_t::ok) {
for (auto &completion : expression_expanded) {
vals.emplace_back(std::move(completion.completion));
@ -1396,7 +1396,7 @@ void completer_t::walk_wrap_chain(const wcstring &cmd, const wcstring &cmdline,
// Extract command from the command line and invoke the receiver with it.
complete_custom(cmd, cmdline, ad);
wcstring_list_t targets = complete_get_wrap_targets(cmd);
std::vector<wcstring> targets = complete_get_wrap_targets(cmd);
scoped_push<size_t> saved_depth(&ad->wrap_depth, ad->wrap_depth + 1);
for (const wcstring &wt : targets) {
@ -1491,7 +1491,7 @@ void completer_t::mark_completions_duplicating_arguments(const wcstring &cmd,
const wcstring &prefix,
const std::vector<tok_t> &args) {
// Get all the arguments, unescaped, into an array that we're going to bsearch.
wcstring_list_t arg_strs;
std::vector<wcstring> arg_strs;
for (const auto &arg : args) {
wcstring argstr = *arg.get_source(cmd);
if (auto argstr_unesc = unescape_string(argstr, UNESCAPE_DEFAULT)) {
@ -1556,7 +1556,7 @@ void completer_t::perform_for_commandline(wcstring cmdline) {
// Consume variable assignments in tokens strictly before the cursor.
// This is a list of (escaped) strings of the form VAR=VAL.
wcstring_list_t var_assignments;
std::vector<wcstring> var_assignments;
for (const tok_t &tok : tokens) {
if (tok.location_in_or_at_end_of_source_range(cursor_pos)) break;
wcstring tok_src = *tok.get_source(cmdline);
@ -1715,7 +1715,7 @@ void append_completion(completion_list_t *completions, wcstring comp, wcstring d
void complete_add(const wcstring &cmd, bool cmd_is_path, const wcstring &option,
complete_option_type_t option_type, completion_mode_t result_mode,
wcstring_list_t condition, const wchar_t *comp, const wchar_t *desc,
std::vector<wcstring> condition, const wchar_t *comp, const wchar_t *desc,
complete_flags_t flags) {
// option should be empty iff the option type is arguments only.
assert(option.empty() == (option_type == option_type_args_only));
@ -1756,7 +1756,7 @@ void complete_remove_all(const wcstring &cmd, bool cmd_is_path) {
}
completion_list_t complete(const wcstring &cmd_with_subcmds, completion_request_options_t flags,
const operation_context_t &ctx, wcstring_list_t *out_needs_loads) {
const operation_context_t &ctx, std::vector<wcstring> *out_needs_loads) {
// Determine the innermost subcommand.
const wchar_t *cmdsubst_begin, *cmdsubst_end;
parse_util_cmdsubst_extent(cmd_with_subcmds.c_str(), cmd_with_subcmds.size(), &cmdsubst_begin,
@ -1900,7 +1900,7 @@ void complete_invalidate_path() {
// TODO: here we unload all completions for commands that are loaded by the autoloader. We also
// unload any completions that the user may specified on the command line. We should in
// principle track those completions loaded by the autoloader alone.
wcstring_list_t cmds = completion_autoloader.acquire()->get_autoloaded_commands();
std::vector<wcstring> cmds = completion_autoloader.acquire()->get_autoloaded_commands();
for (const wcstring &cmd : cmds) {
complete_remove_all(cmd, false /* not a path */);
}
@ -1919,7 +1919,7 @@ bool complete_add_wrapper(const wcstring &command, const wcstring &new_target) {
auto locked_map = wrapper_map.acquire();
wrapper_map_t &wraps = *locked_map;
wcstring_list_t *targets = &wraps[command];
std::vector<wcstring> *targets = &wraps[command];
// If it's already present, we do nothing.
if (!contains(*targets, new_target)) {
targets->push_back(new_target);
@ -1937,7 +1937,7 @@ bool complete_remove_wrapper(const wcstring &command, const wcstring &target_to_
bool result = false;
auto current_targets_iter = wraps.find(command);
if (current_targets_iter != wraps.end()) {
wcstring_list_t *targets = &current_targets_iter->second;
std::vector<wcstring> *targets = &current_targets_iter->second;
auto where = std::find(targets->begin(), targets->end(), target_to_remove);
if (where != targets->end()) {
targets->erase(where);
@ -1947,7 +1947,7 @@ bool complete_remove_wrapper(const wcstring &command, const wcstring &target_to_
return result;
}
wcstring_list_t complete_get_wrap_targets(const wcstring &command) {
std::vector<wcstring> complete_get_wrap_targets(const wcstring &command) {
if (command.empty()) {
return {};
}

View file

@ -242,7 +242,7 @@ void completions_sort_and_prioritize(completion_list_t *comps,
/// \param flags A set of completion flags
void complete_add(const wcstring &cmd, bool cmd_is_path, const wcstring &option,
complete_option_type_t option_type, completion_mode_t result_mode,
wcstring_list_t condition, const wchar_t *comp, const wchar_t *desc,
std::vector<wcstring> condition, const wchar_t *comp, const wchar_t *desc,
complete_flags_t flags);
/// Remove a previously defined completion.
@ -263,7 +263,7 @@ bool complete_load(const wcstring &cmd, parser_t &parser);
class operation_context_t;
completion_list_t complete(const wcstring &cmd, completion_request_options_t flags,
const operation_context_t &ctx,
wcstring_list_t *out_needs_load = nullptr);
std::vector<wcstring> *out_needs_load = nullptr);
/// Return a list of all current completions.
wcstring complete_print(const wcstring &cmd = L"");
@ -283,7 +283,7 @@ bool complete_add_wrapper(const wcstring &command, const wcstring &new_target);
bool complete_remove_wrapper(const wcstring &command, const wcstring &target_to_remove);
/// Returns a list of wrap targets for a given command.
wcstring_list_t complete_get_wrap_targets(const wcstring &command);
std::vector<wcstring> complete_get_wrap_targets(const wcstring &command);
// Observes that fish_complete_path has changed.
void complete_invalidate_path();

View file

@ -150,7 +150,7 @@ static export_generation_t next_export_generation() {
return ++*val;
}
const wcstring_list_t &env_var_t::as_list() const { return *vals_; }
const std::vector<wcstring> &env_var_t::as_list() const { return *vals_; }
wchar_t env_var_t::get_delimiter() const {
return is_pathvar() ? PATH_ARRAY_SEP : NONPATH_ARRAY_SEP;
@ -159,7 +159,7 @@ wchar_t env_var_t::get_delimiter() const {
/// Return a string representation of the var.
wcstring env_var_t::as_string() const { return join_strings(*vals_, get_delimiter()); }
void env_var_t::to_list(wcstring_list_t &out) const { out = *vals_; }
void env_var_t::to_list(std::vector<wcstring> &out) const { out = *vals_; }
env_var_t::env_var_flags_t env_var_t::flags_for(const wchar_t *name) {
env_var_flags_t result = 0;
@ -168,8 +168,8 @@ env_var_t::env_var_flags_t env_var_t::flags_for(const wchar_t *name) {
}
/// \return a singleton empty list, to avoid unnecessary allocations in env_var_t.
std::shared_ptr<const wcstring_list_t> env_var_t::empty_list() {
static const auto s_empty_result = std::make_shared<const wcstring_list_t>();
std::shared_ptr<const std::vector<wcstring>> env_var_t::empty_list() {
static const auto s_empty_result = std::make_shared<const std::vector<wcstring>>();
return s_empty_result;
}
@ -204,7 +204,7 @@ maybe_t<env_var_t> null_environment_t::get(const wcstring &key, env_mode_flags_t
UNUSED(mode);
return none();
}
wcstring_list_t null_environment_t::get_names(env_mode_flags_t flags) const {
std::vector<wcstring> null_environment_t::get_names(env_mode_flags_t flags) const {
UNUSED(flags);
return {};
}
@ -484,7 +484,7 @@ void env_init(const struct config_paths_t *paths, bool do_uvars, bool default_pa
}
}
static int set_umask(const wcstring_list_t &list_val) {
static int set_umask(const std::vector<wcstring> &list_val) {
long mask = -1;
if (list_val.size() == 1 && !list_val.front().empty()) {
mask = fish_wcstol(list_val.front().c_str(), nullptr, 8);
@ -604,7 +604,7 @@ class env_scoped_impl_t : public environment_t, noncopyable_t {
}
maybe_t<env_var_t> get(const wcstring &key, env_mode_flags_t mode = ENV_DEFAULT) const override;
wcstring_list_t get_names(env_mode_flags_t flags) const override;
std::vector<wcstring> get_names(env_mode_flags_t flags) const override;
perproc_data_t &perproc_data() { return perproc_data_; }
const perproc_data_t &perproc_data() const { return perproc_data_; }
@ -712,7 +712,7 @@ std::shared_ptr<owning_null_terminated_array_t> env_scoped_impl_t::create_export
get_exported(this->globals_, vals);
get_exported(this->locals_, vals);
const wcstring_list_t uni = uvars()->get_names(true, false);
const std::vector<wcstring> uni = uvars()->get_names(true, false);
for (const wcstring &key : uni) {
auto var = uvars()->get(key);
assert(var && "Variable should be present in uvars");
@ -769,14 +769,14 @@ maybe_t<env_var_t> env_scoped_impl_t::try_get_computed(const wcstring &key) cons
if (!history) {
history = history_t::with_name(history_session_id(*this));
}
wcstring_list_t result;
std::vector<wcstring> result;
if (history) history->get_history(result);
return env_var_t(L"history", std::move(result));
} else if (key == L"fish_killring") {
return env_var_t(L"fish_killring", kill_entries());
} else if (key == L"pipestatus") {
const auto &js = perproc_data().statuses;
wcstring_list_t result;
std::vector<wcstring> result;
result.reserve(js.pipestatus.size());
for (int i : js.pipestatus) {
result.push_back(to_string(i));
@ -868,7 +868,7 @@ maybe_t<env_var_t> env_scoped_impl_t::get(const wcstring &key, env_mode_flags_t
return result;
}
wcstring_list_t env_scoped_impl_t::get_names(env_mode_flags_t flags) const {
std::vector<wcstring> env_scoped_impl_t::get_names(env_mode_flags_t flags) const {
const query_t query(flags);
std::set<wcstring> names;
@ -899,7 +899,7 @@ wcstring_list_t env_scoped_impl_t::get_names(env_mode_flags_t flags) const {
}
if (query.universal) {
const wcstring_list_t uni_list = uvars()->get_names(query.exports, query.unexports);
const std::vector<wcstring> uni_list = uvars()->get_names(query.exports, query.unexports);
names.insert(uni_list.begin(), uni_list.end());
}
@ -949,7 +949,7 @@ class env_stack_impl_t final : public env_scoped_impl_t {
using env_scoped_impl_t::env_scoped_impl_t;
/// Set a variable under the name \p key, using the given \p mode, setting its value to \p val.
mod_result_t set(const wcstring &key, env_mode_flags_t mode, wcstring_list_t val);
mod_result_t set(const wcstring &key, env_mode_flags_t mode, std::vector<wcstring> val);
/// Remove a variable under the name \p key.
mod_result_t remove(const wcstring &key, int var_mode);
@ -1018,13 +1018,13 @@ class env_stack_impl_t final : public env_scoped_impl_t {
/// Try setting\p key as an electric or readonly variable.
/// \return an error code, or none() if not an electric or readonly variable.
/// \p val will not be modified upon a none() return.
maybe_t<int> try_set_electric(const wcstring &key, const query_t &query, wcstring_list_t &val);
maybe_t<int> try_set_electric(const wcstring &key, const query_t &query, std::vector<wcstring> &val);
/// Set a universal value.
void set_universal(const wcstring &key, wcstring_list_t val, const query_t &query);
void set_universal(const wcstring &key, std::vector<wcstring> val, const query_t &query);
/// Set a variable in a given node \p node.
void set_in_node(const 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, std::vector<wcstring> &&val,
const var_flags_t &flags);
// Implement the default behavior of 'set' by finding the node for an unspecified scope.
@ -1084,8 +1084,8 @@ env_node_ref_t env_stack_impl_t::pop() {
}
/// Apply the pathvar behavior, splitting about colons.
static wcstring_list_t colon_split(const wcstring_list_t &val) {
wcstring_list_t split_val;
static std::vector<wcstring> colon_split(const std::vector<wcstring> &val) {
std::vector<wcstring> split_val;
split_val.reserve(val.size());
for (const wcstring &str : val) {
vec_append(split_val, split_string(str, PATH_ARRAY_SEP));
@ -1094,7 +1094,7 @@ static wcstring_list_t colon_split(const wcstring_list_t &val) {
}
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) {
std::vector<wcstring> &&val, const var_flags_t &flags) {
env_var_t &var = node->env[key];
// Use an explicit exports, or inherit from the existing variable.
@ -1118,7 +1118,7 @@ void env_stack_impl_t::set_in_node(const env_node_ref_t &node, const wcstring &k
}
maybe_t<int> env_stack_impl_t::try_set_electric(const wcstring &key, const query_t &query,
wcstring_list_t &val) {
std::vector<wcstring> &val) {
const electric_var_t *ev = electric_var_t::for_name(key);
if (!ev) {
return none();
@ -1164,7 +1164,7 @@ maybe_t<int> env_stack_impl_t::try_set_electric(const wcstring &key, const query
}
/// Set a universal variable, inheriting as applicable from the given old variable.
void env_stack_impl_t::set_universal(const wcstring &key, wcstring_list_t val,
void env_stack_impl_t::set_universal(const wcstring &key, std::vector<wcstring> val,
const query_t &query) {
auto oldvar = uvars()->get(key);
// Resolve whether or not to export.
@ -1188,7 +1188,7 @@ void env_stack_impl_t::set_universal(const wcstring &key, wcstring_list_t val,
// Split about ':' if it's a path variable.
if (pathvar) {
wcstring_list_t split_val;
std::vector<wcstring> split_val;
for (const wcstring &str : val) {
vec_append(split_val, split_string(str, PATH_ARRAY_SEP));
}
@ -1205,7 +1205,7 @@ void env_stack_impl_t::set_universal(const wcstring &key, wcstring_list_t val,
}
mod_result_t env_stack_impl_t::set(const wcstring &key, env_mode_flags_t mode,
wcstring_list_t val) {
std::vector<wcstring> val) {
const query_t query(mode);
// Handle electric and read-only variables.
auto ret = try_set_electric(key, query, val);
@ -1381,11 +1381,11 @@ maybe_t<env_var_t> env_stack_t::get(const wcstring &key, env_mode_flags_t mode)
return acquire_impl()->get(key, mode);
}
wcstring_list_t env_stack_t::get_names(env_mode_flags_t flags) const {
std::vector<wcstring> env_stack_t::get_names(env_mode_flags_t flags) const {
return acquire_impl()->get_names(flags);
}
int env_stack_t::set(const wcstring &key, env_mode_flags_t mode, wcstring_list_t vals) {
int env_stack_t::set(const wcstring &key, env_mode_flags_t mode, std::vector<wcstring> vals) {
// Historical behavior.
if (vals.size() == 1 && (key == L"PWD" || key == L"HOME")) {
path_make_canonical(vals.front());
@ -1418,11 +1418,11 @@ int env_stack_t::set(const wcstring &key, env_mode_flags_t mode, wcstring_list_t
int env_stack_t::set_ffi(const wcstring &key, env_mode_flags_t mode, const void *vals,
size_t count) {
const wchar_t *const *ptr = static_cast<const wchar_t *const *>(vals);
return this->set(key, mode, wcstring_list_t(ptr, ptr + count));
return this->set(key, mode, std::vector<wcstring>(ptr, ptr + count));
}
int env_stack_t::set_one(const wcstring &key, env_mode_flags_t mode, wcstring val) {
wcstring_list_t vals;
std::vector<wcstring> vals;
vals.push_back(std::move(val));
return set(key, mode, std::move(vals));
}
@ -1451,7 +1451,7 @@ std::shared_ptr<owning_null_terminated_array_t> env_stack_t::export_arr() {
std::shared_ptr<environment_t> env_stack_t::snapshot() const { return acquire_impl()->snapshot(); }
void env_stack_t::set_argv(wcstring_list_t argv) { set(L"argv", ENV_LOCAL, std::move(argv)); }
void env_stack_t::set_argv(std::vector<wcstring> argv) { set(L"argv", ENV_LOCAL, std::move(argv)); }
wcstring env_stack_t::get_pwd_slash() const {
wcstring pwd = acquire_impl()->perproc_data().pwd;

View file

@ -99,12 +99,12 @@ class env_var_t {
using env_var_flags_t = uint8_t;
private:
env_var_t(std::shared_ptr<const wcstring_list_t> vals, env_var_flags_t flags)
env_var_t(std::shared_ptr<const std::vector<wcstring>> vals, env_var_flags_t flags)
: vals_(std::move(vals)), flags_(flags) {}
/// The list of values in this variable.
/// shared_ptr allows for cheap copying.
std::shared_ptr<const wcstring_list_t> vals_{empty_list()};
std::shared_ptr<const std::vector<wcstring>> vals_{empty_list()};
/// Flag in this variable.
env_var_flags_t flags_{};
@ -121,14 +121,14 @@ class env_var_t {
env_var_t(const env_var_t &) = default;
env_var_t(env_var_t &&) = default;
env_var_t(wcstring_list_t vals, env_var_flags_t flags)
: env_var_t(std::make_shared<wcstring_list_t>(std::move(vals)), flags) {}
env_var_t(std::vector<wcstring> vals, env_var_flags_t flags)
: env_var_t(std::make_shared<std::vector<wcstring>>(std::move(vals)), flags) {}
env_var_t(wcstring val, env_var_flags_t flags)
: env_var_t(wcstring_list_t{std::move(val)}, flags) {}
: env_var_t(std::vector<wcstring>{std::move(val)}, flags) {}
// Constructors that infer the flags from a name.
env_var_t(const wchar_t *name, wcstring_list_t vals)
env_var_t(const wchar_t *name, std::vector<wcstring> vals)
: env_var_t(std::move(vals), flags_for(name)) {}
env_var_t(const wchar_t *name, wcstring val) : env_var_t(std::move(val), flags_for(name)) {}
@ -139,14 +139,14 @@ class env_var_t {
env_var_flags_t get_flags() const { return flags_; }
wcstring as_string() const;
void to_list(wcstring_list_t &out) const;
const wcstring_list_t &as_list() const;
void to_list(std::vector<wcstring> &out) const;
const std::vector<wcstring> &as_list() const;
/// \return the character used when delimiting quoted expansion.
wchar_t get_delimiter() const;
/// \return a copy of this variable with new values.
env_var_t setting_vals(wcstring_list_t vals) const {
env_var_t setting_vals(std::vector<wcstring> vals) const {
return env_var_t{std::move(vals), flags_};
}
@ -171,7 +171,7 @@ class env_var_t {
}
static env_var_flags_t flags_for(const wchar_t *name);
static std::shared_ptr<const wcstring_list_t> empty_list();
static std::shared_ptr<const std::vector<wcstring>> empty_list();
env_var_t &operator=(const env_var_t &) = default;
env_var_t &operator=(env_var_t &&) = default;
@ -191,7 +191,7 @@ class environment_t {
public:
virtual maybe_t<env_var_t> get(const wcstring &key,
env_mode_flags_t mode = ENV_DEFAULT) const = 0;
virtual wcstring_list_t get_names(env_mode_flags_t flags) const = 0;
virtual std::vector<wcstring> get_names(env_mode_flags_t flags) const = 0;
virtual ~environment_t();
/// \return a environment variable as a unique pointer, or nullptr if none.
@ -209,7 +209,7 @@ class null_environment_t : public environment_t {
~null_environment_t() override;
maybe_t<env_var_t> get(const wcstring &key, env_mode_flags_t mode = ENV_DEFAULT) const override;
wcstring_list_t get_names(env_mode_flags_t flags) const override;
std::vector<wcstring> get_names(env_mode_flags_t flags) const override;
};
/// A mutable environment which allows scopes to be pushed and popped.
@ -237,10 +237,10 @@ class env_stack_t final : public environment_t {
maybe_t<env_var_t> get(const wcstring &key, env_mode_flags_t mode = ENV_DEFAULT) const override;
/// Implementation of environment_t.
wcstring_list_t get_names(env_mode_flags_t flags) const override;
std::vector<wcstring> get_names(env_mode_flags_t flags) const override;
/// Sets the variable with the specified name to the given values.
int set(const wcstring &key, env_mode_flags_t mode, wcstring_list_t vals);
int set(const wcstring &key, env_mode_flags_t mode, std::vector<wcstring> vals);
/// Sets the variable with the specified name to the given values.
/// The values should have type const wchar_t *const * (but autocxx doesn't support that).
@ -287,7 +287,7 @@ class env_stack_t final : public environment_t {
void set_last_statuses(statuses_t s);
/// Sets up argv as the given list of strings.
void set_argv(wcstring_list_t argv);
void set_argv(std::vector<wcstring> argv);
/// Slightly optimized implementation.
wcstring get_pwd_slash() const override;

View file

@ -219,13 +219,13 @@ static const wchar_t *const ENV_NULL = L"\x1d";
static const wchar_t UVAR_ARRAY_SEP = 0x1e;
/// Decode a serialized universal variable value into a list.
static wcstring_list_t decode_serialized(const wcstring &val) {
static std::vector<wcstring> decode_serialized(const wcstring &val) {
if (val == ENV_NULL) return {};
return split_string(val, UVAR_ARRAY_SEP);
}
/// Decode a a list into a serialized universal variable value.
static wcstring encode_serialized(const wcstring_list_t &vals) {
static wcstring encode_serialized(const std::vector<wcstring> &vals) {
if (vals.empty()) return ENV_NULL;
return join_strings(vals, UVAR_ARRAY_SEP);
}
@ -265,8 +265,8 @@ bool env_universal_t::remove(const wcstring &key) {
return false;
}
wcstring_list_t env_universal_t::get_names(bool show_exported, bool show_unexported) const {
wcstring_list_t result;
std::vector<wcstring> env_universal_t::get_names(bool show_exported, bool show_unexported) const {
std::vector<wcstring> result;
for (const auto &kv : vars) {
const wcstring &key = kv.first;
const env_var_t &var = kv.second;

View file

@ -57,7 +57,7 @@ class env_universal_t {
bool remove(const wcstring &key);
// Gets variable names.
wcstring_list_t get_names(bool show_exported, bool show_unexported) const;
std::vector<wcstring> get_names(bool show_exported, bool show_unexported) const;
/// Get a view on the universal variable table.
const var_table_t &get_table() const { return vars; }

View file

@ -33,7 +33,7 @@ const wchar_t *const event_filter_names[] = {L"signal", L"variable", L"exi
L"process-exit", L"job-exit", L"caller-exit",
L"generic", nullptr};
void event_fire_generic(parser_t &parser, const wcstring &name, const wcstring_list_t &args) {
void event_fire_generic(parser_t &parser, const wcstring &name, const std::vector<wcstring> &args) {
std::vector<wcharz_t> ffi_args;
for (const auto &arg : args) ffi_args.push_back(arg.c_str());
event_fire_generic_ffi(parser, name, ffi_args);

View file

@ -31,7 +31,7 @@ extern const wchar_t *const event_filter_names[];
class parser_t;
void event_fire_generic(parser_t &parser, const wcstring &name,
const wcstring_list_t &args = g_empty_string_list);
const std::vector<wcstring> &args = g_empty_string_list);
#endif
#endif

View file

@ -573,7 +573,7 @@ static launch_result_t exec_external_command(parser_t &parser, const std::shared
// Given that we are about to execute a function, push a function block and set up the
// variable environment.
static block_t *function_prepare_environment(parser_t &parser, wcstring_list_t argv,
static block_t *function_prepare_environment(parser_t &parser, std::vector<wcstring> argv,
const function_properties_t &props) {
// Extract the function name and remaining arguments.
wcstring func_name;
@ -650,7 +650,7 @@ static proc_performer_t get_performer_for_process(process_t *p, job_t *job,
FLOGF(error, _(L"Unknown function '%ls'"), p->argv0());
return proc_performer_t{};
}
const wcstring_list_t &argv = p->argv();
const std::vector<wcstring> &argv = p->argv();
return [=](parser_t &parser) {
// Pull out the job list from the function.
const ast::job_list_t &body = props->func_node->jobs();
@ -734,7 +734,7 @@ static proc_performer_t get_performer_for_builtin(
// Pull out some fields which we want to copy. We don't want to store the process or job in the
// returned closure.
job_group_ref_t job_group = job->group;
const wcstring_list_t &argv = p->argv();
const std::vector<wcstring> &argv = p->argv();
// Be careful to not capture p or j by value, as the intent is that this may be run on another
// thread.
@ -1140,7 +1140,7 @@ bool exec_job(parser_t &parser, const shared_ptr<job_t> &j, const io_chain_t &bl
}
/// Populate \p lst with the output of \p buffer, perhaps splitting lines according to \p split.
static void populate_subshell_output(wcstring_list_t *lst, const separated_buffer_t &buffer,
static void populate_subshell_output(std::vector<wcstring> *lst, const separated_buffer_t &buffer,
bool split) {
// Walk over all the elements.
for (const auto &elem : buffer.elements()) {
@ -1189,7 +1189,7 @@ static void populate_subshell_output(wcstring_list_t *lst, const separated_buffe
/// sense that subshells used during string expansion should halt that expansion. \return the value
/// of $status.
static int exec_subshell_internal(const wcstring &cmd, parser_t &parser,
const job_group_ref_t &job_group, wcstring_list_t *lst,
const job_group_ref_t &job_group, std::vector<wcstring> *lst,
bool *break_expand, bool apply_exit_status, bool is_subcmd) {
parser.assert_can_execute();
auto &ld = parser.libdata();
@ -1233,7 +1233,7 @@ static int exec_subshell_internal(const wcstring &cmd, parser_t &parser,
}
int exec_subshell_for_expand(const wcstring &cmd, parser_t &parser,
const job_group_ref_t &job_group, wcstring_list_t &outputs) {
const job_group_ref_t &job_group, std::vector<wcstring> &outputs) {
parser.assert_can_execute();
bool break_expand = false;
int ret = exec_subshell_internal(cmd, parser, job_group, &outputs, &break_expand, true, true);
@ -1247,7 +1247,7 @@ int exec_subshell(const wcstring &cmd, parser_t &parser, bool apply_exit_status)
false);
}
int exec_subshell(const wcstring &cmd, parser_t &parser, wcstring_list_t &outputs,
int exec_subshell(const wcstring &cmd, parser_t &parser, std::vector<wcstring> &outputs,
bool apply_exit_status) {
bool break_expand = false;
return exec_subshell_internal(cmd, parser, nullptr, &outputs, &break_expand, apply_exit_status,

View file

@ -29,7 +29,7 @@ __warn_unused bool exec_job(parser_t &parser, const std::shared_ptr<job_t> &j,
///
/// \return a value appropriate for populating $status.
int exec_subshell(const wcstring &cmd, parser_t &parser, bool apply_exit_status);
int exec_subshell(const wcstring &cmd, parser_t &parser, wcstring_list_t &outputs,
int exec_subshell(const wcstring &cmd, parser_t &parser, std::vector<wcstring> &outputs,
bool apply_exit_status);
/// Like exec_subshell, but only returns expansion-breaking errors. That is, a zero return means
@ -37,7 +37,7 @@ int exec_subshell(const wcstring &cmd, parser_t &parser, wcstring_list_t &output
/// halt expansion. If the \p pgid is supplied, then any spawned external commands should join that
/// pgroup.
int exec_subshell_for_expand(const wcstring &cmd, parser_t &parser,
const job_group_ref_t &job_group, wcstring_list_t &outputs);
const job_group_ref_t &job_group, std::vector<wcstring> &outputs);
/// Add signals that should be masked for external processes in this job.
bool blocked_signals_for_job(const job_t &job, sigset_t *sigmask);

View file

@ -127,7 +127,7 @@ static bool is_quotable(const wcstring &str) {
wcstring expand_escape_variable(const env_var_t &var) {
wcstring buff;
const wcstring_list_t &lst = var.as_list();
const std::vector<wcstring> &lst = var.as_list();
for (size_t j = 0; j < lst.size(); j++) {
const wcstring &el = lst.at(j);
@ -410,7 +410,7 @@ static expand_result_t expand_variables(wcstring instr, completion_receiver_t *o
// Ok, we have a variable or a history. Let's expand it.
// Start by respecting the sliced elements.
assert((var || history) && "Should have variable or history here");
wcstring_list_t var_item_list;
std::vector<wcstring> var_item_list;
if (all_values) {
if (history) {
history->get_history(var_item_list);
@ -430,7 +430,7 @@ static expand_result_t expand_variables(wcstring instr, completion_receiver_t *o
}
}
} else {
const wcstring_list_t &all_var_items = var->as_list();
const std::vector<wcstring> &all_var_items = var->as_list();
for (long item_index : var_idx_list) {
// Check that we are within array bounds. If not, skip the element. Note:
// Negative indices (`echo $foo[-1]`) are already converted to positive ones
@ -639,7 +639,7 @@ static expand_result_t expand_cmdsubst(wcstring input, const operation_context_t
}
}
wcstring_list_t sub_res;
std::vector<wcstring> sub_res;
int subshell_status = exec_subshell_for_expand(subcmd, *ctx.parser, ctx.job_group, sub_res);
if (subshell_status != 0) {
// TODO: Ad-hoc switch, how can we enumerate the possible errors more safely?
@ -699,7 +699,7 @@ static expand_result_t expand_cmdsubst(wcstring input, const operation_context_t
return expand_result_t::make_error(STATUS_EXPAND_ERROR);
}
wcstring_list_t sub_res2;
std::vector<wcstring> sub_res2;
tail_begin = slice_end - in;
for (long idx : slice_idx) {
if (static_cast<size_t>(idx) > sub_res.size() || idx < 1) {
@ -1022,7 +1022,7 @@ expand_result_t expander_t::stage_wildcards(wcstring path_to_expand, completion_
// So we're going to treat this input as a file path. Compute the "working directories",
// which may be CDPATH if the special flag is set.
const wcstring working_dir = ctx.vars.get_pwd_slash();
wcstring_list_t effective_working_dirs;
std::vector<wcstring> effective_working_dirs;
bool for_cd = flags & expand_flag::special_for_cd;
bool for_command = flags & expand_flag::special_for_command;
if (!for_cd && !for_command) {
@ -1052,7 +1052,7 @@ expand_result_t expander_t::stage_wildcards(wcstring path_to_expand, completion_
} else {
// Get the PATH/CDPATH and CWD. Perhaps these should be passed in. An empty CDPATH
// implies just the current directory, while an empty PATH is left empty.
wcstring_list_t paths;
std::vector<wcstring> paths;
if (auto paths_var = ctx.vars.get(for_cd ? L"CDPATH" : L"PATH")) {
paths = paths_var->as_list();
}
@ -1252,7 +1252,7 @@ bool expand_one(wcstring &string, expand_flags_t flags, const operation_context_
}
expand_result_t expand_to_command_and_args(const wcstring &instr, const operation_context_t &ctx,
wcstring *out_cmd, wcstring_list_t *out_args,
wcstring *out_cmd, std::vector<wcstring> *out_args,
parse_error_list_t *errors, bool skip_wildcards) {
// Fast path.
if (expand_is_clean(instr)) {

View file

@ -187,7 +187,7 @@ bool expand_one(wcstring &string, expand_flags_t flags, const operation_context_
/// If \p skip_wildcards is true, then do not do wildcard expansion
/// \return an expand error.
expand_result_t expand_to_command_and_args(const wcstring &instr, const operation_context_t &ctx,
wcstring *out_cmd, wcstring_list_t *out_args,
wcstring *out_cmd, std::vector<wcstring> *out_args,
parse_error_list_t *errors = nullptr,
bool skip_wildcards = false);

View file

@ -16,7 +16,7 @@ inline std::shared_ptr<T> box_to_shared_ptr(rust::Box<T> &&value) {
}
inline static void trace_if_enabled(const parser_t &parser, wcharz_t command,
const wcstring_list_t &args = {}) {
const std::vector<wcstring> &args = {}) {
if (trace_enabled(parser)) {
trace_argv(parser, command, args);
}

View file

@ -559,7 +559,7 @@ int main(int argc, char **argv) {
// Pass additional args as $argv.
// Note that we *don't* support setting argv[0]/$0, unlike e.g. bash.
wcstring_list_t list;
std::vector<wcstring> list;
for (char **ptr = argv + my_optind; *ptr; ptr++) {
list.push_back(str2wcstring(*ptr));
}
@ -580,7 +580,7 @@ int main(int argc, char **argv) {
FLOGF(error, _(L"Error reading script file '%s':"), file);
perror("error");
} else {
wcstring_list_t list;
std::vector<wcstring> list;
for (char **ptr = argv + my_optind; *ptr; ptr++) {
list.push_back(str2wcstring(*ptr));
}

View file

@ -169,8 +169,8 @@ static void err(const wchar_t *blah, ...) {
std::fwprintf(stdout, L"\n");
}
/// Joins a wcstring_list_t via commas.
static wcstring comma_join(const wcstring_list_t &lst) {
/// Joins a std::vector<wcstring> via commas.
static wcstring comma_join(const std::vector<wcstring> &lst) {
wcstring result;
for (size_t i = 0; i < lst.size(); i++) {
if (i > 0) {
@ -1528,7 +1528,7 @@ void test_dir_iter() {
const wcstring badlinkname = L"badlink"; // link to nowhere
const wcstring selflinkname = L"selflink"; // link to self
const wcstring fifoname = L"fifo";
const wcstring_list_t names = {dirname, regname, reglinkname, dirlinkname,
const std::vector<wcstring> names = {dirname, regname, reglinkname, dirlinkname,
badlinkname, selflinkname, fifoname};
const auto is_link_name = [&](const wcstring &name) -> bool {
@ -1929,9 +1929,9 @@ struct test_environment_t : public environment_t {
return none();
}
wcstring_list_t get_names(env_mode_flags_t flags) const override {
std::vector<wcstring> get_names(env_mode_flags_t flags) const override {
UNUSED(flags);
wcstring_list_t result;
std::vector<wcstring> result;
for (const auto &kv : vars) {
result.push_back(kv.first);
}
@ -1949,7 +1949,7 @@ struct pwd_environment_t : public test_environment_t {
return test_environment_t::get(key, mode);
}
wcstring_list_t get_names(env_mode_flags_t flags) const override {
std::vector<wcstring> get_names(env_mode_flags_t flags) const override {
auto res = test_environment_t::get_names(flags);
res.clear();
if (std::count(res.begin(), res.end(), L"PWD") == 0) {
@ -1985,7 +1985,7 @@ static bool expand_test(const wchar_t *in, expand_flags_t flags, ...) {
return false;
}
wcstring_list_t expected;
std::vector<wcstring> expected;
va_start(va, flags);
while ((arg = va_arg(va, wchar_t *)) != nullptr) {
@ -2179,7 +2179,7 @@ static void test_expand_overflow() {
// Make a list of 64 elements, then expand it cartesian-style 64 times.
// This is far too large to expand.
wcstring_list_t vals;
std::vector<wcstring> vals;
wcstring expansion;
for (int i = 1; i <= 64; i++) {
vals.push_back(to_string(i));
@ -2638,7 +2638,7 @@ static void test_is_potential_path() {
if (system("touch test/is_potential_path_test/gamma")) err(L"touch failed");
const wcstring wd = L"test/is_potential_path_test/";
const wcstring_list_t wds({L".", wd});
const std::vector<wcstring> wds({L".", wd});
operation_context_t ctx{env_stack_t::principal()};
do_test(is_potential_path(L"al", true, wds, ctx, PATH_REQUIRE_DIR));
@ -2666,9 +2666,9 @@ static void test_is_potential_path() {
/// Test the 'test' builtin.
maybe_t<int> builtin_test(parser_t &parser, io_streams_t &streams, const wchar_t **argv);
static bool run_one_test_test(int expected, const wcstring_list_t &lst, bool bracket) {
static bool run_one_test_test(int expected, const std::vector<wcstring> &lst, bool bracket) {
parser_t &parser = parser_t::principal_parser();
wcstring_list_t argv;
std::vector<wcstring> argv;
argv.push_back(bracket ? L"[" : L"test");
argv.insert(argv.end(), lst.begin(), lst.end());
if (bracket) argv.push_back(L"]");
@ -2694,7 +2694,7 @@ static bool run_test_test(int expected, const wcstring &str) {
operation_context_t ctx{parser, nullenv, no_cancel};
completion_list_t comps = parser_t::expand_argument_list(str, expand_flags_t{}, ctx);
wcstring_list_t argv;
std::vector<wcstring> argv;
for (const auto &c : comps) {
argv.push_back(c.completion);
}
@ -2916,7 +2916,7 @@ struct autoload_tester_t {
char t2[] = "/tmp/fish_test_autoload.XXXXXX";
wcstring p2 = str2wcstring(mkdtemp(t2));
const wcstring_list_t paths = {p1, p2};
const std::vector<wcstring> paths = {p1, p2};
autoload_t autoload(L"test_var");
do_test(!autoload.resolve_command(L"file1", paths));
@ -2931,10 +2931,10 @@ struct autoload_tester_t {
do_test(autoload.resolve_command(L"file1", paths));
do_test(!autoload.resolve_command(L"file1", paths));
do_test(autoload.autoload_in_progress(L"file1"));
do_test(autoload.get_autoloaded_commands() == wcstring_list_t{L"file1"});
do_test(autoload.get_autoloaded_commands() == std::vector<wcstring>{L"file1"});
autoload.mark_autoload_finished(L"file1");
do_test(!autoload.autoload_in_progress(L"file1"));
do_test(autoload.get_autoloaded_commands() == wcstring_list_t{L"file1"});
do_test(autoload.get_autoloaded_commands() == std::vector<wcstring>{L"file1"});
do_test(!autoload.resolve_command(L"file1", paths));
do_test(!autoload.resolve_command(L"nothing", paths));
@ -2942,7 +2942,7 @@ struct autoload_tester_t {
do_test(!autoload.resolve_command(L"file2", paths));
autoload.mark_autoload_finished(L"file2");
do_test(!autoload.resolve_command(L"file2", paths));
do_test((autoload.get_autoloaded_commands() == wcstring_list_t{L"file1", L"file2"}));
do_test((autoload.get_autoloaded_commands() == std::vector<wcstring>{L"file1", L"file2"}));
autoload.clear();
do_test(autoload.resolve_command(L"file1", paths));
@ -3014,7 +3014,7 @@ static void test_complete() {
auto func_props = make_test_func_props();
struct test_complete_vars_t : environment_t {
wcstring_list_t get_names(env_mode_flags_t flags) const override {
std::vector<wcstring> get_names(env_mode_flags_t flags) const override {
UNUSED(flags);
return {L"Foo1", L"Foo2", L"Foo3", L"Bar1", L"Bar2",
L"Bar3", L"alpha", L"ALPHA!", L"gamma1", L"GAMMA2"};
@ -3587,9 +3587,9 @@ static void test_autosuggestion_combining() {
do_test(combine_command_and_autosuggestion(L"alpha", L"ALPHA") == L"alpha");
}
static void test_history_matches(history_search_t &search, const wcstring_list_t &expected,
static void test_history_matches(history_search_t &search, const std::vector<wcstring> &expected,
unsigned from_line) {
wcstring_list_t found;
std::vector<wcstring> found;
while (search.go_to_next_match(history_search_direction_t::backward)) {
found.push_back(search.current_string());
}
@ -3770,11 +3770,11 @@ static void test_universal_output() {
const env_var_t::env_var_flags_t flag_pathvar = env_var_t::flag_pathvar;
var_table_t vars;
vars[L"varA"] = env_var_t(wcstring_list_t{L"ValA1", L"ValA2"}, 0);
vars[L"varB"] = env_var_t(wcstring_list_t{L"ValB1"}, flag_export);
vars[L"varC"] = env_var_t(wcstring_list_t{L"ValC1"}, 0);
vars[L"varD"] = env_var_t(wcstring_list_t{L"ValD1"}, flag_export | flag_pathvar);
vars[L"varE"] = env_var_t(wcstring_list_t{L"ValE1", L"ValE2"}, flag_pathvar);
vars[L"varA"] = env_var_t(std::vector<wcstring>{L"ValA1", L"ValA2"}, 0);
vars[L"varB"] = env_var_t(std::vector<wcstring>{L"ValB1"}, flag_export);
vars[L"varC"] = env_var_t(std::vector<wcstring>{L"ValC1"}, 0);
vars[L"varD"] = env_var_t(std::vector<wcstring>{L"ValD1"}, flag_export | flag_pathvar);
vars[L"varE"] = env_var_t(std::vector<wcstring>{L"ValE1", L"ValE2"}, flag_pathvar);
std::string text = env_universal_t::serialize_with_vars(vars);
const char *expected =
@ -3803,11 +3803,11 @@ static void test_universal_parsing() {
const env_var_t::env_var_flags_t flag_pathvar = env_var_t::flag_pathvar;
var_table_t vars;
vars[L"varA"] = env_var_t(wcstring_list_t{L"ValA1", L"ValA2"}, 0);
vars[L"varB"] = env_var_t(wcstring_list_t{L"ValB1"}, flag_export);
vars[L"varC"] = env_var_t(wcstring_list_t{L"ValC1"}, 0);
vars[L"varD"] = env_var_t(wcstring_list_t{L"ValD1"}, flag_export | flag_pathvar);
vars[L"varE"] = env_var_t(wcstring_list_t{L"ValE1", L"ValE2"}, flag_pathvar);
vars[L"varA"] = env_var_t(std::vector<wcstring>{L"ValA1", L"ValA2"}, 0);
vars[L"varB"] = env_var_t(std::vector<wcstring>{L"ValB1"}, flag_export);
vars[L"varC"] = env_var_t(std::vector<wcstring>{L"ValC1"}, 0);
vars[L"varD"] = env_var_t(std::vector<wcstring>{L"ValD1"}, flag_export | flag_pathvar);
vars[L"varE"] = env_var_t(std::vector<wcstring>{L"ValE1", L"ValE2"}, flag_pathvar);
var_table_t parsed_vars;
env_universal_t::populate_variables(input, &parsed_vars);
@ -3822,8 +3822,8 @@ static void test_universal_parsing_legacy() {
"SET_EXPORT varB:ValB1\n";
var_table_t vars;
vars[L"varA"] = env_var_t(wcstring_list_t{L"ValA1", L"ValA2"}, 0);
vars[L"varB"] = env_var_t(wcstring_list_t{L"ValB1"}, env_var_t::flag_export);
vars[L"varA"] = env_var_t(std::vector<wcstring>{L"ValA1", L"ValA2"}, 0);
vars[L"varB"] = env_var_t(std::vector<wcstring>{L"ValB1"}, env_var_t::flag_export);
var_table_t parsed_vars;
env_universal_t::populate_variables(input, &parsed_vars);
@ -4052,7 +4052,7 @@ void history_tests_t::test_history() {
history_search_t searcher;
say(L"Testing history");
const wcstring_list_t items = {L"Gamma", L"beta", L"BetA", L"Beta", L"alpha",
const std::vector<wcstring> items = {L"Gamma", L"beta", L"BetA", L"Beta", L"alpha",
L"AlphA", L"Alpha", L"alph", L"ALPH", L"ZZZ"};
const history_search_flags_t nocase = history_search_ignore_case;
@ -4064,7 +4064,7 @@ void history_tests_t::test_history() {
}
// Helper to set expected items to those matching a predicate, in reverse order.
wcstring_list_t expected;
std::vector<wcstring> expected;
auto set_expected = [&](const std::function<bool(const wcstring &)> &filt) {
expected.clear();
for (const auto &s : items) {
@ -4171,8 +4171,8 @@ static void time_barrier() {
} while (time(nullptr) == start);
}
static wcstring_list_t generate_history_lines(size_t item_count, size_t idx) {
wcstring_list_t result;
static std::vector<wcstring> generate_history_lines(size_t item_count, size_t idx) {
std::vector<wcstring> result;
result.reserve(item_count);
for (unsigned long i = 0; i < item_count; i++) {
result.push_back(format_string(L"%ld %lu", (unsigned long)idx, (unsigned long)i));
@ -4183,7 +4183,7 @@ static wcstring_list_t generate_history_lines(size_t item_count, size_t idx) {
void history_tests_t::test_history_races_pound_on_history(size_t item_count, size_t idx) {
// Called in child thread to modify history.
history_t hist(L"race_test");
const wcstring_list_t hist_lines = generate_history_lines(item_count, idx);
const std::vector<wcstring> hist_lines = generate_history_lines(item_count, idx);
for (const wcstring &line : hist_lines) {
hist.add(line);
hist.save();
@ -4229,7 +4229,7 @@ void history_tests_t::test_history_races() {
}
// Compute the expected lines.
std::array<wcstring_list_t, RACE_COUNT> expected_lines;
std::array<std::vector<wcstring>, RACE_COUNT> expected_lines;
for (size_t i = 0; i < RACE_COUNT; i++) {
expected_lines[i] = generate_history_lines(ITEM_COUNT, i);
}
@ -4249,7 +4249,7 @@ void history_tests_t::test_history_races() {
if (item.empty()) break;
bool found = false;
for (wcstring_list_t &list : expected_lines) {
for (std::vector<wcstring> &list : expected_lines) {
auto iter = std::find(list.begin(), list.end(), item.contents);
if (iter != list.end()) {
found = true;
@ -4267,7 +4267,7 @@ void history_tests_t::test_history_races() {
}
if (!found) {
err(L"Line '%ls' found in history, but not found in some array", item.str().c_str());
for (wcstring_list_t &list : expected_lines) {
for (std::vector<wcstring> &list : expected_lines) {
if (!list.empty()) {
fprintf(stderr, "\tRemaining: %ls\n", list.back().c_str());
}
@ -4282,7 +4282,7 @@ void history_tests_t::test_history_races() {
}
// See if anything is left in the arrays
for (const wcstring_list_t &list : expected_lines) {
for (const std::vector<wcstring> &list : expected_lines) {
for (const wcstring &str : list) {
err(L"Line '%ls' still left in the array", str.c_str());
}
@ -4345,10 +4345,10 @@ void history_tests_t::test_history_merge() {
}
// Everyone should also have items in the same order (#2312)
wcstring_list_t hist_vals1;
std::vector<wcstring> hist_vals1;
hists[0]->get_history(hist_vals1);
for (const auto &hist : hists) {
wcstring_list_t hist_vals2;
std::vector<wcstring> hist_vals2;
hist->get_history(hist_vals2);
do_test(hist_vals1 == hist_vals2);
}
@ -4432,7 +4432,7 @@ void history_tests_t::test_history_path_detection() {
}
// Expected sets of paths.
wcstring_list_t expected[hist_size] = {
std::vector<wcstring> expected[hist_size] = {
{}, // cmd0
{filename}, // cmd1
{tmpdir + L"/" + filename}, // cmd2
@ -4937,8 +4937,8 @@ static void test_new_parser_errors() {
// Given a format string, returns a list of non-empty strings separated by format specifiers. The
// format specifiers themselves are omitted.
static wcstring_list_t separate_by_format_specifiers(const wchar_t *format) {
wcstring_list_t result;
static std::vector<wcstring> separate_by_format_specifiers(const wchar_t *format) {
std::vector<wcstring> result;
const wchar_t *cursor = format;
const wchar_t *end = format + std::wcslen(format);
while (cursor < end) {
@ -4989,7 +4989,7 @@ static wcstring_list_t separate_by_format_specifiers(const wchar_t *format) {
// that each of the remaining chunks is found (in order) in the string.
static bool string_matches_format(const wcstring &string, const wchar_t *format) {
bool result = true;
wcstring_list_t components = separate_by_format_specifiers(format);
std::vector<wcstring> components = separate_by_format_specifiers(format);
size_t idx = 0;
for (const auto &component : components) {
size_t where = string.find(component, idx);
@ -5529,7 +5529,7 @@ maybe_t<int> builtin_string(parser_t &parser, io_streams_t &streams, const wchar
static void run_one_string_test(const wchar_t *const *argv_raw, int expected_rc,
const wchar_t *expected_out) {
// Copy to a null terminated array, as builtin_string may wish to rearrange our pointers.
wcstring_list_t argv_list(argv_raw, argv_raw + null_terminated_array_length(argv_raw));
std::vector<wcstring> argv_list(argv_raw, argv_raw + null_terminated_array_length(argv_raw));
null_terminated_array_t<wchar_t> argv(argv_list);
parser_t &parser = parser_t::principal_parser();
@ -5944,9 +5944,9 @@ static void test_env_vars() {
// TODO: Add tests for the locale and ncurses vars.
env_var_t v1 = {L"abc", env_var_t::flag_export};
env_var_t v2 = {wcstring_list_t{L"abc"}, env_var_t::flag_export};
env_var_t v3 = {wcstring_list_t{L"abc"}, 0};
env_var_t v4 = {wcstring_list_t{L"abc", L"def"}, env_var_t::flag_export};
env_var_t v2 = {std::vector<wcstring>{L"abc"}, env_var_t::flag_export};
env_var_t v3 = {std::vector<wcstring>{L"abc"}, 0};
env_var_t v4 = {std::vector<wcstring>{L"abc", L"def"}, env_var_t::flag_export};
do_test(v1 == v2 && !(v1 != v2));
do_test(v1 != v3 && !(v1 == v3));
do_test(v1 != v4 && !(v1 == v4));
@ -6416,20 +6416,20 @@ static void test_killring() {
kill_add(L"b");
kill_add(L"c");
do_test((kill_entries() == wcstring_list_t{L"c", L"b", L"a"}));
do_test((kill_entries() == std::vector<wcstring>{L"c", L"b", L"a"}));
do_test(kill_yank_rotate() == L"b");
do_test((kill_entries() == wcstring_list_t{L"b", L"a", L"c"}));
do_test((kill_entries() == std::vector<wcstring>{L"b", L"a", L"c"}));
do_test(kill_yank_rotate() == L"a");
do_test((kill_entries() == wcstring_list_t{L"a", L"c", L"b"}));
do_test((kill_entries() == std::vector<wcstring>{L"a", L"c", L"b"}));
kill_add(L"d");
do_test((kill_entries() == wcstring_list_t{L"d", L"a", L"c", L"b"}));
do_test((kill_entries() == std::vector<wcstring>{L"d", L"a", L"c", L"b"}));
do_test(kill_yank_rotate() == L"a");
do_test((kill_entries() == wcstring_list_t{L"a", L"c", L"b", L"d"}));
do_test((kill_entries() == std::vector<wcstring>{L"a", L"c", L"b", L"d"}));
}
namespace {
@ -6464,8 +6464,8 @@ static void test_re_basic() {
auto re = regex_t::try_compile(L"(.)\\1");
do_test(re.has_value());
auto md = re->prepare();
wcstring_list_t matches;
wcstring_list_t captures;
std::vector<wcstring> matches;
std::vector<wcstring> captures;
while (auto r = re->match(md, subject)) {
matches.push_back(substr_from_range(r));
captures.push_back(substr_from_range(re->group(md, 1)));
@ -6602,7 +6602,7 @@ void test_wgetopt() {
wgetopter_t w;
int opt;
int a_count = 0;
wcstring_list_t arguments;
std::vector<wcstring> arguments;
while ((opt = w.wgetopt_long(argc, argv, short_options, long_options, nullptr)) != -1) {
switch (opt) {
case 'a': {

View file

@ -16,7 +16,6 @@
#include "global_safety.h"
using wcstring = std::wstring;
using wcstring_list_t = std::vector<wcstring>;
namespace flog_details {

View file

@ -114,7 +114,7 @@ static void autoload_names(std::unordered_set<wcstring> &names, bool get_hidden)
const auto path_var = vars.get(L"fish_function_path");
if (path_var.missing_or_empty()) return;
const wcstring_list_t &path_list = path_var->as_list();
const std::vector<wcstring> &path_list = path_var->as_list();
for (i = 0; i < path_list.size(); i++) {
const wcstring &ndir_str = path_list.at(i);
@ -276,7 +276,7 @@ bool function_copy(const wcstring &name, const wcstring &new_name, parser_t &par
return true;
}
wcstring_list_t function_get_names(bool get_hidden) {
std::vector<wcstring> function_get_names(bool get_hidden) {
std::unordered_set<wcstring> names;
auto funcset = function_set.acquire();
autoload_names(names, get_hidden);
@ -289,7 +289,7 @@ wcstring_list_t function_get_names(bool get_hidden) {
}
names.insert(name);
}
return wcstring_list_t(names.begin(), names.end());
return std::vector<wcstring>(names.begin(), names.end());
}
void function_invalidate_path() {
@ -297,7 +297,7 @@ void function_invalidate_path() {
// Note we don't want to risk removal during iteration; we expect this to be called
// infrequently.
auto funcset = function_set.acquire();
wcstring_list_t autoloadees;
std::vector<wcstring> autoloadees;
for (const auto &kv : funcset->funcs) {
if (kv.second->is_autoload) {
autoloadees.push_back(kv.first);
@ -391,7 +391,7 @@ wcstring function_properties_t::annotated_definition(const wcstring &name) const
}
}
const wcstring_list_t &named = this->named_arguments;
const std::vector<wcstring> &named = this->named_arguments;
if (!named.empty()) {
append_format(out, L" --argument");
for (const auto &name : named) {

View file

@ -29,14 +29,14 @@ struct function_properties_t {
const ast::block_statement_t *func_node;
/// List of all named arguments for this function.
wcstring_list_t named_arguments;
std::vector<wcstring> named_arguments;
/// Description of the function.
wcstring description;
/// Mapping of all variables that were inherited from the function definition scope to their
/// values.
std::map<wcstring, wcstring_list_t> inherit_vars;
std::map<wcstring, std::vector<wcstring>> inherit_vars;
/// Set to true if invoking this function shadows the variables of the underlying function.
bool shadow_scope{true};
@ -110,7 +110,7 @@ bool function_exists_no_autoload(const wcstring &cmd);
/// Returns all function names.
///
/// \param get_hidden whether to include hidden functions, i.e. ones starting with an underscore.
wcstring_list_t function_get_names(bool get_hidden);
std::vector<wcstring> function_get_names(bool get_hidden);
/// Creates a new function using the same definition as the specified function. Returns true if copy
/// is successful.

View file

@ -188,7 +188,7 @@ static bool fs_is_case_insensitive(const wcstring &path, int fd,
///
/// We expect the path to already be unescaped.
bool is_potential_path(const wcstring &potential_path_fragment, bool at_cursor,
const wcstring_list_t &directories, const operation_context_t &ctx,
const std::vector<wcstring> &directories, const operation_context_t &ctx,
path_flags_t flags) {
ASSERT_IS_BACKGROUND_THREAD();
@ -301,7 +301,7 @@ bool is_potential_path(const wcstring &potential_path_fragment, bool at_cursor,
static bool is_potential_cd_path(const wcstring &path, bool at_cursor,
const wcstring &working_directory, const operation_context_t &ctx,
path_flags_t flags) {
wcstring_list_t directories;
std::vector<wcstring> directories;
if (string_prefixes_string(L"./", path)) {
// Ignore the CDPATH in this case; just use the working directory.
@ -309,8 +309,8 @@ static bool is_potential_cd_path(const wcstring &path, bool at_cursor,
} else {
// Get the CDPATH.
auto cdpath = ctx.vars.get(L"CDPATH");
wcstring_list_t pathsv =
cdpath.missing_or_empty() ? wcstring_list_t{L"."} : cdpath->as_list();
std::vector<wcstring> pathsv =
cdpath.missing_or_empty() ? std::vector<wcstring>{L"."} : cdpath->as_list();
// The current $PWD is always valid.
pathsv.push_back(L".");
@ -889,7 +889,7 @@ static bool range_is_potential_path(const wcstring &src, const source_range_t &r
// Put it back.
if (!token.empty() && token.at(0) == HOME_DIRECTORY) token.at(0) = L'~';
const wcstring_list_t working_directory_list(1, working_directory);
const std::vector<wcstring> working_directory_list(1, working_directory);
result =
is_potential_path(token, at_cursor, working_directory_list, ctx, PATH_EXPAND_TILDE);
}

View file

@ -157,7 +157,7 @@ enum {
};
typedef unsigned int path_flags_t;
bool is_potential_path(const wcstring &potential_path_fragment, bool at_cursor,
const wcstring_list_t &directories, const operation_context_t &ctx,
const std::vector<wcstring> &directories, const operation_context_t &ctx,
path_flags_t flags);
/// Syntax highlighter helper.

View file

@ -342,7 +342,7 @@ struct history_impl_t {
// Gets all the history into a list. This is intended for the $history environment variable.
// This may be long!
void get_history(wcstring_list_t &result);
void get_history(std::vector<wcstring> &result);
// Let indexes be a list of one-based indexes into the history, matching the interpretation of
// $history. That is, $history[1] is the most recently executed command. Values less than one
@ -350,7 +350,7 @@ struct history_impl_t {
std::unordered_map<long, wcstring> items_at_indexes(const std::vector<long> &idxs);
// Sets the valid file paths for the history item with the given identifier.
void set_valid_file_paths(wcstring_list_t &&valid_file_paths, history_identifier_t ident);
void set_valid_file_paths(std::vector<wcstring> &&valid_file_paths, history_identifier_t ident);
// Return the specified history at the specified index. 0 is the index of the current
// commandline. (So the most recent item is at index 1.)
@ -470,7 +470,7 @@ void history_impl_t::remove(const wcstring &str_to_remove) {
assert(first_unwritten_new_item_index <= new_items.size());
}
void history_impl_t::set_valid_file_paths(wcstring_list_t &&valid_file_paths,
void history_impl_t::set_valid_file_paths(std::vector<wcstring> &&valid_file_paths,
history_identifier_t ident) {
// 0 identifier is used to mean "not necessary".
if (ident == 0) {
@ -486,7 +486,7 @@ void history_impl_t::set_valid_file_paths(wcstring_list_t &&valid_file_paths,
}
}
void history_impl_t::get_history(wcstring_list_t &result) {
void history_impl_t::get_history(std::vector<wcstring> &result) {
// If we have a pending item, we skip the first encountered (i.e. last) new item.
bool next_is_pending = this->has_pending_item;
std::unordered_set<wcstring> seen;
@ -1296,7 +1296,7 @@ wcstring history_session_id(const environment_t &vars) {
path_list_t expand_and_detect_paths(const path_list_t &paths, const environment_t &vars) {
ASSERT_IS_BACKGROUND_THREAD();
wcstring_list_t result;
std::vector<wcstring> result;
wcstring working_directory = vars.get_pwd_slash();
operation_context_t ctx(vars, kExpansionLimitBackground);
for (const wcstring &path : paths) {
@ -1480,11 +1480,11 @@ static void do_1_history_search(history_t *hist, history_search_type_t search_ty
}
// Searches history.
bool history_t::search(history_search_type_t search_type, const wcstring_list_t &search_args,
bool history_t::search(history_search_type_t search_type, const std::vector<wcstring> &search_args,
const wchar_t *show_time_format, size_t max_items, bool case_sensitive,
bool null_terminate, bool reverse, const cancel_checker_t &cancel_check,
io_streams_t &streams) {
wcstring_list_t collected;
std::vector<wcstring> collected;
wcstring formatted_record;
size_t remaining = max_items;
bool output_error = false;
@ -1548,7 +1548,7 @@ void history_t::populate_from_bash(FILE *f) { impl()->populate_from_bash(f); }
void history_t::incorporate_external_changes() { impl()->incorporate_external_changes(); }
void history_t::get_history(wcstring_list_t &result) { impl()->get_history(result); }
void history_t::get_history(std::vector<wcstring> &result) { impl()->get_history(result); }
std::unordered_map<long, wcstring> history_t::items_at_indexes(const std::vector<long> &idxs) {
return impl()->items_at_indexes(idxs);

View file

@ -189,7 +189,7 @@ class history_t : noncopyable_t, nonmovable_t {
void save();
/// Searches history.
bool search(history_search_type_t search_type, const wcstring_list_t &search_args,
bool search(history_search_type_t search_type, const std::vector<wcstring> &search_args,
const wchar_t *show_time_format, size_t max_items, bool case_sensitive,
bool null_terminate, bool reverse, const cancel_checker_t &cancel_check,
io_streams_t &streams);
@ -211,7 +211,7 @@ class history_t : noncopyable_t, nonmovable_t {
/// Gets all the history into a list. This is intended for the $history environment variable.
/// This may be long!
void get_history(wcstring_list_t &result);
void get_history(std::vector<wcstring> &result);
/// Let indexes be a list of one-based indexes into the history, matching the interpretation of
/// $history. That is, $history[1] is the most recently executed command. Values less than one

View file

@ -39,7 +39,7 @@ struct input_mapping_t {
/// Character sequence which generates this event.
wcstring seq;
/// Commands that should be evaluated by this mapping.
wcstring_list_t commands;
std::vector<wcstring> commands;
/// We wish to preserve the user-specified order. This is just an incrementing value.
unsigned int specification_order;
/// Mode in which this command should be evaluated.
@ -47,7 +47,7 @@ struct input_mapping_t {
/// New mode that should be switched to after command evaluation.
wcstring sets_mode;
input_mapping_t(wcstring s, wcstring_list_t c, wcstring m, wcstring sm)
input_mapping_t(wcstring s, std::vector<wcstring> c, wcstring m, wcstring sm)
: seq(std::move(s)), commands(std::move(c)), mode(std::move(m)), sets_mode(std::move(sm)) {
static unsigned int s_last_input_map_spec_order = 0;
specification_order = ++s_last_input_map_spec_order;
@ -250,7 +250,7 @@ void input_mapping_set_t::add(wcstring sequence, const wchar_t *const *commands,
all_mappings_cache_.reset();
// Remove existing mappings with this sequence.
const wcstring_list_t commands_vector(commands, commands + commands_len);
const std::vector<wcstring> commands_vector(commands, commands + commands_len);
mapping_list_t &ml = user ? mapping_list_ : preset_mapping_list_;
@ -825,7 +825,7 @@ bool input_mapping_set_t::erase(const wcstring &sequence, const wcstring &mode,
}
bool input_mapping_set_t::get(const wcstring &sequence, const wcstring &mode,
wcstring_list_t *out_cmds, bool user, wcstring *out_sets_mode) const {
std::vector<wcstring> *out_cmds, bool user, wcstring *out_sets_mode) const {
bool result = false;
const auto &ml = user ? mapping_list_ : preset_mapping_list_;
for (const input_mapping_t &m : ml) {
@ -930,9 +930,9 @@ bool input_terminfo_get_name(const wcstring &seq, wcstring *out_name) {
return false;
}
wcstring_list_t input_terminfo_get_names(bool skip_null) {
std::vector<wcstring> input_terminfo_get_names(bool skip_null) {
assert(s_terminfo_mappings.is_set());
wcstring_list_t result;
std::vector<wcstring> result;
const auto &mappings = *s_terminfo_mappings;
result.reserve(mappings.size());
for (const terminfo_mapping_t &m : mappings) {
@ -944,10 +944,10 @@ wcstring_list_t input_terminfo_get_names(bool skip_null) {
return result;
}
const wcstring_list_t &input_function_get_names() {
const std::vector<wcstring> &input_function_get_names() {
// The list and names of input functions are hard-coded and never change
static wcstring_list_t result = ([&]() {
wcstring_list_t result;
static std::vector<wcstring> result = ([&]() {
std::vector<wcstring> result;
result.reserve(input_function_count);
for (const auto &md : input_function_metadata) {
if (md.name[0]) {

View file

@ -44,7 +44,7 @@ class inputter_t final : private input_event_queue_t {
/// \p command_handler is used to run commands. If empty (in the std::function sense), when a
/// character is encountered that would invoke a fish command, it is unread and
/// char_event_type_t::check_exit is returned. Note the handler is not stored.
using command_handler_t = std::function<void(const wcstring_list_t &)>;
using command_handler_t = std::function<void(const std::vector<wcstring> &)>;
char_event_t read_char(const command_handler_t &command_handler = {});
/// Enqueue a char event to the queue of unread characters that input_readch will return before
@ -114,7 +114,7 @@ class input_mapping_set_t {
/// Gets the command bound to the specified key sequence in the specified mode. Returns true if
/// it exists, false if not.
bool get(const wcstring &sequence, const wcstring &mode, wcstring_list_t *out_cmds, bool user,
bool get(const wcstring &sequence, const wcstring &mode, std::vector<wcstring> *out_cmds, bool user,
wcstring *out_sets_mode) const;
/// Returns all mapping names and modes.
@ -149,12 +149,12 @@ bool input_terminfo_get_sequence(const wcstring &name, wcstring *out_seq);
bool input_terminfo_get_name(const wcstring &seq, wcstring *out_name);
/// Return a list of all known terminfo names.
wcstring_list_t input_terminfo_get_names(bool skip_null);
std::vector<wcstring> input_terminfo_get_names(bool skip_null);
/// Returns the input function code for the given input function name.
maybe_t<readline_cmd_t> input_function_get_code(const wcstring &name);
/// Returns a list of all existing input function names.
const wcstring_list_t &input_function_get_names(void);
const std::vector<wcstring> &input_function_get_names(void);
#endif

View file

@ -53,7 +53,7 @@ wcstring kill_yank() {
return kill_list->front();
}
wcstring_list_t kill_entries() {
std::vector<wcstring> kill_entries() {
auto kill_list = s_kill_list.acquire();
return wcstring_list_t{kill_list->begin(), kill_list->end()};
return std::vector<wcstring>{kill_list->begin(), kill_list->end()};
}

View file

@ -20,6 +20,6 @@ wcstring kill_yank_rotate();
wcstring kill_yank();
/// Get copy of kill ring as vector of strings
wcstring_list_t kill_entries();
std::vector<wcstring> kill_entries();
#endif

View file

@ -1,6 +1,6 @@
#include "null_terminated_array.h"
std::vector<std::string> wide_string_list_to_narrow(const wcstring_list_t &strs) {
std::vector<std::string> wide_string_list_to_narrow(const std::vector<wcstring> &strs) {
std::vector<std::string> res;
res.reserve(strs.size());
for (const wcstring &s : strs) {

View file

@ -61,7 +61,7 @@ class owning_null_terminated_array_t {
};
/// Helper to convert a list of wcstring to a list of std::string.
std::vector<std::string> wide_string_list_to_narrow(const wcstring_list_t &strs);
std::vector<std::string> wide_string_list_to_narrow(const std::vector<wcstring> &strs);
/// \return the length of a null-terminated array of pointers to something.
template <typename T>

View file

@ -364,7 +364,7 @@ void pager_t::measure_completion_infos(comp_info_list_t *infos, const wcstring &
size_t prefix_len = fish_wcswidth(prefix);
for (auto &info : *infos) {
comp_t *comp = &info;
const wcstring_list_t &comp_strings = comp->comp;
const std::vector<wcstring> &comp_strings = comp->comp;
for (size_t j = 0; j < comp_strings.size(); j++) {
// If there's more than one, append the length of ', '.

View file

@ -83,7 +83,7 @@ class pager_t {
/// Data structure describing one or a group of related completions.
struct comp_t {
/// The list of all completion strings this entry applies to.
wcstring_list_t comp{};
std::vector<wcstring> comp{};
/// The description.
wcstring desc{};
/// The representative completion.

View file

@ -388,7 +388,7 @@ end_execution_reason_t parse_execution_context_t::run_function_statement(
const ast::block_statement_t &statement, const ast::function_header_t &header) {
using namespace ast;
// Get arguments.
wcstring_list_t arguments;
std::vector<wcstring> arguments;
ast_args_list_t arg_nodes = get_argument_nodes(header.args());
arg_nodes.insert(arg_nodes.begin(), &header.first_arg());
end_execution_reason_t result =
@ -449,7 +449,7 @@ end_execution_reason_t parse_execution_context_t::run_for_statement(
}
// Get the contents to iterate over.
wcstring_list_t arguments;
std::vector<wcstring> arguments;
ast_args_list_t arg_nodes = get_argument_nodes(header.args());
end_execution_reason_t ret = this->expand_arguments_from_nodes(arg_nodes, &arguments, nullglob);
if (ret != end_execution_reason_t::ok) {
@ -465,7 +465,7 @@ end_execution_reason_t parse_execution_context_t::run_for_statement(
auto &vars = parser->vars();
int retval;
retval = vars.set(for_var_name, ENV_LOCAL | ENV_USER, var ? var->as_list() : wcstring_list_t{});
retval = vars.set(for_var_name, ENV_LOCAL | ENV_USER, var ? var->as_list() : std::vector<wcstring>{});
assert(retval == ENV_OK);
trace_if_enabled(*parser, L"for", arguments);
@ -562,7 +562,7 @@ end_execution_reason_t parse_execution_context_t::run_switch_statement(
// anything. We also report case errors, but don't stop execution; i.e. a case item that
// contains an unexpandable process will report and then fail to match.
ast_args_list_t arg_nodes = get_argument_nodes(case_item.arguments());
wcstring_list_t case_args;
std::vector<wcstring> case_args;
end_execution_reason_t case_result =
this->expand_arguments_from_nodes(arg_nodes, &case_args, failglob);
if (case_result == end_execution_reason_t::ok) {
@ -771,7 +771,7 @@ end_execution_reason_t parse_execution_context_t::handle_command_not_found(
// Handle unrecognized commands with standard command not found handler that can make better
// error messages.
wcstring_list_t event_args;
std::vector<wcstring> event_args;
{
ast_args_list_t args = get_argument_nodes(statement.args_or_redirs());
end_execution_reason_t arg_result =
@ -826,7 +826,7 @@ end_execution_reason_t parse_execution_context_t::handle_command_not_found(
end_execution_reason_t parse_execution_context_t::expand_command(
const ast::decorated_statement_t &statement, wcstring *out_cmd,
wcstring_list_t *out_args) const {
std::vector<wcstring> *out_args) const {
// Here we're expanding a command, for example $HOME/bin/stuff or $randomthing. The first
// completion becomes the command itself, everything after becomes arguments. Command
// substitutions are not supported.
@ -871,7 +871,7 @@ end_execution_reason_t parse_execution_context_t::populate_plain_process(
// Get the command and any arguments due to expanding the command.
wcstring cmd;
wcstring_list_t args_from_cmd_expansion;
std::vector<wcstring> args_from_cmd_expansion;
auto ret = expand_command(statement, &cmd, &args_from_cmd_expansion);
if (ret != end_execution_reason_t::ok) {
return ret;
@ -909,7 +909,7 @@ end_execution_reason_t parse_execution_context_t::populate_plain_process(
}
// Produce the full argument list and the set of IO redirections.
wcstring_list_t cmd_args;
std::vector<wcstring> cmd_args;
auto redirections = new_redirection_spec_list();
if (use_implicit_cd) {
// Implicit cd is simple.
@ -954,7 +954,7 @@ end_execution_reason_t parse_execution_context_t::populate_plain_process(
// Determine the list of arguments, expanding stuff. Reports any errors caused by expansion. If we
// have a wildcard that could not be expanded, report the error and continue.
end_execution_reason_t parse_execution_context_t::expand_arguments_from_nodes(
const ast_args_list_t &argument_nodes, wcstring_list_t *out_arguments,
const ast_args_list_t &argument_nodes, std::vector<wcstring> *out_arguments,
globspec_t glob_behavior) {
// Get all argument nodes underneath the statement. We guess we'll have that many arguments (but
// may have more or fewer, if there are wildcards involved).
@ -1145,7 +1145,7 @@ end_execution_reason_t parse_execution_context_t::apply_variable_assignments(
DIE("unexpected expand_string() return value");
}
}
wcstring_list_t vals;
std::vector<wcstring> vals;
for (auto &completion : expression_expanded) {
vals.emplace_back(std::move(completion.completion));
}

View file

@ -81,7 +81,7 @@ class parse_execution_context_t : noncopyable_t {
// Expand a command which may contain variables, producing an expand command and possibly
// arguments. Prints an error message on error.
end_execution_reason_t expand_command(const ast::decorated_statement_t &statement,
wcstring *out_cmd, wcstring_list_t *out_args) const;
wcstring *out_cmd, std::vector<wcstring> *out_args) const;
/// Indicates whether a job is a simple block (one block, no redirections).
bool job_is_simple_block(const ast::job_pipeline_t &job) const;
@ -128,7 +128,7 @@ class parse_execution_context_t : noncopyable_t {
static ast_args_list_t get_argument_nodes(const ast::argument_or_redirection_list_t &args);
end_execution_reason_t expand_arguments_from_nodes(const ast_args_list_t &argument_nodes,
wcstring_list_t *out_arguments,
std::vector<wcstring> *out_arguments,
globspec_t glob_behavior);
// Determines the list of redirections for a node.

View file

@ -70,7 +70,7 @@ rust::Box<WaitHandleStoreFFI> &parser_t::get_wait_handles_ffi() { return wait_ha
const rust::Box<WaitHandleStoreFFI> &parser_t::get_wait_handles_ffi() const { return wait_handles; }
int parser_t::set_var_and_fire(const wcstring &key, env_mode_flags_t mode, wcstring_list_t vals) {
int parser_t::set_var_and_fire(const wcstring &key, env_mode_flags_t mode, std::vector<wcstring> vals) {
int res = vars().set(key, mode, std::move(vals));
if (res == ENV_OK) {
event_fire(*this, *new_event_variable_set(key));
@ -79,7 +79,7 @@ int parser_t::set_var_and_fire(const wcstring &key, env_mode_flags_t mode, wcstr
}
int parser_t::set_var_and_fire(const wcstring &key, env_mode_flags_t mode, wcstring val) {
wcstring_list_t vals;
std::vector<wcstring> vals;
vals.push_back(std::move(val));
return set_var_and_fire(key, mode, std::move(vals));
}
@ -798,7 +798,7 @@ block_t block_t::event_block(const void *evt_) {
return b;
}
block_t block_t::function_block(wcstring name, wcstring_list_t args, bool shadows) {
block_t block_t::function_block(wcstring name, std::vector<wcstring> args, bool shadows) {
block_t b{shadows ? block_type_t::function_call : block_type_t::function_call_no_shadow};
b.function_name = std::move(name);
b.function_args = std::move(args);

View file

@ -68,7 +68,7 @@ class block_t {
uint64_t event_blocks{};
// If this is a function block, the function args. Otherwise empty.
wcstring_list_t function_args{};
std::vector<wcstring> function_args{};
/// Name of file that created this block.
filename_ref_t src_filename{};
@ -103,7 +103,7 @@ class block_t {
/// Entry points for creating blocks.
static block_t if_block();
static block_t event_block(const void *evt_);
static block_t function_block(wcstring name, wcstring_list_t args, bool shadows);
static block_t function_block(wcstring name, std::vector<wcstring> args, bool shadows);
static block_t source_block(filename_ref_t src);
static block_t for_block();
static block_t while_block();
@ -210,7 +210,7 @@ struct library_data_t : public library_data_pod_t {
/// A stack of fake values to be returned by builtin_commandline. This is used by the completion
/// machinery when wrapping: e.g. if `tig` wraps `git` then git completions need to see git on
/// the command line.
wcstring_list_t transient_commandlines{};
std::vector<wcstring> transient_commandlines{};
/// A file descriptor holding the current working directory, for use in openat().
/// This is never null and never invalid.
@ -420,7 +420,7 @@ class parser_t : public std::enable_shared_from_this<parser_t> {
/// Cover of vars().set(), which also fires any returned event handlers.
/// \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_var_and_fire(const wcstring &key, env_mode_flags_t mode, std::vector<wcstring> vals);
/// Update any universal variables and send event handlers.
/// If \p always is set, then do it even if we have no pending changes (that is, look for

View file

@ -26,9 +26,9 @@
#include "wutil.h" // IWYU pragma: keep
// PREFIX is defined at build time.
static const wcstring_list_t kDefaultPath({L"/bin", L"/usr/bin", PREFIX L"/bin"});
static const std::vector<wcstring> kDefaultPath({L"/bin", L"/usr/bin", PREFIX L"/bin"});
static get_path_result_t path_get_path_core(const wcstring &cmd, const wcstring_list_t &pathsv) {
static get_path_result_t path_get_path_core(const wcstring &cmd, const std::vector<wcstring> &pathsv) {
const get_path_result_t noent_res{ENOENT, wcstring{}};
get_path_result_t result{};
@ -142,9 +142,9 @@ static dir_remoteness_t path_remoteness(const wcstring &path) {
#endif
}
wcstring_list_t path_get_paths(const wcstring &cmd, const environment_t &vars) {
std::vector<wcstring> path_get_paths(const wcstring &cmd, const environment_t &vars) {
FLOGF(path, L"path_get_paths('%ls')", cmd.c_str());
wcstring_list_t paths;
std::vector<wcstring> paths;
// If the command has a slash, it must be an absolute or relative path and thus we don't bother
// looking for matching commands in the PATH var.
@ -157,7 +157,7 @@ wcstring_list_t path_get_paths(const wcstring &cmd, const environment_t &vars) {
auto path_var = vars.get(L"PATH");
if (!path_var) return paths;
const wcstring_list_t &pathsv = path_var->as_list();
const std::vector<wcstring> &pathsv = path_var->as_list();
for (auto path : pathsv) {
if (path.empty()) continue;
append_path_component(path, cmd);
@ -172,9 +172,9 @@ wcstring_list_ffi_t path_get_paths_ffi(const wcstring &cmd, const parser_t &pars
return path_get_paths(cmd, parser.vars());
}
wcstring_list_t path_apply_cdpath(const wcstring &dir, const wcstring &wd,
std::vector<wcstring> path_apply_cdpath(const wcstring &dir, const wcstring &wd,
const environment_t &env_vars) {
wcstring_list_t paths;
std::vector<wcstring> paths;
if (dir.at(0) == L'/') {
// Absolute path.
paths.push_back(dir);
@ -184,7 +184,7 @@ wcstring_list_t path_apply_cdpath(const wcstring &dir, const wcstring &wd,
paths.push_back(path_normalize_for_cd(wd, dir));
} else {
// Respect CDPATH.
wcstring_list_t cdpathsv;
std::vector<wcstring> cdpathsv;
if (auto cdpaths = env_vars.get(L"CDPATH")) {
cdpathsv = cdpaths->as_list();
}

View file

@ -64,7 +64,7 @@ struct get_path_result_t {
get_path_result_t path_try_get_path(const wcstring &cmd, const environment_t &vars);
/// Return all the paths that match the given command.
wcstring_list_t path_get_paths(const wcstring &cmd, const environment_t &vars);
std::vector<wcstring> path_get_paths(const wcstring &cmd, const environment_t &vars);
// Needed because of issues with vectors of wstring and environment_t.
wcstring_list_ffi_t path_get_paths_ffi(const wcstring &cmd, const parser_t &parser);
@ -84,7 +84,7 @@ maybe_t<wcstring> path_get_cdpath(const wcstring &dir, const wcstring &wd,
const environment_t &vars);
/// Returns the given directory with all CDPATH components applied.
wcstring_list_t path_apply_cdpath(const wcstring &dir, const wcstring &wd,
std::vector<wcstring> path_apply_cdpath(const wcstring &dir, const wcstring &wd,
const environment_t &env_vars);
/// Returns the path resolved as an implicit cd command, or none() if none. This requires it to

View file

@ -258,16 +258,16 @@ class process_t {
struct concrete_assignment {
wcstring variable_name;
wcstring_list_t values;
std::vector<wcstring> values;
};
/// The expanded variable assignments for this process, as specified by the `a=b cmd` syntax.
std::vector<concrete_assignment> variable_assignments;
/// Sets argv.
void set_argv(wcstring_list_t argv) { argv_ = std::move(argv); }
void set_argv(std::vector<wcstring> argv) { argv_ = std::move(argv); }
/// Returns argv.
const wcstring_list_t &argv() { return argv_; }
const std::vector<wcstring> &argv() { return argv_; }
/// Returns argv[0], or nullptr.
const wchar_t *argv0() const { return argv_.empty() ? nullptr : argv_.front().c_str(); }
@ -346,7 +346,7 @@ class process_t {
process_t &operator=(const process_t &) = delete;
private:
wcstring_list_t argv_;
std::vector<wcstring> argv_;
rust::Box<redirection_spec_list_t> proc_redirection_specs_;
// The wait handle. This is constructed lazily, and cached.

View file

@ -193,7 +193,7 @@ size_t regex_t::capture_group_count() const {
return count;
}
wcstring_list_t regex_t::capture_group_names() const {
std::vector<wcstring> regex_t::capture_group_names() const {
PCRE2_SPTR name_table{};
uint32_t name_entry_size{};
uint32_t name_count{};
@ -230,7 +230,7 @@ wcstring_list_t regex_t::capture_group_names() const {
};
const auto *names = reinterpret_cast<const name_table_entry_t *>(name_table);
wcstring_list_t result;
std::vector<wcstring> result;
result.reserve(name_count);
for (uint32_t i = 0; i < name_count; ++i) {
const auto &name_entry = names[i * name_entry_size];

View file

@ -132,7 +132,7 @@ class regex_t : noncopyable_t {
/// \return the list of capture group names.
/// Note PCRE provides these in sorted order, not specification order.
wcstring_list_t capture_group_names() const;
std::vector<wcstring> capture_group_names() const;
/// Search \p subject for matches for this regex, starting at \p start_idx, and replacing them
/// with \p replacement. If \p repl_count is not null, populate it with the number of

View file

@ -575,7 +575,7 @@ struct autosuggestion_t {
wcstring search_string{};
// The list of completions which may need loading.
wcstring_list_t needs_load{};
std::vector<wcstring> needs_load{};
// Whether the autosuggestion should be case insensitive.
// This is true for file-generated autosuggestions, but not for history.
@ -875,7 +875,7 @@ class reader_data_t : public std::enable_shared_from_this<reader_data_t> {
void move_word(editable_line_t *el, bool move_right, bool erase, move_word_style_t style,
bool newv);
void run_input_command_scripts(const wcstring_list_t &cmds);
void run_input_command_scripts(const std::vector<wcstring> &cmds);
maybe_t<char_event_t> read_normal_chars(readline_loop_state_t &rls);
void handle_readline_command(readline_cmd_t cmd, readline_loop_state_t &rls);
@ -1399,7 +1399,7 @@ maybe_t<abbrs_replacement_t> expand_replacer(SourceRange range, const wcstring &
scoped_push<bool> not_interactive(&parser.libdata().is_interactive, false);
wcstring_list_t outputs{};
std::vector<wcstring> outputs{};
int ret = exec_subshell(cmd, parser, outputs, false /* not apply_exit_status */);
if (ret != STATUS_CMD_OK) {
return none();
@ -1547,7 +1547,7 @@ void reader_write_title(const wcstring &cmd, parser_t &parser, bool reset_cursor
}
}
wcstring_list_t lst;
std::vector<wcstring> lst;
(void)exec_subshell(fish_title_command, parser, lst, false /* ignore exit status */);
if (!lst.empty()) {
wcstring title_line = L"\x1B]0;";
@ -1569,7 +1569,7 @@ void reader_write_title(const wcstring &cmd, parser_t &parser, bool reset_cursor
void reader_data_t::exec_mode_prompt() {
mode_prompt_buff.clear();
if (function_exists(MODE_PROMPT_FUNCTION_NAME, parser())) {
wcstring_list_t mode_indicator_list;
std::vector<wcstring> mode_indicator_list;
exec_subshell(MODE_PROMPT_FUNCTION_NAME, parser(), mode_indicator_list, false);
// We do not support multiple lines in the mode indicator, so just concatenate all of
// them.
@ -1600,7 +1600,7 @@ void reader_data_t::exec_prompt() {
if (!conf.left_prompt_cmd.empty()) {
// Status is ignored.
wcstring_list_t prompt_list;
std::vector<wcstring> prompt_list;
// Historic compatibility hack.
// If the left prompt function is deleted, then use a default prompt instead of
// producing an error.
@ -1614,7 +1614,7 @@ void reader_data_t::exec_prompt() {
if (!conf.right_prompt_cmd.empty()) {
if (function_exists(conf.right_prompt_cmd, parser())) {
// Status is ignored.
wcstring_list_t prompt_list;
std::vector<wcstring> prompt_list;
exec_subshell(conf.right_prompt_cmd, parser(), prompt_list, false);
// Right prompt does not support multiple lines, so just concatenate all of them.
for (const auto &i : prompt_list) {
@ -2018,7 +2018,7 @@ static std::function<autosuggestion_t(void)> get_autosuggestion_performer(
// Try normal completions.
completion_request_options_t complete_flags = completion_request_options_t::autosuggest();
wcstring_list_t needs_load;
std::vector<wcstring> needs_load;
completion_list_t completions = complete(search_string, complete_flags, ctx, &needs_load);
autosuggestion_t result{};
@ -3333,7 +3333,7 @@ static bool event_is_normal_char(const char_event_t &evt) {
}
/// Run a sequence of commands from an input binding.
void reader_data_t::run_input_command_scripts(const wcstring_list_t &cmds) {
void reader_data_t::run_input_command_scripts(const std::vector<wcstring> &cmds) {
auto last_statuses = parser().get_last_statuses();
for (const wcstring &cmd : cmds) {
update_commandline_state();
@ -3365,7 +3365,7 @@ maybe_t<char_event_t> reader_data_t::read_normal_chars(readline_loop_state_t &rl
size_t limit = std::min(rls.nchars - command_line.size(), READAHEAD_MAX);
using command_handler_t = inputter_t::command_handler_t;
command_handler_t normal_handler = [this](const wcstring_list_t &cmds) {
command_handler_t normal_handler = [this](const std::vector<wcstring> &cmds) {
this->run_input_command_scripts(cmds);
};
command_handler_t empty_handler = {};

View file

@ -256,7 +256,7 @@ class layout_cache_t : noncopyable_t {
private:
// Cached escape sequences we've already detected in the prompt and similar strings, ordered
// lexicographically.
wcstring_list_t esc_cache_;
std::vector<wcstring> esc_cache_;
// LRU-list of prompts and their layouts.
// Use a list so we can promote to the front on a cache hit.

View file

@ -245,8 +245,8 @@ size_t ifind(const std::string &haystack, const std::string &needle, bool fuzzy)
return fuzzy ? ifind_impl<true>(haystack, needle) : ifind_impl<false>(haystack, needle);
}
wcstring_list_t split_string(const wcstring &val, wchar_t sep) {
wcstring_list_t out;
std::vector<wcstring> split_string(const wcstring &val, wchar_t sep) {
std::vector<wcstring> out;
size_t pos = 0, end = val.size();
while (pos <= end) {
size_t next_pos = val.find(sep, pos);
@ -259,8 +259,8 @@ wcstring_list_t split_string(const wcstring &val, wchar_t sep) {
return out;
}
wcstring_list_t split_string_tok(const wcstring &val, const wcstring &seps, size_t max_results) {
wcstring_list_t out;
std::vector<wcstring> split_string_tok(const wcstring &val, const wcstring &seps, size_t max_results) {
std::vector<wcstring> out;
size_t end = val.size();
size_t pos = 0;
while (pos < end && out.size() + 1 < max_results) {
@ -286,7 +286,7 @@ wcstring_list_t split_string_tok(const wcstring &val, const wcstring &seps, size
return out;
}
static wcstring join_strings_impl(const wcstring_list_t &vals, const wchar_t *sep, size_t seplen) {
static wcstring join_strings_impl(const std::vector<wcstring> &vals, const wchar_t *sep, size_t seplen) {
if (vals.empty()) return wcstring{};
// Reserve the size we will need.
@ -310,11 +310,11 @@ static wcstring join_strings_impl(const wcstring_list_t &vals, const wchar_t *se
return result;
}
wcstring join_strings(const wcstring_list_t &vals, wchar_t c) {
wcstring join_strings(const std::vector<wcstring> &vals, wchar_t c) {
return join_strings_impl(vals, &c, 1);
}
wcstring join_strings(const wcstring_list_t &vals, const wchar_t *sep) {
wcstring join_strings(const std::vector<wcstring> &vals, const wchar_t *sep) {
return join_strings_impl(vals, sep, wcslen(sep));
}

View file

@ -128,7 +128,7 @@ inline maybe_t<string_fuzzy_match_t> string_fuzzy_match_string(const wcstring &s
}
/// Split a string by a separator character.
wcstring_list_t split_string(const wcstring &val, wchar_t sep);
std::vector<wcstring> split_string(const wcstring &val, wchar_t sep);
/// Split a string by runs of any of the separator characters provided in \p seps.
/// Note the delimiters are the characters in \p seps, not \p seps itself.
@ -137,12 +137,12 @@ wcstring_list_t split_string(const wcstring &val, wchar_t sep);
/// the last output is the the remainder of the input, including leading delimiters,
/// except for the first. This is historical behavior.
/// Example: split_string_tok(" a b c ", " ", 3) -> {"a", "b", " c "}
wcstring_list_t split_string_tok(const wcstring &val, const wcstring &seps,
std::vector<wcstring> split_string_tok(const wcstring &val, const wcstring &seps,
size_t max_results = std::numeric_limits<size_t>::max());
/// Join a list of strings by a separator character or string.
wcstring join_strings(const wcstring_list_t &vals, wchar_t sep);
wcstring join_strings(const wcstring_list_t &vals, const wchar_t *sep);
wcstring join_strings(const std::vector<wcstring> &vals, wchar_t sep);
wcstring join_strings(const std::vector<wcstring> &vals, const wchar_t *sep);
inline wcstring to_string(long x) {
wchar_t buff[64];
@ -192,7 +192,7 @@ inline bool bool_from_string(const wcstring &x) {
/// Max output entries will be max + 1 (after max splits)
template <typename ITER>
void split_about(ITER haystack_start, ITER haystack_end, ITER needle_start, ITER needle_end,
wcstring_list_t *output, long max = LONG_MAX, bool no_empty = false) {
std::vector<wcstring> *output, long max = LONG_MAX, bool no_empty = false) {
long remaining = max;
ITER haystack_cursor = haystack_start;
while (remaining > 0 && haystack_cursor != haystack_end) {

View file

@ -369,8 +369,8 @@ wcstring normalize_path(const wcstring &path, bool allow_leading_double_slashes)
leading_slashes++;
}
wcstring_list_t comps = split_string(path, sep);
wcstring_list_t new_comps;
std::vector<wcstring> comps = split_string(path, sep);
std::vector<wcstring> new_comps;
for (wcstring &comp : comps) {
if (comp.empty() || comp == L".") {
continue;
@ -410,8 +410,8 @@ wcstring path_normalize_for_cd(const wcstring &wd, const wcstring &path) {
}
// Split our strings by the sep.
wcstring_list_t wd_comps = split_string(wd, sep);
wcstring_list_t path_comps = split_string(path, sep);
std::vector<wcstring> wd_comps = split_string(wd, sep);
std::vector<wcstring> path_comps = split_string(path, sep);
// Remove empty segments from wd_comps.
// In particular this removes the leading and trailing empties.
@ -903,7 +903,7 @@ bool file_id_t::operator<(const file_id_t &rhs) const { return this->compare_fil
// static
wcstring_list_ffi_t wcstring_list_ffi_t::get_test_data() {
return wcstring_list_t{L"foo", L"bar", L"baz"};
return std::vector<wcstring>{L"foo", L"bar", L"baz"};
}
// static

View file

@ -40,10 +40,10 @@ struct wcharz_t {
// A helper type for passing vectors of strings back to Rust.
// This hides the vector so that autocxx doesn't complain about templates.
struct wcstring_list_ffi_t {
wcstring_list_t vals{};
std::vector<wcstring> vals{};
wcstring_list_ffi_t() = default;
/* implicit */ wcstring_list_ffi_t(wcstring_list_t vals) : vals(std::move(vals)) {}
/* implicit */ wcstring_list_ffi_t(std::vector<wcstring> vals) : vals(std::move(vals)) {}
size_t size() const { return vals.size(); }
const wcstring &at(size_t idx) const { return vals.at(idx); }