bugGNU roff - Bugs: bug #64728, diversion widths reported when...

 
 

bug #64728: diversion widths reported when using eqn mark/lineup feature inconsistent with Heirloom

Submitter:  None
Submitted:  Sat 30 Sep 2023 01:09:39 PM UTC
   
 
Category:  Preprocessor eqn Severity:  3 - Normal
Item Group:  Incorrect behaviour Status:  Need Info
Privacy:  Public Assigned to:  None
Open/Closed:  Open Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sat 13 Jan 2024 03:48:13 PM UTC, comment #6: 

The information needed here is a gathering of information about various *roff implementations.

This stuff looks like it's so ill-defined that I think we want to check out Seventh Edition Unix troff as well (which we can do with `tm` requests even if the program output is incomprehensible).

We should consider V7 troff, DWB 3.3, Heirloom Doctools, and possibly plan9port and neatroff.

Do the diversion measurement registers `dn` and `dl` measure:

  • net motion of the drawing position,
  • maximal motion of the drawing position relative to that where the diversion started,

or

  • maximal bounds of spilled ink relative to the drawing position where the diversion started?


Negative motions seem ill-defined with only two registers.  Presumably this is why all `sp` requests mean `sp 1` inside diversions, but possibly this insight was insufficiently generalized back in the day.

Unassigning from self because I'm not the only person who can gather such information.

G. Branden Robinson <gbranden>
Group administrator
Tue 10 Oct 2023 03:28:38 PM UTC, comment #5: 

comment #4:

> If you consider the width of a diversion is the horizontal
> displacement of the longest line in the diversion, then the
> horizontal displacement in this single line example is zero,


True, and implementations do seem to treat it this way.  But the documentation (both CSTR #54 section 7.4 and groff's current Texinfo manual) does not directly address this situation.  Both documents refer only to "horizontal size," which could be either the maximum amount of ink spilled horizontally (Anonymous's presumption), or the maximum width the cursor traveled.

Also of note, and not entirely intuitive, is that if the cursor ends up to the left of where it started, the width is still reported as 0 (in both groff and Heirloom).

Dave <barx>
Group Member
Tue 10 Oct 2023 02:50:08 PM UTC, comment #4: 


> Heirloom nroff reports the same zero width, so if this is indeed a bug, it's a widespread one.


If you consider the width of a diversion is the horizontal displacement of the longest line in the diversion, then the horizontal displacement in this single line example is zero, after outputting this diversion the horizontal movement is zero.

Deri James <deri>
Group Member
Tue 10 Oct 2023 02:20:52 PM UTC, comment #3: 

comment #2:

> The following example shows a diversion in which 'abc' is
> printed, followed by a negative horizontal motion of the length
> of the just printed. The reported diversion width is zero; the
> expected width would be \w'abc'u,


Heirloom nroff reports the same zero width, so if this is indeed a bug, it's a widespread one.

A curious difference, though, is that groff outputs a break and a blank line after the "Diversion:" line.  (The piped "sed" masks the blank line, but piping through "uniq" or "cat -s" instead retains it.)  Heirloom has all output on the same line.  The diversion includes an explicit break, so Heirloom seems wrong in omitting it, but I can't account for the blank line in groff.

Dave <barx>
Group Member
Sun 08 Oct 2023 08:28:29 AM UTC, comment #2: 

Yes, the output of groff looks the same as Heirloom Doctools troff/nroff, both with terminal output and PostScript output. (I think this is what you are asking for?)

A bit more playing around made me suspect 342–346 in src/preproc/eqn/box.cpp (in the release version of groff 1.23.0), where it actually looks like the ending of the lineup equation is aligned with that of the mark equation on purpose. In case of a lineup equation being longer than the mark equation, this causes a negative horizontal motion (\h'-72').

Thus, it seems the bug lies indeed deeper. The following example shows a diversion in which 'abc' is printed, followed by a negative horizontal motion of the length of the just printed. The reported diversion width is zero; the expected width would be \w'abc'u, as that's the width of the conceptual box of affected output. Had this not been a diversion, but a string, then a width of zero might be desirable (though this doesn't seem to be so well-defined in the manual).

