gbranden pushed a commit to branch master
in repository groff.

commit dbfd833a6b5facb50a623ca6a7fc3757f15f65a1
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Mar 27 18:47:58 2026 -0500

    Rationalize header file inclusions.
    
    To illuminate inter-module dependencies, get header files out of the
    business of `#include`-ing other header files, in favor of putting
    preprocessor inclusions only in translation units (C/C++ source files).
    Annotate dependencies.
    
    * src/devices/grodvi/dvi.cpp:
    * src/devices/grodvi/dvi.cpp:
    * src/devices/grohtml/html-table.cpp:
    * src/devices/grohtml/html-text.cpp:
    * src/devices/grohtml/html-text.h:
    * src/devices/grohtml/post-html.cpp:
    * src/devices/grolbp/lbp.cpp:
    * src/devices/grolj4/lj4.cpp:
    * src/devices/grops/ps.cpp:
    * src/devices/grotty/tty.cpp:
    * src/include/color.h:
    * src/include/driver.h:
    * src/include/printer.h:
    * src/libs/libdriver/input.cpp:
    * src/libs/libdriver/printer.cpp:
    * src/libs/libgroff/color.cpp:
    * src/roff/troff/dictionary.cpp:
    * src/roff/troff/div.cpp:
    * src/roff/troff/env.cpp:
    * src/roff/troff/input.cpp:
    * src/roff/troff/mtsm.cpp:
    * src/roff/troff/mtsm.h:
    * src/roff/troff/node.cpp:
    * src/roff/troff/number.cpp:
    * src/roff/troff/reg.cpp:
    * src/roff/troff/troff.h: Do it.
---
 ChangeLog                          | 35 ++++++++++++++++++++++
 src/devices/grodvi/dvi.cpp         | 13 ++++++--
 src/devices/grohtml/html-table.cpp |  5 +++-
 src/devices/grohtml/html-text.cpp  | 17 +++++++----
 src/devices/grohtml/html-text.h    |  3 --
 src/devices/grohtml/post-html.cpp  | 11 +++++--
 src/devices/grolbp/lbp.cpp         | 10 ++++++-
 src/devices/grolj4/lj4.cpp         | 12 ++++++--
 src/devices/grops/ps.cpp           | 18 +++++++----
 src/devices/grotty/tty.cpp         | 10 +++++--
 src/include/color.h                |  2 --
 src/include/driver.h               |  1 -
 src/include/printer.h              |  2 --
 src/libs/libdriver/input.cpp       |  8 ++++-
 src/libs/libdriver/printer.cpp     |  6 ++++
 src/libs/libgroff/color.cpp        |  8 ++---
 src/roff/troff/dictionary.cpp      |  5 +++-
 src/roff/troff/div.cpp             | 37 +++++++++++++++--------
 src/roff/troff/env.cpp             | 38 ++++++++++++++++--------
 src/roff/troff/input.cpp           | 61 +++++++++++++++++++++++++-------------
 src/roff/troff/mtsm.cpp            | 27 +++++++++++++----
 src/roff/troff/mtsm.h              |  6 ----
 src/roff/troff/node.cpp            | 47 ++++++++++++++++++-----------
 src/roff/troff/number.cpp          | 28 +++++++++++++----
 src/roff/troff/reg.cpp             | 16 ++++++++--
 src/roff/troff/troff.h             | 11 -------
 26 files changed, 306 insertions(+), 131 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8c4a7c7a9..6cec018cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,38 @@
