mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-25 09:39:52 +08:00
Revert "make tokenize_variable_array()
private"
This reverts commit 4fe9d79438
.
It was meant for the major branch.
This commit is contained in:
parent
7dd2cd7de7
commit
7876bc6ef3
|
@ -105,7 +105,6 @@ static const wcstring_list_t colon_delimited_variable({L"PATH", L"MANPATH", L"CD
|
|||
// Some forward declarations to make it easy to logically group the code.
|
||||
static void init_locale();
|
||||
static void init_curses();
|
||||
static void tokenize_variable_array(const wcstring &val, wcstring_list_t &out);
|
||||
|
||||
// Struct representing one level in the function variable stack.
|
||||
// Only our variable stack should create and destroy these
|
||||
|
@ -1622,7 +1621,7 @@ std::unique_ptr<wcstring> list_to_array_val(const wchar_t **list) {
|
|||
return val;
|
||||
}
|
||||
|
||||
static void tokenize_variable_array(const wcstring &val, wcstring_list_t &out) {
|
||||
void tokenize_variable_array(const wcstring &val, wcstring_list_t &out) {
|
||||
out.clear(); // ensure the output var is empty -- this will normally be a no-op
|
||||
|
||||
// Zero element arrays are internally encoded as this placeholder string.
|
||||
|
|
|
@ -69,6 +69,12 @@ void env_init(const struct config_paths_t *paths = NULL);
|
|||
/// routines.
|
||||
void misc_init();
|
||||
|
||||
/// Tokenize the specified string into the specified wcstring_list_t.
|
||||
///
|
||||
/// \param val the input string. The contents of this string is not changed.
|
||||
/// \param out the list in which to place the elements.
|
||||
void tokenize_variable_array(const wcstring &val, wcstring_list_t &out);
|
||||
|
||||
class env_var_t {
|
||||
private:
|
||||
bool is_missing;
|
||||
|
|
|
@ -168,11 +168,11 @@ static int is_quotable(const wchar_t *str) {
|
|||
|
||||
static int is_quotable(const wcstring &str) { return is_quotable(str.c_str()); }
|
||||
|
||||
wcstring expand_escape_variable(const env_var_t &var) {
|
||||
wcstring expand_escape_variable(const wcstring &in) {
|
||||
wcstring_list_t lst;
|
||||
wcstring buff;
|
||||
|
||||
var.to_list(lst);
|
||||
tokenize_variable_array(in, lst);
|
||||
|
||||
size_t size = lst.size();
|
||||
if (size == 0) {
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
#include <vector>
|
||||
|
||||
#include "common.h"
|
||||
#include "env.h"
|
||||
#include "parse_constants.h"
|
||||
|
||||
enum {
|
||||
|
@ -121,10 +120,10 @@ __warn_unused expand_error_t expand_string(const wcstring &input, std::vector<co
|
|||
bool expand_one(wcstring &inout_str, expand_flags_t flags, parse_error_list_t *errors = NULL);
|
||||
|
||||
/// Convert the variable value to a human readable form, i.e. escape things, handle arrays, etc.
|
||||
/// Suitable for pretty-printing.
|
||||
/// Suitable for pretty-printing. The result must be free'd!
|
||||
///
|
||||
/// \param in the value to escape
|
||||
wcstring expand_escape_variable(const env_var_t &var);
|
||||
wcstring expand_escape_variable(const wcstring &in);
|
||||
|
||||
/// Perform tilde expansion and nothing else on the specified string, which is modified in place.
|
||||
///
|
||||
|
|
|
@ -78,12 +78,13 @@ static int load(const wcstring &name) {
|
|||
static void autoload_names(std::set<wcstring> &names, int get_hidden) {
|
||||
size_t i;
|
||||
|
||||
const env_var_t path_var = env_get(L"fish_function_path");
|
||||
if (path_var.missing_or_empty()) return;
|
||||
const env_var_t path_var_wstr = env_get(L"fish_function_path");
|
||||
if (path_var_wstr.missing()) return;
|
||||
const wchar_t *path_var = path_var_wstr.c_str();
|
||||
|
||||
wcstring_list_t path_list;
|
||||
path_var.to_list(path_list);
|
||||
|
||||
tokenize_variable_array(path_var, path_list);
|
||||
for (i = 0; i < path_list.size(); i++) {
|
||||
const wcstring &ndir_str = path_list.at(i);
|
||||
const wchar_t *ndir = (wchar_t *)ndir_str.c_str();
|
||||
|
|
|
@ -274,14 +274,14 @@ rgb_color_t highlight_get_color(highlight_spec_t highlight, bool is_background)
|
|||
|
||||
if (var.missing()) var = env_get(highlight_var[0]);
|
||||
|
||||
if (!var.missing()) result = parse_color(var, treat_as_background);
|
||||
if (!var.missing()) result = parse_color(var.as_string(), treat_as_background);
|
||||
|
||||
// Handle modifiers.
|
||||
if (highlight & highlight_modifier_valid_path) {
|
||||
env_var_t var2 = env_get(L"fish_color_valid_path");
|
||||
const wcstring val2 = var2.missing() ? L"" : var2.c_str();
|
||||
env_var_t val2_wstr = env_get(L"fish_color_valid_path");
|
||||
const wcstring val2 = val2_wstr.missing() ? L"" : val2_wstr.c_str();
|
||||
|
||||
rgb_color_t result2 = parse_color(var2, is_background);
|
||||
rgb_color_t result2 = parse_color(val2, is_background);
|
||||
if (result.is_normal())
|
||||
result = result2;
|
||||
else {
|
||||
|
|
|
@ -486,8 +486,8 @@ rgb_color_t best_color(const std::vector<rgb_color_t> &candidates, color_support
|
|||
}
|
||||
|
||||
/// Return the internal color code representing the specified color.
|
||||
/// TODO: This code should be refactored to enable sharing with builtin_set_color.
|
||||
rgb_color_t parse_color(const env_var_t &var, bool is_background) {
|
||||
/// XXX This code should be refactored to enable sharing with builtin_set_color.
|
||||
rgb_color_t parse_color(const wcstring &val, bool is_background) {
|
||||
int is_bold = 0;
|
||||
int is_underline = 0;
|
||||
int is_italics = 0;
|
||||
|
@ -497,7 +497,7 @@ rgb_color_t parse_color(const env_var_t &var, bool is_background) {
|
|||
std::vector<rgb_color_t> candidates;
|
||||
|
||||
wcstring_list_t el;
|
||||
var.to_list(el);
|
||||
tokenize_variable_array(val, el);
|
||||
|
||||
for (size_t j = 0; j < el.size(); j++) {
|
||||
const wcstring &next = el.at(j);
|
||||
|
|
|
@ -36,7 +36,7 @@ int writech(wint_t ch);
|
|||
|
||||
void writestr(const wchar_t *str);
|
||||
|
||||
rgb_color_t parse_color(const env_var_t &val, bool is_background);
|
||||
rgb_color_t parse_color(const wcstring &val, bool is_background);
|
||||
|
||||
int writeb(tputs_arg_t b);
|
||||
|
||||
|
|
|
@ -60,8 +60,8 @@ static bool path_get_path_core(const wcstring &cmd, wcstring *out_path,
|
|||
bin_path = *list_to_array_val(wcstring_list_t({L"/bin", L"/usr/bin", PREFIX L"/bin"}));
|
||||
}
|
||||
|
||||
wcstring_list_t pathsv;
|
||||
bin_path_var.to_list(pathsv);
|
||||
std::vector<wcstring> pathsv;
|
||||
tokenize_variable_array(bin_path, pathsv);
|
||||
for (auto next_path : pathsv) {
|
||||
if (next_path.empty()) continue;
|
||||
append_path_component(next_path, cmd);
|
||||
|
|
Loading…
Reference in New Issue
Block a user