mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-26 10:43:47 +08:00
Reformat source files with clang-format
This commit is contained in:
parent
f21e015f1b
commit
0a559ac457
|
@ -35,8 +35,9 @@ struct builtin_data_t {
|
|||
#define BUILTIN_ERR_MISSING _(L"%ls: Expected argument for option %ls\n")
|
||||
|
||||
/// Error message on missing man page.
|
||||
#define BUILTIN_ERR_MISSING_HELP \
|
||||
_(L"fish: Missing man page for '%ls'. Did you install the documentation?\n`help '%ls'` will open the online version.\n")
|
||||
#define BUILTIN_ERR_MISSING_HELP \
|
||||
_(L"fish: Missing man page for '%ls'. Did you install the documentation?\n`help '%ls'` will " \
|
||||
L"open the online version.\n")
|
||||
|
||||
/// Error message on invalid combination of options.
|
||||
#define BUILTIN_ERR_COMBO _(L"%ls: Invalid combination of options\n")
|
||||
|
|
|
@ -60,7 +60,7 @@ maybe_t<int> builtin_cd(parser_t &parser, io_streams_t &streams, const wchar_t *
|
|||
errno = 0;
|
||||
auto best_errno = errno;
|
||||
|
||||
for (const auto &dir: dirs) {
|
||||
for (const auto &dir : dirs) {
|
||||
wcstring norm_dir = normalize_path(dir);
|
||||
|
||||
// We need to keep around the fd for this directory, in the parser.
|
||||
|
@ -106,8 +106,8 @@ maybe_t<int> builtin_cd(parser_t &parser, io_streams_t &streams, const wchar_t *
|
|||
} else {
|
||||
errno = best_errno;
|
||||
wperror(L"cd");
|
||||
streams.err.append_format(_(L"%ls: Unknown error trying to locate directory '%ls'\n"),
|
||||
cmd, dir_in.c_str());
|
||||
streams.err.append_format(_(L"%ls: Unknown error trying to locate directory '%ls'\n"), cmd,
|
||||
dir_in.c_str());
|
||||
}
|
||||
|
||||
if (!parser.is_interactive()) {
|
||||
|
|
|
@ -436,7 +436,6 @@ maybe_t<split_var_t> split_var_and_indexes(const wchar_t *arg, env_mode_flags_t
|
|||
return res;
|
||||
}
|
||||
|
||||
|
||||
/// 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) {
|
||||
|
|
|
@ -80,8 +80,7 @@ maybe_t<int> builtin_source(parser_t &parser, io_streams_t &streams, const wchar
|
|||
|
||||
if (!S_ISREG(buf.st_mode)) {
|
||||
wcstring esc = escape_string(argv[optind], ESCAPE_ALL);
|
||||
streams.err.append_format(_(L"%ls: '%ls' is not a file\n"),
|
||||
cmd, esc.c_str());
|
||||
streams.err.append_format(_(L"%ls: '%ls' is not a file\n"), cmd, esc.c_str());
|
||||
return STATUS_CMD_ERROR;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,16 +32,12 @@ struct type_cmd_opts_t {
|
|||
bool query = false;
|
||||
};
|
||||
static const wchar_t *const short_options = L":hasftpPq";
|
||||
static const struct woption long_options[] = {{L"help", no_argument, nullptr, 'h'},
|
||||
{L"all", no_argument, nullptr, 'a'},
|
||||
{L"short", no_argument, nullptr, 's'},
|
||||
{L"no-functions", no_argument, nullptr, 'f'},
|
||||
{L"type", no_argument, nullptr, 't'},
|
||||
{L"path", no_argument, nullptr, 'p'},
|
||||
{L"force-path", no_argument, nullptr, 'P'},
|
||||
{L"query", no_argument, nullptr, 'q'},
|
||||
{L"quiet", no_argument, nullptr, 'q'},
|
||||
{nullptr, 0, nullptr, 0}};
|
||||
static const struct woption long_options[] = {
|
||||
{L"help", no_argument, nullptr, 'h'}, {L"all", no_argument, nullptr, 'a'},
|
||||
{L"short", no_argument, nullptr, 's'}, {L"no-functions", no_argument, nullptr, 'f'},
|
||||
{L"type", no_argument, nullptr, 't'}, {L"path", no_argument, nullptr, 'p'},
|
||||
{L"force-path", no_argument, nullptr, 'P'}, {L"query", no_argument, nullptr, 'q'},
|
||||
{L"quiet", no_argument, nullptr, 'q'}, {nullptr, 0, nullptr, 0}};
|
||||
|
||||
static int parse_cmd_opts(type_cmd_opts_t &opts, int *optind, int argc, const wchar_t **argv,
|
||||
parser_t &parser, io_streams_t &streams) {
|
||||
|
@ -149,7 +145,8 @@ maybe_t<int> builtin_type(parser_t &parser, io_streams_t &streams, const wchar_t
|
|||
int line_number = function_get_definition_lineno(name);
|
||||
wcstring comment;
|
||||
if (std::wcscmp(path, L"-") != 0) {
|
||||
append_format(comment, L"# Defined in %ls @ line %d\n", path, line_number);
|
||||
append_format(comment, L"# Defined in %ls @ line %d\n", path,
|
||||
line_number);
|
||||
} else {
|
||||
append_format(comment, L"# Defined via `source`\n");
|
||||
}
|
||||
|
|
|
@ -123,8 +123,7 @@ static unsigned long squared_difference(long p1, long p2) {
|
|||
return diff * diff;
|
||||
}
|
||||
|
||||
static uint8_t convert_color(const uint8_t rgb[3], const uint32_t *colors,
|
||||
size_t color_count) {
|
||||
static uint8_t convert_color(const uint8_t rgb[3], const uint32_t *colors, size_t color_count) {
|
||||
long r = rgb[0], g = rgb[1], b = rgb[2];
|
||||
auto best_distance = static_cast<unsigned long>(-1);
|
||||
auto best_index = static_cast<uint8_t>(-1);
|
||||
|
@ -254,9 +253,7 @@ static const wchar_t *name_for_color_idx(uint8_t idx) {
|
|||
return L"unknown";
|
||||
}
|
||||
|
||||
rgb_color_t::rgb_color_t(uint8_t t, uint8_t i) : type(t), flags(), data() {
|
||||
data.name_idx = i;
|
||||
}
|
||||
rgb_color_t::rgb_color_t(uint8_t t, uint8_t i) : type(t), flags(), data() { data.name_idx = i; }
|
||||
|
||||
rgb_color_t rgb_color_t::normal() { return rgb_color_t(type_normal); }
|
||||
|
||||
|
|
44
src/common.h
44
src/common.h
|
@ -731,17 +731,19 @@ static_assert(const_strcmp("b", "aa") > 0, "const_strcmp failure");
|
|||
|
||||
/// Compile-time agnostic-size strlen/wcslen implementation. Unicode-unaware.
|
||||
template <typename T, size_t N>
|
||||
constexpr size_t const_strlen(const T(&val)[N], ssize_t index = -1) {
|
||||
constexpr size_t const_strlen(const T (&val)[N], ssize_t index = -1) {
|
||||
// N is the length of the character array, but that includes one **or more** trailing nuls.
|
||||
static_assert(N > 0, "Invalid input to const_strlen");
|
||||
return index == -1 ?
|
||||
// Assume a minimum of one trailing nul and do a quick check for the usual case (single
|
||||
// trailing nul) before recursing:
|
||||
N - 1 - (N <= 2 || val[N-2] != static_cast<T>(0) ? 0 : const_strlen(val, N - 2))
|
||||
// Prevent an underflow in case the string is comprised of all \0 bytes
|
||||
: index == 0 ? 0
|
||||
// Keep back-tracking until a non-nul byte is found
|
||||
: (val[index] != static_cast<T>(0) ? 0 : 1 + const_strlen(val, index - 1));
|
||||
return index == -1
|
||||
?
|
||||
// Assume a minimum of one trailing nul and do a quick check for the usual case
|
||||
// (single trailing nul) before recursing:
|
||||
N - 1 - (N <= 2 || val[N - 2] != static_cast<T>(0) ? 0 : const_strlen(val, N - 2))
|
||||
// Prevent an underflow in case the string is comprised of all \0 bytes
|
||||
: index == 0
|
||||
? 0
|
||||
// Keep back-tracking until a non-nul byte is found
|
||||
: (val[index] != static_cast<T>(0) ? 0 : 1 + const_strlen(val, index - 1));
|
||||
}
|
||||
static_assert(const_strlen("") == 0, "const_strlen failure");
|
||||
static_assert(const_strlen("a") == 1, "const_strlen failure");
|
||||
|
@ -750,17 +752,17 @@ static_assert(const_strlen("hello") == 5, "const_strlen failure");
|
|||
/// Compile-time assertion of alphabetical sort of array `array`, by specified
|
||||
/// parameter `accessor`. This is only a macro because constexpr lambdas (to
|
||||
/// specify the accessor for the sort key) are C++17 and up.
|
||||
#define ASSERT_SORT_ORDER(array, accessor) \
|
||||
struct verify_ ## array ## _sort_t { \
|
||||
template <class T, size_t N> \
|
||||
constexpr static bool validate(T(&vals)[N], size_t idx = 0) { \
|
||||
return (idx == (((sizeof(array) / sizeof(vals[0]))) - 1)) \
|
||||
? true \
|
||||
: const_strcmp(vals[idx] accessor, vals[idx + 1] accessor) <= 0 && \
|
||||
verify_ ## array ## _sort_t::validate<T, N>(vals, idx + 1); \
|
||||
} \
|
||||
}; \
|
||||
static_assert(verify_ ## array ## _sort_t::validate(array), \
|
||||
#array " members not in asciibetical order!");
|
||||
#define ASSERT_SORT_ORDER(array, accessor) \
|
||||
struct verify_##array##_sort_t { \
|
||||
template <class T, size_t N> \
|
||||
constexpr static bool validate(T (&vals)[N], size_t idx = 0) { \
|
||||
return (idx == (((sizeof(array) / sizeof(vals[0]))) - 1)) \
|
||||
? true \
|
||||
: const_strcmp(vals[idx] accessor, vals[idx + 1] accessor) <= 0 && \
|
||||
verify_##array##_sort_t::validate<T, N>(vals, idx + 1); \
|
||||
} \
|
||||
}; \
|
||||
static_assert(verify_##array##_sort_t::validate(array), \
|
||||
#array " members not in asciibetical order!");
|
||||
|
||||
#endif // FISH_COMMON_H
|
||||
|
|
|
@ -1147,8 +1147,7 @@ bool completer_t::complete_param_for_command(const wcstring &cmd_orig, const wcs
|
|||
|
||||
if (has_force) {
|
||||
*out_do_file = true;
|
||||
}
|
||||
else if (!use_files) {
|
||||
} else if (!use_files) {
|
||||
*out_do_file = false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -361,7 +361,8 @@ void env_init(const struct config_paths_t *paths /* or NULL */) {
|
|||
wcstring nshlvl_str = L"1";
|
||||
if (const char *shlvl_var = getenv("SHLVL")) {
|
||||
const wchar_t *end;
|
||||
// TODO: Figure out how to handle invalid numbers better. Shouldn't we issue a diagnostic?
|
||||
// TODO: Figure out how to handle invalid numbers better. Shouldn't we issue a
|
||||
// diagnostic?
|
||||
long shlvl_i = fish_wcstol(str2wcstring(shlvl_var).c_str(), &end);
|
||||
if (!errno && shlvl_i >= 0) {
|
||||
nshlvl_str = to_string(shlvl_i + 1);
|
||||
|
@ -384,7 +385,8 @@ void env_init(const struct config_paths_t *paths /* or NULL */) {
|
|||
// (see #7636)
|
||||
const char *incoming_pwd_cstr = getenv("PWD");
|
||||
wcstring incoming_pwd = incoming_pwd_cstr ? str2wcstring(incoming_pwd_cstr) : wcstring{};
|
||||
if (!incoming_pwd.empty() && incoming_pwd.front() == L'/' && paths_are_same_file(incoming_pwd, L".")) {
|
||||
if (!incoming_pwd.empty() && incoming_pwd.front() == L'/' &&
|
||||
paths_are_same_file(incoming_pwd, L".")) {
|
||||
vars.set_one(L"PWD", ENV_EXPORT | ENV_GLOBAL, incoming_pwd);
|
||||
} else {
|
||||
vars.set_pwd_from_getcwd();
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "fd_monitor.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <thread> //this_thread::sleep_for
|
||||
#include <thread> //this_thread::sleep_for
|
||||
|
||||
#include "flog.h"
|
||||
#include "io.h"
|
||||
|
|
|
@ -501,8 +501,8 @@ int main(int argc, char **argv) {
|
|||
parser.set_last_statuses(statuses_t::just(STATUS_CMD_OK));
|
||||
|
||||
// If we're profiling startup to a separate file, write it now.
|
||||
if (!opts.profile_startup_output.empty()
|
||||
&& opts.profile_startup_output != opts.profile_output) {
|
||||
if (!opts.profile_startup_output.empty() &&
|
||||
opts.profile_startup_output != opts.profile_output) {
|
||||
parser.emit_profiling(opts.profile_startup_output.c_str());
|
||||
|
||||
// If we are profiling both, ensure the startup data only
|
||||
|
|
|
@ -558,13 +558,14 @@ static void test_convert_ascii() {
|
|||
}
|
||||
}
|
||||
|
||||
/// fish uses the private-use range to encode bytes that could not be decoded using the user's locale.
|
||||
/// If the input could be decoded, but decoded to private-use codepoints, then fish should also use the direct encoding for those bytes.
|
||||
/// Verify that characters in the private use area are correctly round-tripped.
|
||||
/// See #7723.
|
||||
/// fish uses the private-use range to encode bytes that could not be decoded using the user's
|
||||
/// locale. If the input could be decoded, but decoded to private-use codepoints, then fish should
|
||||
/// also use the direct encoding for those bytes. Verify that characters in the private use area are
|
||||
/// correctly round-tripped. See #7723.
|
||||
static void test_convert_private_use() {
|
||||
for (wchar_t wc = ENCODE_DIRECT_BASE; wc < ENCODE_DIRECT_END; wc++) {
|
||||
// Encode the char via the locale. Do not use fish functions which interpret these specially.
|
||||
// Encode the char via the locale. Do not use fish functions which interpret these
|
||||
// specially.
|
||||
char converted[MB_LEN_MAX];
|
||||
mbstate_t state{};
|
||||
size_t len = std::wcrtomb(converted, wc, &state);
|
||||
|
@ -575,7 +576,8 @@ static void test_convert_private_use() {
|
|||
std::string s(converted, len);
|
||||
|
||||
// Ask fish to decode this via str2wcstring.
|
||||
// str2wcstring should notice that the decoded form collides with its private use and encode it directly.
|
||||
// str2wcstring should notice that the decoded form collides with its private use and encode
|
||||
// it directly.
|
||||
wcstring ws = str2wcstring(s);
|
||||
|
||||
// Each byte should be encoded directly, and round tripping should work.
|
||||
|
@ -663,10 +665,10 @@ static void test_tokenizer() {
|
|||
L"Compress_Newlines\n \n\t\n \nInto_Just_One";
|
||||
using tt = token_type_t;
|
||||
const token_type_t types[] = {
|
||||
tt::string, tt::redirect, tt::string, tt::redirect, tt::string, tt::string,
|
||||
tt::string, tt::string, tt::string, tt::pipe, tt::redirect,
|
||||
tt::andand, tt::background, tt::oror, tt::pipe, tt::andand, tt::oror,
|
||||
tt::background, tt::pipe, tt::string, tt::end, tt::string};
|
||||
tt::string, tt::redirect, tt::string, tt::redirect, tt::string, tt::string,
|
||||
tt::string, tt::string, tt::string, tt::pipe, tt::redirect, tt::andand,
|
||||
tt::background, tt::oror, tt::pipe, tt::andand, tt::oror, tt::background,
|
||||
tt::pipe, tt::string, tt::end, tt::string};
|
||||
|
||||
say(L"Test correct tokenization");
|
||||
|
||||
|
@ -3148,7 +3150,7 @@ static void test_complete() {
|
|||
if (system("mkdir -p 'test/complete_test'")) err(L"mkdir failed");
|
||||
if (system("touch 'test/complete_test/has space'")) err(L"touch failed");
|
||||
if (system("touch 'test/complete_test/bracket[abc]'")) err(L"touch failed");
|
||||
#ifndef __CYGWIN__ // Square brackets are not legal path characters on WIN32/CYGWIN
|
||||
#ifndef __CYGWIN__ // Square brackets are not legal path characters on WIN32/CYGWIN
|
||||
if (system(R"(touch 'test/complete_test/gnarlybracket\[abc]')")) err(L"touch failed");
|
||||
#endif
|
||||
if (system("touch 'test/complete_test/testfile'")) err(L"touch failed");
|
||||
|
@ -3188,7 +3190,7 @@ static void test_complete() {
|
|||
completions.front().completion, completions.front().flags, cmdline, &where, false);
|
||||
do_test(newcmdline == L"touch test/complete_test/bracket\\[abc\\] ");
|
||||
|
||||
#ifndef __CYGWIN__ // Square brackets are not legal path characters on WIN32/CYGWIN
|
||||
#ifndef __CYGWIN__ // Square brackets are not legal path characters on WIN32/CYGWIN
|
||||
cmdline = LR"(touch test/complete_test/gnarlybracket\\[)";
|
||||
completions = do_complete(cmdline, {});
|
||||
do_test(completions.size() == 1);
|
||||
|
@ -4619,10 +4621,15 @@ void history_tests_t::test_history_formats() {
|
|||
} else {
|
||||
// The results are in the reverse order that they appear in the bash history file.
|
||||
// We don't expect whitespace to be elided (#4908: except for leading/trailing whitespace)
|
||||
const wchar_t *expected[] = {
|
||||
L"EOF", L"sleep 123", L"a && echo valid construct",
|
||||
L"final line", L"echo supsup", L"export XVAR='exported'",
|
||||
L"history --help", L"echo foo", NULL};
|
||||
const wchar_t *expected[] = {L"EOF",
|
||||
L"sleep 123",
|
||||
L"a && echo valid construct",
|
||||
L"final line",
|
||||
L"echo supsup",
|
||||
L"export XVAR='exported'",
|
||||
L"history --help",
|
||||
L"echo foo",
|
||||
NULL};
|
||||
auto test_history = history_t::with_name(L"bash_import");
|
||||
test_history->populate_from_bash(f);
|
||||
if (!history_equals(test_history, expected)) {
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
|
||||
/// Describes the role of a span of text.
|
||||
enum class highlight_role_t : uint8_t {
|
||||
normal = 0, // normal text
|
||||
error, // error
|
||||
command, // command
|
||||
normal = 0, // normal text
|
||||
error, // error
|
||||
command, // command
|
||||
keyword,
|
||||
statement_terminator, // process separator
|
||||
param, // command parameter (argument)
|
||||
|
|
|
@ -1159,7 +1159,6 @@ static bool should_import_bash_history_line(const wcstring &line) {
|
|||
// "<<" here is a proxy for heredocs (and herestrings).
|
||||
if (line.find(L"<<") != std::string::npos) return false;
|
||||
|
||||
|
||||
if (ast::ast_t::parse(line).errored()) return false;
|
||||
|
||||
// In doing this test do not allow incomplete strings. Hence the "false" argument.
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
#include "history_file.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "fds.h"
|
||||
#include "history.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
// Some forward declarations.
|
||||
static history_item_t decode_item_fish_2_0(const char *base, size_t len);
|
||||
static history_item_t decode_item_fish_1_x(const char *begin, size_t length);
|
||||
|
|
|
@ -291,13 +291,16 @@ void init_input() {
|
|||
input_mapping->add(L"\n", L"execute", DEFAULT_BIND_MODE, DEFAULT_BIND_MODE, false);
|
||||
input_mapping->add(L"\r", L"execute", DEFAULT_BIND_MODE, DEFAULT_BIND_MODE, false);
|
||||
input_mapping->add(L"\t", L"complete", DEFAULT_BIND_MODE, DEFAULT_BIND_MODE, false);
|
||||
input_mapping->add(L"\x3", L"cancel-commandline", DEFAULT_BIND_MODE, DEFAULT_BIND_MODE, false);
|
||||
input_mapping->add(L"\x3", L"cancel-commandline", DEFAULT_BIND_MODE, DEFAULT_BIND_MODE,
|
||||
false);
|
||||
input_mapping->add(L"\x4", L"exit", DEFAULT_BIND_MODE, DEFAULT_BIND_MODE, false);
|
||||
input_mapping->add(L"\x5", L"bind", DEFAULT_BIND_MODE, DEFAULT_BIND_MODE, false);
|
||||
// ctrl-s
|
||||
input_mapping->add(L"\x13", L"pager-toggle-search", DEFAULT_BIND_MODE, DEFAULT_BIND_MODE, false);
|
||||
input_mapping->add(L"\x13", L"pager-toggle-search", DEFAULT_BIND_MODE, DEFAULT_BIND_MODE,
|
||||
false);
|
||||
// ctrl-u
|
||||
input_mapping->add(L"\x15", L"backward-kill-line", DEFAULT_BIND_MODE, DEFAULT_BIND_MODE, false);
|
||||
input_mapping->add(L"\x15", L"backward-kill-line", DEFAULT_BIND_MODE, DEFAULT_BIND_MODE,
|
||||
false);
|
||||
// del/backspace
|
||||
input_mapping->add(L"\x7f", L"backward-delete-char", DEFAULT_BIND_MODE, DEFAULT_BIND_MODE,
|
||||
false);
|
||||
|
|
2
src/io.h
2
src/io.h
|
@ -288,7 +288,7 @@ class output_stream_t;
|
|||
/// An io_buffer_t is a buffer which can populate itself by reading from an fd.
|
||||
/// It is not an io_data_t.
|
||||
class io_buffer_t {
|
||||
public:
|
||||
public:
|
||||
explicit io_buffer_t(size_t limit) : buffer_(limit) {}
|
||||
|
||||
~io_buffer_t();
|
||||
|
|
|
@ -169,9 +169,7 @@ void outputter_t::set_color(rgb_color_t fg, rgb_color_t bg) {
|
|||
return;
|
||||
}
|
||||
|
||||
if ((was_bold && !is_bold)
|
||||
|| (was_dim && !is_dim)
|
||||
|| (was_reverse && !is_reverse)) {
|
||||
if ((was_bold && !is_bold) || (was_dim && !is_dim) || (was_reverse && !is_reverse)) {
|
||||
// Only way to exit bold/dim/reverse mode is a reset of all attributes.
|
||||
writembs(*this, exit_attribute_mode);
|
||||
last_color = normal;
|
||||
|
@ -189,7 +187,8 @@ void outputter_t::set_color(rgb_color_t fg, rgb_color_t bg) {
|
|||
if (!bg.is_special()) {
|
||||
// Background is set.
|
||||
bg_set = true;
|
||||
if (fg == bg) fg = (bg == rgb_color_t::white()) ? rgb_color_t::black() : rgb_color_t::white();
|
||||
if (fg == bg)
|
||||
fg = (bg == rgb_color_t::white()) ? rgb_color_t::black() : rgb_color_t::white();
|
||||
}
|
||||
|
||||
if (enter_bold_mode && enter_bold_mode[0] != '\0') {
|
||||
|
|
|
@ -272,9 +272,7 @@ static void print_profile(const std::deque<profile_item_t> &items, FILE *out) {
|
|||
}
|
||||
}
|
||||
|
||||
void parser_t::clear_profiling() {
|
||||
profile_items.clear();
|
||||
}
|
||||
void parser_t::clear_profiling() { profile_items.clear(); }
|
||||
|
||||
void parser_t::emit_profiling(const char *path) const {
|
||||
// Save profiling information. OK to not use CLO_EXEC here because this is called while fish is
|
||||
|
|
|
@ -656,9 +656,9 @@ static bool process_clean_after_marking(parser_t &parser, bool allow_interactive
|
|||
pid_t pgid = *j->get_pgid();
|
||||
exit_events.push_back(proc_create_event(L"JOB_EXIT", event_type_t::exit, -pgid, 0));
|
||||
}
|
||||
// Caller exit events we still create, which anecdotally fixes `source (thing | psub)` inside event handlers.
|
||||
// This seems benign since this event is barely used (basically only psub), and it seems hard
|
||||
// to construct an infinite loop with it.
|
||||
// Caller exit events we still create, which anecdotally fixes `source (thing | psub)`
|
||||
// inside event handlers. This seems benign since this event is barely used (basically
|
||||
// only psub), and it seems hard to construct an infinite loop with it.
|
||||
exit_events.push_back(
|
||||
proc_create_event(L"JOB_EXIT", event_type_t::caller_exit, j->job_id(), 0));
|
||||
exit_events.back().desc.param1.caller_id = j->internal_job_id;
|
||||
|
|
|
@ -1345,8 +1345,7 @@ void reader_init() {
|
|||
|
||||
// Set up our fixed terminal modes once,
|
||||
// so we don't get flow control just because we inherited it.
|
||||
if (is_interactive_session() &&
|
||||
getpgrp() == tcgetpgrp(STDIN_FILENO)) {
|
||||
if (is_interactive_session() && getpgrp() == tcgetpgrp(STDIN_FILENO)) {
|
||||
term_donate(/* quiet */ true);
|
||||
}
|
||||
|
||||
|
|
|
@ -270,7 +270,6 @@ static void fish_signal_handler(int sig, siginfo_t *info, void *context) {
|
|||
// We have a sigalarm handler that does nothing. This is used in the signal torture
|
||||
// test, to verify that we behave correctly when receiving lots of irrelevant signals.
|
||||
break;
|
||||
|
||||
}
|
||||
errno = saved_errno;
|
||||
}
|
||||
|
|
|
@ -23,21 +23,22 @@
|
|||
*/
|
||||
|
||||
// This version has been altered and ported to C++ for inclusion in fish.
|
||||
#include "fallback.h" // IWYU pragma: keep
|
||||
#include "tinyexpr.h"
|
||||
#include "wutil.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <iterator>
|
||||
#include <utility>
|
||||
|
||||
#include "fallback.h" // IWYU pragma: keep
|
||||
#include "wutil.h"
|
||||
|
||||
// TODO: It would be nice not to rely on a typedef for this, especially one that can only do
|
||||
// functions with two args.
|
||||
using te_fun2 = double (*)(double, double);
|
||||
|
@ -185,14 +186,14 @@ static constexpr double bit_xor(double a, double b) {
|
|||
static double max(double a, double b) {
|
||||
if (std::isnan(a)) return a;
|
||||
if (std::isnan(b)) return b;
|
||||
if (a == b) return std::signbit(a) ? b : a; // treat +0 as larger than -0
|
||||
if (a == b) return std::signbit(a) ? b : a; // treat +0 as larger than -0
|
||||
return a > b ? a : b;
|
||||
}
|
||||
|
||||
static double min(double a, double b) {
|
||||
if (std::isnan(a)) return a;
|
||||
if (std::isnan(b)) return b;
|
||||
if (a == b) return std::signbit(a) ? a : b; // treat -0 as smaller than +0
|
||||
if (a == b) return std::signbit(a) ? a : b; // treat -0 as smaller than +0
|
||||
return a < b ? a : b;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#define FISH_NO_ISW_WRAPPERS
|
||||
#include "config.h"
|
||||
|
||||
#include "wutil.h" // IWYU pragma: keep
|
||||
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -9,16 +11,15 @@
|
|||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <cstring>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/statvfs.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <wctype.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <cstring>
|
||||
#include <cwchar>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
@ -27,7 +28,6 @@
|
|||
#include "fallback.h" // IWYU pragma: keep
|
||||
#include "flog.h"
|
||||
#include "wcstringutil.h"
|
||||
#include "wutil.h" // IWYU pragma: keep
|
||||
|
||||
using cstring = std::string;
|
||||
|
||||
|
@ -139,7 +139,6 @@ wcstring wgetcwd() {
|
|||
return wcstring();
|
||||
}
|
||||
|
||||
|
||||
DIR *wopendir(const wcstring &name) {
|
||||
const cstring tmp = wcs2string(name);
|
||||
return opendir(tmp.c_str());
|
||||
|
|
Loading…
Reference in New Issue
Block a user