+2026-03-27  G. Branden Robinson <[email protected]>
+
+       Rationalize header file inclusions.  To illuminate inter-module
+       dependencies, get header files out of the business of
+       `#include`-ing other header files, in favor of putting
+       preprocessor inclusions only in translation units (C/C++ source
+       files).  Annotate dependencies.
+
+       * src/devices/grodvi/dvi.cpp:
+       * src/devices/grodvi/dvi.cpp:
+       * src/devices/grohtml/html-table.cpp:
+       * src/devices/grohtml/html-text.cpp:
+       * src/devices/grohtml/html-text.h:
+       * src/devices/grohtml/post-html.cpp:
+       * src/devices/grolbp/lbp.cpp:
+       * src/devices/grolj4/lj4.cpp:
+       * src/devices/grops/ps.cpp:
+       * src/devices/grotty/tty.cpp:
+       * src/include/color.h:
+       * src/include/driver.h:
+       * src/include/printer.h:
+       * src/libs/libdriver/input.cpp:
+       * src/libs/libdriver/printer.cpp:
+       * src/libs/libgroff/color.cpp:
+       * src/roff/troff/dictionary.cpp:
+       * src/roff/troff/div.cpp:
+       * src/roff/troff/env.cpp:
+       * src/roff/troff/input.cpp:
+       * src/roff/troff/mtsm.cpp:
+       * src/roff/troff/mtsm.h:
+       * src/roff/troff/node.cpp:
+       * src/roff/troff/number.cpp:
+       * src/roff/troff/reg.cpp:
+       * src/roff/troff/troff.h: Do it.
+
 2026-03-26  G. Branden Robinson <[email protected]>
 
        * src/devices/grohtml/html-table.cpp: Arrange inclusions of
diff --git a/src/devices/grodvi/dvi.cpp b/src/devices/grodvi/dvi.cpp
index b9951e2ca..a5c6ee2bd 100644
--- a/src/devices/grodvi/dvi.cpp
+++ b/src/devices/grodvi/dvi.cpp
@@ -30,12 +30,21 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 #include <stdlib.h> // exit(), EXIT_SUCCESS, strtol()
 #include <string.h> // strcmp(), strlen()
 
+// GNU extensions to C standard library
 #include <getopt.h> // getopt_long()
 
-#include "driver.h"
-#include "geometry.h" // adjust_arc_center()
+// operating system services
 #include "nonposix.h"
 
+// libgroff
+#include "symbol.h" // prerequisite of color.h
+#include "color.h" // prerequisite of printer.h
+#include "geometry.h" // adjust_arc_center()
+
+// libdriver
+#include "driver.h" // do_file()
+#include "printer.h" // environment, printer
+
 extern "C" const char *Version_string;
 
 #define DEFAULT_LINEWIDTH 40
diff --git a/src/devices/grohtml/html-table.cpp 
b/src/devices/grohtml/html-table.cpp
index e8ae59bec..917535f9d 100644
--- a/src/devices/grohtml/html-table.cpp
+++ b/src/devices/grohtml/html-table.cpp
@@ -30,10 +30,13 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 
 #include <stdlib.h> // atoi()
 
-#include "driver.h"
+// libgroff
+#include "symbol.h" // prerequisite of color.h
+#include "color.h"
 #include "cset.h" // csspace()
 #include "stringclass.h"
 
+// grohtml
 #include "html.h"
 #include "html-table.h"
 #include "html-text.h"
diff --git a/src/devices/grohtml/html-text.cpp 
b/src/devices/grohtml/html-text.cpp
index 352eb5548..2ea25c362 100644
--- a/src/devices/grohtml/html-text.cpp
+++ b/src/devices/grohtml/html-text.cpp
@@ -28,9 +28,19 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 #include <config.h>
 #endif
 
-#include "driver.h"
-#include "stringclass.h"
+#include <stddef.h> // size_t: prerequisite of color.h
+
+// libgroff
+#include "symbol.h" // prerequisite of color.h
+#include "color.h" // prerequisite of html-text.h
 #include "cset.h"
+#include "errarg.h" // prerequisite of error.h
+#include "error.h"
+#include "stringclass.h"
+
+// grohtml
+#include "html-table.h" // prerequisite of html-text.h
+#include "html-text.h"
 
 #if !defined(TRUE)
 #   define TRUE  (1==1)
@@ -39,9 +49,6 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 #   define FALSE (1==0)
 #endif
 
-
-#include "html-text.h"
-
 html_text::html_text (simple_output *op, html_dialect d) :
   stackptr(NULL), lastptr(NULL), out(op), dialect(d),
   space_emitted(TRUE), current_indentation(-1),
