gbranden pushed a commit to branch master
in repository groff.
commit 9b1161e6bf63532e9f92baf9e4615b59c0943028
Author: G. Branden Robinson <[email protected]>
AuthorDate: Tue Aug 13 05:16:16 2024 -0500
[troff]: Do less unconditional #including.
* src/roff/troff/troff.h: Drop standard C library header file inclusions
altogether. This exhibited an old style of writing C (and C++?) where
your multi-translation unit program would have an overarching header
file, included by all your *.c files, and into which you stuffed all
of your libc header file dependencies without documenting which
symbols you actually needed or where. This tended to lead to
excessive inclusion, and that tendency bore out here. On a
glibc-based system, GNU troff doesn't need 4 of the 6 headers formerly
#included here at all. And we now use gnulib to help us with
portability, which was not the case in 1989.
* src/roff/troff/env.cpp:
* src/roff/troff/input.cpp:
* src/roff/troff/node.cpp: Include <errno.h> and annotate why.
* src/roff/troff/reg.cpp: Include <assert.h> and annotate why.
---
ChangeLog | 22 ++++++++++++++++++++++
src/roff/troff/env.cpp | 1 +
src/roff/troff/input.cpp | 6 ++++++
src/roff/troff/node.cpp | 6 ++++++
src/roff/troff/reg.cpp | 6 ++++++
src/roff/troff/troff.h | 11 -----------
6 files changed, 41 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index bb972c30b..bb8b6999e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2024-08-13 G. Branden Robinson <[email protected]>
+
+ [troff]: Replace club with scalpel when including standard C
+ library header files.
+
+ * src/roff/troff/troff.h: Drop standard C library header file
+ inclusions altogether. This exhibited an old style of writing C
+ {and C++?} where your multi-translation unit program would have
+ an overarching header file, included by all your *.c files, and
+ into which you stuffed all of your libc header file dependencies
+ without documenting which symbols you actually needed or where.
+ This tended to lead to excessive inclusion, and that tendency
+ bore out here. On a glibc-based system, GNU troff doesn't need
+ 4 of the 6 headers formerly #included here at all. And we now
+ use gnulib to help us with portability, which was not the case
+ in 1989.
+
+ * src/roff/troff/env.cpp:
+ * src/roff/troff/input.cpp:
+ * src/roff/troff/node.cpp: Include <errno.h> and annotate why.
+ * src/roff/troff/reg.cpp: Include <assert.h> and annotate why.
+
2024-08-13 G. Branden Robinson <[email protected]>
* src/roff/troff/input.cpp (do_string_case_transform): Use
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index d3aae3a5a..3d2f01eb0 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -36,6 +36,7 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <config.h>
#endif
+#include <errno.h> // errno
#include <math.h> // ceil()
symbol default_family("T");
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 6044f8c85..42244b07e 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -37,6 +37,12 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <stack>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <errno.h> // errno
+
// Needed for getpid() and isatty()
#include "posix.h"
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index 81c032c43..211cfade7 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -18,6 +18,12 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include "troff.h"
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <errno.h> // errno
+
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
diff --git a/src/roff/troff/reg.cpp b/src/roff/troff/reg.cpp
index fe4a9e9d1..89063d490 100644
--- a/src/roff/troff/reg.cpp
+++ b/src/roff/troff/reg.cpp
@@ -22,6 +22,12 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include "request.h"
#include "reg.h"
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <assert.h> // assert()
+
object_dictionary register_dictionary(101);
bool reg::get_value(units * /*d*/)
diff --git a/src/roff/troff/troff.h b/src/roff/troff/troff.h
index 66e9148ea..337adf4b7 100644
--- a/src/roff/troff/troff.h
+++ b/src/roff/troff/troff.h
@@ -18,17 +18,6 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include "lib.h"
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <assert.h>
-#include <ctype.h>
-#include <errno.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <time.h>
-
#include "color.h"
#include "device.h"
#include "searchpath.h"
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit