gbranden pushed a commit to branch master
in repository groff.

commit 0c97fe8f44a55a493a269216e1450d407f269bff
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Nov 11 07:26:15 2026 -0600

    [tbl]: Guard unreachable code.
    
    ... with new preprocessor conditionals testing symbol `DEBUG_TBL`.
    
    * src/preproc/tbl/table.h (struct entry_format) [DEBUG_TBL]: Guard
      declaration of `debug_print()` member function.
    
    * src/preproc/tbl/main.cpp [DEBUG_TBL]: Guard definitions of
      `entry_format::debug_print()` and `input_entry_format::debug_print()`.
    
      (struct input_entry_format) [DEBUG_TBL]: Guard declaration of
      `debug_print()` member function.
    
      (process_format) [DEBUG_TBL]: Guard logic calling `debug_print()`
      iteratively on `tem` linked list object with conditional testing new
      symbol instead of `0`.
    
    With a reasonably aggressive optimizing compiler, this change results in
    no change to the size of the `tbl` executable, but I expect it to make
    our code coverage statistics more accurate.  Also, this way if we wish
    to examine entry format interpretation and/or encoding, we need not
    alter the source code--we can simply say `make CXXFLAGS+=-DDEBUG_TBL`.
---
 ChangeLog                | 16 ++++++++++++++++
 src/preproc/tbl/main.cpp |  9 +++++++--
 src/preproc/tbl/table.h  |  2 ++
 3 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9ca62d89f..35ad17e93 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2026-11-11  G. Branden Robinson <[email protected]>
+
+       [tbl]: Guard unreachable code with new preprocessor
+       conditionals testing symbol `DEBUG_TBL`.
+
+       * src/preproc/tbl/table.h (struct entry_format) [DEBUG_TBL]:
+       Guard declaration of `debug_print()` member function.
+       * src/preproc/tbl/main.cpp [DEBUG_TBL]: Guard definitions of
+       `entry_format::debug_print()` and
+       `input_entry_format::debug_print()`..
+       (struct input_entry_format) [DEBUG_TBL]: Guard declaration of
+       `debug_print()` member function.
+       (process_format) [DEBUG_TBL]: Guard logic calling
+       `debug_print()` iteratively on `tem` linked list object with
+       conditional testing new symbol instead of `0`.
+
 2026-11-11  G. Branden Robinson <[email protected]>
 
        * src/preproc/tbl/main.cpp: Improve error diagnostics by clearly
diff --git a/src/preproc/tbl/main.cpp b/src/preproc/tbl/main.cpp
index c15c9e653..1c365ef71 100644
--- a/src/preproc/tbl/main.cpp
+++ b/src/preproc/tbl/main.cpp
@@ -573,6 +573,7 @@ entry_format::entry_format(format_type t) : type(t)
 {
 }
 
+#ifdef DEBUG_TBL
 void entry_format::debug_print() const
 {
   switch (type) {
@@ -648,6 +649,7 @@ void entry_format::debug_print() const
   if (stagger)
     putc('u', stderr);
 }
+#endif
 
 struct format {
   int nrows;
@@ -736,7 +738,9 @@ struct input_entry_format : public entry_format {
   int expand;
   input_entry_format(format_type, input_entry_format * = 0);
   ~input_entry_format();
+#ifdef DEBUG_TBL
   void debug_print();
+#endif
 };
 
 input_entry_format::input_entry_format(format_type t, input_entry_format *p)
@@ -763,6 +767,7 @@ static void free_input_entry_format_list(input_entry_format 
*list)
   }
 }
 
+#ifdef DEBUG_TBL
 void input_entry_format::debug_print()
 {
   int i;
@@ -786,6 +791,7 @@ void input_entry_format::debug_print()
   if (is_last_column)
     putc(',', stderr);
 }
+#endif
 
 // Describe an input character.
 // TODO: Can we usefully pull this into libgroff?  If so, we might want
@@ -1252,8 +1258,7 @@ static format *process_format(table_input &in, options 
*opt,
   }
   list = rev;
   input_entry_format *tem;
-
-#if 0
+#ifdef DEBUG_TBL
   for (tem = list; tem; tem = tem->next)
     tem->debug_print();
   putc('\n', stderr);
diff --git a/src/preproc/tbl/table.h b/src/preproc/tbl/table.h
index 5d1140ed1..0313a5a4d 100644
--- a/src/preproc/tbl/table.h
+++ b/src/preproc/tbl/table.h
@@ -69,7 +69,9 @@ struct entry_format : public entry_modifier {
 
   entry_format(format_type);
   entry_format();
+#ifdef DEBUG_TBL
   void debug_print() const;
+#endif
 };
 
 class table_entry;

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

Reply via email to