groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 03/03: Fix man(7) continuous rendering/tbl interaction.


From: G. Branden Robinson
Subject: [groff] 03/03: Fix man(7) continuous rendering/tbl interaction.
Date: Fri, 9 Oct 2020 05:19:00 -0400 (EDT)

gbranden pushed a commit to branch master
in repository groff.

commit ffef301cb320f13292f20d53f4fd2a52a5e70a47
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Fri Oct 9 19:57:43 2020 +1100

    Fix man(7) continuous rendering/tbl interaction.
    
    Stop tbl from injecting spurious blank lines (and emitting spurious
    warnings about tables and "text blocks" not "fitting on a page") into
    long tables in man pages when continuous rendering is used (the default
    for nroff output devices).
    
    * src/preproc/tbl/table.cpp (USE_KEEPS_REG): New preprocessor symbol
      stores name of groff register for dynamic determination of keep usage.
    
      (table::init_output): If the NOKEEP flag is not set, then in generated
      groff output, see if the usekeeps register is defined; if not, define
      it and enable usage of keeps.
    
      (table::do_row): In groff output, check usekeeps register before
      calling keep and release macros.
    
      (table::do_bottom): In groff output, check usekeeps register before
      calling release macro.
    
    * tmac/an-old.tmac (TS): Set the usekeeps register used by tbl to the
      logical complement of the man(7) cR (continuous rendering) register.
    
    Problem appears to date back to the introduction of continuous
    rendering in groff 1.17 (3 May 2001).
    
    Fixes <https://savannah.gnu.org/bugs/index.php?57665>.
---
 ChangeLog                 | 28 +++++++++++++++++++++++++++-
 src/preproc/tbl/table.cpp | 14 ++++++++++----
 tmac/an-old.tmac          |  5 +++++
 3 files changed, 42 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a0370d5..ba2371f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,35 @@
 2020-10-09  G. Branden Robinson <g.branden.robinson@gmail.com>
 