$ cat width_negative_horizontal_motion
.di xx
abc\h'-\w'abc'u'
.br
.di
Diversion: \*(xx
Width: \n(dl

$ nroff width_negative_horizontal_motion | sed '/^$/d'
Diversion: abc
Width: 0


Anonymous
Fri 06 Oct 2023 11:49:07 PM UTC, comment #1: 

Thanks for the report.

Can you confirm that visible output looks the same for both terminals and typesetters with this input, using both groff and Heirloom Doctools troff/nroff?

They do appear the same to me.

The differences show up in the reported widths of the diversions, as you noted.  That leads me to wonder if this is even an eqn issue in the first place; perhaps it lies deeper, in the formatter.

We've seen other complaints about diversion measurement.

G. Branden Robinson <gbranden>
Group administrator
Sat 30 Sep 2023 01:09:39 PM UTC, original submission:  

Using a diversion to capture the output of an eqn equation with the lineup indicator when there is an earlier equation with the mark indicator seemingly gives the wrong width of this lineup equation, in both troff and nroff.

In the example below, two different equations are processed: (1) with a mark indicator, and (2), printed once without and once with a lineup indicator, that is longer and has a common start with equation (1) before the indicators, such that output of both variants of (2) should look the same. However, the width of (2) with lineup indicator as reported by troff and nroff is not equal to the width of (2) without the lineup indicator (and equals the width of (1) in case of troff). For reference, I added the output of the latest (development snapshot) of Heirloom doctools, with the logical output.

$ cat mark_lineup_diversion
.di xx
.EQ
x mark = 1 + 1
.EN
.br
.di
\*(xx
.tm Width of (diversed) 1: \n(dl

.di xx
.EQ
x = 1 - 1 + 1 - 1 + 2
.EN
.br
.di
\*(xx
.tm Width of (diversed) 2: \n(dl

.di xx
.EQ
x lineup = 1 - 1 + 1 - 1 + 2
.EN
.br
.di
\*(xx
.tm Width of (diversed) 2 (using lineup): \n(dl

$ /usr/local/bin/neqn --version
GNU eqn (groff) version 1.23.0
$ /usr/local/bin/nroff --version
GNU nroff (groff) version 1.23.0
GNU groff version 1.23.0
Copyright (C) 2022 Free Software Foundation, Inc.
GNU groff comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of groff and its subprograms
under the terms of the GNU General Public License.
For more information about these matters, see the file
named COPYING.

called subprograms:

GNU grotty (groff) version 1.23.0
GNU troff (groff) version 1.23.0

$ cat mark_lineup_diversion | /usr/local/bin/neqn -Tascii | /usr/local/bin/nroff -Tascii | sed '/^$/d'
Width of (diversed) 1: 120
Width of (diversed) 2: 264
Width of (diversed) 2 (using lineup): 96
x=1+1
x=1-1+1-1+2
x=1-1+1-1+2
$ cat mark_lineup_diversion | /usr/local/ucb/neqn | /usr/local/ucb/nroff | sed '/^$/d'
Width of (diversed) 1: 120
x=1+1
Width of (diversed) 2: 264
x=1-1+1-1+2
Width of (diversed) 2 (using lineup): 264
x=1-1+1-1+2

$ cat mark_lineup_diversion | /usr/local/bin/eqn | /usr/local/bin/troff > /dev/null
Width of (diversed) 1: 36720
Width of (diversed) 2: 81390
Width of (diversed) 2 (using lineup): 36720
$ cat mark_lineup_diversion | /usr/local/ucb/eqn | /usr/local/ucb/troff > /dev/null
Width of (diversed) 1: 27086
Width of (diversed) 2: 58556
Width of (diversed) 2 (using lineup): 58556


Anonymous

 

(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 deri (Posted a comment)
  • -email is unavailable- added by barx (Posted a comment)
  • -email is unavailable- added by gbranden (Posted a comment)
  •  

    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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-01-13 gbranden Assigned togbranden None
    2023-10-06 gbranden CategoryNone Preprocessor eqn
        StatusNone Need Info
        Assigned toNone gbranden
        SummaryWrong width of lined-up eqn equation reported by diversion diversion widths reported when using eqn mark/lineup feature inconsistent with Heirloom

    Back to the top

    Powered by Savane 3.13-04b1.
    Corresponding source code