From 1f06e5f0b9ee483053b987c9cab9f1f5fce2590c Mon Sep 17 00:00:00 2001 From: Kurtis Rader Date: Wed, 20 Apr 2016 23:00:54 -0700 Subject: add better support for IWYU and fix things Remove the "make iwyu" build target. Move the functionality into the recently introduced lint.fish script. Fix a lot, but not all, of the include-what-you-use errors. Specifically, it fixes all of the IWYU errors on my OS X server but only removes some of them on my Ubuntu 14.04 server. Fixes #2957 --- CONTRIBUTING.md | 18 ++++++++ Makefile.in | 12 +----- README.md | 4 +- build_tools/iwyu.linux.imp | 17 ++++++++ build_tools/iwyu.osx.imp | 97 ++++++++++++++++++++++++++++++++++++++++++++ build_tools/lint.fish | 52 ++++++++++++++++++++---- src/autoload.cpp | 12 ++++-- src/autoload.h | 2 + src/builtin.cpp | 20 ++++----- src/builtin.h | 25 ++++++++++-- src/builtin_commandline.cpp | 24 +++++------ src/builtin_complete.cpp | 23 +++++------ src/builtin_jobs.cpp | 22 ++++------ src/builtin_printf.cpp | 15 ++++++- src/builtin_set.cpp | 24 ++++++----- src/builtin_set_color.cpp | 22 +++++++--- src/builtin_string.cpp | 28 +++++++++---- src/builtin_test.cpp | 17 +++++--- src/builtin_ulimit.cpp | 13 ++---- src/color.cpp | 8 ++-- src/color.h | 2 + src/common.cpp | 16 +++----- src/common.h | 17 ++++---- src/complete.cpp | 10 ++--- src/complete.h | 6 +-- src/env.cpp | 11 +++-- src/env.h | 5 ++- src/env_universal_common.cpp | 28 ++++++------- src/env_universal_common.h | 6 ++- src/event.cpp | 12 +++--- src/event.h | 3 +- src/exec.cpp | 13 +++--- src/exec.h | 4 +- src/expand.cpp | 30 ++++++++------ src/expand.h | 14 +++---- src/fallback.cpp | 38 ++++++++--------- src/fallback.h | 23 +++++++---- src/fish.cpp | 10 ++--- src/fish_indent.cpp | 10 ++--- src/fish_tests.cpp | 36 ++++++++-------- src/function.cpp | 8 ++-- src/function.h | 2 +- src/highlight.cpp | 15 +++---- src/highlight.h | 10 ++--- src/history.cpp | 7 ++-- src/history.h | 7 +++- src/input.cpp | 15 +++---- src/input.h | 5 +-- src/input_common.cpp | 17 ++++---- src/input_common.h | 1 - src/intern.cpp | 6 +-- src/io.cpp | 8 +--- src/io.h | 7 ++-- src/iothread.cpp | 12 +++--- src/iothread.h | 1 - src/key_reader.cpp | 6 +-- src/kill.cpp | 5 +-- src/kill.h | 1 - src/lru.h | 2 +- src/output.cpp | 12 +++--- src/output.h | 7 ++-- src/pager.cpp | 11 +++-- src/pager.h | 4 +- src/parse_constants.h | 5 +-- src/parse_execution.cpp | 12 ++++-- src/parse_execution.h | 3 +- src/parse_productions.cpp | 6 ++- src/parse_productions.h | 8 ++-- src/parse_tree.cpp | 11 ++--- src/parse_tree.h | 7 ++-- src/parse_util.cpp | 12 +++--- src/parse_util.h | 4 +- src/parser.cpp | 15 ++++--- src/parser.h | 10 ++--- src/parser_keywords.cpp | 3 -- src/parser_keywords.h | 3 +- src/path.cpp | 4 +- src/path.h | 3 +- src/postfork.cpp | 9 +++- src/postfork.h | 13 +++--- src/print_help.cpp | 3 -- src/proc.cpp | 22 ++++------ src/proc.h | 13 +++--- src/reader.cpp | 18 ++++---- src/reader.h | 5 ++- src/sanity.cpp | 3 -- src/screen.cpp | 10 +---- src/screen.h | 2 + src/signal.cpp | 11 ++--- src/signal.h | 2 +- src/tokenizer.cpp | 6 +-- src/tokenizer.h | 3 +- src/utf8.cpp | 9 ++-- src/utf8.h | 1 - src/util.cpp | 20 ++------- src/util.h | 4 -- src/wcstringutil.cpp | 4 +- src/wcstringutil.h | 2 +- src/wgetopt.cpp | 6 +-- src/wgetopt.h | 2 +- src/wildcard.cpp | 15 +++---- src/wildcard.h | 5 +-- src/wutil.cpp | 6 +-- src/wutil.h | 4 +- 104 files changed, 687 insertions(+), 535 deletions(-) create mode 100644 build_tools/iwyu.linux.imp create mode 100644 build_tools/iwyu.osx.imp diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8e610b13..c3afbd8f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,9 +1,27 @@ + # Guidelines For Developers This document provides guidelines for making changes to the fish-shell project. This includes rules for how to format the code, naming conventions, etc. It also includes recommended best practices such as creating a Travis-CI account so you can verify your changes pass all the tests before making a pull-request. See the bottom of this document for help on installing the linting and style reformatting tools discussed in the following sections. +Fish source should limit the C++ features it uses to those available in C++03. That allows fish to use a few components from [C++TR1](https://en.wikipedia.org/wiki/C%2B%2B_Technical_Report_1) such as `shared_ptr`. It also allows fish to be built and run on OS X Snow Leopard (released in 2009); the oldest OS X release we still support. + +## Include What You Use + +You should not depend on symbols being visible to a `*.cpp` module from `#include` statements inside another header file. In other words if your module does `#include "common.h"` and that header does `#include "signal.h"` your module should pretend that sub-include is not present. It should instead directly `#include "signal.h"` if it needs any symbol from that header. That makes the actual dependencies much clearer. It also makes it easy to modify the headers included by a specific header file without having to worry that will break any module (or header) that includes a particular header. + +To help enforce this rule the `make lint` (and `make lint-all`) command will run the [include-what-you-use](http://include-what-you-use.org/) tool. The IWYU you project is on [github](https://github.com/include-what-you-use/include-what-you-use). + +To install the tool on OS X you'll need to add a [formula](https://github.com/jasonmp85/homebrew-iwyu) then install it: + +``` +brew tap jasonmp85/iwyu +brew install iwyu +``` + +On Ubuntu you can install it via `sudo apt-get install iwyu`. + ## Lint Free Code Automated analysis tools like cppcheck and oclint can point out potential bugs. They also help ensure the code has a consistent style and that it avoids patterns that tend to confuse people. diff --git a/Makefile.in b/Makefile.in index 0858c647..b73e75d1 100644 --- a/Makefile.in +++ b/Makefile.in @@ -859,19 +859,11 @@ depend: cp config.h /tmp/fish_make_depend/ mv $(subst obj/,/tmp/fish_make_depend/src/,$(FISH_ALL_OBJS:.o=.cpp)) /tmp/fish_make_depend/ cd /tmp/fish_make_depend && \ - makedepend -f$(CURDIR)/Makefile.in -pobj/ -Y -Isrc *.cpp + makedepend -f$(CURDIR)/Makefile.in -pobj/ -Y -Isrc *.cpp rm -Rf /tmp/fish_make_depend ./config.status .PHONY: depend -# Include What You Use -iwyu: - # Requires the --keep-going flag as it always returns 1 - # Can't set MAKEFLAGS on a target-specific basic - $(MAKE) -k _iwyu CXX=include-what-you-use -_iwyu: clean $(PROGRAMS) -.PHONY: iwyu _iwyu - # Lint the code. This only deals with C++ files. lint: build_tools/lint.fish $(CXX) $(CXXFLAGS) @@ -894,7 +886,7 @@ style-all: # Restore the source tree to the state right after extracting a tarball. distclean: clean $(MAKE) -C $(PCRE2_DIR) distclean || true - rm -f config.status config.log config.h Makefile + rm -f config.status config.log config.h Makefile osx/config.h .PHONY: distclean diff --git a/README.md b/README.md index 648e8eb6..7dd426bc 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,9 @@ Detailed user documentation is available by running `help` within fish, and also ## Building -fish is written in a sane subset of C++98, with a few components from C++TR1. It builds successfully with g++ 4.2 or later, and with clang. It also will build as C++11. +Fish can be built using a C++11 environment but only requires C++03. It builds successfully with g++ 4.2 or later, and with clang. This allows fish to run on older systems such as OS X Snow Leopard (released in 2009). -fish can be built using autotools or Xcode. autoconf 2.60 or later is required to build from git versions, but is not required for releases. +Fish can be built using autotools or Xcode. autoconf 2.60 or later is required to build from git versions, but is not required for releases. fish depends on a curses implementation, such as ncurses. The headers and libraries are required for building. diff --git a/build_tools/iwyu.linux.imp b/build_tools/iwyu.linux.imp new file mode 100644 index 00000000..6fc614ae --- /dev/null +++ b/build_tools/iwyu.linux.imp @@ -0,0 +1,17 @@ +# Map file for the include-what-you-use tool on Linux. +[ + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "public", "", "public"] }, + { include: ["", "public", "", "public"] }, + { include: ["", "public", "", "public"] }, + { include: ["", "public", "", "public"] }, + + { symbol: ["size_t", "private", "", "public"] }, + { symbol: ["size_t", "private", "", "public"] }, + { symbol: ["size_t", "private", "", "public"] }, + { symbol: ["uint64_t", "private", "", "public"] }, +] diff --git a/build_tools/iwyu.osx.imp b/build_tools/iwyu.osx.imp new file mode 100644 index 00000000..cad467cd --- /dev/null +++ b/build_tools/iwyu.osx.imp @@ -0,0 +1,97 @@ +# Map file for the include-what-you-use tool on OS X. For some reason +# the version installed by HomeBrew doesn't have useful mappings for the +# system provided private headers. +[ + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["<_wctype.h>", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["<_types/_intmax_t.h>", "private", "", "public"] }, + { include: ["<_types/_uintmax_t.h>", "private", "", "public"] }, + { include: ["<_types/_uint8_t.h>", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["<_types/_uint64_t.h>", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["<__functional_base>", "private", "", "public"] }, + { include: ["<__functional_base>", "private", "", "public"] }, + { include: ["<__functional_base>", "private", "", "public"] }, + { include: ["<__tree>", "private", "", "public"] }, + { include: ["<__tree>", "private", "", "public"] }, + { include: ["<_types/_uint32_t.h>", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, + { include: ["", "private", "", "public"] }, +# { include: ["<>", "private", "<>", "public"] }, + + { symbol: ["NULL", "private", "", "public"] }, + { symbol: ["NULL", "private", "", "public"] }, + { symbol: ["NULL", "private", "", "public"] }, + { symbol: ["NULL", "private", "", "public"] }, + { symbol: ["off_t", "private", "", "public"] }, + { symbol: ["size_t", "private", "", "public"] }, + { symbol: ["size_t", "private", "", "public"] }, + { symbol: ["size_t", "private", "", "public"] }, + { symbol: ["off_t", "private", "", "public"] }, + { symbol: ["size_t", "private", "", "public"] }, + { symbol: ["ssize_t", "private", "", "public"] }, + { symbol: ["intptr_t", "private", "", "public"] }, + { symbol: ["ssize_t", "private", "", "public"] }, + { symbol: ["gid_t", "private", "", "public"] }, + { symbol: ["uid_t", "private", "", "public"] }, + { symbol: ["pid_t", "private", "", "public"] }, + { symbol: ["pid_t", "private", "", "public"] }, + { symbol: ["uid_t", "private", "", "public"] }, + { symbol: ["gid_t", "private", "", "public"] }, + { symbol: ["uint32_t", "private", "", "public"] }, + { symbol: ["uint32_t", "private", "", "public"] }, + { symbol: ["intptr_t", "private", "", "public"] }, + { symbol: ["size_t", "private", "", "public"] }, + { symbol: ["tparm", "private", "", "public"] }, + { symbol: ["ERR", "private", "", "public"] }, + { symbol: ["select", "private", "", "public"] }, + { symbol: ["_LIBCPP_VERSION", "private", "", "public"] }, + { symbol: ["_LIBCPP_VERSION", "private", "", "public"] }, + { symbol: ["MB_CUR_MAX", "private", "", "public"] }, + { symbol: ["MB_CUR_MAX", "private", "", "public"] }, +] diff --git a/build_tools/lint.fish b/build_tools/lint.fish index 287269da..5ac05d7d 100755 --- a/build_tools/lint.fish +++ b/build_tools/lint.fish @@ -7,6 +7,8 @@ set cppchecks warning,performance,portability,information,missingInclude set cppcheck_args set c_files set all no +set kernel_name (uname -s) +set machine_type (uname -m) set -gx CXX $argv[1] set -e argv[1] @@ -17,15 +19,27 @@ if test "$argv[1]" = "--all" set -e argv[1] end +if test $kernel_name = Linux + # This is an awful hack. However, the include-what-you-use program spews lots of errors like + # /usr/include/unistd.h:226:10: fatal error: 'stddef.h' file not found + # if we don't explicitly tell it where to find the system headers on Linux. See + # http://stackoverflow.com/questions/19642590/libtooling-cant-find-stddef-h-nor-other-headers/ + set -l sys_includes (eval $CXX -v -c src/builtin.cpp 2>&1 | \ + sed -n -e '/^#include <...> search/,/^End of search list/s/^ *//p')[2..-2] + set -x CPLUS_INCLUDE_PATH (string join ':' $sys_includes) +end + # We only want -D and -I options to be passed thru to cppcheck. for arg in $argv if string match -q -- '-D*' $arg set cppcheck_args $cppcheck_args $arg else if string match -q -- '-I*' $arg set cppcheck_args $cppcheck_args $arg + else if string match -q -- '-iquote*' $arg + set cppcheck_args $cppcheck_args $arg end end -if test (uname -m) = "x86_64" +if test "$machine_type" = "x86_64" set cppcheck_args -D__x86_64__ -D__LP64__ $cppcheck_args end @@ -37,7 +51,7 @@ else set files (git status --porcelain --short --untracked-files=all | sed -e 's/^ *[^ ]* *//') if not set -q files[1] # No pending changes so lint the files in the most recent commit. - set files (git show --word-diff=porcelain --name-only --pretty=oneline head)[2..-1] + set files (git show --word-diff=porcelain --name-only --pretty=oneline)[2..-1] end # Extract just the C/C++ files. @@ -46,6 +60,26 @@ end # We now have a list of files to check so run the linters. if set -q c_files[1] + if type -q iwyu + # The stderr to stdout redirection is because cppcheck, incorrectly IMHO, writes its + # diagnostic messages to stderr. Anyone running this who wants to capture its output will + # expect those messages to be written to stdout. + for c_file in $c_files + echo + echo ======================================== + echo Running IWYU on $c_file + echo ======================================== + switch $kernel_name + case Darwin + include-what-you-use -Xiwyu --no_default_mappings -Xiwyu --mapping_file=build_tools/iwyu.osx.imp $cppcheck_args $c_file 2>&1 + case Linux + include-what-you-use -Xiwyu --mapping_file=build_tools/iwyu.linux.imp $cppcheck_args $c_file 2>&1 + case '*' # hope for the best + include-what-you-use $cppcheck_args $c_file 2>&1 + end + end + end + if type -q cppcheck echo echo ======================================== @@ -54,7 +88,7 @@ if set -q c_files[1] # The stderr to stdout redirection is because cppcheck, incorrectly IMHO, writes its # diagnostic messages to stderr. Anyone running this who wants to capture its output will # expect those messages to be written to stdout. - cppcheck -q --verbose --std=posix --std=c11 --language=c++ --template "[{file}:{line}]: {severity} ({id}): {message}" --suppress=missingIncludeSystem --inline-suppr --enable=$cppchecks $cppcheck_args $c_files 2>& 1 + cppcheck -q --verbose --std=posix --std=c11 --language=c++ --template "[{file}:{line}]: {severity} ({id}): {message}" --suppress=missingIncludeSystem --inline-suppr --enable=$cppchecks $cppcheck_args $c_files 2>&1 end if type -q oclint @@ -65,25 +99,25 @@ if set -q c_files[1] # The stderr to stdout redirection is because oclint, incorrectly writes its final summary # counts of the errors detected to stderr. Anyone running this who wants to capture its # output will expect those messages to be written to stdout. - if test (uname -s) = "Darwin" + if test "$kernel_name" = "Darwin" if not test -f compile_commands.json - xcodebuild > xcodebuild.log - oclint-xcodebuild xcodebuild.log > /dev/null + xcodebuild >xcodebuild.log + oclint-xcodebuild xcodebuild.log >/dev/null end if test $all = yes - oclint-json-compilation-database -e '/pcre2-10.21/' -- -enable-global-analysis 2>& 1 + oclint-json-compilation-database -e '/pcre2-10.21/' -- -enable-global-analysis 2>&1 else set i_files for f in $c_files set i_files $i_files -i $f end echo oclint-json-compilation-database -e '/pcre2-10.21/' $i_files - oclint-json-compilation-database -e '/pcre2-10.21/' $i_files 2>& 1 + oclint-json-compilation-database -e '/pcre2-10.21/' $i_files 2>&1 end else # Presumably we're on Linux or other platform not requiring special # handling for oclint to work. - oclint $c_files -- $argv 2>& 1 + oclint $c_files -- $argv 2>&1 end end else diff --git a/src/autoload.cpp b/src/autoload.cpp index ae63335a..6f7c3905 100644 --- a/src/autoload.cpp +++ b/src/autoload.cpp @@ -1,5 +1,4 @@ // The classes responsible for autoloading functions and completions. -#include "autoload.h" #include #include #include @@ -9,12 +8,17 @@ #include #include #include +#include +#include +#include +#include +#include + +#include "autoload.h" #include "common.h" -#include "config.h" // IWYU pragma: keep #include "env.h" #include "exec.h" -#include "signal.h" // IWYU pragma: keep - needed for CHECK_BLOCK -#include "wutil.h" +#include "wutil.h" // IWYU pragma: keep // The time before we'll recheck an autoloaded file. static const int kAutoloadStalenessInterval = 15; diff --git a/src/autoload.h b/src/autoload.h index 5f8b4d31..5b1d5dfe 100644 --- a/src/autoload.h +++ b/src/autoload.h @@ -6,6 +6,8 @@ #include #include #include +#include + #include "common.h" #include "lru.h" diff --git a/src/builtin.cpp b/src/builtin.cpp index a2bf6736..b7a84c69 100644 --- a/src/builtin.cpp +++ b/src/builtin.cpp @@ -15,12 +15,10 @@ // Check the other builtin manuals for proper syntax. // // 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 @@ -31,12 +29,13 @@ #include #include #include -#include #include #include +#include +#include // IWYU pragma: keep +#include #include "fallback.h" // IWYU pragma: keep - #include "builtin.h" #include "complete.h" #include "env.h" @@ -49,7 +48,6 @@ #include "input.h" #include "intern.h" #include "parse_constants.h" -#include "parse_tree.h" #include "parse_util.h" #include "parser.h" #include "parser_keywords.h" @@ -61,6 +59,8 @@ #include "wcstringutil.h" #include "wgetopt.h" #include "wutil.h" +#include "common.h" +#include "io.h" // The default prompt for the read command. #define DEFAULT_READ_PROMPT L"set_color green; echo -n read; set_color normal; echo -n \"> \"" @@ -103,7 +103,7 @@ int builtin_count_args(const wchar_t *const *argv) { /// This function works like wperror, but it prints its result into the streams.err string instead /// to stderr. Used by the builtin commands. -static void builtin_wperror(const wchar_t *s, io_streams_t &streams) { +void builtin_wperror(const wchar_t *s, io_streams_t &streams) { char *err = strerror(errno); if (s != NULL) { streams.err.append(s); @@ -228,15 +228,15 @@ void builtin_print_help(parser_t &parser, io_streams_t &streams, const wchar_t * } /// Perform error reporting for encounter with unknown option. -static void builtin_unknown_option(parser_t &parser, io_streams_t &streams, const wchar_t *cmd, - const wchar_t *opt) { +void builtin_unknown_option(parser_t &parser, io_streams_t &streams, const wchar_t *cmd, + const wchar_t *opt) { streams.err.append_format(BUILTIN_ERR_UNKNOWN, cmd, opt); builtin_print_help(parser, streams, cmd, streams.err); } /// Perform error reporting for encounter with missing argument. -static void builtin_missing_argument(parser_t &parser, io_streams_t &streams, const wchar_t *cmd, - const wchar_t *opt) { +void builtin_missing_argument(parser_t &parser, io_streams_t &streams, const wchar_t *cmd, + const wchar_t *opt) { streams.err.append_format(BUILTIN_ERR_MISSING, cmd, opt); builtin_print_help(parser, streams, cmd, streams.err); } diff --git a/src/builtin.h b/src/builtin.h index cea7318a..0d62babe 100644 --- a/src/builtin.h +++ b/src/builtin.h @@ -2,14 +2,15 @@ #ifndef FISH_BUILTIN_H #define FISH_BUILTIN_H -#include // for size_t -#include // for vector +#include +#include #include "common.h" -#include "io.h" class completion_t; class parser_t; +class output_stream_t; +struct io_streams_t; enum { COMMAND_NOT_BUILTIN, BUILTIN_REGULAR, BUILTIN_FUNCTION }; @@ -97,4 +98,22 @@ wcstring builtin_help_get(parser_t &parser, const wchar_t *cmd); int define_function(parser_t &parser, io_streams_t &streams, const wcstring_list_t &c_args, const wcstring &contents, int definition_line_offset, wcstring *out_err); +// Print help for the specified builtin. If \c b is sb_err, also print the line information. +void builtin_print_help(parser_t &parser, io_streams_t &streams, const wchar_t *cmd, + output_stream_t &b); + +// Counts the number of non null pointers in the specified array. +int builtin_count_args(const wchar_t *const *argv); + +// Perform error reporting for encounter with unknown option. +void builtin_unknown_option(parser_t &parser, io_streams_t &streams, const wchar_t *cmd, + const wchar_t *opt); + +// Perform error reporting for encounter with missing argument. +void builtin_missing_argument(parser_t &parser, io_streams_t &streams, const wchar_t *cmd, + const wchar_t *opt); + +// This function works like wperror, but it prints its result into the streams.err string instead +// to stderr. Used by the builtin commands. +void builtin_wperror(const wchar_t *s, io_streams_t &streams); #endif diff --git a/src/builtin_commandline.cpp b/src/builtin_commandline.cpp index 122681af..e84bcb07 100644 --- a/src/builtin_commandline.cpp +++ b/src/builtin_commandline.cpp @@ -1,33 +1,29 @@ /** \file builtin_commandline.c Functions defining the commandline builtin Functions used for implementing the commandline builtin. - */ -#include "config.h" - #include -#include #include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include "fallback.h" +#include "fallback.h" // IWYU pragma: keep #include "util.h" - -#include "wutil.h" #include "builtin.h" #include "common.h" #include "wgetopt.h" #include "reader.h" #include "proc.h" -#include "parser.h" #include "tokenizer.h" -#include "input_common.h" #include "input.h" - #include "parse_util.h" +#include "io.h" +#include "wutil.h" // IWYU pragma: keep + +class parser_t; /** Which part of the comandbuffer are we operating on diff --git a/src/builtin_complete.cpp b/src/builtin_complete.cpp index f7f3f256..bd117a8f 100644 --- a/src/builtin_complete.cpp +++ b/src/builtin_complete.cpp @@ -1,28 +1,27 @@ /** \file builtin_complete.c Functions defining the complete builtin Functions used for implementing the complete builtin. - */ -#include "config.h" - #include -#include #include -#include -#include -#include -#include - -#include "fallback.h" -#include "util.h" +#include +#include +#include // IWYU pragma: keep +#include -#include "wutil.h" +#include "fallback.h" // IWYU pragma: keep #include "builtin.h" #include "common.h" #include "complete.h" #include "wgetopt.h" #include "parser.h" #include "reader.h" +#include "env.h" +#include "io.h" +#include "parse_constants.h" +#include "proc.h" +#include "parse_util.h" +#include "wutil.h" // IWYU pragma: keep /* builtin_complete_* are a set of rather silly looping functions that diff --git a/src/builtin_jobs.cpp b/src/builtin_jobs.cpp index 9cad7d55..41982769 100644 --- a/src/builtin_jobs.cpp +++ b/src/builtin_jobs.cpp @@ -1,29 +1,23 @@ /** \file builtin_jobs.c Functions for executing the jobs builtin. */ -#include "config.h" +#include "config.h" // IWYU pragma: keep -#include -#include -#include -#include -#include #include -#include -#include -#include -#include - -#include "fallback.h" -#include "util.h" +#include +#ifdef HAVE__PROC_SELF_STAT +#include +#endif +#include "fallback.h" // IWYU pragma: keep #include "wutil.h" #include "builtin.h" #include "proc.h" -#include "parser.h" #include "common.h" #include "wgetopt.h" +#include "io.h" +class parser_t; /** Print modes for the jobs builtin diff --git a/src/builtin_printf.cpp b/src/builtin_printf.cpp index d5fa1d63..97427948 100644 --- a/src/builtin_printf.cpp +++ b/src/builtin_printf.cpp @@ -49,11 +49,24 @@ /* This file has been imported from source code of printf command in GNU Coreutils version 6.9 */ +#include +#include +#include +#include +#include #include #include -#include +#include +#include +#include #include "common.h" +#include "io.h" +#include "wutil.h" // IWYU pragma: keep +#include "proc.h" +#include "builtin.h" + +class parser_t; struct builtin_printf_state_t { diff --git a/src/builtin_set.cpp b/src/builtin_set.cpp index bd871b09..823bdebc 100644 --- a/src/builtin_set.cpp +++ b/src/builtin_set.cpp @@ -3,28 +3,30 @@ Functions used for implementing the set builtin. */ -#include "config.h" - #include -#include #include #include -#include -#include -#include #include #include -#include "fallback.h" -#include "util.h" - -#include "wutil.h" +#include +#include +#include +#include +#include +#include +#include + +#include "fallback.h" // IWYU pragma: keep +#include "wutil.h" // IWYU pragma: keep #include "builtin.h" #include "env.h" #include "expand.h" #include "common.h" #include "wgetopt.h" #include "proc.h" -#include "parser.h" +#include "io.h" + +class parser_t; /** Error message for invalid path operations diff --git a/src/builtin_set_color.cpp b/src/builtin_set_color.cpp index 449e3895..d3b744cd 100644 --- a/src/builtin_set_color.cpp +++ b/src/builtin_set_color.cpp @@ -5,10 +5,6 @@ Functions used for implementing the set_color builtin. */ #include "config.h" -#include "builtin.h" -#include "color.h" -#include "output.h" - #if HAVE_NCURSES_H #include #elif HAVE_NCURSES_CURSES_H @@ -16,13 +12,29 @@ Functions used for implementing the set_color builtin. #else #include #endif - #if HAVE_TERM_H #include #elif HAVE_NCURSES_TERM_H #include #endif +#include +#include +#include +#include +#include +#include +#include + +#include "builtin.h" +#include "color.h" +#include "output.h" +#include "wgetopt.h" +#include "proc.h" +#include "io.h" +#include "common.h" +#include "wutil.h" // IWYU pragma: keep +class parser_t; /** Error message for invalid path operations diff --git a/src/builtin_string.cpp b/src/builtin_string.cpp index 10508a71..9efa6c2f 100644 --- a/src/builtin_string.cpp +++ b/src/builtin_string.cpp @@ -1,25 +1,37 @@ /** \file builtin_string.cpp Implementation of the string builtin. */ - -#include "config.h" // IWYU pragma: keep +#include "config.h" #define PCRE2_CODE_UNIT_WIDTH WCHAR_T_BITS #ifdef _WIN32 #define PCRE2_STATIC #endif -#include "pcre2.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "pcre2.h" #include "builtin.h" #include "common.h" -#include "parser.h" #include "parse_util.h" #include "wgetopt.h" #include "wildcard.h" -#include "wutil.h" -#include -#include -#include +#include "fallback.h" // IWYU pragma: keep +#include "io.h" +#include "wutil.h" // IWYU pragma: keep + +class parser_t; #define MAX_REPLACE_SIZE size_t(1048576) // pcre2_substitute maximum output size in wchar_t #define STRING_ERR_MISSING _(L"%ls: Expected argument\n") diff --git a/src/builtin_test.cpp b/src/builtin_test.cpp index 00fb8860..9c66238d 100644 --- a/src/builtin_test.cpp +++ b/src/builtin_test.cpp @@ -4,17 +4,22 @@ Functions used for implementing the test builtin. Implemented from scratch (yes, really) by way of IEEE 1003.1 as reference. */ - -#include "config.h" -#include "common.h" -#include "builtin.h" -#include "wutil.h" -#include "proc.h" #include #include #include #include +#include +#include +#include +#include +#include +#include +#include "common.h" +#include "builtin.h" +#include "wutil.h" // IWYU pragma: keep +#include "proc.h" +#include "io.h" enum { diff --git a/src/builtin_ulimit.cpp b/src/builtin_ulimit.cpp index 3b2dadd6..27036023 100644 --- a/src/builtin_ulimit.cpp +++ b/src/builtin_ulimit.cpp @@ -3,24 +3,19 @@ Functions used for implementing the ulimit builtin. */ -#include "config.h" - -#include -#include #include -#include -#include #include -#include #include -#include "fallback.h" +#include "fallback.h" // IWYU pragma: keep #include "util.h" - #include "builtin.h" #include "common.h" #include "wgetopt.h" +#include "io.h" +#include "wutil.h" // IWYU pragma: keep +class parser_t; /** Struct describing a resource limit diff --git a/src/color.cpp b/src/color.cpp index 4c3c89d2..6ff52e35 100644 --- a/src/color.cpp +++ b/src/color.cpp @@ -1,11 +1,11 @@ // Color class implementation. -#include "color.h" -#include "fallback.h" // IWYU pragma: keep #include #include #include -#include -#include + +#include "color.h" +#include "fallback.h" // IWYU pragma: keep +#include "common.h" bool rgb_color_t::try_parse_special(const wcstring &special) { diff --git a/src/color.h b/src/color.h index 1faa35a6..881ce4b3 100644 --- a/src/color.h +++ b/src/color.h @@ -4,6 +4,8 @@ #include #include +#include + #include "common.h" /* 24 bit color */ diff --git a/src/common.cpp b/src/common.cpp index 545288fc..3f738ec0 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -3,16 +3,12 @@ Various functions, mostly string utilities, that are used by most parts of fish. */ - #include "config.h" - #include - #ifdef HAVE_SIGINFO_H #include #endif - #include #include #include @@ -22,28 +18,26 @@ parts of fish. #include #include #include - - #ifdef HAVE_SYS_IOCTL_H #include #endif - #include #include #include #include #include +#include #include #include #include - #ifdef HAVE_EXECINFO_H #include #endif +#include +#include -#include "fallback.h" - -#include "wutil.h" +#include "fallback.h" // IWYU pragma: keep +#include "wutil.h" // IWYU pragma: keep #include "common.h" #include "expand.h" #include "wildcard.h" diff --git a/src/common.h b/src/common.h index d6eb0191..dc6e0236 100644 --- a/src/common.h +++ b/src/common.h @@ -1,29 +1,26 @@ /** \file common.h Prototypes for various functions, mostly string utilities, that are used by most parts of fish. */ - #ifndef FISH_COMMON_H -/** - Header guard -*/ #define FISH_COMMON_H +#include "config.h" #include #include #include -#include #include #include #include #include #include -#include -#include #include - #include -#include "config.h" -#include "fallback.h" +#include +#include +#include + +#include "fallback.h" // IWYU pragma: keep +#include "signal.h" // IWYU pragma: keep /** Avoid writing the type name twice in a common "static_cast-initialization". diff --git a/src/complete.cpp b/src/complete.cpp index 5c817b8d..db63e348 100644 --- a/src/complete.cpp +++ b/src/complete.cpp @@ -2,10 +2,7 @@ These functions are used for storing and retrieving tab-completion data, as well as for performing tab-completion. */ -#include "config.h" - #include -#include #include #include #include @@ -17,10 +14,11 @@ #include #include #include +#include +#include -#include "fallback.h" // IWYU pragma: keep +#include "fallback.h" // IWYU pragma: keep #include "util.h" - #include "wildcard.h" #include "proc.h" #include "parser.h" @@ -32,7 +30,7 @@ #include "expand.h" #include "common.h" #include "parse_util.h" -#include "wutil.h" +#include "wutil.h" // IWYU pragma: keep #include "path.h" #include "parse_tree.h" #include "iothread.h" diff --git a/src/complete.h b/src/complete.h index 6cbb13bc..1e2c1a18 100644 --- a/src/complete.h +++ b/src/complete.h @@ -6,16 +6,14 @@ */ #ifndef FISH_COMPLETE_H - -/** - Header guard -*/ #define FISH_COMPLETE_H #include #include +#include #include "common.h" + /** * Use all completions */ diff --git a/src/env.cpp b/src/env.cpp index 56c9deb0..22d4c573 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -1,8 +1,6 @@ /** \file env.c Functions for setting and getting environment variables. */ -#include "config.h" // IWYU pragma: keep - #include #include #include @@ -19,10 +17,11 @@ #include #include #include +#include +#include -#include "fallback.h" - -#include "wutil.h" +#include "fallback.h" // IWYU pragma: keep +#include "wutil.h" // IWYU pragma: keep #include "proc.h" #include "common.h" #include "env.h" @@ -34,8 +33,8 @@ #include "input.h" #include "event.h" #include "path.h" - #include "fish_version.h" +#include "input_common.h" /** Value denoting a null string */ #define ENV_NULL L"\x1d" diff --git a/src/env.h b/src/env.h index 3eb6313f..4b14d548 100644 --- a/src/env.h +++ b/src/env.h @@ -1,14 +1,15 @@ /** \file env.h Prototypes for functions for setting and getting environment variables. */ - #ifndef FISH_ENV_H #define FISH_ENV_H -#include #include #include #include +#include +#include +#include #include "common.h" diff --git a/src/env_universal_common.cpp b/src/env_universal_common.cpp index 900a2d75..3964a4d8 100644 --- a/src/env_universal_common.cpp +++ b/src/env_universal_common.cpp @@ -3,46 +3,46 @@ The utility library for universal variables. Used both by the client library and by the daemon. - */ #include "config.h" -#include "env_universal_common.h" - #include -#include #include -#include -#include -#include // IWYU pragma: keep - needed for htonl +#include // IWYU pragma: keep #include #include #include #include #include -#include -#include #include #include #include -#include #include #include #include #include -#include -#include - +#include +#include +#include #ifdef HAVE_SYS_SELECT_H #include #endif +#include +#include +#include +// 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 +// We need the sys/file.h for the flock() declaration on Linux but not OS X. +#include // IWYU pragma: keep +#include "env_universal_common.h" #include "fallback.h" // IWYU pragma: keep #include "util.h" - #include "common.h" #include "wutil.h" #include "utf8.h" +#include "env.h" #if __APPLE__ #define FISH_NOTIFYD_AVAILABLE 1 diff --git a/src/env_universal_common.h b/src/env_universal_common.h index edc36016..8e319fe1 100644 --- a/src/env_universal_common.h +++ b/src/env_universal_common.h @@ -1,11 +1,13 @@ #ifndef FISH_ENV_UNIVERSAL_COMMON_H #define FISH_ENV_UNIVERSAL_COMMON_H -#include -#include #include #include +#include +#include +#include #include + #include "common.h" #include "wutil.h" #include "env.h" diff --git a/src/event.cpp b/src/event.cpp index eeff3eb5..ee1d7c0a 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -1,18 +1,17 @@ /** \file event.c Functions for handling event triggers - */ -#include "config.h" // IWYU pragma: keep - #include -#include #include -#include +#include +#include +#include #include +#include #include "fallback.h" // IWYU pragma: keep -#include "wutil.h" // IWYU pragma: keep - needed for gettext +#include "wutil.h" // IWYU pragma: keep #include "input_common.h" #include "proc.h" #include "parser.h" @@ -21,7 +20,6 @@ #include "signal.h" #include "io.h" - /** Number of signals that can be queued before an overflow occurs */ diff --git a/src/event.h b/src/event.h index bf068c5d..93051fac 100644 --- a/src/event.h +++ b/src/event.h @@ -12,8 +12,9 @@ #ifndef FISH_EVENT_H #define FISH_EVENT_H -#include +#include #include +#include #include "common.h" diff --git a/src/exec.cpp b/src/exec.cpp index c9e9833e..02d1b724 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -4,8 +4,7 @@ Some of the code in this file is based on code from the Glibc manual, though the changes performed have been massive. */ - -#include "config.h" // IWYU pragma: keep +#include "config.h" #include #include @@ -24,17 +23,16 @@ #include #include #include -#include // IWYU pragma: keep - suggests instead -#include - +#include #ifdef HAVE_SIGINFO_H #include #endif +#include -#include "fallback.h" // IWYU pragma: keep +#include "fallback.h" // IWYU pragma: keep #include "postfork.h" #include "common.h" -#include "wutil.h" +#include "wutil.h" // IWYU pragma: keep #include "proc.h" #include "exec.h" #include "parser.h" @@ -42,7 +40,6 @@ #include "function.h" #include "env.h" #include "signal.h" -#include "parse_util.h" #include "io.h" #include "parse_tree.h" #include "reader.h" diff --git a/src/exec.h b/src/exec.h index 41dc3193..f2d6c8e7 100644 --- a/src/exec.h +++ b/src/exec.h @@ -3,13 +3,11 @@ */ #ifndef FISH_EXEC_H -/** - Header guard -*/ #define FISH_EXEC_H #include #include +#include #include "common.h" diff --git a/src/expand.cpp b/src/expand.cpp index 72a72e77..1ac626e9 100644 --- a/src/expand.cpp +++ b/src/expand.cpp @@ -4,11 +4,10 @@ String expansion functions. These functions perform several kinds of parameter expansion. */ - -#include "config.h" // IWYU pragma: keep +// IWYU pragma: no_include +#include "config.h" #include -#include #include #include #include @@ -16,38 +15,43 @@ parameter expansion. #include #include #include -#include -#include #include #include #ifdef HAVE_SYS_SYSCTL_H -#include // IWYU pragma: keep - needed for KERN_PROCARGS2 +#include // IWYU pragma: keep #endif - #include #include - #ifdef SunOS #include #endif +#include // IWYU pragma: keep +#include +#if __APPLE__ +#include +#else +#include +#include +#endif #include "fallback.h" // IWYU pragma: keep #include "util.h" - #include "common.h" -#include "wutil.h" +#include "wutil.h" // IWYU pragma: keep #include "env.h" #include "proc.h" -#include "parser.h" #include "path.h" #include "expand.h" #include "wildcard.h" #include "exec.h" -#include "tokenizer.h" #include "complete.h" #include "iothread.h" - #include "parse_util.h" +#include "parse_constants.h" +#ifdef KERN_PROCARGS2 +#else +#include "tokenizer.h" +#endif /** Description for child process diff --git a/src/expand.h b/src/expand.h index fafbcd2a..d0b5e38b 100644 --- a/src/expand.h +++ b/src/expand.h @@ -6,20 +6,16 @@ benefit from using a more clever memory allocation scheme, perhaps an evil combination of talloc, string buffers and reference counting. - */ - #ifndef FISH_EXPAND_H -/** - Header guard -*/ #define FISH_EXPAND_H -#include "config.h" // for __warn_unused +#include "config.h" -#include -#include // for string -#include // for vector +#include +#include +#include +#include #include "common.h" #include "parse_constants.h" diff --git a/src/fallback.cpp b/src/fallback.cpp index ed29f5de..e3dcfed0 100644 --- a/src/fallback.cpp +++ b/src/fallback.cpp @@ -7,46 +7,44 @@ incomplete. lrand28_r internally uses the regular (bad) rand_r function, the gettext function doesn't actually do anything, etc. */ - #include "config.h" - +// IWYU likes to recommend adding term.h when we want ncurses.h. +// IWYU pragma: no_include term.h #include -#include +#include // IWYU pragma: keep #include -#include -#include -#include -#include +#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include // IWYU pragma: keep #include #include #include -#include -#include -#include -#include - +#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include // IWYU pragma: keep +#include // IWYU pragma: keep #if HAVE_GETTEXT #include #endif - #if HAVE_NCURSES_H -#include +#include // IWYU pragma: keep #elif HAVE_NCURSES_CURSES_H #include #else #include #endif - #if HAVE_TERM_H -#include +#include // IWYU pragma: keep #elif HAVE_NCURSES_TERM_H #include #endif +#include // IWYU pragma: keep +#include // IWYU pragma: keep -#include "fallback.h" -#include "util.h" - +#include "fallback.h" // IWYU pragma: keep +#include "util.h" // IWYU pragma: keep #ifndef HAVE___ENVIRON @@ -1339,8 +1337,6 @@ int fish_wcswidth(const wchar_t *str, size_t n) * Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c */ -#include - struct interval { int first; diff --git a/src/fallback.h b/src/fallback.h index 0623ec54..ae48e232 100644 --- a/src/fallback.h +++ b/src/fallback.h @@ -1,16 +1,23 @@ - #ifndef FISH_FALLBACK_H #define FISH_FALLBACK_H -#include +#include "config.h" + +// IWYU likes to recommend adding when we want . If we add it breaks +// compiling several modules that include this header because they use symbols which are defined as +// macros in . +// IWYU pragma: no_include #include -#include -#include -#include -#include -#include -#include #include +#include +// The following include must be kept despite what IWYU says. That's because of the interaction +// between the weak linking of `wcsdup` and `wcscasecmp` via `#define`s below and the declarations +// in . At least on OS X if we don't do this we get compilation errors do to the macro +// substitution if wchar.h is included after this header. +#include // IWYU pragma: keep +#if HAVE_NCURSES_H +#include // IWYU pragma: keep +#endif /** fish's internal versions of wcwidth and wcswidth, which can use an internal implementation if the system one is busted. */ int fish_wcwidth(wchar_t wc); diff --git a/src/fish.cpp b/src/fish.cpp index 9676814d..128a529c 100644 --- a/src/fish.cpp +++ b/src/fish.cpp @@ -15,17 +15,14 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - /** \file fish.c The main loop of fish. */ - #include "config.h" #include #include #include -#include #include #include #include @@ -37,22 +34,23 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #include #include #include -#include // IWYU pragma: keep - suggests internal header +#include // IWYU pragma: keep #include #include #include +#include +#include #include "fallback.h" // IWYU pragma: keep #include "common.h" #include "reader.h" #include "builtin.h" #include "function.h" -#include "wutil.h" +#include "wutil.h" // IWYU pragma: keep #include "env.h" #include "proc.h" #include "parser.h" #include "expand.h" -#include "intern.h" #include "event.h" #include "history.h" #include "path.h" diff --git a/src/fish_indent.cpp b/src/fish_indent.cpp index a469ccf7..fbe9b13c 100644 --- a/src/fish_indent.cpp +++ b/src/fish_indent.cpp @@ -1,3 +1,4 @@ +// The fish_indent program. /* Copyright (C) 2014 ridiculous_fish @@ -14,10 +15,6 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ - -// The fish_indent proegram. -#include "config.h" - #include #include #include @@ -27,11 +24,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #include #include #include +#include +#include +#include #include "color.h" #include "highlight.h" #include "parse_constants.h" -#include "wutil.h" +#include "wutil.h" // IWYU pragma: keep #include "common.h" #include "output.h" #include "env.h" diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index ef1956cc..b616ec51 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -1,21 +1,14 @@ /** \file fish_tests.c Various bug and feature tests. Compiled and run by make test. */ - -#include "config.h" - +// IWYU pragma: no_include #include #include #include #include #include -#include -#include -#include #include -#include #include -#include #include #include #include @@ -25,31 +18,36 @@ #include #include #include -#include #include - -#include "fallback.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "fallback.h" // IWYU pragma: keep #include "util.h" #include "common.h" #include "proc.h" #include "reader.h" #include "builtin.h" #include "function.h" -#include "autoload.h" #include "complete.h" -#include "wutil.h" +#include "wutil.h" // IWYU pragma: keep #include "env.h" #include "expand.h" #include "parser.h" #include "tokenizer.h" -#include "output.h" -#include "exec.h" #include "event.h" #include "path.h" #include "history.h" #include "highlight.h" #include "iothread.h" -#include "postfork.h" #include "signal.h" #include "parse_tree.h" #include "parse_util.h" @@ -59,6 +57,12 @@ #include "utf8.h" #include "env_universal_common.h" #include "wcstringutil.h" +#include "color.h" +#include "io.h" +#include "lru.h" +#include "parse_constants.h" +#include "screen.h" +#include "input_common.h" static const char * const * s_arguments; static int s_test_run_count = 0; diff --git a/src/function.cpp b/src/function.cpp index 71182030..4d731ff3 100644 --- a/src/function.cpp +++ b/src/function.cpp @@ -6,9 +6,7 @@ is taken care of by the parser and to some degree the builtin handling library. */ - -#include "config.h" // IWYU pragma: keep - +// IWYU pragma: no_include #include #include #include @@ -17,10 +15,10 @@ #include #include #include +#include -#include "wutil.h" +#include "wutil.h" // IWYU pragma: keep #include "fallback.h" // IWYU pragma: keep - #include "autoload.h" #include "function.h" #include "common.h" diff --git a/src/function.h b/src/function.h index 5a993fec..8ac45a11 100644 --- a/src/function.h +++ b/src/function.h @@ -6,12 +6,12 @@ is taken care of by the parser and to some degree the builtin handling library. */ - #ifndef FISH_FUNCTION_H #define FISH_FUNCTION_H #include #include +#include #include "common.h" #include "event.h" diff --git a/src/highlight.cpp b/src/highlight.cpp index 3014ebdf..827a324c 100644 --- a/src/highlight.cpp +++ b/src/highlight.cpp @@ -1,9 +1,7 @@ /** \file highlight.c Functions for syntax highlighting */ - -#include "config.h" // IWYU pragma: keep - +// IWYU pragma: no_include #include #include #include @@ -13,10 +11,13 @@ #include #include #include +#include +#include +#include +#include -#include "fallback.h" - -#include "wutil.h" +#include "fallback.h" // IWYU pragma: keep +#include "wutil.h" // IWYU pragma: keep #include "highlight.h" #include "tokenizer.h" #include "parse_util.h" @@ -26,12 +27,12 @@ #include "env.h" #include "expand.h" #include "common.h" -#include "complete.h" #include "output.h" #include "wildcard.h" #include "path.h" #include "history.h" #include "parse_tree.h" +#include "color.h" #define CURSOR_POSITION_INVALID ((size_t)(-1)) diff --git a/src/highlight.h b/src/highlight.h index 161b4b73..46149f46 100644 --- a/src/highlight.h +++ b/src/highlight.h @@ -5,12 +5,12 @@ #ifndef FISH_HIGHLIGHT_H #define FISH_HIGHLIGHT_H -#include // for assert -#include // for size_t -#include // for uint32_t -#include // for vector +#include +#include +#include +#include -#include "common.h" // for wcstring, wcstring_list_t +#include "common.h" #include "env.h" #include "color.h" diff --git a/src/history.cpp b/src/history.cpp index bc9ddd3e..dfb3608c 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -1,5 +1,4 @@ // History functions, part of the user interface. -#include "history.h" #include #include #include @@ -16,10 +15,12 @@ #include #include #include +#include + #include "common.h" -#include "config.h" #include "env.h" #include "fallback.h" // IWYU pragma: keep +#include "history.h" #include "iothread.h" #include "lru.h" #include "parse_constants.h" @@ -28,7 +29,7 @@ #include "reader.h" #include "sanity.h" #include "signal.h" -#include "wutil.h" +#include "wutil.h" // IWYU pragma: keep // Our history format is intended to be valid YAML. Here it is: // diff --git a/src/history.h b/src/history.h index b278c3cc..a861f978 100644 --- a/src/history.h +++ b/src/history.h @@ -2,8 +2,8 @@ #ifndef FISH_HISTORY_H #define FISH_HISTORY_H +// IWYU pragma: no_include #include -#include #include #include #include @@ -12,8 +12,11 @@ #include #include #include +#include +#include + #include "common.h" -#include "wutil.h" +#include "wutil.h" // IWYU pragma: keep // Fish supports multiple shells writing to history at once. Here is its strategy: // diff --git a/src/input.cpp b/src/input.cpp index b4277724..c45939bc 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1,16 +1,13 @@ /** \file input.c Functions for reading a character of input from stdin. - */ - #include "config.h" #include #include #include #include - #if HAVE_NCURSES_H #include #elif HAVE_NCURSES_CURSES_H @@ -18,17 +15,19 @@ #else #include #endif - #if HAVE_TERM_H #include #elif HAVE_NCURSES_TERM_H #include #endif - #include +#include +#include +#include +#include #include "fallback.h" // IWYU pragma: keep -#include "wutil.h" // IWYU pragma: keep - needed for wgettext +#include "wutil.h" // IWYU pragma: keep #include "reader.h" #include "proc.h" #include "common.h" @@ -37,11 +36,9 @@ #include "parser.h" #include "env.h" #include "event.h" -#include "signal.h" // IWYU pragma: keep - needed for CHECK_BLOCK +#include "signal.h" // IWYU pragma: keep #include "io.h" #include "output.h" -#include -#include #define DEFAULT_TERM L"ansi" #define MAX_INPUT_FUNCTION_ARGS 20 diff --git a/src/input.h b/src/input.h index 47315c1c..e3e41936 100644 --- a/src/input.h +++ b/src/input.h @@ -2,19 +2,16 @@ Functions for reading a character of input from stdin, using the inputrc information for key bindings. - */ - #ifndef FISH_INPUT_H #define FISH_INPUT_H #include -#include #include +#include #include "common.h" #include "env.h" -#include "input_common.h" #define DEFAULT_BIND_MODE L"default" #define FISH_BIND_MODE_VAR L"fish_bind_mode" diff --git a/src/input_common.cpp b/src/input_common.cpp index 7c018c2d..3584f903 100644 --- a/src/input_common.cpp +++ b/src/input_common.cpp @@ -1,27 +1,30 @@ /** \file input_common.c Implementation file for the low level input library - */ #include "config.h" - #include #include -#include #include #include #include -#include // for wint_t -#include // for deque -#include // for swap, pair +#include +#include #ifdef HAVE_SYS_SELECT_H #include #endif +#include +#include +#include +#include +#include +#include +#include +#include #include "fallback.h" // IWYU pragma: keep #include "util.h" - #include "common.h" #include "input_common.h" #include "env_universal_common.h" diff --git a/src/input_common.h b/src/input_common.h index 8f4cdd52..1f54317a 100644 --- a/src/input_common.h +++ b/src/input_common.h @@ -1,7 +1,6 @@ /** \file input_common.h Header file for the low level input library - */ #ifndef INPUT_COMMON_H #define INPUT_COMMON_H diff --git a/src/intern.cpp b/src/intern.cpp index 2ec0af8a..0724fcd0 100644 --- a/src/intern.cpp +++ b/src/intern.cpp @@ -1,14 +1,14 @@ /** \file intern.c Library for pooling common strings - */ -#include "config.h" // IWYU pragma: keep - #include #include #include #include +#include +#include +#include #include "fallback.h" // IWYU pragma: keep #include "common.h" diff --git a/src/io.cpp b/src/io.cpp index 61452830..ed5afe55 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -1,23 +1,19 @@ /** \file io.c Utilities for io redirection. - */ -#include "config.h" // IWYU pragma: keep - - #include #include #include #include +#include #include "fallback.h" // IWYU pragma: keep -#include "wutil.h" +#include "wutil.h" // IWYU pragma: keep #include "exec.h" #include "common.h" #include "io.h" - io_data_t::~io_data_t() { } diff --git a/src/io.h b/src/io.h index 181099ad..ed634f19 100644 --- a/src/io.h +++ b/src/io.h @@ -4,10 +4,10 @@ #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 ciso646, which does nothing - +// So it's key that vector go above. If we didn't need vector for other reasons, we might include +// ciso646, which does nothing #if defined(_LIBCPP_VERSION) || __cplusplus > 199711L // C++11 or libc++ (which is a C++11-only library, but the memory header works OK in C++03) #include @@ -17,6 +17,7 @@ using std::shared_ptr; #include using std::tr1::shared_ptr; #endif +#include #include "common.h" diff --git a/src/iothread.cpp b/src/iothread.cpp index 7a37b63b..3623850e 100644 --- a/src/iothread.cpp +++ b/src/iothread.cpp @@ -1,17 +1,17 @@ -#include "config.h" // IWYU pragma: keep -#include "iothread.h" -#include "common.h" #include #include #include -#include // IWYU pragma: keep - for _POSIX_THREADS_MAX, suggests internal header +#include #include -#include +#include #include #include #include #include -#include +#include + +#include "iothread.h" +#include "common.h" #ifdef _POSIX_THREAD_THREADS_MAX #if _POSIX_THREAD_THREADS_MAX < 64 diff --git a/src/iothread.h b/src/iothread.h index bdec2195..26b77550 100644 --- a/src/iothread.h +++ b/src/iothread.h @@ -1,7 +1,6 @@ /** \file iothread.h Handles IO that may hang. */ - #ifndef FISH_IOTHREAD_H #define FISH_IOTHREAD_H diff --git a/src/key_reader.cpp b/src/key_reader.cpp index 1cb3b3de..bb4a0075 100644 --- a/src/key_reader.cpp +++ b/src/key_reader.cpp @@ -5,19 +5,15 @@ Type ^C to exit the program. */ -#include "config.h" - #include #include #include #include -#include #include #include #include "common.h" -#include "fallback.h" - +#include "fallback.h" // IWYU pragma: keep #include "input_common.h" int writestr(char *str) diff --git a/src/kill.cpp b/src/kill.cpp index 7b68b16c..fb83c8aa 100644 --- a/src/kill.cpp +++ b/src/kill.cpp @@ -5,13 +5,12 @@ and paste with a memory of previous cuts. It supports integration with the X clipboard. */ - -#include "config.h" // IWYU pragma: keep - #include #include #include #include +#include +#include #include "fallback.h" // IWYU pragma: keep #include "kill.h" diff --git a/src/kill.h b/src/kill.h index 686122a2..cdcdf691 100644 --- a/src/kill.h +++ b/src/kill.h @@ -3,7 +3,6 @@ Works like the killring in emacs and readline. The killring is cut and paste whith a memory of previous cuts. */ - #ifndef FISH_KILL_H #define FISH_KILL_H diff --git a/src/lru.h b/src/lru.h index a70b165d..3f4181e9 100644 --- a/src/lru.h +++ b/src/lru.h @@ -2,7 +2,6 @@ Least-recently-used cache implementation */ - #ifndef FISH_LRU_H #define FISH_LRU_H @@ -11,6 +10,7 @@ #include #include #include + #include "common.h" /** A predicate to compare dereferenced pointers */ diff --git a/src/output.cpp b/src/output.cpp index 033d1409..3fda2e67 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -1,13 +1,11 @@ /** \file output.c Generic output functions */ - #include "config.h" #include #include #include - #if HAVE_NCURSES_H #include #elif HAVE_NCURSES_CURSES_H @@ -15,25 +13,25 @@ #else #include #endif - #if HAVE_TERM_H #include #elif HAVE_NCURSES_TERM_H #include #endif - #include #include #include +#include +#include -#include "fallback.h" -#include "wutil.h" // IWYU pragma: keep - needed for wgettext +#include "fallback.h" // IWYU pragma: keep +#include "wutil.h" // IWYU pragma: keep #include "common.h" #include "output.h" +#include "color.h" static int writeb_internal(char c); - /** The function used for output */ diff --git a/src/output.h b/src/output.h index acdd2612..7f5b077d 100644 --- a/src/output.h +++ b/src/output.h @@ -4,14 +4,15 @@ /** Constants for various character classifications. Each character of a command string can be classified as one of the following types. */ - #ifndef FISH_OUTPUT_H #define FISH_OUTPUT_H -#include #include +#include +#include + #include "common.h" -#include "fallback.h" +#include "fallback.h" // IWYU pragma: keep #include "color.h" /** diff --git a/src/pager.cpp b/src/pager.cpp index a5cf0ecc..1fb7847e 100644 --- a/src/pager.cpp +++ b/src/pager.cpp @@ -1,14 +1,19 @@ -#include "config.h" // IWYU pragma: keep - +// IWYU pragma: no_include #include #include #include #include #include +#include + #include "util.h" -#include "wutil.h" // IWYU pragma: keep - needed for wgettext +#include "wutil.h" // IWYU pragma: keep #include "pager.h" #include "highlight.h" +#include "common.h" +#include "screen.h" +#include "complete.h" +#include "reader.h" typedef pager_t::comp_t comp_t; typedef std::vector completion_list_t; diff --git a/src/pager.h b/src/pager.h index 5f7da87a..c03ca906 100644 --- a/src/pager.h +++ b/src/pager.h @@ -1,13 +1,15 @@ /** \file pager.h Pager support */ - #ifndef FISH_PAGER_H #define FISH_PAGER_H #include #include #include +#include +#include + #include "common.h" #include "complete.h" #include "screen.h" diff --git a/src/parse_constants.h b/src/parse_constants.h index 4668516b..49721504 100644 --- a/src/parse_constants.h +++ b/src/parse_constants.h @@ -2,9 +2,8 @@ Constants used in the programmatic representation of fish code. */ - -#ifndef fish_parse_constants_h -#define fish_parse_constants_h +#ifndef FISH_PARSE_CONSTANTS_H +#define FISH_PARSE_CONSTANTS_H #include "config.h" diff --git a/src/parse_execution.cpp b/src/parse_execution.cpp index c5494287..202194e7 100644 --- a/src/parse_execution.cpp +++ b/src/parse_execution.cpp @@ -6,8 +6,6 @@ Non-fatal errors are printed as soon as they are encountered; otherwise you would have to wait for the execution to finish to see them. */ - -#include "parse_execution.h" #include #include #include @@ -18,8 +16,11 @@ #include #include #include -#include // IWYU pragma: keep - suggests instead +#include #include +#include + +#include "parse_execution.h" #include "env.h" #include "event.h" #include "tokenizer.h" @@ -35,6 +36,11 @@ #include "function.h" #include "builtin.h" #include "exec.h" +#include "common.h" +#include "io.h" +#include "parse_constants.h" +#include "parse_tree.h" +#include "proc.h" /* These are the specific statement types that support redirections */ static bool specific_statement_type_is_redirectable_block(const parse_node_t &node) diff --git a/src/parse_execution.h b/src/parse_execution.h index ef796676..088729cb 100644 --- a/src/parse_execution.h +++ b/src/parse_execution.h @@ -2,16 +2,17 @@ Provides the "linkage" between a parse_node_tree_t and actual execution structures (job_t, etc.). */ - #ifndef FISH_PARSE_EXECUTION_H #define FISH_PARSE_EXECUTION_H #include + #include "common.h" #include "io.h" #include "parse_constants.h" #include "parse_tree.h" #include "proc.h" +#include class parser_t; struct block_t; diff --git a/src/parse_productions.cpp b/src/parse_productions.cpp index 6ec8e56a..43a580d3 100644 --- a/src/parse_productions.cpp +++ b/src/parse_productions.cpp @@ -1,7 +1,9 @@ -#include "parse_productions.h" -#include #include + #include "parse_tree.h" +#include "parse_productions.h" +#include "parse_constants.h" +#include "common.h" using namespace parse_productions; diff --git a/src/parse_productions.h b/src/parse_productions.h index ce456544..e2c2dcc3 100644 --- a/src/parse_productions.h +++ b/src/parse_productions.h @@ -2,13 +2,13 @@ Programmatic representation of fish code. */ - #ifndef FISH_PARSE_TREE_CONSTRUCTION_H #define FISH_PARSE_TREE_CONSTRUCTION_H -#include // for uint8_t, uint32_t -#include "common.h" // for wcstring -#include "parse_constants.h" // for parse_token_type_t, etc +#include +#include + +#include "parse_constants.h" struct parse_token_t; diff --git a/src/parse_tree.cpp b/src/parse_tree.cpp index 95493955..0c2334ec 100644 --- a/src/parse_tree.cpp +++ b/src/parse_tree.cpp @@ -1,20 +1,21 @@ #include #include #include -#include #include #include #include +#include +#include +#include + #include "common.h" #include "parse_constants.h" #include "parse_productions.h" #include "parse_tree.h" #include "tokenizer.h" -#include "fallback.h" -#include "wutil.h" // IWYU pragma: keep - needed for wgettext +#include "fallback.h" // IWYU pragma: keep +#include "wutil.h" // IWYU pragma: keep #include "proc.h" -#include -#include // This array provides strings for each symbol in enum parse_token_type_t in parse_constants.h. const wchar_t * const token_type_map[] = { diff --git a/src/parse_tree.h b/src/parse_tree.h index 8ae9ee88..9fd17645 100644 --- a/src/parse_tree.h +++ b/src/parse_tree.h @@ -2,18 +2,19 @@ Programmatic representation of fish code. */ - #ifndef FISH_PARSE_PRODUCTIONS_H #define FISH_PARSE_PRODUCTIONS_H #include #include -#include +#include +#include +#include +#include #include "common.h" #include "tokenizer.h" #include "parse_constants.h" -#include class parse_node_tree_t; diff --git a/src/parse_util.cpp b/src/parse_util.cpp index 73db2833..5d6721ec 100644 --- a/src/parse_util.cpp +++ b/src/parse_util.cpp @@ -7,26 +7,26 @@ used in many places in fish and that are somehow related to parsing the code. */ - -#include "config.h" // IWYU pragma: keep - #include #include #include #include #include +#include +#include +#include -#include "fallback.h" +#include "fallback.h" // IWYU pragma: keep #include "util.h" -#include "wutil.h" // IWYU pragma: keep +#include "wutil.h" // IWYU pragma: keep #include "common.h" #include "tokenizer.h" #include "parse_util.h" #include "expand.h" -#include "env.h" #include "wildcard.h" #include "parse_tree.h" #include "builtin.h" +#include "parse_constants.h" /** Error message for improper use of the exec builtin */ #define EXEC_ERR_MSG _(L"The '%ls' command can not be used in a pipeline") diff --git a/src/parse_util.h b/src/parse_util.h index 26f47268..454ac806 100644 --- a/src/parse_util.h +++ b/src/parse_util.h @@ -3,14 +3,16 @@ Various mostly unrelated utility functions related to parsing, loading and evaluating fish code. */ - #ifndef FISH_PARSE_UTIL_H #define FISH_PARSE_UTIL_H #include #include +#include + #include "common.h" #include "parse_constants.h" +#include "tokenizer.h" /** Find the beginning and end of the first subshell in the specified string. diff --git a/src/parser.cpp b/src/parser.cpp index 2862df60..9202d7fd 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1,20 +1,17 @@ /** \file parser.c The fish parser. Contains functions for parsing and evaluating code. - */ - -#include "config.h" // IWYU pragma: keep - #include #include #include -#include #include +#include +#include -#include "fallback.h" +#include "fallback.h" // IWYU pragma: keep #include "common.h" -#include "wutil.h" +#include "wutil.h" // IWYU pragma: keep #include "proc.h" #include "parser.h" #include "function.h" @@ -24,10 +21,12 @@ The fish parser. Contains functions for parsing and evaluating code. #include "sanity.h" #include "event.h" #include "intern.h" -#include "signal.h" // IWYU pragma: keep - needed for CHECK_BLOCK #include "parse_util.h" #include "parse_tree.h" #include "parse_execution.h" +#include "parse_constants.h" + +class io_chain_t; /** Error for evaluating in illegal scope diff --git a/src/parser.h b/src/parser.h index af470d36..d40ca16b 100644 --- a/src/parser.h +++ b/src/parser.h @@ -1,22 +1,22 @@ /** \file parser.h The fish parser. */ - #ifndef FISH_PARSER_H #define FISH_PARSER_H -#include // for size_t -#include // for _List_const_iterator, list, etc +#include +#include +#include +#include #include "common.h" #include "proc.h" #include "event.h" #include "parse_tree.h" -#include "io.h" #include "parse_constants.h" #include "expand.h" -#include +class io_chain_t; /** event_blockage_t represents a block on events of the specified type diff --git a/src/parser_keywords.cpp b/src/parser_keywords.cpp index adf9c40c..5f9710ac 100644 --- a/src/parser_keywords.cpp +++ b/src/parser_keywords.cpp @@ -2,9 +2,6 @@ Functions having to do with parser keywords, like testing if a function is a block command. */ - -#include "config.h" // IWYU pragma: keep - #include "fallback.h" // IWYU pragma: keep #include "common.h" #include "parser_keywords.h" diff --git a/src/parser_keywords.h b/src/parser_keywords.h index 94cd0eb7..d9637323 100644 --- a/src/parser_keywords.h +++ b/src/parser_keywords.h @@ -2,10 +2,11 @@ Functions having to do with parser keywords, like testing if a function is a block command. */ - #ifndef FISH_PARSER_KEYWORD_H #define FISH_PARSER_KEYWORD_H +#include + #include "common.h" /** diff --git a/src/path.cpp b/src/path.cpp index a85b662f..ebe14165 100644 --- a/src/path.cpp +++ b/src/path.cpp @@ -1,5 +1,3 @@ -#include "config.h" // IWYU pragma: keep - #include #include #include @@ -11,7 +9,7 @@ #include "fallback.h" // IWYU pragma: keep #include "common.h" #include "env.h" -#include "wutil.h" +#include "wutil.h" // IWYU pragma: keep #include "path.h" #include "expand.h" diff --git a/src/path.h b/src/path.h index eec776a6..ae958b68 100644 --- a/src/path.h +++ b/src/path.h @@ -5,11 +5,12 @@ name can be found in the PATH, and various other path-related issues. */ - #ifndef FISH_PATH_H #define FISH_PATH_H #include +#include + #include "common.h" #include "env.h" diff --git a/src/postfork.cpp b/src/postfork.cpp index 40a0bffb..f2851eb0 100644 --- a/src/postfork.cpp +++ b/src/postfork.cpp @@ -9,14 +9,19 @@ #include #include #include -#include // IWYU pragma: keep - suggests instead +#include +#if FISH_USE_POSIX_SPAWN +#include +#endif + #include "common.h" #include "proc.h" -#include "wutil.h" +#include "wutil.h" // IWYU pragma: keep #include "signal.h" #include "postfork.h" #include "iothread.h" #include "exec.h" +#include "io.h" #ifndef JOIN_THREADS_BEFORE_FORK #define JOIN_THREADS_BEFORE_FORK 0 diff --git a/src/postfork.h b/src/postfork.h index c277da52..b2ef18ca 100644 --- a/src/postfork.h +++ b/src/postfork.h @@ -2,24 +2,23 @@ Functions that we may safely call after fork(), of which there are very few. In particular we cannot allocate memory, since we're insane enough to call fork from a multithreaded process. */ - #ifndef FISH_POSTFORK_H #define FISH_POSTFORK_H -#include -#include - #include "config.h" -#include "io.h" +#include #if HAVE_SPAWN_H #include #endif - #ifndef FISH_USE_POSIX_SPAWN #define FISH_USE_POSIX_SPAWN HAVE_SPAWN_H #endif +#include +class io_chain_t; +class job_t; +class process_t; /** This function should be called by both the parent process and the @@ -33,8 +32,6 @@ Returns 0 on sucess, -1 on failiure. */ -class job_t; -class process_t; int set_child_group(job_t *j, process_t *p, int print_errors); /** diff --git a/src/print_help.cpp b/src/print_help.cpp index da401134..856b87d5 100644 --- a/src/print_help.cpp +++ b/src/print_help.cpp @@ -1,12 +1,9 @@ - /** \file print_help.c Print help message for the specified command */ - #include #include #include -#include #include #include "print_help.h" diff --git a/src/proc.cpp b/src/proc.cpp index 1a0d6479..f4e47cc9 100644 --- a/src/proc.cpp +++ b/src/proc.cpp @@ -7,45 +7,40 @@ will call proc to create representations of the running jobs as needed. Some of the code in this file is based on code from the Glibc manual. - */ +// IWYU pragma: no_include <__bit_reference> #include "config.h" -#include #include #include #include -#include #include #include #include #include -#include -#include // IWYU pragma: keep - suggests instead +#include #include - #include #include -#include - #if HAVE_TERM_H #include #elif HAVE_NCURSES_TERM_H #include #endif - #ifdef HAVE_SIGINFO_H #include #endif - #ifdef HAVE_SYS_SELECT_H #include #endif +#include +#include +#include // IWYU pragma: keep +#include // IWYU pragma: keep #include "fallback.h" // IWYU pragma: keep #include "util.h" - -#include "wutil.h" +#include "wutil.h" // IWYU pragma: keep #include "proc.h" #include "common.h" #include "reader.h" @@ -53,8 +48,9 @@ Some of the code in this file is based on code from the Glibc manual. #include "parser.h" #include "signal.h" #include "event.h" - #include "output.h" +#include "io.h" +#include "parse_tree.h" /** Size of buffer for reading buffered output diff --git a/src/proc.h b/src/proc.h index 3b77fe51..7fcbe6da 100644 --- a/src/proc.h +++ b/src/proc.h @@ -7,18 +7,19 @@ needed. */ - #ifndef FISH_PROC_H #define FISH_PROC_H +#include "config.h" // IWYU pragma: keep #include -#include #include -#include // for assert -#include // for size_t -#include // for pid_t, termios +#include +#include +#include +#include +#include +#include // IWYU pragma: keep -#include "config.h" // for HAVE__PROC_SELF_STAT #include "io.h" #include "common.h" #include "parse_tree.h" diff --git a/src/reader.cpp b/src/reader.cpp index 50c8c93d..3254b905 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -18,13 +18,12 @@ the end of the list is reached, at which point regular searching will commence. */ - #include "config.h" -#include +// IWYU pragma: no_include +#include #include #include -#include #include #include #include @@ -34,25 +33,22 @@ commence. #include #include #include - #ifdef HAVE_SIGINFO_H #include #endif - #ifdef HAVE_SYS_SELECT_H #include #endif - #include #include #include #include +#include +#include - -#include "fallback.h" +#include "fallback.h" // IWYU pragma: keep #include "util.h" - -#include "wutil.h" +#include "wutil.h" // IWYU pragma: keep #include "highlight.h" #include "reader.h" #include "proc.h" @@ -79,6 +75,8 @@ commence. #include "pager.h" #include "color.h" #include "event.h" +#include "io.h" +#include "parse_constants.h" /** Maximum length of prefix string when printing completion diff --git a/src/reader.h b/src/reader.h index 3d9208a0..0aa10516 100644 --- a/src/reader.h +++ b/src/reader.h @@ -12,14 +12,16 @@ #include #include #include +#include -#include "io.h" #include "common.h" #include "complete.h" #include "highlight.h" #include "parse_constants.h" class history_t; +class env_vars_snapshot_t; +class io_chain_t; /* Helper class for storing a command line */ class editable_line_t @@ -229,7 +231,6 @@ void reader_set_complete_function(complete_function_t); /** The type of a highlight function. */ -class env_vars_snapshot_t; typedef void (*highlight_function_t)(const wcstring &, std::vector &, size_t, wcstring_list_t *, const env_vars_snapshot_t &vars); /** diff --git a/src/sanity.cpp b/src/sanity.cpp index e918c805..43480126 100644 --- a/src/sanity.cpp +++ b/src/sanity.cpp @@ -1,8 +1,6 @@ /** \file sanity.c Functions for performing sanity checks on the program state */ -#include "config.h" // IWYU pragma: keep - #include #include "fallback.h" // IWYU pragma: keep @@ -13,7 +11,6 @@ #include "reader.h" #include "kill.h" - /** Status from earlier sanity checks */ diff --git a/src/screen.cpp b/src/screen.cpp index 7bb5cf4b..a4d6f4b3 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -5,15 +5,13 @@ output to screen efficiently by keeping an internal representation of the current screen contents and trying to find the most efficient way for transforming that to the desired screen content. */ - +// IWYU pragma: no_include #include "config.h" #include #include #include - #include - #if HAVE_NCURSES_H #include #elif HAVE_NCURSES_CURSES_H @@ -21,23 +19,19 @@ efficient way for transforming that to the desired screen content. #else #include #endif - #if HAVE_TERM_H #include #elif HAVE_NCURSES_TERM_H #include #endif - #include #include - #include #include #include #include - -#include "fallback.h" +#include "fallback.h" // IWYU pragma: keep #include "common.h" #include "util.h" #include "output.h" diff --git a/src/screen.h b/src/screen.h index e84d8497..9db4d460 100644 --- a/src/screen.h +++ b/src/screen.h @@ -18,6 +18,8 @@ #include #include "common.h" #include "highlight.h" +#include +#include class page_rendering_t; diff --git a/src/signal.cpp b/src/signal.cpp index a0eccd08..996d3314 100644 --- a/src/signal.cpp +++ b/src/signal.cpp @@ -1,29 +1,24 @@ /** \file signal.c The library for various signal related issues - */ - -#include "config.h" // IWYU pragma: keep - -#include #include #include #include - #ifdef HAVE_SIGINFO_H #include #endif +#include +#include #include "common.h" #include "fallback.h" // IWYU pragma: keep -#include "wutil.h" +#include "wutil.h" // IWYU pragma: keep #include "signal.h" #include "event.h" #include "reader.h" #include "proc.h" - /** Struct describing an entry for the lookup table used to convert between signal names and signal ids, etc. diff --git a/src/signal.h b/src/signal.h index fc3e7e73..4a22520a 100644 --- a/src/signal.h +++ b/src/signal.h @@ -1,12 +1,12 @@ /** \file signal.h The library for various signal related issues - */ #ifndef FISH_SIGNALH #define FISH_SIGNALH #include +#include /** Get the integer signal value representing the specified signal, or diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp index 4075c73b..2eca6627 100644 --- a/src/tokenizer.cpp +++ b/src/tokenizer.cpp @@ -5,19 +5,17 @@ future, the tokenizer should be extended to support marks, tokenizing multiple strings and disposing of unused string segments. */ - -#include "config.h" // IWYU pragma: keep - #include #include #include #include #include #include +#include #include "fallback.h" // IWYU pragma: keep #include "common.h" -#include "wutil.h" // IWYU pragma: keep - needed for wgettext +#include "wutil.h" // IWYU pragma: keep #include "tokenizer.h" /* Wow what a hack */ diff --git a/src/tokenizer.h b/src/tokenizer.h index d6de2559..3c3b6236 100644 --- a/src/tokenizer.h +++ b/src/tokenizer.h @@ -5,11 +5,12 @@ tokenizing multiple strings and disposing of unused string segments. */ - #ifndef FISH_TOKENIZER_H #define FISH_TOKENIZER_H #include +#include + #include "common.h" /** diff --git a/src/utf8.cpp b/src/utf8.cpp index 9bd6edf2..7c876a31 100644 --- a/src/utf8.cpp +++ b/src/utf8.cpp @@ -13,15 +13,12 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - #include -#include - -#include "utf8.h" - +#include // IWYU pragma: keep #include #include -#include + +#include "utf8.h" #define _NXT 0x80 #define _SEQ2 0xc0 diff --git a/src/utf8.h b/src/utf8.h index 33ed6a5e..72e1cc8b 100644 --- a/src/utf8.h +++ b/src/utf8.h @@ -21,7 +21,6 @@ #define _UTF8_H_ #include - #include #define UTF8_IGNORE_ERROR 0x01 diff --git a/src/util.cpp b/src/util.cpp index 14cce1c7..9d084af6 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -3,31 +3,17 @@ Contains datastructures such as automatically growing array lists, priority queues, etc. */ - -#include "config.h" - - -#include #include #include -#include -#include -#include -#include -#include #include -#include #include -#include -#include #include -#include +#include -#include "fallback.h" +#include "fallback.h" // IWYU pragma: keep #include "util.h" - #include "common.h" -#include "wutil.h" +#include "wutil.h" // IWYU pragma: keep int wcsfilecmp(const wchar_t *a, const wchar_t *b) { diff --git a/src/util.h b/src/util.h index 1afde073..d073ef83 100644 --- a/src/util.h +++ b/src/util.h @@ -5,10 +5,6 @@ #ifndef FISH_UTIL_H #define FISH_UTIL_H -#include -#include -#include - /** Returns the larger of two ints */ diff --git a/src/wcstringutil.cpp b/src/wcstringutil.cpp index e61e331b..b752409b 100644 --- a/src/wcstringutil.cpp +++ b/src/wcstringutil.cpp @@ -2,9 +2,7 @@ Helper functions for working with wcstring */ - -#include "config.h" // IWYU pragma: keep - +#include "common.h" #include "wcstringutil.h" typedef wcstring::size_type size_type; diff --git a/src/wcstringutil.h b/src/wcstringutil.h index 4d19fc0b..d2feec07 100644 --- a/src/wcstringutil.h +++ b/src/wcstringutil.h @@ -2,12 +2,12 @@ Helper functions for working with wcstring */ - #ifndef FISH_WCSTRINGUTIL_H #define FISH_WCSTRINGUTIL_H #include #include + #include "common.h" /** diff --git a/src/wgetopt.cpp b/src/wgetopt.cpp index 7951eaea..02476718 100644 --- a/src/wgetopt.cpp +++ b/src/wgetopt.cpp @@ -53,8 +53,6 @@ #include #include -#include "common.h" - /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ @@ -74,11 +72,11 @@ GNU application programs can use a third alternative mode in which they can distinguish the relative order of options and other arguments. */ +#include "common.h" #include "wgetopt.h" -#include "wutil.h" +#include "wutil.h" // IWYU pragma: keep #include "fallback.h" // IWYU pragma: keep - /** Use translation functions if available */ diff --git a/src/wgetopt.h b/src/wgetopt.h index 794ccc65..d20529bb 100644 --- a/src/wgetopt.h +++ b/src/wgetopt.h @@ -47,7 +47,7 @@ Cambridge, MA 02139, USA. */ #ifndef FISH_WGETOPT_H #define FISH_WGETOPT_H -#include +#include class wgetopter_t { diff --git a/src/wildcard.cpp b/src/wildcard.cpp index 202b836d..471453f6 100644 --- a/src/wildcard.cpp +++ b/src/wildcard.cpp @@ -3,32 +3,27 @@ Fish needs it's own globbing implementation to support tab-expansion of globbed parameters. Also provides recursive wildcards using **. - */ - -#include "config.h" // IWYU pragma: keep -#include #include #include #include #include #include -#include #include #include -#include -#include #include #include +#include +#include +#include -#include "fallback.h" -#include "wutil.h" +#include "fallback.h" // IWYU pragma: keep +#include "wutil.h" // IWYU pragma: keep #include "common.h" #include "wildcard.h" #include "complete.h" #include "reader.h" #include "expand.h" -#include /** Description for generic executable diff --git a/src/wildcard.h b/src/wildcard.h index 3e1d2b6f..05e185f4 100644 --- a/src/wildcard.h +++ b/src/wildcard.h @@ -5,14 +5,11 @@ paramaters. */ - #ifndef FISH_WILDCARD_H -/** - Header guard -*/ #define FISH_WILDCARD_H #include +#include #include "common.h" #include "expand.h" diff --git a/src/wutil.cpp b/src/wutil.cpp index 0b11989a..1cee8320 100644 --- a/src/wutil.cpp +++ b/src/wutil.cpp @@ -20,11 +20,11 @@ #include #include #include - -#include "fallback.h" +#include #include "common.h" -#include "wutil.h" +#include "fallback.h" // IWYU pragma: keep +#include "wutil.h" // IWYU pragma: keep typedef std::string cstring; diff --git a/src/wutil.h b/src/wutil.h index f16e28c0..a4fee900 100644 --- a/src/wutil.h +++ b/src/wutil.h @@ -9,10 +9,10 @@ #include #include #include -#include #include #include -#include +#include + #include "common.h" /** -- cgit v1.2.3