mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 21:33:09 +00:00
clang-format C++ files
No functional change (hopefully!)
This commit is contained in:
parent
4712da3eb1
commit
1127d7d68f
13 changed files with 61 additions and 47 deletions
|
@ -211,8 +211,6 @@ void autoload_t::perform_autoload(const wcstring &path, parser_t &parser) {
|
|||
|
||||
wcstring script_source = L"source " + escape_string(path, ESCAPE_ALL);
|
||||
auto prev_statuses = parser.get_last_statuses();
|
||||
const cleanup_t put_back([&] {
|
||||
parser.set_last_statuses(prev_statuses);
|
||||
});
|
||||
const cleanup_t put_back([&] { parser.set_last_statuses(prev_statuses); });
|
||||
parser.eval(script_source, io_chain_t{});
|
||||
}
|
||||
|
|
|
@ -991,8 +991,7 @@ static void escape_string_script(const wchar_t *orig_in, size_t in_len, wcstring
|
|||
case L'"':
|
||||
case L'%':
|
||||
case L'~': {
|
||||
bool char_is_normal = (c == L'~' && no_tilde) ||
|
||||
(c == L'?' && no_qmark);
|
||||
bool char_is_normal = (c == L'~' && no_tilde) || (c == L'?' && no_qmark);
|
||||
if (!char_is_normal) {
|
||||
need_escape = true;
|
||||
if (escape_all) out += L'\\';
|
||||
|
|
|
@ -3750,7 +3750,7 @@ static void test_autosuggest_suggest_special() {
|
|||
|
||||
parser_t::principal_parser().vars().remove(L"HOME", ENV_LOCAL | ENV_EXPORT);
|
||||
popd();
|
||||
#endif //ndef SANITIZE_ADDRESS
|
||||
#endif // ndef SANITIZE_ADDRESS
|
||||
}
|
||||
|
||||
static void perform_one_autosuggestion_should_ignore_test(const wcstring &command, long line) {
|
||||
|
|
|
@ -16,7 +16,9 @@ features_t::features_t() {
|
|||
features_t features_t::global_features;
|
||||
|
||||
const features_t::metadata_t features_t::metadata[features_t::flag_count] = {
|
||||
{stderr_nocaret, L"stderr-nocaret", L"3.0", L"^ no longer redirects stderr (historical, can no longer be changed)", true, true /* read-only */},
|
||||
{stderr_nocaret, L"stderr-nocaret", L"3.0",
|
||||
L"^ no longer redirects stderr (historical, can no longer be changed)", true,
|
||||
true /* read-only */},
|
||||
{qmark_noglob, L"qmark-noglob", L"3.0", L"? no longer globs", false, false},
|
||||
{string_replace_backslash, L"regex-easyesc", L"3.1", L"string replace -r needs fewer \\'s",
|
||||
true, false},
|
||||
|
|
|
@ -76,8 +76,9 @@ namespace std {
|
|||
template <>
|
||||
struct hash<highlight_spec_t> {
|
||||
std::size_t operator()(const highlight_spec_t &v) const {
|
||||
const size_t vals[4] = {static_cast<uint32_t>(v.foreground), static_cast<uint32_t>(v.background),
|
||||
v.valid_path, v.force_underline};
|
||||
const size_t vals[4] = {static_cast<uint32_t>(v.foreground),
|
||||
static_cast<uint32_t>(v.background), v.valid_path,
|
||||
v.force_underline};
|
||||
return (vals[0] << 0) + (vals[1] << 6) + (vals[2] << 12) + (vals[3] << 18);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -247,7 +247,7 @@ class history_search_t {
|
|||
/// The (possibly lowercased) search term.
|
||||
wcstring canon_term_;
|
||||
|
||||
/// Our search type.
|
||||
/// Our search type.
|
||||
enum history_search_type_t search_type_ { history_search_type_t::contains };
|
||||
|
||||
/// Our flags.
|
||||
|
|
|
@ -251,9 +251,11 @@ bool io_chain_t::append_from_specs(const redirection_spec_list_t &specs, const w
|
|||
auto next = wdirname(dname);
|
||||
if (!wstat(next, &buf)) {
|
||||
if (!S_ISDIR(buf.st_mode)) {
|
||||
FLOGF(warning, _(L"Path '%ls' is not a directory"), next.c_str());
|
||||
FLOGF(warning, _(L"Path '%ls' is not a directory"),
|
||||
next.c_str());
|
||||
} else {
|
||||
FLOGF(warning, _(L"Path '%ls' does not exist"), dname.c_str());
|
||||
FLOGF(warning, _(L"Path '%ls' does not exist"),
|
||||
dname.c_str());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
3
src/io.h
3
src/io.h
|
@ -371,7 +371,8 @@ class output_stream_t : noncopyable_t, nonmovable_t {
|
|||
bool want_newline = true);
|
||||
|
||||
/// The following are all convenience overrides.
|
||||
void append_with_separation(const wcstring &s, separation_type_t type, bool want_newline = true) {
|
||||
void append_with_separation(const wcstring &s, separation_type_t type,
|
||||
bool want_newline = true) {
|
||||
append_with_separation(s.data(), s.size(), type, want_newline);
|
||||
}
|
||||
|
||||
|
|
|
@ -891,7 +891,8 @@ end_execution_reason_t parse_execution_context_t::populate_plain_process(
|
|||
function_exists(L"cd", *parser) ? process_type_t::function : process_type_t::builtin;
|
||||
} else {
|
||||
// Not implicit cd.
|
||||
const globspec_t glob_behavior = (cmd == L"set" || cmd == L"count" || cmd == L"path") ? nullglob : failglob;
|
||||
const globspec_t glob_behavior =
|
||||
(cmd == L"set" || cmd == L"count" || cmd == L"path") ? nullglob : failglob;
|
||||
// Form the list of arguments. The command is the first argument, followed by any arguments
|
||||
// from expanding the command, followed by the argument nodes themselves. E.g. if the
|
||||
// command is '$gco foo' and $gco is git checkout.
|
||||
|
|
|
@ -23,8 +23,8 @@ static const string_set_t block_keywords = {L"for", L"while", L"if",
|
|||
L"function", L"switch", L"begin"};
|
||||
|
||||
static const wcstring reserved_keywords[] = {
|
||||
L"end", L"case", L"else", L"return", L"continue", L"break", L"argparse",
|
||||
L"read", L"string", L"set", L"status", L"test", L"[", L"_", L"eval"};
|
||||
L"end", L"case", L"else", L"return", L"continue", L"break", L"argparse", L"read",
|
||||
L"string", L"set", L"status", L"test", L"[", L"_", L"eval"};
|
||||
|
||||
// The lists above are purposely implemented separately from the logic below, so that future
|
||||
// maintainers may assume the contents of the list based off their names, and not off what the
|
||||
|
|
|
@ -392,30 +392,34 @@ void safe_report_exec_error(int err, const char *actual_cmd, const char *const *
|
|||
if (sz >= static_cast<unsigned long long>(arg_max)) {
|
||||
char sz2[128];
|
||||
format_size_safe(sz2, static_cast<unsigned long long>(arg_max));
|
||||
FLOGF_SAFE(exec,
|
||||
"Failed to execute process '%s': the total size of the argument list and "
|
||||
"exported variables (%s) exceeds the OS limit of %s.",
|
||||
actual_cmd, sz1, sz2);
|
||||
FLOGF_SAFE(
|
||||
exec,
|
||||
"Failed to execute process '%s': the total size of the argument list and "
|
||||
"exported variables (%s) exceeds the OS limit of %s.",
|
||||
actual_cmd, sz1, sz2);
|
||||
} else {
|
||||
// MAX_ARG_STRLEN, a linux thing that limits the size of one argument. It's
|
||||
// defined in binfmts.h, but we don't want to include that just to be able to
|
||||
// print the real limit.
|
||||
FLOGF_SAFE(exec,
|
||||
"Failed to execute process '%s': An argument or exported variable exceeds the OS "
|
||||
"argument length limit.", actual_cmd);
|
||||
"Failed to execute process '%s': An argument or exported variable "
|
||||
"exceeds the OS "
|
||||
"argument length limit.",
|
||||
actual_cmd);
|
||||
}
|
||||
|
||||
if (szenv >= static_cast<unsigned long long>(arg_max) / 2) {
|
||||
FLOGF_SAFE(exec,
|
||||
"Hint: Your exported variables take up over half the limit. Try erasing or unexporting variables."
|
||||
);
|
||||
"Hint: Your exported variables take up over half the limit. Try "
|
||||
"erasing or unexporting variables.");
|
||||
}
|
||||
} else {
|
||||
FLOGF_SAFE(exec,
|
||||
"Failed to execute process '%s': the total size of the argument list and "
|
||||
"exported variables (%s) exceeds the "
|
||||
"operating system limit.",
|
||||
actual_cmd, sz1);
|
||||
FLOGF_SAFE(
|
||||
exec,
|
||||
"Failed to execute process '%s': the total size of the argument list and "
|
||||
"exported variables (%s) exceeds the "
|
||||
"operating system limit.",
|
||||
actual_cmd, sz1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -471,7 +475,8 @@ void safe_report_exec_error(int err, const char *actual_cmd, const char *const *
|
|||
}
|
||||
} else if (access(actual_cmd, X_OK) == 0) {
|
||||
FLOGF_SAFE(exec,
|
||||
"Failed to execute process '%s': The file exists and is executable. Check the interpreter or linker?",
|
||||
"Failed to execute process '%s': The file exists and is executable. "
|
||||
"Check the interpreter or linker?",
|
||||
actual_cmd);
|
||||
} else {
|
||||
FLOGF_SAFE(exec,
|
||||
|
|
|
@ -163,14 +163,14 @@ wcstring timer_snapshot_t::print_delta(const timer_snapshot_t &t1, const timer_s
|
|||
|
||||
wcstring output;
|
||||
if (!verbose) {
|
||||
append_format(output, L"\n_______________________________"
|
||||
L"\nExecuted in %6.2F %s"
|
||||
L"\n usr time %6.2F %s"
|
||||
L"\n sys time %6.2F %s"
|
||||
L"\n",
|
||||
wall_time, unit_name(wall_unit),
|
||||
usr_time, unit_name(cpu_unit),
|
||||
sys_time, unit_name(cpu_unit));
|
||||
append_format(output,
|
||||
L"\n_______________________________"
|
||||
L"\nExecuted in %6.2F %s"
|
||||
L"\n usr time %6.2F %s"
|
||||
L"\n sys time %6.2F %s"
|
||||
L"\n",
|
||||
wall_time, unit_name(wall_unit), usr_time, unit_name(cpu_unit), sys_time,
|
||||
unit_name(cpu_unit));
|
||||
} else {
|
||||
auto fish_unit = get_unit(std::max(fish_sys_micros, fish_usr_micros));
|
||||
auto child_unit = get_unit(std::max(child_sys_micros, child_usr_micros));
|
||||
|
@ -179,8 +179,8 @@ wcstring timer_snapshot_t::print_delta(const timer_snapshot_t &t1, const timer_s
|
|||
double child_usr_time = convert(child_usr_micros, child_unit);
|
||||
double child_sys_time = convert(child_sys_micros, child_unit);
|
||||
|
||||
int column2_unit_len = std::max(strlen(unit_short_name(wall_unit)),
|
||||
strlen(unit_short_name(cpu_unit)));
|
||||
int column2_unit_len =
|
||||
std::max(strlen(unit_short_name(wall_unit)), strlen(unit_short_name(cpu_unit)));
|
||||
append_format(output,
|
||||
L"\n________________________________________________________"
|
||||
L"\nExecuted in %6.2F %-*s %-*s %s"
|
||||
|
|
|
@ -728,7 +728,7 @@ double fish_wcstod(const wcstring &str, wchar_t **endptr) {
|
|||
/// are not consumed.
|
||||
double fish_wcstod_underscores(const wchar_t *str, wchar_t **endptr) {
|
||||
const wchar_t *orig = str;
|
||||
while (iswspace(*str)) str++; // Skip leading whitespace.
|
||||
while (iswspace(*str)) str++; // Skip leading whitespace.
|
||||
size_t leading_whitespace = size_t(str - orig);
|
||||
auto is_sign = [](wchar_t c) { return c == L'+' || c == L'-'; };
|
||||
auto is_inf_or_nan_char = [](wchar_t c) {
|
||||
|
@ -757,8 +757,11 @@ double fish_wcstod_underscores(const wchar_t *str, wchar_t **endptr) {
|
|||
// literals using 0o, etc., we could just use iswalnum, instead of iswxdigit and P/p/X/x checks.
|
||||
while (iswxdigit(*str) || *str == L'P' || *str == L'p' || *str == L'X' || *str == L'x' ||
|
||||
is_sign(*str) || *str == L'.' || *str == L'_') {
|
||||
if (*str == L'_') underscores.push_back(pruned.length());
|
||||
else pruned.push_back(*str);
|
||||
if (*str == L'_') {
|
||||
underscores.push_back(pruned.length());
|
||||
} else {
|
||||
pruned.push_back(*str);
|
||||
}
|
||||
str++;
|
||||
}
|
||||
const wchar_t *pruned_begin = pruned.c_str();
|
||||
|
@ -768,11 +771,13 @@ double fish_wcstod_underscores(const wchar_t *str, wchar_t **endptr) {
|
|||
if (endptr) *endptr = (wchar_t *)orig;
|
||||
return result;
|
||||
}
|
||||
auto consumed_underscores_end = std::upper_bound(underscores.begin(), underscores.end(),
|
||||
size_t(pruned_end - pruned_begin));
|
||||
auto consumed_underscores_end =
|
||||
std::upper_bound(underscores.begin(), underscores.end(), size_t(pruned_end - pruned_begin));
|
||||
size_t num_underscores_consumed = std::distance(underscores.begin(), consumed_underscores_end);
|
||||
if (endptr) *endptr = (wchar_t *)(orig + leading_whitespace + (pruned_end - pruned_begin)
|
||||
+ num_underscores_consumed);
|
||||
if (endptr) {
|
||||
*endptr = (wchar_t *)(orig + leading_whitespace + (pruned_end - pruned_begin) +
|
||||
num_underscores_consumed);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue