gbranden pushed a commit to branch master
in repository groff.

commit 6ccdab9d64864b148781a5819b567518130324ed
Author: G. Branden Robinson <[email protected]>
AuthorDate: Fri Dec 29 23:18:14 2023 -0600

    [tbl]: Fix Savannah #62471 (hrules in nroff mode).
    
    This fixes the last problem I know of that keeps man pages from freely
    using the full width of the terminal.  (You can still cause lines to
    overrun manually, of course.)
    
    * src/preproc/tbl/table.h (class table): Define new enumeration
      constant, `HAS_DATA_HRULE`, to keep track of whether a table uses a
      horizontal rule as a data row.
    * src/preproc/tbl/main.cpp (process_data): Set it when encountering
      appropriate input.
    * src/preproc/tbl/table.cpp (table::compute_overall_width): Check for it
      if the table is not already boxed, and emit output to reduce the line
      length by one in nroff mode.
---
 ChangeLog                 | 17 +++++++++++++++++
 src/preproc/tbl/main.cpp  |  1 +
 src/preproc/tbl/table.cpp |  2 ++
 src/preproc/tbl/table.h   | 25 +++++++++++++------------
 4 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index eb42323c2..b78f3ac1e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2023-12-29  G. Branden Robinson <[email protected]>
+
+       [tbl]: Fix Savannah #62471 (hrules in nroff mode).
+
+       This fixes the last problem I know of that keeps man pages from
+       freely using the full width of the terminal.  (You can still
+       cause lines to overrun manually, of course.)
+
+       * src/preproc/tbl/table.h (class table): Define new enumeration
+       constant, `HAS_DATA_HRULE`, to keep track of whether a table
+       uses a horizontal rule as a data row.
+       * src/preproc/tbl/main.cpp (process_data): Set it when
+       encountering appropriate input.
+       * src/preproc/tbl/table.cpp (table::compute_overall_width):
+       Check for it if the table is not already boxed, and emit output
+       to reduce the line length by one in nroff mode.
+
 2023-12-29  G. Branden Robinson <[email protected]>
 
        [tbl]: Regression-test Savannah #62471.
diff --git a/src/preproc/tbl/main.cpp b/src/preproc/tbl/main.cpp
index 4e0faebce..7ad597b52 100644
--- a/src/preproc/tbl/main.cpp
+++ b/src/preproc/tbl/main.cpp
@@ -1337,6 +1337,7 @@ table *process_data(table_input &in, format *f, options 
*opt)
          type = DOUBLE_HRULE;
        if (0 == current_row)
          tbl->flags |= table::HAS_TOP_HRULE;
+       tbl->flags |= table::HAS_DATA_HRULE;
       }
       else {
        in.unget(d);
diff --git a/src/preproc/tbl/table.cpp b/src/preproc/tbl/table.cpp
index 0c73a9005..93ab4b9ff 100644
--- a/src/preproc/tbl/table.cpp
+++ b/src/preproc/tbl/table.cpp
@@ -2211,6 +2211,8 @@ void table::compute_overall_width()
       printfs(".if n .ll -%1n \\\" right separation\n",
              as_string(right_separation));
   }
+  if (!(flags & (ALLBOX | BOX | DOUBLEBOX)) && (flags & HAS_DATA_HRULE))
+    prints(".if n .ll -1n \\\" horizontal rule compensation\n");
   // Compute the amount of horizontal space available for expansion,
   // measuring every column _including_ those eligible for expansion.
   // This is the minimum required to set the table without compression.
diff --git a/src/preproc/tbl/table.h b/src/preproc/tbl/table.h
index f29be4749..1d737c317 100644
--- a/src/preproc/tbl/table.h
+++ b/src/preproc/tbl/table.h
@@ -132,19 +132,20 @@ class table {
 public:
   unsigned flags;
   enum {
-    CENTER        = 0x00000001,
-    EXPAND        = 0x00000002,
-    BOX           = 0x00000004,
-    ALLBOX        = 0x00000008,
-    DOUBLEBOX     = 0x00000010,
-    NOKEEP        = 0x00000020,
-    NOSPACES      = 0x00000040,
-    NOWARN        = 0x00000080,
+    CENTER         = 0x00000001,
+    EXPAND         = 0x00000002,
+    BOX            = 0x00000004,
+    ALLBOX         = 0x00000008,
+    DOUBLEBOX      = 0x00000010,
+    NOKEEP         = 0x00000020,
+    NOSPACES       = 0x00000040,
+    NOWARN         = 0x00000080,
     // The next few properties help manage nroff mode output.
-    HAS_TOP_VRULE = 0x00000100,
-    HAS_TOP_HRULE = 0x00000200,
-    GAP_EXPAND    = 0x00000400,
-    EXPERIMENTAL  = 0x80000000 // undocumented
+    HAS_TOP_VRULE  = 0x00000100,
+    HAS_TOP_HRULE  = 0x00000200,
+    HAS_DATA_HRULE = 0x00000400,
+    GAP_EXPAND     = 0x00000800,
+    EXPERIMENTAL   = 0x80000000 // undocumented
     };
   char *expand;
   table(int nc, unsigned flags, int linesize, char decimal_point_char);

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

Reply via email to