From 569b61137cf45521d9fd4f693cf841be485dd4b8 Mon Sep 17 00:00:00 2001 From: Randy Palamar Date: Sat, 13 Dec 2025 11:17:09 -0700 Subject: move all standard library includes into util.h --- Makefile | 2 +- array.c | 4 ---- array.h | 3 --- buffer.c | 5 ----- buffer.h | 2 -- configure | 2 +- event-basic.c | 2 -- map.c | 3 --- sam.c | 9 --------- test/core/array-test.c | 7 +------ test/core/buffer-test.c | 8 +++----- test/core/map-test.c | 7 +++---- test/core/text-test.c | 11 ++--------- text-common.c | 3 --- text-internal.h | 2 -- text-io.c | 16 ---------------- text-iterator.c | 5 ----- text-motions.c | 6 ------ text-motions.h | 1 - text-objects.c | 4 ---- text-objects.h | 1 - text-regex-tre.c | 5 ----- text-regex.c | 3 --- text-util.c | 3 --- text-util.h | 2 -- text.c | 15 --------------- text.h | 8 -------- ui-terminal-curses.c | 1 - ui-terminal.c | 17 ----------------- ui.h | 4 ---- util.h | 36 ++++++++++++++++++++++++++++++++++++ view.c | 8 -------- view.h | 3 --- vis-cmds.c | 1 - vis-core.h | 2 -- vis-lua.c | 10 ---------- vis-menu.c | 3 +++ vis-modes.c | 2 -- vis-motions.c | 3 --- vis-operators.c | 2 -- vis-prompt.c | 1 - vis-registers.c | 3 --- vis-subprocess.c | 7 ------- vis-subprocess.h | 1 - vis.c | 25 ++----------------------- 45 files changed, 52 insertions(+), 216 deletions(-) diff --git a/Makefile b/Makefile index 3335f10..bf1dc69 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ DOCUMENTATION = LICENSE README.md VERSION = $(shell git describe --always --dirty 2>/dev/null || echo "v0.9-git") -CFLAGS_STD ?= -std=c99 -U_XOPEN_SOURCE -D_XOPEN_SOURCE=700 -DNDEBUG +CFLAGS_STD ?= -std=c99 -DNDEBUG CFLAGS_STD += -DVERSION=\"${VERSION}\" LDFLAGS_STD ?= -lc diff --git a/array.c b/array.c index b1e55b2..a6de4b1 100644 --- a/array.c +++ b/array.c @@ -1,7 +1,3 @@ -#include -#include -#include - #include "util.h" #include "array.h" diff --git a/array.h b/array.h index 1d9e1cf..9deac45 100644 --- a/array.h +++ b/array.h @@ -1,9 +1,6 @@ #ifndef ARRAY_H #define ARRAY_H -#include -#include - /** * @file * diff --git a/buffer.c b/buffer.c index 709a328..67070b9 100644 --- a/buffer.c +++ b/buffer.c @@ -1,8 +1,3 @@ -#include -#include -#include -#include - #include "buffer.h" #ifndef BUFFER_SIZE diff --git a/buffer.h b/buffer.h index 66e8d4d..d8a58fb 100644 --- a/buffer.h +++ b/buffer.h @@ -1,8 +1,6 @@ #ifndef BUFFER_H #define BUFFER_H -#include -#include #include "text.h" /** diff --git a/configure b/configure index 7278f99..1842e23 100755 --- a/configure +++ b/configure @@ -220,7 +220,7 @@ tryflag CFLAGS_TRY -Werror=unused-command-line-argument tryldflag LDFLAGS_TRY -Werror=unknown-warning-option tryldflag LDFLAGS_TRY -Werror=unused-command-line-argument -CFLAGS_STD="-std=c99 -U_XOPEN_SOURCE -D_XOPEN_SOURCE=700 -DNDEBUG" +CFLAGS_STD="-std=c99 -DNDEBUG" LDFLAGS_STD="-lc" OS=$(uname) diff --git a/event-basic.c b/event-basic.c index e070522..a03d13f 100644 --- a/event-basic.c +++ b/event-basic.c @@ -1,5 +1,3 @@ -#include - #include "vis-core.h" #if !CONFIG_LUA diff --git a/map.c b/map.c index 44b6ade..12b2f16 100644 --- a/map.c +++ b/map.c @@ -9,9 +9,6 @@ * http://github.com/agl/critbit * http://ccodearchive.net/info/strmap.html */ -#include -#include -#include #include "map.h" typedef struct Node Node; diff --git a/sam.c b/sam.c index 2d6e634..cd91059 100644 --- a/sam.c +++ b/sam.c @@ -16,15 +16,6 @@ * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. */ -#include -#include -#include -#include -#include -#include -#include -#include - #include "util.h" #include "sam.h" diff --git a/test/core/array-test.c b/test/core/array-test.c index e4da4f6..5944904 100644 --- a/test/core/array-test.c +++ b/test/core/array-test.c @@ -1,9 +1,4 @@ -#include -#include -#include -#include -#include -#include +#include "util.h" #include "tap.h" diff --git a/test/core/buffer-test.c b/test/core/buffer-test.c index 8034ac4..edb7786 100644 --- a/test/core/buffer-test.c +++ b/test/core/buffer-test.c @@ -1,9 +1,7 @@ -#include -#include -#include -#include -#include +#include "util.h" + #include "tap.h" + #include "buffer.c" static bool compare(Buffer *buf, const char *data, size_t len) { diff --git a/test/core/map-test.c b/test/core/map-test.c index a8231a3..a78777f 100644 --- a/test/core/map-test.c +++ b/test/core/map-test.c @@ -1,8 +1,7 @@ -#include -#include -#include -#include +#include "util.h" + #include "tap.h" + #include "map.c" static bool get(Map *map, const char *key, const void *data) { diff --git a/test/core/text-test.c b/test/core/text-test.c index c69038c..4ec5fb6 100644 --- a/test/core/text-test.c +++ b/test/core/text-test.c @@ -1,14 +1,7 @@ -#include -#include -#include -#include -#include -#include -#include -#include "tap.h" - #include "util.h" +#include "tap.h" + #include "array.c" #include "buffer.c" #include "text.c" diff --git a/text-common.c b/text-common.c index 87dc13f..d052d51 100644 --- a/text-common.c +++ b/text-common.c @@ -1,6 +1,3 @@ -#include -#include -#include #include "text.h" static bool text_vprintf(Text *txt, size_t pos, const char *format, va_list ap) { diff --git a/text-internal.h b/text-internal.h index 3f9052f..13647d6 100644 --- a/text-internal.h +++ b/text-internal.h @@ -1,8 +1,6 @@ #ifndef TEXT_INTERNAL #define TEXT_INTERNAL -#include -#include #include "text.h" /* Block holding the file content, either readonly mmap(2)-ed from the original diff --git a/text-io.c b/text-io.c index bbd1f8d..aca5441 100644 --- a/text-io.c +++ b/text-io.c @@ -1,19 +1,3 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#if CONFIG_ACL -#include -#endif -#if CONFIG_SELINUX -#include -#endif - #include "text.h" #include "text-internal.h" #include "text-util.h" diff --git a/text-iterator.c b/text-iterator.c index e264781..3dbf664 100644 --- a/text-iterator.c +++ b/text-iterator.c @@ -1,8 +1,3 @@ -#include -#include -#include -#include -#include #include "text.h" #include "util.h" diff --git a/text-motions.c b/text-motions.c index a17adde..9bd6461 100644 --- a/text-motions.c +++ b/text-motions.c @@ -1,9 +1,3 @@ -#include -#include -#include -#include -#include -#include #include "text-motions.h" #include "text-util.h" #include "util.h" diff --git a/text-motions.h b/text-motions.h index 95e554d..218b44b 100644 --- a/text-motions.h +++ b/text-motions.h @@ -5,7 +5,6 @@ * perform a certain movement and return the new position. If the movement * is not possible the original position is returned unchanged. */ -#include #include "text.h" #include "text-regex.h" diff --git a/text-objects.c b/text-objects.c index 69ea91c..5e724b8 100644 --- a/text-objects.c +++ b/text-objects.c @@ -1,7 +1,3 @@ -#include -#include -#include -#include #include "text-motions.h" #include "text-objects.h" #include "text-util.h" diff --git a/text-objects.h b/text-objects.h index d9ea218..f98c496 100644 --- a/text-objects.h +++ b/text-objects.h @@ -6,7 +6,6 @@ * such text-object at the given location, an empty range is returned. */ -#include #include "text.h" /* return range covering the entire text */ diff --git a/text-regex-tre.c b/text-regex-tre.c index eccbafb..a4443f7 100644 --- a/text-regex-tre.c +++ b/text-regex-tre.c @@ -1,8 +1,3 @@ -#include -#include -#include -#include - #include "text-regex.h" #include "text-motions.h" diff --git a/text-regex.c b/text-regex.c index 7c6812e..0cf05ab 100644 --- a/text-regex.c +++ b/text-regex.c @@ -1,6 +1,3 @@ -#include -#include - #include "text-regex.h" struct Regex { diff --git a/text-util.c b/text-util.c index 7e47cce..acd80c2 100644 --- a/text-util.c +++ b/text-util.c @@ -1,8 +1,5 @@ #include "text-util.h" #include "util.h" -#include -#include -#include Filerange text_range_union(const Filerange *r1, const Filerange *r2) { if (!text_range_valid(r1)) diff --git a/text-util.h b/text-util.h index 922bab3..9e906b5 100644 --- a/text-util.h +++ b/text-util.h @@ -1,8 +1,6 @@ #ifndef TEXT_UTIL_H #define TEXT_UTIL_H -#include -#include #include "text.h" /* test whether the given range is valid (start <= end) */ diff --git a/text.c b/text.c index f2ecce8..b6ea518 100644 --- a/text.c +++ b/text.c @@ -1,18 +1,3 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "util.h" #include "array.h" diff --git a/text.h b/text.h index 9057a6a..4ff8bdb 100644 --- a/text.h +++ b/text.h @@ -1,14 +1,6 @@ #ifndef TEXT_H #define TEXT_H -#include -#include -#include -#include -#include -#include -#include - #include "util.h" /** A mark. */ diff --git a/ui-terminal-curses.c b/ui-terminal-curses.c index a2aa7ec..1224d5a 100644 --- a/ui-terminal-curses.c +++ b/ui-terminal-curses.c @@ -1,5 +1,4 @@ /* This file is included from ui-terminal.c */ -#include #include #define UI_TERMKEY_FLAGS (TERMKEY_FLAG_UTF8|TERMKEY_FLAG_NOTERMIOS) diff --git a/ui-terminal.c b/ui-terminal.c index a96bea3..746e24c 100644 --- a/ui-terminal.c +++ b/ui-terminal.c @@ -1,20 +1,3 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "vis.h" #include "vis-core.h" #include "text.h" diff --git a/ui.h b/ui.h index 6ed0587..d971562 100644 --- a/ui.h +++ b/ui.h @@ -1,10 +1,6 @@ #ifndef UI_H #define UI_H -#include -#include -#include - /* enable large file optimization for files larger than: */ #define UI_LARGE_FILE_SIZE (1 << 25) /* enable large file optimization for files containing lines longer than: */ diff --git a/util.h b/util.h index 83dd4ab..6e8adbc 100644 --- a/util.h +++ b/util.h @@ -26,9 +26,45 @@ #define CONFIG_ACL 0 #endif +#undef _XOPEN_SOURCE +#define _XOPEN_SOURCE 700 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#if CONFIG_ACL +#include +#endif +#if CONFIG_SELINUX +#include +#endif #define LENGTH(x) ((int)(sizeof (x) / sizeof *(x))) #define MIN(a, b) ((a) > (b) ? (b) : (a)) diff --git a/view.c b/view.c index 1cef27a..14b79b1 100644 --- a/view.c +++ b/view.c @@ -1,11 +1,3 @@ -#include -#include -#include -#include -#include -#include -#include - #include "vis-core.h" #include "view.h" #include "text.h" diff --git a/view.h b/view.h index b1370a3..c1fe735 100644 --- a/view.h +++ b/view.h @@ -1,9 +1,6 @@ #ifndef VIEW_H #define VIEW_H -#include -#include - #include "ui.h" #include "text.h" #include "array.h" diff --git a/vis-cmds.c b/vis-cmds.c index adb5822..0fef1be 100644 --- a/vis-cmds.c +++ b/vis-cmds.c @@ -1,6 +1,5 @@ /* this file is included from sam.c */ -#include #include "vis-lua.h" // FIXME: avoid this redirection? diff --git a/vis-core.h b/vis-core.h index 8091305..6c54640 100644 --- a/vis-core.h +++ b/vis-core.h @@ -1,8 +1,6 @@ #ifndef VIS_CORE_H #define VIS_CORE_H -#include - #include "util.h" #include "vis.h" diff --git a/vis-lua.c b/vis-lua.c index 6e74e4f..28211a7 100644 --- a/vis-lua.c +++ b/vis-lua.c @@ -11,16 +11,6 @@ * @license ISC * @release RELEASE */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "util.h" #include "vis-lua.h" diff --git a/vis-menu.c b/vis-menu.c index 1dd115b..0685d40 100644 --- a/vis-menu.c +++ b/vis-menu.c @@ -30,6 +30,9 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ +#undef _XOPEN_SOURCE +#define _XOPEN_SOURCE 700 + #include #include #include diff --git a/vis-modes.c b/vis-modes.c index 5b8a71d..2d8abbd 100644 --- a/vis-modes.c +++ b/vis-modes.c @@ -1,5 +1,3 @@ -#include -#include #include "vis-core.h" #include "text-motions.h" #include "util.h" diff --git a/vis-motions.c b/vis-motions.c index d864dd5..0510a59 100644 --- a/vis-motions.c +++ b/vis-motions.c @@ -1,6 +1,3 @@ -#include -#include -#include #include "vis-core.h" #include "text-motions.h" #include "text-objects.h" diff --git a/vis-operators.c b/vis-operators.c index 123d126..ae2da5a 100644 --- a/vis-operators.c +++ b/vis-operators.c @@ -1,5 +1,3 @@ -#include -#include #include "vis-core.h" #include "text-motions.h" #include "text-objects.h" diff --git a/vis-prompt.c b/vis-prompt.c index 089a931..f6f06a7 100644 --- a/vis-prompt.c +++ b/vis-prompt.c @@ -1,4 +1,3 @@ -#include #include "vis-core.h" #include "text-motions.h" #include "text-objects.h" diff --git a/vis-registers.c b/vis-registers.c index e1f2c92..2059d5c 100644 --- a/vis-registers.c +++ b/vis-registers.c @@ -1,6 +1,3 @@ -#include -#include - #include "vis-core.h" static Buffer *register_buffer(Register *reg, size_t slot) { diff --git a/vis-subprocess.c b/vis-subprocess.c index b1d6a26..4c556be 100644 --- a/vis-subprocess.c +++ b/vis-subprocess.c @@ -1,10 +1,3 @@ -#include -#include -#include -#include -#include -#include - #include "util.h" #include "vis-lua.h" diff --git a/vis-subprocess.h b/vis-subprocess.h index 05f4dfe..3d69978 100644 --- a/vis-subprocess.h +++ b/vis-subprocess.h @@ -2,7 +2,6 @@ #define VIS_SUBPROCESS_H #include "vis-core.h" #include "vis-lua.h" -#include typedef struct Process Process; #if CONFIG_LUA diff --git a/vis.c b/vis.c index fcadd10..5bf2d6e 100644 --- a/vis.c +++ b/vis.c @@ -1,27 +1,7 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include "util.h" +#include + #include "vis.h" #include "text-util.h" #include "text-motions.h" @@ -31,7 +11,6 @@ #include "ui.h" #include "vis-subprocess.h" - #include "array.c" #include "buffer.c" #include "event-basic.c" -- cgit v1.2.3