diff --git a/src/devices/grohtml/html-text.h b/src/devices/grohtml/html-text.h
index 2e13477a9..f362c30c1 100644
--- a/src/devices/grohtml/html-text.h
+++ b/src/devices/grohtml/html-text.h
@@ -23,9 +23,6 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
-#include "html.h"
-#include "html-table.h"
-
 #define STYLE_VERTICAL_SPACE "1em"
 
 /*
diff --git a/src/devices/grohtml/post-html.cpp 
b/src/devices/grohtml/post-html.cpp
index a8a2a7e8f..d1496df37 100644
--- a/src/devices/grohtml/post-html.cpp
+++ b/src/devices/grohtml/post-html.cpp
@@ -36,16 +36,23 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 
 #include <getopt.h> // getopt_long()
 
+// libgroff
+#include "symbol.h" // prerequisite of color.h
+#include "color.h"
 #include "cset.h" // csspace()
 #include "curtime.h"
-#include "driver.h"
 #include "lib.h" // strsave(), xtmpfile()
 #include "stringclass.h"
 #include "unicode.h"
 
+// libdriver
+#include "driver.h" // do_file()
+#include "printer.h" // environment, printer
+
+// grohtml
 #include "html.h"
-#include "html-text.h"
 #include "html-table.h"
+#include "html-text.h"
 
 extern "C" const char *Version_string;
 
diff --git a/src/devices/grolbp/lbp.cpp b/src/devices/grolbp/lbp.cpp
index a197cf4dd..0efd21095 100644
--- a/src/devices/grolbp/lbp.cpp
+++ b/src/devices/grolbp/lbp.cpp
@@ -38,13 +38,21 @@ TODO
 #include <string.h> // strcmp(), strcpy(), strlen(), strncpy()
 #include <strings.h> // strcasecmp()
 
+// GNU extensions to C standard library
 #include <getopt.h> // getopt_long()
 
+// operating system services
 #include "nonposix.h"
 
-#include "driver.h"
+// libgroff
+#include "symbol.h" // prerequisite of color.h
+#include "color.h" // prerequisite of printer.h
 #include "lib.h" // strsave()
 
+// libdriver
+#include "driver.h" // do_file()
+#include "printer.h" // environment, printer
+
 // grolbp
 #include "charset.h"
 #include "lbp.h"
diff --git a/src/devices/grolj4/lj4.cpp b/src/devices/grolj4/lj4.cpp
index 36e1c7c16..7cf8b4b2a 100644
--- a/src/devices/grolj4/lj4.cpp
+++ b/src/devices/grolj4/lj4.cpp
@@ -46,14 +46,22 @@ X command to include bitmap graphics
 #include <string.h> // strcmp()
 #include <strings.h> // strcasecmp()
 
+// GNU extensions to C standard library
 #include <getopt.h> // getopt_long()
 
+// operating system services
 #include "nonposix.h"
 
+// libgroff
+#include "symbol.h" // prerequisite of color.h
+#include "color.h" // prerequisite of printer.h
 #include "cset.h" // csdigit()
-#include "driver.h"
 #include "geometry.h" // adjust_arc_center()
-#include "lib.h" // array_size(), PI
+#include "lib.h" // PI
+
+// libdriver
+#include "driver.h" // do_file()
+#include "printer.h" // environment, printer
 
 extern "C" const char *Version_string;
 
diff --git a/src/devices/grops/ps.cpp b/src/devices/grops/ps.cpp
index 98f5c3834..2308a996a 100644
--- a/src/devices/grops/ps.cpp
+++ b/src/devices/grops/ps.cpp
@@ -41,20 +41,28 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
                    // strlen(), strncmp(), strstr(), strtok()
 #include <time.h> // asctime()
 
+// GNU extensions to C standard library
 #include <getopt.h> // getopt_long()
 
+// operating system services
 // needed for SET_BINARY()
 #include "posix.h"
 #include "nonposix.h"
 
-#include "lib.h" // PI
-
-#include "cset.h"
-#include "curtime.h"
-#include "driver.h"
+// libgroff
+#include "symbol.h" // prerequisite of color.h
+#include "color.h"
+#include "cset.h" // csalpha(), csprint(), csspace()
+#include "curtime.h" // current_time()
 #include "geometry.h" // adjust_arc_center()
+#include "lib.h" // PI
 #include "stringclass.h"
 
+// libdriver
+#include "driver.h" // do_file()
+#include "printer.h" // environment, printer
+
+// grops
 #include "ps.h"
 
 extern "C" const char *Version_string;
diff --git a/src/devices/grotty/tty.cpp b/src/devices/grotty/tty.cpp
index c73957e5f..89a2a217b 100644
--- a/src/devices/grotty/tty.cpp
+++ b/src/devices/grotty/tty.cpp
@@ -29,12 +29,18 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
                   // putchar(), setbuf(), stderr, stdout
 #include <stdlib.h> // exit(), EXIT_SUCCESS, getenv(), strtol()
 
+// GNU extensions to C standard library
 #include <getopt.h> // getopt_long()
 
-#include "device.h"
-#include "driver.h"
+// libgroff
+#include "symbol.h" // prerequisite of color.h
+#include "color.h" // prerequisite of printer.h
 #include "ptable.h"
 
+// libdriver
+#include "driver.h"
+#include "printer.h" // environment, printer
+
 typedef signed char schar;
 
 declare_ptable(schar)
diff --git a/src/include/color.h b/src/include/color.h
index 44f73e18e..a1037640e 100644
--- a/src/include/color.h
+++ b/src/include/color.h
@@ -16,8 +16,6 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
-#include "symbol.h"
-
 enum color_scheme {DEFAULT, CMY, CMYK, RGB, GRAY};
 
 class color {
diff --git a/src/include/driver.h b/src/include/driver.h
index 29ac66ca0..26e48d593 100644
--- a/src/include/driver.h
+++ b/src/include/driver.h
@@ -19,7 +19,6 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 #include "errarg.h"
 #include "error.h"
 #include "font.h"
-#include "printer.h"
 
 void do_file(const char *);
 
diff --git a/src/include/printer.h b/src/include/printer.h
index 2d9b473b5..6b73c8e88 100644
--- a/src/include/printer.h
+++ b/src/include/printer.h
@@ -26,8 +26,6 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
    'input.cpp'.
 */
 
