bugGNU troff - Bugs: bug #61854, [tbl] tables lacking 'x' column...

 
 

bug #61854: [tbl] tables lacking 'x' column modifier don't get table width warnings

Submitter:  G. Branden Robinson <gbranden>
Submitted:  Wed 19 Jan 2022 10:41:13 AM UTC
 
Category:  Preprocessor tbl Severity:  3 - Normal
Item Group:  Incorrect behaviour Status:  Fixed
Privacy:  Public Assigned to:  gbranden
Open/Closed:  Closed Planned Release:  1.23.0
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       No canned response available

 

( Jump to the original submission )

Thu 20 Jan 2022 03:23:15 PM UTC, comment #6: 

commit 77e6fb6bce3edcca62416c956f8d13fff33b5a78
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Thu Jan 20 16:20:11 2022 +1100

    [tbl]: Fix Savannah #61854.

    * src/preproc/tbl/table.cpp (compute_expand_width): To properly warn if
      a table is too wide to fit between the indentation and the right
      margin, we need to compute its column widths including those eligible
      for expansion via the 'x' column modifier; we cannot use the same
      expression that we do to determine how the amount of space we have to
      distribute among the expanded columns.  Iterate through columns again
      (the function was already doing so twice), once to potentially produce
      the warning, and then as before to distribute any available width.  In
      other words, warnings were only being emitted for too-wide tables
      where one or more columns used the 'x' modifier.

    Fixes <https://savannah.gnu.org/bugs/?61854>.

G. Branden Robinson <gbranden>
Project Administrator
Wed 19 Jan 2022 02:49:42 PM UTC, comment #5: 

Nope, that's not good enough.

It has the side effect of hobbling the 'x' modifier; the table gets
widened, but not to the full width of the page.  Possibly the "3expand"
register is used for two different purposes (though it appears to get
reset to zero pretty soon after the test I modified).

Will have to take a fresh look at this after some sleep.

G. Branden Robinson <gbranden>
Project Administrator
Wed 19 Jan 2022 01:40:00 PM UTC, comment #4: 

diff --git a/ChangeLog b/ChangeLog
index 9ef1c2d84..754c70bf4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2022-01-20  G. Branden Robinson <g.branden.robinson@gmail.com>
+
+       [tbl]: Fix Savannah #61854.
+
+       * src/preproc/tbl/table.cpp (compute_expand_width): Include
+       width of expanded ('x'-modified) columns in expression used to
+       decide whether the table with has exceeded the line length.
+       Omitting them from the calculation incorrectly surpressed
+       warning diagnostics of too-wide tables.  (In other words, you
+       only got warnings of too-wide tables where one or more columns
+       used the 'x' modifier.)
+
+       Fixes <https://savannah.gnu.org/bugs/?61854>.
+
 2022-01-19  G. Branden Robinson <g.branden.robinson@gmail.com>

        [ms]: Don't add leaders that don't lead anywhere.
diff --git a/src/preproc/tbl/table.cpp b/src/preproc/tbl/table.cpp
index 435ac6bf7..4508965c2 100644
--- a/src/preproc/tbl/table.cpp
+++ b/src/preproc/tbl/table.cpp
@@ -2162,8 +2162,7 @@ void table::compute_expand_width()
   int colcount = count_expand_columns();
   prints(".nr " EXPAND_REG " \\n[.l]-\\n[.i]");
   for (i = 0; i < ncolumns; i++)
-    if (!expand[i])
-      printfs("-\\n[%1]", span_width_reg(i, i));
+    printfs("-\\n[%1]", span_width_reg(i, i));
   if (total_separation)
     printfs("-%1n", as_string(total_separation));
   prints("\n");

G. Branden Robinson <gbranden>
Project Administrator
Wed 19 Jan 2022 12:28:45 PM UTC, comment #3: 

Forgot to assign this to the right Category.

Here's a raw roff reproducer.

$ cat EXPERIMENTS/wide-table.roff
.ll 10n
.TS
L.
12345678901
.TE
.
.TS
Lx.
12345678901
.TE

G. Branden Robinson <gbranden>
Project Administrator
Wed 19 Jan 2022 12:26:23 PM UTC, comment #2: 

I found the problem; it's a tbl bug.

The 'x' column modifier should not be necessary to enable
warnings about a table being too wide.

In the following exhibit, both tables should warn because they
overrun the line length by 1n.  But only the second one, using
the 'x' modifier, actually does.

groff 1.22.4 and Git HEAD both show this behavior.  There are
cosmetic differences in diagnostics.

$ cat EXPERIMENTS/wide-table.ms
.nr LL 10n
.TS
L.
12345678901
.TE
.
.TS
Lx.
12345678901
.TE
$ groff -Tutf8 -z -t -ms EXPERIMENTS/wide-table.ms
warning: file 'EXPERIMENTS/wide-table.ms', around line 9:
  table wider than line width
$ ./build/test-groff -Tutf8 -z -t -ms EXPERIMENTS/wide-table.ms
EXPERIMENTS/wide-table.ms: around line 9: warning: table wider than line width

G. Branden Robinson <gbranden>
Project Administrator
Wed 19 Jan 2022 11:02:36 AM UTC, comment #1: 

As I should have remembered, tbl(1) already produces *roff code
to emit this warning itself.

However, for some reason the warning is not showing up for
certain tables in doc/ms.ms.

This ticket may be invalid, or it may need to move to the ms
package.

G. Branden Robinson <gbranden>
Project Administrator
Wed 19 Jan 2022 10:41:13 AM UTC, original submission:  

The `TW` register has been part of the tbl(1) spec for the best
part of 50 years.

Macro packages' `TE` macros could test this register's value
against the line length and warn if a table is too wide.

I propose to do this.

(For man(7), I'll guard this behind the `CHECKSTYLE` register.)

G. Branden Robinson <gbranden>
Project Administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by gbranden (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

     

     

     

    Follow 11 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-01-20 gbranden StatusIn Progress Fixed
        Open/ClosedOpen Closed
        Planned ReleaseNone 1.23.0
    2022-01-19 gbranden StatusConfirmed In Progress
    2022-01-19 gbranden CategoryMacro ms Preprocessor tbl
    2022-01-19 gbranden CategoryMacro - others/general Macro ms
        Severity1 - Wish 3 - Normal
        Item GroupFeature change Incorrect behaviour
        StatusNeed Info Confirmed
        SummaryTE macro implementations should check TW register [tbl] tables lacking 'x' column modifier don't get table width warnings
    2022-01-19 gbranden StatusIn Progress Need Info

    Back to the top


    Powered by Savane 3.9