diff --git a/src/builtin.h b/src/builtin.h index edfdc8e96..4e3852698 100644 --- a/src/builtin.h +++ b/src/builtin.h @@ -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") diff --git a/src/builtin_cd.cpp b/src/builtin_cd.cpp index 880a5e522..8b6b24e17 100644 --- a/src/builtin_cd.cpp +++ b/src/builtin_cd.cpp @@ -60,7 +60,7 @@ maybe_t 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 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()) { diff --git a/src/builtin_set.cpp b/src/builtin_set.cpp index 32c59d03a..4896383c7 100644 --- a/src/builtin_set.cpp +++ b/src/builtin_set.cpp @@ -436,7 +436,6 @@ maybe_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 indexes) { diff --git a/src/builtin_source.cpp b/src/builtin_source.cpp index 8b4bdce73..ca312d3b0 100644 --- a/src/builtin_source.cpp +++ b/src/builtin_source.cpp @@ -80,8 +80,7 @@ maybe_t 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; } diff --git a/src/builtin_type.cpp b/src/builtin_type.cpp index 18994b884..3ab6a2fb9 100644 --- a/src/builtin_type.cpp +++ b/src/builtin_type.cpp @@ -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 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"); } diff --git a/src/color.cpp b/src/color.cpp index 9b0864e9d..2af5718e9 100644 --- a/src/color.cpp +++ b/src/color.cpp @@ -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(-1); auto best_index = static_cast(-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); } diff --git a/src/common.h b/src/common.h index a7d33f851..cbda24a56 100644 --- a/src/common.h +++ b/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 -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(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(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(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(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 \ - 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(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 \ + 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(vals, idx + 1); \ + } \ + }; \ + static_assert(verify_##array##_sort_t::validate(array), \ + #array " members not in asciibetical order!"); #endif // FISH_COMMON_H diff --git a/src/complete.cpp b/src/complete.cpp index 53f29ee18..d04316eae 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -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; diff --git a/src/env.cpp b/src/env.cpp index 7da6e5438..a7a04075d 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -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(); diff --git a/src/fd_monitor.cpp b/src/fd_monitor.cpp index 214b74083..61c0eb851 100644 --- a/src/fd_monitor.cpp +++ b/src/fd_monitor.cpp @@ -4,7 +4,7 @@ #include "fd_monitor.h" #include -#include //this_thread::sleep_for +#include //this_thread::sleep_for #include "flog.h" #include "io.h" diff --git a/src/fish.cpp b/src/fish.cpp index 53063e0e5..91b68f4e9 100644 --- a/src/fish.cpp +++ b/src/fish.cpp @@ -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 diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index 07463e916..280c491f2 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -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)) { diff --git a/src/highlight.h b/src/highlight.h index 9d3389b3f..ed1115078 100644 --- a/src/highlight.h +++ b/src/highlight.h @@ -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) diff --git a/src/history.cpp b/src/history.cpp index 71210e6d9..73bef3f82 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -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. diff --git a/src/history_file.cpp b/src/history_file.cpp index dbb177654..8ce8028bf 100644 --- a/src/history_file.cpp +++ b/src/history_file.cpp @@ -2,11 +2,11 @@ #include "history_file.h" +#include + #include "fds.h" #include "history.h" -#include - // 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); diff --git a/src/input.cpp b/src/input.cpp index e1ae17af9..f1c2f9fed 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -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); diff --git a/src/io.h b/src/io.h index 4b8bf8fd0..4b1b09d7e 100644 --- a/src/io.h +++ b/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(); diff --git a/src/output.cpp b/src/output.cpp index da125840c..052d0aea1 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -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') { diff --git a/src/parser.cpp b/src/parser.cpp index 0c22b0ac9..1bc2271b2 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -272,9 +272,7 @@ static void print_profile(const std::deque &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 diff --git a/src/proc.cpp b/src/proc.cpp index 1e63e7f89..a8b0b82fd 100644 --- a/src/proc.cpp +++ b/src/proc.cpp @@ -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; diff --git a/src/reader.cpp b/src/reader.cpp index 0f6b991b3..5edf3c30e 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -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); } diff --git a/src/signal.cpp b/src/signal.cpp index 16fe044ea..b5334a382 100644 --- a/src/signal.cpp +++ b/src/signal.cpp @@ -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; } diff --git a/src/tinyexpr.cpp b/src/tinyexpr.cpp index dc3afe254..a6ec302bd 100644 --- a/src/tinyexpr.cpp +++ b/src/tinyexpr.cpp @@ -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 #include #include #include #include #include +#include #include #include #include +#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; } diff --git a/src/wutil.cpp b/src/wutil.cpp index d7478fe66..41204fc61 100644 --- a/src/wutil.cpp +++ b/src/wutil.cpp @@ -2,6 +2,8 @@ #define FISH_NO_ISW_WRAPPERS #include "config.h" +#include "wutil.h" // IWYU pragma: keep + #include #include #include @@ -9,16 +11,15 @@ #include #include #include -#include - -#include #include +#include #include #include #include #include #include +#include #include #include #include @@ -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());