gbranden pushed a commit to branch master
in repository groff.
commit de402cc58b6f1be6163b65f7a3496da3d73f3063
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun May 31 08:35:04 2026 -0500
[pic]: Rationalize header file inclusions.
Move some into "object.h" or "pic.h" where not doing so introduces
cycles.
* src/preproc/pic/output.h: Preprocessor-include "text.h".
* src/preproc/pic/lex.cpp:
* src/preproc/pic/main.cpp:
* src/preproc/pic/object.cpp:
* src/preproc/pic/output.cpp:
* src/preproc/pic/pic.h:
* src/preproc/pic/pic.ypp:
* src/preproc/pic/tex.cpp:
* src/preproc/pic/troff.cpp: Arrange inclusions of "libgroff" header
files before pic-specific ones. Within such inclusions, sort header
file names in alphabetical order, where the header file dependency
graph permits. Annotate exceptions.
* src/preproc/pic/main.cpp: Preprocessor-include "<limits.h>" to ensure
visiblity of `CHAR_MAX` symbol.
* src/preproc/pic/pic.h: Declare `extern` symbols from "lex.cpp" here,
not in "pic.ypp".
---
ChangeLog | 22 ++++++++++++++++++++++
src/preproc/pic/lex.cpp | 6 +++---
src/preproc/pic/main.cpp | 5 +++++
src/preproc/pic/object.cpp | 7 ++++---
src/preproc/pic/output.h | 2 ++
src/preproc/pic/pic.h | 30 +++++++++++++++++++++---------
src/preproc/pic/pic.ypp | 12 ++----------
src/preproc/pic/tex.cpp | 2 ++
src/preproc/pic/troff.cpp | 2 ++
9 files changed, 63 insertions(+), 25 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 287e06918..5d4bc0912 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2026-05-31 G. Branden Robinson <[email protected]>
+
+ [pic]: Rationalize header file inclusions. Move some into
+ "object.h" or "pic.h" where not doing so introduces cycles.
+
+ * src/preproc/pic/output.h: Preprocessor-include "text.h".
+ * src/preproc/pic/lex.cpp:
+ * src/preproc/pic/main.cpp:
+ * src/preproc/pic/object.cpp:
+ * src/preproc/pic/output.cpp:
+ * src/preproc/pic/pic.h:
+ * src/preproc/pic/pic.ypp:
+ * src/preproc/pic/tex.cpp:
+ * src/preproc/pic/troff.cpp: Arrange inclusions of "libgroff"
+ header files before pic-specific ones. Within such inclusions,
+ sort header file names in alphabetical order, where the header
+ file dependency graph permits. Annotate exceptions.
+ * src/preproc/pic/main.cpp: Preprocessor-include "<limits.h>" to
+ ensure visiblity of `CHAR_MAX` symbol.
+ * src/preproc/pic/pic.h: Declare `extern` symbols from "lex.cpp"
+ here, not in "pic.ypp".
+
2026-05-31 G. Branden Robinson <[email protected]>
[pic]: Fix code style nit.
diff --git a/src/preproc/pic/lex.cpp b/src/preproc/pic/lex.cpp
index 0b97ed7de..c501c4826 100644
--- a/src/preproc/pic/lex.cpp
+++ b/src/preproc/pic/lex.cpp
@@ -27,10 +27,10 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <stdio.h> // EOF, FILE, fclose(), fopen(), getc(), ungetc()
#include <string.h> // strerror()
-#include "pic.h" // must precede object.h
+#include "cset.h" // csdigit(), csupper()
+#include "lib.h" // is_invalid_input_char(), strsave()
-#include "ptable.h" // must precede object.h
-#include "object.h"
+#include "pic.h"
#include "pic.hpp"
declare_ptable(char)
diff --git a/src/preproc/pic/main.cpp b/src/preproc/pic/main.cpp
index b1b5ca66c..fc3a242b8 100644
--- a/src/preproc/pic/main.cpp
+++ b/src/preproc/pic/main.cpp
@@ -22,6 +22,7 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <assert.h>
#include <errno.h>
+#include <limits.h> // CHAR_MAX
#include <locale.h> // setlocale()
#include <stdio.h> // EOF, FILE, fclose(), ferror(), fflush(), fopen(),
// fprintf(), fputs(), getc(), printf(), setbuf(),
@@ -31,6 +32,10 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <getopt.h> // getopt_long()
+#include "lib.h" // strsave()
+#include "stringclass.h" // prerequisite of "lf.h"
+#include "lf.h" // normalize_file_name_for_lf_request()
+
#include "pic.h"
extern int yyparse();
diff --git a/src/preproc/pic/object.cpp b/src/preproc/pic/object.cpp
index f2edf200c..0c844b345 100644
--- a/src/preproc/pic/object.cpp
+++ b/src/preproc/pic/object.cpp
@@ -24,9 +24,10 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <math.h> // M_PI, acos(), atan2(), cos(), sin()
#include <stdlib.h> // free()
-#include "pic.h" // includes cset.h, which declares csupper()
-#include "ptable.h"
-#include "object.h"
+#include "cset.h" // csupper()
+#include "lib.h" // strsave()
+
+#include "pic.h"
void print_object_list(object *);
diff --git a/src/preproc/pic/output.h b/src/preproc/pic/output.h
index 08937542f..0287a66e3 100644
--- a/src/preproc/pic/output.h
+++ b/src/preproc/pic/output.h
@@ -16,6 +16,8 @@ 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 "text.h" // text_piece
+
struct line_type {
enum { invisible, solid, dotted, dashed } type;
double dash_width;
diff --git a/src/preproc/pic/pic.h b/src/preproc/pic/pic.h
index 2a805fcfc..fe934ad32 100644
--- a/src/preproc/pic/pic.h
+++ b/src/preproc/pic/pic.h
@@ -16,16 +16,15 @@ 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 "errarg.h" // prerequisite of "error.h"
+#include "error.h" // error(), error_with_file_and_line(), warning(),
+ // warning_with_file_and_line()
+#include "ptable.h"
+#include "stringclass.h" // string
-#include "cset.h"
-#include "stringclass.h"
-#include "lf.h"
-#include "errarg.h"
-#include "error.h"
-#include "position.h"
-#include "text.h"
-#include "output.h"
+#include "position.h" // prerequisite of "object.h" and "output.h"
+#include "output.h" // prerequisite of "output.h"
+#include "object.h"
#ifndef M_SQRT2
#define M_SQRT2 1.41421356237309504880
@@ -35,6 +34,19 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#define M_PI 3.14159265358979323846
#endif
+// lex.cpp
+extern int delim_flag;
+extern void copy_rest_thru(const char * /* body */,
+ const char * /* until */);
+extern void copy_file_thru(const char * /* filename*/,
+ const char * /* body */,
+ const char * /* until */);
+extern void push_body(const char *);
+extern void do_for(char * /* var */, double /* from */, double /* to */,
+ int /* by_is_multiplicative */, double /* by */,
+ char * /* body*/);
+extern void do_lookahead();
+
class input {
input *next;
public:
diff --git a/src/preproc/pic/pic.ypp b/src/preproc/pic/pic.ypp
index a97751095..10ade53b4 100644
--- a/src/preproc/pic/pic.ypp
+++ b/src/preproc/pic/pic.ypp
@@ -48,17 +48,9 @@ extern "C" {
}
#endif /* NEED_DECLARATION_SRAND */
+#include "lib.h" // strsave()
+
#include "pic.h"
-#include "ptable.h"
-#include "object.h"
-
-extern int delim_flag;
-extern void copy_rest_thru(const char *, const char *);
-extern void copy_file_thru(const char *, const char *, const char *);
-extern void push_body(const char *);
-extern void do_for(char *var, double from, double to,
- int by_is_multiplicative, double by, char *body);
-extern void do_lookahead();
/* Maximum number of characters produced by printf("%g") */
#define GDIGITS 14
diff --git a/src/preproc/pic/tex.cpp b/src/preproc/pic/tex.cpp
index c92f6b011..8a4e28174 100644
--- a/src/preproc/pic/tex.cpp
+++ b/src/preproc/pic/tex.cpp
@@ -25,6 +25,8 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <stdlib.h> // strtol()
#include <stdio.h> // fputs(), printf(), stdout
+#include "cset.h" // csalpha(), csspace()
+
#include "pic.h"
#ifdef TEX_SUPPORT
diff --git a/src/preproc/pic/troff.cpp b/src/preproc/pic/troff.cpp
index dc0cdc1a0..33afc1a65 100644
--- a/src/preproc/pic/troff.cpp
+++ b/src/preproc/pic/troff.cpp
@@ -24,6 +24,8 @@ along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#include <stdlib.h> // free()
#include <stdio.h> // fputs(), printf(), putchar(), puts(), stdout
+#include "lib.h" // strsave()
+
#include "pic.h"
#include "common.h"
_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit