mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-29 06:13:20 +00:00
Restyle codebase with clang-format
This commit is contained in:
parent
20a1bf289f
commit
389b75fe42
33 changed files with 144 additions and 119 deletions
|
@ -350,7 +350,7 @@ struct source_range_visitor_t {
|
||||||
// Whether any node was found to be unsourced.
|
// Whether any node was found to be unsourced.
|
||||||
bool any_unsourced{false};
|
bool any_unsourced{false};
|
||||||
};
|
};
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
maybe_t<source_range_t> node_t::try_source_range() const {
|
maybe_t<source_range_t> node_t::try_source_range() const {
|
||||||
source_range_visitor_t v;
|
source_range_visitor_t v;
|
||||||
|
|
|
@ -180,8 +180,7 @@ void builtin_missing_argument(parser_t &parser, io_streams_t &streams, const wch
|
||||||
opt += std::wcslen(opt) - 1;
|
opt += std::wcslen(opt) - 1;
|
||||||
// now prepend - to output -c
|
// now prepend - to output -c
|
||||||
streams.err.append_format(BUILTIN_ERR_MISSING, cmd, wcstring(L"-").append(opt).c_str());
|
streams.err.append_format(BUILTIN_ERR_MISSING, cmd, wcstring(L"-").append(opt).c_str());
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
streams.err.append_format(BUILTIN_ERR_MISSING, cmd, opt);
|
streams.err.append_format(BUILTIN_ERR_MISSING, cmd, opt);
|
||||||
|
|
||||||
if (print_hints) {
|
if (print_hints) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ struct builtin_data_t {
|
||||||
#define BUILTIN_ERR_MISSING _(L"%ls: %ls: option requires an argument\n")
|
#define BUILTIN_ERR_MISSING _(L"%ls: %ls: option requires an argument\n")
|
||||||
|
|
||||||
/// Error message on missing man page.
|
/// Error message on missing man page.
|
||||||
#define BUILTIN_ERR_MISSING_HELP \
|
#define BUILTIN_ERR_MISSING_HELP \
|
||||||
_(L"fish: %ls: missing man page\nDocumentation may not be installed.\n`help %ls` will " \
|
_(L"fish: %ls: missing man page\nDocumentation may not be installed.\n`help %ls` will " \
|
||||||
L"show an online version\n")
|
L"show an online version\n")
|
||||||
|
|
||||||
|
@ -44,8 +44,7 @@ struct builtin_data_t {
|
||||||
#define BUILTIN_ERR_COMBO2_EXCLUSIVE _(L"%ls: %ls %ls: options cannot be used together\n")
|
#define BUILTIN_ERR_COMBO2_EXCLUSIVE _(L"%ls: %ls %ls: options cannot be used together\n")
|
||||||
|
|
||||||
/// Error message on multiple scope levels for variables.
|
/// Error message on multiple scope levels for variables.
|
||||||
#define BUILTIN_ERR_GLOCAL \
|
#define BUILTIN_ERR_GLOCAL _(L"%ls: scope can be only one of: universal function global local\n")
|
||||||
_(L"%ls: scope can be only one of: universal function global local\n")
|
|
||||||
|
|
||||||
/// Error message for specifying both export and unexport to set/read.
|
/// Error message for specifying both export and unexport to set/read.
|
||||||
#define BUILTIN_ERR_EXPUNEXP _(L"%ls: cannot both export and unexport\n")
|
#define BUILTIN_ERR_EXPUNEXP _(L"%ls: cannot both export and unexport\n")
|
||||||
|
|
|
@ -411,11 +411,13 @@ static int parse_cmd_opts(argparse_cmd_opts_t &opts, int *optind, //!OCLINT(hig
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ':': {
|
case ':': {
|
||||||
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1], /* print_hints */false);
|
builtin_missing_argument(parser, streams, cmd, argv[w.woptind - 1],
|
||||||
|
/* print_hints */ false);
|
||||||
return STATUS_INVALID_ARGS;
|
return STATUS_INVALID_ARGS;
|
||||||
}
|
}
|
||||||
case '?': {
|
case '?': {
|
||||||
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1], /* print_hints */false);
|
builtin_unknown_option(parser, streams, cmd, argv[w.woptind - 1],
|
||||||
|
/* print_hints */ false);
|
||||||
return STATUS_INVALID_ARGS;
|
return STATUS_INVALID_ARGS;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
|
|
@ -206,9 +206,8 @@ static int validate_function_name(int argc, const wchar_t *const *argv, wcstring
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parser_keywords_is_reserved(function_name)) {
|
if (parser_keywords_is_reserved(function_name)) {
|
||||||
streams.err.append_format(
|
streams.err.append_format(_(L"%ls: %ls: cannot use reserved keyword as function name"), cmd,
|
||||||
_(L"%ls: %ls: cannot use reserved keyword as function name"), cmd,
|
function_name.c_str());
|
||||||
function_name.c_str());
|
|
||||||
return STATUS_INVALID_ARGS;
|
return STATUS_INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,15 +21,23 @@
|
||||||
#include "wgetopt.h"
|
#include "wgetopt.h"
|
||||||
#include "wutil.h" // IWYU pragma: keep
|
#include "wutil.h" // IWYU pragma: keep
|
||||||
|
|
||||||
enum hist_cmd_t { HIST_SEARCH = 1, HIST_DELETE, HIST_CLEAR, HIST_MERGE, HIST_SAVE, HIST_UNDEF,
|
enum hist_cmd_t {
|
||||||
HIST_CLEAR_SESSION };
|
HIST_SEARCH = 1,
|
||||||
|
HIST_DELETE,
|
||||||
|
HIST_CLEAR,
|
||||||
|
HIST_MERGE,
|
||||||
|
HIST_SAVE,
|
||||||
|
HIST_UNDEF,
|
||||||
|
HIST_CLEAR_SESSION
|
||||||
|
};
|
||||||
|
|
||||||
// Must be sorted by string, not enum or random.
|
// Must be sorted by string, not enum or random.
|
||||||
static const enum_map<hist_cmd_t> hist_enum_map[] = {
|
static const enum_map<hist_cmd_t> hist_enum_map[] = {
|
||||||
{HIST_CLEAR, L"clear"}, {HIST_CLEAR_SESSION, L"clear-session"},
|
{HIST_CLEAR, L"clear"}, {HIST_CLEAR_SESSION, L"clear-session"},
|
||||||
{HIST_DELETE, L"delete"}, {HIST_MERGE, L"merge"},
|
{HIST_DELETE, L"delete"}, {HIST_MERGE, L"merge"},
|
||||||
{HIST_SAVE, L"save"}, {HIST_SEARCH, L"search"},
|
{HIST_SAVE, L"save"}, {HIST_SEARCH, L"search"},
|
||||||
{HIST_UNDEF, nullptr}, };
|
{HIST_UNDEF, nullptr},
|
||||||
|
};
|
||||||
|
|
||||||
struct history_cmd_opts_t {
|
struct history_cmd_opts_t {
|
||||||
hist_cmd_t hist_cmd = HIST_UNDEF;
|
hist_cmd_t hist_cmd = HIST_UNDEF;
|
||||||
|
@ -82,8 +90,7 @@ static bool check_for_unexpected_hist_args(const history_cmd_opts_t &opts, const
|
||||||
const wcstring_list_t &args, io_streams_t &streams) {
|
const wcstring_list_t &args, io_streams_t &streams) {
|
||||||
if (opts.history_search_type_defined || opts.show_time_format || opts.null_terminate) {
|
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);
|
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,
|
streams.err.append_format(_(L"%ls: %ls: subcommand takes no options\n"), cmd, subcmd_str);
|
||||||
subcmd_str);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!args.empty()) {
|
if (!args.empty()) {
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
#include "builtin_read.h"
|
#include "builtin_read.h"
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
|
@ -392,8 +392,8 @@ static int validate_read_args(const wchar_t *cmd, read_cmd_opts_t &opts, int arg
|
||||||
return STATUS_INVALID_ARGS;
|
return STATUS_INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((opts.place & ENV_LOCAL ? 1 : 0) + (opts.place & ENV_FUNCTION ? 1 : 0) + (opts.place & ENV_GLOBAL ? 1 : 0) +
|
if ((opts.place & ENV_LOCAL ? 1 : 0) + (opts.place & ENV_FUNCTION ? 1 : 0) +
|
||||||
(opts.place & ENV_UNIVERSAL ? 1 : 0) >
|
(opts.place & ENV_GLOBAL ? 1 : 0) + (opts.place & ENV_UNIVERSAL ? 1 : 0) >
|
||||||
1) {
|
1) {
|
||||||
streams.err.append_format(BUILTIN_ERR_GLOCAL, cmd);
|
streams.err.append_format(BUILTIN_ERR_GLOCAL, cmd);
|
||||||
builtin_print_error_trailer(parser, streams.err, cmd);
|
builtin_print_error_trailer(parser, streams.err, cmd);
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// Functions used for implementing the set builtin.
|
// Functions used for implementing the set builtin.
|
||||||
#include "config.h" // IWYU pragma: keep
|
#include "config.h" // IWYU pragma: keep
|
||||||
|
|
||||||
|
#include "builtin_set.h"
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
@ -17,7 +19,6 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "builtin.h"
|
#include "builtin.h"
|
||||||
#include "builtin_set.h"
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "env.h"
|
#include "env.h"
|
||||||
#include "expand.h"
|
#include "expand.h"
|
||||||
|
@ -60,16 +61,23 @@ enum {
|
||||||
// (REQUIRE_ORDER) option for flag parsing. This is not typical of most fish commands. It means
|
// (REQUIRE_ORDER) option for flag parsing. This is not typical of most fish commands. It means
|
||||||
// we stop scanning for flags when the first non-flag argument is seen.
|
// we stop scanning for flags when the first non-flag argument is seen.
|
||||||
static const wchar_t *const short_options = L"+:LSUaefghlnpqux";
|
static const wchar_t *const short_options = L"+:LSUaefghlnpqux";
|
||||||
static const struct woption long_options[] = {
|
static const struct woption long_options[] = {{L"export", no_argument, nullptr, 'x'},
|
||||||
{L"export", no_argument, nullptr, 'x'}, {L"global", no_argument, nullptr, 'g'},
|
{L"global", no_argument, nullptr, 'g'},
|
||||||
{L"function", no_argument, nullptr, 'f'},
|
{L"function", no_argument, nullptr, 'f'},
|
||||||
{L"local", no_argument, nullptr, 'l'}, {L"erase", no_argument, nullptr, 'e'},
|
{L"local", no_argument, nullptr, 'l'},
|
||||||
{L"names", no_argument, nullptr, 'n'}, {L"unexport", no_argument, nullptr, 'u'},
|
{L"erase", no_argument, nullptr, 'e'},
|
||||||
{L"universal", no_argument, nullptr, 'U'}, {L"long", no_argument, nullptr, 'L'},
|
{L"names", no_argument, nullptr, 'n'},
|
||||||
{L"query", no_argument, nullptr, 'q'}, {L"show", no_argument, nullptr, 'S'},
|
{L"unexport", no_argument, nullptr, 'u'},
|
||||||
{L"append", no_argument, nullptr, 'a'}, {L"prepend", no_argument, nullptr, 'p'},
|
{L"universal", no_argument, nullptr, 'U'},
|
||||||
{L"path", no_argument, nullptr, opt_path}, {L"unpath", no_argument, nullptr, opt_unpath},
|
{L"long", no_argument, nullptr, 'L'},
|
||||||
{L"help", no_argument, nullptr, 'h'}, {nullptr, 0, nullptr, 0}};
|
{L"query", no_argument, nullptr, 'q'},
|
||||||
|
{L"show", no_argument, nullptr, 'S'},
|
||||||
|
{L"append", no_argument, nullptr, 'a'},
|
||||||
|
{L"prepend", no_argument, nullptr, 'p'},
|
||||||
|
{L"path", no_argument, nullptr, opt_path},
|
||||||
|
{L"unpath", no_argument, nullptr, opt_unpath},
|
||||||
|
{L"help", no_argument, nullptr, 'h'},
|
||||||
|
{nullptr, 0, nullptr, 0}};
|
||||||
|
|
||||||
// Hint for invalid path operation with a colon.
|
// Hint for invalid path operation with a colon.
|
||||||
#define BUILTIN_SET_MISMATCHED_ARGS _(L"%ls: You provided %d indexes but %d values\n")
|
#define BUILTIN_SET_MISMATCHED_ARGS _(L"%ls: You provided %d indexes but %d values\n")
|
||||||
|
@ -218,8 +226,8 @@ static int validate_cmd_opts(const wchar_t *cmd,
|
||||||
}
|
}
|
||||||
|
|
||||||
// The --show flag cannot be combined with any other flag.
|
// The --show flag cannot be combined with any other flag.
|
||||||
if (opts.show &&
|
if (opts.show && (opts.local || opts.function || opts.global || opts.erase || opts.list ||
|
||||||
(opts.local || opts.function || opts.global || opts.erase || opts.list || opts.exportv || opts.universal)) {
|
opts.exportv || opts.universal)) {
|
||||||
streams.err.append_format(BUILTIN_ERR_COMBO, cmd);
|
streams.err.append_format(BUILTIN_ERR_COMBO, cmd);
|
||||||
builtin_print_error_trailer(parser, streams.err, cmd);
|
builtin_print_error_trailer(parser, streams.err, cmd);
|
||||||
return STATUS_INVALID_ARGS;
|
return STATUS_INVALID_ARGS;
|
||||||
|
@ -315,7 +323,8 @@ struct split_var_t {
|
||||||
/// a split var on success, none() on error, in which case an error will have been printed.
|
/// a split var on success, none() on error, in which case an error will have been printed.
|
||||||
/// If no index is found, this leaves indexes empty.
|
/// If no index is found, this leaves indexes empty.
|
||||||
static maybe_t<split_var_t> split_var_and_indexes(const wchar_t *arg, env_mode_flags_t mode,
|
static maybe_t<split_var_t> split_var_and_indexes(const wchar_t *arg, env_mode_flags_t mode,
|
||||||
const environment_t &vars, io_streams_t &streams) {
|
const environment_t &vars,
|
||||||
|
io_streams_t &streams) {
|
||||||
split_var_t res{};
|
split_var_t res{};
|
||||||
const wchar_t *open_bracket = std::wcschr(arg, L'[');
|
const wchar_t *open_bracket = std::wcschr(arg, L'[');
|
||||||
size_t varname_len = open_bracket ? open_bracket - arg : wcslen(arg);
|
size_t varname_len = open_bracket ? open_bracket - arg : wcslen(arg);
|
||||||
|
@ -754,7 +763,8 @@ static int builtin_set_set(const wchar_t *cmd, set_cmd_opts_t &opts, int argc, c
|
||||||
new_values = new_var_values_by_index(*split, argc, argv);
|
new_values = new_var_values_by_index(*split, argc, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool have_shadowing_global = check_global_scope_exists(cmd, opts, split->varname, streams, parser);
|
bool have_shadowing_global =
|
||||||
|
check_global_scope_exists(cmd, opts, split->varname, streams, parser);
|
||||||
// Set the value back in the variable stack and fire any events.
|
// Set the value back in the variable stack and fire any events.
|
||||||
int retval = env_set_reporting_errors(cmd, split->varname, scope, std::move(new_values),
|
int retval = env_set_reporting_errors(cmd, split->varname, scope, std::move(new_values),
|
||||||
streams, parser);
|
streams, parser);
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cwchar>
|
#include <cwchar>
|
||||||
|
|
||||||
#include "maybe.h"
|
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
|
#include "maybe.h"
|
||||||
|
|
||||||
class parser_t;
|
class parser_t;
|
||||||
|
|
||||||
|
|
|
@ -1974,4 +1974,3 @@ bool is_console_session() {
|
||||||
}();
|
}();
|
||||||
return console_session;
|
return console_session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -216,7 +216,7 @@ extern const wcstring g_empty_string;
|
||||||
#define DIE_ON_FAILURE(e) \
|
#define DIE_ON_FAILURE(e) \
|
||||||
do { \
|
do { \
|
||||||
int status = e; \
|
int status = e; \
|
||||||
if (unlikely(status != 0)) { \
|
if (unlikely(status != 0)) { \
|
||||||
__fish_assert(#e, __FILE__, __LINE__, status); \
|
__fish_assert(#e, __FILE__, __LINE__, status); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
@ -702,8 +702,7 @@ const T *get_by_sorted_name(const wcstring &name, const T (&vals)[N]) {
|
||||||
/// As established in 1ab81ab90d1a408702e11f081fdaaafa30636c31, iswdigit() is very slow under glibc,
|
/// As established in 1ab81ab90d1a408702e11f081fdaaafa30636c31, iswdigit() is very slow under glibc,
|
||||||
/// and does nothing more than establish whether or not the single specified character is in the
|
/// and does nothing more than establish whether or not the single specified character is in the
|
||||||
/// range ('0','9').
|
/// range ('0','9').
|
||||||
__attribute__((always_inline))
|
__attribute__((always_inline)) bool inline iswdigit(const wchar_t c) {
|
||||||
bool inline iswdigit(const wchar_t c) {
|
|
||||||
return c >= L'0' && c <= L'9';
|
return c >= L'0' && c <= L'9';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1046,9 +1046,8 @@ void env_stack_impl_t::set_in_node(const env_node_ref_t &node, const wcstring &k
|
||||||
val = colon_split(val);
|
val = colon_split(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
var = var.setting_vals(std::move(val))
|
var =
|
||||||
.setting_exports(res_exports)
|
var.setting_vals(std::move(val)).setting_exports(res_exports).setting_pathvar(res_pathvar);
|
||||||
.setting_pathvar(res_pathvar);
|
|
||||||
|
|
||||||
// Perhaps mark that this node contains an exported variable, or shadows an exported variable.
|
// Perhaps mark that this node contains an exported variable, or shadows an exported variable.
|
||||||
// If so regenerate the export list.
|
// If so regenerate the export list.
|
||||||
|
|
|
@ -81,7 +81,8 @@ struct statuses_t {
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Initialize environment variable data.
|
/// Initialize environment variable data.
|
||||||
void env_init(const struct config_paths_t *paths = nullptr, bool do_uvars = true, bool default_paths = false);
|
void env_init(const struct config_paths_t *paths = nullptr, bool do_uvars = true,
|
||||||
|
bool default_paths = false);
|
||||||
|
|
||||||
/// Various things we need to initialize at run-time that don't really fit any of the other init
|
/// Various things we need to initialize at run-time that don't really fit any of the other init
|
||||||
/// routines.
|
/// routines.
|
||||||
|
|
|
@ -61,11 +61,23 @@
|
||||||
|
|
||||||
/// List of all locale environment variable names that might trigger (re)initializing the locale
|
/// List of all locale environment variable names that might trigger (re)initializing the locale
|
||||||
/// subsystem.
|
/// subsystem.
|
||||||
static const wcstring locale_variables[] = {
|
static const wcstring locale_variables[] = {L"LANG",
|
||||||
L"LANG", L"LANGUAGE", L"LC_ALL", L"LC_ADDRESS", L"LC_COLLATE",
|
L"LANGUAGE",
|
||||||
L"LC_CTYPE", L"LC_IDENTIFICATION", L"LC_MEASUREMENT", L"LC_MESSAGES", L"LC_MONETARY",
|
L"LC_ALL",
|
||||||
L"LC_NAME", L"LC_NUMERIC", L"LC_PAPER", L"LC_TELEPHONE", L"LC_TIME",
|
L"LC_ADDRESS",
|
||||||
L"fish_allow_singlebyte_locale", L"LOCPATH"};
|
L"LC_COLLATE",
|
||||||
|
L"LC_CTYPE",
|
||||||
|
L"LC_IDENTIFICATION",
|
||||||
|
L"LC_MEASUREMENT",
|
||||||
|
L"LC_MESSAGES",
|
||||||
|
L"LC_MONETARY",
|
||||||
|
L"LC_NAME",
|
||||||
|
L"LC_NUMERIC",
|
||||||
|
L"LC_PAPER",
|
||||||
|
L"LC_TELEPHONE",
|
||||||
|
L"LC_TIME",
|
||||||
|
L"fish_allow_singlebyte_locale",
|
||||||
|
L"LOCPATH"};
|
||||||
|
|
||||||
/// List of all curses environment variable names that might trigger (re)initializing the curses
|
/// List of all curses environment variable names that might trigger (re)initializing the curses
|
||||||
/// subsystem.
|
/// subsystem.
|
||||||
|
@ -154,7 +166,7 @@ static void handle_timezone(const wchar_t *env_var_name, const environment_t &va
|
||||||
static void guess_emoji_width(const environment_t &vars) {
|
static void guess_emoji_width(const environment_t &vars) {
|
||||||
if (auto width_str = vars.get(L"fish_emoji_width")) {
|
if (auto width_str = vars.get(L"fish_emoji_width")) {
|
||||||
int new_width = fish_wcstol(width_str->as_string().c_str());
|
int new_width = fish_wcstol(width_str->as_string().c_str());
|
||||||
g_fish_emoji_width = std::min(2,std::max(1, new_width));
|
g_fish_emoji_width = std::min(2, std::max(1, new_width));
|
||||||
FLOGF(term_support, "'fish_emoji_width' preference: %d, overwriting default",
|
FLOGF(term_support, "'fish_emoji_width' preference: %d, overwriting default",
|
||||||
g_fish_emoji_width);
|
g_fish_emoji_width);
|
||||||
return;
|
return;
|
||||||
|
@ -183,7 +195,7 @@ static void guess_emoji_width(const environment_t &vars) {
|
||||||
// Default to whatever system wcwidth says to U+1F603,
|
// Default to whatever system wcwidth says to U+1F603,
|
||||||
// but only if it's at least 1 and at most 2.
|
// but only if it's at least 1 and at most 2.
|
||||||
int w = wcwidth(L'😃');
|
int w = wcwidth(L'😃');
|
||||||
g_fish_emoji_width = std::min(2,std::max(1, w));
|
g_fish_emoji_width = std::min(2, std::max(1, w));
|
||||||
FLOGF(term_support, "default emoji width: %d", g_fish_emoji_width);
|
FLOGF(term_support, "default emoji width: %d", g_fish_emoji_width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -495,9 +507,8 @@ static bool initialize_curses_using_fallback(const char *term) {
|
||||||
/// One situation in which this breaks down is with screen, since screen supports setting the
|
/// One situation in which this breaks down is with screen, since screen supports setting the
|
||||||
/// terminal title if the underlying terminal does so, but will print garbage on terminals that
|
/// terminal title if the underlying terminal does so, but will print garbage on terminals that
|
||||||
/// don't. Since we can't see the underlying terminal below screen there is no way to fix this.
|
/// don't. Since we can't see the underlying terminal below screen there is no way to fix this.
|
||||||
static const wchar_t *const title_terms[] = {L"xterm", L"screen", L"tmux",
|
static const wchar_t *const title_terms[] = {L"xterm", L"screen", L"tmux", L"nxterm",
|
||||||
L"nxterm", L"rxvt", L"alacritty",
|
L"rxvt", L"alacritty", L"wezterm"};
|
||||||
L"wezterm"};
|
|
||||||
static bool does_term_support_setting_title(const environment_t &vars) {
|
static bool does_term_support_setting_title(const environment_t &vars) {
|
||||||
const auto term_var = vars.get(L"TERM");
|
const auto term_var = vars.get(L"TERM");
|
||||||
if (term_var.missing_or_empty()) return false;
|
if (term_var.missing_or_empty()) return false;
|
||||||
|
@ -567,12 +578,7 @@ static void init_curses(const environment_t &vars) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr const char *utf8_locales[] = {
|
static constexpr const char *utf8_locales[] = {
|
||||||
"C.UTF-8",
|
"C.UTF-8", "en_US.UTF-8", "en_GB.UTF-8", "de_DE.UTF-8", "C.utf8", "UTF-8",
|
||||||
"en_US.UTF-8",
|
|
||||||
"en_GB.UTF-8",
|
|
||||||
"de_DE.UTF-8",
|
|
||||||
"C.utf8",
|
|
||||||
"UTF-8",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Initialize the locale subsystem.
|
/// Initialize the locale subsystem.
|
||||||
|
|
|
@ -395,7 +395,6 @@ bool env_universal_t::load_from_path(const wcstring &path, callback_data_list_t
|
||||||
}
|
}
|
||||||
|
|
||||||
bool env_universal_t::load_from_path(const std::string &path, callback_data_list_t &callbacks) {
|
bool env_universal_t::load_from_path(const std::string &path, callback_data_list_t &callbacks) {
|
||||||
|
|
||||||
// Check to see if the file is unchanged. We do this again in load_from_fd, but this avoids
|
// Check to see if the file is unchanged. We do this again in load_from_fd, but this avoids
|
||||||
// opening the file unnecessarily.
|
// opening the file unnecessarily.
|
||||||
if (last_read_file != kInvalidFileID && file_id_for_path(path) == last_read_file) {
|
if (last_read_file != kInvalidFileID && file_id_for_path(path) == last_read_file) {
|
||||||
|
|
|
@ -183,8 +183,8 @@ enum class parse_slice_error_t {
|
||||||
/// Parse an array slicing specification Returns 0 on success. If a parse error occurs, returns the
|
/// Parse an array slicing specification Returns 0 on success. If a parse error occurs, returns the
|
||||||
/// index of the bad token. Note that 0 can never be a bad index because the string always starts
|
/// index of the bad token. Note that 0 can never be a bad index because the string always starts
|
||||||
/// with [.
|
/// with [.
|
||||||
static size_t parse_slice(const wchar_t * const in, wchar_t ** const end_ptr,
|
static size_t parse_slice(const wchar_t *const in, wchar_t **const end_ptr, std::vector<long> &idx,
|
||||||
std::vector<long> &idx, size_t array_size, parse_slice_error_t * const error) {
|
size_t array_size, parse_slice_error_t *const error) {
|
||||||
const long size = static_cast<long>(array_size);
|
const long size = static_cast<long>(array_size);
|
||||||
size_t pos = 1; // skip past the opening square brace
|
size_t pos = 1; // skip past the opening square brace
|
||||||
|
|
||||||
|
@ -213,9 +213,9 @@ static size_t parse_slice(const wchar_t * const in, wchar_t ** const end_ptr,
|
||||||
*error = parse_slice_error_t::invalid_index;
|
*error = parse_slice_error_t::invalid_index;
|
||||||
return pos;
|
return pos;
|
||||||
} else if (tmp == 0) {
|
} else if (tmp == 0) {
|
||||||
// Explicitly refuse $foo[0] as valid syntax, regardless of whether or not we're going
|
// Explicitly refuse $foo[0] as valid syntax, regardless of whether or not we're
|
||||||
// to show an error if the index ultimately evaluates to zero. This will help newcomers
|
// going to show an error if the index ultimately evaluates to zero. This will help
|
||||||
// to fish avoid a common off-by-one error. See #4862.
|
// newcomers to fish avoid a common off-by-one error. See #4862.
|
||||||
*error = parse_slice_error_t::zero_index;
|
*error = parse_slice_error_t::zero_index;
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
@ -384,7 +384,8 @@ static expand_result_t expand_variables(wcstring instr, completion_receiver_t *o
|
||||||
effective_val_count = history->size();
|
effective_val_count = history->size();
|
||||||
}
|
}
|
||||||
parse_slice_error_t parse_error;
|
parse_slice_error_t parse_error;
|
||||||
size_t bad_pos = parse_slice(in + slice_start, &slice_end, var_idx_list, effective_val_count, &parse_error);
|
size_t bad_pos = parse_slice(in + slice_start, &slice_end, var_idx_list,
|
||||||
|
effective_val_count, &parse_error);
|
||||||
if (bad_pos != 0) {
|
if (bad_pos != 0) {
|
||||||
switch (parse_error) {
|
switch (parse_error) {
|
||||||
case parse_slice_error_t::none:
|
case parse_slice_error_t::none:
|
||||||
|
@ -684,7 +685,8 @@ static expand_result_t expand_cmdsubst(wcstring input, const operation_context_t
|
||||||
const wchar_t *const slice_begin = in + tail_begin;
|
const wchar_t *const slice_begin = in + tail_begin;
|
||||||
wchar_t *slice_end = nullptr;
|
wchar_t *slice_end = nullptr;
|
||||||
parse_slice_error_t parse_error;
|
parse_slice_error_t parse_error;
|
||||||
size_t bad_pos = parse_slice(slice_begin, &slice_end, slice_idx, sub_res.size(), &parse_error);
|
size_t bad_pos =
|
||||||
|
parse_slice(slice_begin, &slice_end, slice_idx, sub_res.size(), &parse_error);
|
||||||
if (bad_pos != 0) {
|
if (bad_pos != 0) {
|
||||||
switch (parse_error) {
|
switch (parse_error) {
|
||||||
case parse_slice_error_t::none:
|
case parse_slice_error_t::none:
|
||||||
|
|
|
@ -167,4 +167,4 @@ double wcstod_l(const wchar_t *enptr, wchar_t **endptr, locale_t loc);
|
||||||
#define wcstod_l(x, y, z) fish_compat::wcstod_l(x, y, z)
|
#define wcstod_l(x, y, z) fish_compat::wcstod_l(x, y, z)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // FISH_FALLBACK_H
|
#endif // FISH_FALLBACK_H
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#include <sys/eventfd.h>
|
#include <sys/eventfd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// The first fd in the "high range." fds below this are allowed to be used directly by users in
|
// The first fd in the "high range." fds below this are allowed to be used directly by users in
|
||||||
// redirections, e.g. >&3
|
// redirections, e.g. >&3
|
||||||
const int k_first_high_fd = 10;
|
const int k_first_high_fd = 10;
|
||||||
|
|
|
@ -50,8 +50,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
#include "history.h"
|
#include "history.h"
|
||||||
#include "intern.h"
|
#include "intern.h"
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
#include "parser.h"
|
|
||||||
#include "parse_util.h"
|
#include "parse_util.h"
|
||||||
|
#include "parser.h"
|
||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include "proc.h"
|
#include "proc.h"
|
||||||
#include "reader.h"
|
#include "reader.h"
|
||||||
|
@ -266,7 +266,8 @@ static int run_command_list(parser_t &parser, std::vector<std::string> *cmds,
|
||||||
if (!errored) {
|
if (!errored) {
|
||||||
// Construct a parsed source ref.
|
// Construct a parsed source ref.
|
||||||
// Be careful to transfer ownership, this could be a very large string.
|
// Be careful to transfer ownership, this could be a very large string.
|
||||||
parsed_source_ref_t ps = std::make_shared<parsed_source_t>(std::move(cmd_wcs), std::move(ast));
|
parsed_source_ref_t ps =
|
||||||
|
std::make_shared<parsed_source_t>(std::move(cmd_wcs), std::move(ast));
|
||||||
parser.eval(ps, io);
|
parser.eval(ps, io);
|
||||||
} else {
|
} else {
|
||||||
wcstring sb;
|
wcstring sb;
|
||||||
|
|
|
@ -135,8 +135,8 @@ static void print_ignored_signals() {
|
||||||
|
|
||||||
static void print_stop_cont() {
|
static void print_stop_cont() {
|
||||||
signal(SIGTSTP, [](int) {
|
signal(SIGTSTP, [](int) {
|
||||||
// C++ compilers are awful and this is the dance we need to do to silence the "Unused result" warning.
|
// C++ compilers are awful and this is the dance we need to do to silence the "Unused
|
||||||
// No, casting to (void) does *not* work. Please leave this.
|
// result" warning. No, casting to (void) does *not* work. Please leave this.
|
||||||
auto __attribute__((unused)) _ = write(STDOUT_FILENO, "SIGTSTP\n", strlen("SIGTSTP\n"));
|
auto __attribute__((unused)) _ = write(STDOUT_FILENO, "SIGTSTP\n", strlen("SIGTSTP\n"));
|
||||||
kill(getpid(), SIGSTOP);
|
kill(getpid(), SIGSTOP);
|
||||||
});
|
});
|
||||||
|
|
|
@ -5507,7 +5507,6 @@ static void test_highlighting() {
|
||||||
{L"# comment", highlight_role_t::comment},
|
{L"# comment", highlight_role_t::comment},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
highlight_tests.push_back({
|
highlight_tests.push_back({
|
||||||
{L"echo", highlight_role_t::command},
|
{L"echo", highlight_role_t::command},
|
||||||
{L"--", highlight_role_t::option},
|
{L"--", highlight_role_t::option},
|
||||||
|
@ -5580,13 +5579,15 @@ static void test_highlighting() {
|
||||||
auto e_col = expected_colors.at(i);
|
auto e_col = expected_colors.at(i);
|
||||||
auto a_col = colors.at(i);
|
auto a_col = colors.at(i);
|
||||||
auto j = i + 1;
|
auto j = i + 1;
|
||||||
while (j < colors.size() && expected_colors.at(j) == e_col && colors.at(j) == a_col) j++;
|
while (j < colors.size() && expected_colors.at(j) == e_col && colors.at(j) == a_col)
|
||||||
|
j++;
|
||||||
if (j == colors.size() - 1) j++;
|
if (j == colors.size() - 1) j++;
|
||||||
const wcstring spaces(i, L' ');
|
const wcstring spaces(i, L' ');
|
||||||
const wcstring carets(j - i, L'^');
|
const wcstring carets(j - i, L'^');
|
||||||
err(L"Wrong color in test at index %lu-%lu in text (expected %#x, actual "
|
err(L"Wrong color in test at index %lu-%lu in text (expected %#x, actual "
|
||||||
L"%#x):\n%ls\n%ls%ls",
|
L"%#x):\n%ls\n%ls%ls",
|
||||||
i, j - 1, expected_colors.at(i), colors.at(i), text.c_str(), spaces.c_str(), carets.c_str());
|
i, j - 1, expected_colors.at(i), colors.at(i), text.c_str(), spaces.c_str(),
|
||||||
|
carets.c_str());
|
||||||
i = j;
|
i = j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -523,9 +523,8 @@ static size_t color_variable(const wchar_t *in, size_t in_len,
|
||||||
static void color_string_internal(const wcstring &buffstr, highlight_spec_t base_color,
|
static void color_string_internal(const wcstring &buffstr, highlight_spec_t base_color,
|
||||||
std::vector<highlight_spec_t>::iterator colors) {
|
std::vector<highlight_spec_t>::iterator colors) {
|
||||||
// Clarify what we expect.
|
// Clarify what we expect.
|
||||||
assert((base_color == highlight_role_t::param
|
assert((base_color == highlight_role_t::param || base_color == highlight_role_t::option ||
|
||||||
|| base_color == highlight_role_t::option
|
base_color == highlight_role_t::command) &&
|
||||||
|| base_color == highlight_role_t::command) &&
|
|
||||||
"Unexpected base color");
|
"Unexpected base color");
|
||||||
const size_t buff_len = buffstr.size();
|
const size_t buff_len = buffstr.size();
|
||||||
std::fill(colors, colors + buff_len, base_color);
|
std::fill(colors, colors + buff_len, base_color);
|
||||||
|
@ -853,7 +852,7 @@ void highlighter_t::color_command(const ast::string_t &node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// node does not necessarily have type symbol_argument here.
|
// node does not necessarily have type symbol_argument here.
|
||||||
void highlighter_t::color_as_argument(const ast::node_t &node, bool options_allowed) {
|
void highlighter_t::color_as_argument(const ast::node_t &node, bool options_allowed) {
|
||||||
auto source_range = node.source_range();
|
auto source_range = node.source_range();
|
||||||
const wcstring arg_str = get_source(source_range);
|
const wcstring arg_str = get_source(source_range);
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,6 @@ maybe_t<wcstring> history_filename(const wcstring &session_id, const wcstring &s
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
class history_lru_cache_t : public lru_cache_t<history_item_t> {
|
class history_lru_cache_t : public lru_cache_t<history_item_t> {
|
||||||
|
@ -1091,7 +1090,7 @@ void history_impl_t::clear() {
|
||||||
|
|
||||||
void history_impl_t::clear_session() {
|
void history_impl_t::clear_session() {
|
||||||
for (const auto &item : new_items) {
|
for (const auto &item : new_items) {
|
||||||
deleted_items.insert(std::pair<wcstring,bool>(item.str(), true));
|
deleted_items.insert(std::pair<wcstring, bool>(item.str(), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
new_items.clear();
|
new_items.clear();
|
||||||
|
|
|
@ -89,7 +89,6 @@ class lru_cache_t {
|
||||||
evict_node(static_cast<lru_node_t *>(mouth.prev));
|
evict_node(static_cast<lru_node_t *>(mouth.prev));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Implementation of merge step for mergesort.
|
// Implementation of merge step for mergesort.
|
||||||
// Given two singly linked lists left and right, and a binary func F implementing less-than,
|
// Given two singly linked lists left and right, and a binary func F implementing less-than,
|
||||||
// return the list in sorted order.
|
// return the list in sorted order.
|
||||||
|
|
|
@ -454,8 +454,7 @@ end_execution_reason_t parse_execution_context_t::run_for_statement(
|
||||||
auto var = parser->vars().get(for_var_name, ENV_DEFAULT);
|
auto var = parser->vars().get(for_var_name, ENV_DEFAULT);
|
||||||
if (env_var_t::flags_for(for_var_name.c_str()) & env_var_t::flag_read_only) {
|
if (env_var_t::flags_for(for_var_name.c_str()) & env_var_t::flag_read_only) {
|
||||||
return report_error(STATUS_INVALID_ARGS, header.var_name,
|
return report_error(STATUS_INVALID_ARGS, header.var_name,
|
||||||
L"for: %ls: cannot overwrite read-only variable",
|
L"for: %ls: cannot overwrite read-only variable", for_var_name.c_str());
|
||||||
for_var_name.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto &vars = parser->vars();
|
auto &vars = parser->vars();
|
||||||
|
|
|
@ -78,7 +78,8 @@ void report_setpgid_error(int err, bool is_parent, pid_t desired_pgid, const job
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EPERM: {
|
case EPERM: {
|
||||||
FLOGF_SAFE(error, "setpgid: Process %s is a session leader or pgid %s does not match", pid_buff, getpgid_buff);
|
FLOGF_SAFE(error, "setpgid: Process %s is a session leader or pgid %s does not match",
|
||||||
|
pid_buff, getpgid_buff);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ESRCH: {
|
case ESRCH: {
|
||||||
|
@ -412,11 +413,10 @@ void safe_report_exec_error(int err, const char *actual_cmd, const char *const *
|
||||||
}
|
}
|
||||||
|
|
||||||
case ENOEXEC: {
|
case ENOEXEC: {
|
||||||
FLOGF_SAFE(
|
FLOGF_SAFE(exec,
|
||||||
exec,
|
"The file '%s' is marked as an executable but could not be run by the "
|
||||||
"The file '%s' is marked as an executable but could not be run by the "
|
"operating system.",
|
||||||
"operating system.",
|
actual_cmd);
|
||||||
actual_cmd);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,15 +457,20 @@ void safe_report_exec_error(int err, const char *actual_cmd, const char *const *
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EACCES: {
|
case EACCES: {
|
||||||
FLOGF_SAFE(exec, "Failed to execute process '%s': The file could not be accessed.", actual_cmd);
|
FLOGF_SAFE(exec, "Failed to execute process '%s': The file could not be accessed.",
|
||||||
|
actual_cmd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ETXTBSY: {
|
case ETXTBSY: {
|
||||||
FLOGF_SAFE(exec, "Failed to execute process '%s': File is currently open for writing.", actual_cmd);
|
FLOGF_SAFE(exec, "Failed to execute process '%s': File is currently open for writing.",
|
||||||
|
actual_cmd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ELOOP: {
|
case ELOOP: {
|
||||||
FLOGF_SAFE(exec, "Failed to execute process '%s': Too many layers of symbolic links. Maybe a loop?", actual_cmd);
|
FLOGF_SAFE(
|
||||||
|
exec,
|
||||||
|
"Failed to execute process '%s': Too many layers of symbolic links. Maybe a loop?",
|
||||||
|
actual_cmd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EINVAL: {
|
case EINVAL: {
|
||||||
|
@ -477,16 +482,19 @@ void safe_report_exec_error(int err, const char *actual_cmd, const char *const *
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ENOTDIR: {
|
case ENOTDIR: {
|
||||||
FLOGF_SAFE(exec, "Failed to execute process '%s': A path component is not a directory.", actual_cmd);
|
FLOGF_SAFE(exec, "Failed to execute process '%s': A path component is not a directory.",
|
||||||
|
actual_cmd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case EMFILE: {
|
case EMFILE: {
|
||||||
FLOGF_SAFE(exec, "Failed to execute process '%s': Too many open files in this process.", actual_cmd);
|
FLOGF_SAFE(exec, "Failed to execute process '%s': Too many open files in this process.",
|
||||||
|
actual_cmd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ENFILE: {
|
case ENFILE: {
|
||||||
FLOGF_SAFE(exec, "Failed to execute process '%s': Too many open files on the system.", actual_cmd);
|
FLOGF_SAFE(exec, "Failed to execute process '%s': Too many open files on the system.",
|
||||||
|
actual_cmd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ENAMETOOLONG: {
|
case ENAMETOOLONG: {
|
||||||
|
@ -494,13 +502,17 @@ void safe_report_exec_error(int err, const char *actual_cmd, const char *const *
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EPERM: {
|
case EPERM: {
|
||||||
FLOGF_SAFE(exec, "Failed to execute process '%s': No permission. Either suid/sgid is forbidden or you lack capabilities.", actual_cmd);
|
FLOGF_SAFE(exec,
|
||||||
|
"Failed to execute process '%s': No permission. Either suid/sgid is "
|
||||||
|
"forbidden or you lack capabilities.",
|
||||||
|
actual_cmd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
char errnum_buff[64];
|
char errnum_buff[64];
|
||||||
format_long_safe(errnum_buff, err);
|
format_long_safe(errnum_buff, err);
|
||||||
FLOGF_SAFE(exec, "Failed to execute process '%s', unknown error number %s", actual_cmd, errnum_buff);
|
FLOGF_SAFE(exec, "Failed to execute process '%s', unknown error number %s", actual_cmd,
|
||||||
|
errnum_buff);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2630,7 +2630,7 @@ static std::shared_ptr<reader_data_t> reader_push_ret(parser_t &parser,
|
||||||
const wcstring &history_name,
|
const wcstring &history_name,
|
||||||
reader_config_t &&conf) {
|
reader_config_t &&conf) {
|
||||||
std::shared_ptr<history_t> hist = history_t::with_name(history_name);
|
std::shared_ptr<history_t> hist = history_t::with_name(history_name);
|
||||||
hist->resolve_pending(); // see #6892
|
hist->resolve_pending(); // see #6892
|
||||||
auto data = std::make_shared<reader_data_t>(parser.shared(), hist, std::move(conf));
|
auto data = std::make_shared<reader_data_t>(parser.shared(), hist, std::move(conf));
|
||||||
reader_data_stack.push_back(data);
|
reader_data_stack.push_back(data);
|
||||||
data->command_line_changed(&data->command_line);
|
data->command_line_changed(&data->command_line);
|
||||||
|
@ -4161,7 +4161,6 @@ bool reader_data_t::jump(jump_direction_t dir, jump_precision_t precision, edita
|
||||||
|
|
||||||
maybe_t<wcstring> reader_readline(int nchars) { return current_data()->readline(nchars); }
|
maybe_t<wcstring> reader_readline(int nchars) { return current_data()->readline(nchars); }
|
||||||
|
|
||||||
|
|
||||||
int reader_reading_interrupted() {
|
int reader_reading_interrupted() {
|
||||||
int res = reader_test_and_clear_interrupted();
|
int res = reader_test_and_clear_interrupted();
|
||||||
reader_data_t *data = current_data_or_null();
|
reader_data_t *data = current_data_or_null();
|
||||||
|
|
|
@ -131,7 +131,7 @@ static bool is_screen_name_escape_seq(const wchar_t *code, size_t *resulting_len
|
||||||
const wchar_t *i = screen_name_end;
|
const wchar_t *i = screen_name_end;
|
||||||
while (i > code && *(i - 1) == L'\x1B' && --i) esc_count++;
|
while (i > code && *(i - 1) == L'\x1B' && --i) esc_count++;
|
||||||
if (esc_count % 2 == 1) {
|
if (esc_count % 2 == 1) {
|
||||||
offset=screen_name_end - code + 1;
|
offset = screen_name_end - code + 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -355,7 +355,7 @@ static size_t measure_run_from(const wchar_t *input, size_t start, size_t *out_e
|
||||||
auto w = fish_wcwidth_visible(input[idx]);
|
auto w = fish_wcwidth_visible(input[idx]);
|
||||||
// A backspace at the start of the line does nothing.
|
// A backspace at the start of the line does nothing.
|
||||||
if (w != -1 || width > 0) {
|
if (w != -1 || width > 0) {
|
||||||
width += w;
|
width += w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -316,6 +316,7 @@ class layout_cache_t : noncopyable_t {
|
||||||
static layout_cache_t shared;
|
static layout_cache_t shared;
|
||||||
|
|
||||||
layout_cache_t() = default;
|
layout_cache_t() = default;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Add a cache entry.
|
// Add a cache entry.
|
||||||
void add_prompt_layout(prompt_cache_entry_t entry);
|
void add_prompt_layout(prompt_cache_entry_t entry);
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#ifndef FISH_SIGNALH
|
#ifndef FISH_SIGNALH
|
||||||
#define FISH_SIGNALH
|
#define FISH_SIGNALH
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
/// Get the integer signal value representing the specified signal, or -1 of no signal was found.
|
/// Get the integer signal value representing the specified signal, or -1 of no signal was found.
|
||||||
int wcs2sig(const wchar_t *str);
|
int wcs2sig(const wchar_t *str);
|
||||||
|
|
|
@ -8,9 +8,7 @@
|
||||||
|
|
||||||
static bool do_trace = false;
|
static bool do_trace = false;
|
||||||
|
|
||||||
void trace_set_enabled(bool do_enable) {
|
void trace_set_enabled(bool do_enable) { do_trace = do_enable; }
|
||||||
do_trace = do_enable;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool trace_enabled(const parser_t &parser) {
|
bool trace_enabled(const parser_t &parser) {
|
||||||
const auto &ld = parser.libdata();
|
const auto &ld = parser.libdata();
|
||||||
|
|
|
@ -297,8 +297,10 @@ class line_iterator_t {
|
||||||
/// Like fish_wcwidth, but returns 0 for characters with no real width instead of -1.
|
/// Like fish_wcwidth, but returns 0 for characters with no real width instead of -1.
|
||||||
int fish_wcwidth_visible(wchar_t widechar);
|
int fish_wcwidth_visible(wchar_t widechar);
|
||||||
|
|
||||||
/// The same, but for all chars. Note that this only makes sense if the string has an arbitrary long prefix - backslashes can move the cursor *before* the string.
|
/// The same, but for all chars. Note that this only makes sense if the string has an arbitrary long
|
||||||
|
/// prefix - backslashes can move the cursor *before* the string.
|
||||||
///
|
///
|
||||||
/// In typical usage, you probably want to wrap wcwidth_visible to accumulate the width, but never go below 0.
|
/// In typical usage, you probably want to wrap wcwidth_visible to accumulate the width, but never
|
||||||
|
/// go below 0.
|
||||||
int fish_wcswidth_visible(const wcstring &str);
|
int fish_wcswidth_visible(const wcstring &str);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -541,9 +541,7 @@ locale_t fish_c_locale() {
|
||||||
|
|
||||||
static bool fish_numeric_locale_is_valid = false;
|
static bool fish_numeric_locale_is_valid = false;
|
||||||
|
|
||||||
void fish_invalidate_numeric_locale() {
|
void fish_invalidate_numeric_locale() { fish_numeric_locale_is_valid = false; }
|
||||||
fish_numeric_locale_is_valid = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
locale_t fish_numeric_locale() {
|
locale_t fish_numeric_locale() {
|
||||||
// The current locale, except LC_NUMERIC isn't forced to C.
|
// The current locale, except LC_NUMERIC isn't forced to C.
|
||||||
|
@ -747,9 +745,7 @@ file_id_t file_id_for_fd(int fd) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
file_id_t file_id_for_fd(const autoclose_fd_t &fd) {
|
file_id_t file_id_for_fd(const autoclose_fd_t &fd) { return file_id_for_fd(fd.fd()); }
|
||||||
return file_id_for_fd(fd.fd());
|
|
||||||
}
|
|
||||||
|
|
||||||
file_id_t file_id_for_path(const wcstring &path) {
|
file_id_t file_id_for_path(const wcstring &path) {
|
||||||
file_id_t result = kInvalidFileID;
|
file_id_t result = kInvalidFileID;
|
||||||
|
@ -773,7 +769,6 @@ bool file_id_t::operator==(const file_id_t &rhs) const { return this->compare_fi
|
||||||
|
|
||||||
bool file_id_t::operator!=(const file_id_t &rhs) const { return !(*this == rhs); }
|
bool file_id_t::operator!=(const file_id_t &rhs) const { return !(*this == rhs); }
|
||||||
|
|
||||||
|
|
||||||
wcstring file_id_t::dump() const {
|
wcstring file_id_t::dump() const {
|
||||||
using llong = long long;
|
using llong = long long;
|
||||||
wcstring result;
|
wcstring result;
|
||||||
|
|
Loading…
Reference in a new issue