+       Stop tbl from injecting spurious blank lines (and emitting
+       spurious warnings about tables and "text blocks" not "fitting on
+       a page") into long tables in man pages when continuous rendering
+       is used (the default for nroff output devices).
+
+       * src/preproc/tbl/table.cpp (USE_KEEPS_REG): New preprocessor
+       symbol stores name of groff register for dynamic determination
+       of keep usage.
+       (table::init_output): If the NOKEEP flag is not set, then in
+       generated groff output, see if the usekeeps register is defined;
+       if not, define it and enable usage of keeps.
+       (table::do_row): In groff output, check usekeeps register before
+       calling keep and release macros.
+       (table::do_bottom): In groff output, check usekeeps register
+       before calling release macro.
+
+       * tmac/an-old.tmac (TS): Set the usekeeps register used by tbl
+       to the logical complement of the man(7) cR (continuous
+       rendering) register.
+
        * tmac/tests/an-old_TS_do_not_keep_tables_when_cR_set.sh: Add
-       regression test for Savannah #57665.
+       regression test.
+
        * tmac/tmac.am (TESTS): Run the test.
 
+       Problem appears to date back to the introduction of continuous
+       rendering in groff 1.17 (3 May 2001).
+
+       Fixes <https://savannah.gnu.org/bugs/index.php?57665>.
+
 2020-10-09  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        * src/preproc/tbl/table.cpp (simple_entry::position_vertically):
diff --git a/src/preproc/tbl/table.cpp b/src/preproc/tbl/table.cpp
index a4cf162..c863934 100644
--- a/src/preproc/tbl/table.cpp
+++ b/src/preproc/tbl/table.cpp
@@ -40,6 +40,7 @@ const int DEFAULT_COLUMN_SEPARATION = 3;
 #define SECTION_DIVERSION_FLAG_REG PREFIX "sflag"
 #define SAVED_VERTICAL_POS_REG PREFIX "vert"
 #define NEED_BOTTOM_RULE_REG PREFIX "brule"
+#define USE_KEEPS_REG PREFIX "usekeeps"
 #define KEEP_MACRO_NAME PREFIX "keep"
 #define RELEASE_MACRO_NAME PREFIX "release"
 #define SAVED_FONT_REG PREFIX "fnt"
@@ -876,6 +877,7 @@ double_line_entry::double_line_entry(const table *p,
                                     const entry_modifier *m)
 : line_entry(p, m)
 {
+  error("double_line_entry constructed");
 }
 
 int double_line_entry::line_type()
@@ -885,6 +887,7 @@ int double_line_entry::line_type()
 
 void double_line_entry::simple_print(int dont_move)
 {
+  error("double_line_entry::simple_print(dont_move=%1)", dont_move);
   if (!dont_move)
     prints("\\v'-" BAR_HEIGHT "'");
   printfs("\\h'|\\n[%1]u",
@@ -1759,6 +1762,9 @@ void table::init_output()
     prints(".nr " SAVED_CENTER_REG " \\n[.ce]\n");
   if (compatible_flag)
     prints(".ds " LEADER_REG " \\a\n");
+  if (!(flags & NOKEEP))
+    prints(".if !r " USE_KEEPS_REG " \\\n"
+          ".  nr " USE_KEEPS_REG " 1\n");
   prints(".de " RESET_MACRO_NAME "\n"
         ".ft \\n[.f]\n"
         ".ps \\n[.s]\n"
@@ -2731,7 +2737,7 @@ int table::row_ends_section(int r)
 void table::do_row(int r)
 {
   if (!(flags & NOKEEP) && row_begins_section(r))
-    prints("." KEEP_MACRO_NAME "\n");
+    prints(".if \\n[" USE_KEEPS_REG "] ." KEEP_MACRO_NAME "\n");
   int had_line = 0;
   stuff *p;
   for (p = stuff_list; p && p->row < r; p = p->next)
@@ -2759,7 +2765,7 @@ void table::do_row(int r)
     printfs("." REPEATED_MARK_MACRO " %1\n", row_top_reg(r));
   // we might have had a .TH, for example,  since we last tried
   if (!(flags & NOKEEP) && row_begins_section(r))
-    prints("." KEEP_MACRO_NAME "\n");
+    prints(".if \\n[" USE_KEEPS_REG "] ." KEEP_MACRO_NAME "\n");
   prints("." REPEATED_NM_SET_MACRO " d\n"
         ".nr " ROW_MAX_LINE_REG " \\n[ln]\n");
   printfs(".mk %1\n", row_start_reg(r));
@@ -2894,7 +2900,7 @@ void table::do_row(int r)
     if (printed_one)
       prints("." REPEATED_VPT_MACRO " 1\n");
     if (!(flags & NOKEEP) && row_ends_section(r))
-      prints("." RELEASE_MACRO_NAME "\n");
+      prints(".if \\n[" USE_KEEPS_REG "] ." RELEASE_MACRO_NAME "\n");
   }
   prints(".if \\n[ln] .nr ln \\n[" ROW_MAX_LINE_REG "]\n");
 }
@@ -2937,7 +2943,7 @@ void table::do_bottom()
     if (p->row > nrows - 1)
       p->print(this);
   if (!(flags & NOKEEP))
-    prints("." RELEASE_MACRO_NAME "\n");
+    prints(".if \\n[" USE_KEEPS_REG "] ." RELEASE_MACRO_NAME "\n");
   printfs(".mk %1\n", row_top_reg(nrows));
   prints(".nr " NEED_BOTTOM_RULE_REG " 1\n"
         ".nr T. 1\n"
diff --git a/tmac/an-old.tmac b/tmac/an-old.tmac
index c9f71e2..1a042f9 100644
--- a/tmac/an-old.tmac
+++ b/tmac/an-old.tmac
@@ -567,6 +567,11 @@
 .\" table support
 .
 .de1 TS
+.  \" If continuous rendering, tell tbl not to use keeps.
+.  ie \\n[cR] \
+.    nr 3usekeeps 0
+.  el \
+.    nr 3usekeeps 1
 .  sp \\n[PD]u
 .  if \\n[an-html] \{\
 .    nr an-TS-ll \\n[.l]



reply via email to

[Prev in Thread] Current Thread [Next in Thread]