bug-groff
[Top][All Lists]
Advanced

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

[bug #62298] [eqn] handles complex matrix badly in nroff mode


From: G. Branden Robinson
Subject: [bug #62298] [eqn] handles complex matrix badly in nroff mode
Date: Mon, 11 Apr 2022 21:44:45 -0400 (EDT)

URL:
  <https://savannah.gnu.org/bugs/?62298>

                 Summary: [eqn] handles complex matrix badly in nroff mode
                 Project: GNU troff
            Submitted by: gbranden
            Submitted on: Tue 12 Apr 2022 01:44:43 AM UTC
                Category: Preprocessor eqn
                Severity: 3 - Normal
              Item Group: Incorrect behaviour
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None

    _______________________________________________________

Details:

A long time ago, so long that I was still maintaining XFree86 for Debian,
David Schmitt reported a problem with a Mesa GLU-related man page.

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=192144

Colin Watson boiled things down to a pretty simple reproducer.


$ cat EXPERIMENTS/bad_matrix.roff 
The generated matrix is
.sp
.ce
.EQ
left ( ~~ down 130 { matrix {
   ccol { {f over "aspect"} above 0 above 0 above 0 }
   ccol { 0 above f above 0 above 0 }
   ccol { 0 above 0 above {{"zFar" + "zNear"} over {"zNear" - "zFar"}} above
-1 }
   ccol { 0 above 0 above {{2 * "zFar" * "zNear"} over {"zNear" - "zFar"}}
above 0}
}}  ~~~ right )
.EN


The resulting conversation was not fruitful, with observations that groff's
output was worse than AIX troff's, but that the latter was pretty badly
damaged as well.

Nobody remarked on this at the time--perhaps our diagnostics have since gotten
better--but contemporary groff suggests whence some of the problems may
arise.


$ ./build/test-groff -Tutf8 -e EXPERIMENTS/bad_matrix.roff  | cat -s
troff:EXPERIMENTS/bad_matrix.roff:184: error: division by zero
troff:EXPERIMENTS/bad_matrix.roff:230: error: division by zero
The generated matrix is

               ⎝______ 0      0           0      ⎠
                   0   f      0           0
                   0   0 __________ _____________
                   0   0    −1            0


If we further turn on all warnings, we get this...


troff:EXPERIMENTS/bad_matrix.roff:185: warning: register '0temp' not defined


...which suggests to me that the evaluation of a numeric expression involving
zero division cancelled the register definition in progress.

Nobody ever promised that nroff-mode eqn output was going to look good (as far
as I can tell, eqn didn't even start getting written until typesetter roff was
in development--there was just no point bothering with line printers and
typewriters).  But if we can make eqn robust against zero divisors for
itself--particularly in generating them for itself--and fall back to some sane
value if a supposedly invariantly-existing temp register ends up missing,
maybe we can produce output that sucks less for the above input.




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?62298>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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