bugGNU roff - Bugs: bug #62471, [tbl] horizontal and vertical...

 
 

bug #62471: [tbl] horizontal and vertical rules are drawn too long in nroff mode

Submitter:  G. Branden Robinson <gbranden>
Submitted:  Mon 16 May 2022 03:30:55 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.24.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 16 Jan 2024 01:07:17 PM UTC, comment #11: 


commit db07433b17c2874d70c011808be8823e7323f068 (HEAD -> master, origin/master, origin/HEAD)
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Sun Jan 14 10:00:10 2024 -0600

    [tbl]: Compensate harder (Savannah #62471).

    [tbl]: Re-fix Savannah #62471 (vrules in nroff and no-space modes).

    * src/preproc/tbl/table.cpp (do_top): Compensate harder for
      non-intersected vertical rules occurring at the top of a table in
      nroff mode.  The previous strategy would fail if no-space mode was on
      and the drawing position was at the top of a page, provoking an error
      from grotty ("output above first line discarded").  Restore spacing
      before issuing `sp` request.

    Continues fixing Savannah #62471, and commit 6ccdab9d64, 29 December.

commit 0a0bfe65c8d883add6a95f3e7c1fe6122c665c7e
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Sun Jan 14 10:07:07 2024 -0600

    [tbl]: Add test case.

    * src/preproc/tbl/tests/do-not-overdraw-page-top-in-nroff-mode.sh: Add
      an eleventh test case, prompted by ascii(7) from Linux man-pages,
      where a table with a vertical rule got coincidentally rendered at the
      very top of a page (which can only happen in continuous rendering
      mode, where the page boundaries are invisible) while no-space mode was
      on (due to the table immediately following a paragraphing macro).

    Test fails at this commit.


G. Branden Robinson <gbranden>
Group administrator
Sun 14 Jan 2024 04:24:29 PM UTC, comment #10: 

Ah, but consider this.


$ cat EXPERIMENTS/table-top-vrule.roff
.ns
.TS
L | L.
foo     bar
.TE
$ nroff -t EXPERIMENTS/table-top-vrule.roff|cat -s # groff Git
grotty:<standard input>:(EXPERIMENTS/table-top-vrule.roff):20: error: output above first line discarded
foo │ bar

$ ./build/test-groff -Tutf8 -t EXPERIMENTS/table-top-vrule.roff|cat -s # my working copy
    │
foo │ bar


G. Branden Robinson <gbranden>
Group administrator
Sun 31 Dec 2023 01:07:04 AM UTC, comment #9: 


commit 6ccdab9d64864b148781a5819b567518130324ed
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   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.

commit 028f80cf2da8301e235b049c93e49138d0bb44f3
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Fri Dec 29 23:10:08 2023 -0600

    [tbl]: Regression-test Savannah #62471.

    * src/preproc/tbl/tests/horizontal-rules-not-drawn-too-long.sh: Do it.
    * src/preproc/tbl/tbl.am (tbl_TESTS): Run test.

    Test fails at this commit.


G. Branden Robinson <gbranden>
Group administrator
Thu 10 Aug 2023 01:29:08 PM UTC, comment #8: 

comment #3:

> I despair of resolving this before 1.23.0 is released; postponing.


I have less despair now that 1.23.0 is out.

This still might be devilish to fix.

G. Branden Robinson <gbranden>
Group administrator
Fri 03 Feb 2023 06:01:50 AM UTC, comment #7: 


comment #5:

> tbl has so much misbehavior, though, that it is admittedly difficult to distinguish its various defects.


See bug #63749 for support of this claim.

G. Branden Robinson <gbranden>
Group administrator
Fri 03 Feb 2023 06:00:36 AM UTC, comment #6: 

Quoting bug #63749:


.ll 64n
.nf
1234567890123456789012345678901234567890123456789012345678901234
.fi
.TS
tab(@);
L L L L L.
abandoning@babysitter@cablecasts@dachshunds@earmarkingX
.TE
.pl \n(nlu


> 2.  In the first table, if we add another character to the last entry and a horizontal line on another row, the table will overrun the line length with no warning.  This is an aspect of bug #62471.


> 3.  It might be possible to address that case, and the straggling vertical line case, by drawing horizontal and vertical lines 1n shorter on nroff devices if no line intersection will take place.  (Accommodation of that scenario is why they are drawn too long in the first place.)  My changes to tbl over the last year or so track more state about `hline` and `vline` usage, so this may be tractable.

G. Branden Robinson <gbranden>
Group administrator
Tue 29 Nov 2022 11:42:04 AM UTC, comment #5: 

comment #4:

> The detailed analysis in http://lists.gnu.org/r/groff/2022-07/msg00223.html suggests that this and bug #62265 are respectively the horizontal and vertical manifestations of the same bug.


Bug #62265 was resolved as invalid.

Because the rules are drawn 1 character cell too wide/tall on nroff devices to facilitate detection of crossings, and replacement with Unicode box-drawing characters (or ASCII "+" if that is all one has), I don't agree that there are separate vertical and horizontal manifestations of what I'm trying to draw within the scope of this bug.

tbl has so much misbehavior, though, that it is admittedly difficult to distinguish its various defects.

I think I will be re-scoping bug #61597 to a simple desire for a syntax extension to permit a column width modifier after a bar in a row descriptor.  A good deal of what it gripes about, is the "vertical rules too tall in nroff" discussed here.

G. Branden Robinson <gbranden>
Group administrator
Fri 29 Jul 2022 05:56:27 AM UTC, comment #4: 

The detailed analysis in http://lists.gnu.org/r/groff/2022-07/msg00223.html suggests that this and bug #62265 are respectively the horizontal and vertical manifestations of the same bug.

Dave <barx>
Group Member
Tue 31 May 2022 05:16:02 AM UTC, comment #3: 

This is going to require a fairly intrusive change to tbl.

Right now "total separation" is computed at the time tbl runs.

https://git.savannah.gnu.org/cgit/groff.git/tree/src/preproc/tbl/table.cpp#n2228

This means that the amount of horizontal space not allocated to table entries is invariant with respect to nroff/troff mode.

But that's a problem because vertical rules are nearly zero-width in troff mode but take up an entire character cell in nroff mode.
Further, the number of vertical rules is highly variable; there could be 0, 1, 2 (a common case with boxed tables), or many.

And tbl doesn't know which mode the table will be formatted in.

So the computation of total separation is going to have to be deferred to formatting time.  I expect more registers will have to be introduced.

I despair of resolving this before 1.23.0 is released; postponing.

G. Branden Robinson <gbranden>
Group administrator
Tue 17 May 2022 04:11:38 AM UTC, comment #2: 

The existing behavior appears to be at least in part to enable crossings between horizontal and vertical lines that can be detected by nroff-mode devices (for groff, that's just grotty(1)).

This is an unfortunate chunk of technical debt.  This design choice entangles tbl and grotty and impacts vertical lines (the "|" column classifier), tbl box options, and tbl's idea of "total separation" (for a table row), which is not currently distinct for troff mode and nroff mode.  That's a nice feature but it leads to excess spacing in grotty.  Also, strictly speaking, it wouldn't be necessary for overstriking nroff devices.  But we don't have one of those to test.

Further, as far as I can tell, there's an assumption of left-to-right output printing embedded in this.

A tough nut to crack, but I'm not giving up yet.

G. Branden Robinson <gbranden>
Group administrator
Mon 16 May 2022 06:14:01 AM UTC, comment #1: 

This actually appears to be a bug in grotty(1).  Some kind of rounding problem?

To produce horizontal rules in tables, tbl(1) produces groff(7) code like this.


$ grep '\\D' EXPERIMENTS/78-char-table.roff.post-tbl
\v'.25m'\s[\n[3lps]]\h'|\n[3cd0]u'\D'l |\n[3cd1]u 0'\s0


Notice that we're using \D escape sequences for drawing, not \l for a horizontal rules.

This comes from single_line_entry::simple_print().  https://git.savannah.gnu.org/cgit/groff.git/tree/src/preproc/tbl/table.cpp#n2446

Something interesting happens if you feed groff intermediate output ("grout") to grotty, varying only the horizontal length parameter to the 'l' drawing command.

The horizontal motion quantum of the grotty output devices is 24.  That is, 1n == 1m == 24u.  Watch what happens.


$ cat EXPERIMENTS/horizontal-line-24u.grout
x T utf8
x res 240 24 40
x init
p1
V40
H0
md
DFd
s10
Dl 24 0
n40 0
x trailer
V2640
x stop
$ ./build/grotty -F ./build/font EXPERIMENTS/horizontal-line-24u.grout | cat -s
──

$ cat EXPERIMENTS/horizontal-line-12u.grout
x T utf8
x res 240 24 40
x init
p1
V40
H0
md
DFd
s10
Dl 12 0
n40 0
x trailer
V2640
x stop
$ ./build/grotty -F ./build/font EXPERIMENTS/horizontal-line-12u.grout | cat -s
──

$ cat EXPERIMENTS/horizontal-line-1u.grout
x T utf8
x res 240 24 40
x init
p1
V40
H0
md
DFd
s10
Dl 1 0
n40 0
x trailer
V2640
x stop
$ ./build/grotty -F ./build/font EXPERIMENTS/horizontal-line-1u.grout | cat -s
──


No matter how short we make the line, we get two character cells of output.

Something differently curious happens for a zero-length horizontal line, but I'll leave that for another time because it doesn't seem to be generated by tbl(1) and thus doesn't hose up man pages.

G. Branden Robinson <gbranden>
Group administrator
Mon 16 May 2022 03:30:55 AM UTC, original submission:  

This is a headache for man pages.


$ cat EXPERIMENTS/78-char-table.roff
.ll 78n
.TS
L.
_
123456789012345678901234567890123456789012345678901234567890123456789012345678
.TE
.pl \n(nlu
$ groff -Tascii -t EXPERIMENTS/78-char-table.roff
-------------------------------------------------------------------------------
123456789012345678901234567890123456789012345678901234567890123456789012345678


G. Branden Robinson <gbranden>
Group 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 barx (Posted a comment)
  • -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 17 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-01-16 gbranden StatusIn Progress Fixed
        Open/ClosedOpen Closed
    2024-01-14 gbranden StatusFixed In Progress
        Open/ClosedClosed Open
    2023-12-31 gbranden StatusIn Progress Fixed
        Open/ClosedOpen Closed
        Planned ReleaseNone 1.24.0
    2023-12-30 gbranden StatusNone In Progress
    2023-08-10 gbranden StatusPostponed None
    2022-09-08 gbranden Summary[tbl] draws horizontal lines that are too long by 1n in nroff mode [tbl] horizontal and vertical rules are drawn too long in nroff mode
    2022-05-31 gbranden CategoryDriver - others/general Preprocessor tbl
        StatusIn Progress Postponed
        Summary[grotty] draws horizontal lines that are too long by 1n [tbl] draws horizontal lines that are too long by 1n in nroff mode
    2022-05-16 gbranden CategoryPreprocessor tbl Driver - others/general
        StatusNone In Progress
        Assigned toNone gbranden
        Summary[tbl] oversets horizontal rules by 1n in nroff mode [grotty] draws horizontal lines that are too long by 1n

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code