-#include "color.h"
-
 struct environment {
   int fontno;
   int size;
diff --git a/src/libs/libdriver/input.cpp b/src/libs/libdriver/input.cpp
index 9df863ee5..dd1c493a7 100644
--- a/src/libs/libdriver/input.cpp
+++ b/src/libs/libdriver/input.cpp
@@ -243,9 +243,15 @@
 #include <stdlib.h> // strtol()
 #include <string.h> // strcmp(), strlen(), strncmp(), strncpy()
 
-#include "driver.h"
+// libgroff
+#include "symbol.h" // prerequisite of color.h
+#include "color.h"
 #include "device.h"
 
+// libdriver
+#include "driver.h" // do_file()
+#include "printer.h" // environment, printer
+
 
 /**********************************************************************
                            local types
diff --git a/src/libs/libdriver/printer.cpp b/src/libs/libdriver/printer.cpp
index 40fa8dc6e..0a3b40cf2 100644
--- a/src/libs/libdriver/printer.cpp
+++ b/src/libs/libdriver/printer.cpp
@@ -26,7 +26,13 @@
 #include <stdio.h> // clearerr(), ferror(), fflush(), stdout
 #include <string.h> // strcmp()
 
+// libgroff
+#include "symbol.h" // prerequisite of color.h
+#include "color.h" // prerequisite of printer.h
+
+// libdriver
 #include "driver.h"
+#include "printer.h" // environment, font_pointer_list, printer
 
 /* If we are sending output to an onscreen pager (as is the normal case
    when reading man pages), then we may get an error state on the output
diff --git a/src/libs/libgroff/color.cpp b/src/libs/libgroff/color.cpp
index d34090e4a..159f38b85 100644
--- a/src/libs/libgroff/color.cpp
+++ b/src/libs/libgroff/color.cpp
@@ -23,12 +23,10 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 #include <assert.h>
 #include <stdio.h> // sprintf()
 
-#include "lib.h"
-
+// libgroff
+#include "symbol.h" // prerequisite of color.h
 #include "color.h"
-#include "cset.h"
-#include "errarg.h"
-#include "error.h"
+#include "cset.h" // csdigit(), csupper(), csxdigit()
 
 static inline unsigned int
 min(const unsigned int a, const unsigned int b)
diff --git a/src/roff/troff/dictionary.cpp b/src/roff/troff/dictionary.cpp
index e63f0eb73..4aebc1f92 100644
--- a/src/roff/troff/dictionary.cpp
+++ b/src/roff/troff/dictionary.cpp
@@ -21,7 +21,10 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 #include <config.h>
 #endif
 
-#include "troff.h"
+#include <stdio.h> // prerequisite of searchpath.h
+
+// libgroff
+#include "symbol.h" // prerequisite of dictionary.h
 #include "dictionary.h"
 
 // is 'p' a good size for a hash table
diff --git a/src/roff/troff/div.cpp b/src/roff/troff/div.cpp
index c8d09d0c0..20874474d 100644
--- a/src/roff/troff/div.cpp
+++ b/src/roff/troff/div.cpp
@@ -24,23 +24,36 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 #include <config.h>
 #endif
 
+#include <stdio.h> // prerequisite of searchpath.h
 #include <stdlib.h> // exit(), EXIT_SUCCESS
 
-#include "troff.h"
-#include "dictionary.h"
-#include "hvunits.h"
-#include "stringclass.h"
-#include "mtsm.h"
-#include "env.h"
-#include "request.h"
-#include "node.h"
-#include "token.h"
-#include "div.h"
-#include "reg.h"
-#include "input.h" // was_invoked_with_regular_control_character
+#include <stack> // prerequisite of mtsm.h
 
+// operating system services
 #include "nonposix.h"
 
+// libgroff
+#include "errarg.h" // prerequisite of troff.h
+#include "error.h" // prerequisite of troff.h
+#include "searchpath.h" // prerequisite of troff.h
+#include "symbol.h" // prerequisite of dictionary.h and color.h
+#include "color.h" // prerequisite of env.h
+#include "lib.h" // i_to_a()
+#include "stringclass.h" // prerequisite of mtsm.h
+
+// troff
+#include "troff.h" // prerequisite of hvunits.h, token.h; units
+#include "dictionary.h" // object
+#include "hvunits.h" // prerequisite of div.h; hunits, vunits
+#include "token.h" // prerequisite of div.h
+#include "mtsm.h" // prerequisite of div.h; statem
+#include "div.h" // diversion
+#include "env.h" // environment, font_size
+#include "input.h" // was_invoked_with_regular_control_character
+#include "request.h" // prerequisite of node.h; macro
+#include "node.h"
+#include "reg.h"
+
 bool is_exit_underway = false;
 bool is_eoi_macro_finished = false;
 bool seen_last_page_ejector = false;
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 173b6f0ba..ba62a7718 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -24,25 +24,37 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 
 #include <errno.h> // errno
 #include <math.h> // ceil(), fabs()
+#include <stdio.h> // prerequisite of mtsm.h, searchpath.h
 
+#include <stack> // prerequisite of mtsm.h
 #include <vector>
 #include <algorithm> // find()
 
-#include "troff.h"
-#include "dictionary.h"
-#include "hvunits.h"
-#include "stringclass.h"
-#include "mtsm.h"
-#include "env.h"
-#include "request.h"
+#include "symbol.h" // prerequisite of dictionary.h and color.h
+#include "color.h" // prerequisite of env.h
+#include "cset.h" // csdigit(), csspace()
+#include "errarg.h" // prerequisite of troff.h
+#include "error.h" // prerequisite of troff.h
+#include "lib.h" // UINT_DIGITS, i_to_a(), if_to_a(),
+                // is_invalid_input_char()
+#include "searchpath.h" // prerequisite of troff.h
+
+// troff
+#include "troff.h" // prerequisite of hvunits.h, token.h; units
+#include "font.h" // prerequisite of charinfo.h
+#include "token.h" // prerequisite of charinfo.h
+#include "charinfo.h"
+#include "dictionary.h" // object
+#include "hvunits.h" // prerequisite of div.h; hunits, vunits
+#include "stringclass.h" // prerequisite of mtsm.h
+#include "mtsm.h" // prerequisite of div.h; statem
+#include "div.h" // curdiv
+#include "env.h" // environment, font_size
+#include "input.h" // do_fill_color(), do_stroke_color(), suppress_push,
+                  // was_invoked_with_regular_control_character
+#include "request.h" // prerequisite of node.h; macro
 #include "node.h"
-#include "token.h"
-#include "div.h"
 #include "reg.h"
-#include "font.h"
-#include "charinfo.h"
-#include "macropath.h"
-#include "input.h"
 
 symbol default_family("T");
 
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 91196b946..5b43be739 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -26,7 +26,8 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 #include <errno.h> // ENOENT, errno
 #include <locale.h> // setlocale()
 #include <stdcountof.h>
-#include <stdio.h> // EOF, FILE, clearerr(), fclose(), fflush(),
+#include <stdio.h> // prerequisite of searchpath.h
+                  // EOF, FILE, clearerr(), fclose(), fflush(),
                   // fileno(), fopen(), fprintf(), fseek(), getc(),
                   // pclose(), popen(), printf(), SEEK_SET, snprintf(),
                   // sprintf(), setbuf(), stderr, stdin, stdout,
@@ -35,34 +36,52 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
                    // free(), getenv(), setenv(), strtol(), system()
 #include <string.h> // strcpy(), strdup(), strerror()
 
+// GNU extensions to C standard library
 #include <getopt.h> // getopt_long()
 
 #include <stack>
 
-#include "json-encode.h" // json_encode_char()
+// operating system services
+// needed for getpid() and isatty()
+#include "posix.h"
+#include "nonposix.h"
 
-#include "troff.h"
-#include "dictionary.h"
-#include "hvunits.h"
-#include "stringclass.h"
-#include "mtsm.h"
-#include "env.h"
-#include "request.h"
-#include "node.h"
-#include "token.h"
-#include "div.h"
-#include "reg.h"
-#include "font.h"
-#include "charinfo.h"
-#include "macropath.h"
-#include "input.h"
+// build configuration
 #include "defs.h"
+
+// libgroff
+#include "errarg.h" // prerequisite of troff.h
+#include "error.h" // prerequisite of troff.h
+#include "searchpath.h" // prerequisite of troff.h
+#include "symbol.h" // prerequisite of dictionary.h and color.h
+#include "color.h" // prerequisite of env.h
+#include "cmap.h" // cmlower(), cmupper()
+#include "cset.h" // cset, csalpha(), csdigit(), csgraph(), cslower(),
+                 // csprint(), cspunct(), csupper()
+#include "device.h"
+#include "font.h" // prerequisite of charinfo.h
+#include "json-encode.h" // json_encode_char()
+#include "lib.h" // i_to_a(), is_invalid_input_char(), ui_to_a()
+#include "stringclass.h" // prerequisite of mtsm.h
 #include "unicode.h"
-#include "curtime.h"
 
-// needed for getpid() and isatty()
-#include "posix.h"
-#include "nonposix.h"
+// troff
+#include "troff.h" // prerequisite of hvunits.h, token.h; units
+#include "token.h" // prerequisite of charinfo.h; tok
+#include "charinfo.h"
+#include "curtime.h" // current_time()
+#include "dictionary.h" // object
+#include "hvunits.h" // prerequisite of div.h; hunits, vunits
+#include "mtsm.h" // prerequisite of div.h; statem
+#include "div.h" // curdiv
+#include "env.h" // environment, font_size
+#include "input.h" // do_fill_color(), do_stroke_color(), suppress_push,
+                  // was_invoked_with_regular_control_character
+#include "macropath.h" // config_macro_path, macro_path,
+                      // safer_macro_path
+#include "request.h" // prerequisite of node.h; macro
+#include "node.h"
+#include "reg.h"
 
 #define MACRO_PREFIX "tmac."
 #define MACRO_POSTFIX ".tmac"
diff --git a/src/roff/troff/mtsm.cpp b/src/roff/troff/mtsm.cpp
index d3b0d30af..9492941c4 100644
--- a/src/roff/troff/mtsm.cpp
+++ b/src/roff/troff/mtsm.cpp
@@ -23,18 +23,33 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 #include <config.h>
 #endif
 
-extern bool want_html_debugging;
-
-#include "troff.h"
-#include "hvunits.h"
-#include "stringclass.h"
-#include "mtsm.h"
+#include <stdio.h> // prerequisite of mtsm.h, searchpath.h
+
+#include <stack> // prerequisite of mtsm.h
+
+// libgroff
+#include "errarg.h" // prerequisite of troff.h
+#include "error.h" // prerequisite of troff.h
+#include "searchpath.h" // prerequisite of troff.h
+#include "symbol.h" // prerequisite of color.h
+#include "color.h" // prerequisite of env.h
+#include "cset.h" // cset, csalpha(), csdigit(), csgraph(), cslower(),
+                 // csprint(), cspunct(), csupper()
+#include "lib.h" // i_to_a()
+#include "stringclass.h" // prerequisite of mtsm.h
+
+// troff
+#include "troff.h" // prerequisite of env.h, hvunits.h; units
+#include "hvunits.h" // prerequisite of env.h, hunits
 #include "env.h"
+#include "mtsm.h"
 
 #if defined(DEBUGGING)
 static int no_of_statems = 0;
 #endif
 
+extern bool want_html_debugging;
+
 int_value::int_value()
 : value(0), is_known(0)
 {
diff --git a/src/roff/troff/mtsm.h b/src/roff/troff/mtsm.h
index 6d522ada2..91ea383f5 100644
--- a/src/roff/troff/mtsm.h
+++ b/src/roff/troff/mtsm.h
@@ -24,12 +24,6 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
-#include <stdio.h> // FILE
-
-#include <stack>
-
-#include "stringclass.h" // string
-
 // groff doesn't yet use include guards, so until it does, any source
 // file needing symbols from this one must #include "hvunits.h" first.
 //
diff --git a/src/roff/troff/node.cpp b/src/roff/troff/node.cpp
index b7137da31..0d024af92 100644
--- a/src/roff/troff/node.cpp
+++ b/src/roff/troff/node.cpp
@@ -23,26 +23,13 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 #endif
 
 #include <errno.h>
+#include <stdio.h> // prerequisite of searchpath.h
 #include <stdlib.h> // free(), malloc()
 #include <string.h> // strerror()
 
-#include "troff.h"
-#include "dictionary.h"
-#include "hvunits.h"
-#include "stringclass.h"
-#include "mtsm.h"
-#include "env.h"
-#include "request.h"
-#include "node.h"
-#include "token.h"
-#include "div.h"
-#include "reg.h"
-#include "font.h"
-#include "charinfo.h"
-#include "input.h"
-#include "geometry.h" // adjust_arc_center()
-#include "json-encode.h" // json_encode_char()
+#include <stack>
 
+// operating system services
 #include "posix.h"
 #include "nonposix.h"
 
@@ -63,7 +50,32 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 
 #endif /* not _POSIX_VERSION */
 
-#include <stack>
+// libgroff
+#include "errarg.h" // prerequisite of troff.h
+#include "error.h" // prerequisite of troff.h
+#include "searchpath.h" // prerequisite of troff.h
+#include "symbol.h" // prerequisite of dictionary.h and color.h
+#include "color.h" // prerequisite of env.h
+#include "cset.h" // csdigit(), csgraph()
+#include "device.h"
+#include "font.h" // prerequisite of charinfo.h
+#include "lib.h" // i_to_a(), ui_to_a()
+#include "geometry.h" // adjust_arc_center()
+#include "json-encode.h" // json_encode_char()
+#include "stringclass.h"
+
+// troff
+#include "troff.h" // prerequisite of env.h, hvunits.h; units
+#include "token.h" // prerequisite of charinfo.h
+#include "charinfo.h"
+#include "dictionary.h"
+#include "hvunits.h" // prerequisite of env.h; hunits, vunits
+#include "mtsm.h" // prerequisite of div.h; statem
+#include "div.h" // topdiv
+#include "env.h" // environment, font_size
+#include "request.h" // prerequisite of node.h; macro
+#include "node.h"
+#include "reg.h"
 
 static bool is_output_suppressed = false;
 
@@ -72,7 +84,6 @@ class tfont;
 class tfont_spec;
 tfont *make_tfont(tfont_spec &);
 
-
 /*
  *  how many boundaries of images have been written? Useful for
  *  debugging grohtml
diff --git a/src/roff/troff/number.cpp b/src/roff/troff/number.cpp
index d36151ba9..688da0bf8 100644
--- a/src/roff/troff/number.cpp
+++ b/src/roff/troff/number.cpp
@@ -23,13 +23,29 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 #endif
 
 #include <stdckdint.h>
-
-#include "troff.h" // units
-#include "hvunits.h" // hunits, vunits
-#include "mtsm.h" // state_set
-#include "env.h" // curenv
-#include "token.h" // tok
+#include <stdio.h> // prerequisite of mtsm.h, searchpath.h
+
+#include <stack> // prerequisite of mtsm.h
+
+// libgroff
+#include "errarg.h" // prerequisite of troff.h
+#include "error.h" // prerequisite of troff.h
+#include "searchpath.h" // prerequisite of troff.h
+#include "symbol.h" // prerequisite of color.h
+#include "color.h" // prerequisite of env.h
+#include "cset.h" // csdigit()
+#include "stringclass.h" // prerequisite of mtsm.h
+
+// troff
+#include "troff.h" // prerequisite of hvunits.h, token.h; units
+#include "hvunits.h" // prerequisite of div.h; hunits, vunits
+#include "dictionary.h" // prerequisite of request.h
+#include "env.h" // prerequisite of node.h; curenv
+#include "mtsm.h" // prerequisite of node.h
+#include "request.h" // prerequisite of node.h
+#include "node.h" // prerequisite of div.h
 #include "div.h" // curdiv
+#include "token.h" // tok
 
 const vunits V0; // zero in vertical units
 const hunits H0; // zero in horizontal units
diff --git a/src/roff/troff/reg.cpp b/src/roff/troff/reg.cpp
index 363f4c616..6dbcbc588 100644
--- a/src/roff/troff/reg.cpp
+++ b/src/roff/troff/reg.cpp
@@ -23,13 +23,23 @@ along with this program.  If not, see 
<http://www.gnu.org/licenses/>. */
 #endif
 
 #include <assert.h>
+#include <stdio.h> // prerequisite of searchpath.h
+
+// libgroff
+#include "errarg.h" // prerequisite of troff.h
+#include "error.h" // prerequisite of troff.h
+#include "searchpath.h" // prerequisite of troff.h
+#include "symbol.h" // prerequisite of color.h
+#include "color.h" // prerequisite of env.h
+#include "cset.h" // csdigit()
+#include "lib.h" // INT_DIGITS
 
-#include "troff.h"
+// troff
 #include "dictionary.h"
-#include "lib.h" // INT_DIGITS
-#include "token.h"
 #include "request.h"
+#include "troff.h" // prerequisite of reg.h, token.h; units
 #include "reg.h"
+#include "token.h"
 
 object_dictionary register_dictionary(101);
 
diff --git a/src/roff/troff/troff.h b/src/roff/troff/troff.h
index e15f247e1..b91e63fd9 100644
--- a/src/roff/troff/troff.h
+++ b/src/roff/troff/troff.h
@@ -17,12 +17,6 @@ for more details.
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
-#include "lib.h"
-
-#include "color.h"
-#include "device.h"
-#include "searchpath.h"
-
 typedef int units;
 
 extern units scale(units n, units x, units y); // scale n by x/y
@@ -43,11 +37,6 @@ extern int sizescale;
 
 extern search_path *mac_path;
 
-#include "cset.h"
-#include "cmap.h"
-#include "errarg.h"
-#include "error.h"
-
 enum warning_category {
   // This first item is so that diagnostic functions in "input.cpp" can
   // have a consistent parameter list.  It feels a little clunky...

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to