groff-commit
[Top][All Lists]
Advanced

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

[groff] 42/46: [tbl]: Fix Savannah #61878.


From: G. Branden Robinson
Subject: [groff] 42/46: [tbl]: Fix Savannah #61878.
Date: Wed, 7 Dec 2022 04:32:38 -0500 (EST)

gbranden pushed a commit to branch master
in repository groff.

commit ebf4ff1be1401dac0163b719bb0be0f0945da448
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Dec 7 00:42:19 2022 -0600

    [tbl]: Fix Savannah #61878.
    
    * src/preproc/tbl/table.cpp: Define new preprocessor macro,
      `STARTING_PAGE_REG`.
    
      (table::define_bottom_macro): Have the formatter issue a warning if an
      unkept, boxed table ends on a different page than it began.
    
      (table::do_top): Save current page number when table begins.
    
    Fixes <https://savannah.gnu.org/bugs/?61878>.
---
 ChangeLog                 | 13 +++++++++++++
 src/preproc/tbl/table.cpp | 12 ++++++++++--
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ee44db4f2..c9b6246c3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2022-12-07  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [tbl]: Fix Savannah #61878.
+
+       * src/preproc/tbl/table.cpp: Define new preprocessor macro,
+       `STARTING_PAGE_REG`.
+       (table::define_bottom_macro): Have the formatter issue a warning
+       if an unkept, boxed table ends on a different page than it
+       began.
+       (table::do_top): Save current page number when table begins.
+
+       Fixes <https://savannah.gnu.org/bugs/?61878>.
+
 2022-12-07  G. Branden Robinson <g.branden.robinson@gmail.com>
 
        [tbl]: Regression-test Savannah #61878.
diff --git a/src/preproc/tbl/table.cpp b/src/preproc/tbl/table.cpp
index e1c8dbd59..049caa87e 100644
--- a/src/preproc/tbl/table.cpp
+++ b/src/preproc/tbl/table.cpp
@@ -67,6 +67,7 @@ const int DEFAULT_COLUMN_SEPARATION = 3;
 #define SAVED_HYPHENATION_SPACE_REG PREFIX "hyphspace"
 #define SAVED_NUMBERING_LINENO PREFIX "linenumber"
 #define SAVED_NUMBERING_SUPPRESSION_COUNT PREFIX "linenumbersuppresscnt"
+#define STARTING_PAGE_REG PREFIX "startingpage"
 
 // this must be one character
 #define COMPATIBLE_REG PREFIX "c"
@@ -2729,8 +2730,14 @@ void table::define_bottom_macro()
   prints(".    ls\n");
   prints(".    nr " LAST_PASSED_ROW_REG " \\n[" CURRENT_ROW_REG "]\n"
         ".    sp |\\n[" SAVED_VERTICAL_POS_REG "]u\n"
-        ".    " REPEATED_VPT_MACRO " 1\n"
-        ".  \\}\n"
+        ".    " REPEATED_VPT_MACRO " 1\n");
+  if ((flags & NOKEEP) && (flags & (BOX | DOUBLEBOX | ALLBOX)))
+    prints(".    if (\\n% > \\n[" STARTING_PAGE_REG "]) \\{\\\n"
+          ".      tmc \\n[.F]:\\n[.c]: warning:\n"
+          ".      tmc \" boxed, unkept table does not fit on page\n"
+          ".      tm1 \" \\n[" STARTING_PAGE_REG "]\n"
+          ".    \\}\n");
+  prints(".  \\}\n"
         "..\n"
         ".ig\n"
         ".EQ\n"
@@ -2971,6 +2978,7 @@ void table::do_top()
   // vertical rule is not drawn above the top of the page.
   else if ((flags & HAS_TOP_VLINE) && !(flags & HAS_TOP_HLINE))
     prints(".if n .sp\n");
+  prints(".nr " STARTING_PAGE_REG " \\n%\n");
   //printfs(".mk %1\n", row_top_reg(0));
 }
 



reply via email to

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