diff --git a/src/autoload.cpp b/src/autoload.cpp index 7ecd3cbe9..8550dae1b 100644 --- a/src/autoload.cpp +++ b/src/autoload.cpp @@ -1,7 +1,6 @@ // The classes responsible for autoloading functions and completions. #include "config.h" // IWYU pragma: keep -#include #include #include #include diff --git a/src/autoload.h b/src/autoload.h index 6a395cf08..63886390e 100644 --- a/src/autoload.h +++ b/src/autoload.h @@ -4,6 +4,7 @@ #include #include + #include #include "common.h" diff --git a/src/builtin.cpp b/src/builtin.cpp index e7470806c..6ee4ec986 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -17,18 +17,18 @@ // 4). Use 'git add doc_src/NAME.txt' to start tracking changes to the documentation file. #include "config.h" // IWYU pragma: keep -#include #include #include #include #include -#include #include +#include #include #include #include #include #include + #include #include #include diff --git a/src/builtin.h b/src/builtin.h index f27086799..17f4671a0 100644 --- a/src/builtin.h +++ b/src/builtin.h @@ -3,6 +3,7 @@ #define FISH_BUILTIN_H #include + #include #include "common.h" diff --git a/src/builtin_commandline.cpp b/src/builtin_commandline.cpp index 1a81226bb..dafe6c286 100644 --- a/src/builtin_commandline.cpp +++ b/src/builtin_commandline.cpp @@ -1,7 +1,6 @@ // Functions used for implementing the commandline builtin. #include "config.h" // IWYU pragma: keep -#include #include #include #include diff --git a/src/builtin_complete.h b/src/builtin_complete.h index 3ef45a32d..96d667cba 100644 --- a/src/builtin_complete.h +++ b/src/builtin_complete.h @@ -3,6 +3,7 @@ #define FISH_BUILTIN_COMPLETE_H #include + #include class parser_t; diff --git a/src/builtin_jobs.h b/src/builtin_jobs.h index caf059f88..5c37043ac 100644 --- a/src/builtin_jobs.h +++ b/src/builtin_jobs.h @@ -3,6 +3,7 @@ #define FISH_BUILTIN_JOBS_H #include + #include class parser_t; diff --git a/src/builtin_printf.h b/src/builtin_printf.h index f99a864fd..1f9d44d58 100644 --- a/src/builtin_printf.h +++ b/src/builtin_printf.h @@ -3,6 +3,7 @@ #define FISH_BUILTIN_PRINTF_H #include + #include class parser_t; diff --git a/src/builtin_set.cpp b/src/builtin_set.cpp index 9aa5519e2..810a76aa6 100644 --- a/src/builtin_set.cpp +++ b/src/builtin_set.cpp @@ -453,9 +453,8 @@ int builtin_set(parser_t &parser, io_streams_t &streams, wchar_t **argv) { wchar_t *arg = argv[i]; int slice = 0; - if (!(dest = wcsdup(arg))) { - DIE_MEM(); - } + dest = wcsdup(arg); + assert(dest); if (wcschr(dest, L'[')) { slice = 1; @@ -512,9 +511,8 @@ int builtin_set(parser_t &parser, io_streams_t &streams, wchar_t **argv) { return retcode; } - if (!(dest = wcsdup(argv[w.woptind]))) { - DIE_MEM(); - } + dest = wcsdup(argv[w.woptind]); + assert(dest); if (wcschr(dest, L'[')) { slice = 1; diff --git a/src/builtin_set.h b/src/builtin_set.h index 765857336..134fea28b 100644 --- a/src/builtin_set.h +++ b/src/builtin_set.h @@ -3,6 +3,7 @@ #define FISH_BUILTIN_SET_H #include + #include class parser_t; diff --git a/src/builtin_set_color.cpp b/src/builtin_set_color.cpp index fcbf5b02d..a75989736 100644 --- a/src/builtin_set_color.cpp +++ b/src/builtin_set_color.cpp @@ -1,6 +1,10 @@ // Functions used for implementing the set_color builtin. #include "config.h" +#include +#include +#include + #if HAVE_NCURSES_H #include #elif HAVE_NCURSES_CURSES_H @@ -14,10 +18,6 @@ #include #endif -#include -#include -#include -#include #include #include #include diff --git a/src/builtin_set_color.h b/src/builtin_set_color.h index 7e41cd58b..65647018a 100644 --- a/src/builtin_set_color.h +++ b/src/builtin_set_color.h @@ -3,6 +3,7 @@ #define FISH_BUILTIN_SET_COLOR_H #include + #include class parser_t; diff --git a/src/builtin_string.cpp b/src/builtin_string.cpp index 4293b0d06..f2b565fda 100644 --- a/src/builtin_string.cpp +++ b/src/builtin_string.cpp @@ -5,7 +5,6 @@ #ifdef _WIN32 #define PCRE2_STATIC #endif -#include #include #include #include @@ -370,9 +369,7 @@ struct compiled_regex_t { } match = pcre2_match_data_create_from_pattern(code, 0); - if (match == 0) { - DIE_MEM(); - } + assert(match); } ~compiled_regex_t() { @@ -705,9 +702,8 @@ bool regex_replacer_t::replace_matches(const wchar_t *arg) { bool done = false; while (!done) { - if (output == NULL) { - DIE_MEM(); - } + assert(output); + PCRE2_SIZE outlen = bufsize; pcre2_rc = pcre2_substitute(regex.code, PCRE2_SPTR(arg), arglen, 0, // start offset diff --git a/src/builtin_string.h b/src/builtin_string.h index 49247d9c1..0f530c641 100644 --- a/src/builtin_string.h +++ b/src/builtin_string.h @@ -3,6 +3,7 @@ #define FISH_BUILTIN_STRING_H #include + #include class parser_t; diff --git a/src/builtin_test.cpp b/src/builtin_test.cpp index 2842806dd..648315e3f 100644 --- a/src/builtin_test.cpp +++ b/src/builtin_test.cpp @@ -3,13 +3,13 @@ // Implemented from scratch (yes, really) by way of IEEE 1003.1 as reference. #include "config.h" // IWYU pragma: keep -#include #include #include #include #include #include #include + #include #include #include diff --git a/src/builtin_ulimit.h b/src/builtin_ulimit.h index 1e694e07c..1676b5a35 100644 --- a/src/builtin_ulimit.h +++ b/src/builtin_ulimit.h @@ -3,6 +3,7 @@ #define FISH_BUILTIN_ULIMIT_H #include + #include class parser_t; diff --git a/src/color.cpp b/src/color.cpp index 235e70841..3f6ebac2a 100644 --- a/src/color.cpp +++ b/src/color.cpp @@ -1,7 +1,6 @@ // Color class implementation. #include "config.h" // IWYU pragma: keep -#include #include #include #include @@ -298,7 +297,7 @@ color24_t rgb_color_t::to_color24() const { } unsigned char rgb_color_t::to_name_index() const { - // XXX this should look for the nearest color + // TODO: This should look for the nearest color. assert(type == type_named || type == type_rgb); if (type == type_named) return data.name_idx; if (type == type_rgb) return term16_color_for_rgb(data.color.rgb); @@ -342,8 +341,7 @@ wcstring rgb_color_t::description() const { return L"normal"; } default: { - abort(); - return L""; + DIE("unknown color type"); } } } diff --git a/src/color.h b/src/color.h index 592fdc30b..ec6d29dbb 100644 --- a/src/color.h +++ b/src/color.h @@ -3,6 +3,7 @@ #define FISH_COLOR_H #include + #include #include "common.h" diff --git a/src/common.cpp b/src/common.cpp index db906422e..6daca1ac2 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -1,7 +1,6 @@ // Various functions, mostly string utilities, that are used by most parts of fish. #include "config.h" -#include #include #include #include @@ -28,6 +27,7 @@ #ifdef HAVE_SYS_IOCTL_H #include #endif + #include #include // IWYU pragma: keep #include @@ -266,14 +266,14 @@ char *wcs2str(const wchar_t *in) { if (result) { // It converted into the local buffer, so copy it. result = strdup(result); - if (!result) DIE_MEM(); + assert(result); } return result; } // Here we probably allocate a buffer probably much larger than necessary. char *out = (char *)malloc(MAX_UTF8_BYTES * wcslen(in) + 1); - if (!out) DIE_MEM(); + assert(out); return wcs2str_internal(in, out); } @@ -400,9 +400,7 @@ void append_formatv(wcstring &target, const wchar_t *format, va_list va_orig) { break; } buff = (wchar_t *)realloc((buff == static_buff ? NULL : buff), size); - if (buff == NULL) { - DIE_MEM(); - } + assert(buff != NULL); } // Try printing. @@ -2031,3 +2029,10 @@ void redirect_tty_output() { if (tcgetattr(STDERR_FILENO, &t) == -1 && errno == EIO) dup2(fd, STDERR_FILENO); close(fd); } + +/// Display a failed assertion message, dump a stack trace if possible, then die. +[[noreturn]] void __assert(const char *msg, const char *file, size_t line) { + debug(0, L"%s:%zu: failed assertion: %s", file, line, msg); + show_stackframe(L'E', 99, 1); + abort(); +} diff --git a/src/common.h b/src/common.h index 16798a130..a8deba97e 100644 --- a/src/common.h +++ b/src/common.h @@ -12,6 +12,7 @@ #include #include #include + #include #include #include @@ -125,25 +126,6 @@ enum selection_direction_t { direction_deselect }; -inline bool selection_direction_is_cardinal(selection_direction_t dir) { - switch (dir) { - case direction_north: - case direction_east: - case direction_south: - case direction_west: - case direction_page_north: - case direction_page_south: { - return true; - } - case direction_next: - case direction_prev: - case direction_deselect: { - return false; - } - default: { abort(); } - } -} - /// Issue a debug message with printf-style string formating and automatic line breaking. The string /// will begin with the string \c program_name, followed by a colon and a whitespace. /// @@ -244,20 +226,17 @@ extern bool has_working_tty_timestamps; exit_without_destructors(1); \ } -/// Exit program at once after emitting an error message. -#define DIE(msg) \ - { \ - debug(0, "%s on line %ld of file %s, shutting down fish", msg, (long)__LINE__, __FILE__); \ - FATAL_EXIT(); \ - } - -/// Exit program at once, leaving an error message about running out of memory. -#define DIE_MEM() \ - { \ - fwprintf(stderr, L"fish: Out of memory on line %ld of file %s, shutting down fish\n", \ - (long)__LINE__, __FILE__); \ - FATAL_EXIT(); \ - } +/// Exit the program at once after emitting an error message and stack trace if possible. +/// We use our own private implementation of `assert()` for two reasons. First, some implementations +/// are subtly broken. For example, using `printf()` which can cause problems when mixed with wide +/// stdio functions and should be writing the message to stderr rather than stdout. Second, if +/// possible it is useful to provide additional context such as a stack backtrace. +#undef assert +#undef __assert +//#define assert(e) do {(void)((e) ? ((void)0) : __assert(#e, __FILE__, __LINE__)); } while(false) +#define assert(e) (e) ? ((void)0) : __assert(#e, __FILE__, __LINE__) +#define DIE(msg) __assert(msg, __FILE__, __LINE__) +[[noreturn]] void __assert(const char *msg, const char *file, size_t line); /// Check if signals are blocked. If so, print an error message and return from the function /// performing this check. diff --git a/src/complete.cpp b/src/complete.cpp index 50e890617..2e609bac9 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -5,12 +5,12 @@ /// #include "config.h" // IWYU pragma: keep -#include #include #include #include #include #include + #include #include #include diff --git a/src/complete.h b/src/complete.h index 0820f0dce..afa3c7885 100644 --- a/src/complete.h +++ b/src/complete.h @@ -6,6 +6,7 @@ #define FISH_COMPLETE_H #include + #include #include "common.h" diff --git a/src/env.cpp b/src/env.cpp index e1009196c..40f796746 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -1,7 +1,6 @@ // Functions for setting and getting environment variables. #include "config.h" // IWYU pragma: keep -#include #include #include #include diff --git a/src/env.h b/src/env.h index 29877fec0..ca8be6462 100644 --- a/src/env.h +++ b/src/env.h @@ -4,6 +4,7 @@ #include #include + #include #include #include diff --git a/src/env_universal_common.cpp b/src/env_universal_common.cpp index 47b54cd4c..43f919551 100644 --- a/src/env_universal_common.cpp +++ b/src/env_universal_common.cpp @@ -2,16 +2,15 @@ #include "config.h" // IWYU pragma: keep #include // IWYU pragma: keep -#include #include #include // We need the sys/file.h for the flock() declaration on Linux but not OS X. #include // IWYU pragma: keep // We need the ioctl.h header so we can check if SIOCGIFHWADDR is defined by it so we know if we're // on a Linux system. -#include // IWYU pragma: keep #include #include // IWYU pragma: keep +#include // IWYU pragma: keep #if !defined(__APPLE__) && !defined(__CYGWIN__) #include #endif @@ -26,7 +25,7 @@ #include // IWYU pragma: keep #endif #include -#include // IWYU pragma: keep +#include // IWYU pragma: keep #include // IWYU pragma: keep #include #include diff --git a/src/env_universal_common.h b/src/env_universal_common.h index dcd7b0756..4eb63dadb 100644 --- a/src/env_universal_common.h +++ b/src/env_universal_common.h @@ -4,6 +4,7 @@ #include #include + #include #include #include diff --git a/src/event.h b/src/event.h index 809489f44..aa05030d9 100644 --- a/src/event.h +++ b/src/event.h @@ -7,6 +7,7 @@ #define FISH_EVENT_H #include + #include #include diff --git a/src/exec.cpp b/src/exec.cpp index 9a8d68a38..8b4d57528 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -4,7 +4,6 @@ // performed have been massive. #include "config.h" -#include #include #include #ifdef HAVE_SIGINFO_H diff --git a/src/exec.h b/src/exec.h index 5a7fa78cd..7ce80fb6f 100644 --- a/src/exec.h +++ b/src/exec.h @@ -3,6 +3,7 @@ #define FISH_EXEC_H #include + #include #include "common.h" diff --git a/src/expand.cpp b/src/expand.cpp index 90f3305e6..e8da82563 100644 --- a/src/expand.cpp +++ b/src/expand.cpp @@ -2,7 +2,6 @@ // IWYU pragma: no_include #include "config.h" -#include #include #include #include diff --git a/src/expand.h b/src/expand.h index bf4c1233a..cf984d1b1 100644 --- a/src/expand.h +++ b/src/expand.h @@ -8,6 +8,7 @@ #include "config.h" #include + #include #include diff --git a/src/fallback.cpp b/src/fallback.cpp index 20af4fd5f..0d58db0be 100644 --- a/src/fallback.cpp +++ b/src/fallback.cpp @@ -7,7 +7,6 @@ // IWYU likes to recommend adding term.h when we want ncurses.h. // IWYU pragma: no_include term.h -#include // IWYU pragma: keep #include // IWYU pragma: keep #include // IWYU pragma: keep #include // IWYU pragma: keep diff --git a/src/fish.cpp b/src/fish.cpp index 5b74264a4..eeafa5591 100644 --- a/src/fish.cpp +++ b/src/fish.cpp @@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #include #include #include + #include #include #include @@ -454,9 +455,9 @@ int main(int argc, char **argv) { res = reader_read(fd, empty_ios); if (res) { - debug(1, _(L"Error while reading file %ls\n"), reader_current_filename() - ? reader_current_filename() - : _(L"Standard input")); + debug(1, _(L"Error while reading file %ls\n"), + reader_current_filename() ? reader_current_filename() + : _(L"Standard input")); } reader_pop_current_filename(); } diff --git a/src/fish_indent.cpp b/src/fish_indent.cpp index 80235a2df..e4e6b867f 100644 --- a/src/fish_indent.cpp +++ b/src/fish_indent.cpp @@ -17,7 +17,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #include "config.h" // IWYU pragma: keep -#include #include #include #include @@ -27,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #include #include #include + #include #include #include diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index 3a055ad13..b5705aea7 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -3,7 +3,6 @@ // IWYU pragma: no_include // IWYU pragma: no_include -#include #include #include #include diff --git a/src/function.cpp b/src/function.cpp index da5fc30b5..b3dc699ea 100644 --- a/src/function.cpp +++ b/src/function.cpp @@ -10,6 +10,7 @@ #include #include #include + #include #include #include diff --git a/src/highlight.h b/src/highlight.h index a4fd9b6bd..e4e255f27 100644 --- a/src/highlight.h +++ b/src/highlight.h @@ -2,9 +2,9 @@ #ifndef FISH_HIGHLIGHT_H #define FISH_HIGHLIGHT_H -#include #include #include + #include #include "color.h" diff --git a/src/history.cpp b/src/history.cpp index 31b04263d..595304f62 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -1,7 +1,6 @@ // History functions, part of the user interface. #include "config.h" // IWYU pragma: keep -#include #include #include #include diff --git a/src/history.h b/src/history.h index 6a29d20ce..d398fd9dd 100644 --- a/src/history.h +++ b/src/history.h @@ -9,6 +9,7 @@ #include #include #include + #include #include #include diff --git a/src/input.cpp b/src/input.cpp index 4bdd78544..17b5c6dcc 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1,7 +1,6 @@ // Functions for reading a character of input from stdin. #include "config.h" -#include #include #include #include diff --git a/src/input.h b/src/input.h index 13ed5bea9..403dabf4c 100644 --- a/src/input.h +++ b/src/input.h @@ -4,6 +4,7 @@ #define FISH_INPUT_H #include + #include #include "common.h" diff --git a/src/input_common.h b/src/input_common.h index 3b8bb0535..e48b32d91 100644 --- a/src/input_common.h +++ b/src/input_common.h @@ -3,6 +3,7 @@ #define INPUT_COMMON_H #include + #include #include "common.h" diff --git a/src/intern.cpp b/src/intern.cpp index 2ca0340ac..d7fb6fff6 100644 --- a/src/intern.cpp +++ b/src/intern.cpp @@ -3,6 +3,7 @@ #include #include + #include #include #include diff --git a/src/io.cpp b/src/io.cpp index 22af1195e..0dfb1f75f 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -1,7 +1,6 @@ // Utilities for io redirection. #include "config.h" // IWYU pragma: keep -#include #include #include #include diff --git a/src/io.h b/src/io.h index 25a277cd7..a2340362e 100644 --- a/src/io.h +++ b/src/io.h @@ -4,6 +4,7 @@ #include #include #include + #include // Note that we have to include something to get any _LIBCPP_VERSION defined so we can detect libc++ // So it's key that vector go above. If we didn't need vector for other reasons, we might include diff --git a/src/iothread.cpp b/src/iothread.cpp index 81dd8537d..f4807dd21 100644 --- a/src/iothread.cpp +++ b/src/iothread.cpp @@ -1,6 +1,5 @@ #include "config.h" // IWYU pragma: keep -#include #include #include #include @@ -9,6 +8,7 @@ #include #include #include + #include #include "common.h" @@ -40,8 +40,7 @@ struct spawn_request_t { spawn_request_t() {} - spawn_request_t(void_function_t &&f, void_function_t &&comp) - : handler(f), completion(comp) {} + spawn_request_t(void_function_t &&f, void_function_t &&comp) : handler(f), completion(comp) {} // Move-only spawn_request_t &operator=(const spawn_request_t &) = delete; diff --git a/src/lru.h b/src/lru.h index c3159c8f3..51d7c5e5f 100644 --- a/src/lru.h +++ b/src/lru.h @@ -2,8 +2,8 @@ #ifndef FISH_LRU_H #define FISH_LRU_H -#include #include + #include #include "common.h" @@ -303,19 +303,19 @@ class lru_cache_t { size_t count = 0; while (cursor != &mouth) { if (cursor->prev != prev) { - assert(0 && "Node busted previous link"); + DIE("node busted previous link"); } prev = cursor; cursor = cursor->next; if (count++ > max) { - assert(0 && "LRU cache unable to re-reach the mouth - not circularly linked?"); + DIE("LRU cache unable to re-reach the mouth - not circularly linked?"); } } if (mouth.prev != prev) { - assert(0 && "mouth.prev does not connect to last node"); + DIE("mouth.prev does not connect to last node"); } if (count != expected_count) { - assert(0 && "Linked list count mismatch from map count"); + DIE("linked list count mismatch from map count"); } // Count iterators @@ -325,7 +325,7 @@ class lru_cache_t { iter_dist++; } if (iter_dist != count) { - assert(0 && "Linked list iterator mismatch from map count"); + DIE("linked list iterator mismatch from map count"); } } }; diff --git a/src/output.cpp b/src/output.cpp index 061b8dff9..92b2355bb 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -18,6 +18,7 @@ #endif #include #include + #include #include #include diff --git a/src/output.h b/src/output.h index 6ca31d92c..26fbdc260 100644 --- a/src/output.h +++ b/src/output.h @@ -6,6 +6,7 @@ #define FISH_OUTPUT_H #include + #include #include "color.h" diff --git a/src/pager.cpp b/src/pager.cpp index d84f7913d..e8b0c4967 100644 --- a/src/pager.cpp +++ b/src/pager.cpp @@ -1,7 +1,6 @@ #include "config.h" // IWYU pragma: keep // IWYU pragma: no_include -#include #include #include #include @@ -40,6 +39,24 @@ typedef std::vector comp_info_list_t; /// Text we use for the search field. #define SEARCH_FIELD_PROMPT _(L"search: ") +inline bool selection_direction_is_cardinal(selection_direction_t dir) { + switch (dir) { + case direction_north: + case direction_east: + case direction_south: + case direction_west: + case direction_page_north: + case direction_page_south: { + return true; + } + case direction_next: + case direction_prev: + case direction_deselect: { + return false; + } + } +} + /// Returns numer / denom, rounding up. As a "courtesy" 0/0 is 0. static size_t divide_round_up(size_t numer, size_t denom) { if (numer == 0) return 0; diff --git a/src/pager.h b/src/pager.h index 20c5bcf50..1d1571fb3 100644 --- a/src/pager.h +++ b/src/pager.h @@ -3,6 +3,7 @@ #define FISH_PAGER_H #include + #include #include #include diff --git a/src/parse_execution.cpp b/src/parse_execution.cpp index 7d65622d5..689c9a16c 100644 --- a/src/parse_execution.cpp +++ b/src/parse_execution.cpp @@ -8,7 +8,6 @@ // for the execution to finish to see them. #include "config.h" // IWYU pragma: keep -#include #include #include #include diff --git a/src/parse_tree.cpp b/src/parse_tree.cpp index e6372f3a7..41dc50896 100644 --- a/src/parse_tree.cpp +++ b/src/parse_tree.cpp @@ -1,7 +1,6 @@ // Programmatic representation of fish code. #include "config.h" // IWYU pragma: keep -#include #include #include #include diff --git a/src/parse_tree.h b/src/parse_tree.h index 4f78fd4b0..3d686ce58 100644 --- a/src/parse_tree.h +++ b/src/parse_tree.h @@ -2,10 +2,10 @@ #ifndef FISH_PARSE_PRODUCTIONS_H #define FISH_PARSE_PRODUCTIONS_H -#include #include #include #include + #include #include diff --git a/src/parse_util.cpp b/src/parse_util.cpp index eea3680a8..bf30dad32 100644 --- a/src/parse_util.cpp +++ b/src/parse_util.cpp @@ -4,7 +4,6 @@ // that are somehow related to parsing the code. #include "config.h" // IWYU pragma: keep -#include #include #include #include @@ -300,9 +299,7 @@ static void job_or_process_extent(const wchar_t *buff, size_t cursor_pos, const if (a) *a = begin; if (b) *b = end; buffcpy = wcsndup(begin, end - begin); - if (!buffcpy) { - DIE_MEM(); - } + assert(buffcpy != NULL); tokenizer_t tok(buffcpy, TOK_ACCEPT_UNFINISHED); tok_t token; @@ -659,8 +656,9 @@ std::vector parse_util_compute_indents(const wcstring &src) { // foo ; cas', we get an invalid parse tree (since 'cas' is not valid) but we indent it as if it // were a case item list. parse_node_tree_t tree; - parse_tree_from_string(src, parse_flag_continue_after_error | parse_flag_include_comments | - parse_flag_accept_incomplete_tokens, + parse_tree_from_string(src, + parse_flag_continue_after_error | parse_flag_include_comments | + parse_flag_accept_incomplete_tokens, &tree, NULL /* errors */); // Start indenting at the first node. If we have a parse error, we'll have to start indenting diff --git a/src/parse_util.h b/src/parse_util.h index a4d4e29ef..19a85a8ee 100644 --- a/src/parse_util.h +++ b/src/parse_util.h @@ -3,6 +3,7 @@ #define FISH_PARSE_UTIL_H #include + #include #include "common.h" diff --git a/src/parser.cpp b/src/parser.cpp index 0a3194cc2..27da941a8 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1,9 +1,9 @@ // The fish parser. Contains functions for parsing and evaluating code. #include "config.h" // IWYU pragma: keep -#include #include #include + #include #include diff --git a/src/path.cpp b/src/path.cpp index ae4be9618..6ae5c11bd 100644 --- a/src/path.cpp +++ b/src/path.cpp @@ -3,7 +3,6 @@ // issues. #include "config.h" // IWYU pragma: keep -#include #include #include #include diff --git a/src/proc.cpp b/src/proc.cpp index 2641aff6c..2a57e5ab1 100644 --- a/src/proc.cpp +++ b/src/proc.cpp @@ -14,8 +14,7 @@ #include #include #include -#include -#include + #if HAVE_TERM_H #include #elif HAVE_NCURSES_TERM_H @@ -29,7 +28,10 @@ #endif #include // IWYU pragma: keep #include + #include // IWYU pragma: keep +#include +#include #include "common.h" #include "event.h" diff --git a/src/proc.h b/src/proc.h index ef2aaa759..928e6a8c2 100644 --- a/src/proc.h +++ b/src/proc.h @@ -5,7 +5,6 @@ #define FISH_PROC_H #include "config.h" // IWYU pragma: keep -#include #include #include #include // IWYU pragma: keep diff --git a/src/reader.cpp b/src/reader.cpp index 1aac55357..5c4fe0be6 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -14,7 +14,6 @@ #include "config.h" // IWYU pragma: no_include -#include #include #include #include diff --git a/src/reader.h b/src/reader.h index da675fc68..72680bd87 100644 --- a/src/reader.h +++ b/src/reader.h @@ -5,6 +5,7 @@ #define FISH_READER_H #include + #include #include diff --git a/src/screen.cpp b/src/screen.cpp index 3bccc2411..cad973d4b 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -10,7 +10,10 @@ #include #include #include +#include #include +#include + #if HAVE_NCURSES_H #include #elif HAVE_NCURSES_CURSES_H @@ -23,9 +26,7 @@ #elif HAVE_NCURSES_TERM_H #include #endif -#include -#include -#include + #include #include #include diff --git a/src/screen.h b/src/screen.h index 6ae6f0cb7..2c4212fe6 100644 --- a/src/screen.h +++ b/src/screen.h @@ -10,12 +10,10 @@ #define FISH_SCREEN_H #include "config.h" // IWYU pragma: keep -#include #include #include #include -#include #include #include #include diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index 5fecf7f2f..cb99b98e7 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -2,7 +2,6 @@ // extended to support marks, tokenizing multiple strings and disposing of unused string segments. #include "config.h" // IWYU pragma: keep -#include #include #include #include diff --git a/src/utf8.cpp b/src/utf8.cpp index 55d404fe8..738d82168 100644 --- a/src/utf8.cpp +++ b/src/utf8.cpp @@ -17,6 +17,7 @@ #include // IWYU pragma: keep #include + #include #include diff --git a/src/utf8.h b/src/utf8.h index 3879459b4..49d2b62b8 100644 --- a/src/utf8.h +++ b/src/utf8.h @@ -19,6 +19,7 @@ #define _UTF8_H_ #include + #include #define UTF8_IGNORE_ERROR 0x01 diff --git a/src/wildcard.cpp b/src/wildcard.cpp index 8cc6ca3de..f871db448 100644 --- a/src/wildcard.cpp +++ b/src/wildcard.cpp @@ -2,7 +2,6 @@ // provides recursive wildcards using **. #include "config.h" // IWYU pragma: keep -#include #include #include #include @@ -294,7 +293,7 @@ static bool wildcard_complete_internal(const wchar_t *str, const wchar_t *wc, return false; } default: { - DIE("Unreachable code reached"); + DIE("unreachable code reached"); break; } } diff --git a/src/wutil.cpp b/src/wutil.cpp index 432fd597a..f771696d5 100644 --- a/src/wutil.cpp +++ b/src/wutil.cpp @@ -2,7 +2,6 @@ #define FISH_NO_ISW_WRAPPERS #include "config.h" -#include #include #include #include @@ -353,7 +352,7 @@ wchar_t *wrealpath(const wcstring &pathname, wchar_t *resolved_path) { if (pathsep_idx == cstring::npos) { // No pathsep means a single path component relative to pwd. narrow_res = realpath(".", NULL); - if (!narrow_res) DIE("unexpected realpath(\".\") failure"); + assert(narrow_res != NULL); pathsep_idx = 0; } else { // Only call realpath() on the portion up to the last component.