mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-29 06:13:20 +00:00
Cleanup on aisle haphazard-everywhere
This commit is contained in:
parent
75d252dadc
commit
362319d25f
9 changed files with 32 additions and 54 deletions
|
@ -330,7 +330,7 @@ static int collect_option_specs(argparse_cmd_opts_t &opts, int *optind, int argc
|
|||
// A counter to give short chars to long-only options because getopt needs that.
|
||||
// Luckily we have wgetopt so we can use wchars - this is one of the private use areas so we
|
||||
// have 6400 options available.
|
||||
wchar_t counter = static_cast<wchar_t>(0xE000);
|
||||
auto counter = static_cast<wchar_t>(0xE000);
|
||||
|
||||
while (true) {
|
||||
if (std::wcscmp(L"--", argv[*optind]) == 0) {
|
||||
|
|
|
@ -683,7 +683,7 @@ static wcstring_list_t new_var_values_by_index(const split_var_t &split, int arg
|
|||
long lidx = split.indexes.at(i);
|
||||
assert(lidx >= 1 && "idx should have been verified in range already");
|
||||
// Convert from 1-based to 0-based.
|
||||
size_t idx = static_cast<size_t>(lidx - 1);
|
||||
auto idx = static_cast<size_t>(lidx - 1);
|
||||
// Extend as needed with empty strings.
|
||||
if (idx >= result.size()) result.resize(idx + 1);
|
||||
result.at(idx) = argv[i];
|
||||
|
|
|
@ -1673,7 +1673,7 @@ static wcstring wcsrepeat(const wcstring &to_repeat, size_t count) {
|
|||
// Helper function to abstract the repeat until logic from string_repeat
|
||||
// returns the to_repeat string, repeated until max char has been reached.
|
||||
static wcstring wcsrepeat_until(const wcstring &to_repeat, size_t max) {
|
||||
if (to_repeat.length() == 0) return wcstring();
|
||||
if (to_repeat.length() == 0) return {};
|
||||
size_t count = max / to_repeat.length();
|
||||
size_t mod = max % to_repeat.length();
|
||||
|
||||
|
|
|
@ -61,8 +61,7 @@ bool term_has_xn = false;
|
|||
/// This is typically initialized in env_init(), and is considered empty before then.
|
||||
static acquired_lock<env_universal_t> uvars() {
|
||||
// Leaked to avoid shutdown dtor registration.
|
||||
static owning_lock<env_universal_t> *const s_universal_variables =
|
||||
new owning_lock<env_universal_t>();
|
||||
static auto const s_universal_variables = new owning_lock<env_universal_t>();
|
||||
return s_universal_variables->acquire();
|
||||
}
|
||||
|
||||
|
@ -843,7 +842,7 @@ wcstring_list_t env_scoped_impl_t::get_names(int flags) const {
|
|||
names.insert(uni_list.begin(), uni_list.end());
|
||||
}
|
||||
|
||||
return wcstring_list_t(names.begin(), names.end());
|
||||
return {names.begin(), names.end()};
|
||||
}
|
||||
|
||||
/// Recursive helper to snapshot a series of nodes.
|
||||
|
|
|
@ -263,7 +263,6 @@ int fish_wcwidth(wchar_t wc) {
|
|||
// Fall back to system wcwidth in this case.
|
||||
return wcwidth(wc);
|
||||
case widechar_ambiguous:
|
||||
return g_fish_ambiguous_width;
|
||||
case widechar_private_use:
|
||||
// TR11: "All private-use characters are by default classified as Ambiguous".
|
||||
return g_fish_ambiguous_width;
|
||||
|
|
|
@ -104,61 +104,41 @@ static const wchar_t *get_highlight_var_name(highlight_role_t role) {
|
|||
static highlight_role_t get_fallback(highlight_role_t role) {
|
||||
switch (role) {
|
||||
case highlight_role_t::normal:
|
||||
return highlight_role_t::normal;
|
||||
case highlight_role_t::error:
|
||||
return highlight_role_t::normal;
|
||||
case highlight_role_t::command:
|
||||
case highlight_role_t::statement_terminator:
|
||||
case highlight_role_t::param:
|
||||
case highlight_role_t::search_match:
|
||||
case highlight_role_t::comment:
|
||||
case highlight_role_t::operat:
|
||||
case highlight_role_t::escape:
|
||||
case highlight_role_t::quote:
|
||||
case highlight_role_t::redirection:
|
||||
case highlight_role_t::autosuggestion:
|
||||
case highlight_role_t::selection:
|
||||
case highlight_role_t::pager_progress:
|
||||
case highlight_role_t::pager_background:
|
||||
case highlight_role_t::pager_prefix:
|
||||
case highlight_role_t::pager_completion:
|
||||
case highlight_role_t::pager_description:
|
||||
return highlight_role_t::normal;
|
||||
case highlight_role_t::keyword:
|
||||
return highlight_role_t::command;
|
||||
case highlight_role_t::statement_terminator:
|
||||
return highlight_role_t::normal;
|
||||
case highlight_role_t::option:
|
||||
return highlight_role_t::param;
|
||||
case highlight_role_t::param:
|
||||
return highlight_role_t::normal;
|
||||
case highlight_role_t::comment:
|
||||
return highlight_role_t::normal;
|
||||
case highlight_role_t::search_match:
|
||||
return highlight_role_t::normal;
|
||||
case highlight_role_t::operat:
|
||||
return highlight_role_t::normal;
|
||||
case highlight_role_t::escape:
|
||||
return highlight_role_t::normal;
|
||||
case highlight_role_t::quote:
|
||||
return highlight_role_t::normal;
|
||||
case highlight_role_t::redirection:
|
||||
return highlight_role_t::normal;
|
||||
case highlight_role_t::autosuggestion:
|
||||
return highlight_role_t::normal;
|
||||
case highlight_role_t::selection:
|
||||
return highlight_role_t::normal;
|
||||
case highlight_role_t::pager_progress:
|
||||
return highlight_role_t::normal;
|
||||
case highlight_role_t::pager_background:
|
||||
return highlight_role_t::normal;
|
||||
case highlight_role_t::pager_prefix:
|
||||
return highlight_role_t::normal;
|
||||
case highlight_role_t::pager_completion:
|
||||
return highlight_role_t::normal;
|
||||
case highlight_role_t::pager_description:
|
||||
return highlight_role_t::normal;
|
||||
case highlight_role_t::pager_secondary_background:
|
||||
return highlight_role_t::pager_background;
|
||||
case highlight_role_t::pager_secondary_prefix:
|
||||
case highlight_role_t::pager_selected_prefix:
|
||||
return highlight_role_t::pager_prefix;
|
||||
case highlight_role_t::pager_secondary_completion:
|
||||
case highlight_role_t::pager_selected_completion:
|
||||
return highlight_role_t::pager_completion;
|
||||
case highlight_role_t::pager_secondary_description:
|
||||
case highlight_role_t::pager_selected_description:
|
||||
return highlight_role_t::pager_description;
|
||||
case highlight_role_t::pager_selected_background:
|
||||
return highlight_role_t::search_match;
|
||||
case highlight_role_t::pager_selected_prefix:
|
||||
return highlight_role_t::pager_prefix;
|
||||
case highlight_role_t::pager_selected_completion:
|
||||
return highlight_role_t::pager_completion;
|
||||
case highlight_role_t::pager_selected_description:
|
||||
return highlight_role_t::pager_description;
|
||||
}
|
||||
DIE("invalid highlight role");
|
||||
}
|
||||
|
@ -175,7 +155,7 @@ static bool fs_is_case_insensitive(const wcstring &path, int fd,
|
|||
bool result = false;
|
||||
#ifdef _PC_CASE_SENSITIVE
|
||||
// Try the cache first.
|
||||
case_sensitivity_cache_t::iterator cache = case_sensitivity_cache.find(path);
|
||||
auto cache = case_sensitivity_cache.find(path);
|
||||
if (cache != case_sensitivity_cache.end()) {
|
||||
/* Use the cached value */
|
||||
result = cache->second;
|
||||
|
@ -518,7 +498,7 @@ static size_t color_variable(const wchar_t *in, size_t in_len,
|
|||
for (size_t slice_count = 0; slice_count < dollar_count; slice_count++) {
|
||||
long slice_len = parse_util_slice_length(in + idx);
|
||||
if (slice_len > 0) {
|
||||
size_t slice_ulen = static_cast<size_t>(slice_len);
|
||||
auto slice_ulen = static_cast<size_t>(slice_len);
|
||||
colors[idx] = highlight_role_t::operat;
|
||||
colors[idx + slice_ulen - 1] = highlight_role_t::operat;
|
||||
idx += slice_ulen;
|
||||
|
@ -1276,7 +1256,7 @@ highlighter_t::color_array_t highlighter_t::highlight() {
|
|||
// Underline every valid path.
|
||||
if (io_ok) {
|
||||
for (const ast::node_t &node : ast) {
|
||||
const ast::argument_t *arg = node.try_as<ast::argument_t>();
|
||||
const auto arg = node.try_as<ast::argument_t>();
|
||||
if (!arg || arg->unsourced) continue;
|
||||
if (ctx.check_cancel()) break;
|
||||
if (range_is_potential_path(buff, arg->range, ctx, working_directory)) {
|
||||
|
|
|
@ -137,7 +137,7 @@ static owning_lock<main_thread_queue_t> s_main_thread_queue;
|
|||
/// \return the signaller for completions and main thread requests.
|
||||
static fd_event_signaller_t &get_notify_signaller() {
|
||||
// Leaked to avoid shutdown dtors.
|
||||
static fd_event_signaller_t *s_signaller = new fd_event_signaller_t();
|
||||
static auto s_signaller = new fd_event_signaller_t();
|
||||
return *s_signaller;
|
||||
}
|
||||
|
||||
|
@ -356,7 +356,7 @@ bool make_detached_pthread(void *(*func)(void *), void *param) {
|
|||
// Spawn a thread. If this fails, it means there's already a bunch of threads; it is very
|
||||
// unlikely that they are all on the verge of exiting, so one is likely to be ready to handle
|
||||
// extant requests. So we can ignore failure with some confidence.
|
||||
pthread_t thread = 0;
|
||||
pthread_t thread = nullptr;
|
||||
int err = pthread_create(&thread, nullptr, func, param);
|
||||
if (err == 0) {
|
||||
// Success, return the thread.
|
||||
|
|
|
@ -522,7 +522,7 @@ void screen_t::desired_append_char(wchar_t b, highlight_spec_t c, int indent, si
|
|||
this->desired.line(this->desired.cursor.y).is_soft_wrapped = false;
|
||||
int line_no = ++this->desired.cursor.y;
|
||||
this->desired.cursor.x = 0;
|
||||
size_t indentation = prompt_width + indent * INDENT_STEP;
|
||||
size_t indentation = prompt_width + static_cast<size_t>(indent) * INDENT_STEP;
|
||||
line_t &line = this->desired.line(line_no);
|
||||
line.indentation = indentation;
|
||||
for (size_t i = 0; i < indentation; i++) {
|
||||
|
|
|
@ -464,7 +464,7 @@ ssize_t wwrite_to_fd(const wchar_t *input, size_t input_len, int fd) {
|
|||
ssize_t samt = write(fd, cursor, remaining);
|
||||
if (samt < 0) return false;
|
||||
total_written += samt;
|
||||
size_t amt = static_cast<size_t>(samt);
|
||||
auto amt = static_cast<size_t>(samt);
|
||||
assert(amt <= remaining && "Wrote more than requested");
|
||||
remaining -= amt;
|
||||
cursor += amt;
|
||||
|
@ -547,9 +547,9 @@ void fish_invalidate_numeric_locale() {
|
|||
|
||||
locale_t fish_numeric_locale() {
|
||||
// The current locale, except LC_NUMERIC isn't forced to C.
|
||||
static locale_t loc = 0;
|
||||
static locale_t loc = nullptr;
|
||||
if (!fish_numeric_locale_is_valid) {
|
||||
if (loc != 0) freelocale(loc);
|
||||
if (loc != nullptr) freelocale(loc);
|
||||
auto cur = duplocale(LC_GLOBAL_LOCALE);
|
||||
loc = newlocale(LC_NUMERIC_MASK, "", cur);
|
||||
fish_numeric_locale_is_valid = true;
|
||||
|
|
Loading…
Reference in a new issue