[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 18/24: Rationalize and annotate header file inclusions.
From: |
G. Branden Robinson |
Subject: |
[groff] 18/24: Rationalize and annotate header file inclusions. |
Date: |
Mon, 2 Dec 2024 22:52:30 -0500 (EST) |
gbranden pushed a commit to branch master
in repository groff.
commit 267ced3fb559805da2d6ff5855637b762f28ed66
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Mon Dec 2 19:26:07 2024 -0600
Rationalize and annotate header file inclusions.
* src/devices/grohtml/output.cpp:
* src/libs/libgroff/color.cpp:
* src/libs/libgroff/maxfilename.cpp:
* src/libs/libgroff/maxpathname.cpp:
* src/libs/libgroff/tmpfile.cpp:
* src/preproc/html/pre-html.cpp:
* src/preproc/html/pushback.cpp:
* src/roff/groff/groff.cpp:
* src/roff/groff/pipeline.c:
* src/utils/indxbib/indxbib.cpp:
* src/utils/indxbib/signal.c: Do it.
---
ChangeLog | 15 +++++++++++++++
src/devices/grohtml/output.cpp | 9 +++------
src/libs/libgroff/color.cpp | 7 +------
src/libs/libgroff/maxfilename.cpp | 6 ------
src/libs/libgroff/maxpathname.cpp | 12 +++++-------
src/libs/libgroff/tmpfile.cpp | 12 ++++++++----
src/preproc/html/pre-html.cpp | 31 +++++++++++++------------------
src/preproc/html/pushback.cpp | 18 +++++++-----------
src/roff/groff/groff.cpp | 13 +++++++++++--
src/roff/groff/pipeline.c | 22 +++++++---------------
src/utils/indxbib/indxbib.cpp | 9 +++------
src/utils/indxbib/signal.c | 16 +++++++++++-----
12 files changed, 84 insertions(+), 86 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5e6312005..e901dc0c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2024-12-02 G. Branden Robinson <g.branden.robinson@gmail.com>
+
+ Rationalize and annotate header file inclusions.
+
+ * src/devices/grohtml/output.cpp:
+ * src/libs/libgroff/color.cpp:
+ * src/libs/libgroff/maxfilename.cpp:
+ * src/libs/libgroff/maxpathname.cpp:
+ * src/libs/libgroff/tmpfile.cpp:
+ * src/preproc/html/pre-html.cpp:
+ * src/preproc/html/pushback.cpp:
+ * src/roff/groff/pipeline.c:
+ * src/utils/indxbib/indxbib.cpp:
+ * src/utils/indxbib/signal.c: Do it.
+
2024-12-01 G. Branden Robinson <g.branden.robinson@gmail.com>
* src/preproc/grn/hdb.cpp: Include "<stdlib.h>" header file to
diff --git a/src/devices/grohtml/output.cpp b/src/devices/grohtml/output.cpp
index d0ed691f4..d524a4a9f 100644
--- a/src/devices/grohtml/output.cpp
+++ b/src/devices/grohtml/output.cpp
@@ -29,16 +29,13 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <config.h>
#endif
-#include <time.h>
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
+#include <stdio.h> // EOF, FILE, fflush(), fputc(), fputs(), fwrite(),
+ // getc(), putc(), sprintf()
+#include <string.h> // strlen(), strncpy()
#include "driver.h"
#include "stringclass.h"
#include "cset.h"
-
#include "html.h"
#if !defined(TRUE)
diff --git a/src/libs/libgroff/color.cpp b/src/libs/libgroff/color.cpp
index 7361826ca..0a8c9a946 100644
--- a/src/libs/libgroff/color.cpp
+++ b/src/libs/libgroff/color.cpp
@@ -21,12 +21,7 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#endif
#include <assert.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
+#include <stdio.h> // sprintf()
#include "lib.h"
diff --git a/src/libs/libgroff/maxfilename.cpp
b/src/libs/libgroff/maxfilename.cpp
index 2028dd904..23eb61557 100644
--- a/src/libs/libgroff/maxfilename.cpp
+++ b/src/libs/libgroff/maxfilename.cpp
@@ -22,12 +22,6 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
/* file_name_max(dir) does the same as pathconf(dir, _PC_NAME_MAX) */
-#include <sys/types.h>
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif /* HAVE_UNISTD_H */
-
#include "lib.h"
#ifdef _POSIX_VERSION
diff --git a/src/libs/libgroff/maxpathname.cpp
b/src/libs/libgroff/maxpathname.cpp
index 110c53545..7cc736c8f 100644
--- a/src/libs/libgroff/maxpathname.cpp
+++ b/src/libs/libgroff/maxpathname.cpp
@@ -20,15 +20,13 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <config.h>
#endif
-/* path_name_max(dir) does the same as pathconf(dir, _PC_PATH_MAX) */
-
-#include <sys/types.h>
+#include "lib.h"
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif /* HAVE_UNISTD_H */
+// needed for pathconf()
+#include "posix.h"
+#include "nonposix.h"
-#include "lib.h"
+/* path_name_max(dir) does the same as pathconf(dir, _PC_PATH_MAX) */
#ifdef _POSIX_VERSION
diff --git a/src/libs/libgroff/tmpfile.cpp b/src/libs/libgroff/tmpfile.cpp
index 927c7bd66..62118e981 100644
--- a/src/libs/libgroff/tmpfile.cpp
+++ b/src/libs/libgroff/tmpfile.cpp
@@ -21,10 +21,14 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#endif
#include <errno.h>
-#include <stdlib.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h> // unlink()
-#endif
+#include <stdio.h> // FILE, fdopen()
+#include <stdlib.h> // getenv(), mkstemp()
+#include <string.h> // strcat(), strchr(), strcpy(), strerror(),
+ // strlen()
+
+// needed for unlink()
+#include "posix.h"
+#include "nonposix.h"
#include "lib.h"
diff --git a/src/preproc/html/pre-html.cpp b/src/preproc/html/pre-html.cpp
index ad4c5abed..7e7b36d59 100644
--- a/src/preproc/html/pre-html.cpp
+++ b/src/preproc/html/pre-html.cpp
@@ -24,17 +24,23 @@
#endif
#include <assert.h>
-#include <ctype.h>
#include <errno.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <string.h> // strerror(), strsignal()
-#ifdef HAVE_UNISTD_H
-#include <unistd.h> // unlink()
-#endif
+#include <stdarg.h> // va_list, va_end(), va_start(), vsnprintf()
+#include <stdio.h> // EOF, FILE, fclose(), feof(), fflush(), fopen(),
+ // fprintf(), fputc(), fread(), getc(), printf(),
+ // stderr, stdin, stdout, ungetc()
+#include <stdlib.h> // atexit(), atoi(), exit(), free(), getenv(),
+ // malloc(), system()
+#include <string.h> // memcpy(), strchr(), strcmp(), strcpy(),
+ // strerror(), strlen(), strncmp(), strsignal()
#include <getopt.h> // getopt_long()
+// needed for close(), creat(), dup(), dup2(), execvp(), fork(),
+// getpid(), mkdir(), open(), pipe(), unlink(), wait(), write()
+#include "posix.h"
+#include "nonposix.h"
+
#define PREHTMLC
#include "lib.h"
@@ -42,19 +48,12 @@
#include "errarg.h"
#include "error.h"
#include "stringclass.h"
-#include "posix.h"
#include "defs.h"
#include "searchpath.h"
#include "paper.h"
#include "device.h"
#include "font.h"
-#include <errno.h>
-#include <sys/types.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
#ifdef _POSIX_VERSION
# include <sys/wait.h>
# define PID_T pid_t
@@ -62,10 +61,6 @@
# define PID_T int
#endif /* not _POSIX_VERSION */
-#include <stdarg.h>
-
-#include "nonposix.h"
-
#if 0
# define DEBUGGING
#endif
diff --git a/src/preproc/html/pushback.cpp b/src/preproc/html/pushback.cpp
index 8f437bd82..6d2cecb48 100644
--- a/src/preproc/html/pushback.cpp
+++ b/src/preproc/html/pushback.cpp
@@ -20,23 +20,19 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <config.h>
#endif
-#include <signal.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <errno.h>
-
-#include <sys/types.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
+#include <stdio.h> // fflush(), fprintf(), printf(), putchar(), stderr
+#include <stdlib.h> // exit(), free(), malloc()
+#include <string.h> // strcpy(), strlen()
+
+// needed for close(), dup(), open(), read()
+#include "posix.h"
+#include "nonposix.h"
#include "lib.h"
#include "errarg.h"
#include "error.h"
#include "stringclass.h"
-#include "posix.h"
-#include "nonposix.h"
#include "pushback.h"
#include "pre-html.h"
diff --git a/src/roff/groff/groff.cpp b/src/roff/groff/groff.cpp
index 1367dafd2..05c83a281 100644
--- a/src/roff/groff/groff.cpp
+++ b/src/roff/groff/groff.cpp
@@ -26,9 +26,19 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <errno.h>
#include <stdio.h> // EOF, FILE, fflush(), setbuf(), stderr, stdout
#include <stdlib.h> // exit(), EXIT_SUCCESS, free(), getenv(), putenv()
-#include <string.h> // strerror()
+#include <string.h> // strerror(), strsignal()
#include <getopt.h> // getopt_long()
+//
+// TODO: operating system services proper (cf. the standard C/C++
+// runtime and libraries) should be abstracted through posix.h/
+// nonposix.h (if gnulib doesn't handle it for us).
+#include <sys/types.h> // pid_t
+#include <signal.h> // kill()
+
+// needed for close(), dup(), execvp(), _exit(), fork(), pipe(), wait()
+#include "posix.h"
+#include "nonposix.h"
#include "lib.h"
@@ -39,7 +49,6 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include "font.h"
#include "device.h"
#include "pipeline.h"
-#include "nonposix.h"
#include "relocate.h"
#include "defs.h"
diff --git a/src/roff/groff/pipeline.c b/src/roff/groff/pipeline.c
index 9bc071a5b..5b50ac6ba 100644
--- a/src/roff/groff/pipeline.c
+++ b/src/roff/groff/pipeline.c
@@ -21,17 +21,16 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#endif
#include <errno.h>
-#include <fcntl.h> // open()
-#include <signal.h> // kill(), SIGINT, signal()
#include <stdbool.h>
#include <stdio.h> // sprintf()
#include <string.h> // strerror(), strsignal()
-#include <sys/types.h> // kill(), open(), wait()
-#include <sys/stat.h> // open()
-#ifdef HAVE_UNISTD_H
-#include <unistd.h> // dup(), pipe(), STDIN_FILENO, STDOUT_FILENO,
- // unlink()
-#endif
+
+#include <signal.h> // kill(), SIGINT, signal()
+
+// needed for dup(), open(), pipe(), STDIN_FILENO, STDOUT_FILENO,
+// unlink()
+#include "posix.h"
+#include "nonposix.h"
#ifdef _POSIX_VERSION
@@ -97,13 +96,6 @@ static void sys_fatal(const char *);
|| (defined(_WIN32) && !defined(_UWIN) && !defined(__CYGWIN__)) \
|| defined(__EMX__)
-#include <process.h>
-#include <fcntl.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "nonposix.h"
-
static const char *sh = "sh";
static const char *cmd = "cmd";
static const char *command = "command";
diff --git a/src/utils/indxbib/indxbib.cpp b/src/utils/indxbib/indxbib.cpp
index bf9c515c3..f958ae3bd 100644
--- a/src/utils/indxbib/indxbib.cpp
+++ b/src/utils/indxbib/indxbib.cpp
@@ -28,18 +28,15 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
// stderr, stdin, stdout, ungetc()
#include <string.h> // strcat(), strchr(), strcmp(), strcpy(),
// strerror(), strlen(), strrchr()
-#ifdef HAVE_UNISTD_H
-#include <unistd.h> // unlink()
-#endif
#include <getopt.h> // getopt_long()
-#include "lib.h"
-
-// needed for getcwd()
+// needed for getcwd(), unlink()
#include "posix.h"
#include "nonposix.h"
+#include "lib.h"
+
#include "errarg.h"
#include "error.h"
#include "stringclass.h"
diff --git a/src/utils/indxbib/signal.c b/src/utils/indxbib/signal.c
index c1bf8631a..51ec79f63 100644
--- a/src/utils/indxbib/signal.c
+++ b/src/utils/indxbib/signal.c
@@ -18,17 +18,23 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
/* Unfortunately vendors seem to have problems writing a <signal.h>
that is correct for C++, so we implement all signal handling in C. */
-// TODO: Revisit that 1993 claim in 2023. Use gnulib?
+
+// TODO: Revisit the above 1993 claim in 2023. Use gnulib?
+//
+// TODO: Also, operating system services proper (cf. the standard C/C++
+// runtime and libraries) should be abstracted through posix.h/
+// nonposix.h (if gnulib doesn't handle it for us).
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include <stdlib.h>
-#include <sys/types.h>
-#include <signal.h>
+#include <stdlib.h> // exit()
+
+#include <sys/types.h> // pid_t
+#include <signal.h> // kill(), SIG_DFL, SIG_IGN, signal()
#ifdef HAVE_UNISTD_H
-#include <unistd.h>
+#include <unistd.h> // getpid()
#endif
#ifdef __cplusplus
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 18/24: Rationalize and annotate header file inclusions.,
G. Branden Robinson <=