aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Kurtis Rader <krader@skepticism.us>2016-04-20 23:00:54 -0700
committerGravatar Kurtis Rader <krader@skepticism.us>2016-04-26 15:02:22 -0700
commit1f06e5f0b9ee483053b987c9cab9f1f5fce2590c (patch)
tree8ebebff055f4aa184e7d7b021190ab01d9376992
parentdaa217f533490e0b9bc4113a143e8f38de922b7a (diff)
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
-rw-r--r--CONTRIBUTING.md18
-rw-r--r--Makefile.in12
-rw-r--r--README.md4
-rw-r--r--build_tools/iwyu.linux.imp17
-rw-r--r--build_tools/iwyu.osx.imp97
-rwxr-xr-xbuild_tools/lint.fish52
-rw-r--r--src/autoload.cpp12
-rw-r--r--src/autoload.h2
-rw-r--r--src/builtin.cpp20
-rw-r--r--src/builtin.h25
-rw-r--r--src/builtin_commandline.cpp24
-rw-r--r--src/builtin_complete.cpp23
-rw-r--r--src/builtin_jobs.cpp22
-rw-r--r--src/builtin_printf.cpp15
-rw-r--r--src/builtin_set.cpp24
-rw-r--r--src/builtin_set_color.cpp22
-rw-r--r--src/builtin_string.cpp28
-rw-r--r--src/builtin_test.cpp17
-rw-r--r--src/builtin_ulimit.cpp13
-rw-r--r--src/color.cpp8
-rw-r--r--src/color.h2
-rw-r--r--src/common.cpp16
-rw-r--r--src/common.h17
-rw-r--r--src/complete.cpp10
-rw-r--r--src/complete.h6
-rw-r--r--src/env.cpp11
-rw-r--r--src/env.h5
-rw-r--r--src/env_universal_common.cpp28
-rw-r--r--src/env_universal_common.h6
-rw-r--r--src/event.cpp12
-rw-r--r--src/event.h3
-rw-r--r--src/exec.cpp13
-rw-r--r--src/exec.h4
-rw-r--r--src/expand.cpp30
-rw-r--r--src/expand.h14
-rw-r--r--src/fallback.cpp38
-rw-r--r--src/fallback.h23
-rw-r--r--src/fish.cpp10
-rw-r--r--src/fish_indent.cpp10
-rw-r--r--src/fish_tests.cpp36
-rw-r--r--src/function.cpp8
-rw-r--r--src/function.h2
-rw-r--r--src/highlight.cpp15
-rw-r--r--src/highlight.h10
-rw-r--r--src/history.cpp7
-rw-r--r--src/history.h7
-rw-r--r--src/input.cpp15
-rw-r--r--src/input.h5
-rw-r--r--src/input_common.cpp17
-rw-r--r--src/input_common.h1
-rw-r--r--src/intern.cpp6
-rw-r--r--src/io.cpp8
-rw-r--r--src/io.h7
-rw-r--r--src/iothread.cpp12
-rw-r--r--src/iothread.h1
-rw-r--r--src/key_reader.cpp6
-rw-r--r--src/kill.cpp5
-rw-r--r--src/kill.h1
-rw-r--r--src/lru.h2
-rw-r--r--src/output.cpp12
-rw-r--r--src/output.h7
-rw-r--r--src/pager.cpp11
-rw-r--r--src/pager.h4
-rw-r--r--src/parse_constants.h5
-rw-r--r--src/parse_execution.cpp12
-rw-r--r--src/parse_execution.h3
-rw-r--r--src/parse_productions.cpp6
-rw-r--r--src/parse_productions.h8
-rw-r--r--src/parse_tree.cpp11
-rw-r--r--src/parse_tree.h7
-rw-r--r--src/parse_util.cpp12
-rw-r--r--src/parse_util.h4
-rw-r--r--src/parser.cpp15
-rw-r--r--src/parser.h10
-rw-r--r--src/parser_keywords.cpp3
-rw-r--r--src/parser_keywords.h3
-rw-r--r--src/path.cpp4
-rw-r--r--src/path.h3
-rw-r--r--src/postfork.cpp9
-rw-r--r--src/postfork.h13
-rw-r--r--src/print_help.cpp3
-rw-r--r--src/proc.cpp22
-rw-r--r--src/proc.h13
-rw-r--r--src/reader.cpp18
-rw-r--r--src/reader.h5
-rw-r--r--src/sanity.cpp3
-rw-r--r--src/screen.cpp10
-rw-r--r--src/screen.h2
-rw-r--r--src/signal.cpp11
-rw-r--r--src/signal.h2
-rw-r--r--src/tokenizer.cpp6
-rw-r--r--src/tokenizer.h3
-rw-r--r--src/utf8.cpp9
-rw-r--r--src/utf8.h1
-rw-r--r--src/util.cpp20
-rw-r--r--src/util.h4
-rw-r--r--src/wcstringutil.cpp4
-rw-r--r--src/wcstringutil.h2
-rw-r--r--src/wgetopt.cpp6
-rw-r--r--src/wgetopt.h2
-rw-r--r--src/wildcard.cpp15
-rw-r--r--src/wildcard.h5
-rw-r--r--src/wutil.cpp6
-rw-r--r--src/wutil.h4
104 files changed, 687 insertions, 535 deletions
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: ["<bits/fcntl-linux.h>", "private", "<fcntl.h>", "public"] },
+ { include: ["<bits/mman-linux.h>", "private", "<sys/mman.h>", "public"] },
+ { include: ["<bits/socket-linux.h>", "private", "<sys/socket.h>", "public"] },
+ { include: ["<bits/socket_type.h>", "private", "<sys/socket.h>", "public"] },
+ { include: ["<bits/local_lim.h>", "private", "<limits.h>", "public"] },
+ { include: ["<tr1/memory>", "public", "<memory>", "public"] },
+ { include: ["<features.h>", "public", "<stdio.h>", "public"] },
+ { include: ["<features.h>", "public", "<stddef.h>", "public"] },
+ { include: ["<features.h>", "public", "<unistd.h>", "public"] },
+
+ { symbol: ["size_t", "private", "<unistd.h>", "public"] },
+ { symbol: ["size_t", "private", "<stddef.h>", "public"] },
+ { symbol: ["size_t", "private", "<stdlib.h>", "public"] },
+ { symbol: ["uint64_t", "private", "<sys/types.h>", "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: ["<sys/_pthread/_pthread_once_t.h>", "private", "<pthread.h>", "public"] },
+ { include: ["<sys/_pthread/_pthread_mutex_t.h>", "private", "<pthread.h>", "public"] },
+ { include: ["<sys/_pthread/_pthread_rwlock_t.h>", "private", "<pthread.h>", "public"] },
+ { include: ["<sys/_pthread/_pthread_mutexattr_t.h>", "private", "<pthread.h>", "public"] },
+ { include: ["<sys/_pthread/_pthread_cond_t.h>", "private", "<pthread.h>", "public"] },
+ { include: ["<sys/_pthread/_pthread_t.h>", "private", "<pthread.h>", "public"] },
+ { include: ["<sys/_pthread/_pthread_key_t.h>", "private", "<pthread.h>", "public"] },
+ { include: ["<sys/_types/_posix_vdisable.h>", "private", "<pthread.h>", "public"] },
+ { include: ["<sys/_types/_time_t.h>", "private", "<time.h>", "public"] },
+ { include: ["<sys/_types/_suseconds_t.h>", "private", "<time.h>", "public"] },
+ { include: ["<sys/_types/_suseconds_t.h>", "private", "<sys/types.h>", "public"] },
+ { include: ["<sys/errno.h>", "private", "<errno.h>", "public"] },
+ { include: ["<sys/unistd.h>", "private", "<unistd.h>", "public"] },
+ { include: ["<_wctype.h>", "private", "<wctype.h>", "public"] },
+ { include: ["<sys/fcntl.h>", "private", "<fcntl.h>", "public"] },
+ { include: ["<sys/_types/_seek_set.h>", "private", "<fcntl.h>", "public"] },
+ { include: ["<sys/_types/_mbstate_t.h>", "private", "<wchar.h>", "public"] },
+ { include: ["<iosfwd>", "private", "<string>", "public"] },
+ { include: ["<sys/_types/_s_ifmt.h>", "private", "<sys/types.h>", "public"] },
+ { include: ["<sys/_types/_size_t.h>", "private", "<sys/types.h>", "public"] },
+ { include: ["<sys/_types/_size_t.h>", "private", "<stdlib.h>", "public"] },
+ { include: ["<sys/_types/_mode_t.h>", "private", "<sys/types.h>", "public"] },
+ { include: ["<sys/_types/_pid_t.h>", "private", "<sys/types.h>", "public"] },
+ { include: ["<sys/_types/_fd_def.h>", "private", "<sys/types.h>", "public"] },
+ { include: ["<sys/_types/_fd_isset.h>", "private", "<sys/types.h>", "public"] },
+ { include: ["<sys/_types/_fd_set.h>", "private", "<sys/types.h>", "public"] },
+ { include: ["<sys/_types/_fd_zero.h>", "private", "<sys/types.h>", "public"] },
+ { include: ["<sys/_types/_timeval.h>", "private", "<sys/types.h>", "public"] },
+ { include: ["<sys/_types/_uid_t.h>", "private", "<sys/types.h>", "public"] },
+ { include: ["<_types/_intmax_t.h>", "private", "<sys/types.h>", "public"] },
+ { include: ["<_types/_uintmax_t.h>", "private", "<sys/types.h>", "public"] },
+ { include: ["<_types/_uint8_t.h>", "private", "<sys/types.h>", "public"] },
+ { include: ["<sys/_types/_int32_t.h>", "private", "<sys/types.h>", "public"] },
+ { include: ["<_types/_uint64_t.h>", "private", "<sys/types.h>", "public"] },
+ { include: ["<sys/_types/_uintptr_t.h>", "private", "<sys/types.h>", "public"] },
+ { include: ["<sys/_types/_dev_t.h>", "private", "<sys/types.h>", "public"] },
+ { include: ["<sys/_types/_ino_t.h>", "private", "<sys/types.h>", "public"] },
+ { include: ["<sys/_types/_va_list.h>", "private", "<stdio.h>", "public"] },
+ { include: ["<__functional_base>", "private", "<memory>", "public"] },
+ { include: ["<__functional_base>", "private", "<vector>", "public"] },
+ { include: ["<__functional_base>", "private", "<string>", "public"] },
+ { include: ["<__tree>", "private", "<map>", "public"] },
+ { include: ["<__tree>", "private", "<set>", "public"] },
+ { include: ["<_types/_uint32_t.h>", "private", "<sys/types.h>", "public"] },
+ { include: ["<sys/_types/_va_list.h>", "private", "<sys/types.h>", "public"] },
+ { include: ["<sys/_types/_sigset_t.h>", "private", "<signal.h>", "public"] },
+ { include: ["<sys/signal.h>", "private", "<signal.h>", "public"] },
+ { include: ["<strings.h>", "private", "<string.h>", "public"] },
+ { include: ["<sys/termios.h>", "private", "<termios.h>", "public"] },
+ { include: ["<sys/ttycom.h>", "private", "<termios.h>", "public"] },
+ { include: ["<sys/syslimits.h>", "private", "<limits.h>", "public"] },
+ { include: ["<i386/limits.h>", "private", "<limits.h>", "public"] },
+ { include: ["<sys/_types/_wint_t.h>", "private", "<stddef.h>", "public"] },
+ { include: ["<sys/_select.h>", "private", "<select.h>", "public"] },
+ { include: ["<sys/cdefs.h>", "private", "<unistd.h>", "public"] },
+ { include: ["<istream>", "private", "<iostream>", "public"] },
+ { include: ["<sys/_endian.h>", "private", "<netinet/in.h>", "public"] },
+ { include: ["<sys/_types/_timespec.h>", "private", "<time.h>", "public"] },
+ { include: ["<sys/spawn.h>", "private", "<spawn.h>", "public"] },
+ { include: ["<sys/dirent.h>", "private", "<dirent.h>", "public"] },
+# { include: ["<>", "private", "<>", "public"] },
+
+ { symbol: ["NULL", "private", "<stddef.h>", "public"] },
+ { symbol: ["NULL", "private", "<stdlib.h>", "public"] },
+ { symbol: ["NULL", "private", "<stdio.h>", "public"] },
+ { symbol: ["NULL", "private", "<unistd.h>", "public"] },
+ { symbol: ["off_t", "private", "<unistd.h>", "public"] },
+ { symbol: ["size_t", "private", "<unistd.h>", "public"] },
+ { symbol: ["size_t", "private", "<stddef.h>", "public"] },
+ { symbol: ["size_t", "private", "<stdlib.h>", "public"] },
+ { symbol: ["off_t", "private", "<sys/types.h>", "public"] },
+ { symbol: ["size_t", "private", "<sys/types.h>", "public"] },
+ { symbol: ["ssize_t", "private", "<sys/types.h>", "public"] },
+ { symbol: ["intptr_t", "private", "<unistd.h>", "public"] },
+ { symbol: ["ssize_t", "private", "<unistd.h>", "public"] },
+ { symbol: ["gid_t", "private", "<unistd.h>", "public"] },
+ { symbol: ["uid_t", "private", "<unistd.h>", "public"] },
+ { symbol: ["pid_t", "private", "<unistd.h>", "public"] },
+ { symbol: ["pid_t", "private", "<sys/types.h>", "public"] },
+ { symbol: ["uid_t", "private", "<sys/types.h>", "public"] },
+ { symbol: ["gid_t", "private", "<sys/types.h>", "public"] },
+ { symbol: ["uint32_t", "private", "<sys/types.h>", "public"] },
+ { symbol: ["uint32_t", "private", "<stdint.h>", "public"] },
+ { symbol: ["intptr_t", "private", "<stdint.h>", "public"] },
+ { symbol: ["size_t", "private", "<stdint.h>", "public"] },
+ { symbol: ["tparm", "private", "<ncurses.h>", "public"] },
+ { symbol: ["ERR", "private", "<ncurses.h>", "public"] },
+ { symbol: ["select", "private", "<sys/select.h>", "public"] },
+ { symbol: ["_LIBCPP_VERSION", "private", "<stddef.h>", "public"] },
+ { symbol: ["_LIBCPP_VERSION", "private", "<unistd.h>", "public"] },
+ { symbol: ["MB_CUR_MAX", "private", "<xlocale.h>", "public"] },
+ { symbol: ["MB_CUR_MAX", "private", "<stdlib.h>", "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 <assert.h>
#include <errno.h>
#include <sys/stat.h>
@@ -9,12 +8,17 @@
#include <string>
#include <utility>
#include <vector>
+#include <pthread.h>
+#include <stddef.h>
+#include <set>
+#include <time.h>
+#include <stdbool.h>
+
+#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 <stddef.h>
#include <time.h>
#include <set>
+#include <stdbool.h>
+
#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 <assert.h>
#include <errno.h>
#include <fcntl.h>
-#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -31,12 +29,13 @@
#include <wctype.h>
#include <algorithm>
#include <map>
-#include <stack>
#include <string>
#include <utility>
+#include <limits.h>
+#include <memory> // IWYU pragma: keep
+#include <stdbool.h>
#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 <stddef.h> // for size_t
-#include <vector> // for vector
+#include <stddef.h>
+#include <vector>
#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 <stdlib.h>
-#include <stdio.h>
#include <wchar.h>
-#include <wctype.h>
-#include <sys/types.h>
-#include <termios.h>
-#include <signal.h>
+#include <assert.h>
+#include <pthread.h>
+#include <errno.h>
+#include <cstring>
+#include <stdbool.h>
-#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 <stdlib.h>
-#include <stdio.h>
#include <wchar.h>
-#include <wctype.h>
-#include <sys/types.h>
-#include <termios.h>
-#include <signal.h>
-
-#include "fallback.h"
-#include "util.h"
+#include <string>
+#include <vector>
+#include <memory> // IWYU pragma: keep
+#include <stdbool.h>
-#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 <stdlib.h>
-#include <stdio.h>
-#include <wchar.h>
-#include <unistd.h>
-#include <termios.h>
#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <wctype.h>
-
-#include "fallback.h"
-#include "util.h"
+#include <stdbool.h>
+#ifdef HAVE__PROC_SELF_STAT
+#include <sys/time.h>
+#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 <errno.h>
+#include <limits.h>
+#include <locale.h>
+#include <wchar.h>
+#include <wctype.h>
#include <stdio.h>
#include <sys/types.h>
-#include <inttypes.h>
+#include <stdarg.h>
+#include <string.h>
+#include <stdbool.h>
#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 <stdlib.h>
-#include <stdio.h>
#include <wchar.h>
#include <wctype.h>
-#include <sys/types.h>
-#include <termios.h>
-#include <signal.h>
#include <vector>
#include <algorithm>
-#include "fallback.h"
-#include "util.h"
-
-#include "wutil.h"
+#include <sys/stat.h>
+#include <string>
+#include <memory>
+#include <errno.h>
+#include <set>
+#include <iterator>
+#include <stdbool.h>
+
+#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 <ncurses.h>
#elif HAVE_NCURSES_CURSES_H
@@ -16,13 +12,29 @@ Functions used for implementing the set_color builtin.
#else
#include <curses.h>
#endif
-
#if HAVE_TERM_H
#include <term.h>
#elif HAVE_NCURSES_TERM_H
#include <ncurses/term.h>
#endif
+#include <unistd.h>
+#include <assert.h>
+#include <string>
+#include <vector>
+#include <memory>
+#include <stdlib.h>
+#include <stdbool.h>
+
+#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 <iterator>
+#include <algorithm>
+#include <assert.h>
+#include <limits.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <wchar.h>
+#include <wctype.h>
+#include <string>
+#include <vector>
+#include <sys/types.h>
+#include <stdbool.h>
+#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 <iterator>
-#include <algorithm>
-#include <unistd.h>
+#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 <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <memory>
+#include <assert.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <wchar.h>
+#include <string>
+#include <stdbool.h>
+#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 <stdlib.h>
-#include <stdio.h>
#include <wchar.h>
-#include <wctype.h>
-#include <sys/time.h>
#include <sys/resource.h>
-#include <unistd.h>
#include <errno.h>
-#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 <assert.h>
#include <stdint.h>
#include <stdlib.h>
-#include <wchar.h>
-#include <cstddef>
+
+#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 <string.h>
#include <string>
+#include <stdbool.h>
+
#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 <unistd.h>
-
#ifdef HAVE_SIGINFO_H
#include <siginfo.h>
#endif
-
#include <stdlib.h>
#include <termios.h>
#include <wchar.h>
@@ -22,28 +18,26 @@ parts of fish.
#include <assert.h>
#include <math.h>
#include <signal.h>
-
-
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
-
#include <sys/stat.h>
#include <wctype.h>
#include <errno.h>
#include <limits.h>
#include <stdarg.h>
+#include <stddef.h>
#include <locale.h>
#include <sys/time.h>
#include <algorithm>
-
#ifdef HAVE_EXECINFO_H
#include <execinfo.h>
#endif
+#include <stdint.h>
+#include <stdbool.h>
-#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 <stdlib.h>
#include <stdio.h>
#include <wchar.h>
-#include <termios.h>
#include <string>
#include <sstream>
#include <vector>
#include <pthread.h>
#include <string.h>
-#include <stdarg.h>
-#include <stddef.h>
#include <sys/types.h>
-
#include <errno.h>
-#include "config.h"
-#include "fallback.h"
+#include <termios.h>
+#include <memory>
+#include <stdbool.h>
+
+#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 <assert.h>
-#include <stdlib.h>
#include <stddef.h>
#include <wchar.h>
#include <wctype.h>
@@ -17,10 +14,11 @@
#include <set>
#include <string>
#include <utility>
+#include <memory>
+#include <stdbool.h>
-#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 <vector>
#include <stdint.h>
+#include <stdbool.h>
#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 <stdlib.h>
#include <wchar.h>
#include <locale.h>
@@ -19,10 +17,11 @@
#include <wctype.h>
#include <utility>
#include <vector>
+#include <sys/types.h>
+#include <stdbool.h>
-#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 <wchar.h>
#include <stdint.h>
#include <string>
#include <map>
+#include <stddef.h>
+#include <memory>
+#include <stdbool.h>
#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 <fcntl.h>
-#include <sys/ioctl.h>
#include <sys/mman.h>
-#include <sys/file.h>
-#include <sys/socket.h>
-#include <arpa/inet.h> // IWYU pragma: keep - needed for htonl
+#include <arpa/inet.h> // IWYU pragma: keep
#include <pwd.h>
#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <stdarg.h>
-#include <stddef.h>
-#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
-#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
#include <wchar.h>
#include <wctype.h>
-#include <map>
-#include <utility>
-
+#include <string>
+#include <stdbool.h>
+#include <sys/socket.h>
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
+#include <map>
+#include <utility>
+#include <netinet/in.h>
+// 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 <sys/ioctl.h> // IWYU pragma: keep
+// We need the sys/file.h for the flock() declaration on Linux but not OS X.
+#include <sys/file.h> // 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 <string>
-#include <set>
#include <pthread.h>
#include <stdio.h>
+#include <stdbool.h>
+#include <set>
+#include <memory>
#include <vector>
+
#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 <signal.h>
-#include <algorithm>
#include <assert.h>
-#include <stddef.h>
+#include <unistd.h>
+#include <memory>
+#include <algorithm>
#include <string>
+#include <stdbool.h>
#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 <ctime>
+#include <unistd.h>
#include <vector>
+#include <stdbool.h>
#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 <stdlib.h>
#include <stdio.h>
@@ -24,17 +23,16 @@
#include <wctype.h>
#include <map>
#include <string>
-#include <memory> // IWYU pragma: keep - suggests <tr1/memory> instead
-#include <utility>
-
+#include <memory>
#ifdef HAVE_SIGINFO_H
#include <siginfo.h>
#endif
+#include <stdbool.h>
-#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 <stddef.h>
#include <vector>
+#include <stdbool.h>
#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 <cstddef>
+#include "config.h"
#include <stdlib.h>
-#include <stdio.h>
#include <stdarg.h>
#include <stddef.h>
#include <wchar.h>
@@ -16,38 +15,43 @@ parameter expansion.
#include <wctype.h>
#include <errno.h>
#include <pwd.h>
-#include <dirent.h>
-#include <sys/stat.h>
#include <unistd.h>
#include <algorithm>
#ifdef HAVE_SYS_SYSCTL_H
-#include <sys/sysctl.h> // IWYU pragma: keep - needed for KERN_PROCARGS2
+#include <sys/sysctl.h> // IWYU pragma: keep
#endif
-
#include <assert.h>
#include <vector>
-
#ifdef SunOS
#include <procfs.h>
#endif
+#include <memory> // IWYU pragma: keep
+#include <stdio.h>
+#if __APPLE__
+#include <sys/proc.h>
+#else
+#include <sys/stat.h>
+#include <dirent.h>
+#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 <wchar.h>
-#include <string> // for string
-#include <vector> // for vector
+#include <string>
+#include <vector>
+#include <stddef.h>
+#include <stdbool.h>
#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 <stdlib.h>
-#include <stdio.h>
+#include <stdio.h> // IWYU pragma: keep
#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <fcntl.h>
+#include <sys/types.h> // IWYU pragma: keep
+#include <sys/stat.h> // IWYU pragma: keep
+#include <errno.h> // IWYU pragma: keep
+#include <fcntl.h> // IWYU pragma: keep
#include <wchar.h>
#include <wctype.h>
#include <string.h>
-#include <dirent.h>
-#include <stdarg.h>
-#include <limits.h>
-#include <assert.h>
-
+#include <dirent.h> // IWYU pragma: keep
+#include <stdarg.h> // IWYU pragma: keep
+#include <limits.h> // IWYU pragma: keep
+#include <assert.h> // IWYU pragma: keep
#if HAVE_GETTEXT
#include <libintl.h>
#endif
-
#if HAVE_NCURSES_H
-#include <ncurses.h>
+#include <ncurses.h> // IWYU pragma: keep
#elif HAVE_NCURSES_CURSES_H
#include <ncurses/curses.h>
#else
#include <curses.h>
#endif
-
#if HAVE_TERM_H
-#include <term.h>
+#include <term.h> // IWYU pragma: keep
#elif HAVE_NCURSES_TERM_H
#include <ncurses/term.h>
#endif
+#include <signal.h> // IWYU pragma: keep
+#include <wchar.h> // 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 <wchar.h>
-
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 <stdio.h>
+#include "config.h"
+
+// IWYU likes to recommend adding <term.h> when we want <ncurses.h>. If we add <term.h> it breaks
+// compiling several modules that include this header because they use symbols which are defined as
+// macros in <term.h>.
+// IWYU pragma: no_include <term.h>
#include <stdint.h>
-#include <stdarg.h>
-#include <wctype.h>
-#include <wchar.h>
-#include <limits.h>
-#include <sys/time.h>
-#include <sys/types.h>
#include <signal.h>
+#include <unistd.h>
+// 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 <wchar.h>. 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 <wchar.h> // IWYU pragma: keep
+#if HAVE_NCURSES_H
+#include <ncurses.h> // 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 <tt>fish</tt>.
*/
-
#include "config.h"
#include <assert.h>
#include <getopt.h>
#include <limits.h>
-#include <stddef.h>
#include <stdint.h>
#include <sys/stat.h>
#include <string>
@@ -37,22 +34,23 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
-#include <sys/socket.h> // IWYU pragma: keep - suggests internal header
+#include <sys/socket.h> // IWYU pragma: keep
#include <sys/un.h>
#include <pwd.h>
#include <locale.h>
+#include <memory>
+#include <stdbool.h>
#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 <getopt.h>
#include <stdlib.h>
#include <stdio.h>
@@ -27,11 +24,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#include <locale.h>
#include <stddef.h>
#include <string>
+#include <memory>
+#include <wctype.h>
+#include <stdbool.h>
#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 <cstring>
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
#include <string.h>
#include <unistd.h>
-#include <errno.h>
-#include <unistd.h>
-#include <termios.h>
#include <sys/types.h>
-#include <sys/stat.h>
#include <sys/wait.h>
-#include <fcntl.h>
#include <stdarg.h>
#include <libgen.h>
#include <iostream>
@@ -25,31 +18,36 @@
#include <iterator>
#include <signal.h>
#include <locale.h>
-#include <dirent.h>
#include <time.h>
-
-#include "fallback.h"
+#include <assert.h>
+#include <limits.h>
+#include <pthread.h>
+#include <stddef.h>
+#include <memory>
+#include <set>
+#include <vector>
+#include <wctype.h>
+#include <stdbool.h>
+#include <sys/select.h>
+
+#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 <type_traits>
#include <wchar.h>
#include <pthread.h>
#include <map>
@@ -17,10 +15,10 @@
#include <stddef.h>
#include <string>
#include <utility>
+#include <memory>
-#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 <vector>
#include <map>
+#include <stdbool.h>
#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 <cstddef>
#include <sys/stat.h>
#include <unistd.h>
#include <errno.h>
@@ -13,10 +11,13 @@
#include <map>
#include <set>
#include <string>
+#include <memory>
+#include <utility>
+#include <limits.h>
+#include <wctype.h>
-#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 <assert.h> // for assert
-#include <stddef.h> // for size_t
-#include <stdint.h> // for uint32_t
-#include <vector> // for vector
+#include <assert.h>
+#include <stdint.h>
+#include <vector>
+#include <stdbool.h>
-#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 <assert.h>
#include <ctype.h>
#include <errno.h>
@@ -16,10 +15,12 @@
#include <algorithm>
#include <iterator>
#include <map>
+#include <pthread.h>
+
#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 <cstddef>
#include <pthread.h>
-#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <time.h>
@@ -12,8 +12,11 @@
#include <string>
#include <utility>
#include <vector>
+#include <memory>
+#include <stdbool.h>
+
#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 <assert.h>
#include <errno.h>
#include <unistd.h>
#include <wchar.h>
-
#if HAVE_NCURSES_H
#include <ncurses.h>
#elif HAVE_NCURSES_CURSES_H
@@ -18,17 +15,19 @@
#else
#include <curses.h>
#endif
-
#if HAVE_TERM_H
#include <term.h>
#elif HAVE_NCURSES_TERM_H
#include <ncurses/term.h>
#endif
-
#include <wctype.h>
+#include <vector>
+#include <algorithm>
+#include <memory>
+#include <string>
#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 <vector>
-#include <algorithm>
#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 <stddef.h>
-#include <string>
#include <vector>
+#include <stdbool.h>
#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 <string.h>
#include <errno.h>
-#include <sys/time.h>
#include <unistd.h>
#include <list>
#include <queue>
-#include <cwchar> // for wint_t
-#include <deque> // for deque
-#include <utility> // for swap, pair
+#include <deque>
+#include <utility>
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
+#include <stdbool.h>
+#include <memory>
+#include <cwctype>
+#include <wchar.h>
+#include <wctype.h>
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
#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 <wchar.h>
#include <pthread.h>
#include <vector>
#include <algorithm>
+#include <memory>
+#include <stddef.h>
+#include <stdbool.h>
#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 <stdio.h>
#include <errno.h>
#include <assert.h>
#include <unistd.h>
+#include <stddef.h>
#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 <vector>
#include <stddef.h>
#include <stdlib.h>
-
+#include <stdarg.h>
// 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 <memory>
@@ -17,6 +17,7 @@ using std::shared_ptr;
#include <tr1/memory>
using std::tr1::shared_ptr;
#endif
+#include <stdbool.h>
#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 <pthread.h>
#include <assert.h>
#include <stdio.h>
-#include <limits.h> // IWYU pragma: keep - for _POSIX_THREADS_MAX, suggests internal header
+#include <limits.h>
#include <sys/select.h>
-#include <sys/time.h>
+#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
#include <fcntl.h>
#include <queue>
-#include <algorithm>
+#include <stdbool.h>
+
+#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 <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <termios.h>
-#include <unistd.h>
#include <locale.h>
#include <termcap.h>
#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 <stddef.h>
#include <algorithm>
#include <list>
#include <string>
+#include <memory>
+#include <stdbool.h>
#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 <map>
#include <set>
#include <list>
+
#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 <stdlib.h>
#include <stdio.h>
#include <string.h>
-
#if HAVE_NCURSES_H
#include <ncurses.h>
#elif HAVE_NCURSES_CURSES_H
@@ -15,25 +13,25 @@
#else
#include <curses.h>
#endif
-
#if HAVE_TERM_H
#include <term.h>
#elif HAVE_NCURSES_TERM_H
#include <ncurses/term.h>
#endif
-
#include <wchar.h>
#include <limits.h>
#include <string>
+#include <vector>
+#include <memory>
-#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 <stddef.h>
#include <vector>
+#include <stddef.h>
+#include <stdbool.h>
+
#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 <cstddef>
#include <assert.h>
#include <wchar.h>
#include <wctype.h>
#include <vector>
#include <map>
+#include <stddef.h>
+
#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_t> 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 <stddef.h>
#include <string>
#include <vector>
+#include <memory>
+#include <stdbool.h>
+
#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 <assert.h>
#include <errno.h>
#include <stdarg.h>
@@ -18,8 +16,11 @@
#include <wchar.h>
#include <wctype.h>
#include <string>
-#include <memory> // IWYU pragma: keep - suggests <tr1/memory> instead
+#include <memory>
#include <vector>
+#include <stdbool.h>
+
+#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 <stddef.h>
+
#include "common.h"
#include "io.h"
#include "parse_constants.h"
#include "parse_tree.h"
#include "proc.h"
+#include <stdbool.h>
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 <assert.h>
#include <stdio.h>
+
#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 <stdint.h> // for uint8_t, uint32_t
-#include "common.h" // for wcstring
-#include "parse_constants.h" // for parse_token_type_t, etc
+#include <sys/types.h>
+#include <stdbool.h>
+
+#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 <assert.h>
#include <stdarg.h>
#include <stddef.h>
-#include <stdint.h>
#include <stdio.h>
#include <wchar.h>
#include <string>
+#include <vector>
+#include <algorithm>
+#include <cwchar>
+
#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 <vector>
-#include <algorithm>
// 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 <assert.h>
#include <stddef.h>
-#include <stdint.h>
+#include <vector>
+#include <memory>
+#include <sys/types.h>
+#include <stdbool.h>
#include "common.h"
#include "tokenizer.h"
#include "parse_constants.h"
-#include <vector>
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 <stdlib.h>
#include <stdarg.h>
#include <wchar.h>
#include <string>
#include <assert.h>
+#include <stdio.h>
+#include <memory>
+#include <stdbool.h>
-#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 <stddef.h>
#include <vector>
+#include <stdbool.h>
+
#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 <stdio.h>
#include <wchar.h>
#include <assert.h>
-#include <string>
#include <algorithm>
+#include <memory>
+#include <stdbool.h>
-#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 <stddef.h> // for size_t
-#include <list> // for _List_const_iterator, list, etc
+#include <stddef.h>
+#include <list>
+#include <vector>
+#include <stdbool.h>
#include "common.h"
#include "proc.h"
#include "event.h"
#include "parse_tree.h"
-#include "io.h"
#include "parse_constants.h"
#include "expand.h"
-#include <vector>
+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 <stdbool.h>
+
#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 <wchar.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -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 <stddef.h>
+#include <stdbool.h>
+
#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 <stdio.h>
#include <string.h>
#include <time.h>
-#include <memory> // IWYU pragma: keep - suggests <tr1/memory> instead
+#include <memory>
+#if FISH_USE_POSIX_SPAWN
+#include <spawn.h>
+#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 <stddef.h>
-#include <unistd.h>
-
#include "config.h"
-#include "io.h"
+#include <unistd.h>
#if HAVE_SPAWN_H
#include <spawn.h>
#endif
-
#ifndef FISH_USE_POSIX_SPAWN
#define FISH_USE_POSIX_SPAWN HAVE_SPAWN_H
#endif
+#include <stdbool.h>
+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 <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <stddef.h>
#include <sys/types.h>
#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 <stdlib.h>
#include <stdio.h>
#include <sys/wait.h>
#include <wchar.h>
-#include <string.h>
#include <errno.h>
#include <termios.h>
#include <pthread.h>
#include <wctype.h>
-#include <algorithm>
-#include <memory> // IWYU pragma: keep - suggests <tr1/memory> instead
+#include <memory>
#include <vector>
-
#include <unistd.h>
#include <signal.h>
-#include <sys/time.h>
-
#if HAVE_TERM_H
#include <term.h>
#elif HAVE_NCURSES_TERM_H
#include <ncurses/term.h>
#endif
-
#ifdef HAVE_SIGINFO_H
#include <siginfo.h>
#endif
-
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
+#include <sys/types.h>
+#include <stdbool.h>
+#include <sys/time.h> // IWYU pragma: keep
+#include <algorithm> // 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 <signal.h>
-#include <sys/time.h>
#include <list>
-#include <assert.h> // for assert
-#include <stddef.h> // for size_t
-#include <termios.h> // for pid_t, termios
+#include <assert.h>
+#include <stddef.h>
+#include <termios.h>
+#include <unistd.h>
+#include <stdbool.h>
+#include <sys/time.h> // 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 <algorithm>
+// IWYU pragma: no_include <type_traits>
+#include <algorithm>
#include <stdlib.h>
#include <stdio.h>
-#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <termios.h>
@@ -34,25 +33,22 @@ commence.
#include <wctype.h>
#include <stack>
#include <pthread.h>
-
#ifdef HAVE_SIGINFO_H
#include <siginfo.h>
#endif
-
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
-
#include <signal.h>
#include <fcntl.h>
#include <wchar.h>
#include <assert.h>
+#include <sys/types.h>
+#include <memory>
-
-#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 <vector>
#include <string>
#include <stddef.h>
+#include <stdbool.h>
-#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<highlight_spec_t> &, 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 <unistd.h>
#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 <cstddef>
#include "config.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-
#include <unistd.h>
-
#if HAVE_NCURSES_H
#include <ncurses.h>
#elif HAVE_NCURSES_CURSES_H
@@ -21,23 +19,19 @@ efficient way for transforming that to the desired screen content.
#else
#include <curses.h>
#endif
-
#if HAVE_TERM_H
#include <term.h>
#elif HAVE_NCURSES_TERM_H
#include <ncurses/term.h>
#endif
-
#include <wchar.h>
#include <time.h>
-
#include <assert.h>
#include <algorithm>
#include <string>
#include <vector>
-
-#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 <sys/stat.h>
#include "common.h"
#include "highlight.h"
+#include <stdbool.h>
+#include <memory>
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 <wchar.h>
#include <stdio.h>
#include <signal.h>
#include <errno.h>
-
#ifdef HAVE_SIGINFO_H
#include <siginfo.h>
#endif
+#include <pthread.h>
+#include <stdbool.h>
#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 <signal.h>
+#include <stdbool.h>
/**
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 <wchar.h>
#include <wctype.h>
#include <unistd.h>
#include <fcntl.h>
#include <assert.h>
#include <string>
+#include <limits.h>
#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 <stddef.h>
+#include <stdbool.h>
+
#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 <sys/types.h>
-#include <stdint.h>
-
-#include "utf8.h"
-
+#include <stdint.h> // IWYU pragma: keep
#include <string>
#include <limits>
-#include <algorithm>
+
+#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 <stddef.h>
-
#include <string>
#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 <stdio.h>
#include <stdlib.h>
#include <wchar.h>
-#include <math.h>
-#include <sys/time.h>
-#include <stdarg.h>
-#include <string.h>
-#include <ctype.h>
#include <wctype.h>
-#include <unistd.h>
#include <sys/types.h>
-#include <sys/stat.h>
-#include <dirent.h>
#include <errno.h>
-#include <assert.h>
+#include <sys/time.h>
-#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 <wchar.h>
-#include <stdarg.h>
-#include <unistd.h>
-
/**
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 <string>
#include <utility>
+
#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 <stdio.h>
#include <wchar.h>
-#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 <wchar.h>
+#include <stddef.h>
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 <stdlib.h>
#include <wchar.h>
#include <unistd.h>
#include <sys/stat.h>
#include <dirent.h>
#include <errno.h>
-#include <string.h>
#include <set>
#include <assert.h>
-#include <stddef.h>
-#include <wctype.h>
#include <string>
#include <utility>
+#include <stdbool.h>
+#include <sys/types.h>
+#include <memory>
-#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 <map>
/**
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 <vector>
+#include <stdbool.h>
#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 <assert.h>
#include <string>
#include <map>
-
-#include "fallback.h"
+#include <memory>
#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 <stdio.h>
#include <dirent.h>
#include <sys/types.h>
-#include <stddef.h>
#include <time.h>
#include <string>
-#include <stdint.h>
+#include <stdbool.h>
+
#include "common.h"
/**